More return documentation
[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 # Add a <div class="mw-content-ltr/rtl"> around the body text
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 = array( 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
408 'class' => 'mw-content-'.$pageLang->getDir() );
409 $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
410 }
411
412 $tpl->setRef( 'bodytext', $out->mBodytext );
413
414 # Language links
415 $language_urls = array();
416
417 if ( !$wgHideInterlanguageLinks ) {
418 foreach( $out->getLanguageLinks() as $l ) {
419 $tmp = explode( ':', $l, 2 );
420 $class = 'interwiki-' . $tmp[0];
421 unset( $tmp );
422 $nt = Title::newFromText( $l );
423 if ( $nt ) {
424 $language_urls[] = array(
425 'href' => $nt->getFullURL(),
426 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
427 $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
428 'title' => $nt->getText(),
429 'class' => $class,
430 'lang' => $nt->getInterwiki(),
431 'hreflang' => $nt->getInterwiki(),
432 );
433 }
434 }
435 }
436 if( count( $language_urls ) ) {
437 $tpl->setRef( 'language_urls', $language_urls );
438 } else {
439 $tpl->set( 'language_urls', false );
440 }
441 wfProfileOut( __METHOD__ . '-stuff4' );
442
443 wfProfileIn( __METHOD__ . '-stuff5' );
444 # Personal toolbar
445 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
446 $content_navigation = $this->buildContentNavigationUrls();
447 $content_actions = $this->buildContentActionUrls( $content_navigation );
448 $tpl->setRef( 'content_navigation', $content_navigation );
449 $tpl->setRef( 'content_actions', $content_actions );
450
451 $tpl->set( 'sidebar', $this->buildSidebar() );
452 $tpl->set( 'nav_urls', $this->buildNavUrls() );
453
454 // Set the head scripts near the end, in case the above actions resulted in added scripts
455 if ( $this->useHeadElement ) {
456 $tpl->set( 'headelement', $out->headElement( $this ) );
457 } else {
458 $tpl->set( 'headscripts', $out->getScript() );
459 }
460
461 $tpl->set( 'debughtml', $this->generateDebugHTML() );
462 $tpl->set( 'reporttime', wfReportTime() );
463
464 // original version by hansm
465 if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
466 wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
467 }
468
469 // Set the bodytext to another key so that skins can just output it on it's own
470 // and output printfooter and debughtml separately
471 $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
472
473 // Append printfooter and debughtml onto bodytext so that skins that were already
474 // using bodytext before they were split out don't suddenly start not outputting information
475 $tpl->data['bodytext'] .= Html::rawElement( 'div', array( 'class' => 'printfooter' ), "\n{$tpl->data['printfooter']}" ) . "\n";
476 $tpl->data['bodytext'] .= $tpl->data['debughtml'];
477
478 // allow extensions adding stuff after the page content.
479 // See Skin::afterContentHook() for further documentation.
480 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
481 wfProfileOut( __METHOD__ . '-stuff5' );
482
483 // execute template
484 wfProfileIn( __METHOD__ . '-execute' );
485 $res = $tpl->execute();
486 wfProfileOut( __METHOD__ . '-execute' );
487
488 // result may be an error
489 $this->printOrError( $res );
490
491 if ( $oldContext ) {
492 $this->setContext( $oldContext );
493 }
494 wfProfileOut( __METHOD__ );
495 }
496
497 /**
498 * Output the string, or print error message if it's
499 * an error object of the appropriate type.
500 * For the base class, assume strings all around.
501 *
502 * @param $str Mixed
503 * @private
504 */
505 function printOrError( $str ) {
506 echo $str;
507 }
508
509 /**
510 * Output a boolean indiciating if buildPersonalUrls should output separate
511 * login and create account links or output a combined link
512 * By default we simply return a global config setting that affects most skins
513 * This is setup as a method so that like with $wgLogo and getLogo() a skin
514 * can override this setting and always output one or the other if it has
515 * a reason it can't output one of the two modes.
516 * @return bool
517 */
518 function useCombinedLoginLink() {
519 global $wgUseCombinedLoginLink;
520 return $wgUseCombinedLoginLink;
521 }
522
523 /**
524 * build array of urls for personal toolbar
525 * @return array
526 */
527 protected function buildPersonalUrls() {
528 $title = $this->getTitle();
529 $request = $this->getRequest();
530 $pageurl = $title->getLocalURL();
531 wfProfileIn( __METHOD__ );
532
533 /* set up the default links for the personal toolbar */
534 $personal_urls = array();
535
536 # Due to bug 32276, if a user does not have read permissions,
537 # $this->getTitle() will just give Special:Badtitle, which is
538 # not especially useful as a returnto parameter. Use the title
539 # from the request instead, if there was one.
540 $page = Title::newFromURL( $request->getVal( 'title', '' ) );
541 $page = $request->getVal( 'returnto', $page );
542 $a = array();
543 if ( strval( $page ) !== '' ) {
544 $a['returnto'] = $page;
545 $query = $request->getVal( 'returntoquery', $this->thisquery );
546 if( $query != '' ) {
547 $a['returntoquery'] = $query;
548 }
549 }
550 $returnto = wfArrayToCGI( $a );
551 if( $this->loggedin ) {
552 $personal_urls['userpage'] = array(
553 'text' => $this->username,
554 'href' => &$this->userpageUrlDetails['href'],
555 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
556 'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
557 );
558 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
559 $personal_urls['mytalk'] = array(
560 'text' => $this->msg( 'mytalk' )->text(),
561 'href' => &$usertalkUrlDetails['href'],
562 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
563 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
564 );
565 $href = self::makeSpecialUrl( 'Preferences' );
566 $personal_urls['preferences'] = array(
567 'text' => $this->msg( 'mypreferences' )->text(),
568 'href' => $href,
569 'active' => ( $href == $pageurl )
570 );
571 $href = self::makeSpecialUrl( 'Watchlist' );
572 $personal_urls['watchlist'] = array(
573 'text' => $this->msg( 'mywatchlist' )->text(),
574 'href' => $href,
575 'active' => ( $href == $pageurl )
576 );
577
578 # We need to do an explicit check for Special:Contributions, as we
579 # have to match both the title, and the target (which could come
580 # from request values or be specified in "sub page" form. The plot
581 # thickens, because the Title object is altered for special pages,
582 # so doesn't contain the original alias-with-subpage.
583 $origTitle = Title::newFromText( $request->getText( 'title' ) );
584 if( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
585 list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
586 $active = $spName == 'Contributions'
587 && ( ( $spPar && $spPar == $this->username )
588 || $request->getText( 'target' ) == $this->username );
589 } else {
590 $active = false;
591 }
592
593 $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
594 $personal_urls['mycontris'] = array(
595 'text' => $this->msg( 'mycontris' )->text(),
596 'href' => $href,
597 'active' => $active
598 );
599 $personal_urls['logout'] = array(
600 'text' => $this->msg( 'userlogout' )->text(),
601 'href' => self::makeSpecialUrl( 'Userlogout',
602 // userlogout link must always contain an & character, otherwise we might not be able
603 // to detect a buggy precaching proxy (bug 17790)
604 $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
605 ),
606 'active' => false
607 );
608 } else {
609 $useCombinedLoginLink = $this->useCombinedLoginLink();
610 $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
611 ? 'nav-login-createaccount'
612 : 'login';
613 $is_signup = $request->getText('type') == "signup";
614
615 # anonlogin & login are the same
616 $login_url = array(
617 'text' => $this->msg( $loginlink )->text(),
618 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
619 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == "nav-login-createaccount" || !$is_signup )
620 );
621 if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
622 $createaccount_url = array(
623 'text' => $this->msg( 'createaccount' )->text(),
624 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
625 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
626 );
627 }
628 global $wgServer, $wgSecureLogin;
629 if( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
630 $title = SpecialPage::getTitleFor( 'Userlogin' );
631 $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
632 $login_url['href'] = $https_url;
633 # @todo FIXME: Class depends on skin
634 $login_url['class'] = 'link-https';
635 if ( isset($createaccount_url) ) {
636 $https_url = preg_replace( '/^http:/', 'https:',
637 $title->getFullURL("type=signup") );
638 $createaccount_url['href'] = $https_url;
639 # @todo FIXME: Class depends on skin
640 $createaccount_url['class'] = 'link-https';
641 }
642 }
643
644
645 if( $this->showIPinHeader() ) {
646 $href = &$this->userpageUrlDetails['href'];
647 $personal_urls['anonuserpage'] = array(
648 'text' => $this->username,
649 'href' => $href,
650 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
651 'active' => ( $pageurl == $href )
652 );
653 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
654 $href = &$usertalkUrlDetails['href'];
655 $personal_urls['anontalk'] = array(
656 'text' => $this->msg( 'anontalk' )->text(),
657 'href' => $href,
658 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
659 'active' => ( $pageurl == $href )
660 );
661 $personal_urls['anonlogin'] = $login_url;
662 } else {
663 $personal_urls['login'] = $login_url;
664 }
665 if ( isset($createaccount_url) ) {
666 $personal_urls['createaccount'] = $createaccount_url;
667 }
668 }
669
670 wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) );
671 wfProfileOut( __METHOD__ );
672 return $personal_urls;
673 }
674
675 /**
676 * TODO document
677 * @param $title Title
678 * @param $message String message key
679 * @param $selected Bool
680 * @param $query String
681 * @param $checkEdit Bool
682 * @return array
683 */
684 function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
685 $classes = array();
686 if( $selected ) {
687 $classes[] = 'selected';
688 }
689 if( $checkEdit && !$title->isKnown() ) {
690 $classes[] = 'new';
691 $query = 'action=edit&redlink=1';
692 }
693
694 // wfMessageFallback will nicely accept $message as an array of fallbacks
695 // or just a single key
696 $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
697 if ( is_array($message) ) {
698 // for hook compatibility just keep the last message name
699 $message = end($message);
700 }
701 if ( $msg->exists() ) {
702 $text = $msg->text();
703 } else {
704 global $wgContLang;
705 $text = $wgContLang->getFormattedNsText(
706 MWNamespace::getSubject( $title->getNamespace() ) );
707 }
708
709 $result = array();
710 if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
711 $title, $message, $selected, $checkEdit,
712 &$classes, &$query, &$text, &$result ) ) ) {
713 return $result;
714 }
715
716 return array(
717 'class' => implode( ' ', $classes ),
718 'text' => $text,
719 'href' => $title->getLocalUrl( $query ),
720 'primary' => true );
721 }
722
723 function makeTalkUrlDetails( $name, $urlaction = '' ) {
724 $title = Title::newFromText( $name );
725 if( !is_object( $title ) ) {
726 throw new MWException( __METHOD__ . " given invalid pagename $name" );
727 }
728 $title = $title->getTalkPage();
729 self::checkTitle( $title, $name );
730 return array(
731 'href' => $title->getLocalURL( $urlaction ),
732 'exists' => $title->getArticleID() != 0,
733 );
734 }
735
736 function makeArticleUrlDetails( $name, $urlaction = '' ) {
737 $title = Title::newFromText( $name );
738 $title= $title->getSubjectPage();
739 self::checkTitle( $title, $name );
740 return array(
741 'href' => $title->getLocalURL( $urlaction ),
742 'exists' => $title->getArticleID() != 0,
743 );
744 }
745
746 /**
747 * a structured array of links usually used for the tabs in a skin
748 *
749 * There are 4 standard sections
750 * namespaces: Used for namespace tabs like special, page, and talk namespaces
751 * views: Used for primary page views like read, edit, history
752 * actions: Used for most extra page actions like deletion, protection, etc...
753 * variants: Used to list the language variants for the page
754 *
755 * Each section's value is a key/value array of links for that section.
756 * The links themseves have these common keys:
757 * - class: The css classes to apply to the tab
758 * - text: The text to display on the tab
759 * - href: The href for the tab to point to
760 * - rel: An optional rel= for the tab's link
761 * - redundant: If true the tab will be dropped in skins using content_actions
762 * this is useful for tabs like "Read" which only have meaning in skins that
763 * take special meaning from the grouped structure of content_navigation
764 *
765 * Views also have an extra key which can be used:
766 * - primary: If this is not true skins like vector may try to hide the tab
767 * when the user has limited space in their browser window
768 *
769 * content_navigation using code also expects these ids to be present on the
770 * links, however these are usually automatically generated by SkinTemplate
771 * itself and are not necessary when using a hook. The only things these may
772 * matter to are people modifying content_navigation after it's initial creation:
773 * - id: A "preferred" id, most skins are best off outputting this preferred id for best compatibility
774 * - tooltiponly: This is set to true for some tabs in cases where the system
775 * believes that the accesskey should not be added to the tab.
776 *
777 * @return array
778 */
779 protected function buildContentNavigationUrls() {
780 global $wgDisableLangConversion;
781
782 wfProfileIn( __METHOD__ );
783
784 $title = $this->getRelevantTitle(); // Display tabs for the relevant title rather than always the title itself
785 $onPage = $title->equals($this->getTitle());
786
787 $out = $this->getOutput();
788 $request = $this->getRequest();
789 $user = $this->getUser();
790
791 $content_navigation = array(
792 'namespaces' => array(),
793 'views' => array(),
794 'actions' => array(),
795 'variants' => array()
796 );
797
798 // parameters
799 $action = $request->getVal( 'action', 'view' );
800
801 $userCanRead = $title->quickUserCan( 'read', $user );
802
803 $preventActiveTabs = false;
804 wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
805
806 // Checks if page is some kind of content
807 if( $title->canExist() ) {
808 // Gets page objects for the related namespaces
809 $subjectPage = $title->getSubjectPage();
810 $talkPage = $title->getTalkPage();
811
812 // Determines if this is a talk page
813 $isTalk = $title->isTalkPage();
814
815 // Generates XML IDs from namespace names
816 $subjectId = $title->getNamespaceKey( '' );
817
818 if ( $subjectId == 'main' ) {
819 $talkId = 'talk';
820 } else {
821 $talkId = "{$subjectId}_talk";
822 }
823
824 $skname = $this->skinname;
825
826 // Adds namespace links
827 $subjectMsg = array( "nstab-$subjectId" );
828 if ( $subjectPage->isMainPage() ) {
829 array_unshift($subjectMsg, 'mainpage-nstab');
830 }
831 $content_navigation['namespaces'][$subjectId] = $this->tabAction(
832 $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
833 );
834 $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
835 $content_navigation['namespaces'][$talkId] = $this->tabAction(
836 $talkPage, array( "nstab-$talkId", 'talk' ), $isTalk && !$preventActiveTabs, '', $userCanRead
837 );
838 $content_navigation['namespaces'][$talkId]['context'] = 'talk';
839
840 if ( $userCanRead ) {
841 // Adds view view link
842 if ( $title->exists() ) {
843 $content_navigation['views']['view'] = $this->tabAction(
844 $isTalk ? $talkPage : $subjectPage,
845 array( "$skname-view-view", 'view' ),
846 ( $onPage && ($action == 'view' || $action == 'purge' ) ), '', true
847 );
848 $content_navigation['views']['view']['redundant'] = true; // signal to hide this from simple content_actions
849 }
850
851 wfProfileIn( __METHOD__ . '-edit' );
852
853 // Checks if user can edit the current page if it exists or create it otherwise
854 if ( $title->quickUserCan( 'edit', $user ) && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) ) {
855 // Builds CSS class for talk page links
856 $isTalkClass = $isTalk ? ' istalk' : '';
857 // Whether the user is editing the page
858 $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
859 // Whether to show the "Add a new section" tab
860 // Checks if this is a current rev of talk page and is not forced to be hidden
861 $showNewSection = !$out->forceHideNewSectionLink()
862 && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
863 $section = $request->getVal( 'section' );
864
865 $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ?
866 "edit" : "create";
867 $content_navigation['views']['edit'] = array(
868 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass,
869 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(),
870 'href' => $title->getLocalURL( $this->editUrlOptions() ),
871 'primary' => true, // don't collapse this in vector
872 );
873
874 // section link
875 if ( $showNewSection ) {
876 // Adds new section link
877 //$content_navigation['actions']['addsection']
878 $content_navigation['views']['addsection'] = array(
879 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
880 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(),
881 'href' => $title->getLocalURL( 'action=edit&section=new' )
882 );
883 }
884 // Checks if the page has some kind of viewable content
885 } elseif ( $title->hasSourceText() ) {
886 // Adds view source view link
887 $content_navigation['views']['viewsource'] = array(
888 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
889 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->setContext( $this->getContext() )->text(),
890 'href' => $title->getLocalURL( $this->editUrlOptions() ),
891 'primary' => true, // don't collapse this in vector
892 );
893 }
894 wfProfileOut( __METHOD__ . '-edit' );
895
896 wfProfileIn( __METHOD__ . '-live' );
897 // Checks if the page exists
898 if ( $title->exists() ) {
899 // Adds history view link
900 $content_navigation['views']['history'] = array(
901 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
902 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->setContext( $this->getContext() )->text(),
903 'href' => $title->getLocalURL( 'action=history' ),
904 'rel' => 'archives',
905 );
906
907 if ( $title->quickUserCan( 'delete', $user ) ) {
908 $content_navigation['actions']['delete'] = array(
909 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
910 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->setContext( $this->getContext() )->text(),
911 'href' => $title->getLocalURL( 'action=delete' )
912 );
913 }
914
915 if ( $title->quickUserCan( 'move', $user ) ) {
916 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
917 $content_navigation['actions']['move'] = array(
918 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
919 'text' => wfMessageFallback( "$skname-action-move", 'move' )->setContext( $this->getContext() )->text(),
920 'href' => $moveTitle->getLocalURL()
921 );
922 }
923 } else {
924 // article doesn't exist or is deleted
925 if ( $user->isAllowed( 'deletedhistory' ) ) {
926 $n = $title->isDeleted();
927 if( $n ) {
928 $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
929 // If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
930 $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
931 $content_navigation['actions']['undelete'] = array(
932 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
933 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
934 ->setContext( $this->getContext() )->numParams( $n )->text(),
935 'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) )
936 );
937 }
938 }
939 }
940
941 if ( $title->getNamespace() !== NS_MEDIAWIKI && $title->quickUserCan( 'protect', $user ) ) {
942 $mode = $title->isProtected() ? 'unprotect' : 'protect';
943 $content_navigation['actions'][$mode] = array(
944 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
945 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(),
946 'href' => $title->getLocalURL( "action=$mode" )
947 );
948 }
949
950 wfProfileOut( __METHOD__ . '-live' );
951
952 // Checks if the user is logged in
953 if ( $this->loggedin ) {
954 /**
955 * The following actions use messages which, if made particular to
956 * the any specific skins, would break the Ajax code which makes this
957 * action happen entirely inline. Skin::makeGlobalVariablesScript
958 * defines a set of messages in a javascript object - and these
959 * messages are assumed to be global for all skins. Without making
960 * a change to that procedure these messages will have to remain as
961 * the global versions.
962 */
963 $mode = $title->userIsWatching() ? 'unwatch' : 'watch';
964 $token = WatchAction::getWatchToken( $title, $user, $mode );
965 $content_navigation['actions'][$mode] = array(
966 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
967 'text' => $this->msg( $mode )->text(), // uses 'watch' or 'unwatch' message
968 'href' => $title->getLocalURL( array( 'action' => $mode, 'token' => $token ) )
969 );
970 }
971 }
972
973 wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$content_navigation ) );
974
975 if ( $userCanRead && !$wgDisableLangConversion ) {
976 $pageLang = $title->getPageLanguage();
977 // Gets list of language variants
978 $variants = $pageLang->getVariants();
979 // Checks that language conversion is enabled and variants exist
980 // And if it is not in the special namespace
981 if( count( $variants ) > 1 ) {
982 // Gets preferred variant (note that user preference is
983 // only possible for wiki content language variant)
984 $preferred = $pageLang->getPreferredVariant();
985 // Loops over each variant
986 foreach( $variants as $code ) {
987 // Gets variant name from language code
988 $varname = $pageLang->getVariantname( $code );
989 // Checks if the variant is marked as disabled
990 if( $varname == 'disable' ) {
991 // Skips this variant
992 continue;
993 }
994 // Appends variant link
995 $content_navigation['variants'][] = array(
996 'class' => ( $code == $preferred ) ? 'selected' : false,
997 'text' => $varname,
998 'href' => $title->getLocalURL( array( 'variant' => $code ) )
999 );
1000 }
1001 }
1002 }
1003 } else {
1004 // If it's not content, it's got to be a special page
1005 $content_navigation['namespaces']['special'] = array(
1006 'class' => 'selected',
1007 'text' => $this->msg( 'nstab-special' )->text(),
1008 'href' => $request->getRequestURL(), // @bug 2457, 2510
1009 'context' => 'subject'
1010 );
1011
1012 wfRunHooks( 'SkinTemplateNavigation::SpecialPage',
1013 array( &$this, &$content_navigation ) );
1014 }
1015
1016 // Equiv to SkinTemplateContentActions
1017 wfRunHooks( 'SkinTemplateNavigation::Universal', array( &$this, &$content_navigation ) );
1018
1019 // Setup xml ids and tooltip info
1020 foreach ( $content_navigation as $section => &$links ) {
1021 foreach ( $links as $key => &$link ) {
1022 $xmlID = $key;
1023 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1024 $xmlID = 'ca-nstab-' . $xmlID;
1025 } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1026 $xmlID = 'ca-talk';
1027 } elseif ( $section == "variants" ) {
1028 $xmlID = 'ca-varlang-' . $xmlID;
1029 } else {
1030 $xmlID = 'ca-' . $xmlID;
1031 }
1032 $link['id'] = $xmlID;
1033 }
1034 }
1035
1036 # We don't want to give the watch tab an accesskey if the
1037 # page is being edited, because that conflicts with the
1038 # accesskey on the watch checkbox. We also don't want to
1039 # give the edit tab an accesskey, because that's fairly su-
1040 # perfluous and conflicts with an accesskey (Ctrl-E) often
1041 # used for editing in Safari.
1042 if( in_array( $action, array( 'edit', 'submit' ) ) ) {
1043 if ( isset($content_navigation['views']['edit']) ) {
1044 $content_navigation['views']['edit']['tooltiponly'] = true;
1045 }
1046 if ( isset($content_navigation['actions']['watch']) ) {
1047 $content_navigation['actions']['watch']['tooltiponly'] = true;
1048 }
1049 if ( isset($content_navigation['actions']['unwatch']) ) {
1050 $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1051 }
1052 }
1053
1054 wfProfileOut( __METHOD__ );
1055
1056 return $content_navigation;
1057 }
1058
1059 /**
1060 * an array of edit links by default used for the tabs
1061 * @return array
1062 * @private
1063 */
1064 function buildContentActionUrls( $content_navigation ) {
1065
1066 wfProfileIn( __METHOD__ );
1067
1068 // content_actions has been replaced with content_navigation for backwards
1069 // compatibility and also for skins that just want simple tabs content_actions
1070 // is now built by flattening the content_navigation arrays into one
1071
1072 $content_actions = array();
1073
1074 foreach ( $content_navigation as $links ) {
1075
1076 foreach ( $links as $key => $value ) {
1077
1078 if ( isset($value["redundant"]) && $value["redundant"] ) {
1079 // Redundant tabs are dropped from content_actions
1080 continue;
1081 }
1082
1083 // content_actions used to have ids built using the "ca-$key" pattern
1084 // so the xmlID based id is much closer to the actual $key that we want
1085 // for that reason we'll just strip out the ca- if present and use
1086 // the latter potion of the "id" as the $key
1087 if ( isset($value["id"]) && substr($value["id"], 0, 3) == "ca-" ) {
1088 $key = substr($value["id"], 3);
1089 }
1090
1091 if ( isset($content_actions[$key]) ) {
1092 wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening content_navigation into content_actions." );
1093 continue;
1094 }
1095
1096 $content_actions[$key] = $value;
1097
1098 }
1099
1100 }
1101
1102 wfProfileOut( __METHOD__ );
1103
1104 return $content_actions;
1105 }
1106
1107 /**
1108 * build array of common navigation links
1109 * @return array
1110 * @private
1111 */
1112 protected function buildNavUrls() {
1113 global $wgUploadNavigationUrl;
1114
1115 wfProfileIn( __METHOD__ );
1116
1117 $out = $this->getOutput();
1118 $request = $this->getRequest();
1119
1120 $nav_urls = array();
1121 $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
1122 if( $wgUploadNavigationUrl ) {
1123 $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
1124 } elseif( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1125 $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
1126 } else {
1127 $nav_urls['upload'] = false;
1128 }
1129 $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
1130
1131 $nav_urls['print'] = false;
1132 $nav_urls['permalink'] = false;
1133 $nav_urls['whatlinkshere'] = false;
1134 $nav_urls['recentchangeslinked'] = false;
1135 $nav_urls['contributions'] = false;
1136 $nav_urls['log'] = false;
1137 $nav_urls['blockip'] = false;
1138 $nav_urls['emailuser'] = false;
1139
1140 // A print stylesheet is attached to all pages, but nobody ever
1141 // figures that out. :) Add a link...
1142 if( $out->isArticle() ) {
1143 if ( !$out->isPrintable() ) {
1144 $nav_urls['print'] = array(
1145 'text' => $this->msg( 'printableversion' )->text(),
1146 'href' => $this->getTitle()->getLocalURL(
1147 $request->appendQueryValue( 'printable', 'yes', true ) )
1148 );
1149 }
1150
1151 // Also add a "permalink" while we're at it
1152 $revid = $this->getRevisionId();
1153 if ( $revid ) {
1154 $nav_urls['permalink'] = array(
1155 'text' => $this->msg( 'permalink' )->text(),
1156 'href' => $out->getTitle()->getLocalURL( "oldid=$revid" )
1157 );
1158 }
1159
1160 // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1161 wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1162 array( &$this, &$nav_urls, &$revid, &$revid ) );
1163 }
1164
1165 if ( $out->isArticleRelated() ) {
1166 $nav_urls['whatlinkshere'] = array(
1167 'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalUrl()
1168 );
1169 if ( $this->getTitle()->getArticleId() ) {
1170 $nav_urls['recentchangeslinked'] = array(
1171 'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalUrl()
1172 );
1173 }
1174 }
1175
1176 $user = $this->getRelevantUser();
1177 if ( $user ) {
1178 $rootUser = $user->getName();
1179
1180 $nav_urls['contributions'] = array(
1181 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
1182 );
1183
1184 if ( $user->isLoggedIn() ) {
1185 $logPage = SpecialPage::getTitleFor( 'Log' );
1186 $nav_urls['log'] = array(
1187 'href' => $logPage->getLocalUrl( array( 'user' => $rootUser ) )
1188 );
1189 }
1190
1191 if ( $this->getUser()->isAllowed( 'block' ) ) {
1192 $nav_urls['blockip'] = array(
1193 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1194 );
1195 }
1196
1197 if ( $this->showEmailUser( $user ) ) {
1198 $nav_urls['emailuser'] = array(
1199 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser )
1200 );
1201 }
1202 }
1203
1204 wfProfileOut( __METHOD__ );
1205 return $nav_urls;
1206 }
1207
1208 /**
1209 * Generate strings used for xml 'id' names
1210 * @return string
1211 * @private
1212 */
1213 function getNameSpaceKey() {
1214 return $this->getTitle()->getNamespaceKey();
1215 }
1216
1217 public function commonPrintStylesheet() {
1218 return false;
1219 }
1220 }
1221
1222 /**
1223 * Generic wrapper for template functions, with interface
1224 * compatible with what we use of PHPTAL 0.7.
1225 * @ingroup Skins
1226 */
1227 abstract class QuickTemplate {
1228 /**
1229 * Constructor
1230 */
1231 public function QuickTemplate() {
1232 $this->data = array();
1233 $this->translator = new MediaWiki_I18N();
1234 }
1235
1236 /**
1237 * Sets the value $value to $name
1238 * @param $name
1239 * @param $value
1240 */
1241 public function set( $name, $value ) {
1242 $this->data[$name] = $value;
1243 }
1244
1245 /**
1246 * @param $name
1247 * @param $value
1248 */
1249 public function setRef( $name, &$value ) {
1250 $this->data[$name] =& $value;
1251 }
1252
1253 /**
1254 * @param $t
1255 */
1256 public function setTranslator( &$t ) {
1257 $this->translator = &$t;
1258 }
1259
1260 /**
1261 * Main function, used by classes that subclass QuickTemplate
1262 * to show the actual HTML output
1263 */
1264 abstract public function execute();
1265
1266 /**
1267 * @private
1268 */
1269 function text( $str ) {
1270 echo htmlspecialchars( $this->data[$str] );
1271 }
1272
1273 /**
1274 * @private
1275 */
1276 function jstext( $str ) {
1277 echo Xml::escapeJsString( $this->data[$str] );
1278 }
1279
1280 /**
1281 * @private
1282 */
1283 function html( $str ) {
1284 echo $this->data[$str];
1285 }
1286
1287 /**
1288 * @private
1289 */
1290 function msg( $str ) {
1291 echo htmlspecialchars( $this->translator->translate( $str ) );
1292 }
1293
1294 /**
1295 * @private
1296 */
1297 function msgHtml( $str ) {
1298 echo $this->translator->translate( $str );
1299 }
1300
1301 /**
1302 * An ugly, ugly hack.
1303 * @private
1304 */
1305 function msgWiki( $str ) {
1306 global $wgOut;
1307
1308 $text = $this->translator->translate( $str );
1309 echo $wgOut->parse( $text );
1310 }
1311
1312 /**
1313 * @private
1314 * @return bool
1315 */
1316 function haveData( $str ) {
1317 return isset( $this->data[$str] );
1318 }
1319
1320 /**
1321 * @private
1322 *
1323 * @return bool
1324 */
1325 function haveMsg( $str ) {
1326 $msg = $this->translator->translate( $str );
1327 return ( $msg != '-' ) && ( $msg != '' ); # ????
1328 }
1329
1330 /**
1331 * Get the Skin object related to this object
1332 *
1333 * @return Skin object
1334 */
1335 public function getSkin() {
1336 return $this->data['skin'];
1337 }
1338 }
1339
1340 /**
1341 * New base template for a skin's template extended from QuickTemplate
1342 * this class features helper methods that provide common ways of interacting
1343 * with the data stored in the QuickTemplate
1344 */
1345 abstract class BaseTemplate extends QuickTemplate {
1346
1347 /**
1348 * Get a Message object with its context set
1349 *
1350 * @param $name string message name
1351 * @return Message
1352 */
1353 public function getMsg( $name ) {
1354 return $this->getSkin()->msg( $name );
1355 }
1356
1357 function msg( $str ) {
1358 echo $this->getMsg( $str )->escaped();
1359 }
1360
1361 function msgHtml( $str ) {
1362 echo $this->getMsg( $str )->text();
1363 }
1364
1365 function msgWiki( $str ) {
1366 echo $this->getMsg( $str )->parseAsBlock();
1367 }
1368
1369 /**
1370 * Create an array of common toolbox items from the data in the quicktemplate
1371 * stored by SkinTemplate.
1372 * The resulting array is built acording to a format intended to be passed
1373 * through makeListItem to generate the html.
1374 * @return array
1375 */
1376 function getToolbox() {
1377 wfProfileIn( __METHOD__ );
1378
1379 $toolbox = array();
1380 if ( isset( $this->data['nav_urls']['whatlinkshere'] ) && $this->data['nav_urls']['whatlinkshere'] ) {
1381 $toolbox['whatlinkshere'] = $this->data['nav_urls']['whatlinkshere'];
1382 $toolbox['whatlinkshere']['id'] = 't-whatlinkshere';
1383 }
1384 if ( isset( $this->data['nav_urls']['recentchangeslinked'] ) && $this->data['nav_urls']['recentchangeslinked'] ) {
1385 $toolbox['recentchangeslinked'] = $this->data['nav_urls']['recentchangeslinked'];
1386 $toolbox['recentchangeslinked']['msg'] = 'recentchangeslinked-toolbox';
1387 $toolbox['recentchangeslinked']['id'] = 't-recentchangeslinked';
1388 }
1389 if ( isset( $this->data['feeds'] ) && $this->data['feeds'] ) {
1390 $toolbox['feeds']['id'] = 'feedlinks';
1391 $toolbox['feeds']['links'] = array();
1392 foreach ( $this->data['feeds'] as $key => $feed ) {
1393 $toolbox['feeds']['links'][$key] = $feed;
1394 $toolbox['feeds']['links'][$key]['id'] = "feed-$key";
1395 $toolbox['feeds']['links'][$key]['rel'] = 'alternate';
1396 $toolbox['feeds']['links'][$key]['type'] = "application/{$key}+xml";
1397 $toolbox['feeds']['links'][$key]['class'] = 'feedlink';
1398 }
1399 }
1400 foreach ( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ) {
1401 if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) {
1402 $toolbox[$special] = $this->data['nav_urls'][$special];
1403 $toolbox[$special]['id'] = "t-$special";
1404 }
1405 }
1406 if ( isset( $this->data['nav_urls']['print'] ) && $this->data['nav_urls']['print'] ) {
1407 $toolbox['print'] = $this->data['nav_urls']['print'];
1408 $toolbox['print']['rel'] = 'alternate';
1409 $toolbox['print']['msg'] = 'printableversion';
1410 }
1411 if ( isset( $this->data['nav_urls']['permalink'] ) && $this->data['nav_urls']['permalink'] ) {
1412 $toolbox['permalink'] = $this->data['nav_urls']['permalink'];
1413 if( $toolbox['permalink']['href'] === '' ) {
1414 unset( $toolbox['permalink']['href'] );
1415 $toolbox['ispermalink']['tooltiponly'] = true;
1416 $toolbox['ispermalink']['id'] = 't-ispermalink';
1417 $toolbox['ispermalink']['msg'] = 'permalink';
1418 } else {
1419 $toolbox['permalink']['id'] = 't-permalink';
1420 }
1421 }
1422 wfRunHooks( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
1423 wfProfileOut( __METHOD__ );
1424 return $toolbox;
1425 }
1426
1427 /**
1428 * Create an array of personal tools items from the data in the quicktemplate
1429 * stored by SkinTemplate.
1430 * The resulting array is built acording to a format intended to be passed
1431 * through makeListItem to generate the html.
1432 * This is in reality the same list as already stored in personal_urls
1433 * however it is reformatted so that you can just pass the individual items
1434 * to makeListItem instead of hardcoding the element creation boilerplate.
1435 * @return array
1436 */
1437 function getPersonalTools() {
1438 $personal_tools = array();
1439 foreach( $this->data['personal_urls'] as $key => $ptool ) {
1440 # The class on a personal_urls item is meant to go on the <a> instead
1441 # of the <li> so we have to use a single item "links" array instead
1442 # of using most of the personal_url's keys directly
1443 $personal_tools[$key] = array();
1444 $personal_tools[$key]["links"][] = array();
1445 $personal_tools[$key]["links"][0]["single-id"] = $personal_tools[$key]["id"] = "pt-$key";
1446 if ( isset($ptool["active"]) ) {
1447 $personal_tools[$key]["active"] = $ptool["active"];
1448 }
1449 foreach ( array("href", "class", "text") as $k ) {
1450 if ( isset($ptool[$k]) )
1451 $personal_tools[$key]["links"][0][$k] = $ptool[$k];
1452 }
1453 }
1454 return $personal_tools;
1455 }
1456
1457 function getSidebar( $options = array() ) {
1458 // Force the rendering of the following portals
1459 $sidebar = $this->data['sidebar'];
1460 if ( !isset( $sidebar['SEARCH'] ) ) {
1461 $sidebar['SEARCH'] = true;
1462 }
1463 if ( !isset( $sidebar['TOOLBOX'] ) ) {
1464 $sidebar['TOOLBOX'] = true;
1465 }
1466 if ( !isset( $sidebar['LANGUAGES'] ) ) {
1467 $sidebar['LANGUAGES'] = true;
1468 }
1469
1470 if ( !isset( $options['search'] ) || $options['search'] !== true ) {
1471 unset( $sidebar['SEARCH'] );
1472 }
1473 if ( isset( $options['toolbox'] ) && $options['toolbox'] === false ) {
1474 unset( $sidebar['TOOLBOX'] );
1475 }
1476 if ( isset( $options['languages'] ) && $options['languages'] === false ) {
1477 unset( $sidebar['LANGUAGES'] );
1478 }
1479
1480 $boxes = array();
1481 foreach ( $sidebar as $boxName => $content ) {
1482 if ( $content === false ) {
1483 continue;
1484 }
1485 switch ( $boxName ) {
1486 case 'SEARCH':
1487 // Search is a special case, skins should custom implement this
1488 $boxes[$boxName] = array(
1489 'id' => "p-search",
1490 'header' => $this->getMsg( 'search' )->text(),
1491 'generated' => false,
1492 'content' => true,
1493 );
1494 break;
1495 case 'TOOLBOX':
1496 $msgObj = $this->getMsg( 'toolbox' );
1497 $boxes[$boxName] = array(
1498 'id' => "p-tb",
1499 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
1500 'generated' => false,
1501 'content' => $this->getToolbox(),
1502 );
1503 break;
1504 case 'LANGUAGES':
1505 if ( $this->data['language_urls'] ) {
1506 $msgObj = $this->getMsg( 'otherlanguages' );
1507 $boxes[$boxName] = array(
1508 'id' => "p-lang",
1509 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
1510 'generated' => false,
1511 'content' => $this->data['language_urls'],
1512 );
1513 }
1514 break;
1515 default:
1516 $msgObj = $this->getMsg( $boxName );
1517 $boxes[$boxName] = array(
1518 'id' => "p-$boxName",
1519 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
1520 'generated' => true,
1521 'content' => $content,
1522 );
1523 break;
1524 }
1525 }
1526
1527 // HACK: Compatibility with extensions still using SkinTemplateToolboxEnd
1528 $hookContents = null;
1529 if ( isset( $boxes['TOOLBOX'] ) ) {
1530 ob_start();
1531 // We pass an extra 'true' at the end so extensions using BaseTemplateToolbox
1532 // can abort and avoid outputting double toolbox links
1533 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
1534 $hookContents = ob_get_contents();
1535 ob_end_clean();
1536 if ( !trim( $hookContents ) ) {
1537 $hookContents = null;
1538 }
1539 }
1540 // END hack
1541
1542 if ( isset( $options['htmlOnly'] ) && $options['htmlOnly'] === true ) {
1543 foreach ( $boxes as $boxName => $box ) {
1544 if ( is_array( $box['content'] ) ) {
1545 $content = "<ul>";
1546 foreach ( $box['content'] as $key => $val ) {
1547 $content .= "\n " . $this->makeListItem( $key, $val );
1548 }
1549 // HACK, shove the toolbox end onto the toolbox if we're rendering itself
1550 if ( $hookContents ) {
1551 $content .= "\n $hookContents";
1552 }
1553 // END hack
1554 $content .= "\n</ul>\n";
1555 $boxes[$boxName]['content'] = $content;
1556 }
1557 }
1558 } else {
1559 if ( $hookContents ) {
1560 $boxes['TOOLBOXEND'] = array(
1561 'id' => "p-toolboxend",
1562 'header' => $boxes['TOOLBOX']['header'],
1563 'generated' => false,
1564 'content' => "<ul>{$hookContents}</ul>",
1565 );
1566 // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
1567 $boxes2 = array();
1568 foreach ( $boxes as $key => $box ) {
1569 if ( $key === 'TOOLBOXEND' ) {
1570 continue;
1571 }
1572 $boxes2[$key] = $box;
1573 if ( $key === 'TOOLBOX' ) {
1574 $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
1575 }
1576 }
1577 $boxes = $boxes2;
1578 // END hack
1579 }
1580 }
1581
1582 return $boxes;
1583 }
1584
1585 /**
1586 * Makes a link, usually used by makeListItem to generate a link for an item
1587 * in a list used in navigation lists, portlets, portals, sidebars, etc...
1588 *
1589 * $key is a string, usually a key from the list you are generating this link from
1590 * $item is an array containing some of a specific set of keys.
1591 * The text of the link will be generated either from the contents of the "text"
1592 * key in the $item array, if a "msg" key is present a message by that name will
1593 * be used, and if neither of those are set the $key will be used as a message name.
1594 * If a "href" key is not present makeLink will just output htmlescaped text.
1595 * The href, id, class, rel, and type keys are used as attributes for the link if present.
1596 * If an "id" or "single-id" (if you don't want the actual id to be output on the link)
1597 * is present it will be used to generate a tooltip and accesskey for the link.
1598 * If you don't want an accesskey, set $item['tooltiponly'] = true;
1599 * $options can be used to affect the output of a link:
1600 * You can use a text-wrapper key to specify a list of elements to wrap the
1601 * text of a link in. This should be an array of arrays containing a 'tag' and
1602 * optionally an 'attributes' key. If you only have one element you don't need
1603 * to wrap it in another array. eg: To use <a><span>...</span></a> in all links
1604 * use array( 'text-wrapper' => array( 'tag' => 'span' ) ) for your options.
1605 * A link-class key can be used to specify additional classes to apply to all links.
1606 * A link-fallback can be used to specify a tag to use instead of <a> if there is
1607 * no link. eg: If you specify 'link-fallback' => 'span' than any non-link will
1608 * output a <span> instead of just text.
1609 * @return string
1610 */
1611 function makeLink( $key, $item, $options = array() ) {
1612 if ( isset( $item['text'] ) ) {
1613 $text = $item['text'];
1614 } else {
1615 $text = $this->translator->translate( isset( $item['msg'] ) ? $item['msg'] : $key );
1616 }
1617
1618 $html = htmlspecialchars( $text );
1619
1620 if ( isset( $options['text-wrapper'] ) ) {
1621 $wrapper = $options['text-wrapper'];
1622 if ( isset( $wrapper['tag'] ) ) {
1623 $wrapper = array( $wrapper );
1624 }
1625 while ( count( $wrapper ) > 0 ) {
1626 $element = array_pop( $wrapper );
1627 $html = Html::rawElement( $element['tag'], isset( $element['attributes'] ) ? $element['attributes'] : null, $html );
1628 }
1629 }
1630
1631 if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) {
1632 $attrs = $item;
1633 foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly' ) as $k ) {
1634 unset( $attrs[$k] );
1635 }
1636
1637 if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) {
1638 $item['single-id'] = $item['id'];
1639 }
1640 if ( isset( $item['single-id'] ) ) {
1641 if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) {
1642 $title = Linker::titleAttrib( $item['single-id'] );
1643 if ( $title !== false ) {
1644 $attrs['title'] = $title;
1645 }
1646 } else {
1647 $tip = Linker::tooltipAndAccesskeyAttribs( $item['single-id'] );
1648 if ( isset( $tip['title'] ) && $tip['title'] !== false ) {
1649 $attrs['title'] = $tip['title'];
1650 }
1651 if ( isset( $tip['accesskey'] ) && $tip['accesskey'] !== false ) {
1652 $attrs['accesskey'] = $tip['accesskey'];
1653 }
1654 }
1655 }
1656 if ( isset( $options['link-class'] ) ) {
1657 if ( isset( $attrs['class'] ) ) {
1658 $attrs['class'] .= " {$options['link-class']}";
1659 } else {
1660 $attrs['class'] = $options['link-class'];
1661 }
1662 }
1663 $html = Html::rawElement( isset( $attrs['href'] ) ? 'a' : $options['link-fallback'], $attrs, $html );
1664 }
1665
1666 return $html;
1667 }
1668
1669 /**
1670 * Generates a list item for a navigation, portlet, portal, sidebar... etc list
1671 * $key is a string, usually a key from the list you are generating this link from
1672 * $item is an array of list item data containing some of a specific set of keys.
1673 * The "id" and "class" keys will be used as attributes for the list item,
1674 * if "active" contains a value of true a "active" class will also be appended to class.
1675 * If you want something other than a <li> you can pass a tag name such as
1676 * "tag" => "span" in the $options array to change the tag used.
1677 * link/content data for the list item may come in one of two forms
1678 * A "links" key may be used, in which case it should contain an array with
1679 * a list of links to include inside the list item, see makeLink for the format
1680 * of individual links array items.
1681 * Otherwise the relevant keys from the list item $item array will be passed
1682 * to makeLink instead. Note however that "id" and "class" are used by the
1683 * list item directly so they will not be passed to makeLink
1684 * (however the link will still support a tooltip and accesskey from it)
1685 * If you need an id or class on a single link you should include a "links"
1686 * array with just one link item inside of it.
1687 * $options is also passed on to makeLink calls
1688 * @return string
1689 */
1690 function makeListItem( $key, $item, $options = array() ) {
1691 if ( isset( $item['links'] ) ) {
1692 $html = '';
1693 foreach ( $item['links'] as $linkKey => $link ) {
1694 $html .= $this->makeLink( $linkKey, $link, $options );
1695 }
1696 } else {
1697 $link = $item;
1698 // These keys are used by makeListItem and shouldn't be passed on to the link
1699 foreach ( array( 'id', 'class', 'active', 'tag' ) as $k ) {
1700 unset( $link[$k] );
1701 }
1702 if ( isset( $item['id'] ) ) {
1703 // The id goes on the <li> not on the <a> for single links
1704 // but makeSidebarLink still needs to know what id to use when
1705 // generating tooltips and accesskeys.
1706 $link['single-id'] = $item['id'];
1707 }
1708 $html = $this->makeLink( $key, $link, $options );
1709 }
1710
1711 $attrs = array();
1712 foreach ( array( 'id', 'class' ) as $attr ) {
1713 if ( isset( $item[$attr] ) ) {
1714 $attrs[$attr] = $item[$attr];
1715 }
1716 }
1717 if ( isset( $item['active'] ) && $item['active'] ) {
1718 if ( !isset( $attrs['class'] ) ) {
1719 $attrs['class'] = '';
1720 }
1721 $attrs['class'] .= ' active';
1722 $attrs['class'] = trim( $attrs['class'] );
1723 }
1724 return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html );
1725 }
1726
1727 function makeSearchInput( $attrs = array() ) {
1728 $realAttrs = array(
1729 'type' => 'search',
1730 'name' => 'search',
1731 'value' => isset( $this->data['search'] ) ? $this->data['search'] : '',
1732 );
1733 $realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
1734 return Html::element( 'input', $realAttrs );
1735 }
1736
1737 function makeSearchButton( $mode, $attrs = array() ) {
1738 switch( $mode ) {
1739 case 'go':
1740 case 'fulltext':
1741 $realAttrs = array(
1742 'type' => 'submit',
1743 'name' => $mode,
1744 'value' => $this->translator->translate(
1745 $mode == 'go' ? 'searcharticle' : 'searchbutton' ),
1746 );
1747 $realAttrs = array_merge(
1748 $realAttrs,
1749 Linker::tooltipAndAccesskeyAttribs( "search-$mode" ),
1750 $attrs
1751 );
1752 return Html::element( 'input', $realAttrs );
1753 case 'image':
1754 $buttonAttrs = array(
1755 'type' => 'submit',
1756 'name' => 'button',
1757 );
1758 $buttonAttrs = array_merge(
1759 $buttonAttrs,
1760 Linker::tooltipAndAccesskeyAttribs( 'search-fulltext' ),
1761 $attrs
1762 );
1763 unset( $buttonAttrs['src'] );
1764 unset( $buttonAttrs['alt'] );
1765 $imgAttrs = array(
1766 'src' => $attrs['src'],
1767 'alt' => isset( $attrs['alt'] )
1768 ? $attrs['alt']
1769 : $this->translator->translate( 'searchbutton' ),
1770 );
1771 return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
1772 default:
1773 throw new MWException( 'Unknown mode passed to BaseTemplate::makeSearchButton' );
1774 }
1775 }
1776
1777 /**
1778 * Returns an array of footerlinks trimmed down to only those footer links that
1779 * are valid.
1780 * If you pass "flat" as an option then the returned array will be a flat array
1781 * of footer icons instead of a key/value array of footerlinks arrays broken
1782 * up into categories.
1783 * @return array|mixed
1784 */
1785 function getFooterLinks( $option = null ) {
1786 $footerlinks = $this->data['footerlinks'];
1787
1788 // Reduce footer links down to only those which are being used
1789 $validFooterLinks = array();
1790 foreach( $footerlinks as $category => $links ) {
1791 $validFooterLinks[$category] = array();
1792 foreach( $links as $link ) {
1793 if( isset( $this->data[$link] ) && $this->data[$link] ) {
1794 $validFooterLinks[$category][] = $link;
1795 }
1796 }
1797 if ( count( $validFooterLinks[$category] ) <= 0 ) {
1798 unset( $validFooterLinks[$category] );
1799 }
1800 }
1801
1802 if ( $option == 'flat' ) {
1803 // fold footerlinks into a single array using a bit of trickery
1804 $validFooterLinks = call_user_func_array(
1805 'array_merge',
1806 array_values( $validFooterLinks )
1807 );
1808 }
1809
1810 return $validFooterLinks;
1811 }
1812
1813 /**
1814 * Returns an array of footer icons filtered down by options relevant to how
1815 * the skin wishes to display them.
1816 * If you pass "icononly" as the option all footer icons which do not have an
1817 * image icon set will be filtered out.
1818 * If you pass "nocopyright" then MediaWiki's copyright icon will not be included
1819 * in the list of footer icons. This is mostly useful for skins which only
1820 * display the text from footericons instead of the images and don't want a
1821 * duplicate copyright statement because footerlinks already rendered one.
1822 * @return
1823 */
1824 function getFooterIcons( $option = null ) {
1825 // Generate additional footer icons
1826 $footericons = $this->data['footericons'];
1827
1828 if ( $option == 'icononly' ) {
1829 // Unset any icons which don't have an image
1830 foreach ( $footericons as &$footerIconsBlock ) {
1831 foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
1832 if ( !is_string( $footerIcon ) && !isset( $footerIcon['src'] ) ) {
1833 unset( $footerIconsBlock[$footerIconKey] );
1834 }
1835 }
1836 }
1837 // Redo removal of any empty blocks
1838 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
1839 if ( count( $footerIconsBlock ) <= 0 ) {
1840 unset( $footericons[$footerIconsKey] );
1841 }
1842 }
1843 } elseif ( $option == 'nocopyright' ) {
1844 unset( $footericons['copyright']['copyright'] );
1845 if ( count( $footericons['copyright'] ) <= 0 ) {
1846 unset( $footericons['copyright'] );
1847 }
1848 }
1849
1850 return $footericons;
1851 }
1852
1853 /**
1854 * Output the basic end-page trail including bottomscripts, reporttime, and
1855 * debug stuff. This should be called right before outputting the closing
1856 * body and html tags.
1857 */
1858 function printTrail() { ?>
1859 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
1860 <?php $this->html('reporttime') ?>
1861 <?php if ( $this->data['debug'] ): ?>
1862 <!-- Debug output:
1863 <?php $this->text( 'debug' ); ?>
1864
1865 -->
1866 <?php endif;
1867 }
1868
1869 }
1870