}
/**
- * TODO document
- * @param $title Title
- * @param $message String message key
- * @param $selected Bool
- * @param $query String
- * @param $checkEdit Bool
+ * Builds an array with tab definition
+ *
+ * @param Title $title page where the tab links to
+ * @param string|array $message message key or an array of message keys (will fall back)
+ * @param boolean $selected display the tab as selected
+ * @param string $query query string attached to tab URL
+ * @param boolean $checkEdit check if $title exists and mark with .new if one doesn't
+ *
* @return array
*/
function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
}
if( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
- $query = 'action=edit&redlink=1';
+ if ( $query !== '' ) {
+ $query = 'action=edit&redlink=1&' . $query;
+ } else {
+ $query = 'action=edit&redlink=1';
+ }
}
// wfMessageFallback will nicely accept $message as an array of fallbacks
// Gets preferred variant (note that user preference is
// only possible for wiki content language variant)
$preferred = $pageLang->getPreferredVariant();
+ if ( Action::getActionName( $this ) === 'view' ) {
+ $params = $request->getQueryValues();
+ unset( $params['title'] );
+ } else {
+ $params = array();
+ }
// Loops over each variant
foreach( $variants as $code ) {
// Gets variant name from language code
$content_navigation['variants'][] = array(
'class' => ( $code == $preferred ) ? 'selected' : false,
'text' => $varname,
- 'href' => $title->getLocalURL( array( 'variant' => $code ) ),
+ 'href' => $title->getLocalURL( array( 'variant' => $code ) + $params ),
'lang' => $code,
'hreflang' => $code
);