r48999 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48998‎ | r48999 | r49000 >
Date:12:46, 29 March 2009
Author:ashley
Status:ok (Comments)
Tags:
Comment:
Skin.php/SkinTemplate.php: cleanup, spacing tweaks, double quotes to single quotes where appropriate, changed $fname to __METHOD__, broke up some long lines, converted raw SQL queries to use Database class, marked visibility of certain functions that were marked as /** @public */
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -27,11 +27,11 @@
2828 class MediaWiki_I18N {
2929 var $_context = array();
3030
31 - function set($varName, $value) {
 31+ function set( $varName, $value ) {
3232 $this->_context[$varName] = $value;
3333 }
3434
35 - function translate($value) {
 35+ function translate( $value ) {
3636 wfProfileIn( __METHOD__ );
3737
3838 // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
@@ -40,12 +40,12 @@
4141 $value = wfMsg( $value );
4242 // interpolate variables
4343 $m = array();
44 - while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
45 - list($src, $var) = $m;
 44+ while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
 45+ list( $src, $var ) = $m;
4646 wfSuppressWarnings();
4747 $varValue = $this->_context[$var];
4848 wfRestoreWarnings();
49 - $value = str_replace($src, $varValue, $value);
 49+ $value = str_replace( $src, $varValue, $value );
5050 }
5151 wfProfileOut( __METHOD__ );
5252 return $value;
@@ -124,7 +124,7 @@
125125 * @return object
126126 * @private
127127 */
128 - function setupTemplate( $classname, $repository=false, $cache_dir=false ) {
 128+ function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
129129 return new $classname();
130130 }
131131
@@ -150,23 +150,23 @@
151151 $diff = $wgRequest->getVal( 'diff' );
152152 $action = $wgRequest->getVal( 'action', 'view' );
153153
154 - wfProfileIn( __METHOD__."-init" );
 154+ wfProfileIn( __METHOD__ . '-init' );
155155 $this->initPage( $out );
156156
157157 $this->setMembers();
158158 $tpl = $this->setupTemplate( $this->template, 'skins' );
159159
160160 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
161 - $tpl->setTranslator(new MediaWiki_I18N());
 161+ $tpl->setTranslator( new MediaWiki_I18N() );
162162 #}
163 - wfProfileOut( __METHOD__."-init" );
 163+ wfProfileOut( __METHOD__ . '-init' );
164164
165 - wfProfileIn( __METHOD__."-stuff" );
166 - $this->thispage = $this->mTitle->getPrefixedDbKey();
 165+ wfProfileIn( __METHOD__ . '-stuff' );
 166+ $this->thispage = $this->mTitle->getPrefixedDBkey();
167167 $this->thisurl = $this->mTitle->getPrefixedURL();
168168 $this->loggedin = $wgUser->isLoggedIn();
169 - $this->iscontent = ($this->mTitle->getNamespace() != NS_SPECIAL );
170 - $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
 169+ $this->iscontent = ( $this->mTitle->getNamespace() != NS_SPECIAL );
 170+ $this->iseditable = ( $this->iscontent and !( $action == 'edit' or $action == 'submit' ) );
171171 $this->username = $wgUser->getName();
172172
173173 if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) {
@@ -181,18 +181,18 @@
182182 $this->setupUserCss( $out );
183183 $this->setupUserJs( $out->isUserJsAllowed() );
184184 $this->titletxt = $this->mTitle->getPrefixedText();
185 - wfProfileOut( __METHOD__."-stuff" );
 185+ wfProfileOut( __METHOD__ . '-stuff' );
186186
187 - wfProfileIn( __METHOD__."-stuff2" );
 187+ wfProfileIn( __METHOD__ . '-stuff2' );
188188 $tpl->set( 'title', $out->getPageTitle() );
189189 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
190190 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
191191 $tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
192 - $tpl->set( 'skinnameclass', ( "skin-" . Sanitizer::escapeClass( $this->getSkinName ( ) ) ) );
 192+ $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
193193
194194 $nsname = isset( $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] ) ?
195 - $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] :
196 - $this->mTitle->getNsText();
 195+ $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] :
 196+ $this->mTitle->getNsText();
197197
198198 $tpl->set( 'nscanonical', $nsname );
199199 $tpl->set( 'nsnumber', $this->mTitle->getNamespace() );
@@ -203,33 +203,34 @@
204204
205205 $tpl->set( 'isarticle', $out->isArticle() );
206206
207 - $tpl->setRef( "thispage", $this->thispage );
 207+ $tpl->setRef( 'thispage', $this->thispage );
208208 $subpagestr = $this->subPageSubtitle();
209209 $tpl->set(
210 - 'subtitle', !empty($subpagestr)?
211 - '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
 210+ 'subtitle', !empty( $subpagestr ) ?
 211+ '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle() :
212212 $out->getSubtitle()
213213 );
214214 $undelete = $this->getUndeleteLink();
215215 $tpl->set(
216 - "undelete", !empty($undelete)?
217 - '<span class="subpages">'.$undelete.'</span>':
 216+ 'undelete', !empty( $undelete ) ?
 217+ '<span class="subpages">'.$undelete.'</span>' :
218218 ''
219219 );
220220
221 - $tpl->set( 'catlinks', $this->getCategories());
 221+ $tpl->set( 'catlinks', $this->getCategories() );
222222 if( $out->isSyndicated() ) {
223223 $feeds = array();
224224 foreach( $out->getSyndicationLinks() as $format => $link ) {
225225 $feeds[$format] = array(
226226 'text' => wfMsg( "feed-$format" ),
227 - 'href' => $link );
 227+ 'href' => $link
 228+ );
228229 }
229230 $tpl->setRef( 'feeds', $feeds );
230231 } else {
231232 $tpl->set( 'feeds', false );
232233 }
233 - if ($wgUseTrackbacks && $out->isArticleRelated()) {
 234+ if( $wgUseTrackbacks && $out->isArticleRelated() ) {
234235 $tpl->set( 'trackbackhtml', $wgTitle->trackbackRDF() );
235236 } else {
236237 $tpl->set( 'trackbackhtml', null );
@@ -250,7 +251,7 @@
251252 $tpl->set( 'printable', $wgRequest->getBool( 'printable' ) );
252253 $tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) );
253254 $tpl->setRef( 'loggedin', $this->loggedin );
254 - $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL);
 255+ $tpl->set( 'notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL );
255256 /* XXX currently unused, might get useful later
256257 $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) );
257258 $tpl->set( "exists", $this->mTitle->getArticleID() != 0 );
@@ -259,38 +260,38 @@
260261 $tpl->set( "helppage", wfMsg('helppage'));
261262 */
262263 $tpl->set( 'searchaction', $this->escapeSearchLink() );
263 - $tpl->set( 'searchtitle', SpecialPage::getTitleFor('search')->getPrefixedDBKey() );
 264+ $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBKey() );
