X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=skins%2FVector.php;h=3479ba58f7941a2f2ec503f82e0a74fcb031ecc7;hb=25b3c477503a47d5b20023c5a07b336474a12749;hp=a5b0117c68906cc80fd5f02bb80e808d53b10eba;hpb=ccf173c37667e1447dc291e8f226ed22cca00aec;p=lhc%2Fweb%2Fwiklou.git diff --git a/skins/Vector.php b/skins/Vector.php index a5b0117c68..3479ba58f7 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,42 +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 ) { - global $wgContLang; - // Append to the default screen common & print styles... - if ( $wgContLang->isRTL() ) { - $out->addStyle( 'vector/main-rtl.css', 'screen' ); - } else { - $out->addStyle( 'vector/main-ltr.css', 'screen' ); - } - // Add common styles + function setupSkinUserCss( OutputPage $out ){ + global $wgVectorExtraStyles; + parent::setupSkinUserCss( $out ); + + // Append skin-specific styles + $out->addStyle( "{$this->stylename}/main-rtl.css", 'screen', '', 'rtl' ); + $out->addStyle( "{$this->stylename}/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, $wgArticle; - global $wgDisableLangConversion; + global $wgDisableLangConversion, $wgVectorUseIconWatch; wfProfileIn( __METHOD__ ); @@ -63,14 +81,13 @@ class SkinVector extends SkinTemplate { 'actions' => array(), 'variants' => array() ); - + // Detects parameters $action = $wgRequest->getVal( 'action', 'view' ); $section = $wgRequest->getVal( 'section' ); // 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(); @@ -80,14 +97,13 @@ class SkinVector extends SkinTemplate { // Generates XML IDs from namespace names $subjectId = $this->mTitle->getNamespaceKey( '' ); - + if ( $subjectId == 'main' ) { $talkId = 'talk'; } else { $talkId = "{$subjectId}_talk"; } - $currentId = $isTalk ? $talkId : $subjectId; - + // Adds namespace links $links['namespaces'][$subjectId] = $this->tabAction( $subjectPage, 'vector-namespace-' . $subjectId, !$isTalk, '', true @@ -97,7 +113,7 @@ class SkinVector extends SkinTemplate { $talkPage, 'vector-namespace-talk', $isTalk, '', true ); $links['namespaces'][$talkId]['context'] = 'talk'; - + // Adds view view link if ( $this->mTitle->exists() ) { $links['views']['view'] = $this->tabAction( @@ -105,9 +121,9 @@ class SkinVector extends SkinTemplate { 'vector-view-view', ( $action == 'view' ), '', true ); } - + wfProfileIn( __METHOD__ . '-edit' ); - + // Checks if user can... if ( // edit the current page @@ -133,7 +149,7 @@ class SkinVector extends SkinTemplate { ? wfMsg( 'vector-view-edit' ) : wfMsg( 'vector-view-create' ), 'href' => - $this->mTitle->getLocalUrl( $this->editUrlOptions() ) + $this->mTitle->getLocalURL( $this->editUrlOptions() ) ); // Checks if this is a current rev of talk page and we should show a new // section link @@ -141,23 +157,24 @@ class SkinVector extends SkinTemplate { // 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, + //$links['actions']['addsection'] + $links['views']['addsection'] = array( + 'class' => 'collapsible ' . ( $section == 'new' ? 'selected' : false ), 'text' => wfMsg( 'vector-action-addsection' ), - 'href' => $this->mTitle->getLocalUrl( + '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( 'vector-view-viewsource' ), 'href' => - $this->mTitle->getLocalUrl( $this->editUrlOptions() ) + $this->mTitle->getLocalURL( $this->editUrlOptions() ) ); } wfProfileOut( __METHOD__ . '-edit' ); @@ -168,17 +185,17 @@ class SkinVector extends SkinTemplate { if ( $this->mTitle->exists() ) { // Adds history view link $links['views']['history'] = array( - 'class' => ($action == 'history') ? 'selected' : false, + 'class' => 'collapsible ' . ( ( $action == 'history' ) ? 'selected' : false ), 'text' => wfMsg( 'vector-view-history' ), - 'href' => $this->mTitle->getLocalUrl( 'action=history' ), + 'href' => $this->mTitle->getLocalURL( 'action=history' ), 'rel' => 'archives', ); if( $wgUser->isAllowed( 'delete' ) ) { $links['actions']['delete'] = array( - 'class' => ($action == 'delete') ? 'selected' : false, + 'class' => ( $action == 'delete' ) ? 'selected' : false, 'text' => wfMsg( 'vector-action-delete' ), - 'href' => $this->mTitle->getLocalUrl( 'action=delete' ) + 'href' => $this->mTitle->getLocalURL( 'action=delete' ) ); } if ( $this->mTitle->quickUserCan( 'move' ) ) { @@ -189,7 +206,7 @@ class SkinVector extends SkinTemplate { 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, 'text' => wfMsg( 'vector-action-move' ), - 'href' => $moveTitle->getLocalUrl() + 'href' => $moveTitle->getLocalURL() ); } @@ -197,22 +214,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( '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( 'vector-action-unprotect' ), 'href' => - $this->mTitle->getLocalUrl( 'action=unprotect' ) + $this->mTitle->getLocalURL( 'action=unprotect' ) ); } } @@ -231,7 +248,7 @@ class SkinVector extends SkinTemplate { array( 'parsemag' ), $wgLang->formatNum( $n ) ), - 'href' => $undelTitle->getLocalUrl( + 'href' => $undelTitle->getLocalURL( 'target=' . urlencode( $this->thispage ) ) ); @@ -244,26 +261,25 @@ class SkinVector extends SkinTemplate { ) { if ( !$this->mTitle->getRestrictions( 'create' ) ) { $links['actions']['protect'] = array( - 'class' => ($action == 'protect') ? + 'class' => ( $action == 'protect' ) ? 'selected' : false, '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( '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 @@ -274,32 +290,24 @@ class SkinVector extends SkinTemplate { * 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( @@ -316,7 +324,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 ); @@ -326,12 +333,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 ++; } } @@ -360,15 +366,11 @@ class VectorTemplate extends QuickTemplate { * Outputs the entire contents of the XHTML page */ public function execute() { - global $wgRequest, $wgUseTwoButtonsSearchForm; + global $wgRequest, $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 ) { @@ -386,12 +388,13 @@ class VectorTemplate extends QuickTemplate { 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' ) ) @@ -408,12 +411,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"'; } @@ -436,9 +438,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(); @@ -448,347 +457,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') ?>"> -
-
+ // 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'] ): ?> - data['sitenotice']) { ?>
html('sitenotice') ?>
+
html( 'sitenotice' ) ?>
+ -

html('title') ?>

+

html( 'title' ) ?>

-

msg('tagline') ?>

+
msg( 'tagline' ) ?>
-
html('subtitle') ?>
+
html('userlangattributes') ?>>html( 'subtitle' ) ?>
- data['undelete']): ?> + data['undelete'] ): ?> -
html('undelete') ?>
+
html( 'undelete' ) ?>
data['newtalk'] ): ?> -
html('newtalk') ?>
+
html( 'newtalk' ) ?>
- data['showjumplinks']): ?> + data['showjumplinks'] ): ?> - html('bodytext') ?> + html( 'bodytext' ) ?> + data['catlinks'] ): ?> - data['catlinks']) { $this->html('catlinks'); } ?> + html( 'catlinks' ); ?> + + data['dataAfterContent'] ): ?> - data['dataAfterContent']) { $this->html('dataAfterContent'); } ?> + html( 'dataAfterContent' ); ?> +
-