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