264265 $tpl->set( 'search', trim( $wgRequest->getVal( 'search' ) ) );
265266 $tpl->setRef( 'stylepath', $wgStylePath );
266267 $tpl->setRef( 'articlepath', $wgArticlePath );
267268 $tpl->setRef( 'scriptpath', $wgScriptPath );
268269 $tpl->setRef( 'serverurl', $wgServer );
269270 $tpl->setRef( 'logopath', $wgLogo );
270 - $tpl->setRef( "lang", $wgContLanguageCode );
271 - $tpl->set( 'dir', $wgContLang->isRTL() ? "rtl" : "ltr" );
 271+ $tpl->setRef( 'lang', $wgContLanguageCode );
 272+ $tpl->set( 'dir', $wgContLang->isRTL() ? 'rtl' : 'ltr' );
272273 $tpl->set( 'rtl', $wgContLang->isRTL() );
273274 $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
274275 $tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
275276 $tpl->set( 'username', $wgUser->isAnon() ? NULL : $this->username );
276 - $tpl->setRef( 'userpage', $this->userpage);
277 - $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href']);
 277+ $tpl->setRef( 'userpage', $this->userpage );
 278+ $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
278279 $tpl->set( 'userlang', $wgLang->getCode() );
279280 $tpl->set( 'pagecss', $this->setupPageCss() );
280 - $tpl->setRef( 'usercss', $this->usercss);
281 - $tpl->setRef( 'userjs', $this->userjs);
282 - $tpl->setRef( 'userjsprev', $this->userjsprev);
 281+ $tpl->setRef( 'usercss', $this->usercss );
 282+ $tpl->setRef( 'userjs', $this->userjs );
 283+ $tpl->setRef( 'userjsprev', $this->userjsprev );
