Also set the queue types map when rebuilding the ready queue map
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 24854d8..86bd979 100644 (file)
  * @private
  * @ingroup Skins
  */
-class MediaWiki_I18N {
-       var $_context = array();
+class MediaWikiI18N {
+       private $context = array();
 
        function set( $varName, $value ) {
-               $this->_context[$varName] = $value;
+               $this->context[$varName] = $value;
        }
 
        function translate( $value ) {
@@ -46,7 +46,7 @@ class MediaWiki_I18N {
                while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
                        list( $src, $var ) = $m;
                        wfSuppressWarnings();
-                       $varValue = $this->_context[$var];
+                       $varValue = $this->context[$var];
                        wfRestoreWarnings();
                        $value = str_replace( $src, $varValue, $value );
                }
@@ -68,35 +68,23 @@ class MediaWiki_I18N {
  * @ingroup Skins
  */
 class SkinTemplate extends Skin {
-       /**#@+
-        * @private
-        */
-
-       /**
-        * Name of our skin, it probably needs to be all lower case.  Child classes
-        * should override the default.
-        */
-       var $skinname = 'monobook';
-
        /**
-        * Stylesheets set to use.  Subdirectory in skins/ where various stylesheets
-        * are located.  Child classes should override the default.
+        * @var string Name of our skin, it probably needs to be all lower case.
+        *   Child classes should override the default.
         */
-       var $stylename = 'monobook';
+       public $skinname = 'monobook';
 
        /**
-        * For QuickTemplate, the name of the subclass which will actually fill the
-        * template.  Child classes should override the default.
+        * @var string Stylesheets set to use. Subdirectory in skins/ where various
+        *   stylesheets are located.  Child classes should override the default.
         */
-       var $template = 'QuickTemplate';
+       public $stylename = 'monobook';
 
        /**
-        * Whether this skin use OutputPage::headElement() to generate the "<head>"
-        * tag
+        * @var string For QuickTemplate, the name of the subclass which will
+        *   actually fill the template.  Child classes should override the default.
         */
-       var $useHeadElement = false;
-
-       /**#@-*/
+       public $template = 'QuickTemplate';
 
        /**
         * Add specific styles for this skin
@@ -117,8 +105,8 @@ class SkinTemplate extends Skin {
         * roughly equivalent to PHPTAL 0.7.
         *
         * @param string $classname
-        * @param string $repository Subdirectory where we keep template files
-        * @param string $cache_dir
+        * @param bool|string $repository Subdirectory where we keep template files
+        * @param bool|string $cache_dir
         * @return QuickTemplate
         * @private
         */
@@ -187,7 +175,10 @@ class SkinTemplate extends Skin {
                                        'lang' => $ilInterwikiCodeBCP47,
                                        'hreflang' => $ilInterwikiCodeBCP47,
                                );
-                               wfRunHooks( 'SkinTemplateGetLanguageLink', array( &$languageLink, $languageLinkTitle, $this->getTitle() ) );
+                               wfRunHooks(
+                                       'SkinTemplateGetLanguageLink',
+                                       array( &$languageLink, $languageLinkTitle, $this->getTitle() )
+                               );
                                $languageLinks[] = $languageLink;
                        }
                }
@@ -293,26 +284,6 @@ class SkinTemplate extends Skin {
                $out = $this->getOutput();
                $tpl = $this->setupTemplateForOutput();
 
-               wfProfileIn( __METHOD__ . '-stuff-head' );
-               if ( !$this->useHeadElement ) {
-                       $tpl->set( 'pagecss', false );
-                       $tpl->set( 'usercss', false );
-
-                       $tpl->set( 'userjs', false );
-                       $tpl->set( 'userjsprev', false );
-
-                       $tpl->set( 'jsvarurl', false );
-
-                       $tpl->set( 'xhtmldefaultnamespace', 'http://www.w3.org/1999/xhtml' );
-                       $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
-                       $tpl->set( 'html5version', $wgHtml5Version );
-                       $tpl->set( 'headlinks', $out->getHeadLinks() );
-                       $tpl->set( 'csslinks', $out->buildCssLinks() );
-                       $tpl->set( 'pageclass', $this->getPageClasses( $title ) );
-                       $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
-               }
-               wfProfileOut( __METHOD__ . '-stuff-head' );
-
                wfProfileIn( __METHOD__ . '-stuff2' );
                $tpl->set( 'title', $out->getPageTitle() );
                $tpl->set( 'pagetitle', $out->getHTMLTitle() );
@@ -402,7 +373,8 @@ class SkinTemplate extends Skin {
                // that interface elements are in a different language.
                $tpl->set( 'userlangattributes', '' );
                $tpl->set( 'specialpageattributes', '' ); # obsolete
-               // Used by VectorBeta to insert HTML before content but after the heading for the page title. Defaults to empty string.
+               // Used by VectorBeta to insert HTML before content but after the
+               // heading for the page title. Defaults to empty string.
                $tpl->set( 'prebodyhtml', '' );
 
                if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) {
@@ -542,11 +514,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'nav_urls', $this->buildNavUrls() );
 
                // Set the head scripts near the end, in case the above actions resulted in added scripts
-               if ( $this->useHeadElement ) {
-                       $tpl->set( 'headelement', $out->headElement( $this ) );
-               } else {
-                       $tpl->set( 'headscripts', $out->getHeadScripts() . $out->getHeadItems() );
-               }
+               $tpl->set( 'headelement', $out->headElement( $this ) );
 
                $tpl->set( 'debug', '' );
                $tpl->set( 'debughtml', $this->generateDebugHTML() );
@@ -561,9 +529,14 @@ class SkinTemplate extends Skin {
                // and output printfooter and debughtml separately
                $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
 
-               // Append printfooter and debughtml onto bodytext so that skins that were already
-               // using bodytext before they were split out don't suddenly start not outputting information
-               $tpl->data['bodytext'] .= Html::rawElement( 'div', array( 'class' => 'printfooter' ), "\n{$tpl->data['printfooter']}" ) . "\n";
+               // Append printfooter and debughtml onto bodytext so that skins that
+               // were already using bodytext before they were split out don't suddenly
+               // start not outputting information.
+               $tpl->data['bodytext'] .= Html::rawElement(
+                       'div',
+                       array( 'class' => 'printfooter' ),
+                       "\n{$tpl->data['printfooter']}"
+               ) . "\n";
                $tpl->data['bodytext'] .= $tpl->data['debughtml'];
 
                // allow extensions adding stuff after the page content.
@@ -733,7 +706,8 @@ class SkinTemplate extends Skin {
                        $login_url = array(
                                'text' => $this->msg( $loginlink )->text(),
                                'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
-                               'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
+                               'active' => $title->isSpecial( 'Userlogin' )
+                                       && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
                        );
                        $createaccount_url = array(
                                'text' => $this->msg( 'pt-createaccount' )->text(),
@@ -875,9 +849,10 @@ class SkinTemplate extends Skin {
         * links, however these are usually automatically generated by SkinTemplate
         * itself and are not necessary when using a hook. The only things these may
         * matter to are people modifying content_navigation after it's initial creation:
-        * - id: A "preferred" id, most skins are best off outputting this preferred id for best compatibility
+        * - id: A "preferred" id, most skins are best off outputting this preferred
+        *   id for best compatibility.
         * - tooltiponly: This is set to true for some tabs in cases where the system
-        *                believes that the accesskey should not be added to the tab.
+        *   believes that the accesskey should not be added to the tab.
         *
         * @return array
         */
@@ -974,7 +949,9 @@ class SkinTemplate extends Skin {
                                wfProfileIn( __METHOD__ . '-edit' );
 
                                // Checks if user can edit the current page if it exists or create it otherwise
-                               if ( $title->quickUserCan( 'edit', $user ) && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) ) {
+                               if ( $title->quickUserCan( 'edit', $user )
+                                       && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
+                               ) {
                                        // Builds CSS class for talk page links
                                        $isTalkClass = $isTalk ? ' istalk' : '';
                                        // Whether the user is editing the page
@@ -985,14 +962,22 @@ class SkinTemplate extends Skin {
                                                && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
                                        $section = $request->getVal( 'section' );
 
-                                       if ( $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ) {
+                                       if ( $title->exists()
+                                               || ( $title->getNamespace() == NS_MEDIAWIKI
+                                                       && $title->getDefaultMessageText() !== false
+                                               )
+                                       ) {
                                                $msgKey = $isForeignFile ? 'edit-local' : 'edit';
                                        } else {
                                                $msgKey = $isForeignFile ? 'create-local' : 'create';
                                        }
                                        $content_navigation['views']['edit'] = array(
-                                               'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass,
-                                               'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(),
+                                               'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
+                                                       ? 'selected'
+                                                       : ''
+                                               ) . $isTalkClass,
+                                               'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
+                                                       ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( $this->editUrlOptions() ),
                                                'primary' => !$isForeignFile, // don't collapse this in vector
                                        );
@@ -1003,7 +988,8 @@ class SkinTemplate extends Skin {
                                                //$content_navigation['actions']['addsection']
                                                $content_navigation['views']['addsection'] = array(
                                                        'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
-                                                       'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(),
+                                                       'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
+                                                               ->setContext( $this->getContext() )->text(),
                                                        'href' => $title->getLocalURL( 'action=edit&section=new' )
                                                );
                                        }
@@ -1012,7 +998,8 @@ class SkinTemplate extends Skin {
                                        // Adds view source view link
                                        $content_navigation['views']['viewsource'] = array(
                                                'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
-                                               'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->setContext( $this->getContext() )->text(),
+                                               'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
+                                                       ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( $this->editUrlOptions() ),
                                                'primary' => true, // don't collapse this in vector
                                        );
@@ -1025,7 +1012,8 @@ class SkinTemplate extends Skin {
                                        // Adds history view link
                                        $content_navigation['views']['history'] = array(
                                                'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
-                                               'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->setContext( $this->getContext() )->text(),
+                                               'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
+                                                       ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( 'action=history' ),
                                                'rel' => 'archives',
                                        );
@@ -1033,7 +1021,8 @@ class SkinTemplate extends Skin {
                                        if ( $title->quickUserCan( 'delete', $user ) ) {
                                                $content_navigation['actions']['delete'] = array(
                                                        'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
-                                                       'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->setContext( $this->getContext() )->text(),
+                                                       'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
+                                                               ->setContext( $this->getContext() )->text(),
                                                        'href' => $title->getLocalURL( 'action=delete' )
                                                );
                                        }
@@ -1042,7 +1031,8 @@ class SkinTemplate extends Skin {
                                                $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
                                                $content_navigation['actions']['move'] = array(
                                                        'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
-                                                       'text' => wfMessageFallback( "$skname-action-move", 'move' )->setContext( $this->getContext() )->text(),
+                                                       'text' => wfMessageFallback( "$skname-action-move", 'move' )
+                                                               ->setContext( $this->getContext() )->text(),
                                                        'href' => $moveTitle->getLocalURL()
                                                );
                                        }
@@ -1052,7 +1042,8 @@ class SkinTemplate extends Skin {
                                                $n = $title->isDeleted();
                                                if ( $n ) {
                                                        $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
-                                                       // If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
+                                                       // If the user can't undelete but can view deleted
+                                                       // history show them a "View .. deleted" tab instead.
                                                        $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
                                                        $content_navigation['actions']['undelete'] = array(
                                                                'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
@@ -1070,7 +1061,8 @@ class SkinTemplate extends Skin {
                                        $mode = $title->isProtected() ? 'unprotect' : 'protect';
                                        $content_navigation['actions'][$mode] = array(
                                                'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
-                                               'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(),
+                                               'text' => wfMessageFallback( "$skname-action-$mode", $mode )
+                                                       ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( "action=$mode" )
                                        );
                                }
@@ -1190,10 +1182,10 @@ class SkinTemplate extends Skin {
 
        /**
         * an array of edit links by default used for the tabs
+        * @param $content_navigation
         * @return array
-        * @private
         */
-       function buildContentActionUrls( $content_navigation ) {
+       private function buildContentActionUrls( $content_navigation ) {
 
                wfProfileIn( __METHOD__ );
 
@@ -1204,9 +1196,7 @@ class SkinTemplate extends Skin {
                $content_actions = array();
 
                foreach ( $content_navigation as $links ) {
-
                        foreach ( $links as $key => $value ) {
-
                                if ( isset( $value['redundant'] ) && $value['redundant'] ) {
                                        // Redundant tabs are dropped from content_actions
                                        continue;
@@ -1227,9 +1217,7 @@ class SkinTemplate extends Skin {
                                }
 
                                $content_actions[$key] = $value;
-
                        }
-
                }
 
                wfProfileOut( __METHOD__ );
@@ -1240,7 +1228,6 @@ class SkinTemplate extends Skin {
        /**
         * build array of common navigation links
         * @return array
-        * @private
         */
        protected function buildNavUrls() {
                global $wgUploadNavigationUrl;
@@ -1357,9 +1344,8 @@ class SkinTemplate extends Skin {
        /**
         * Generate strings used for xml 'id' names
         * @return string
-        * @private
         */
-       function getNameSpaceKey() {
+       protected function getNameSpaceKey() {
                return $this->getTitle()->getNamespaceKey();
        }
 }
@@ -1375,7 +1361,7 @@ abstract class QuickTemplate {
         */
        function __construct() {
                $this->data = array();
-               $this->translator = new MediaWiki_I18N();
+               $this->translator = new MediaWikiI18N();
        }
 
        /**
@@ -1411,7 +1397,7 @@ abstract class QuickTemplate {
        }
 
        /**
-        * @param MediaWiki_I18N $t
+        * @param MediaWikiI18N $t
         */
        public function setTranslator( &$t ) {
                $this->translator = &$t;
@@ -1556,11 +1542,15 @@ abstract class BaseTemplate extends QuickTemplate {
                wfProfileIn( __METHOD__ );
 
                $toolbox = array();
-               if ( isset( $this->data['nav_urls']['whatlinkshere'] ) && $this->data['nav_urls']['whatlinkshere'] ) {
+               if ( isset( $this->data['nav_urls']['whatlinkshere'] )
+                       && $this->data['nav_urls']['whatlinkshere']
+               ) {
                        $toolbox['whatlinkshere'] = $this->data['nav_urls']['whatlinkshere'];
                        $toolbox['whatlinkshere']['id'] = 't-whatlinkshere';
                }
-               if ( isset( $this->data['nav_urls']['recentchangeslinked'] ) && $this->data['nav_urls']['recentchangeslinked'] ) {
+               if ( isset( $this->data['nav_urls']['recentchangeslinked'] )
+                       && $this->data['nav_urls']['recentchangeslinked']
+               ) {
                        $toolbox['recentchangeslinked'] = $this->data['nav_urls']['recentchangeslinked'];
                        $toolbox['recentchangeslinked']['msg'] = 'recentchangeslinked-toolbox';
                        $toolbox['recentchangeslinked']['id'] = 't-recentchangeslinked';
@@ -1576,7 +1566,9 @@ abstract class BaseTemplate extends QuickTemplate {
                                $toolbox['feeds']['links'][$key]['class'] = 'feedlink';
                        }
                }
-               foreach ( array( 'contributions', 'log', 'blockip', 'emailuser', 'userrights', 'upload', 'specialpages' ) as $special ) {
+               foreach ( array( 'contributions', 'log', 'blockip', 'emailuser',
+                       'userrights', 'upload', 'specialpages' ) as $special
+               ) {
                        if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) {
                                $toolbox[$special] = $this->data['nav_urls'][$special];
                                $toolbox[$special]['id'] = "t-$special";
@@ -1844,7 +1836,9 @@ abstract class BaseTemplate extends QuickTemplate {
                        }
                        while ( count( $wrapper ) > 0 ) {
                                $element = array_pop( $wrapper );
-                               $html = Html::rawElement( $element['tag'], isset( $element['attributes'] ) ? $element['attributes'] : null, $html );
+                               $html = Html::rawElement( $element['tag'], isset( $element['attributes'] )
+                                       ? $element['attributes']
+                                       : null, $html );
                        }
                }
 
@@ -1880,7 +1874,9 @@ abstract class BaseTemplate extends QuickTemplate {
                                        $attrs['class'] = $options['link-class'];
                                }
                        }
-                       $html = Html::rawElement( isset( $attrs['href'] ) ? 'a' : $options['link-fallback'], $attrs, $html );
+                       $html = Html::rawElement( isset( $attrs['href'] )
+                               ? 'a'
+                               : $options['link-fallback'], $attrs, $html );
                }
 
                return $html;
@@ -2016,6 +2012,7 @@ abstract class BaseTemplate extends QuickTemplate {
         * If you pass "flat" as an option then the returned array will be a flat array
         * of footer icons instead of a key/value array of footerlinks arrays broken
         * up into categories.
+        * @param string $option
         * @return array|mixed
         */
        function getFooterLinks( $option = null ) {
@@ -2055,6 +2052,7 @@ abstract class BaseTemplate extends QuickTemplate {
         * in the list of footer icons. This is mostly useful for skins which only
         * display the text from footericons instead of the images and don't want a
         * duplicate copyright statement because footerlinks already rendered one.
+        * @param string $option
         * @return string
         */
        function getFooterIcons( $option = null ) {
@@ -2097,5 +2095,4 @@ abstract class BaseTemplate extends QuickTemplate {
 <?php $this->html( 'reporttime' ) ?>
 <?php
        }
-
 }