Merge "Provide month names via mediawiki.language.months RL module"
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 8e41b5a..2739df3 100644 (file)
@@ -165,39 +165,14 @@ class SkinTemplate extends Skin {
                return $language_urls;
        }
 
-       /**
-        * initialize various variables and generate the template
-        *
-        * @param $out OutputPage
-        */
-       function outputPage( OutputPage $out = null ) {
-               global $wgContLang;
-               global $wgScript, $wgStylePath;
-               global $wgMimeType, $wgJsMimeType;
-               global $wgXhtmlNamespaces, $wgHtml5Version;
-               global $wgDisableCounters, $wgSitename, $wgLogo;
-               global $wgMaxCredits, $wgShowCreditsIfMax;
-               global $wgPageShowWatchingUsers;
-               global $wgArticlePath, $wgScriptPath, $wgServer;
-
+       protected function setupTemplateForOutput() {
                wfProfileIn( __METHOD__ );
-               Profiler::instance()->setTemplated( true );
 
-               $oldContext = null;
-               if ( $out !== null ) {
-                       // @todo Add wfDeprecated in 1.20
-                       $oldContext = $this->getContext();
-                       $this->setContext( $out->getContext() );
-               }
-
-               $out = $this->getOutput();
                $request = $this->getRequest();
                $user = $this->getUser();
                $title = $this->getTitle();
 
                wfProfileIn( __METHOD__ . '-init' );
-               $this->initPage( $out );
-
                $tpl = $this->setupTemplate( $this->template, 'skins' );
                wfProfileOut( __METHOD__ . '-init' );
 
@@ -226,6 +201,47 @@ class SkinTemplate extends Skin {
 
                wfProfileOut( __METHOD__ . '-stuff' );
 
+               wfProfileOut( __METHOD__ );
+
+               return $tpl;
+       }
+
+       /**
+        * initialize various variables and generate the template
+        *
+        * @param $out OutputPage
+        */
+       function outputPage( OutputPage $out = null ) {
+               global $wgContLang;
+               global $wgScript, $wgStylePath;
+               global $wgMimeType, $wgJsMimeType;
+               global $wgXhtmlNamespaces, $wgHtml5Version;
+               global $wgDisableCounters, $wgSitename, $wgLogo;
+               global $wgMaxCredits, $wgShowCreditsIfMax;
+               global $wgPageShowWatchingUsers;
+               global $wgArticlePath, $wgScriptPath, $wgServer;
+
+               wfProfileIn( __METHOD__ );
+               Profiler::instance()->setTemplated( true );
+
+               $oldContext = null;
+               if ( $out !== null ) {
+                       // @todo Add wfDeprecated in 1.20
+                       $oldContext = $this->getContext();
+                       $this->setContext( $out->getContext() );
+               }
+
+               $out = $this->getOutput();
+               $request = $this->getRequest();
+               $user = $this->getUser();
+               $title = $this->getTitle();
+
+               wfProfileIn( __METHOD__ . '-init' );
+               $this->initPage( $out );
+               wfProfileOut( __METHOD__ . '-init' );
+
+               $tpl = $this->setupTemplateForOutput();
+
                wfProfileIn( __METHOD__ . '-stuff-head' );
                if ( !$this->useHeadElement ) {
                        $tpl->set( 'pagecss', false );
@@ -275,6 +291,7 @@ class SkinTemplate extends Skin {
                if ( $out->isSyndicated() ) {
                        $feeds = array();
                        foreach ( $out->getSyndicationLinks() as $format => $link ) {
+                               // Give grep a chance to find the usages: feed-atom, feed-rss
                                $feeds[$format] = array(
                                        'text' => $this->msg( "feed-$format" )->text(),
                                        'href' => $link
@@ -323,7 +340,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'rtl', $userLang->isRTL() );
 
                $tpl->set( 'capitalizeallnouns', $userLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
-               $tpl->set( 'showjumplinks', $user->getOption( 'showjumplinks' ) );
+               $tpl->set( 'showjumplinks', true ); // showjumplinks preference has been removed
                $tpl->set( 'username', $this->loggedin ? $this->username : null );
                $tpl->setRef( 'userpage', $this->userpage );
                $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
@@ -515,6 +532,20 @@ class SkinTemplate extends Skin {
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * Get the HTML for the p-personal list
+        * @return string
+        */
+       public function getPersonalToolsList() {
+               $tpl = $this->setupTemplateForOutput();
+               $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
+               $html = '';
+               foreach ( $tpl->getPersonalTools() as $key => $item ) {
+                       $html .= $tpl->makeListItem( $key, $item );
+               }
+               return $html;
+       }
+
        /**
         * Format language name for use in sidebar interlanguage links list.
         * By default it is capitalized.
@@ -587,10 +618,6 @@ class SkinTemplate extends Skin {
                        }
                }
 
-               if ( $wgSecureLogin && $request->detectProtocol() === 'https' ) {
-                       $a['wpStickHTTPS'] = true;
-               }
-
                $returnto = wfArrayToCgi( $a );
                if ( $this->loggedin ) {
                        $personal_urls['userpage'] = array(
@@ -662,21 +689,16 @@ class SkinTemplate extends Skin {
                                : 'login';
                        $is_signup = $request->getText( 'type' ) == 'signup';
 
-                       # anonlogin & login are the same
-                       $proto = $wgSecureLogin ? PROTO_HTTPS : null;
-
                        $login_id = $this->showIPinHeader() ? 'anonlogin' : 'login';
                        $login_url = array(
                                'text' => $this->msg( $loginlink )->text(),
-                               'href' => self::makeSpecialUrl( 'Userlogin', $returnto, $proto ),
+                               'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
                                'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
-                               'class' => $wgSecureLogin ? 'link-https' : ''
                        );
                        $createaccount_url = array(
                                'text' => $this->msg( 'createaccount' )->text(),
-                               'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup", $proto ),
+                               'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
                                'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
-                               'class' => $wgSecureLogin ? 'link-https' : ''
                        );
 
                        if ( $this->showIPinHeader() ) {
@@ -1305,6 +1327,21 @@ abstract class QuickTemplate {
                $this->data[$name] = $value;
        }
 
+       /**
+        * Gets the template data requested
+        * @since 1.22
+        * @param string $name Key for the data
+        * @param mixed $default Optional default (or null)
+        * @return mixed The value of the data requested or the deafult
+        */
+       public function get( $name, $default = null ) {
+               if ( isset( $this->data[$name] ) ) {
+                       return $this->data[$name];
+               } else {
+                       return $default;
+               }
+       }
+
        /**
         * @param $name
         * @param $value
@@ -1507,7 +1544,7 @@ abstract class BaseTemplate extends QuickTemplate {
         */
        function getPersonalTools() {
                $personal_tools = array();
-               foreach ( $this->data['personal_urls'] as $key => $plink ) {
+               foreach ( $this->get( 'personal_urls' ) as $key => $plink ) {
                        # The class on a personal_urls item is meant to go on the <a> instead
                        # of the <li> so we have to use a single item "links" array instead
                        # of using most of the personal_url's keys directly.
@@ -1824,7 +1861,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        'type' => 'search',
                        'name' => 'search',
                        'placeholder' => wfMessage( 'searchsuggest-search' )->text(),
-                       'value' => isset( $this->data['search'] ) ? $this->data['search'] : '',
+                       'value' => $this->get( 'search', '' ),
                );
                $realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
                return Html::element( 'input', $realAttrs );
@@ -1883,7 +1920,7 @@ abstract class BaseTemplate extends QuickTemplate {
         * @return array|mixed
         */
        function getFooterLinks( $option = null ) {
-               $footerlinks = $this->data['footerlinks'];
+               $footerlinks = $this->get( 'footerlinks' );
 
                // Reduce footer links down to only those which are being used
                $validFooterLinks = array();
@@ -1923,7 +1960,7 @@ abstract class BaseTemplate extends QuickTemplate {
         */
        function getFooterIcons( $option = null ) {
                // Generate additional footer icons
-               $footericons = $this->data['footericons'];
+               $footericons = $this->get( 'footericons' );
 
                if ( $option == 'icononly' ) {
                        // Unset any icons which don't have an image