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