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