283284 if( $wgUseSiteJs ) {
284285 $jsCache = $this->loggedin ? '&smaxage=0' : '';
285286 $tpl->set( 'jsvarurl',
286 - self::makeUrl('-',
 287+ self::makeUrl( '-',
287288 "action=raw$jsCache&gen=js&useskin=" .
288289 urlencode( $this->getSkinName() ) ) );
289290 } else {
290 - $tpl->set('jsvarurl', false);
 291+ $tpl->set( 'jsvarurl', false );
291292 }
292293 $newtalks = $wgUser->getNewMessageLinks();
293294
294 - if (count($newtalks) == 1 && $newtalks[0]["wiki"] === wfWikiID() ) {
 295+ if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
295296 $usertitle = $this->mUser->getUserPage();
296297 $usertalktitle = $usertitle->getTalkPage();
297298 if( !$usertalktitle->equals( $this->mTitle ) ) {
@@ -307,63 +308,63 @@
308309 )
309310 );
310311 # Disable Cache
311 - $out->setSquidMaxage(0);
 312+ $out->setSquidMaxage( 0 );
312313 }
313 - } else if (count($newtalks)) {
314 - $sep = str_replace("_", " ", wfMsgHtml("newtalkseparator"));
 314+ } else if( count( $newtalks ) ) {
 315+ $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
315316 $msgs = array();
316 - foreach ($newtalks as $newtalk) {
317 - $msgs[] = Xml::element("a",
318 - array('href' => $newtalk["link"]), $newtalk["wiki"]);
 317+ foreach( $newtalks as $newtalk ) {
 318+ $msgs[] = Xml::element('a',
 319+ array( 'href' => $newtalk['link'] ), $newtalk['wiki'] );
319320 }
320 - $parts = implode($sep, $msgs);
321 - $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
322 - $out->setSquidMaxage(0);
 321+ $parts = implode( $sep, $msgs );
 322+ $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
 323+ $out->setSquidMaxage( 0 );
323324 } else {
324325 $ntl = '';
325326 }
326 - wfProfileOut( __METHOD__."-stuff2" );
 327+ wfProfileOut( __METHOD__ . '-stuff2' );
327328
328 - wfProfileIn( __METHOD__."-stuff3" );
 329+ wfProfileIn( __METHOD__ . '-stuff3' );
329330 $tpl->setRef( 'newtalk', $ntl );
330331 $tpl->setRef( 'skin', $this );
331332 $tpl->set( 'logo', $this->logoText() );
332 - if ( $out->isArticle() and (!isset( $oldid ) or isset( $diff )) and
333 - $wgArticle and 0 != $wgArticle->getID() )
334 - {
 333+ if ( $out->isArticle() and ( !isset( $oldid ) or isset( $diff ) ) and
 334+ $wgArticle and 0 != $wgArticle->getID() ){
335335 if ( !$wgDisableCounters ) {
336336 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
337337 if ( $viewcount ) {
338 - $tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
 338+ $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
339339 } else {
340 - $tpl->set('viewcount', false);
 340+ $tpl->set( 'viewcount', false );
341341 }
342342 } else {
343 - $tpl->set('viewcount', false);
 343+ $tpl->set( 'viewcount', false );
344344 }
345345
346 - if ($wgPageShowWatchingUsers) {
 346+ if( $wgPageShowWatchingUsers ) {
347347 $dbr = wfGetDB( DB_SLAVE );
348348 $watchlist = $dbr->tableName( 'watchlist' );
349 - $sql = "SELECT COUNT(*) AS n FROM $watchlist
350 - WHERE wl_title='" . $dbr->strencode($this->mTitle->getDBkey()) .
351 - "' AND wl_namespace=" . $this->mTitle->getNamespace() ;
352 - $res = $dbr->query( $sql, 'SkinTemplate::outputPage');
 349+ $res = $dbr->select( 'watchlist',
 350+ array( 'COUNT(*) AS n' ),
 351+ array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
 352+ __METHOD__
 353+ );
353354 $x = $dbr->fetchObject( $res );
354355 $numberofwatchingusers = $x->n;
355 - if ($numberofwatchingusers > 0) {
356 - $tpl->set('numberofwatchingusers',
357 - wfMsgExt('number_of_watching_users_pageview', array('parseinline'),
358 - $wgLang->formatNum($numberofwatchingusers))
 356+ if( $numberofwatchingusers > 0 ) {
 357+ $tpl->set( 'numberofwatchingusers',
 358+ wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ),
 359+ $wgLang->formatNum( $numberofwatchingusers ) )
359360 );
360361 } else {
361 - $tpl->set('numberofwatchingusers', false);
 362+ $tpl->set( 'numberofwatchingusers', false );
362363 }
363364 } else {
364 - $tpl->set('numberofwatchingusers', false);
 365+ $tpl->set( 'numberofwatchingusers', false );
365366 }
366367
367 - $tpl->set('copyright',$this->getCopyright());
 368+ $tpl->set( 'copyright', $this->getCopyright() );
368369
369370 $this->credits = false;
370371
@@ -376,21 +377,21 @@
377378 $tpl->setRef( 'credits', $this->credits );
378379
379380 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
380 - $tpl->set('copyright', $this->getCopyright());
381 - $tpl->set('viewcount', false);
382 - $tpl->set('lastmod', false);
383 - $tpl->set('credits', false);
384 - $tpl->set('numberofwatchingusers', false);
 381+ $tpl->set( 'copyright', $this->getCopyright() );
 382+ $tpl->set( 'viewcount', false );
 383+ $tpl->set( 'lastmod', false );
 384+ $tpl->set( 'credits', false );
 385+ $tpl->set( 'numberofwatchingusers', false );
385386 } else {
386 - $tpl->set('copyright', false);
387 - $tpl->set('viewcount', false);
388 - $tpl->set('lastmod', false);
389 - $tpl->set('credits', false);
390 - $tpl->set('numberofwatchingusers', false);
 387+ $tpl->set( 'copyright', false );
 388+ $tpl->set( 'viewcount', false );
 389+ $tpl->set( 'lastmod', false );
 390+ $tpl->set( 'credits', false );
 391+ $tpl->set( 'numberofwatchingusers', false );
391392 }
392 - wfProfileOut( __METHOD__."-stuff3" );
 393+ wfProfileOut( __METHOD__ . '-stuff3' );
393394
394 - wfProfileIn( __METHOD__."-stuff4" );
 395+ wfProfileIn( __METHOD__ . '-stuff4' );
395396 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
396397 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
397398 $tpl->set( 'disclaimer', $this->disclaimerLink() );
@@ -413,37 +414,37 @@
414415 foreach( $out->getLanguageLinks() as $l ) {
415416 $tmp = explode( ':', $l, 2 );
416417 $class = 'interwiki-' . $tmp[0];
417 - unset($tmp);
 418+ unset( $tmp );
418419 $nt = Title::newFromText( $l );
419420 if ( $nt ) {
420421 $language_urls[] = array(
421422 'href' => $nt->getFullURL(),
422 - 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
 423+ 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
 424+ $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
423425 'class' => $class
424426 );
425427 }
426428 }
427429 }
428 - if(count($language_urls)) {
429 - $tpl->setRef( 'language_urls', $language_urls);
 430+ if( count( $language_urls ) ) {
 431+ $tpl->setRef( 'language_urls', $language_urls );
430432 } else {
431 - $tpl->set('language_urls', false);
 433+ $tpl->set( 'language_urls', false );
432434 }
433 - wfProfileOut( __METHOD__."-stuff4" );
 435+ wfProfileOut( __METHOD__ . '-stuff4' );
434436
435 - wfProfileIn( __METHOD__."-stuff5" );
 437+ wfProfileIn( __METHOD__ . '-stuff5' );
436438 # Personal toolbar
437 - $tpl->set('personal_urls', $this->buildPersonalUrls());
 439+ $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
438440 $content_actions = $this->buildContentActionUrls();
439 - $tpl->setRef('content_actions', $content_actions);
 441+ $tpl->setRef( 'content_actions', $content_actions );
440442
441443 // XXX: attach this from javascript, same with section editing
442 - if($this->iseditable && $wgUser->getOption("editondblclick") )
443 - {
 444+ if( $this->iseditable && $wgUser->getOption( 'editondblclick' ) ){
444445 $encEditUrl = Xml::escapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
445 - $tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";');
 446+ $tpl->set( 'body_ondblclick', 'document.location = "' . $encEditUrl . '";' );
446447 } else {
447 - $tpl->set('body_ondblclick', false);
 448+ $tpl->set( 'body_ondblclick', false );
448449 }
449450 $tpl->set( 'body_onload', false );
450451 $tpl->set( 'sidebar', $this->buildSidebar() );
@@ -456,13 +457,13 @@
457458
458459 // allow extensions adding stuff after the page content.
459460 // See Skin::afterContentHook() for further documentation.
460 - $tpl->set ('dataAfterContent', $this->afterContentHook());
461 - wfProfileOut( __METHOD__."-stuff5" );
 461+ $tpl->set( 'dataAfterContent', $this->afterContentHook() );
 462+ wfProfileOut( __METHOD__ . '-stuff5' );
462463
463464 // execute template
464 - wfProfileIn( __METHOD__."-execute" );
 465+ wfProfileIn( __METHOD__ . '-execute' );
465466 $res = $tpl->execute();
466 - wfProfileOut( __METHOD__."-execute" );
 467+ wfProfileOut( __METHOD__ . '-execute' );
467468
468469 // result may be an error
469470 $this->printOrError( $res );
@@ -494,18 +495,18 @@
495496
496497 /* set up the default links for the personal toolbar */
497498 $personal_urls = array();
498 - if ($this->loggedin) {
 499+ if( $this->loggedin ) {
499500 $personal_urls['userpage'] = array(
500501 'text' => $this->username,
501502 'href' => &$this->userpageUrlDetails['href'],
502 - 'class' => $this->userpageUrlDetails['exists']?false:'new',
 503+ 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
503504 'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
504505 );
505 - $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
 506+ $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
506507 $personal_urls['mytalk'] = array(
507 - 'text' => wfMsg('mytalk'),
 508+ 'text' => wfMsg( 'mytalk' ),
508509 'href' => &$usertalkUrlDetails['href'],
509 - 'class' => $usertalkUrlDetails['exists']?false:'new',
 510+ 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
510511 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
511512 );
512513 $href = self::makeSpecialUrl( 'Preferences' );
@@ -560,15 +561,15 @@
561562 $personal_urls['anonuserpage'] = array(
562563 'text' => $this->username,
563564 'href' => $href,
564 - 'class' => $this->userpageUrlDetails['exists']?false:'new',
 565+ 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
565566 'active' => ( $pageurl == $href )
566567 );
567 - $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
 568+ $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
568569 $href = &$usertalkUrlDetails['href'];
569570 $personal_urls['anontalk'] = array(
570 - 'text' => wfMsg('anontalk'),
 571+ 'text' => wfMsg( 'anontalk' ),
571572 'href' => $href,
572 - 'class' => $usertalkUrlDetails['exists']?false:'new',
 573+ 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
573574 'active' => ( $pageurl == $href )
574575 );
575576 $personal_urls['anonlogin'] = array(
@@ -577,7 +578,6 @@
578579 'active' => $wgTitle->isSpecial( 'Userlogin' )
579580 );
580581 } else {
581 -
582582 $personal_urls['login'] = array(
583583 'text' => wfMsg( $loginlink ),
584584 'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ),
@@ -591,7 +591,7 @@
592592 return $personal_urls;
593593 }
594594
595 - function tabAction( $title, $message, $selected, $query='', $checkEdit=false ) {
 595+ function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
596596 $classes = array();
597597 if( $selected ) {
598598 $classes[] = 'selected';
@@ -608,9 +608,9 @@
609609 }
610610
611611 $result = array();
612 - if( !wfRunHooks('SkinTemplateTabAction', array(&$this,
 612+ if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
613613 $title, $message, $selected, $checkEdit,
614 - &$classes, &$query, &$text, &$result)) ) {
 614+ &$classes, &$query, &$text, &$result ) ) ) {
615615 return $result;
616616 }
617617
@@ -622,8 +622,8 @@
623623
624624 function makeTalkUrlDetails( $name, $urlaction = '' ) {
625625 $title = Title::newFromText( $name );
626 - if( !is_object($title) ) {
627 - throw new MWException( __METHOD__." given invalid pagename $name" );
 626+ if( !is_object( $title ) ) {
 627+ throw new MWException( __METHOD__ . " given invalid pagename $name" );
628628 }
629629 $title = $title->getTalkPage();
630630 self::checkTitle( $title, $name );
@@ -657,8 +657,8 @@
658658 $section = $wgRequest->getVal( 'section' );
659659 $content_actions = array();
660660
661 - $prevent_active_tabs = false ;
662 - wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this , &$prevent_active_tabs ) ) ;
 661+ $prevent_active_tabs = false;
 662+ wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$prevent_active_tabs ) );
663663
664664 if( $this->iscontent ) {
665665 $subjpage = $this->mTitle->getSubjectPage();
@@ -669,21 +669,23 @@
670670 $subjpage,
671671 $nskey,
672672 !$this->mTitle->isTalkPage() && !$prevent_active_tabs,
673 - '', true);
 673+ '', true
 674+ );
674675
675676 $content_actions['talk'] = $this->tabAction(
676677 $talkpage,
677678 'talk',
678679 $this->mTitle->isTalkPage() && !$prevent_active_tabs,
679680 '',
680 - true);
 681+ true
 682+ );
681683
682 - wfProfileIn( __METHOD__."-edit" );
 684+ wfProfileIn( __METHOD__ . '-edit' );
683685 if ( $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) {
684686 $istalk = $this->mTitle->isTalkPage();
685687 $istalkclass = $istalk?' istalk':'';
686688 $content_actions['edit'] = array(
687 - 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
 689+ 'class' => ( ( ( $action == 'edit' or $action == 'submit' ) and $section != 'new' ) ? 'selected' : '' ) . $istalkclass,
688690 'text' => $this->mTitle->exists()
689691 ? wfMsg( 'edit' )
690692 : wfMsg( 'create' ),
@@ -694,7 +696,7 @@
695697 if ( !$wgOut->forceHideNewSectionLink() ) {
696698 $content_actions['addsection'] = array(
697699 'class' => $section == 'new' ? 'selected' : false,
698 - 'text' => wfMsg('addsection'),
 700+ 'text' => wfMsg( 'addsection' ),
699701 'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
700702 );
701703 }
@@ -702,26 +704,26 @@
703705 } elseif ( $this->mTitle->isKnown() ) {
704706 $content_actions['viewsource'] = array(
705707 'class' => ($action == 'edit') ? 'selected' : false,
706 - 'text' => wfMsg('viewsource'),
 708+ 'text' => wfMsg( 'viewsource' ),
707709 'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
708710 );
709711 }
710 - wfProfileOut( __METHOD__."-edit" );
 712+ wfProfileOut( __METHOD__ . '-edit' );
711713
712 - wfProfileIn( __METHOD__."-live" );
 714+ wfProfileIn( __METHOD__ . '-live' );
713715 if ( $this->mTitle->exists() ) {
714716
715717 $content_actions['history'] = array(
716718 'class' => ($action == 'history') ? 'selected' : false,
717 - 'text' => wfMsg('history_short'),
 719+ 'text' => wfMsg( 'history_short' ),
718720 'href' => $this->mTitle->getLocalUrl( 'action=history' ),
719721 'rel' => 'archives',
720722 );
721723
722 - if( $wgUser->isAllowed('delete') ) {
 724+ if( $wgUser->isAllowed( 'delete' ) ) {
723725 $content_actions['delete'] = array(
724726 'class' => ($action == 'delete') ? 'selected' : false,
725 - 'text' => wfMsg('delete'),
 727+ 'text' => wfMsg( 'delete' ),
726728 'href' => $this->mTitle->getLocalUrl( 'action=delete' )
727729 );
728730 }
@@ -729,7 +731,7 @@
730732 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
731733 $content_actions['move'] = array(
732734 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
733 - 'text' => wfMsg('move'),
 735+ 'text' => wfMsg( 'move' ),
734736 'href' => $moveTitle->getLocalUrl()
735737 );
736738 }
@@ -738,14 +740,14 @@
739741 if( !$this->mTitle->isProtected() ){
740742 $content_actions['protect'] = array(
741743 'class' => ($action == 'protect') ? 'selected' : false,
742 - 'text' => wfMsg('protect'),
 744+ 'text' => wfMsg( 'protect' ),
743745 'href' => $this->mTitle->getLocalUrl( 'action=protect' )
744746 );
745747
746748 } else {
747749 $content_actions['unprotect'] = array(
748750 'class' => ($action == 'unprotect') ? 'selected' : false,
749 - 'text' => wfMsg('unprotect'),
 751+ 'text' => wfMsg( 'unprotect' ),
750752 'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
751753 );
752754 }
@@ -757,7 +759,7 @@
758760 $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
759761 $content_actions['undelete'] = array(
760762 'class' => false,
761 - 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum($n) ),
 763+ 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum( $n ) ),
762764 'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
763765 #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" )
764766 );
@@ -768,40 +770,40 @@
769771 if( !$this->mTitle->getRestrictions( 'create' ) ) {
770772 $content_actions['protect'] = array(
771773 'class' => ($action == 'protect') ? 'selected' : false,
772 - 'text' => wfMsg('protect'),
 774+ 'text' => wfMsg( 'protect' ),
773775 'href' => $this->mTitle->getLocalUrl( 'action=protect' )
774776 );
775777
776778 } else {
777779 $content_actions['unprotect'] = array(
778780 'class' => ($action == 'unprotect') ? 'selected' : false,
779 - 'text' => wfMsg('unprotect'),
 781+ 'text' => wfMsg( 'unprotect' ),
780782 'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
781783 );
782784 }
783785 }
784786 }
785787
786 - wfProfileOut( __METHOD__."-live" );
 788+ wfProfileOut( __METHOD__ . '-live' );
