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