X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=skins%2FVector.php;h=96db057d34670276bdf71af92753b41db122244b;hb=d5a03b9d13c9c94f39129276440054167bdd273c;hp=42fdb39b7ed673f536106e38e838c7c0367d533a;hpb=8819185e28fb1c98fe69c5d72b008a38b782cb95;p=lhc%2Fweb%2Fwiklou.git diff --git a/skins/Vector.php b/skins/Vector.php index 42fdb39b7e..96db057d34 100644 --- a/skins/Vector.php +++ b/skins/Vector.php @@ -2,14 +2,15 @@ /** * Vector - Branch of MonoBook which has many usability improvements and * somewhat cleaner code. - * + * * @todo document * @file * @ingroup Skins */ -if( !defined( 'MEDIAWIKI' ) ) +if( !defined( 'MEDIAWIKI' ) ) { die( -1 ); +} /** * SkinTemplate class for Vector skin @@ -18,37 +19,59 @@ if( !defined( 'MEDIAWIKI' ) ) class SkinVector extends SkinTemplate { /* Functions */ + var $skinname = 'vector', $stylename = 'vector', + $template = 'VectorTemplate', $useHeadElement = true; /** * Initializes output page and sets up skin-specific parameters - * @param object $out Output page object to initialize + * @param $out OutputPage object to initialize */ public function initPage( OutputPage $out ) { + global $wgLocalStylePath; + parent::initPage( $out ); - $this->skinname = 'vector'; - $this->stylename = 'vector'; - $this->template = 'VectorTemplate'; + + // Append CSS which includes IE only behavior fixes for hover support - + // this is better than including this in a CSS fille since it doesn't + // wait for the CSS file to load before fetching the HTC file. + $out->addScript( + '' + ); } /** - * Defines CSS files to be included - * @param object $out Output page to add styles to + * Load skin and user CSS files in the correct order + * fixes bug 22916 + * @param $out OutputPage object */ - public function setupSkinUserCss( OutputPage $out ) { + function setupSkinUserCss( OutputPage $out ){ + global $wgVectorExtraStyles; + parent::setupSkinUserCss( $out ); - // Append to the default screen common & print styles... - $out->addStyle( 'vector/main.css', 'screen' ); + // Append skin-specific styles + $out->addStyle( 'vector/main-rtl.css', 'screen', '', 'rtl' ); + $out->addStyle( 'vector/main-ltr.css', 'screen', '', 'ltr' ); + + // Add extra stylesheets + // THIS IS ONLY USEFUL FOR EXPERIMENTING WITH DIFFERNT STYLE OPTIONS! THIS WILL BE REMOVED IN THE NEAR FUTURE. + if ( is_array( $wgVectorExtraStyles ) ) { + foreach ( $wgVectorExtraStyles as $style ) { + $out->addStyle( 'vector/' . $style, 'screen' ); + } + } } /** - * A structured array of edit links by default used for the tabs + * Builds a structured array of links used for tabs and menus * @return array * @private */ function buildNavigationUrls() { - global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest; - global $wgDisableLangConversion; + global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle; + global $wgDisableLangConversion, $wgVectorUseIconWatch; wfProfileIn( __METHOD__ ); @@ -65,7 +88,6 @@ class SkinVector extends SkinTemplate { // Checks if page is some kind of content if( $this->iscontent ) { - // Gets page objects for the related namespaces $subjectPage = $this->mTitle->getSubjectPage(); $talkPage = $this->mTitle->getTalkPage(); @@ -74,26 +96,30 @@ class SkinVector extends SkinTemplate { $isTalk = $this->mTitle->isTalkPage(); // Generates XML IDs from namespace names - $subjectId = $wgContLang->lc( $this->mTitle->getSubjectNsText() ); - if ( $subjectId == '' ) { - $subjectId = 'main'; + $subjectId = $this->mTitle->getNamespaceKey( '' ); + + if ( $subjectId == 'main' ) { + $talkId = 'talk'; + } else { + $talkId = "{$subjectId}_talk"; } - $talkId = "{$subjectId}_talk"; $currentId = $isTalk ? $talkId : $subjectId; // Adds namespace links $links['namespaces'][$subjectId] = $this->tabAction( - $subjectPage, 'nstab-' . $subjectId, !$isTalk, '', true + $subjectPage, 'vector-namespace-' . $subjectId, !$isTalk, '', true ); + $links['namespaces'][$subjectId]['context'] = 'subject'; $links['namespaces'][$talkId] = $this->tabAction( - $talkPage, 'talk', $isTalk, '', true + $talkPage, 'vector-namespace-talk', $isTalk, '', true ); + $links['namespaces'][$talkId]['context'] = 'talk'; // Adds view view link if ( $this->mTitle->exists() ) { $links['views']['view'] = $this->tabAction( $isTalk ? $talkPage : $subjectPage, - 'view', ( $action == 'view' ), '', true + 'vector-view-view', ( $action == 'view' ), '', true ); } @@ -121,34 +147,35 @@ class SkinVector extends SkinTemplate { $links['views']['edit'] = array( 'class' => ( $selected ? 'selected' : '' ) . $isTalkClass, 'text' => $this->mTitle->exists() - ? wfMsg( 'edit' ) - : wfMsg( 'create' ), + ? wfMsg( 'vector-view-edit' ) + : wfMsg( 'vector-view-create' ), 'href' => - $this->mTitle->getLocalUrl( $this->editUrlOptions() ) + $this->mTitle->getLocalURL( $this->editUrlOptions() ) ); - // Checks if this is a talk page and we should show a new + // Checks if this is a current rev of talk page and we should show a new // section link - if ( $isTalk || $wgOut->showNewSectionLink() ) { + if ( ( $isTalk && $wgArticle->isCurrent() ) || ( $wgOut->showNewSectionLink() ) ) { // Checks if we should ever show a new section link if ( !$wgOut->forceHideNewSectionLink() ) { // Adds new section link - $links['actions']['addsection'] = array( - 'class' => $section == 'new' ? 'selected' : false, - 'text' => wfMsg( 'addsection' ), - 'href' => $this->mTitle->getLocalUrl( + //$links['actions']['addsection'] + $links['views']['addsection'] = array( + 'class' => 'collapsible ' . ( $section == 'new' ? 'selected' : false ), + 'text' => wfMsg( 'vector-action-addsection' ), + 'href' => $this->mTitle->getLocalURL( 'action=edit§ion=new' ) ); } } - // Checks if the page is known (some kind of viewable content) - } elseif ( $this->mTitle->isKnown() ) { + // Checks if the page has some kind of viewable content + } elseif ( $this->mTitle->hasSourceText() ) { // Adds view source view link $links['views']['viewsource'] = array( 'class' => ( $action == 'edit' ) ? 'selected' : false, - 'text' => wfMsg( 'viewsource' ), + 'text' => wfMsg( 'vector-view-viewsource' ), 'href' => - $this->mTitle->getLocalUrl( $this->editUrlOptions() ) + $this->mTitle->getLocalURL( $this->editUrlOptions() ) ); } wfProfileOut( __METHOD__ . '-edit' ); @@ -159,17 +186,17 @@ class SkinVector extends SkinTemplate { if ( $this->mTitle->exists() ) { // Adds history view link $links['views']['history'] = array( - 'class' => ($action == 'history') ? 'selected' : false, - 'text' => wfMsg( 'history_short' ), - 'href' => $this->mTitle->getLocalUrl( 'action=history' ), + 'class' => 'collapsible ' . ( ( $action == 'history' ) ? 'selected' : false ), + 'text' => wfMsg( 'vector-view-history' ), + 'href' => $this->mTitle->getLocalURL( 'action=history' ), 'rel' => 'archives', ); if( $wgUser->isAllowed( 'delete' ) ) { $links['actions']['delete'] = array( - 'class' => ($action == 'delete') ? 'selected' : false, - 'text' => wfMsg( 'delete' ), - 'href' => $this->mTitle->getLocalUrl( 'action=delete' ) + 'class' => ( $action == 'delete' ) ? 'selected' : false, + 'text' => wfMsg( 'vector-action-delete' ), + 'href' => $this->mTitle->getLocalURL( 'action=delete' ) ); } if ( $this->mTitle->quickUserCan( 'move' ) ) { @@ -179,8 +206,8 @@ class SkinVector extends SkinTemplate { $links['actions']['move'] = array( 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, - 'text' => wfMsg( 'move' ), - 'href' => $moveTitle->getLocalUrl() + 'text' => wfMsg( 'vector-action-move' ), + 'href' => $moveTitle->getLocalURL() ); } @@ -188,22 +215,22 @@ class SkinVector extends SkinTemplate { $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { - if ( !$this->mTitle->isProtected() ){ + if ( !$this->mTitle->isProtected() ) { $links['actions']['protect'] = array( - 'class' => ($action == 'protect') ? + 'class' => ( $action == 'protect' ) ? 'selected' : false, - 'text' => wfMsg( 'protect' ), + 'text' => wfMsg( 'vector-action-protect' ), 'href' => - $this->mTitle->getLocalUrl( 'action=protect' ) + $this->mTitle->getLocalURL( 'action=protect' ) ); } else { $links['actions']['unprotect'] = array( - 'class' => ($action == 'unprotect') ? + 'class' => ( $action == 'unprotect' ) ? 'selected' : false, - 'text' => wfMsg( 'unprotect' ), + 'text' => wfMsg( 'vector-action-unprotect' ), 'href' => - $this->mTitle->getLocalUrl( 'action=unprotect' ) + $this->mTitle->getLocalURL( 'action=unprotect' ) ); } } @@ -218,11 +245,11 @@ class SkinVector extends SkinTemplate { $links['actions']['undelete'] = array( 'class' => false, 'text' => wfMsgExt( - 'undelete_short', + 'vector-action-undelete', array( 'parsemag' ), $wgLang->formatNum( $n ) ), - 'href' => $undelTitle->getLocalUrl( + 'href' => $undelTitle->getLocalURL( 'target=' . urlencode( $this->thispage ) ) ); @@ -235,55 +262,58 @@ class SkinVector extends SkinTemplate { ) { if ( !$this->mTitle->getRestrictions( 'create' ) ) { $links['actions']['protect'] = array( - 'class' => ($action == 'protect') ? + 'class' => ( $action == 'protect' ) ? 'selected' : false, - 'text' => wfMsg( 'protect' ), + 'text' => wfMsg( 'vector-action-protect' ), 'href' => - $this->mTitle->getLocalUrl( 'action=protect' ) + $this->mTitle->getLocalURL( 'action=protect' ) ); } else { $links['actions']['unprotect'] = array( - 'class' => ($action == 'unprotect') ? + 'class' => ( $action == 'unprotect' ) ? 'selected' : false, - 'text' => wfMsg( 'unprotect' ), + 'text' => wfMsg( 'vector-action-unprotect' ), 'href' => - $this->mTitle->getLocalUrl( 'action=unprotect' ) + $this->mTitle->getLocalURL( 'action=unprotect' ) ); } } } wfProfileOut( __METHOD__ . '-live' ); - + /** + * The following actions use messages which, if made particular to + * the Vector skin, would break the Ajax code which makes this + * action happen entirely inline. Skin::makeGlobalVariablesScript + * defines a set of messages in a javascript object - and these + * messages are assumed to be global for all skins. Without making + * a change to that procedure these messages will have to remain as + * the global versions. + */ // Checks if the user is logged in - if( $this->loggedin ) { - // Checks if the user is watching this page - if( !$this->mTitle->userIsWatching() ) { - // Adds watch action link - $links['actions']['watch'] = array( - 'class' => - ( $action == 'watch' or $action == 'unwatch' ) ? - 'selected' : false, - 'text' => wfMsg( 'watch' ), - 'href' => $this->mTitle->getLocalUrl( 'action=watch' ) - ); + if ( $this->loggedin ) { + if ( $wgVectorUseIconWatch ) { + $class = 'icon '; + $place = 'views'; } else { - // Adds unwatch action link - $links['actions']['unwatch'] = array( - 'class' => - ($action == 'unwatch' or $action == 'watch') ? - 'selected' : false, - 'text' => wfMsg( 'unwatch' ), - 'href' => $this->mTitle->getLocalUrl( 'action=unwatch' ) - ); + $class = ''; + $place = 'actions'; } + $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch'; + $links[$place][$mode] = array( + 'class' => $class . ( ( $action == 'watch' || $action == 'unwatch' ) ? ' selected' : false ), + 'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message + 'href' => $this->mTitle->getLocalURL( 'action=' . $mode ) + ); } + // This is instead of SkinTemplateTabs - which uses a flat array + wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$links ) ); // If it's not content, it's got to be a special page } else { $links['namespaces']['special'] = array( 'class' => 'selected', - 'text' => wfMsg( 'nstab-special' ), + 'text' => wfMsg( 'vector-namespace-special' ), 'href' => $wgRequest->getRequestURL() ); } @@ -295,7 +325,6 @@ class SkinVector extends SkinTemplate { // Gets preferred variant $preferred = $wgContLang->getPreferredVariant(); // Loops over each variant - $vcount = 0; foreach( $variants as $code ) { // Gets variant name from language code $varname = $wgContLang->getVariantname( $code ); @@ -305,12 +334,11 @@ class SkinVector extends SkinTemplate { continue; } // Appends variant link - $links['variants'][$vcount] = array( + $links['variants'][] = array( 'class' => ( $code == $preferred ) ? 'selected' : false, 'text' => $varname, 'href' => $this->mTitle->getLocalURL( '', $code ) ); - $vcount ++; } } @@ -339,39 +367,44 @@ class VectorTemplate extends QuickTemplate { * Outputs the entire contents of the XHTML page */ public function execute() { - global $wgRequest, $wgUseTwoButtonsSearchForm; + global $wgRequest, $wgOut, $wgContLang; $this->skin = $this->data['skin']; $action = $wgRequest->getText( 'action' ); - // Suppress warnings to prevent notices about missing indexes in - // $this->data (is this really the best way to handle this?) - wfSuppressWarnings(); - // Build additional attributes for navigation urls $nav = $this->skin->buildNavigationUrls(); foreach ( $nav as $section => $links ) { foreach ( $links as $key => $link ) { + $xmlID = $key; + if ( isset( $link['context'] ) && $link['context'] == 'subject' ) { + $xmlID = 'ca-nstab-' . $xmlID; + } else if ( isset( $link['context'] ) && $link['context'] == 'talk' ) { + $xmlID = 'ca-talk'; + } else { + $xmlID = 'ca-' . $xmlID; + } $nav[$section][$key]['attributes'] = - ' id="' . Sanitizer::escapeId( "ca-$key" ) . '"'; + ' id="' . Sanitizer::escapeId( $xmlID ) . '"'; if ( $nav[$section][$key]['class'] ) { $nav[$section][$key]['attributes'] .= ' class="' . htmlspecialchars( $link['class'] ) . '"'; + unset( $nav[$section][$key]['class'] ); } - // We don't want to give the watch tab an accesskey if the page is - // being edited, because that conflicts with the accesskey on the - // watch checkbox. We also don't want to give the edit tab an - // accesskey, because that's fairly superfluous and conflicts with - // an accesskey (Ctrl-E) often used for editing in Safari. + // We don't want to give the watch tab an accesskey if the page + // is being edited, because that conflicts with the accesskey on + // the watch checkbox. We also don't want to give the edit tab + // an accesskey, because that's fairly superfluous and conflicts + // with an accesskey (Ctrl-E) often used for editing in Safari. if ( in_array( $action, array( 'edit', 'submit' ) ) && in_array( $key, array( 'edit', 'watch', 'unwatch' ) ) ) { $nav[$section][$key]['key'] = - $this->skin->tooltip( "ca-$key" ); + $this->skin->tooltip( $xmlID ); } else { $nav[$section][$key]['key'] = - $this->skin->tooltipAndAccesskey( "ca-$key" ); + $this->skin->tooltipAndAccesskey( $xmlID ); } } } @@ -379,12 +412,11 @@ class VectorTemplate extends QuickTemplate { $this->data['view_urls'] = $nav['views']; $this->data['action_urls'] = $nav['actions']; $this->data['variant_urls'] = $nav['variants']; - // Build additional attributes for personal_urls foreach ( $this->data['personal_urls'] as $key => $item) { - $this->data['personal_urls'][$key]['attributes'] = + $this->data['personal_urls'][$key]['attributes'] = ' id="' . Sanitizer::escapeId( "pt-$key" ) . '"'; - if ( $item['active'] ) { + if ( isset( $item['active'] ) && $item['active'] ) { $this->data['personal_urls'][$key]['attributes'] .= ' class="active"'; } @@ -407,9 +439,16 @@ class VectorTemplate extends QuickTemplate { 'about', 'disclaimer', ), + 'icons' => array( + 'poweredbyico', + 'copyrightico', + ), ); - - // Build list of valid footer links + $footerlinksClasses = array( + 'icons' => array( 'noprint' ) + ); + + // Reduce footer links down to only those which are being used $validFooterLinks = array(); foreach( $footerlinks as $category => $links ) { $validFooterLinks[$category] = array(); @@ -419,366 +458,199 @@ class VectorTemplate extends QuickTemplate { } } } - - // Begin content output -?> -data['xhtmlnamespaces'] as $tag => $ns): ?>xmlns:xml:lang="text('lang') ?>" lang="text('lang') ?>" dir="text('dir') ?>"> - - - <?php $this->text('pagetitle') ?> - - html('headlinks') ?> - - - html('csslinks') ?> - - - - - - data ); ?> - - - - - - html('headscripts') ?> - - data['jsvarurl']): ?> - - - - - data['pagecss']): ?> - - - - - data['usercss']): ?> - - - - - data['userjs']): ?> - - - - - data['userjsprev']): ?> - - - - - data['trackbackhtml']): ?> - - data['trackbackhtml']; ?> - - - - data['body_ondblclick']): ?> ondblclick="text('body_ondblclick') ?>" data['body_onload']): ?> onload="text('body_onload') ?>" class="mediawiki text('dir') ?> text('pageclass') ?> text('skinnameclass') ?>"> -
-
- -
- -
-
- - - data['sitenotice']) { ?>
html('sitenotice') ?>
- - -

html('title') ?>

- - -
- -

msg('tagline') ?>

- - -
html('subtitle') ?>
- - data['undelete']): ?> - -
html('undelete') ?>
- - - data['newtalk'] ): ?> - -
html('newtalk') ?>
- - - data['showjumplinks']): ?> - - - - - - html('bodytext') ?> - - - data['catlinks']) { $this->html('catlinks'); } ?> - - - data['dataAfterContent']) { $this->html('dataAfterContent'); } ?> - -
-
- + // Reverse horizontally rendered navigation elements + if ( $wgContLang->isRTL() ) { + $this->data['view_urls'] = + array_reverse( $this->data['view_urls'] ); + $this->data['namespace_urls'] = + array_reverse( $this->data['namespace_urls'] ); + $this->data['personal_urls'] = + array_reverse( $this->data['personal_urls'] ); + } + // Output HTML Page + $this->html( 'headelement' ); +?> +
+
+ +
html('specialpageattributes') ?>> + + + data['sitenotice'] ): ?> + +
html( 'sitenotice' ) ?>
+ + + +