787789
788790 if( $this->loggedin ) {
789791 if( !$this->mTitle->userIsWatching()) {
790792 $content_actions['watch'] = array(
791793 'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
792 - 'text' => wfMsg('watch'),
 794+ 'text' => wfMsg( 'watch' ),
793795 'href' => $this->mTitle->getLocalUrl( 'action=watch' )
794796 );
795797 } else {
796798 $content_actions['unwatch'] = array(
797799 'class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
798 - 'text' => wfMsg('unwatch'),
 800+ 'text' => wfMsg( 'unwatch' ),
799801 'href' => $this->mTitle->getLocalUrl( 'action=unwatch' )
800802 );
801803 }
802804 }
803805
804806
805 - wfRunHooks( 'SkinTemplateTabs', array( &$this , &$content_actions ) ) ;
 807+ wfRunHooks( 'SkinTemplateTabs', array( &$this, &$content_actions ) );
806808 } else {
807809 /* show special page tab */
808810
@@ -826,10 +828,10 @@
827829 continue;
828830 $selected = ( $code == $preferred )? 'selected' : false;
829831 $content_actions['varlang-' . $vcount] = array(
830 - 'class' => $selected,
831 - 'text' => $varname,
832 - 'href' => $this->mTitle->getLocalURL('',$code)
833 - );
 832+ 'class' => $selected,
 833+ 'text' => $varname,
 834+ 'href' => $this->mTitle->getLocalURL( '', $code )
 835+ );
