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