From e02715b58a51a25579993e9a178adc63f404d5e7 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 12 Jun 2013 12:50:19 -0400 Subject: [PATCH] Add getPersonalToolsList to SkinTemplate This is for CentralAuth, so it can replace the p-personal list. Bug: 50619 Change-Id: I7385bcb36e45310fb08da05f8df8925acd7d9890 --- includes/SkinTemplate.php | 82 ++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 8e41b5a969..94978d49b5 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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. -- 2.20.1