r107820 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107819‎ | r107820 | r107821 >
Date:12:04, 2 January 2012
Author:ialex
Status:ok
Tags:
Comment:
* Moved wfReportTime() call just before executing 'SkinTemplateOutputPageBeforeExec' hook to take into account remaining calls
* Group similar stuff
* Factorise calls to $this->getLanguage()
* Facrorise calls to $user->is(Anon|LoggedIn)()
* Changed the code that wraps 'subtitle' and 'undelete' items to be more readable
Modified paths:
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -165,6 +165,7 @@
166166
167167 wfProfileIn( __METHOD__ . '-stuff' );
168168 $this->thispage = $title->getPrefixedDBkey();
 169+ $this->titletxt = $title->getPrefixedText();
169170 $this->userpage = $user->getUserPage()->getPrefixedText();
170171 $query = array();
171172 if ( !$request->wasPosted() ) {
@@ -178,7 +179,7 @@
179180 $this->username = $user->getName();
180181 $this->userdisplayname = $user->getDisplayName();
181182
182 - if ( $user->isLoggedIn() || $this->showIPinHeader() ) {
 183+ if ( $this->loggedin || $this->showIPinHeader() ) {
183184 $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
184185 } else {
185186 # This won't be used in the standard skins, but we define it to preserve the interface
@@ -186,7 +187,6 @@
187188 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
188189 }
189190
190 - $this->titletxt = $title->getPrefixedText();
191191 wfProfileOut( __METHOD__ . '-stuff' );
192192
193193 wfProfileIn( __METHOD__ . '-stuff-head' );
@@ -218,25 +218,25 @@
219219 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
220220 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
221221
222 - $tpl->set( 'titleprefixeddbkey', $title->getPrefixedDBKey() );
 222+ $tpl->setRef( 'thispage', $this->thispage );
 223+ $tpl->setRef( 'titleprefixeddbkey', $this->thispage );
223224 $tpl->set( 'titletext', $title->getText() );
224225 $tpl->set( 'articleid', $title->getArticleId() );
225226
226227 $tpl->set( 'isarticle', $out->isArticle() );
227228
228 - $tpl->setRef( 'thispage', $this->thispage );
229229 $subpagestr = $this->subPageSubtitle();
230 - $tpl->set(
231 - 'subtitle', !empty( $subpagestr ) ?
232 - '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() :
233 - $out->getSubtitle()
234 - );
 230+ if ( $subpagestr !== '' ) {
 231+ $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
 232+ }
 233+ $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
 234+
235235 $undelete = $this->getUndeleteLink();
236 - $tpl->set(
237 - 'undelete', !empty( $undelete ) ?
238 - '<span class="subpages">' . $undelete . '</span>' :
239 - ''
240 - );
 236+ if ( $undelete === '' ) {
 237+ $tpl->set( 'undelete', '' );
 238+ } else {
 239+ $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
 240+ }
241241
242242 $tpl->set( 'catlinks', $this->getCategories() );
243243 if( $out->isSyndicated() ) {
@@ -258,6 +258,7 @@
259259 $tpl->setRef( 'wgScript', $wgScript );
260260 $tpl->setRef( 'skinname', $this->skinname );
261261 $tpl->set( 'skinclass', get_class( $this ) );
 262+ $tpl->setRef( 'skin', $this );
262263 $tpl->setRef( 'stylename', $this->stylename );
263264 $tpl->set( 'printable', $out->isPrintable() );
264265 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
@@ -280,19 +281,18 @@
281282 $tpl->setRef( 'logopath', $wgLogo );
282283 $tpl->setRef( 'sitename', $wgSitename );
283284
284 - $contentlang = $wgContLang->getHtmlCode();
285 - $contentdir = $wgContLang->getDir();
286 - $userlang = $this->getLanguage()->getHtmlCode();
287 - $userdir = $this->getLanguage()->getDir();
 285+ $lang = $this->getLanguage();
 286+ $userlang = $lang->getHtmlCode();
 287+ $userdir = $lang->getDir();
288288
289289 $tpl->set( 'lang', $userlang );
290290 $tpl->set( 'dir', $userdir );
291 - $tpl->set( 'rtl', $this->getLanguage()->isRTL() );
 291+ $tpl->set( 'rtl', $lang->isRTL() );
292292
293 - $tpl->set( 'capitalizeallnouns', $this->getLanguage()->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
 293+ $tpl->set( 'capitalizeallnouns', $lang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
294294 $tpl->set( 'showjumplinks', $user->getOption( 'showjumplinks' ) );
295 - $tpl->set( 'username', $user->isAnon() ? null : $this->username );
296 - $tpl->set( 'userdisplayname', $user->isAnon() ? null : $this->userdisplayname );
 295+ $tpl->set( 'username', $this->loggedin ? $this->username : null );
 296+ $tpl->set( 'userdisplayname', $this->loggedin ? $this->userdisplayname : null );
297297 $tpl->setRef( 'userpage', $this->userpage );
298298 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
299299 $tpl->set( 'userlang', $userlang );
@@ -303,7 +303,7 @@
304304 $tpl->set( 'userlangattributes', '' );
305305 $tpl->set( 'specialpageattributes', '' ); # obsolete
306306
307 - if ( $userlang !== $contentlang || $userdir !== $contentdir ) {
 307+ if ( $userlang !== $wgContLang->getHtmlCode() || $userdir !== $wgContLang->getDir() ) {
308308 $attrs = " lang='$userlang' dir='$userdir'";
309309 $tpl->set( 'userlangattributes', $attrs );
310310 }
@@ -312,7 +312,6 @@
313313
314314 wfProfileIn( __METHOD__ . '-stuff3' );
315315 $tpl->set( 'newtalk', $this->getNewtalks() );
316 - $tpl->setRef( 'skin', $this );
317316 $tpl->set( 'logo', $this->logoText() );
318317
319318 $tpl->set( 'copyright', false );
@@ -400,7 +399,6 @@
401400 $tpl->set( 'debug', '' );
402401 }
403402
404 - $tpl->set( 'reporttime', wfReportTime() );
405403 $tpl->set( 'sitenotice', $this->getSiteNotice() );
406404 $tpl->set( 'bottomscripts', $this->bottomScripts() );
407405 $tpl->set( 'printfooter', $this->printSource() );
@@ -467,6 +465,7 @@
468466 }
469467
470468 $tpl->set( 'debughtml', $this->generateDebugHTML() );
 469+ $tpl->set( 'reporttime', wfReportTime() );
471470
472471 // original version by hansm
473472 if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {

Sign-offs

UserFlagDate
Nikerabbitinspected13:29, 2 January 2012

Status & tagging log