Reverted r91871 per CR: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91871...
[lhc/web/wiklou.git] / includes / Skin.php
1 <?php
2 /**
3 * @defgroup Skins Skins
4 */
5
6 if ( !defined( 'MEDIAWIKI' ) ) {
7 die( 1 );
8 }
9
10 /**
11 * The main skin class that provide methods and properties for all other skins.
12 * This base class is also the "Standard" skin.
13 *
14 * See docs/skin.txt for more information.
15 *
16 * @ingroup Skins
17 */
18 abstract class Skin extends ContextSource {
19 protected $skinname = 'standard';
20 protected $mRelevantTitle = null;
21 protected $mRelevantUser = null;
22
23 /**
24 * Fetch the set of available skins.
25 * @return array of strings
26 */
27 static function getSkinNames() {
28 global $wgValidSkinNames;
29 static $skinsInitialised = false;
30
31 if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
32 # Get a list of available skins
33 # Build using the regular expression '^(.*).php$'
34 # Array keys are all lower case, array value keep the case used by filename
35 #
36 wfProfileIn( __METHOD__ . '-init' );
37
38 global $wgStyleDirectory;
39
40 $skinDir = dir( $wgStyleDirectory );
41
42 # while code from www.php.net
43 while ( false !== ( $file = $skinDir->read() ) ) {
44 // Skip non-PHP files, hidden files, and '.dep' includes
45 $matches = array();
46
47 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
48 $aSkin = $matches[1];
49 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
50 }
51 }
52 $skinDir->close();
53 $skinsInitialised = true;
54 wfProfileOut( __METHOD__ . '-init' );
55 }
56 return $wgValidSkinNames;
57 }
58
59 /**
60 * Fetch the list of usable skins in regards to $wgSkipSkins.
61 * Useful for Special:Preferences and other places where you
62 * only want to show skins users _can_ use.
63 * @return array of strings
64 */
65 public static function getUsableSkins() {
66 global $wgSkipSkins;
67
68 $usableSkins = self::getSkinNames();
69
70 foreach ( $wgSkipSkins as $skip ) {
71 unset( $usableSkins[$skip] );
72 }
73
74 return $usableSkins;
75 }
76
77 /**
78 * Normalize a skin preference value to a form that can be loaded.
79 * If a skin can't be found, it will fall back to the configured
80 * default (or the old 'Classic' skin if that's broken).
81 * @param $key String: 'monobook', 'standard', etc.
82 * @return string
83 */
84 static function normalizeKey( $key ) {
85 global $wgDefaultSkin;
86
87 $skinNames = Skin::getSkinNames();
88
89 if ( $key == '' ) {
90 // Don't return the default immediately;
91 // in a misconfiguration we need to fall back.
92 $key = $wgDefaultSkin;
93 }
94
95 if ( isset( $skinNames[$key] ) ) {
96 return $key;
97 }
98
99 // Older versions of the software used a numeric setting
100 // in the user preferences.
101 $fallback = array(
102 0 => $wgDefaultSkin,
103 1 => 'nostalgia',
104 2 => 'cologneblue'
105 );
106
107 if ( isset( $fallback[$key] ) ) {
108 $key = $fallback[$key];
109 }
110
111 if ( isset( $skinNames[$key] ) ) {
112 return $key;
113 } elseif ( isset( $skinNames[$wgDefaultSkin] ) ) {
114 return $wgDefaultSkin;
115 } else {
116 return 'vector';
117 }
118 }
119
120 /**
121 * Factory method for loading a skin of a given type
122 * @param $key String: 'monobook', 'standard', etc.
123 * @return Skin
124 */
125 static function &newFromKey( $key ) {
126 global $wgStyleDirectory;
127
128 $key = Skin::normalizeKey( $key );
129
130 $skinNames = Skin::getSkinNames();
131 $skinName = $skinNames[$key];
132 $className = "Skin{$skinName}";
133
134 # Grab the skin class and initialise it.
135 if ( !MWInit::classExists( $className ) ) {
136
137 if ( !defined( 'MW_COMPILED' ) ) {
138 // Preload base classes to work around APC/PHP5 bug
139 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
140 if ( file_exists( $deps ) ) {
141 include_once( $deps );
142 }
143 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
144 }
145
146 # Check if we got if not failback to default skin
147 if ( !MWInit::classExists( $className ) ) {
148 # DO NOT die if the class isn't found. This breaks maintenance
149 # scripts and can cause a user account to be unrecoverable
150 # except by SQL manipulation if a previously valid skin name
151 # is no longer valid.
152 wfDebug( "Skin class does not exist: $className\n" );
153 $className = 'SkinVector';
154 if ( !defined( 'MW_COMPILED' ) ) {
155 require_once( "{$wgStyleDirectory}/Vector.php" );
156 }
157 }
158 }
159 $skin = new $className;
160 return $skin;
161 }
162
163 /** @return string skin name */
164 public function getSkinName() {
165 return $this->skinname;
166 }
167
168 function initPage( OutputPage $out ) {
169 wfProfileIn( __METHOD__ );
170
171 $this->preloadExistence();
172
173 wfProfileOut( __METHOD__ );
174 }
175
176 /**
177 * Preload the existence of three commonly-requested pages in a single query
178 */
179 function preloadExistence() {
180 $user = $this->getUser();
181
182 // User/talk link
183 $titles = array( $user->getUserPage(), $user->getTalkPage() );
184
185 // Other tab link
186 if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) {
187 // nothing
188 } elseif ( $this->getTitle()->isTalkPage() ) {
189 $titles[] = $this->getTitle()->getSubjectPage();
190 } else {
191 $titles[] = $this->getTitle()->getTalkPage();
192 }
193
194 $lb = new LinkBatch( $titles );
195 $lb->setCaller( __METHOD__ );
196 $lb->execute();
197 }
198
199 /**
200 * Get the current revision ID
201 *
202 * @return Integer
203 */
204 public function getRevisionId() {
205 return $this->getOutput()->getRevisionId();
206 }
207
208 /**
209 * Whether the revision displayed is the latest revision of the page
210 *
211 * @return Boolean
212 */
213 public function isRevisionCurrent() {
214 $revID = $this->getRevisionId();
215 return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
216 }
217
218 /**
219 * Set the "relevant" title
220 * @see self::getRelevantTitle()
221 * @param $t Title object to use
222 */
223 public function setRelevantTitle( $t ) {
224 $this->mRelevantTitle = $t;
225 }
226
227 /**
228 * Return the "relevant" title.
229 * A "relevant" title is not necessarily the actual title of the page.
230 * Special pages like Special:MovePage use set the page they are acting on
231 * as their "relevant" title, this allows the skin system to display things
232 * such as content tabs which belong to to that page instead of displaying
233 * a basic special page tab which has almost no meaning.
234 *
235 * @return Title
236 */
237 public function getRelevantTitle() {
238 if ( isset($this->mRelevantTitle) ) {
239 return $this->mRelevantTitle;
240 }
241 return $this->getTitle();
242 }
243
244 /**
245 * Set the "relevant" user
246 * @see self::getRelevantUser()
247 * @param $u User object to use
248 */
249 public function setRelevantUser( $u ) {
250 $this->mRelevantUser = $u;
251 }
252
253 /**
254 * Return the "relevant" user.
255 * A "relevant" user is similar to a relevant title. Special pages like
256 * Special:Contributions mark the user which they are relevant to so that
257 * things like the toolbox can display the information they usually are only
258 * able to display on a user's userpage and talkpage.
259 * @return User
260 */
261 public function getRelevantUser() {
262 if ( isset($this->mRelevantUser) ) {
263 return $this->mRelevantUser;
264 }
265 $title = $this->getRelevantTitle();
266 if( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) {
267 $rootUser = strtok( $title->getText(), '/' );
268 if ( User::isIP( $rootUser ) ) {
269 $this->mRelevantUser = User::newFromName( $rootUser, false );
270 } else {
271 $user = User::newFromName( $rootUser );
272 if ( $user->isLoggedIn() ) {
273 $this->mRelevantUser = $user;
274 }
275 }
276 return $this->mRelevantUser;
277 }
278 return null;
279 }
280
281 /**
282 * Outputs the HTML generated by other functions.
283 * @param $out OutputPage
284 */
285 abstract function outputPage( OutputPage $out );
286
287 static function makeVariablesScript( $data ) {
288 if ( $data ) {
289 return Html::inlineScript(
290 ResourceLoader::makeLoaderConditionalScript( ResourceLoader::makeConfigSetScript( $data ) )
291 );
292 } else {
293 return '';
294 }
295 }
296
297 /**
298 * Generated JavaScript action=raw&gen=js
299 * This used to load MediaWiki:Common.js and the skin-specific style
300 * before the ResourceLoader.
301 *
302 * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
303 * point.
304 * @param $skinName String: If set, overrides the skin name
305 * @return String
306 */
307 public function generateUserJs( $skinName = null ) {
308 return '';
309 }
310
311 /**
312 * Generate user stylesheet for action=raw&gen=css
313 *
314 * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
315 * point.
316 * @return String
317 */
318 public function generateUserStylesheet() {
319 return '';
320 }
321
322 /**
323 * Get the query to generate a dynamic stylesheet
324 *
325 * @return array
326 */
327 public static function getDynamicStylesheetQuery() {
328 global $wgSquidMaxage;
329
330 return array(
331 'action' => 'raw',
332 'maxage' => $wgSquidMaxage,
333 'usemsgcache' => 'yes',
334 'ctype' => 'text/css',
335 'smaxage' => $wgSquidMaxage,
336 );
337 }
338
339 /**
340 * Add skin specific stylesheets
341 * Calling this method with an $out of anything but the same OutputPage
342 * inside ->getOutput() is deprecated. The $out arg is kept
343 * for compatibility purposes with skins.
344 * @param $out OutputPage
345 * @delete
346 */
347 abstract function setupSkinUserCss( OutputPage $out );
348
349 /**
350 * TODO: document
351 * @param $title Title
352 * @return String
353 */
354 function getPageClasses( $title ) {
355 $numeric = 'ns-' . $title->getNamespace();
356
357 if ( $title->getNamespace() == NS_SPECIAL ) {
358 $type = 'ns-special';
359 // bug 23315: provide a class based on the canonical special page name without subpages
360 list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
361 if ( $canonicalName ) {
362 $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
363 } else {
364 $type .= ' mw-invalidspecialpage';
365 }
366 } elseif ( $title->isTalkPage() ) {
367 $type = 'ns-talk';
368 } else {
369 $type = 'ns-subject';
370 }
371
372 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
373
374 return "$numeric $type $name";
375 }
376
377 /**
378 * This will be called by OutputPage::headElement when it is creating the
379 * <body> tag, skins can override it if they have a need to add in any
380 * body attributes or classes of their own.
381 * @param $out OutputPage
382 * @param $bodyAttrs Array
383 */
384 function addToBodyAttributes( $out, &$bodyAttrs ) {
385 // does nothing by default
386 }
387
388 /**
389 * URL to the logo
390 * @return String
391 */
392 function getLogo() {
393 global $wgLogo;
394 return $wgLogo;
395 }
396
397 function getCategoryLinks() {
398 global $wgUseCategoryBrowser;
399
400 $out = $this->getOutput();
401 $allCats = $out->getCategoryLinks();
402
403 if ( !count( $allCats ) ) {
404 return '';
405 }
406
407 $embed = "<li>";
408 $pop = "</li>";
409
410 $s = '';
411 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
412
413 if ( !empty( $allCats['normal'] ) ) {
414 $t = $embed . implode( "{$pop}{$embed}" , $allCats['normal'] ) . $pop;
415
416 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
417 $s .= '<div id="mw-normal-catlinks">' .
418 Linker::link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
419 . $colon . '<ul>' . $t . '</ul>' . '</div>';
420 }
421
422 # Hidden categories
423 if ( isset( $allCats['hidden'] ) ) {
424 if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
425 $class = 'mw-hidden-cats-user-shown';
426 } elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
427 $class = 'mw-hidden-cats-ns-shown';
428 } else {
429 $class = 'mw-hidden-cats-hidden';
430 }
431
432 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
433 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
434 $colon . '<ul>' . $embed . implode( "{$pop}{$embed}" , $allCats['hidden'] ) . $pop . '</ul>' .
435 '</div>';
436 }
437
438 # optional 'dmoz-like' category browser. Will be shown under the list
439 # of categories an article belong to
440 if ( $wgUseCategoryBrowser ) {
441 $s .= '<br /><hr />';
442
443 # get a big array of the parents tree
444 $parenttree = $this->getTitle()->getParentCategoryTree();
445 # Skin object passed by reference cause it can not be
446 # accessed under the method subfunction drawCategoryBrowser
447 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
448 # Clean out bogus first entry and sort them
449 unset( $tempout[0] );
450 asort( $tempout );
451 # Output one per line
452 $s .= implode( "<br />\n", $tempout );
453 }
454
455 return $s;
456 }
457
458 /**
459 * Render the array as a serie of links.
460 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
461 * @return String separated by &gt;, terminate with "\n"
462 */
463 function drawCategoryBrowser( $tree ) {
464 $return = '';
465
466 foreach ( $tree as $element => $parent ) {
467 if ( empty( $parent ) ) {
468 # element start a new list
469 $return .= "\n";
470 } else {
471 # grab the others elements
472 $return .= $this->drawCategoryBrowser( $parent ) . ' &gt; ';
473 }
474
475 # add our current element to the list
476 $eltitle = Title::newFromText( $element );
477 $return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
478 }
479
480 return $return;
481 }
482
483 function getCategories() {
484 $out = $this->getOutput();
485
486 $catlinks = $this->getCategoryLinks();
487
488 $classes = 'catlinks';
489
490 // Check what we're showing
491 $allCats = $out->getCategoryLinks();
492 $showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
493 $this->getTitle()->getNamespace() == NS_CATEGORY;
494
495 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
496 $classes .= ' catlinks-allhidden';
497 }
498
499 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
500 }
501
502 /**
503 * This runs a hook to allow extensions placing their stuff after content
504 * and article metadata (e.g. categories).
505 * Note: This function has nothing to do with afterContent().
506 *
507 * This hook is placed here in order to allow using the same hook for all
508 * skins, both the SkinTemplate based ones and the older ones, which directly
509 * use this class to get their data.
510 *
511 * The output of this function gets processed in SkinTemplate::outputPage() for
512 * the SkinTemplate based skins, all other skins should directly echo it.
513 *
514 * @return String, empty by default, if not changed by any hook function.
515 */
516 protected function afterContentHook() {
517 $data = '';
518
519 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
520 // adding just some spaces shouldn't toggle the output
521 // of the whole <div/>, so we use trim() here
522 if ( trim( $data ) != '' ) {
523 // Doing this here instead of in the skins to
524 // ensure that the div has the same ID in all
525 // skins
526 $data = "<div id='mw-data-after-content'>\n" .
527 "\t$data\n" .
528 "</div>\n";
529 }
530 } else {
531 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
532 }
533
534 return $data;
535 }
536
537 /**
538 * Generate debug data HTML for displaying at the bottom of the main content
539 * area.
540 * @return String HTML containing debug data, if enabled (otherwise empty).
541 */
542 protected function generateDebugHTML() {
543 global $wgShowDebug;
544
545 if ( $wgShowDebug ) {
546 $listInternals = $this->formatDebugHTML( $this->getOutput()->mDebugtext );
547 return "\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">" .
548 $listInternals . "</ul>\n";
549 }
550
551 return '';
552 }
553
554 private function formatDebugHTML( $debugText ) {
555 global $wgDebugTimestamps;
556
557 $lines = explode( "\n", $debugText );
558 $curIdent = 0;
559 $ret = '<li>';
560
561 foreach ( $lines as $line ) {
562 $pre = '';
563 if ( $wgDebugTimestamps ) {
564 $matches = array();
565 if ( preg_match( '/^(\d+\.\d+\s{2})/', $line, $matches ) ) {
566 $pre = $matches[1];
567 $line = substr( $line, strlen( $pre ) );
568 }
569 }
570 $display = ltrim( $line );
571 $ident = strlen( $line ) - strlen( $display );
572 $diff = $ident - $curIdent;
573
574 $display = $pre . $display;
575 if ( $display == '' ) {
576 $display = "\xc2\xa0";
577 }
578
579 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
580 $ident = $curIdent;
581 $diff = 0;
582 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
583 } else {
584 $display = htmlspecialchars( $display );
585 }
586
587 if ( $diff < 0 ) {
588 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
589 } elseif ( $diff == 0 ) {
590 $ret .= "</li><li>\n";
591 } else {
592 $ret .= str_repeat( "<ul><li>\n", $diff );
593 }
594 $ret .= "<tt>$display</tt>\n";
595
596 $curIdent = $ident;
597 }
598
599 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
600
601 return $ret;
602 }
603
604 /**
605 * This gets called shortly before the </body> tag.
606 *
607 * @return String HTML-wrapped JS code to be put before </body>
608 */
609 function bottomScripts() {
610 // TODO and the suckage continues. This function is really just a wrapper around
611 // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
612 // up at some point
613 $bottomScriptText = $this->getOutput()->getBottomScripts();
614 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
615
616 return $bottomScriptText;
617 }
618
619 /** @return string Retrievied from HTML text */
620 function printSource() {
621 $url = htmlspecialchars( $this->getTitle()->getFullURL() );
622 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
623 }
624
625 function getUndeleteLink() {
626 $action = $this->getRequest()->getVal( 'action', 'view' );
627
628 if ( $this->getUser()->isAllowed( 'deletedhistory' ) && !$this->getUser()->isBlocked() &&
629 ( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
630
631 $includeSuppressed = $this->getUser()->isAllowed( 'suppressrevision' );
632 $n = $this->getTitle()->isDeleted( $includeSuppressed );
633
634 if ( $n ) {
635 if ( $this->getUser()->isAllowed( 'undelete' ) ) {
636 $msg = 'thisisdeleted';
637 } else {
638 $msg = 'viewdeleted';
639 }
640
641 return wfMsg(
642 $msg,
643 Linker::linkKnown(
644 SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
645 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $n ) )
646 )
647 );
648 }
649 }
650
651 return '';
652 }
653
654 function subPageSubtitle() {
655 $out = $this->getOutput();
656 $subpages = '';
657
658 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
659 return $subpages;
660 }
661
662 if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) {
663 $ptext = $this->getTitle()->getPrefixedText();
664 if ( preg_match( '/\//', $ptext ) ) {
665 $links = explode( '/', $ptext );
666 array_pop( $links );
667 $c = 0;
668 $growinglink = '';
669 $display = '';
670
671 foreach ( $links as $link ) {
672 $growinglink .= $link;
673 $display .= $link;
674 $linkObj = Title::newFromText( $growinglink );
675
676 if ( is_object( $linkObj ) && $linkObj->exists() ) {
677 $getlink = Linker::linkKnown(
678 $linkObj,
679 htmlspecialchars( $display )
680 );
681
682 $c++;
683
684 if ( $c > 1 ) {
685 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
686 } else {
687 $subpages .= '&lt; ';
688 }
689
690 $subpages .= $getlink;
691 $display = '';
692 } else {
693 $display .= '/';
694 }
695 $growinglink .= '/';
696 }
697 }
698 }
699
700 return $subpages;
701 }
702
703 /**
704 * Returns true if the IP should be shown in the header
705 * @return Bool
706 */
707 function showIPinHeader() {
708 global $wgShowIPinHeader;
709 return $wgShowIPinHeader && session_id() != '';
710 }
711
712 function getSearchLink() {
713 $searchPage = SpecialPage::getTitleFor( 'Search' );
714 return $searchPage->getLocalURL();
715 }
716
717 function escapeSearchLink() {
718 return htmlspecialchars( $this->getSearchLink() );
719 }
720
721 function getCopyright( $type = 'detect' ) {
722 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
723
724 if ( $type == 'detect' ) {
725 if ( !$this->isRevisionCurrent() && wfMsgForContent( 'history_copyright' ) !== '-' ) {
726 $type = 'history';
727 } else {
728 $type = 'normal';
729 }
730 }
731
732 if ( $type == 'history' ) {
733 $msg = 'history_copyright';
734 } else {
735 $msg = 'copyright';
736 }
737
738 if ( $wgRightsPage ) {
739 $title = Title::newFromText( $wgRightsPage );
740 $link = Linker::linkKnown( $title, $wgRightsText );
741 } elseif ( $wgRightsUrl ) {
742 $link = Linker::makeExternalLink( $wgRightsUrl, $wgRightsText );
743 } elseif ( $wgRightsText ) {
744 $link = $wgRightsText;
745 } else {
746 # Give up now
747 return '';
748 }
749
750 // Allow for site and per-namespace customization of copyright notice.
751 $forContent = true;
752
753 wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
754
755 if ( $forContent ) {
756 return wfMsgForContent( $msg, $link );
757 } else {
758 return wfMsg( $msg, $link );
759 }
760 }
761
762 function getCopyrightIcon() {
763 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
764
765 $out = '';
766
767 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
768 $out = $wgCopyrightIcon;
769 } elseif ( $wgRightsIcon ) {
770 $icon = htmlspecialchars( $wgRightsIcon );
771
772 if ( $wgRightsUrl ) {
773 $url = htmlspecialchars( $wgRightsUrl );
774 $out .= '<a href="' . $url . '">';
775 }
776
777 $text = htmlspecialchars( $wgRightsText );
778 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
779
780 if ( $wgRightsUrl ) {
781 $out .= '</a>';
782 }
783 }
784
785 return $out;
786 }
787
788 /**
789 * Gets the powered by MediaWiki icon.
790 * @return string
791 */
792 function getPoweredBy() {
793 global $wgStylePath;
794
795 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
796 $text = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
797 wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
798 return $text;
799 }
800
801 /**
802 * Get the timestamp of the latest revision, formatted in user language
803 *
804 * @param $article Article object. Used if we're working with the current revision
805 * @return String
806 */
807 protected function lastModified( $article ) {
808 if ( !$this->isRevisionCurrent() ) {
809 $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
810 } else {
811 $timestamp = $article->getTimestamp();
812 }
813
814 if ( $timestamp ) {
815 $d = $this->getLang()->date( $timestamp, true );
816 $t = $this->getLang()->time( $timestamp, true );
817 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
818 } else {
819 $s = '';
820 }
821
822 if ( wfGetLB()->getLaggedSlaveMode() ) {
823 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
824 }
825
826 return $s;
827 }
828
829 function logoText( $align = '' ) {
830 if ( $align != '' ) {
831 $a = " align='{$align}'";
832 } else {
833 $a = '';
834 }
835
836 $mp = wfMsgHtml( 'mainpage' );
837 $mptitle = Title::newMainPage();
838 $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
839
840 $logourl = $this->getLogo();
841 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
842
843 return $s;
844 }
845
846 /**
847 * Renders a $wgFooterIcons icon acording to the method's arguments
848 * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array
849 * @param $withImage Bool|String: Whether to use the icon's image or output a text-only footericon
850 * @return String HTML
851 */
852 function makeFooterIcon( $icon, $withImage = 'withImage' ) {
853 if ( is_string( $icon ) ) {
854 $html = $icon;
855 } else { // Assuming array
856 $url = isset($icon["url"]) ? $icon["url"] : null;
857 unset( $icon["url"] );
858 if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
859 $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
860 } else {
861 $html = htmlspecialchars( $icon["alt"] );
862 }
863 if ( $url ) {
864 $html = Html::rawElement( 'a', array( "href" => $url ), $html );
865 }
866 }
867 return $html;
868 }
869
870 /**
871 * Gets the link to the wiki's main page.
872 * @return string
873 */
874 function mainPageLink() {
875 $s = Linker::linkKnown(
876 Title::newMainPage(),
877 wfMsgHtml( 'mainpage' )
878 );
879
880 return $s;
881 }
882
883 public function footerLink( $desc, $page ) {
884 // if the link description has been set to "-" in the default language,
885 if ( wfMsgForContent( $desc ) == '-' ) {
886 // then it is disabled, for all languages.
887 return '';
888 } else {
889 // Otherwise, we display the link for the user, described in their
890 // language (which may or may not be the same as the default language),
891 // but we make the link target be the one site-wide page.
892 $title = Title::newFromText( wfMsgForContent( $page ) );
893
894 return Linker::linkKnown(
895 $title,
896 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
897 );
898 }
899 }
900
901 /**
902 * Gets the link to the wiki's privacy policy page.
903 * @return String HTML
904 */
905 function privacyLink() {
906 return $this->footerLink( 'privacy', 'privacypage' );
907 }
908
909 /**
910 * Gets the link to the wiki's about page.
911 * @return String HTML
912 */
913 function aboutLink() {
914 return $this->footerLink( 'aboutsite', 'aboutpage' );
915 }
916
917 /**
918 * Gets the link to the wiki's general disclaimers page.
919 * @return String HTML
920 */
921 function disclaimerLink() {
922 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
923 }
924
925 /**
926 * Return URL options for the 'edit page' link.
927 * This may include an 'oldid' specifier, if the current page view is such.
928 *
929 * @return array
930 * @private
931 */
932 function editUrlOptions() {
933 $options = array( 'action' => 'edit' );
934
935 if ( !$this->isRevisionCurrent() ) {
936 $options['oldid'] = intval( $this->getRevisionId() );
937 }
938
939 return $options;
940 }
941
942 function showEmailUser( $id ) {
943 $targetUser = User::newFromId( $id );
944 return $this->getUser()->canSendEmail() && # the sending user must have a confirmed email address
945 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
946 }
947
948 /**
949 * Return a fully resolved style path url to images or styles stored in the common folder.
950 * This method returns a url resolved using the configured skin style path
951 * and includes the style version inside of the url.
952 * @param $name String: The name or path of a skin resource file
953 * @return String The fully resolved style path url including styleversion
954 */
955 function getCommonStylePath( $name ) {
956 global $wgStylePath, $wgStyleVersion;
957 return "$wgStylePath/common/$name?$wgStyleVersion";
958 }
959
960 /**
961 * Return a fully resolved style path url to images or styles stored in the curent skins's folder.
962 * This method returns a url resolved using the configured skin style path
963 * and includes the style version inside of the url.
964 * @param $name String: The name or path of a skin resource file
965 * @return String The fully resolved style path url including styleversion
966 */
967 function getSkinStylePath( $name ) {
968 global $wgStylePath, $wgStyleVersion;
969 return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
970 }
971
972 /* these are used extensively in SkinTemplate, but also some other places */
973 static function makeMainPageUrl( $urlaction = '' ) {
974 $title = Title::newMainPage();
975 self::checkTitle( $title, '' );
976
977 return $title->getLocalURL( $urlaction );
978 }
979
980 static function makeSpecialUrl( $name, $urlaction = '' ) {
981 $title = SpecialPage::getSafeTitleFor( $name );
982 return $title->getLocalURL( $urlaction );
983 }
984
985 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
986 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
987 return $title->getLocalURL( $urlaction );
988 }
989
990 static function makeI18nUrl( $name, $urlaction = '' ) {
991 $title = Title::newFromText( wfMsgForContent( $name ) );
992 self::checkTitle( $title, $name );
993 return $title->getLocalURL( $urlaction );
994 }
995
996 static function makeUrl( $name, $urlaction = '' ) {
997 $title = Title::newFromText( $name );
998 self::checkTitle( $title, $name );
999
1000 return $title->getLocalURL( $urlaction );
1001 }
1002
1003 /**
1004 * If url string starts with http, consider as external URL, else
1005 * internal
1006 * @param $name String
1007 * @return String URL
1008 */
1009 static function makeInternalOrExternalUrl( $name ) {
1010 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1011 return $name;
1012 } else {
1013 return self::makeUrl( $name );
1014 }
1015 }
1016
1017 # this can be passed the NS number as defined in Language.php
1018 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
1019 $title = Title::makeTitleSafe( $namespace, $name );
1020 self::checkTitle( $title, $name );
1021
1022 return $title->getLocalURL( $urlaction );
1023 }
1024
1025 /* these return an array with the 'href' and boolean 'exists' */
1026 static function makeUrlDetails( $name, $urlaction = '' ) {
1027 $title = Title::newFromText( $name );
1028 self::checkTitle( $title, $name );
1029
1030 return array(
1031 'href' => $title->getLocalURL( $urlaction ),
1032 'exists' => $title->getArticleID() != 0,
1033 );
1034 }
1035
1036 /**
1037 * Make URL details where the article exists (or at least it's convenient to think so)
1038 * @param $name String Article name
1039 * @param $urlaction String
1040 * @return Array
1041 */
1042 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1043 $title = Title::newFromText( $name );
1044 self::checkTitle( $title, $name );
1045
1046 return array(
1047 'href' => $title->getLocalURL( $urlaction ),
1048 'exists' => true
1049 );
1050 }
1051
1052 # make sure we have some title to operate on
1053 static function checkTitle( &$title, $name ) {
1054 if ( !is_object( $title ) ) {
1055 $title = Title::newFromText( $name );
1056 if ( !is_object( $title ) ) {
1057 $title = Title::newFromText( '--error: link target missing--' );
1058 }
1059 }
1060 }
1061
1062 /**
1063 * Build an array that represents the sidebar(s), the navigation bar among them
1064 *
1065 * @return array
1066 */
1067 function buildSidebar() {
1068 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1069 wfProfileIn( __METHOD__ );
1070
1071 $key = wfMemcKey( 'sidebar', $this->getLang()->getCode() );
1072
1073 if ( $wgEnableSidebarCache ) {
1074 $cachedsidebar = $parserMemc->get( $key );
1075 if ( $cachedsidebar ) {
1076 wfProfileOut( __METHOD__ );
1077 return $cachedsidebar;
1078 }
1079 }
1080
1081 $bar = array();
1082 $this->addToSidebar( $bar, 'sidebar' );
1083
1084 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
1085 if ( $wgEnableSidebarCache ) {
1086 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1087 }
1088
1089 wfProfileOut( __METHOD__ );
1090 return $bar;
1091 }
1092 /**
1093 * Add content from a sidebar system message
1094 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
1095 *
1096 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
1097 *
1098 * @param &$bar array
1099 * @param $message String
1100 */
1101 function addToSidebar( &$bar, $message ) {
1102 $this->addToSidebarPlain( $bar, wfMsgForContentNoTrans( $message ) );
1103 }
1104
1105 /**
1106 * Add content from plain text
1107 * @since 1.17
1108 * @param &$bar array
1109 * @param $text string
1110 * @return Array
1111 */
1112 function addToSidebarPlain( &$bar, $text ) {
1113 $lines = explode( "\n", $text );
1114 $wikiBar = array(); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
1115
1116 $heading = '';
1117
1118 foreach ( $lines as $line ) {
1119 if ( strpos( $line, '*' ) !== 0 ) {
1120 continue;
1121 }
1122 $line = rtrim( $line, "\r" ); // for Windows compat
1123
1124 if ( strpos( $line, '**' ) !== 0 ) {
1125 $heading = trim( $line, '* ' );
1126 if ( !array_key_exists( $heading, $bar ) ) {
1127 $bar[$heading] = array();
1128 }
1129 } else {
1130 $line = trim( $line, '* ' );
1131
1132 if ( strpos( $line, '|' ) !== false ) { // sanity check
1133 $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
1134 $line = array_map( 'trim', explode( '|', $line, 2 ) );
1135 $extraAttribs = array();
1136
1137 $msgLink = wfMessage( $line[0] )->inContentLanguage();
1138 if ( $msgLink->exists() ) {
1139 $link = $msgLink->text();
1140 if ( $link == '-' ) {
1141 continue;
1142 }
1143 } else {
1144 $link = $line[0];
1145 }
1146
1147 $msgText = wfMessage( $line[1] );
1148 if ( $msgText->exists() ) {
1149 $text = $msgText->text();
1150 } else {
1151 $text = $line[1];
1152 }
1153
1154 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1155 $href = $link;
1156 //Parser::getExternalLinkAttribs won't work here because of the Namespace things
1157 global $wgNoFollowLinks;
1158 if ( $wgNoFollowLinks ) {
1159 $extraAttribs['rel'] = 'nofollow';
1160
1161 global $wgNoFollowDomainExceptions;
1162 if ( $wgNoFollowDomainExceptions ) {
1163 $bits = wfParseUrl( $url );
1164 if ( is_array( $bits ) && isset( $bits['host'] ) ) {
1165 foreach ( $wgNoFollowDomainExceptions as $domain ) {
1166 if ( substr( $bits['host'], -strlen( $domain ) ) == $domain ) {
1167 unset( $extraAttribs['rel'] );
1168 break;
1169 }
1170 }
1171 }
1172 }
1173 }
1174 global $wgExternalLinkTarget;
1175 if ( $wgExternalLinkTarget) {
1176 $extraAttribs['target'] = $wgExternalLinkTarget;
1177 }
1178 } else {
1179 $title = Title::newFromText( $link );
1180
1181 if ( $title ) {
1182 $title = $title->fixSpecialName();
1183 $href = $title->getLocalURL();
1184 } else {
1185 $href = 'INVALID-TITLE';
1186 }
1187 }
1188
1189 $bar[$heading][] = array_merge( array(
1190 'text' => $text,
1191 'href' => $href,
1192 'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
1193 'active' => false
1194 ), $extraAttribs );
1195 } elseif ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
1196 global $wgParser;
1197
1198 $line = substr( $line, 2, strlen( $line ) - 4 );
1199
1200 $options = new ParserOptions();
1201 $options->setEditSection( false );
1202 $options->setInterfaceMessage( true );
1203 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $this->getTitle(), $options )->getText();
1204 } else {
1205 continue;
1206 }
1207 }
1208 }
1209
1210 if ( count( $wikiBar ) > 0 ) {
1211 $bar = array_merge( $bar, $wikiBar );
1212 }
1213
1214 return $bar;
1215 }
1216
1217 /**
1218 * Should we include common/wikiprintable.css? Skins that have their own
1219 * print stylesheet should override this and return false. (This is an
1220 * ugly hack to get Monobook to play nicely with
1221 * OutputPage::headElement().)
1222 *
1223 * @return bool
1224 */
1225 public function commonPrintStylesheet() {
1226 return true;
1227 }
1228
1229 /**
1230 * Gets new talk page messages for the current user.
1231 * @return MediaWiki message or if no new talk page messages, nothing
1232 */
1233 function getNewtalks() {
1234 $out = $this->getOutput();
1235
1236 $newtalks = $this->getUser()->getNewMessageLinks();
1237 $ntl = '';
1238
1239 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
1240 $userTitle = $this->getUser()->getUserPage();
1241 $userTalkTitle = $userTitle->getTalkPage();
1242
1243 if ( !$userTalkTitle->equals( $out->getTitle() ) ) {
1244 $newMessagesLink = Linker::linkKnown(
1245 $userTalkTitle,
1246 wfMsgHtml( 'newmessageslink' ),
1247 array(),
1248 array( 'redirect' => 'no' )
1249 );
1250
1251 $newMessagesDiffLink = Linker::linkKnown(
1252 $userTalkTitle,
1253 wfMsgHtml( 'newmessagesdifflink' ),
1254 array(),
1255 array( 'diff' => 'cur' )
1256 );
1257
1258 $ntl = wfMsg(
1259 'youhavenewmessages',
1260 $newMessagesLink,
1261 $newMessagesDiffLink
1262 );
1263 # Disable Squid cache
1264 $out->setSquidMaxage( 0 );
1265 }
1266 } elseif ( count( $newtalks ) ) {
1267 // _>" " for BC <= 1.16
1268 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
1269 $msgs = array();
1270
1271 foreach ( $newtalks as $newtalk ) {
1272 $msgs[] = Xml::element(
1273 'a',
1274 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
1275 );
1276 }
1277 $parts = implode( $sep, $msgs );
1278 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
1279 $out->setSquidMaxage( 0 );
1280 }
1281
1282 return $ntl;
1283 }
1284
1285 /**
1286 * Get a cached notice
1287 *
1288 * @param $name String: message name, or 'default' for $wgSiteNotice
1289 * @return String: HTML fragment
1290 */
1291 private function getCachedNotice( $name ) {
1292 global $wgRenderHashAppend, $parserMemc, $wgContLang;
1293
1294 wfProfileIn( __METHOD__ );
1295
1296 $needParse = false;
1297
1298 if( $name === 'default' ) {
1299 // special case
1300 global $wgSiteNotice;
1301 $notice = $wgSiteNotice;
1302 if( empty( $notice ) ) {
1303 wfProfileOut( __METHOD__ );
1304 return false;
1305 }
1306 } else {
1307 $msg = wfMessage( $name )->inContentLanguage();
1308 if( $msg->isDisabled() ) {
1309 wfProfileOut( __METHOD__ );
1310 return false;
1311 }
1312 $notice = $msg->plain();
1313 }
1314
1315 // Use the extra hash appender to let eg SSL variants separately cache.
1316 $key = wfMemcKey( $name . $wgRenderHashAppend );
1317 $cachedNotice = $parserMemc->get( $key );
1318 if( is_array( $cachedNotice ) ) {
1319 if( md5( $notice ) == $cachedNotice['hash'] ) {
1320 $notice = $cachedNotice['html'];
1321 } else {
1322 $needParse = true;
1323 }
1324 } else {
1325 $needParse = true;
1326 }
1327
1328 if ( $needParse ) {
1329 $parsed = $this->getOutput()->parse( $notice );
1330 $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
1331 $notice = $parsed;
1332 }
1333
1334 $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
1335 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), $notice );
1336 wfProfileOut( __METHOD__ );
1337 return $notice;
1338 }
1339
1340 /**
1341 * Get a notice based on page's namespace
1342 *
1343 * @return String: HTML fragment
1344 */
1345 function getNamespaceNotice() {
1346 wfProfileIn( __METHOD__ );
1347
1348 $key = 'namespacenotice-' . $this->getTitle()->getNsText();
1349 $namespaceNotice = $this->getCachedNotice( $key );
1350 if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p>&lt;' ) {
1351 $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
1352 } else {
1353 $namespaceNotice = '';
1354 }
1355
1356 wfProfileOut( __METHOD__ );
1357 return $namespaceNotice;
1358 }
1359
1360 /**
1361 * Get the site notice
1362 *
1363 * @return String: HTML fragment
1364 */
1365 function getSiteNotice() {
1366 wfProfileIn( __METHOD__ );
1367 $siteNotice = '';
1368
1369 if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
1370 if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
1371 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1372 } else {
1373 $anonNotice = $this->getCachedNotice( 'anonnotice' );
1374 if ( !$anonNotice ) {
1375 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1376 } else {
1377 $siteNotice = $anonNotice;
1378 }
1379 }
1380 if ( !$siteNotice ) {
1381 $siteNotice = $this->getCachedNotice( 'default' );
1382 }
1383 }
1384
1385 wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
1386 wfProfileOut( __METHOD__ );
1387 return $siteNotice;
1388 }
1389
1390 /**
1391 * Create a section edit link. This supersedes editSectionLink() and
1392 * editSectionLinkForOther().
1393 *
1394 * @param $nt Title The title being linked to (may not be the same as
1395 * $wgTitle, if the section is included from a template)
1396 * @param $section string The designation of the section being pointed to,
1397 * to be included in the link, like "&section=$section"
1398 * @param $tooltip string The tooltip to use for the link: will be escaped
1399 * and wrapped in the 'editsectionhint' message
1400 * @param $lang string Language code
1401 * @return string HTML to use for edit link
1402 */
1403 public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
1404 // HTML generated here should probably have userlangattributes
1405 // added to it for LTR text on RTL pages
1406 $attribs = array();
1407 if ( !is_null( $tooltip ) ) {
1408 # Bug 25462: undo double-escaping.
1409 $tooltip = Sanitizer::decodeCharReferences( $tooltip );
1410 $attribs['title'] = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag' ), $tooltip );
1411 }
1412 $link = Linker::link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ),
1413 $attribs,
1414 array( 'action' => 'edit', 'section' => $section ),
1415 array( 'noclasses', 'known' )
1416 );
1417
1418 # Run the old hook. This takes up half of the function . . . hopefully
1419 # we can rid of it someday.
1420 $attribs = '';
1421 if ( $tooltip ) {
1422 $attribs = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag', 'escape' ), $tooltip );
1423 $attribs = " title=\"$attribs\"";
1424 }
1425 $result = null;
1426 wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $link, &$result, $lang ) );
1427 if ( !is_null( $result ) ) {
1428 # For reverse compatibility, add the brackets *after* the hook is
1429 # run, and even add them to hook-provided text. (This is the main
1430 # reason that the EditSectionLink hook is deprecated in favor of
1431 # DoEditSectionLink: it can't change the brackets or the span.)
1432 $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $result );
1433 return "<span class=\"editsection\">$result</span>";
1434 }
1435
1436 # Add the brackets and the span, and *then* run the nice new hook, with
1437 # clean and non-redundant arguments.
1438 $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $link );
1439 $result = "<span class=\"editsection\">$result</span>";
1440
1441 wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
1442 return $result;
1443 }
1444
1445 /**
1446 * Use PHP's magic __call handler to intercept legacy calls to the linker
1447 * for backwards compatibility.
1448 *
1449 * @param $fname String Name of called method
1450 * @param $args Array Arguments to the method
1451 */
1452 function __call( $fname, $args ) {
1453 $realFunction = array( 'Linker', $fname );
1454 if ( is_callable( $realFunction ) ) {
1455 return call_user_func_array( $realFunction, $args );
1456 } else {
1457 $className = get_class( $this );
1458 throw new MWException( "Call to undefined method $className::$fname" );
1459 }
1460 }
1461
1462 }