834836 $vcount ++;
835837 }
836838 }
@@ -840,8 +842,6 @@
841843 return $content_actions;
842844 }
843845
844 -
845 -
846846 /**
847847 * build array of common navigation links
848848 * @return array
@@ -858,13 +858,13 @@
859859 $nav_urls = array();
860860 $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
861861 if( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
862 - if ($wgUploadNavigationUrl) {
 862+ if( $wgUploadNavigationUrl ) {
863863 $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
864864 } else {
865865 $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
866866 }
867867 } else {
868 - if ($wgUploadNavigationUrl)
 868+ if( $wgUploadNavigationUrl )
869869 $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
870870 else
871871 $nav_urls['upload'] = false;
@@ -908,21 +908,21 @@
909909 } else {
910910 $nav_urls['recentchangeslinked'] = false;
911911 }
912 - if ($wgUseTrackbacks)
 912+ if( $wgUseTrackbacks )
913913 $nav_urls['trackbacklink'] = array(
914914 'href' => $wgTitle->trackbackURL()
915915 );
916916 }
917917
918918 if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
919 - $id = User::idFromName($this->mTitle->getText());
920 - $ip = User::isIP($this->mTitle->getText());
 919+ $id = User::idFromName( $this->mTitle->getText() );
 920+ $ip = User::isIP( $this->mTitle->getText() );
921921 } else {
922922 $id = 0;
923923 $ip = false;
924924 }
925925
926 - if($id || $ip) { # both anons and non-anons have contribs list
 926+ if( $id || $ip ) { # both anons and non-anons have contribs list
927927 $nav_urls['contributions'] = array(
928928 'href' => self::makeSpecialUrlSubpage( 'Contributions', $this->mTitle->getText() )
929929 );
@@ -979,9 +979,9 @@
980980 if( $allowUserJs && $this->loggedin ) {
981981 if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) {
982982 # XXX: additional security check/prompt?
983 - $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
 983+ $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText( 'wpTextbox1' ) . ' /*]]>*/';
984984 } else {
985 - $this->userjs = self::makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType);
 985+ $this->userjs = self::makeUrl( $this->userpage . '/' . $this->skinname . '.js', 'action=raw&ctype=' . $wgJsMimeType );
986986 }
987987 }
988988 wfProfileOut( __METHOD__ );
@@ -1009,42 +1009,45 @@
10101010 */
10111011 class QuickTemplate {
10121012 /**
1013 - * @public
 1013+ * Constructor
10141014 */
1015 - function QuickTemplate() {
 1015+ public function QuickTemplate() {
10161016 $this->data = array();
10171017 $this->translator = new MediaWiki_I18N();
10181018 }
10191019
10201020 /**
1021 - * @public
 1021+ * Sets the value $value to $name
 1022+ * @param $name
 1023+ * @param $value
10221024 */
1023 - function set( $name, $value ) {
 1025+ public function set( $name, $value ) {
10241026 $this->data[$name] = $value;
10251027 }
10261028
10271029 /**
1028 - * @public
 1030+ * @param $name
 1031+ * @param $value
10291032 */
1030 - function setRef($name, &$value) {
 1033+ public function setRef( $name, &$value ) {
10311034 $this->data[$name] =& $value;
10321035 }
10331036
10341037 /**
1035 - * @public
 1038+ * @param $t
10361039 */
1037 - function setTranslator( &$t ) {
 1040+ public function setTranslator( &$t ) {
10381041 $this->translator = &$t;
10391042 }
10401043
10411044 /**
1042 - * @public
 1045+ * Main function, used by classes that subclass QuickTemplate
 1046+ * to show the actual HTML output
10431047 */
1044 - function execute() {
1045 - echo "Override this function.";
 1048+ public function execute() {
 1049+ echo 'Override this function.';
10461050 }
10471051
1048 -
10491052 /**
10501053 * @private
10511054 */
@@ -1105,6 +1108,6 @@
11061109 */
11071110 function haveMsg( $str ) {
11081111 $msg = $this->translator->translate( $str );
1109 - return ($msg != '-') && ($msg != ''); # ????
 1112+ return ( $msg != '-' ) && ( $msg != '' ); # ????
11101113 }
1111 -}
 1114+}
\ No newline at end of file
Index: trunk/phase3/includes/Skin.php
@@ -23,7 +23,7 @@
2424 protected $searchboxes = '';
2525 /**#@-*/
2626 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
27 - protected $skinname = 'standard' ;
 27+ protected $skinname = 'standard';
2828
2929 /** Constructor, call parent constructor */
3030 function Skin() { parent::__construct(); }
@@ -46,10 +46,10 @@
4747 $skinDir = dir( $wgStyleDirectory );
4848
4949 # while code from www.php.net
50 - while (false !== ($file = $skinDir->read())) {
 50+ while( false !== ( $file = $skinDir->read() ) ) {
5151 // Skip non-PHP files, hidden files, and '.dep' includes
5252 $matches = array();
53 - if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
 53+ if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
5454 $aSkin = $matches[1];
5555 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
5656 }
@@ -196,7 +196,7 @@
197197 'title' => wfMsgForContent( 'opensearch-desc' ),
198198 ));
199199
200 - $this->addMetadataLinks($out);
 200+ $this->addMetadataLinks( $out );
201201
202202 $this->mRevisionId = $out->mRevisionId;
203203
@@ -237,13 +237,15 @@
238238 $out->addMetadataLink( array(
239239 'title' => 'Creative Commons',
240240 'type' => 'application/rdf+xml',
241 - 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
 241+ 'href' => $wgTitle->getLocalURL( 'action=creativecommons' ) )
 242+ );
242243 }
243244 if( $wgEnableDublinCoreRdf ) {
244245 $out->addMetadataLink( array(
245246 'title' => 'Dublin Core',
246247 'type' => 'application/rdf+xml',
247 - 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
 248+ 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) )
 249+ );
248250 }
249251 }
250252 $copyright = '';
@@ -259,7 +261,8 @@
260262 if( $copyright ) {
261263 $out->addLink( array(
262264 'rel' => 'copyright',
263 - 'href' => $copyright ) );
 265+ 'href' => $copyright )
 266+ );
264267 }
265268 }
266269
@@ -384,11 +387,11 @@
385388 'wgDigitTransformTable' => $compactDigitTransTable,
386389 );
387390
388 - if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
 391+ if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
389392 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
390393 $vars['wgDBname'] = $wgDBname;
391394 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
392 - $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
 395+ $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
393396 }
394397
395398 foreach( $wgRestrictionTypes as $type )
@@ -409,7 +412,8 @@
410413 $vars['wgAjaxWatch'] = $msgs;
411414 }
412415
413 - wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
 416+ // Allow extensions to add their custom variables to the global JS variables
 417+ wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