html( 'title' ) ?>

+ + +
+ +

msg( 'tagline' ) ?>

+ + +
html('userlangattributes') ?>>html( 'subtitle' ) ?>
+ + data['undelete'] ): ?> + +
html( 'undelete' ) ?>
+ + + data['newtalk'] ): ?> + +
html( 'newtalk' ) ?>
+ + + data['showjumplinks'] ): ?> + + + + + + html( 'bodytext' ) ?> + + data['catlinks'] ): ?> + + html( 'catlinks' ); ?> + + + data['dataAfterContent'] ): ?> + + html( 'dataAfterContent' ); ?> + + +
- - - + + +
+ renderNavigation( 'PERSONAL' ); ?> +
+ renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
- - -
-
- - - - - data['sidebar']; - $sidebar['TOOLBOX'] = ( !isset( $sidebar['TOOLBOX'] ) ); - $sidebar['LANGUAGES'] = ( !isset( $sidebar['LANGUAGES'] ) ); - foreach ( $sidebar as $name => $content ) { - switch( $name ) { - case 'SEARCH': - break; - case 'TOOLBOX': - $this->toolBox(); - break; - case 'LANGUAGES': - $this->languageBox(); - break; - default: - $this->customBox( $name, $content ); - break; - } - } - ?> - -
+
+ renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
- -
- - - -
- - - - + + + + html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?> html( 'reporttime' ) ?> data['debug'] ): ?> - + $content ) { + echo "\n\n"; + switch( $name ) { + case 'SEARCH': + break; + case 'TOOLBOX': ?> -
-
html('userlangattributes') ?>>msg( 'toolbox' ) ?>
-
-
+
data['language_urls'] ) { + break; + case 'LANGUAGES': + if ( $this->data['language_urls'] ) { ?>
-
html('userlangattributes') ?>>msg( 'otherlanguages' ) ?>
+ html('userlangattributes') ?>>msg( 'otherlanguages' ) ?>
    data['language_urls'] as $langlink ): ?> -
  • +
-
skin->tooltip( 'p-' . $bar ) ?>> -
html('userlangattributes') ?>>
+
skin->tooltip( 'p-' . $name ) ?>> + html('userlangattributes') ?>>
    @@ -792,5 +664,127 @@ class VectorTemplate extends QuickTemplate {
\n"; + } + } + + /** + * Render one or more navigations elements by name, automatically reveresed + * when UI is in RTL mode + */ + private function renderNavigation( $elements ) { + global $wgContLang, $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser; + + // If only one element was given, wrap it in an array, allowing more + // flexible arguments + if ( !is_array( $elements ) ) { + $elements = array( $elements ); + // If there's a series of elements, reverse them when in RTL mode + } else if ( $wgContLang->isRTL() ) { + $elements = array_reverse( $elements ); + } + // Render elements + foreach ( $elements as $name => $element ) { + echo "\n\n"; + switch ( $element ) { + case 'NAMESPACES': +?> +
+
msg('namespaces') ?>
+ html('userlangattributes') ?>> + data['namespace_urls'] as $key => $link ): ?> +
  • >>
  • + + +
    + +
    + +

    + data['variant_urls'] as $key => $link ): ?> + + + + +

    + +
    msg('variants') ?>
    + +
    + +
    +
    msg('views') ?>
    + html('userlangattributes') ?>> + data['view_urls'] as $key => $link ): ?> + >>' : ''.htmlspecialchars( $link['text'] ).'') ?> + + +
    + +
    +
    msg('actions') ?>
    + +
    + +
    +
    msg('personaltools') ?>
    + html('userlangattributes') ?>> + data['personal_urls'] as $key => $item): ?> +
  • > class="">
  • + + +
    + + +\n"; + } } }