r105765 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105764‎ | r105765 | r105766 >
Date:17:01, 10 December 2011
Author:ialex
Status:ok
Tags:
Comment:
Factorise calls to $this->getTitle() in SkinTemplate::outputPage()
Modified paths:
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -155,6 +155,7 @@
156156 $out = $this->getOutput();
157157 $request = $this->getRequest();
158158 $user = $this->getUser();
 159+ $title = $this->getTitle();
159160
160161 wfProfileIn( __METHOD__ . '-init' );
161162 $this->initPage( $out );
@@ -163,7 +164,7 @@
164165 wfProfileOut( __METHOD__ . '-init' );
165166
166167 wfProfileIn( __METHOD__ . '-stuff' );
167 - $this->thispage = $this->getTitle()->getPrefixedDBkey();
 168+ $this->thispage = $title->getPrefixedDBkey();
168169 $this->userpage = $user->getUserPage()->getPrefixedText();
169170 $query = array();
170171 if ( !$request->wasPosted() ) {
@@ -185,7 +186,7 @@
186187 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
187188 }
188189
189 - $this->titletxt = $this->getTitle()->getPrefixedText();
 190+ $this->titletxt = $title->getPrefixedText();
190191 wfProfileOut( __METHOD__ . '-stuff' );
191192
192193 wfProfileIn( __METHOD__ . '-stuff-head' );
@@ -215,7 +216,7 @@
216217 $tpl->set( 'html5version', $wgHtml5Version );
217218 $tpl->set( 'headlinks', $out->getHeadLinks() );
218219 $tpl->set( 'csslinks', $out->buildCssLinks() );
219 - $tpl->set( 'pageclass', $this->getPageClasses( $this->getTitle() ) );
 220+ $tpl->set( 'pageclass', $this->getPageClasses( $title ) );
220221 $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
221222 }
222223 wfProfileOut( __METHOD__ . '-stuff-head' );
@@ -225,9 +226,9 @@
226227 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
227228 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
228229
229 - $tpl->set( 'titleprefixeddbkey', $this->getTitle()->getPrefixedDBKey() );
230 - $tpl->set( 'titletext', $this->getTitle()->getText() );
231 - $tpl->set( 'articleid', $this->getTitle()->getArticleId() );
 230+ $tpl->set( 'titleprefixeddbkey', $title->getPrefixedDBKey() );
 231+ $tpl->set( 'titletext', $title->getText() );
 232+ $tpl->set( 'articleid', $title->getArticleId() );
232233
233234 $tpl->set( 'isarticle', $out->isArticle() );
234235
@@ -269,12 +270,12 @@
270271 $tpl->set( 'printable', $out->isPrintable() );
271272 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
272273 $tpl->setRef( 'loggedin', $this->loggedin );
273 - $tpl->set( 'notspecialpage', !$this->getTitle()->isSpecialPage() );
 274+ $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
274275 /* XXX currently unused, might get useful later
275 - $tpl->set( 'editable', ( !$this->getTitle()->isSpecialPage() ) );
276 - $tpl->set( 'exists', $this->getTitle()->getArticleID() != 0 );
277 - $tpl->set( 'watch', $this->getTitle()->userIsWatching() ? 'unwatch' : 'watch' );
278 - $tpl->set( 'protect', count( $this->getTitle()->isProtected() ) ? 'unprotect' : 'protect' );
 276+ $tpl->set( 'editable', ( !$title->isSpecialPage() ) );
 277+ $tpl->set( 'exists', $title->getArticleID() != 0 );
 278+ $tpl->set( 'watch', $title->userIsWatching() ? 'unwatch' : 'watch' );
 279+ $tpl->set( 'protect', count( $title->isProtected() ) ? 'unprotect' : 'protect' );
279280 $tpl->set( 'helppage', $this->msg( 'helppage' )->text() );
280281 */
281282 $tpl->set( 'searchaction', $this->escapeSearchLink() );
@@ -327,9 +328,9 @@
328329 $tpl->set( 'lastmod', false );
329330 $tpl->set( 'credits', false );
330331 $tpl->set( 'numberofwatchingusers', false );
331 - if ( $out->isArticle() && $this->getTitle()->exists() ) {
 332+ if ( $out->isArticle() && $title->exists() ) {
332333 if ( $this->isRevisionCurrent() ) {
333 - $page = WikiPage::factory( $this->getTitle() );
 334+ $page = WikiPage::factory( $title );
334335 if ( !$wgDisableCounters ) {
335336 $viewcount = $page->getCount();
336337 if ( $viewcount ) {
@@ -340,7 +341,7 @@
341342 if( $wgPageShowWatchingUsers ) {
342343 $dbr = wfGetDB( DB_SLAVE );
343344 $num = $dbr->selectField( 'watchlist', 'COUNT(*)',
344 - array( 'wl_title' => $this->getTitle()->getDBkey(), 'wl_namespace' => $this->getTitle()->getNamespace() ),
 345+ array( 'wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace() ),
345346 __METHOD__
346347 );
347348 if( $num > 0 ) {
@@ -415,10 +416,10 @@
416417 # Add a <div class="mw-content-ltr/rtl"> around the body text
417418 # not for special pages or file pages AND only when viewing AND if the page exists
418419 # (or is in MW namespace, because that has default content)
419 - if( !in_array( $this->getTitle()->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
 420+ if( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
420421 in_array( $request->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) &&
421 - ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) {
422 - $pageLang = $this->getTitle()->getPageLanguage();
 422+ ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) {
 423+ $pageLang = $title->getPageLanguage();
423424 $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
424425 'class' => 'mw-content-'.$pageLang->getDir() );
425426 $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );

Status & tagging log