Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/94248


Change subject: Create prepareTemplate function
......................................................................

Create prepareTemplate function

Skins should be able to easily add to templates their own
variables. This helps with this.

This helps drastically reduce to the code in the mobile
skin and ensure it benefits from changes in core

See: I0a9a7f10ea6a2e9c90c2a83e7c5f7fa56fa0fb93

Change-Id: I0a9a7f10ea6a2e9c90c2a83e7c5f7fa56fa0fb93
---
M includes/SkinTemplate.php
1 file changed, 29 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/94248/1

diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php
index 1e7ce13..b421694 100644
--- a/includes/SkinTemplate.php
+++ b/includes/SkinTemplate.php
@@ -217,15 +217,6 @@
         * @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 );
 
@@ -237,14 +228,40 @@
                }
 
                $out = $this->getOutput();
-               $request = $this->getRequest();
                $user = $this->getUser();
-               $title = $this->getTitle();
 
                wfProfileIn( __METHOD__ . '-init' );
                $this->initPage( $out );
                wfProfileOut( __METHOD__ . '-init' );
+               $tpl = $this->prepareTemplate( $out );
+               // execute template
+               wfProfileIn( __METHOD__ . '-execute' );
+               $res = $tpl->execute();
+               wfProfileOut( __METHOD__ . '-execute' );
 
+               // result may be an error
+               $this->printOrError( $res );
+
+               if ( $oldContext ) {
+                       $this->setContext( $oldContext );
+               }
+       }
+
+       /**
+        * initialize various variables and generate the template
+        *
+        * @param $out OutputPage
+        * @return QuickTemplate the template to be executed by outputPage
+        */
+       protected function prepareTemplate( OutputPage $out = null ) {
+               global $wgContLang, $wgScript, $wgStylePath,
+                       $wgMimeType, $wgJsMimeType, $wgXhtmlNamespaces, 
$wgHtml5Version,
+                       $wgDisableCounters, $wgSitename, $wgLogo, $wgMaxCredits,
+                       $wgShowCreditsIfMax, $wgPageShowWatchingUsers, 
$wgArticlePath,
+                       $wgScriptPath, $wgServer;
+
+               $title = $this->getTitle();
+               $request = $this->getRequest();
                $tpl = $this->setupTemplateForOutput();
 
                wfProfileIn( __METHOD__ . '-stuff-head' );
@@ -523,18 +540,8 @@
                $tpl->set( 'dataAfterContent', $this->afterContentHook() );
                wfProfileOut( __METHOD__ . '-stuff5' );
 
-               // execute template
-               wfProfileIn( __METHOD__ . '-execute' );
-               $res = $tpl->execute();
-               wfProfileOut( __METHOD__ . '-execute' );
-
-               // result may be an error
-               $this->printOrError( $res );
-
-               if ( $oldContext ) {
-                       $this->setContext( $oldContext );
-               }
                wfProfileOut( __METHOD__ );
+               return $tpl;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/94248
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a9a7f10ea6a2e9c90c2a83e7c5f7fa56fa0fb93
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to