414418
415419 return self::makeVariablesScript( $vars );
416420 }
@@ -421,10 +425,10 @@
422426
423427 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
424428 global $wgUseSiteJs;
425 - if ($wgUseSiteJs) {
 429+ if( $wgUseSiteJs ) {
426430 $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
427431 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
428 - htmlspecialchars(self::makeUrl('-',
 432+ htmlspecialchars( self::makeUrl( '-',
429433 "action=raw$jsCache&gen=js&useskin=" .
430434 urlencode( $this->getSkinName() ) ) ) .
431435 "\"><!-- site js --></script>";
@@ -433,7 +437,7 @@
434438 $userpage = $wgUser->getUserPage();
435439 $userjs = htmlspecialchars( self::makeUrl(
436440 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
437 - 'action=raw&ctype='.$wgJsMimeType));
 441+ 'action=raw&ctype='.$wgJsMimeType ) );
438442 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
439443 }
440444 return $vars . "\t\t" . implode ( "\n\t\t", $r );
@@ -485,8 +489,8 @@
486490 $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n";
487491 $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
488492 $s .= "\n\n/* MediaWiki:Common.js */\n";
489 - $commonJs = wfMsgForContent('common.js');
490 - if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
 493+ $commonJs = wfMsgForContent( 'common.js' );
 494+ if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
491495 $s .= $commonJs;
492496 }
493497
@@ -494,7 +498,7 @@
495499 // avoid inclusion of non defined user JavaScript (with custom skins only)
496500 // by checking for default message content
497501 $msgKey = ucfirst( $this->getSkinName() ).'.js';
498 - $userJS = wfMsgForContent($msgKey);
 502+ $userJS = wfMsgForContent( $msgKey );
499503 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
500504 $s .= $userJS;
501505 }
@@ -504,7 +508,7 @@
505509 }
506510
507511 /**
508 - * generate user stylesheet for action=raw&gen=css
 512+ * Generate user stylesheet for action=raw&gen=css
509513 */
510514 public function generateUserStylesheet() {
511515 wfProfileIn( __METHOD__ );
@@ -520,7 +524,7 @@
521525 protected function reallyGenerateUserStylesheet(){
522526 global $wgUser;
523527 $s = '';
524 - if (($undopt = $wgUser->getOption("underline")) < 2) {
 528+ if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
525529 $underline = $undopt ? 'underline' : 'none';
526530 $s .= "a { text-decoration: $underline; }\n";
527531 }
@@ -608,14 +612,14 @@
609613
610614 // Per-user custom style pages
611615 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
612 - $action = $wgRequest->getVal('action');
 616+ $action = $wgRequest->getVal( 'action' );
613617 # If we're previewing the CSS page, use it
614618 if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
615 - $previewCss = $wgRequest->getText('wpTextbox1');
 619+ $previewCss = $wgRequest->getText( 'wpTextbox1' );
616620 // @FIXME: properly escape the cdata!
617621 $this->usercss = "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
618622 } else {
619 - $out->addStyle( self::makeUrl($this->userpage . '/' . $this->getSkinName() .'.css',
 623+ $out->addStyle( self::makeUrl( $this->userpage . '/' . $this->getSkinName() .'.css',
620624 'action=raw&ctype=text/css' ) );
621625 }
622626 }
@@ -643,30 +647,29 @@
644648 $a = array( 'bgcolor' => '#ffffec' );
645649 }
646650 else $a = array( 'bgcolor' => '#FFFFFF' );
647 - if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
 651+ if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
648652 $wgTitle->quickUserCan( 'edit' ) ) {
649653 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
650654 $s = 'document.location = "' .Xml::escapeJsString( $s ) .'";';
651 - $a += array ('ondblclick' => $s);
652 -
 655+ $a += array( 'ondblclick' => $s );
653656 }
654657 $a['onload'] = $wgOut->getOnloadHandler();
655658 $a['class'] =
656659 'mediawiki' .
657 - ' '.( $wgContLang->isRTL() ? "rtl" : "ltr" ).
 660+ ' '.( $wgContLang->isRTL() ? 'rtl' : 'ltr' ).
658661 ' '.$this->getPageClasses( $wgTitle ) .
659 - ' skin-'. Sanitizer::escapeClass( $this->getSkinName( ) );
 662+ ' skin-'. Sanitizer::escapeClass( $this->getSkinName() );
660663 return $a;
661664 }
662665
663666 function getPageClasses( $title ) {
664667 $numeric = 'ns-'.$title->getNamespace();
665668 if( $title->getNamespace() == NS_SPECIAL ) {
666 - $type = "ns-special";
 669+ $type = 'ns-special';
667670 } elseif( $title->isTalkPage() ) {
668 - $type = "ns-talk";
 671+ $type = 'ns-talk';
669672 } else {
670 - $type = "ns-subject";
 673+ $type = 'ns-subject';
671674 }
672675 $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
673676 return "$numeric $type $name";
@@ -690,8 +693,7 @@
691694
692695 function doBeforeContent() {
693696 global $wgContLang;
694 - $fname = 'Skin::doBeforeContent';
695 - wfProfileIn( $fname );
 697+ wfProfileIn( __METHOD__ );
696698
697699 $s = '';
698700 $qb = $this->qbSetting();
@@ -721,10 +723,10 @@
722724 $l = $wgContLang->isRTL() ? 'right' : 'left';
723725 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
724726
725 - $s .= $this->topLinks() ;
 727+ $s .= $this->topLinks();
726728 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
727729
728 - $r = $wgContLang->isRTL() ? "left" : "right";
 730+ $r = $wgContLang->isRTL() ? 'left' : 'right';
729731 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
730732 $s .= $this->nameAndLogin();
731733 $s .= "\n<br />" . $this->searchForm() . "</td>";
@@ -744,9 +746,9 @@
745747 $s .= "\n<div id='siteNotice'>$notice</div>\n";
746748 }
747749 $s .= $this->pageTitle();
748 - $s .= $this->pageSubtitle() ;
 750+ $s .= $this->pageSubtitle();
749751 $s .= $this->getCategories();
750 - wfProfileOut( $fname );
 752+ wfProfileOut( __METHOD__ );
751753 return $s;
752754 }
753755
@@ -770,11 +772,11 @@
771773 $s = '';
772774 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
773775 if ( !empty( $allCats['normal'] ) ) {
774 - $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
 776+ $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
775777
776778 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
777779 $s .= '<div id="mw-normal-catlinks">' .
778 - $this->link( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
 780+ $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
779781 . $colon . $t . '</div>';
780782 }
781783
@@ -802,35 +804,36 @@
803805 $parenttree = $wgTitle->getParentCategoryTree();
804806 # Skin object passed by reference cause it can not be
805807 # accessed under the method subfunction drawCategoryBrowser
806 - $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this) );
 808+ $tempout = explode( "\n", Skin::drawCategoryBrowser( $parenttree, $this ) );
807809 # Clean out bogus first entry and sort them
808 - unset($tempout[0]);
809 - asort($tempout);
 810+ unset( $tempout[0] );
 811+ asort( $tempout );
810812 # Output one per line
811 - $s .= implode("<br />\n", $tempout);
 813+ $s .= implode( "<br />\n", $tempout );
