Add getPersonalToolsList to SkinTemplate
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 8e41b5a..94978d4 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 );
@@ -515,6 +531,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.