Merge "ResourceLoaderLanguageDataModule: clean up"
[lhc/web/wiklou.git] / includes / SkinTemplate.php
1 <?php
2 /**
3 * Base class for template-based skins.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * Wrapper object for MediaWiki's localization functions,
25 * to be passed to the template engine.
26 *
27 * @private
28 * @ingroup Skins
29 */
30 class MediaWiki_I18N {
31 var $_context = array();
32
33 function set( $varName, $value ) {
34 $this->_context[$varName] = $value;
35 }
36
37 function translate( $value ) {
38 wfProfileIn( __METHOD__ );
39
40 // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
41 $value = preg_replace( '/^string:/', '', $value );
42
43 $value = wfMsg( $value );
44 // interpolate variables
45 $m = array();
46 while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
47 list( $src, $var ) = $m;
48 wfSuppressWarnings();
49 $varValue = $this->_context[$var];
50 wfRestoreWarnings();
51 $value = str_replace( $src, $varValue, $value );
52 }
53 wfProfileOut( __METHOD__ );
54 return $value;
55 }
56 }
57
58 /**
59 * Template-filler skin base class
60 * Formerly generic PHPTal (http://phptal.sourceforge.net/) skin
61 * Based on Brion's smarty skin
62 * @copyright Copyright © Gabriel Wicke -- http://www.aulinx.de/
63 *
64 * @todo Needs some serious refactoring into functions that correspond
65 * to the computations individual esi snippets need. Most importantly no body
66 * parsing for most of those of course.
67 *
68 * @ingroup Skins
69 */
70 class SkinTemplate extends Skin {
71 /**#@+
72 * @private
73 */
74
75 /**
76 * Name of our skin, it probably needs to be all lower case. Child classes
77 * should override the default.
78 */
79 var $skinname = 'monobook';
80
81 /**
82 * Stylesheets set to use. Subdirectory in skins/ where various stylesheets
83 * are located. Child classes should override the default.
84 */
85 var $stylename = 'monobook';
86
87 /**
88 * For QuickTemplate, the name of the subclass which will actually fill the
89 * template. Child classes should override the default.
90 */
91 var $template = 'QuickTemplate';
92
93 /**
94 * Whether this skin use OutputPage::headElement() to generate the <head>
95 * tag
96 */
97 var $useHeadElement = false;
98
99 /**#@-*/
100
101 /**
102 * Add specific styles for this skin
103 *
104 * @param $out OutputPage
105 */
106 function setupSkinUserCss( OutputPage $out ) {
107 $out->addModuleStyles( array( 'mediawiki.legacy.shared', 'mediawiki.legacy.commonPrint' ) );
108 }
109
110 /**
111 * Create the template engine object; we feed it a bunch of data
112 * and eventually it spits out some HTML. Should have interface
113 * roughly equivalent to PHPTAL 0.7.
114 *
115 * @param $classname String
116 * @param $repository string: subdirectory where we keep template files
117 * @param $cache_dir string
118 * @return QuickTemplate
119 * @private
120 */
121 function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
122 return new $classname();
123 }
124
125 /**
126 * initialize various variables and generate the template
127 *
128 * @param $out OutputPage
129 */
130 function outputPage( OutputPage $out=null ) {
131 global $wgContLang;
132 global $wgScript, $wgStylePath;
133 global $wgMimeType, $wgJsMimeType;
134 global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
135 global $wgDisableCounters, $wgSitename, $wgLogo, $wgHideInterlanguageLinks;
136 global $wgMaxCredits, $wgShowCreditsIfMax;
137 global $wgPageShowWatchingUsers;
138 global $wgDebugComments;
139 global $wgArticlePath, $wgScriptPath, $wgServer;
140
141 wfProfileIn( __METHOD__ );
142 Profiler::instance()->setTemplated( true );
143
144 $oldContext = null;
145 if ( $out !== null ) {
146 // @todo Add wfDeprecated in 1.20
147 $oldContext = $this->getContext();
148 $this->setContext( $out->getContext() );
149 }
150
151 $out = $this->getOutput();
152 $request = $this->getRequest();
153 $user = $this->getUser();
154 $title = $this->getTitle();
155
156 wfProfileIn( __METHOD__ . '-init' );
157 $this->initPage( $out );
158
159 $tpl = $this->setupTemplate( $this->template, 'skins' );
160 wfProfileOut( __METHOD__ . '-init' );
161
162 wfProfileIn( __METHOD__ . '-stuff' );
163 $this->thispage = $title->getPrefixedDBkey();
164 $this->titletxt = $title->getPrefixedText();
165 $this->userpage = $user->getUserPage()->getPrefixedText();
166 $query = array();
167 if ( !$request->wasPosted() ) {
168 $query = $request->getValues();
169 unset( $query['title'] );
170 unset( $query['returnto'] );
171 unset( $query['returntoquery'] );
172 }
173 $this->thisquery = wfArrayToCGI( $query );
174 $this->loggedin = $user->isLoggedIn();
175 $this->username = $user->getName();
176
177 if ( $this->loggedin || $this->showIPinHeader() ) {
178 $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
179 } else {
180 # This won't be used in the standard skins, but we define it to preserve the interface
181 # To save time, we check for existence
182 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
183 }
184
185 wfProfileOut( __METHOD__ . '-stuff' );
186
187 wfProfileIn( __METHOD__ . '-stuff-head' );
188 if ( !$this->useHeadElement ) {
189 $tpl->set( 'pagecss', false );
190 $tpl->set( 'usercss', false );
191
192 $tpl->set( 'userjs', false );
193 $tpl->set( 'userjsprev', false );
194
195 $tpl->set( 'jsvarurl', false );
196
197 $tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace );
198 $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
199 $tpl->set( 'html5version', $wgHtml5Version );
200 $tpl->set( 'headlinks', $out->getHeadLinks() );
201 $tpl->set( 'csslinks', $out->buildCssLinks() );
202 $tpl->set( 'pageclass', $this->getPageClasses( $title ) );
203 $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
204 }
205 wfProfileOut( __METHOD__ . '-stuff-head' );
206
207 wfProfileIn( __METHOD__ . '-stuff2' );
208 $tpl->set( 'title', $out->getPageTitle() );
209 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
210 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
211
212 $tpl->setRef( 'thispage', $this->thispage );
213 $tpl->setRef( 'titleprefixeddbkey', $this->thispage );
214 $tpl->set( 'titletext', $title->getText() );
215 $tpl->set( 'articleid', $title->getArticleID() );
216
217 $tpl->set( 'isarticle', $out->isArticle() );
218
219 $subpagestr = $this->subPageSubtitle();
220 if ( $subpagestr !== '' ) {
221 $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
222 }
223 $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
224
225 $undelete = $this->getUndeleteLink();
226 if ( $undelete === '' ) {
227 $tpl->set( 'undelete', '' );
228 } else {
229 $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
230 }
231
232 $tpl->set( 'catlinks', $this->getCategories() );
233 if( $out->isSyndicated() ) {
234 $feeds = array();
235 foreach( $out->getSyndicationLinks() as $format => $link ) {
236 $feeds[$format] = array(
237 'text' => $this->msg( "feed-$format" )->text(),
238 'href' => $link
239 );
240 }
241 $tpl->setRef( 'feeds', $feeds );
242 } else {
243 $tpl->set( 'feeds', false );
244 }
245
246 $tpl->setRef( 'mimetype', $wgMimeType );
247 $tpl->setRef( 'jsmimetype', $wgJsMimeType );
248 $tpl->set( 'charset', 'UTF-8' );
249 $tpl->setRef( 'wgScript', $wgScript );
250 $tpl->setRef( 'skinname', $this->skinname );
251 $tpl->set( 'skinclass', get_class( $this ) );
252 $tpl->setRef( 'skin', $this );
253 $tpl->setRef( 'stylename', $this->stylename );
254 $tpl->set( 'printable', $out->isPrintable() );
255 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
256 $tpl->setRef( 'loggedin', $this->loggedin );
257 $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
258 /* XXX currently unused, might get useful later
259 $tpl->set( 'editable', ( !$title->isSpecialPage() ) );
260 $tpl->set( 'exists', $title->getArticleID() != 0 );
261 $tpl->set( 'watch', $title->userIsWatching() ? 'unwatch' : 'watch' );
262 $tpl->set( 'protect', count( $title->isProtected() ) ? 'unprotect' : 'protect' );
263 $tpl->set( 'helppage', $this->msg( 'helppage' )->text() );
264 */
265 $tpl->set( 'searchaction', $this->escapeSearchLink() );
266 $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBKey() );
267 $tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
268 $tpl->setRef( 'stylepath', $wgStylePath );
269 $tpl->setRef( 'articlepath', $wgArticlePath );
270 $tpl->setRef( 'scriptpath', $wgScriptPath );
271 $tpl->setRef( 'serverurl', $wgServer );
272 $tpl->setRef( 'logopath', $wgLogo );
273 $tpl->setRef( 'sitename', $wgSitename );
274
275 $lang = $this->getLanguage();
276 $userlang = $lang->getHtmlCode();
277 $userdir = $lang->getDir();
278
279 $tpl->set( 'lang', $userlang );
280 $tpl->set( 'dir', $userdir );
281 $tpl->set( 'rtl', $lang->isRTL() );
282
283 $tpl->set( 'capitalizeallnouns', $lang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
284 $tpl->set( 'showjumplinks', $user->getOption( 'showjumplinks' ) );
285 $tpl->set( 'username', $this->loggedin ? $this->username : null );
286 $tpl->setRef( 'userpage', $this->userpage );
287 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
288 $tpl->set( 'userlang', $userlang );
289
290 // Users can have their language set differently than the
291 // content of the wiki. For these users, tell the web browser
292 // that interface elements are in a different language.
293 $tpl->set( 'userlangattributes', '' );
294 $tpl->set( 'specialpageattributes', '' ); # obsolete
295
296 if ( $userlang !== $wgContLang->getHtmlCode() || $userdir !== $wgContLang->getDir() ) {
297 $attrs = " lang='$userlang' dir='$userdir'";
298 $tpl->set( 'userlangattributes', $attrs );
299 }
300
301 wfProfileOut( __METHOD__ . '-stuff2' );
302
303 wfProfileIn( __METHOD__ . '-stuff3' );
304 $tpl->set( 'newtalk', $this->getNewtalks() );
305 $tpl->set( 'logo', $this->logoText() );
306
307 $tpl->set( 'copyright', false );
308 $tpl->set( 'viewcount', false );
309 $tpl->set( 'lastmod', false );
310 $tpl->set( 'credits', false );
311 $tpl->set( 'numberofwatchingusers', false );
312 if ( $out->isArticle() && $title->exists() ) {
313 if ( $this->isRevisionCurrent() ) {
314 if ( !$wgDisableCounters ) {
315 $viewcount = $this->getWikiPage()->getCount();
316 if ( $viewcount ) {
317 $tpl->set( 'viewcount', $this->msg( 'viewcount' )->numParams( $viewcount )->parse() );
318 }
319 }
320
321 if( $wgPageShowWatchingUsers ) {
322 $dbr = wfGetDB( DB_SLAVE );
323 $num = $dbr->selectField( 'watchlist', 'COUNT(*)',
324 array( 'wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace() ),
325 __METHOD__
326 );
327 if( $num > 0 ) {
328 $tpl->set( 'numberofwatchingusers',
329 $this->msg( 'number_of_watching_users_pageview' )->numParams( $num )->parse()
330 );
331 }
332 }
333
334 if ( $wgMaxCredits != 0 ) {
335 $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
336 $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
337 } else {
338 $tpl->set( 'lastmod', $this->lastModified() );
339 }
340 }
341 $tpl->set( 'copyright', $this->getCopyright() );
342 }
343 wfProfileOut( __METHOD__ . '-stuff3' );
344
345 wfProfileIn( __METHOD__ . '-stuff4' );
346 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
347 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
348 $tpl->set( 'disclaimer', $this->disclaimerLink() );
349 $tpl->set( 'privacy', $this->privacyLink() );
350 $tpl->set( 'about', $this->aboutLink() );
351
352 $tpl->set( 'footerlinks', array(
353 'info' => array(
354 'lastmod',
355 'viewcount',
356 'numberofwatchingusers',
357 'credits',
358 'copyright',
359 ),
360 'places' => array(
361 'privacy',
362 'about',
363 'disclaimer',
364 ),
365 ) );
366
367 global $wgFooterIcons;
368 $tpl->set( 'footericons', $wgFooterIcons );
369 foreach ( $tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock ) {
370 if ( count( $footerIconsBlock ) > 0 ) {
371 foreach ( $footerIconsBlock as &$footerIcon ) {
372 if ( isset( $footerIcon['src'] ) ) {
373 if ( !isset( $footerIcon['width'] ) ) {
374 $footerIcon['width'] = 88;
375 }
376 if ( !isset( $footerIcon['height'] ) ) {
377 $footerIcon['height'] = 31;
378 }
379 }
380 }
381 } else {
382 unset( $tpl->data['footericons'][$footerIconsKey] );
383 }
384 }
385
386 if ( $wgDebugComments ) {
387 $tpl->setRef( 'debug', $out->mDebugtext );
388 } else {
389 $tpl->set( 'debug', '' );
390 }
391
392 $tpl->set( 'sitenotice', $this->getSiteNotice() );
393 $tpl->set( 'bottomscripts', $this->bottomScripts() );
394 $tpl->set( 'printfooter', $this->printSource() );
395
396 # An ID that includes the actual body text; without categories, contentSub, ...
397 $realBodyAttribs = array( 'id' => 'mw-content-text' );
398
399 # Add a mw-content-ltr/rtl class to be able to style based on text direction
400 # when the content is different from the UI language, i.e.:
401 # not for special pages or file pages AND only when viewing AND if the page exists
402 # (or is in MW namespace, because that has default content)
403 if( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
404 in_array( $request->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) &&
405 ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) {
406 $pageLang = $title->getPageLanguage();
407 $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
408 $realBodyAttribs['dir'] = $pageLang->getDir();
409 $realBodyAttribs['class'] = 'mw-content-'.$pageLang->getDir();
410 }
411
412 $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
413 $tpl->setRef( 'bodytext', $out->mBodytext );
414
415 # Language links
416 $language_urls = array();
417
418 if ( !$wgHideInterlanguageLinks ) {
419 foreach( $out->getLanguageLinks() as $l ) {
420 $tmp = explode( ':', $l, 2 );
421 $class = 'interwiki-' . $tmp[0];
422 unset( $tmp );
423 $nt = Title::newFromText( $l );
424 if ( $nt ) {
425 $language_urls[] = array(
426 'href' => $nt->getFullURL(),
427 'text' => ( Language::fetchLanguageName( $nt->getInterwiki() ) != '' ?
428 Language::fetchLanguageName( $nt->getInterwiki() ) : $l ),
429 'title' => $nt->getText(),
430 'class' => $class,
431 'lang' => $nt->getInterwiki(),
432 'hreflang' => $nt->getInterwiki(),
433 );
434 }
435 }
436 }
437 if( count( $language_urls ) ) {
438 $tpl->setRef( 'language_urls', $language_urls );
439 } else {
440 $tpl->set( 'language_urls', false );
441 }
442 wfProfileOut( __METHOD__ . '-stuff4' );
443
444 wfProfileIn( __METHOD__ . '-stuff5' );
445 # Personal toolbar
446 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
447 $content_navigation = $this->buildContentNavigationUrls();
448 $content_actions = $this->buildContentActionUrls( $content_navigation );
449 $tpl->setRef( 'content_navigation', $content_navigation );
450 $tpl->setRef( 'content_actions', $content_actions );
451
452 $tpl->set( 'sidebar', $this->buildSidebar() );
453 $tpl->set( 'nav_urls', $this->buildNavUrls() );
454
455 // Set the head scripts near the end, in case the above actions resulted in added scripts
456 if ( $this->useHeadElement ) {
457 $tpl->set( 'headelement', $out->headElement( $this ) );
458 } else {
459 $tpl->set( 'headscripts', $out->getHeadScripts() . $out->getHeadItems() );
460 }
461
462 $tpl->set( 'debughtml', $this->generateDebugHTML() );
463 $tpl->set( 'reporttime', wfReportTime() );
464
465 // original version by hansm
466 if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
467 wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
468 }
469
470 // Set the bodytext to another key so that skins can just output it on it's own
471 // and output printfooter and debughtml separately
472 $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
473
474 // Append printfooter and debughtml onto bodytext so that skins that were already
475 // using bodytext before they were split out don't suddenly start not outputting information
476 $tpl->data['bodytext'] .= Html::rawElement( 'div', array( 'class' => 'printfooter' ), "\n{$tpl->data['printfooter']}" ) . "\n";
477 $tpl->data['bodytext'] .= $tpl->data['debughtml'];
478
479 // allow extensions adding stuff after the page content.
480 // See Skin::afterContentHook() for further documentation.
481 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
482 wfProfileOut( __METHOD__ . '-stuff5' );
483
484 // execute template
485 wfProfileIn( __METHOD__ . '-execute' );
486 $res = $tpl->execute();
487 wfProfileOut( __METHOD__ . '-execute' );
488
489 // result may be an error
490 $this->printOrError( $res );
491
492 if ( $oldContext ) {
493 $this->setContext( $oldContext );
494 }
495 wfProfileOut( __METHOD__ );
496 }
497
498 /**
499 * Output the string, or print error message if it's
500 * an error object of the appropriate type.
501 * For the base class, assume strings all around.
502 *
503 * @param $str Mixed
504 * @private
505 */
506 function printOrError( $str ) {
507 echo $str;
508 }
509
510 /**
511 * Output a boolean indiciating if buildPersonalUrls should output separate
512 * login and create account links or output a combined link
513 * By default we simply return a global config setting that affects most skins
514 * This is setup as a method so that like with $wgLogo and getLogo() a skin
515 * can override this setting and always output one or the other if it has
516 * a reason it can't output one of the two modes.
517 * @return bool
518 */
519 function useCombinedLoginLink() {
520 global $wgUseCombinedLoginLink;
521 return $wgUseCombinedLoginLink;
522 }
523
524 /**
525 * build array of urls for personal toolbar
526 * @return array
527 */
528 protected function buildPersonalUrls() {
529 $title = $this->getTitle();
530 $request = $this->getRequest();
531 $pageurl = $title->getLocalURL();
532 wfProfileIn( __METHOD__ );
533
534 /* set up the default links for the personal toolbar */
535 $personal_urls = array();
536
537 # Due to bug 32276, if a user does not have read permissions,
538 # $this->getTitle() will just give Special:Badtitle, which is
539 # not especially useful as a returnto parameter. Use the title
540 # from the request instead, if there was one.
541 $page = Title::newFromURL( $request->getVal( 'title', '' ) );
542 $page = $request->getVal( 'returnto', $page );
543 $a = array();
544 if ( strval( $page ) !== '' ) {
545 $a['returnto'] = $page;
546 $query = $request->getVal( 'returntoquery', $this->thisquery );
547 if( $query != '' ) {
548 $a['returntoquery'] = $query;
549 }
550 }
551 $returnto = wfArrayToCGI( $a );
552 if( $this->loggedin ) {
553 $personal_urls['userpage'] = array(
554 'text' => $this->username,
555 'href' => &$this->userpageUrlDetails['href'],
556 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
557 'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
558 );
559 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
560 $personal_urls['mytalk'] = array(
561 'text' => $this->msg( 'mytalk' )->text(),
562 'href' => &$usertalkUrlDetails['href'],
563 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
564 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
565 );
566 $href = self::makeSpecialUrl( 'Preferences' );
567 $personal_urls['preferences'] = array(
568 'text' => $this->msg( 'mypreferences' )->text(),
569 'href' => $href,
570 'active' => ( $href == $pageurl )
571 );
572 $href = self::makeSpecialUrl( 'Watchlist' );
573 $personal_urls['watchlist'] = array(
574 'text' => $this->msg( 'mywatchlist' )->text(),
575 'href' => $href,
576 'active' => ( $href == $pageurl )
577 );
578
579 # We need to do an explicit check for Special:Contributions, as we
580 # have to match both the title, and the target, which could come
581 # from request values (Special:Contributions?target=Jimbo_Wales)
582 # or be specified in "sub page" form
583 # (Special:Contributions/Jimbo_Wales). The plot
584 # thickens, because the Title object is altered for special pages,
585 # so it doesn't contain the original alias-with-subpage.
586 $origTitle = Title::newFromText( $request->getText( 'title' ) );
587 if( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
588 list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
589 $active = $spName == 'Contributions'
590 && ( ( $spPar && $spPar == $this->username )
591 || $request->getText( 'target' ) == $this->username );
592 } else {
593 $active = false;
594 }
595
596 $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
597 $personal_urls['mycontris'] = array(
598 'text' => $this->msg( 'mycontris' )->text(),
599 'href' => $href,
600 'active' => $active
601 );
602 $personal_urls['logout'] = array(
603 'text' => $this->msg( 'userlogout' )->text(),
604 'href' => self::makeSpecialUrl( 'Userlogout',
605 // userlogout link must always contain an & character, otherwise we might not be able
606 // to detect a buggy precaching proxy (bug 17790)
607 $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
608 ),
609 'active' => false
610 );
611 } else {
612 $useCombinedLoginLink = $this->useCombinedLoginLink();
613 $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
614 ? 'nav-login-createaccount'
615 : 'login';
616 $is_signup = $request->getText('type') == "signup";
617
618 # anonlogin & login are the same
619 $login_url = array(
620 'text' => $this->msg( $loginlink )->text(),
621 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
622 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == "nav-login-createaccount" || !$is_signup )
623 );
624 if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
625 $createaccount_url = array(
626 'text' => $this->msg( 'createaccount' )->text(),
627 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
628 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
629 );
630 }
631 global $wgServer, $wgSecureLogin;
632 if( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
633 $title = SpecialPage::getTitleFor( 'Userlogin' );
634 $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
635 $login_url['href'] = $https_url;
636 # @todo FIXME: Class depends on skin
637 $login_url['class'] = 'link-https';
638 if ( isset($createaccount_url) ) {
639 $https_url = preg_replace( '/^http:/', 'https:',
640 $title->getFullURL("type=signup") );
641 $createaccount_url['href'] = $https_url;
642 # @todo FIXME: Class depends on skin
643 $createaccount_url['class'] = 'link-https';
644 }
645 }
646
647 if ( isset( $createaccount_url ) ) {
648 $personal_urls['createaccount'] = $createaccount_url;
649 }
650
651 if( $this->showIPinHeader() ) {
652 $href = &$this->userpageUrlDetails['href'];
653 $personal_urls['anonuserpage'] = array(
654 'text' => $this->username,
655 'href' => $href,
656 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
657 'active' => ( $pageurl == $href )
658 );
659 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
660 $href = &$usertalkUrlDetails['href'];
661 $personal_urls['anontalk'] = array(
662 'text' => $this->msg( 'anontalk' )->text(),
663 'href' => $href,
664 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
665 'active' => ( $pageurl == $href )
666 );
667 $personal_urls['anonlogin'] = $login_url;
668 } else {
669 $personal_urls['login'] = $login_url;
670 }
671 }
672
673 wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) );
674 wfProfileOut( __METHOD__ );
675 return $personal_urls;
676 }
677
678 /**
679 * TODO document
680 * @param $title Title
681 * @param $message String message key
682 * @param $selected Bool
683 * @param $query String
684 * @param $checkEdit Bool
685 * @return array
686 */
687 function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
688 $classes = array();
689 if( $selected ) {
690 $classes[] = 'selected';
691 }
692 if( $checkEdit && !$title->isKnown() ) {
693 $classes[] = 'new';
694 $query = 'action=edit&redlink=1';
695 }
696
697 // wfMessageFallback will nicely accept $message as an array of fallbacks
698 // or just a single key
699 $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
700 if ( is_array($message) ) {
701 // for hook compatibility just keep the last message name
702 $message = end($message);
703 }
704 if ( $msg->exists() ) {
705 $text = $msg->text();
706 } else {
707 global $wgContLang;
708 $text = $wgContLang->getFormattedNsText(
709 MWNamespace::getSubject( $title->getNamespace() ) );
710 }
711
712 $result = array();
713 if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
714 $title, $message, $selected, $checkEdit,
715 &$classes, &$query, &$text, &$result ) ) ) {
716 return $result;
717 }
718
719 return array(
720 'class' => implode( ' ', $classes ),
721 'text' => $text,
722 'href' => $title->getLocalUrl( $query ),
723 'primary' => true );
724 }
725
726 function makeTalkUrlDetails( $name, $urlaction = '' ) {
727 $title = Title::newFromText( $name );
728 if( !is_object( $title ) ) {
729 throw new MWException( __METHOD__ . " given invalid pagename $name" );
730 }
731 $title = $title->getTalkPage();
732 self::checkTitle( $title, $name );
733 return array(
734 'href' => $title->getLocalURL( $urlaction ),
735 'exists' => $title->getArticleID() != 0,
736 );
737 }
738
739 function makeArticleUrlDetails( $name, $urlaction = '' ) {
740 $title = Title::newFromText( $name );
741 $title= $title->getSubjectPage();
742 self::checkTitle( $title, $name );
743 return array(
744 'href' => $title->getLocalURL( $urlaction ),
745 'exists' => $title->getArticleID() != 0,
746 );
747 }
748
749 /**
750 * a structured array of links usually used for the tabs in a skin
751 *
752 * There are 4 standard sections
753 * namespaces: Used for namespace tabs like special, page, and talk namespaces
754 * views: Used for primary page views like read, edit, history
755 * actions: Used for most extra page actions like deletion, protection, etc...
756 * variants: Used to list the language variants for the page
757 *
758 * Each section's value is a key/value array of links for that section.
759 * The links themseves have these common keys:
760 * - class: The css classes to apply to the tab
761 * - text: The text to display on the tab
762 * - href: The href for the tab to point to
763 * - rel: An optional rel= for the tab's link
764 * - redundant: If true the tab will be dropped in skins using content_actions
765 * this is useful for tabs like "Read" which only have meaning in skins that
766 * take special meaning from the grouped structure of content_navigation
767 *
768 * Views also have an extra key which can be used:
769 * - primary: If this is not true skins like vector may try to hide the tab
770 * when the user has limited space in their browser window
771 *
772 * content_navigation using code also expects these ids to be present on the
773 * links, however these are usually automatically generated by SkinTemplate
774 * itself and are not necessary when using a hook. The only things these may
775 * matter to are people modifying content_navigation after it's initial creation:
776 * - id: A "preferred" id, most skins are best off outputting this preferred id for best compatibility
777 * - tooltiponly: This is set to true for some tabs in cases where the system
778 * believes that the accesskey should not be added to the tab.
779 *
780 * @return array
781 */
782 protected function buildContentNavigationUrls() {
783 global $wgDisableLangConversion;
784
785 wfProfileIn( __METHOD__ );
786
787 $title = $this->getRelevantTitle(); // Display tabs for the relevant title rather than always the title itself
788 $onPage = $title->equals($this->getTitle());
789
790 $out = $this->getOutput();
791 $request = $this->getRequest();
792 $user = $this->getUser();
793
794 $content_navigation = array(
795 'namespaces' => array(),
796 'views' => array(),
797 'actions' => array(),
798 'variants' => array()
799 );
800
801 // parameters
802 $action = $request->getVal( 'action', 'view' );
803
804 $userCanRead = $title->quickUserCan( 'read', $user );
805
806 $preventActiveTabs = false;
807 wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
808
809 // Checks if page is some kind of content
810 if( $title->canExist() ) {
811 // Gets page objects for the related namespaces
812 $subjectPage = $title->getSubjectPage();
813 $talkPage = $title->getTalkPage();
814
815 // Determines if this is a talk page
816 $isTalk = $title->isTalkPage();
817
818 // Generates XML IDs from namespace names
819 $subjectId = $title->getNamespaceKey( '' );
820
821 if ( $subjectId == 'main' ) {
822 $talkId = 'talk';
823 } else {
824 $talkId = "{$subjectId}_talk";
825 }
826
827 $skname = $this->skinname;
828
829 // Adds namespace links
830 $subjectMsg = array( "nstab-$subjectId" );
831 if ( $subjectPage->isMainPage() ) {
832 array_unshift($subjectMsg, 'mainpage-nstab');
833 }
834 $content_navigation['namespaces'][$subjectId] = $this->tabAction(
835 $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
836 );
837 $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
838 $content_navigation['namespaces'][$talkId] = $this->tabAction(
839 $talkPage, array( "nstab-$talkId", 'talk' ), $isTalk && !$preventActiveTabs, '', $userCanRead
840 );
841 $content_navigation['namespaces'][$talkId]['context'] = 'talk';
842
843 if ( $userCanRead ) {
844 // Adds view view link
845 if ( $title->exists() ) {
846 $content_navigation['views']['view'] = $this->tabAction(
847 $isTalk ? $talkPage : $subjectPage,
848 array( "$skname-view-view", 'view' ),
849 ( $onPage && ($action == 'view' || $action == 'purge' ) ), '', true
850 );
851 $content_navigation['views']['view']['redundant'] = true; // signal to hide this from simple content_actions
852 }
853
854 wfProfileIn( __METHOD__ . '-edit' );
855
856 // Checks if user can edit the current page if it exists or create it otherwise
857 if ( $title->quickUserCan( 'edit', $user ) && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) ) {
858 // Builds CSS class for talk page links
859 $isTalkClass = $isTalk ? ' istalk' : '';
860 // Whether the user is editing the page
861 $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
862 // Whether to show the "Add a new section" tab
863 // Checks if this is a current rev of talk page and is not forced to be hidden
864 $showNewSection = !$out->forceHideNewSectionLink()
865 && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
866 $section = $request->getVal( 'section' );
867
868 $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ?
869 "edit" : "create";
870 $content_navigation['views']['edit'] = array(
871 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass,
872 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(),
873 'href' => $title->getLocalURL( $this->editUrlOptions() ),
874 'primary' => true, // don't collapse this in vector
875 );
876
877 // section link
878 if ( $showNewSection ) {
879 // Adds new section link
880 //$content_navigation['actions']['addsection']
881 $content_navigation['views']['addsection'] = array(
882 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
883 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(),
884 'href' => $title->getLocalURL( 'action=edit&section=new' )
885 );
886 }
887 // Checks if the page has some kind of viewable content
888 } elseif ( $title->hasSourceText() ) {
889 // Adds view source view link
890 $content_navigation['views']['viewsource'] = array(
891 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
892 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->setContext( $this->getContext() )->text(),
893 'href' => $title->getLocalURL( $this->editUrlOptions() ),
894 'primary' => true, // don't collapse this in vector
895 );
896 }
897 wfProfileOut( __METHOD__ . '-edit' );
898
899 wfProfileIn( __METHOD__ . '-live' );
900 // Checks if the page exists
901 if ( $title->exists() ) {
902 // Adds history view link
903 $content_navigation['views']['history'] = array(
904 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
905 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->setContext( $this->getContext() )->text(),
906 'href' => $title->getLocalURL( 'action=history' ),
907 'rel' => 'archives',
908 );
909
910 if ( $title->quickUserCan( 'delete', $user ) ) {
911 $content_navigation['actions']['delete'] = array(
912 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
913 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->setContext( $this->getContext() )->text(),
914 'href' => $title->getLocalURL( 'action=delete' )
915 );
916 }
917
918 if ( $title->quickUserCan( 'move', $user ) ) {
919 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
920 $content_navigation['actions']['move'] = array(
921 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
922 'text' => wfMessageFallback( "$skname-action-move", 'move' )->setContext( $this->getContext() )->text(),
923 'href' => $moveTitle->getLocalURL()
924 );
925 }
926 } else {
927 // article doesn't exist or is deleted
928 if ( $user->isAllowed( 'deletedhistory' ) ) {
929 $n = $title->isDeleted();
930 if( $n ) {
931 $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
932 // If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
933 $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
934 $content_navigation['actions']['undelete'] = array(
935 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
936 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
937 ->setContext( $this->getContext() )->numParams( $n )->text(),
938 'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) )
939 );
940 }
941 }
942 }
943
944 if ( $title->getNamespace() !== NS_MEDIAWIKI && $title->quickUserCan( 'protect', $user ) ) {
945 $mode = $title->isProtected() ? 'unprotect' : 'protect';
946 $content_navigation['actions'][$mode] = array(
947 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
948 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(),
949 'href' => $title->getLocalURL( "action=$mode" )
950 );
951 }
952
953 wfProfileOut( __METHOD__ . '-live' );
954
955 // Checks if the user is logged in
956 if ( $this->loggedin ) {
957 /**
958 * The following actions use messages which, if made particular to
959 * the any specific skins, would break the Ajax code which makes this
960 * action happen entirely inline. Skin::makeGlobalVariablesScript
961 * defines a set of messages in a javascript object - and these
962 * messages are assumed to be global for all skins. Without making
963 * a change to that procedure these messages will have to remain as
964 * the global versions.
965 */
966 $mode = $title->userIsWatching() ? 'unwatch' : 'watch';
967 $token = WatchAction::getWatchToken( $title, $user, $mode );
968 $content_navigation['actions'][$mode] = array(
969 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
970 'text' => $this->msg( $mode )->text(), // uses 'watch' or 'unwatch' message
971 'href' => $title->getLocalURL( array( 'action' => $mode, 'token' => $token ) )
972 );
973 }
974 }
975
976 wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$content_navigation ) );
977
978 if ( $userCanRead && !$wgDisableLangConversion ) {
979 $pageLang = $title->getPageLanguage();
980 // Gets list of language variants
981 $variants = $pageLang->getVariants();
982 // Checks that language conversion is enabled and variants exist
983 // And if it is not in the special namespace
984 if( count( $variants ) > 1 ) {
985 // Gets preferred variant (note that user preference is
986 // only possible for wiki content language variant)
987 $preferred = $pageLang->getPreferredVariant();
988 // Loops over each variant
989 foreach( $variants as $code ) {
990 // Gets variant name from language code
991 $varname = $pageLang->getVariantname( $code );
992 // Checks if the variant is marked as disabled
993 if( $varname == 'disable' ) {
994 // Skips this variant
995 continue;
996 }
997 // Appends variant link
998 $content_navigation['variants'][] = array(
999 'class' => ( $code == $preferred ) ? 'selected' : false,
1000 'text' => $varname,
1001 'href' => $title->getLocalURL( array( 'variant' => $code ) ),
1002 'lang' => $code,
1003 'hreflang' => $code
1004 );
1005 }
1006 }
1007 }
1008 } else {
1009 // If it's not content, it's got to be a special page
1010 $content_navigation['namespaces']['special'] = array(
1011 'class' => 'selected',
1012 'text' => $this->msg( 'nstab-special' )->text(),
1013 'href' => $request->getRequestURL(), // @bug 2457, 2510
1014 'context' => 'subject'
1015 );
1016
1017 wfRunHooks( 'SkinTemplateNavigation::SpecialPage',
1018 array( &$this, &$content_navigation ) );
1019 }
1020
1021 // Equiv to SkinTemplateContentActions
1022 wfRunHooks( 'SkinTemplateNavigation::Universal', array( &$this, &$content_navigation ) );
1023
1024 // Setup xml ids and tooltip info
1025 foreach ( $content_navigation as $section => &$links ) {
1026 foreach ( $links as $key => &$link ) {
1027 $xmlID = $key;
1028 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1029 $xmlID = 'ca-nstab-' . $xmlID;
1030 } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1031 $xmlID = 'ca-talk';
1032 } elseif ( $section == "variants" ) {
1033 $xmlID = 'ca-varlang-' . $xmlID;
1034 } else {
1035 $xmlID = 'ca-' . $xmlID;
1036 }
1037 $link['id'] = $xmlID;
1038 }
1039 }
1040
1041 # We don't want to give the watch tab an accesskey if the
1042 # page is being edited, because that conflicts with the
1043 # accesskey on the watch checkbox. We also don't want to
1044 # give the edit tab an accesskey, because that's fairly su-
1045 # perfluous and conflicts with an accesskey (Ctrl-E) often
1046 # used for editing in Safari.
1047 if( in_array( $action, array( 'edit', 'submit' ) ) ) {
1048 if ( isset($content_navigation['views']['edit']) ) {
1049 $content_navigation['views']['edit']['tooltiponly'] = true;
1050 }
1051 if ( isset($content_navigation['actions']['watch']) ) {
1052 $content_navigation['actions']['watch']['tooltiponly'] = true;
1053 }
1054 if ( isset($content_navigation['actions']['unwatch']) ) {
1055 $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1056 }
1057 }
1058
1059 wfProfileOut( __METHOD__ );
1060
1061 return $content_navigation;
1062 }
1063
1064 /**
1065 * an array of edit links by default used for the tabs
1066 * @return array
1067 * @private
1068 */
1069 function buildContentActionUrls( $content_navigation ) {
1070
1071 wfProfileIn( __METHOD__ );
1072
1073 // content_actions has been replaced with content_navigation for backwards
1074 // compatibility and also for skins that just want simple tabs content_actions
1075 // is now built by flattening the content_navigation arrays into one
1076
1077 $content_actions = array();
1078
1079 foreach ( $content_navigation as $links ) {
1080
1081 foreach ( $links as $key => $value ) {
1082
1083 if ( isset($value["redundant"]) && $value["redundant"] ) {
1084 // Redundant tabs are dropped from content_actions
1085 continue;
1086 }
1087
1088 // content_actions used to have ids built using the "ca-$key" pattern
1089 // so the xmlID based id is much closer to the actual $key that we want
1090 // for that reason we'll just strip out the ca- if present and use
1091 // the latter potion of the "id" as the $key
1092 if ( isset($value["id"]) && substr($value["id"], 0, 3) == "ca-" ) {
1093 $key = substr($value["id"], 3);
1094 }
1095
1096 if ( isset($content_actions[$key]) ) {
1097 wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening content_navigation into content_actions." );
1098 continue;
1099 }
1100
1101 $content_actions[$key] = $value;
1102
1103 }
1104
1105 }
1106
1107 wfProfileOut( __METHOD__ );
1108
1109 return $content_actions;
1110 }
1111
1112 /**
1113 * build array of common navigation links
1114 * @return array
1115 * @private
1116 */
1117 protected function buildNavUrls() {
1118 global $wgUploadNavigationUrl;
1119
1120 wfProfileIn( __METHOD__ );
1121
1122 $out = $this->getOutput();
1123 $request = $this->getRequest();
1124
1125 $nav_urls = array();
1126 $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
1127 if( $wgUploadNavigationUrl ) {
1128 $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
1129 } elseif( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1130 $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
1131 } else {
1132 $nav_urls['upload'] = false;
1133 }
1134 $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
1135
1136 $nav_urls['print'] = false;
1137 $nav_urls['permalink'] = false;
1138 $nav_urls['whatlinkshere'] = false;
1139 $nav_urls['recentchangeslinked'] = false;
1140 $nav_urls['contributions'] = false;
1141 $nav_urls['log'] = false;
1142 $nav_urls['blockip'] = false;
1143 $nav_urls['emailuser'] = false;
1144
1145 // A print stylesheet is attached to all pages, but nobody ever
1146 // figures that out. :) Add a link...
1147 if( $out->isArticle() ) {
1148 if ( !$out->isPrintable() ) {
1149 $nav_urls['print'] = array(
1150 'text' => $this->msg( 'printableversion' )->text(),
1151 'href' => $this->getTitle()->getLocalURL(
1152 $request->appendQueryValue( 'printable', 'yes', true ) )
1153 );
1154 }
1155
1156 // Also add a "permalink" while we're at it
1157 $revid = $this->getRevisionId();
1158 if ( $revid ) {
1159 $nav_urls['permalink'] = array(
1160 'text' => $this->msg( 'permalink' )->text(),
1161 'href' => $out->getTitle()->getLocalURL( "oldid=$revid" )
1162 );
1163 }
1164
1165 // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1166 wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1167 array( &$this, &$nav_urls, &$revid, &$revid ) );
1168 }
1169
1170 if ( $out->isArticleRelated() ) {
1171 $nav_urls['whatlinkshere'] = array(
1172 'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalUrl()
1173 );
1174 if ( $this->getTitle()->getArticleID() ) {
1175 $nav_urls['recentchangeslinked'] = array(
1176 'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalUrl()
1177 );
1178 }
1179 }
1180
1181 $user = $this->getRelevantUser();
1182 if ( $user ) {
1183 $rootUser = $user->getName();
1184
1185 $nav_urls['contributions'] = array(
1186 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
1187 );
1188
1189 $logPage = SpecialPage::getTitleFor( 'Log' );
1190 $nav_urls['log'] = array(
1191 'href' => $logPage->getLocalUrl( array( 'user' => $rootUser ) )
1192 );
1193
1194 if ( $this->getUser()->isAllowed( 'block' ) ) {
1195 $nav_urls['blockip'] = array(
1196 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1197 );
1198 }
1199
1200 if ( $this->showEmailUser( $user ) ) {
1201 $nav_urls['emailuser'] = array(
1202 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser )
1203 );
1204 }
1205 }
1206
1207 wfProfileOut( __METHOD__ );
1208 return $nav_urls;
1209 }
1210
1211 /**
1212 * Generate strings used for xml 'id' names
1213 * @return string
1214 * @private
1215 */
1216 function getNameSpaceKey() {
1217 return $this->getTitle()->getNamespaceKey();
1218 }
1219
1220 public function commonPrintStylesheet() {
1221 return false;
1222 }
1223 }
1224
1225 /**
1226 * Generic wrapper for template functions, with interface
1227 * compatible with what we use of PHPTAL 0.7.
1228 * @ingroup Skins
1229 */
1230 abstract class QuickTemplate {
1231 /**
1232 * Constructor
1233 */
1234 public function QuickTemplate() {
1235 $this->data = array();
1236 $this->translator = new MediaWiki_I18N();
1237 }
1238
1239 /**
1240 * Sets the value $value to $name
1241 * @param $name
1242 * @param $value
1243 */
1244 public function set( $name, $value ) {
1245 $this->data[$name] = $value;
1246 }
1247
1248 /**
1249 * @param $name
1250 * @param $value
1251 */
1252 public function setRef( $name, &$value ) {
1253 $this->data[$name] =& $value;
1254 }
1255
1256 /**
1257 * @param $t
1258 */
1259 public function setTranslator( &$t ) {
1260 $this->translator = &$t;
1261 }
1262
1263 /**
1264 * Main function, used by classes that subclass QuickTemplate
1265 * to show the actual HTML output
1266 */
1267 abstract public function execute();
1268
1269 /**
1270 * @private
1271 */
1272 function text( $str ) {
1273 echo htmlspecialchars( $this->data[$str] );
1274 }
1275
1276 /**
1277 * @private
1278 */
1279 function jstext( $str ) {
1280 echo Xml::escapeJsString( $this->data[$str] );
1281 }
1282
1283 /**
1284 * @private
1285 */
1286 function html( $str ) {
1287 echo $this->data[$str];
1288 }
1289
1290 /**
1291 * @private
1292 */
1293 function msg( $str ) {
1294 echo htmlspecialchars( $this->translator->translate( $str ) );
1295 }
1296
1297 /**
1298 * @private
1299 */
1300 function msgHtml( $str ) {
1301 echo $this->translator->translate( $str );
1302 }
1303
1304 /**
1305 * An ugly, ugly hack.
1306 * @private
1307 */
1308 function msgWiki( $str ) {
1309 global $wgOut;
1310
1311 $text = $this->translator->translate( $str );
1312 echo $wgOut->parse( $text );
1313 }
1314
1315 /**
1316 * @private
1317 * @return bool
1318 */
1319 function haveData( $str ) {
1320 return isset( $this->data[$str] );
1321 }
1322
1323 /**
1324 * @private
1325 *
1326 * @return bool
1327 */
1328 function haveMsg( $str ) {
1329 $msg = $this->translator->translate( $str );
1330 return ( $msg != '-' ) && ( $msg != '' ); # ????
1331 }
1332
1333 /**
1334 * Get the Skin object related to this object
1335 *
1336 * @return Skin object
1337 */
1338 public function getSkin() {
1339 return $this->data['skin'];
1340 }
1341 }
1342
1343 /**
1344 * New base template for a skin's template extended from QuickTemplate
1345 * this class features helper methods that provide common ways of interacting
1346 * with the data stored in the QuickTemplate
1347 */
1348 abstract class BaseTemplate extends QuickTemplate {
1349
1350 /**
1351 * Get a Message object with its context set
1352 *
1353 * @param $name string message name
1354 * @return Message
1355 */
1356 public function getMsg( $name ) {
1357 return $this->getSkin()->msg( $name );
1358 }
1359
1360 function msg( $str ) {
1361 echo $this->getMsg( $str )->escaped();
1362 }
1363
1364 function msgHtml( $str ) {
1365 echo $this->getMsg( $str )->text();
1366 }
1367
1368 function msgWiki( $str ) {
1369 echo $this->getMsg( $str )->parseAsBlock();
1370 }
1371
1372 /**
1373 * Create an array of common toolbox items from the data in the quicktemplate
1374 * stored by SkinTemplate.
1375 * The resulting array is built acording to a format intended to be passed
1376 * through makeListItem to generate the html.
1377 * @return array
1378 */
1379 function getToolbox() {
1380 wfProfileIn( __METHOD__ );
1381
1382 $toolbox = array();
1383 if ( isset( $this->data['nav_urls']['whatlinkshere'] ) && $this->data['nav_urls']['whatlinkshere'] ) {
1384 $toolbox['whatlinkshere'] = $this->data['nav_urls']['whatlinkshere'];
1385 $toolbox['whatlinkshere']['id'] = 't-whatlinkshere';
1386 }
1387 if ( isset( $this->data['nav_urls']['recentchangeslinked'] ) && $this->data['nav_urls']['recentchangeslinked'] ) {
1388 $toolbox['recentchangeslinked'] = $this->data['nav_urls']['recentchangeslinked'];
1389 $toolbox['recentchangeslinked']['msg'] = 'recentchangeslinked-toolbox';
1390 $toolbox['recentchangeslinked']['id'] = 't-recentchangeslinked';
1391 }
1392 if ( isset( $this->data['feeds'] ) && $this->data['feeds'] ) {
1393 $toolbox['feeds']['id'] = 'feedlinks';
1394 $toolbox['feeds']['links'] = array();
1395 foreach ( $this->data['feeds'] as $key => $feed ) {
1396 $toolbox['feeds']['links'][$key] = $feed;
1397 $toolbox['feeds']['links'][$key]['id'] = "feed-$key";
1398 $toolbox['feeds']['links'][$key]['rel'] = 'alternate';
1399 $toolbox['feeds']['links'][$key]['type'] = "application/{$key}+xml";
1400 $toolbox['feeds']['links'][$key]['class'] = 'feedlink';
1401 }
1402 }
1403 foreach ( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ) {
1404 if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) {
1405 $toolbox[$special] = $this->data['nav_urls'][$special];
1406 $toolbox[$special]['id'] = "t-$special";
1407 }
1408 }
1409 if ( isset( $this->data['nav_urls']['print'] ) && $this->data['nav_urls']['print'] ) {
1410 $toolbox['print'] = $this->data['nav_urls']['print'];
1411 $toolbox['print']['rel'] = 'alternate';
1412 $toolbox['print']['msg'] = 'printableversion';
1413 }
1414 if ( isset( $this->data['nav_urls']['permalink'] ) && $this->data['nav_urls']['permalink'] ) {
1415 $toolbox['permalink'] = $this->data['nav_urls']['permalink'];
1416 if( $toolbox['permalink']['href'] === '' ) {
1417 unset( $toolbox['permalink']['href'] );
1418 $toolbox['ispermalink']['tooltiponly'] = true;
1419 $toolbox['ispermalink']['id'] = 't-ispermalink';
1420 $toolbox['ispermalink']['msg'] = 'permalink';
1421 } else {
1422 $toolbox['permalink']['id'] = 't-permalink';
1423 }
1424 }
1425 wfRunHooks( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
1426 wfProfileOut( __METHOD__ );
1427 return $toolbox;
1428 }
1429
1430 /**
1431 * Create an array of personal tools items from the data in the quicktemplate
1432 * stored by SkinTemplate.
1433 * The resulting array is built acording to a format intended to be passed
1434 * through makeListItem to generate the html.
1435 * This is in reality the same list as already stored in personal_urls
1436 * however it is reformatted so that you can just pass the individual items
1437 * to makeListItem instead of hardcoding the element creation boilerplate.
1438 * @return array
1439 */
1440 function getPersonalTools() {
1441 $personal_tools = array();
1442 foreach( $this->data['personal_urls'] as $key => $ptool ) {
1443 # The class on a personal_urls item is meant to go on the <a> instead
1444 # of the <li> so we have to use a single item "links" array instead
1445 # of using most of the personal_url's keys directly
1446 $personal_tools[$key] = array();
1447 $personal_tools[$key]["links"][] = array();
1448 $personal_tools[$key]["links"][0]["single-id"] = $personal_tools[$key]["id"] = "pt-$key";
1449 if ( isset($ptool["active"]) ) {
1450 $personal_tools[$key]["active"] = $ptool["active"];
1451 }
1452 foreach ( array("href", "class", "text") as $k ) {
1453 if ( isset($ptool[$k]) )
1454 $personal_tools[$key]["links"][0][$k] = $ptool[$k];
1455 }
1456 }
1457 return $personal_tools;
1458 }
1459
1460 function getSidebar( $options = array() ) {
1461 // Force the rendering of the following portals
1462 $sidebar = $this->data['sidebar'];
1463 if ( !isset( $sidebar['SEARCH'] ) ) {
1464 $sidebar['SEARCH'] = true;
1465 }
1466 if ( !isset( $sidebar['TOOLBOX'] ) ) {
1467 $sidebar['TOOLBOX'] = true;
1468 }
1469 if ( !isset( $sidebar['LANGUAGES'] ) ) {
1470 $sidebar['LANGUAGES'] = true;
1471 }
1472
1473 if ( !isset( $options['search'] ) || $options['search'] !== true ) {
1474 unset( $sidebar['SEARCH'] );
1475 }
1476 if ( isset( $options['toolbox'] ) && $options['toolbox'] === false ) {
1477 unset( $sidebar['TOOLBOX'] );
1478 }
1479 if ( isset( $options['languages'] ) && $options['languages'] === false ) {
1480 unset( $sidebar['LANGUAGES'] );
1481 }
1482
1483 $boxes = array();
1484 foreach ( $sidebar as $boxName => $content ) {
1485 if ( $content === false ) {
1486 continue;
1487 }
1488 switch ( $boxName ) {
1489 case 'SEARCH':
1490 // Search is a special case, skins should custom implement this
1491 $boxes[$boxName] = array(
1492 'id' => "p-search",
1493 'header' => $this->getMsg( 'search' )->text(),
1494 'generated' => false,
1495 'content' => true,
1496 );
1497 break;
1498 case 'TOOLBOX':
1499 $msgObj = $this->getMsg( 'toolbox' );
1500 $boxes[$boxName] = array(
1501 'id' => "p-tb",
1502 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
1503 'generated' => false,
1504 'content' => $this->getToolbox(),
1505 );
1506 break;
1507 case 'LANGUAGES':
1508 if ( $this->data['language_urls'] ) {
1509 $msgObj = $this->getMsg( 'otherlanguages' );
1510 $boxes[$boxName] = array(
1511 'id' => "p-lang",
1512 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
1513 'generated' => false,
1514 'content' => $this->data['language_urls'],
1515 );
1516 }
1517 break;
1518 default:
1519 $msgObj = $this->getMsg( $boxName );
1520 $boxes[$boxName] = array(
1521 'id' => "p-$boxName",
1522 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
1523 'generated' => true,
1524 'content' => $content,
1525 );
1526 break;
1527 }
1528 }
1529
1530 // HACK: Compatibility with extensions still using SkinTemplateToolboxEnd
1531 $hookContents = null;
1532 if ( isset( $boxes['TOOLBOX'] ) ) {
1533 ob_start();
1534 // We pass an extra 'true' at the end so extensions using BaseTemplateToolbox
1535 // can abort and avoid outputting double toolbox links
1536 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
1537 $hookContents = ob_get_contents();
1538 ob_end_clean();
1539 if ( !trim( $hookContents ) ) {
1540 $hookContents = null;
1541 }
1542 }
1543 // END hack
1544
1545 if ( isset( $options['htmlOnly'] ) && $options['htmlOnly'] === true ) {
1546 foreach ( $boxes as $boxName => $box ) {
1547 if ( is_array( $box['content'] ) ) {
1548 $content = "<ul>";
1549 foreach ( $box['content'] as $key => $val ) {
1550 $content .= "\n " . $this->makeListItem( $key, $val );
1551 }
1552 // HACK, shove the toolbox end onto the toolbox if we're rendering itself
1553 if ( $hookContents ) {
1554 $content .= "\n $hookContents";
1555 }
1556 // END hack
1557 $content .= "\n</ul>\n";
1558 $boxes[$boxName]['content'] = $content;
1559 }
1560 }
1561 } else {
1562 if ( $hookContents ) {
1563 $boxes['TOOLBOXEND'] = array(
1564 'id' => "p-toolboxend",
1565 'header' => $boxes['TOOLBOX']['header'],
1566 'generated' => false,
1567 'content' => "<ul>{$hookContents}</ul>",
1568 );
1569 // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
1570 $boxes2 = array();
1571 foreach ( $boxes as $key => $box ) {
1572 if ( $key === 'TOOLBOXEND' ) {
1573 continue;
1574 }
1575 $boxes2[$key] = $box;
1576 if ( $key === 'TOOLBOX' ) {
1577 $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
1578 }
1579 }
1580 $boxes = $boxes2;
1581 // END hack
1582 }
1583 }
1584
1585 return $boxes;
1586 }
1587
1588 /**
1589 * Makes a link, usually used by makeListItem to generate a link for an item
1590 * in a list used in navigation lists, portlets, portals, sidebars, etc...
1591 *
1592 * $key is a string, usually a key from the list you are generating this link from
1593 * $item is an array containing some of a specific set of keys.
1594 * The text of the link will be generated either from the contents of the "text"
1595 * key in the $item array, if a "msg" key is present a message by that name will
1596 * be used, and if neither of those are set the $key will be used as a message name.
1597 * If a "href" key is not present makeLink will just output htmlescaped text.
1598 * The href, id, class, rel, and type keys are used as attributes for the link if present.
1599 * If an "id" or "single-id" (if you don't want the actual id to be output on the link)
1600 * is present it will be used to generate a tooltip and accesskey for the link.
1601 * If you don't want an accesskey, set $item['tooltiponly'] = true;
1602 * $options can be used to affect the output of a link:
1603 * You can use a text-wrapper key to specify a list of elements to wrap the
1604 * text of a link in. This should be an array of arrays containing a 'tag' and
1605 * optionally an 'attributes' key. If you only have one element you don't need
1606 * to wrap it in another array. eg: To use <a><span>...</span></a> in all links
1607 * use array( 'text-wrapper' => array( 'tag' => 'span' ) ) for your options.
1608 * A link-class key can be used to specify additional classes to apply to all links.
1609 * A link-fallback can be used to specify a tag to use instead of <a> if there is
1610 * no link. eg: If you specify 'link-fallback' => 'span' than any non-link will
1611 * output a <span> instead of just text.
1612 * @return string
1613 */
1614 function makeLink( $key, $item, $options = array() ) {
1615 if ( isset( $item['text'] ) ) {
1616 $text = $item['text'];
1617 } else {
1618 $text = $this->translator->translate( isset( $item['msg'] ) ? $item['msg'] : $key );
1619 }
1620
1621 $html = htmlspecialchars( $text );
1622
1623 if ( isset( $options['text-wrapper'] ) ) {
1624 $wrapper = $options['text-wrapper'];
1625 if ( isset( $wrapper['tag'] ) ) {
1626 $wrapper = array( $wrapper );
1627 }
1628 while ( count( $wrapper ) > 0 ) {
1629 $element = array_pop( $wrapper );
1630 $html = Html::rawElement( $element['tag'], isset( $element['attributes'] ) ? $element['attributes'] : null, $html );
1631 }
1632 }
1633
1634 if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) {
1635 $attrs = $item;
1636 foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly' ) as $k ) {
1637 unset( $attrs[$k] );
1638 }
1639
1640 if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) {
1641 $item['single-id'] = $item['id'];
1642 }
1643 if ( isset( $item['single-id'] ) ) {
1644 if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) {
1645 $title = Linker::titleAttrib( $item['single-id'] );
1646 if ( $title !== false ) {
1647 $attrs['title'] = $title;
1648 }
1649 } else {
1650 $tip = Linker::tooltipAndAccesskeyAttribs( $item['single-id'] );
1651 if ( isset( $tip['title'] ) && $tip['title'] !== false ) {
1652 $attrs['title'] = $tip['title'];
1653 }
1654 if ( isset( $tip['accesskey'] ) && $tip['accesskey'] !== false ) {
1655 $attrs['accesskey'] = $tip['accesskey'];
1656 }
1657 }
1658 }
1659 if ( isset( $options['link-class'] ) ) {
1660 if ( isset( $attrs['class'] ) ) {
1661 $attrs['class'] .= " {$options['link-class']}";
1662 } else {
1663 $attrs['class'] = $options['link-class'];
1664 }
1665 }
1666 $html = Html::rawElement( isset( $attrs['href'] ) ? 'a' : $options['link-fallback'], $attrs, $html );
1667 }
1668
1669 return $html;
1670 }
1671
1672 /**
1673 * Generates a list item for a navigation, portlet, portal, sidebar... etc list
1674 * $key is a string, usually a key from the list you are generating this link from
1675 * $item is an array of list item data containing some of a specific set of keys.
1676 * The "id" and "class" keys will be used as attributes for the list item,
1677 * if "active" contains a value of true a "active" class will also be appended to class.
1678 * If you want something other than a <li> you can pass a tag name such as
1679 * "tag" => "span" in the $options array to change the tag used.
1680 * link/content data for the list item may come in one of two forms
1681 * A "links" key may be used, in which case it should contain an array with
1682 * a list of links to include inside the list item, see makeLink for the format
1683 * of individual links array items.
1684 * Otherwise the relevant keys from the list item $item array will be passed
1685 * to makeLink instead. Note however that "id" and "class" are used by the
1686 * list item directly so they will not be passed to makeLink
1687 * (however the link will still support a tooltip and accesskey from it)
1688 * If you need an id or class on a single link you should include a "links"
1689 * array with just one link item inside of it.
1690 * $options is also passed on to makeLink calls
1691 * @return string
1692 */
1693 function makeListItem( $key, $item, $options = array() ) {
1694 if ( isset( $item['links'] ) ) {
1695 $html = '';
1696 foreach ( $item['links'] as $linkKey => $link ) {
1697 $html .= $this->makeLink( $linkKey, $link, $options );
1698 }
1699 } else {
1700 $link = $item;
1701 // These keys are used by makeListItem and shouldn't be passed on to the link
1702 foreach ( array( 'id', 'class', 'active', 'tag' ) as $k ) {
1703 unset( $link[$k] );
1704 }
1705 if ( isset( $item['id'] ) ) {
1706 // The id goes on the <li> not on the <a> for single links
1707 // but makeSidebarLink still needs to know what id to use when
1708 // generating tooltips and accesskeys.
1709 $link['single-id'] = $item['id'];
1710 }
1711 $html = $this->makeLink( $key, $link, $options );
1712 }
1713
1714 $attrs = array();
1715 foreach ( array( 'id', 'class' ) as $attr ) {
1716 if ( isset( $item[$attr] ) ) {
1717 $attrs[$attr] = $item[$attr];
1718 }
1719 }
1720 if ( isset( $item['active'] ) && $item['active'] ) {
1721 if ( !isset( $attrs['class'] ) ) {
1722 $attrs['class'] = '';
1723 }
1724 $attrs['class'] .= ' active';
1725 $attrs['class'] = trim( $attrs['class'] );
1726 }
1727 return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html );
1728 }
1729
1730 function makeSearchInput( $attrs = array() ) {
1731 $realAttrs = array(
1732 'type' => 'search',
1733 'name' => 'search',
1734 'value' => isset( $this->data['search'] ) ? $this->data['search'] : '',
1735 );
1736 $realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
1737 return Html::element( 'input', $realAttrs );
1738 }
1739
1740 function makeSearchButton( $mode, $attrs = array() ) {
1741 switch( $mode ) {
1742 case 'go':
1743 case 'fulltext':
1744 $realAttrs = array(
1745 'type' => 'submit',
1746 'name' => $mode,
1747 'value' => $this->translator->translate(
1748 $mode == 'go' ? 'searcharticle' : 'searchbutton' ),
1749 );
1750 $realAttrs = array_merge(
1751 $realAttrs,
1752 Linker::tooltipAndAccesskeyAttribs( "search-$mode" ),
1753 $attrs
1754 );
1755 return Html::element( 'input', $realAttrs );
1756 case 'image':
1757 $buttonAttrs = array(
1758 'type' => 'submit',
1759 'name' => 'button',
1760 );
1761 $buttonAttrs = array_merge(
1762 $buttonAttrs,
1763 Linker::tooltipAndAccesskeyAttribs( 'search-fulltext' ),
1764 $attrs
1765 );
1766 unset( $buttonAttrs['src'] );
1767 unset( $buttonAttrs['alt'] );
1768 $imgAttrs = array(
1769 'src' => $attrs['src'],
1770 'alt' => isset( $attrs['alt'] )
1771 ? $attrs['alt']
1772 : $this->translator->translate( 'searchbutton' ),
1773 );
1774 return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
1775 default:
1776 throw new MWException( 'Unknown mode passed to BaseTemplate::makeSearchButton' );
1777 }
1778 }
1779
1780 /**
1781 * Returns an array of footerlinks trimmed down to only those footer links that
1782 * are valid.
1783 * If you pass "flat" as an option then the returned array will be a flat array
1784 * of footer icons instead of a key/value array of footerlinks arrays broken
1785 * up into categories.
1786 * @return array|mixed
1787 */
1788 function getFooterLinks( $option = null ) {
1789 $footerlinks = $this->data['footerlinks'];
1790
1791 // Reduce footer links down to only those which are being used
1792 $validFooterLinks = array();
1793 foreach( $footerlinks as $category => $links ) {
1794 $validFooterLinks[$category] = array();
1795 foreach( $links as $link ) {
1796 if( isset( $this->data[$link] ) && $this->data[$link] ) {
1797 $validFooterLinks[$category][] = $link;
1798 }
1799 }
1800 if ( count( $validFooterLinks[$category] ) <= 0 ) {
1801 unset( $validFooterLinks[$category] );
1802 }
1803 }
1804
1805 if ( $option == 'flat' ) {
1806 // fold footerlinks into a single array using a bit of trickery
1807 $validFooterLinks = call_user_func_array(
1808 'array_merge',
1809 array_values( $validFooterLinks )
1810 );
1811 }
1812
1813 return $validFooterLinks;
1814 }
1815
1816 /**
1817 * Returns an array of footer icons filtered down by options relevant to how
1818 * the skin wishes to display them.
1819 * If you pass "icononly" as the option all footer icons which do not have an
1820 * image icon set will be filtered out.
1821 * If you pass "nocopyright" then MediaWiki's copyright icon will not be included
1822 * in the list of footer icons. This is mostly useful for skins which only
1823 * display the text from footericons instead of the images and don't want a
1824 * duplicate copyright statement because footerlinks already rendered one.
1825 * @return
1826 */
1827 function getFooterIcons( $option = null ) {
1828 // Generate additional footer icons
1829 $footericons = $this->data['footericons'];
1830
1831 if ( $option == 'icononly' ) {
1832 // Unset any icons which don't have an image
1833 foreach ( $footericons as &$footerIconsBlock ) {
1834 foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
1835 if ( !is_string( $footerIcon ) && !isset( $footerIcon['src'] ) ) {
1836 unset( $footerIconsBlock[$footerIconKey] );
1837 }
1838 }
1839 }
1840 // Redo removal of any empty blocks
1841 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
1842 if ( count( $footerIconsBlock ) <= 0 ) {
1843 unset( $footericons[$footerIconsKey] );
1844 }
1845 }
1846 } elseif ( $option == 'nocopyright' ) {
1847 unset( $footericons['copyright']['copyright'] );
1848 if ( count( $footericons['copyright'] ) <= 0 ) {
1849 unset( $footericons['copyright'] );
1850 }
1851 }
1852
1853 return $footericons;
1854 }
1855
1856 /**
1857 * Output the basic end-page trail including bottomscripts, reporttime, and
1858 * debug stuff. This should be called right before outputting the closing
1859 * body and html tags.
1860 */
1861 function printTrail() { ?>
1862 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
1863 <?php $this->html('reporttime') ?>
1864 <?php if ( $this->data['debug'] ): ?>
1865 <!-- Debug output:
1866 <?php $this->text( 'debug' ); ?>
1867
1868 -->
1869 <?php endif;
1870 }
1871
1872 }
1873