812814 }
813815
814816 return $s;
815817 }
816818
817 - /** Render the array as a serie of links.
 819+ /**
 820+ * Render the array as a serie of links.
818821 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
819822 * @param &skin Object: skin passed by reference
820823 * @return String separated by &gt;, terminate with "\n"
821824 */
822825 function drawCategoryBrowser( $tree, &$skin ){
823826 $return = '';
824 - foreach ($tree as $element => $parent) {
825 - if (empty($parent)) {
 827+ foreach( $tree as $element => $parent ) {
 828+ if( empty( $parent ) ) {
826829 # element start a new list
827830 $return .= "\n";
828831 } else {
829832 # grab the others elements
830 - $return .= Skin::drawCategoryBrowser($parent, $skin) . ' &gt; ';
 833+ $return .= Skin::drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
831834 }
832835 # add our current element to the list
833 - $eltitle = Title::newFromText($element);
834 - $return .= $skin->link( $eltitle, $eltitle->getText() ) ;
 836+ $eltitle = Title::newFromText( $element );
 837+ $return .= $skin->link( $eltitle, $eltitle->getText() );
835838 }
836839 return $return;
837840 }
@@ -869,7 +872,7 @@
870873 * Returns an empty string by default, if not changed by any hook function.
871874 */
872875 protected function afterContentHook() {
873 - $data = "";
 876+ $data = '';
874877
875878 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
876879 // adding just some spaces shouldn't toggle the output
@@ -937,7 +940,7 @@
938941 }
939942
940943 /** overloaded by derived classes */
941 - function doAfterContent() { return "</div></div>"; }
 944+ function doAfterContent() { return '</div></div>'; }
942945
943946 function pageTitleLinks() {
944947 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
@@ -980,8 +983,8 @@
981984 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
982985 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
983986 # disable caching
984 - $wgOut->setSquidMaxage(0);
985 - $wgOut->enableClientCache(false);
 987+ $wgOut->setSquidMaxage( 0 );
 988+ $wgOut->enableClientCache( false );
986989 }
987990 }
988991
@@ -995,9 +998,8 @@
996999 function getUndeleteLink() {
9971000 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
9981001 if( $wgUser->isAllowed( 'deletedhistory' ) &&
999 - (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
1000 - ($n = $wgTitle->isDeleted() ) )
1001 - {
 1002+ ( ( $wgTitle->getArticleId() == 0 ) || ( $action == 'history' ) ) &&
 1003+ ( $n = $wgTitle->isDeleted() ) ){
10021004 if ( $wgUser->isAllowed( 'undelete' ) ) {
10031005 $msg = 'thisisdeleted';
10041006 } else {
@@ -1042,34 +1044,34 @@
10431045 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
10441046 }
10451047 $subpages = $this->subPageSubtitle();
1046 - $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
 1048+ $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
10471049 $s = "<p class='subtitle'>{$sub}</p>\n";
10481050 return $s;
10491051 }
10501052
10511053 function subPageSubtitle() {
10521054 $subpages = '';
1053 - if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
 1055+ if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
10541056 return $subpages;
10551057
10561058 global $wgOut, $wgTitle;
1057 - if($wgOut->isArticle() && MWNamespace::hasSubpages( $wgTitle->getNamespace() )) {
1058 - $ptext=$wgTitle->getPrefixedText();
1059 - if(preg_match('/\//',$ptext)) {
1060 - $links = explode('/',$ptext);
 1059+ if( $wgOut->isArticle() && MWNamespace::hasSubpages( $wgTitle->getNamespace() ) ) {
 1060+ $ptext = $wgTitle->getPrefixedText();
 1061+ if( preg_match( '/\//', $ptext ) ) {
 1062+ $links = explode( '/', $ptext );
10611063 array_pop( $links );
10621064 $c = 0;
10631065 $growinglink = '';
10641066 $display = '';
1065 - foreach($links as $link) {
 1067+ foreach( $links as $link ) {
10661068 $growinglink .= $link;
10671069 $display .= $link;
10681070 $linkObj = Title::newFromText( $growinglink );
10691071 if( is_object( $linkObj ) && $linkObj->exists() ){
10701072 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
10711073 $c++;
1072 - if ($c>1) {
1073 - $subpages .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
 1074+ if( $c > 1 ) {
 1075+ $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
10741076 } else {
10751077 $subpages .= '&lt; ';
10761078 }
@@ -1167,19 +1169,19 @@
11681170 $s = '<form id="searchform'.$this->searchboxes.'" name="search" class="inline" method="post" action="'
11691171 . $this->escapeSearchLink() . "\">\n"
11701172 . '<input type="text" id="searchInput'.$this->searchboxes.'" name="search" size="19" value="'
1171 - . htmlspecialchars(substr($search,0,256)) . "\" />\n"
1172 - . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" />';
1173 -
1174 - if ($wgUseTwoButtonsSearchForm)
1175 - $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n";
 1173+ . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
 1174+ . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
 1175+
 1176+ if( $wgUseTwoButtonsSearchForm )
 1177+ $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
11761178 else
1177 - $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg ('powersearch-legend') . "</a>\n";
1178 -
 1179+ $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
 1180+
11791181 $s .= '</form>';
1180 -
 1182+
11811183 // Ensure unique id's for search boxes made after the first
11821184 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
1183 -
 1185+
11841186 return $s;
11851187 }
11861188
@@ -1207,7 +1209,7 @@
12081210 }
12091211
12101212 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1211 - return implode( $s, wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "\n" );
 1213+ return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
12121214 }
12131215
12141216 /**
@@ -1251,7 +1253,10 @@
12521254 $varname = $wgContLang->getVariantname( $code );
12531255 if( $varname == 'disable' )
12541256 continue;
1255 - $s = $wgLang->pipeList( array( $s, '<a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>' ) );
 1257+ $s = $wgLang->pipeList( array(
 1258+ $s,
 1259+ '<a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
 1260+ ) );
12561261 }
12571262 }
12581263 return $s;
@@ -1259,7 +1264,7 @@
12601265
12611266 function bottomLinks() {
12621267 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1263 - $sep = wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "\n";
 1268+ $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
12641269
12651270 $s = '';
12661271 if ( $wgOut->isArticleRelated() ) {
@@ -1272,17 +1277,15 @@
12731278 $element[] = $this->whatLinksHere();
12741279 $element[] = $this->watchPageLinksLink();
12751280
1276 - if ($wgUseTrackbacks)
 1281+ if( $wgUseTrackbacks )
12771282 $element[] = $this->trackbackLink();
12781283
12791284 if ( $wgTitle->getNamespace() == NS_USER
1280 - || $wgTitle->getNamespace() == NS_USER_TALK )
 1285+ || $wgTitle->getNamespace() == NS_USER_TALK ){
 1286+ $id = User::idFromName( $wgTitle->getText() );
 1287+ $ip = User::isIP( $wgTitle->getText() );
12811288
1282 - {
1283 - $id=User::idFromName($wgTitle->getText());
1284 - $ip=User::isIP($wgTitle->getText());
1285 -
1286 - if($id || $ip) { # both anons and non-anons have contri list
 1289+ if( $id || $ip ) { # both anons and non-anons have contri list
12871290 $element[] = $this->userContribsLink();
12881291 }
12891292 if( $this->showEmailUser( $id ) ) {
@@ -1294,9 +1297,9 @@
12951298
12961299 if ( $wgTitle->getArticleId() ) {
12971300 $s .= "\n<br />";
1298 - if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1299 - if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1300 - if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
 1301+ if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
 1302+ if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
 1303+ if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
13011304 }
13021305 $s .= "<br />\n" . $this->otherLanguages();
13031306 }
@@ -1331,15 +1334,15 @@
13321335
13331336 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
13341337 $dbr = wfGetDB( DB_SLAVE );
1335 - $watchlist = $dbr->tableName( 'watchlist' );
1336 - $sql = "SELECT COUNT(*) AS n FROM $watchlist
1337 - WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1338 - "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1339 - $res = $dbr->query( $sql, 'Skin::pageStats');
 1338+ $res = $dbr->select( 'watchlist',
 1339+ array( 'COUNT(*) AS n' ),
 1340+ array( 'wl_title' => $dbr->strencode( $wgTitle->getDBkey() ), 'wl_namespace' => $wgTitle->getNamespace() ),
 1341+ __METHOD__
 1342+ );
13401343 $x = $dbr->fetchObject( $res );
13411344
13421345 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1343 - array( 'parseinline' ), $wgLang->formatNum($x->n)
 1346+ array( 'parseinline' ), $wgLang->formatNum( $x->n )
13441347 );
13451348 }
13461349
@@ -1428,12 +1431,15 @@
14291432 }
14301433
14311434 function logoText( $align = '' ) {
1432 - if ( '' != $align ) { $a = " align='{$align}'"; }
1433 - else { $a = ''; }
 1435+ if ( '' != $align ) {
 1436+ $a = " align='{$align}'";
 1437+ } else {
 1438+ $a = '';
 1439+ }
14341440
14351441 $mp = wfMsg( 'mainpage' );
14361442 $mptitle = Title::newMainPage();
1437 - $url = ( is_object($mptitle) ? $mptitle->escapeLocalURL() : '' );
 1443+ $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
14381444
14391445 $logourl = $this->getLogo();
14401446 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
@@ -1537,9 +1543,9 @@
15381544 global $wgArticle;
15391545
15401546 if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
1541 - return "action=edit&oldid=" . intval( $this->mRevisionId );
 1547+ return 'action=edit&oldid=' . intval( $this->mRevisionId );
15421548 } else {
1543 - return "action=edit";
 1549+ return 'action=edit';
15441550 }
15451551 }
15461552
@@ -1547,7 +1553,7 @@
15481554 global $wgUser, $wgTitle, $wgRequest;
15491555
15501556 $diff = $wgRequest->getVal( 'diff' );
1551 - if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
 1557+ if ( $wgTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
15521558 $t = wfMsg( 'deletethispage' );
15531559
15541560 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
@@ -1584,11 +1590,11 @@
15851591 if ( $wgTitle->userIsWatching() ) {
15861592 $t = wfMsg( 'unwatchthispage' );
15871593 $q = 'action=unwatch';
1588 - $id = "mw-unwatch-link".$this->mWatchLinkNum;
 1594+ $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
15891595 } else {
15901596 $t = wfMsg( 'watchthispage' );
15911597 $q = 'action=watch';
1592 - $id = 'mw-watch-link'.$this->mWatchLinkNum;
 1598+ $id = 'mw-watch-link' . $this->mWatchLinkNum;
15931599 }
15941600 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
15951601 } else {
@@ -1662,8 +1668,8 @@
16631669 function trackbackLink() {
16641670 global $wgTitle;
16651671
1666 - return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1667 - . wfMsg('trackbacklink') . "</a>";
 1672+ return '<a href="' . $wgTitle->trackbackURL() . '">'
 1673+ . wfMsg( 'trackbacklink' ) . '</a>';
16681674 }
16691675
16701676 function otherLanguages() {
@@ -1680,9 +1686,11 @@
16811687
16821688 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
16831689 $first = true;
1684 - if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
 1690+ if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
16851691 foreach( $a as $l ) {
1686 - if ( ! $first ) { $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); }
 1692+ if ( !$first ) {
 1693+ $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
 1694+ }
16871695 $first = false;
16881696
16891697 $nt = Title::newFromText( $l );
@@ -1693,7 +1701,7 @@
16941702 $style = $this->getExternalLinkAttributes( $l, $text );
16951703 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
16961704 }
1697 - if($wgContLang->isRTL()) $s .= '</span>';
 1705+ if( $wgContLang->isRTL() ) $s .= '</span>';
16981706 return $s;
16991707 }
17001708
@@ -1872,24 +1880,24 @@
18731881 $bar = array();
18741882 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
18751883 $heading = '';
1876 - foreach ($lines as $line) {
1877 - if (strpos($line, '*') !== 0)
 1884+ foreach( $lines as $line ) {
 1885+ if( strpos( $line, '*' ) !== 0 )
18781886 continue;
1879 - if (strpos($line, '**') !== 0) {
1880 - $line = trim($line, '* ');
 1887+ if( strpos( $line, '**') !== 0 ) {
 1888+ $line = trim( $line, '* ' );
18811889 $heading = $line;
1882 - if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
 1890+ if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
18831891 } else {
1884 - if (strpos($line, '|') !== false) { // sanity check
1885 - $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
 1892+ if( strpos( $line, '|' ) !== false ) { // sanity check
 1893+ $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
18861894 $link = wfMsgForContent( $line[0] );
1887 - if ($link == '-')
 1895+ if( $link == '-' )
18881896 continue;
18891897
1890 - $text = wfMsgExt($line[1], 'parsemag');
1891 - if (wfEmptyMsg($line[1], $text))
 1898+ $text = wfMsgExt( $line[1], 'parsemag' );
 1899+ if( wfEmptyMsg( $line[1], $text ) )
18921900 $text = $line[1];
1893 - if (wfEmptyMsg($line[0], $link))
 1901+ if( wfEmptyMsg( $line[0], $link ) )
18941902 $link = $line[0];
18951903
18961904 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
@@ -1907,15 +1915,15 @@
19081916 $bar[$heading][] = array(
19091917 'text' => $text,
19101918 'href' => $href,
1911 - 'id' => 'n-' . strtr($line[1], ' ', '-'),
 1919+ 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
19121920 'active' => false
19131921 );
19141922 } else { continue; }
19151923 }
19161924 }
1917 - wfRunHooks('SkinBuildSidebar', array($this, &$bar));
 1925+ wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
19181926 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
19191927 wfProfileOut( __METHOD__ );
19201928 return $bar;
19211929 }
1922 -}
 1930+}
\ No newline at end of file

Comments

#Comment by Aaron Schulz (talk | contribs)   18:06, 30 March 2009

Note sure I like that bracket change to getUndeleteLink(). It was clearer before. I also see "if( ){" instead of "if( ) {". Was that by mistake?

Status & tagging log