Space out search results just ever so slightly
[mediawiki.git] / includes / Skin.php
blob6722ccabd1b3e954708ebbb9e19237b3aecf842b
1 <?php
2 /**
3 * Base class for all skins.
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.
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.
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
20 * @file
23 /**
24 * @defgroup Skins Skins
27 /**
28 * The main skin class which provides methods and properties for all other skins.
29 * This base class is also the "Standard" skin.
31 * See docs/skin.txt for more information.
33 * @ingroup Skins
35 abstract class Skin extends ContextSource {
36 protected $skinname = 'standard';
37 protected $mRelevantTitle = null;
38 protected $mRelevantUser = null;
40 /**
41 * Fetch the set of available skins.
42 * @return array associative array of strings
44 static function getSkinNames() {
45 global $wgValidSkinNames;
46 static $skinsInitialised = false;
48 if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
49 # Get a list of available skins
50 # Build using the regular expression '^(.*).php$'
51 # Array keys are all lower case, array value keep the case used by filename
53 wfProfileIn( __METHOD__ . '-init' );
55 global $wgStyleDirectory;
57 $skinDir = dir( $wgStyleDirectory );
59 if ( $skinDir !== false && $skinDir !== null ) {
60 # while code from www.php.net
61 while ( false !== ( $file = $skinDir->read() ) ) {
62 // Skip non-PHP files, hidden files, and '.dep' includes
63 $matches = array();
65 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
66 $aSkin = $matches[1];
67 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
70 $skinDir->close();
72 $skinsInitialised = true;
73 wfProfileOut( __METHOD__ . '-init' );
75 return $wgValidSkinNames;
78 /**
79 * Fetch the skinname messages for available skins.
80 * @return array of strings
82 static function getSkinNameMessages() {
83 $messages = array();
84 foreach ( self::getSkinNames() as $skinKey => $skinName ) {
85 // Messages: skinname-cologneblue, skinname-monobook, skinname-modern, skinname-vector
86 $messages[] = "skinname-$skinKey";
88 return $messages;
91 /**
92 * Fetch the list of user-selectable skins in regards to $wgSkipSkins.
93 * Useful for Special:Preferences and other places where you
94 * only want to show skins users _can_ use.
95 * @return array of strings
97 public static function getUsableSkins() {
98 global $wgSkipSkins;
100 $allowedSkins = self::getSkinNames();
102 foreach ( $wgSkipSkins as $skip ) {
103 unset( $allowedSkins[$skip] );
106 return $allowedSkins;
110 * Normalize a skin preference value to a form that can be loaded.
111 * If a skin can't be found, it will fall back to the configured
112 * default (or the old 'Classic' skin if that's broken).
113 * @param string $key 'monobook', 'standard', etc.
114 * @return string
116 static function normalizeKey( $key ) {
117 global $wgDefaultSkin;
119 $skinNames = Skin::getSkinNames();
121 if ( $key == '' || $key == 'default' ) {
122 // Don't return the default immediately;
123 // in a misconfiguration we need to fall back.
124 $key = $wgDefaultSkin;
127 if ( isset( $skinNames[$key] ) ) {
128 return $key;
131 // Older versions of the software used a numeric setting
132 // in the user preferences.
133 $fallback = array(
134 0 => $wgDefaultSkin,
135 2 => 'cologneblue'
138 if ( isset( $fallback[$key] ) ) {
139 $key = $fallback[$key];
142 if ( isset( $skinNames[$key] ) ) {
143 return $key;
144 } elseif ( isset( $skinNames[$wgDefaultSkin] ) ) {
145 return $wgDefaultSkin;
146 } else {
147 return 'vector';
152 * Factory method for loading a skin of a given type
153 * @param string $key 'monobook', 'standard', etc.
154 * @return Skin
156 static function &newFromKey( $key ) {
157 global $wgStyleDirectory;
159 $key = Skin::normalizeKey( $key );
161 $skinNames = Skin::getSkinNames();
162 $skinName = $skinNames[$key];
163 $className = "Skin{$skinName}";
165 # Grab the skin class and initialise it.
166 if ( !class_exists( $className ) ) {
168 require_once "{$wgStyleDirectory}/{$skinName}.php";
170 # Check if we got if not fallback to default skin
171 if ( !class_exists( $className ) ) {
172 # DO NOT die if the class isn't found. This breaks maintenance
173 # scripts and can cause a user account to be unrecoverable
174 # except by SQL manipulation if a previously valid skin name
175 # is no longer valid.
176 wfDebug( "Skin class does not exist: $className\n" );
177 $className = 'SkinVector';
178 require_once "{$wgStyleDirectory}/Vector.php";
181 $skin = new $className( $key );
182 return $skin;
185 /** @return string skin name */
186 public function getSkinName() {
187 return $this->skinname;
191 * @param $out OutputPage
193 function initPage( OutputPage $out ) {
194 wfProfileIn( __METHOD__ );
196 $this->preloadExistence();
198 wfProfileOut( __METHOD__ );
202 * Defines the ResourceLoader modules that should be added to the skin
203 * It is recommended that skins wishing to override call parent::getDefaultModules()
204 * and substitute out any modules they wish to change by using a key to look them up
205 * @return Array of modules with helper keys for easy overriding
207 public function getDefaultModules() {
208 global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
209 $wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
211 $out = $this->getOutput();
212 $user = $out->getUser();
213 $modules = array(
214 // modules that enhance the page content in some way
215 'content' => array(
216 'mediawiki.page.ready',
218 // modules that exist for legacy reasons
219 'legacy' => array(),
220 // modules relating to search functionality
221 'search' => array(),
222 // modules relating to functionality relating to watching an article
223 'watch' => array(),
224 // modules which relate to the current users preferences
225 'user' => array(),
227 if ( $wgIncludeLegacyJavaScript ) {
228 $modules['legacy'][] = 'mediawiki.legacy.wikibits';
231 if ( $wgPreloadJavaScriptMwUtil ) {
232 $modules['legacy'][] = 'mediawiki.util';
235 // Add various resources if required
236 if ( $wgUseAjax ) {
237 $modules['legacy'][] = 'mediawiki.legacy.ajax';
239 if ( $wgEnableAPI ) {
240 if ( $wgEnableWriteAPI && $wgAjaxWatch && $user->isLoggedIn()
241 && $user->isAllowed( 'writeapi' )
243 $modules['watch'][] = 'mediawiki.page.watch.ajax';
246 $modules['search'][] = 'mediawiki.searchSuggest';
250 if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
251 $modules['user'][] = 'mediawiki.action.view.rightClickEdit';
254 // Crazy edit-on-double-click stuff
255 if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) {
256 $modules['user'][] = 'mediawiki.action.view.dblClickEdit';
258 return $modules;
262 * Preload the existence of three commonly-requested pages in a single query
264 function preloadExistence() {
265 $user = $this->getUser();
267 // User/talk link
268 $titles = array( $user->getUserPage(), $user->getTalkPage() );
270 // Other tab link
271 if ( $this->getTitle()->isSpecialPage() ) {
272 // nothing
273 } elseif ( $this->getTitle()->isTalkPage() ) {
274 $titles[] = $this->getTitle()->getSubjectPage();
275 } else {
276 $titles[] = $this->getTitle()->getTalkPage();
279 $lb = new LinkBatch( $titles );
280 $lb->setCaller( __METHOD__ );
281 $lb->execute();
285 * Get the current revision ID
287 * @return Integer
289 public function getRevisionId() {
290 return $this->getOutput()->getRevisionId();
294 * Whether the revision displayed is the latest revision of the page
296 * @return Boolean
298 public function isRevisionCurrent() {
299 $revID = $this->getRevisionId();
300 return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
304 * Set the "relevant" title
305 * @see self::getRelevantTitle()
306 * @param $t Title object to use
308 public function setRelevantTitle( $t ) {
309 $this->mRelevantTitle = $t;
313 * Return the "relevant" title.
314 * A "relevant" title is not necessarily the actual title of the page.
315 * Special pages like Special:MovePage use set the page they are acting on
316 * as their "relevant" title, this allows the skin system to display things
317 * such as content tabs which belong to to that page instead of displaying
318 * a basic special page tab which has almost no meaning.
320 * @return Title
322 public function getRelevantTitle() {
323 if ( isset( $this->mRelevantTitle ) ) {
324 return $this->mRelevantTitle;
326 return $this->getTitle();
330 * Set the "relevant" user
331 * @see self::getRelevantUser()
332 * @param $u User object to use
334 public function setRelevantUser( $u ) {
335 $this->mRelevantUser = $u;
339 * Return the "relevant" user.
340 * A "relevant" user is similar to a relevant title. Special pages like
341 * Special:Contributions mark the user which they are relevant to so that
342 * things like the toolbox can display the information they usually are only
343 * able to display on a user's userpage and talkpage.
344 * @return User
346 public function getRelevantUser() {
347 if ( isset( $this->mRelevantUser ) ) {
348 return $this->mRelevantUser;
350 $title = $this->getRelevantTitle();
351 if ( $title->hasSubjectNamespace( NS_USER ) ) {
352 $rootUser = $title->getRootText();
353 if ( User::isIP( $rootUser ) ) {
354 $this->mRelevantUser = User::newFromName( $rootUser, false );
355 } else {
356 $user = User::newFromName( $rootUser, false );
357 if ( $user && $user->isLoggedIn() ) {
358 $this->mRelevantUser = $user;
361 return $this->mRelevantUser;
363 return null;
367 * Outputs the HTML generated by other functions.
368 * @param $out OutputPage
370 abstract function outputPage( OutputPage $out = null );
373 * @param $data array
374 * @return string
376 static function makeVariablesScript( $data ) {
377 if ( $data ) {
378 return Html::inlineScript(
379 ResourceLoader::makeLoaderConditionalScript( ResourceLoader::makeConfigSetScript( $data ) )
381 } else {
382 return '';
387 * Make a "<script>" tag containing global variables
389 * @deprecated in 1.19
390 * @param $unused
391 * @return string HTML fragment
393 public static function makeGlobalVariablesScript( $unused ) {
394 global $wgOut;
396 wfDeprecated( __METHOD__, '1.19' );
398 return self::makeVariablesScript( $wgOut->getJSVars() );
402 * Get the query to generate a dynamic stylesheet
404 * @return array
406 public static function getDynamicStylesheetQuery() {
407 global $wgSquidMaxage;
409 return array(
410 'action' => 'raw',
411 'maxage' => $wgSquidMaxage,
412 'usemsgcache' => 'yes',
413 'ctype' => 'text/css',
414 'smaxage' => $wgSquidMaxage,
419 * Add skin specific stylesheets
420 * Calling this method with an $out of anything but the same OutputPage
421 * inside ->getOutput() is deprecated. The $out arg is kept
422 * for compatibility purposes with skins.
423 * @param $out OutputPage
424 * @todo delete
426 abstract function setupSkinUserCss( OutputPage $out );
429 * TODO: document
430 * @param $title Title
431 * @return String
433 function getPageClasses( $title ) {
434 $numeric = 'ns-' . $title->getNamespace();
436 if ( $title->isSpecialPage() ) {
437 $type = 'ns-special';
438 // bug 23315: provide a class based on the canonical special page name without subpages
439 list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
440 if ( $canonicalName ) {
441 $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
442 } else {
443 $type .= ' mw-invalidspecialpage';
445 } elseif ( $title->isTalkPage() ) {
446 $type = 'ns-talk';
447 } else {
448 $type = 'ns-subject';
451 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
453 return "$numeric $type $name";
457 * Return values for <html> element
458 * @return array of associative name-to-value elements for <html> element
460 public function getHtmlElementAttributes() {
461 $lang = $this->getLanguage();
462 return array(
463 'lang' => $lang->getHtmlCode(),
464 'dir' => $lang->getDir(),
465 'class' => 'client-nojs',
470 * This will be called by OutputPage::headElement when it is creating the
471 * "<body>" tag, skins can override it if they have a need to add in any
472 * body attributes or classes of their own.
473 * @param $out OutputPage
474 * @param $bodyAttrs Array
476 function addToBodyAttributes( $out, &$bodyAttrs ) {
477 // does nothing by default
481 * URL to the logo
482 * @return String
484 function getLogo() {
485 global $wgLogo;
486 return $wgLogo;
490 * @return string
492 function getCategoryLinks() {
493 global $wgUseCategoryBrowser;
495 $out = $this->getOutput();
496 $allCats = $out->getCategoryLinks();
498 if ( !count( $allCats ) ) {
499 return '';
502 $embed = "<li>";
503 $pop = "</li>";
505 $s = '';
506 $colon = $this->msg( 'colon-separator' )->escaped();
508 if ( !empty( $allCats['normal'] ) ) {
509 $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
511 $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
512 $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
513 $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
514 Linker::link( Title::newFromText( $linkPage ), $msg )
515 . $colon . '<ul>' . $t . '</ul>' . '</div>';
518 # Hidden categories
519 if ( isset( $allCats['hidden'] ) ) {
520 if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
521 $class = ' mw-hidden-cats-user-shown';
522 } elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
523 $class = ' mw-hidden-cats-ns-shown';
524 } else {
525 $class = ' mw-hidden-cats-hidden';
528 $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
529 $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
530 $colon . '<ul>' . $embed . implode( "{$pop}{$embed}", $allCats['hidden'] ) . $pop . '</ul>' .
531 '</div>';
534 # optional 'dmoz-like' category browser. Will be shown under the list
535 # of categories an article belong to
536 if ( $wgUseCategoryBrowser ) {
537 $s .= '<br /><hr />';
539 # get a big array of the parents tree
540 $parenttree = $this->getTitle()->getParentCategoryTree();
541 # Skin object passed by reference cause it can not be
542 # accessed under the method subfunction drawCategoryBrowser
543 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
544 # Clean out bogus first entry and sort them
545 unset( $tempout[0] );
546 asort( $tempout );
547 # Output one per line
548 $s .= implode( "<br />\n", $tempout );
551 return $s;
555 * Render the array as a series of links.
556 * @param array $tree categories tree returned by Title::getParentCategoryTree
557 * @return String separated by &gt;, terminate with "\n"
559 function drawCategoryBrowser( $tree ) {
560 $return = '';
562 foreach ( $tree as $element => $parent ) {
563 if ( empty( $parent ) ) {
564 # element start a new list
565 $return .= "\n";
566 } else {
567 # grab the others elements
568 $return .= $this->drawCategoryBrowser( $parent ) . ' &gt; ';
571 # add our current element to the list
572 $eltitle = Title::newFromText( $element );
573 $return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
576 return $return;
580 * @return string
582 function getCategories() {
583 $out = $this->getOutput();
585 $catlinks = $this->getCategoryLinks();
587 $classes = 'catlinks';
589 // Check what we're showing
590 $allCats = $out->getCategoryLinks();
591 $showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
592 $this->getTitle()->getNamespace() == NS_CATEGORY;
594 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
595 $classes .= ' catlinks-allhidden';
598 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
602 * This runs a hook to allow extensions placing their stuff after content
603 * and article metadata (e.g. categories).
604 * Note: This function has nothing to do with afterContent().
606 * This hook is placed here in order to allow using the same hook for all
607 * skins, both the SkinTemplate based ones and the older ones, which directly
608 * use this class to get their data.
610 * The output of this function gets processed in SkinTemplate::outputPage() for
611 * the SkinTemplate based skins, all other skins should directly echo it.
613 * @return String, empty by default, if not changed by any hook function.
615 protected function afterContentHook() {
616 $data = '';
618 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
619 // adding just some spaces shouldn't toggle the output
620 // of the whole <div/>, so we use trim() here
621 if ( trim( $data ) != '' ) {
622 // Doing this here instead of in the skins to
623 // ensure that the div has the same ID in all
624 // skins
625 $data = "<div id='mw-data-after-content'>\n" .
626 "\t$data\n" .
627 "</div>\n";
629 } else {
630 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
633 return $data;
637 * Generate debug data HTML for displaying at the bottom of the main content
638 * area.
639 * @return String HTML containing debug data, if enabled (otherwise empty).
641 protected function generateDebugHTML() {
642 return MWDebug::getHTMLDebugLog();
646 * This gets called shortly before the "</body>" tag.
648 * @return String HTML-wrapped JS code to be put before "</body>"
650 function bottomScripts() {
651 // TODO and the suckage continues. This function is really just a wrapper around
652 // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
653 // up at some point
654 $bottomScriptText = $this->getOutput()->getBottomScripts();
655 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
657 return $bottomScriptText;
661 * Text with the permalink to the source page,
662 * usually shown on the footer of a printed page
664 * @return string HTML text with an URL
666 function printSource() {
667 $oldid = $this->getRevisionId();
668 if ( $oldid ) {
669 $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) ) );
670 } else {
671 // oldid not available for non existing pages
672 $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
674 return $this->msg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' )->text();
678 * @return String
680 function getUndeleteLink() {
681 $action = $this->getRequest()->getVal( 'action', 'view' );
683 if ( $this->getUser()->isAllowed( 'deletedhistory' ) &&
684 ( $this->getTitle()->getArticleID() == 0 || $action == 'history' ) ) {
685 $n = $this->getTitle()->isDeleted();
687 if ( $n ) {
688 if ( $this->getUser()->isAllowed( 'undelete' ) ) {
689 $msg = 'thisisdeleted';
690 } else {
691 $msg = 'viewdeleted';
694 return $this->msg( $msg )->rawParams(
695 Linker::linkKnown(
696 SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
697 $this->msg( 'restorelink' )->numParams( $n )->escaped() )
698 )->text();
702 return '';
706 * @return string
708 function subPageSubtitle() {
709 global $wgLang;
710 $out = $this->getOutput();
711 $subpages = '';
713 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
714 return $subpages;
717 if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) {
718 $ptext = $this->getTitle()->getPrefixedText();
719 if ( preg_match( '/\//', $ptext ) ) {
720 $links = explode( '/', $ptext );
721 array_pop( $links );
722 $c = 0;
723 $growinglink = '';
724 $display = '';
726 foreach ( $links as $link ) {
727 $growinglink .= $link;
728 $display .= $link;
729 $linkObj = Title::newFromText( $growinglink );
731 if ( is_object( $linkObj ) && $linkObj->isKnown() ) {
732 $getlink = Linker::linkKnown(
733 $linkObj,
734 htmlspecialchars( $display )
737 $c++;
739 if ( $c > 1 ) {
740 $subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
741 } else {
742 $subpages .= '&lt; ';
745 $subpages .= $getlink;
746 $display = '';
747 } else {
748 $display .= '/';
750 $growinglink .= '/';
755 return $subpages;
759 * Returns true if the IP should be shown in the header
760 * @return Bool
762 function showIPinHeader() {
763 global $wgShowIPinHeader;
764 return $wgShowIPinHeader && session_id() != '';
768 * @return String
770 function getSearchLink() {
771 $searchPage = SpecialPage::getTitleFor( 'Search' );
772 return $searchPage->getLocalURL();
776 * @return string
778 function escapeSearchLink() {
779 return htmlspecialchars( $this->getSearchLink() );
783 * @param $type string
784 * @return string
786 function getCopyright( $type = 'detect' ) {
787 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
789 if ( $type == 'detect' ) {
790 if ( !$this->isRevisionCurrent() && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled() ) {
791 $type = 'history';
792 } else {
793 $type = 'normal';
797 if ( $type == 'history' ) {
798 $msg = 'history_copyright';
799 } else {
800 $msg = 'copyright';
803 if ( $wgRightsPage ) {
804 $title = Title::newFromText( $wgRightsPage );
805 $link = Linker::linkKnown( $title, $wgRightsText );
806 } elseif ( $wgRightsUrl ) {
807 $link = Linker::makeExternalLink( $wgRightsUrl, $wgRightsText );
808 } elseif ( $wgRightsText ) {
809 $link = $wgRightsText;
810 } else {
811 # Give up now
812 return '';
815 // Allow for site and per-namespace customization of copyright notice.
816 $forContent = true;
818 wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
820 $msgObj = $this->msg( $msg )->rawParams( $link );
821 if ( $forContent ) {
822 $msg = $msgObj->inContentLanguage()->text();
823 if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
824 $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $msg );
826 return $msg;
827 } else {
828 return $msgObj->text();
833 * @return null|string
835 function getCopyrightIcon() {
836 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
838 $out = '';
840 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
841 $out = $wgCopyrightIcon;
842 } elseif ( $wgRightsIcon ) {
843 $icon = htmlspecialchars( $wgRightsIcon );
845 if ( $wgRightsUrl ) {
846 $url = htmlspecialchars( $wgRightsUrl );
847 $out .= '<a href="' . $url . '">';
850 $text = htmlspecialchars( $wgRightsText );
851 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
853 if ( $wgRightsUrl ) {
854 $out .= '</a>';
858 return $out;
862 * Gets the powered by MediaWiki icon.
863 * @return string
865 function getPoweredBy() {
866 global $wgStylePath;
868 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
869 $text = '<a href="//www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
870 wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
871 return $text;
875 * Get the timestamp of the latest revision, formatted in user language
877 * @return String
879 protected function lastModified() {
880 $timestamp = $this->getOutput()->getRevisionTimestamp();
882 # No cached timestamp, load it from the database
883 if ( $timestamp === null ) {
884 $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
887 if ( $timestamp ) {
888 $d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
889 $t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
890 $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->text();
891 } else {
892 $s = '';
895 if ( wfGetLB()->getLaggedSlaveMode() ) {
896 $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->text() . '</strong>';
899 return $s;
903 * @param $align string
904 * @return string
906 function logoText( $align = '' ) {
907 if ( $align != '' ) {
908 $a = " style='float: {$align};'";
909 } else {
910 $a = '';
913 $mp = $this->msg( 'mainpage' )->escaped();
914 $mptitle = Title::newMainPage();
915 $url = ( is_object( $mptitle ) ? htmlspecialchars( $mptitle->getLocalURL() ) : '' );
917 $logourl = $this->getLogo();
918 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
920 return $s;
924 * Renders a $wgFooterIcons icon according to the method's arguments
925 * @param array $icon The icon to build the html for, see $wgFooterIcons for the format of this array
926 * @param bool|String $withImage Whether to use the icon's image or output a text-only footericon
927 * @return String HTML
929 function makeFooterIcon( $icon, $withImage = 'withImage' ) {
930 if ( is_string( $icon ) ) {
931 $html = $icon;
932 } else { // Assuming array
933 $url = isset( $icon["url"] ) ? $icon["url"] : null;
934 unset( $icon["url"] );
935 if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
936 $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
937 } else {
938 $html = htmlspecialchars( $icon["alt"] );
940 if ( $url ) {
941 $html = Html::rawElement( 'a', array( "href" => $url ), $html );
944 return $html;
948 * Gets the link to the wiki's main page.
949 * @return string
951 function mainPageLink() {
952 $s = Linker::linkKnown(
953 Title::newMainPage(),
954 $this->msg( 'mainpage' )->escaped()
957 return $s;
961 * @param $desc
962 * @param $page
963 * @return string
965 public function footerLink( $desc, $page ) {
966 // if the link description has been set to "-" in the default language,
967 if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
968 // then it is disabled, for all languages.
969 return '';
970 } else {
971 // Otherwise, we display the link for the user, described in their
972 // language (which may or may not be the same as the default language),
973 // but we make the link target be the one site-wide page.
974 $title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
976 return Linker::linkKnown(
977 $title,
978 $this->msg( $desc )->escaped()
984 * Gets the link to the wiki's privacy policy page.
985 * @return String HTML
987 function privacyLink() {
988 return $this->footerLink( 'privacy', 'privacypage' );
992 * Gets the link to the wiki's about page.
993 * @return String HTML
995 function aboutLink() {
996 return $this->footerLink( 'aboutsite', 'aboutpage' );
1000 * Gets the link to the wiki's general disclaimers page.
1001 * @return String HTML
1003 function disclaimerLink() {
1004 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1008 * Return URL options for the 'edit page' link.
1009 * This may include an 'oldid' specifier, if the current page view is such.
1011 * @return array
1012 * @private
1014 function editUrlOptions() {
1015 $options = array( 'action' => 'edit' );
1017 if ( !$this->isRevisionCurrent() ) {
1018 $options['oldid'] = intval( $this->getRevisionId() );
1021 return $options;
1025 * @param $id User|int
1026 * @return bool
1028 function showEmailUser( $id ) {
1029 if ( $id instanceof User ) {
1030 $targetUser = $id;
1031 } else {
1032 $targetUser = User::newFromId( $id );
1034 return $this->getUser()->canSendEmail() && # the sending user must have a confirmed email address
1035 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1039 * Return a fully resolved style path url to images or styles stored in the common folder.
1040 * This method returns a url resolved using the configured skin style path
1041 * and includes the style version inside of the url.
1042 * @param string $name The name or path of a skin resource file
1043 * @return String The fully resolved style path url including styleversion
1045 function getCommonStylePath( $name ) {
1046 global $wgStylePath, $wgStyleVersion;
1047 return "$wgStylePath/common/$name?$wgStyleVersion";
1051 * Return a fully resolved style path url to images or styles stored in the current skins's folder.
1052 * This method returns a url resolved using the configured skin style path
1053 * and includes the style version inside of the url.
1054 * @param string $name The name or path of a skin resource file
1055 * @return String The fully resolved style path url including styleversion
1057 function getSkinStylePath( $name ) {
1058 global $wgStylePath, $wgStyleVersion;
1059 return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
1062 /* these are used extensively in SkinTemplate, but also some other places */
1065 * @param $urlaction string
1066 * @return String
1068 static function makeMainPageUrl( $urlaction = '' ) {
1069 $title = Title::newMainPage();
1070 self::checkTitle( $title, '' );
1072 return $title->getLocalURL( $urlaction );
1076 * Make a URL for a Special Page using the given query and protocol.
1078 * If $proto is set to null, make a local URL. Otherwise, make a full
1079 * URL with the protocol specified.
1081 * @param string $name Name of the Special page
1082 * @param string $urlaction Query to append
1083 * @param $proto Protocol to use or null for a local URL
1084 * @return String
1086 static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
1087 $title = SpecialPage::getSafeTitleFor( $name );
1088 if ( is_null( $proto ) ) {
1089 return $title->getLocalURL( $urlaction );
1090 } else {
1091 return $title->getFullURL( $urlaction, false, $proto );
1096 * @param $name string
1097 * @param $subpage string
1098 * @param $urlaction string
1099 * @return String
1101 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1102 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
1103 return $title->getLocalURL( $urlaction );
1107 * @param $name string
1108 * @param $urlaction string
1109 * @return String
1111 static function makeI18nUrl( $name, $urlaction = '' ) {
1112 $title = Title::newFromText( wfMessage( $name )->inContentLanguage()->text() );
1113 self::checkTitle( $title, $name );
1114 return $title->getLocalURL( $urlaction );
1118 * @param $name string
1119 * @param $urlaction string
1120 * @return String
1122 static function makeUrl( $name, $urlaction = '' ) {
1123 $title = Title::newFromText( $name );
1124 self::checkTitle( $title, $name );
1126 return $title->getLocalURL( $urlaction );
1130 * If url string starts with http, consider as external URL, else
1131 * internal
1132 * @param $name String
1133 * @return String URL
1135 static function makeInternalOrExternalUrl( $name ) {
1136 if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
1137 return $name;
1138 } else {
1139 return self::makeUrl( $name );
1144 * this can be passed the NS number as defined in Language.php
1145 * @param $name
1146 * @param $urlaction string
1147 * @param $namespace int
1148 * @return String
1150 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
1151 $title = Title::makeTitleSafe( $namespace, $name );
1152 self::checkTitle( $title, $name );
1154 return $title->getLocalURL( $urlaction );
1158 * these return an array with the 'href' and boolean 'exists'
1159 * @param $name
1160 * @param $urlaction string
1161 * @return array
1163 static function makeUrlDetails( $name, $urlaction = '' ) {
1164 $title = Title::newFromText( $name );
1165 self::checkTitle( $title, $name );
1167 return array(
1168 'href' => $title->getLocalURL( $urlaction ),
1169 'exists' => $title->getArticleID() != 0,
1174 * Make URL details where the article exists (or at least it's convenient to think so)
1175 * @param string $name Article name
1176 * @param $urlaction String
1177 * @return Array
1179 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1180 $title = Title::newFromText( $name );
1181 self::checkTitle( $title, $name );
1183 return array(
1184 'href' => $title->getLocalURL( $urlaction ),
1185 'exists' => true
1190 * make sure we have some title to operate on
1192 * @param $title Title
1193 * @param $name string
1195 static function checkTitle( &$title, $name ) {
1196 if ( !is_object( $title ) ) {
1197 $title = Title::newFromText( $name );
1198 if ( !is_object( $title ) ) {
1199 $title = Title::newFromText( '--error: link target missing--' );
1205 * Build an array that represents the sidebar(s), the navigation bar among them.
1207 * BaseTemplate::getSidebar can be used to simplify the format and id generation in new skins.
1209 * The format of the returned array is array( heading => content, ... ), where:
1210 * - heading is the heading of a navigation portlet. It is either:
1211 * - magic string to be handled by the skins ('SEARCH' / 'LANGUAGES' / 'TOOLBOX' / ...)
1212 * - a message name (e.g. 'navigation'), the message should be HTML-escaped by the skin
1213 * - plain text, which should be HTML-escaped by the skin
1214 * - content is the contents of the portlet. It is either:
1215 * - HTML text (<ul><li>...</li>...</ul>)
1216 * - array of link data in a format accepted by BaseTemplate::makeListItem()
1217 * - (for a magic string as a key, any value)
1219 * Note that extensions can control the sidebar contents using the SkinBuildSidebar hook
1220 * and can technically insert anything in here; skin creators are expected to handle
1221 * values described above.
1223 * @return array
1225 function buildSidebar() {
1226 global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1227 wfProfileIn( __METHOD__ );
1229 $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
1231 if ( $wgEnableSidebarCache ) {
1232 $cachedsidebar = $wgMemc->get( $key );
1233 if ( $cachedsidebar ) {
1234 wfProfileOut( __METHOD__ );
1235 return $cachedsidebar;
1239 $bar = array();
1240 $this->addToSidebar( $bar, 'sidebar' );
1242 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
1243 if ( $wgEnableSidebarCache ) {
1244 $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1247 wfProfileOut( __METHOD__ );
1248 return $bar;
1251 * Add content from a sidebar system message
1252 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
1254 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
1256 * @param $bar array
1257 * @param $message String
1259 function addToSidebar( &$bar, $message ) {
1260 $this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
1264 * Add content from plain text
1265 * @since 1.17
1266 * @param $bar array
1267 * @param $text string
1268 * @return Array
1270 function addToSidebarPlain( &$bar, $text ) {
1271 $lines = explode( "\n", $text );
1273 $heading = '';
1275 foreach ( $lines as $line ) {
1276 if ( strpos( $line, '*' ) !== 0 ) {
1277 continue;
1279 $line = rtrim( $line, "\r" ); // for Windows compat
1281 if ( strpos( $line, '**' ) !== 0 ) {
1282 $heading = trim( $line, '* ' );
1283 if ( !array_key_exists( $heading, $bar ) ) {
1284 $bar[$heading] = array();
1286 } else {
1287 $line = trim( $line, '* ' );
1289 if ( strpos( $line, '|' ) !== false ) { // sanity check
1290 $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
1291 $line = array_map( 'trim', explode( '|', $line, 2 ) );
1292 if ( count( $line ) !== 2 ) {
1293 // Second sanity check, could be hit by people doing
1294 // funky stuff with parserfuncs... (bug 33321)
1295 continue;
1298 $extraAttribs = array();
1300 $msgLink = $this->msg( $line[0] )->inContentLanguage();
1301 if ( $msgLink->exists() ) {
1302 $link = $msgLink->text();
1303 if ( $link == '-' ) {
1304 continue;
1306 } else {
1307 $link = $line[0];
1309 $msgText = $this->msg( $line[1] );
1310 if ( $msgText->exists() ) {
1311 $text = $msgText->text();
1312 } else {
1313 $text = $line[1];
1316 if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $link ) ) {
1317 $href = $link;
1319 // Parser::getExternalLinkAttribs won't work here because of the Namespace things
1320 global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
1321 if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) {
1322 $extraAttribs['rel'] = 'nofollow';
1325 global $wgExternalLinkTarget;
1326 if ( $wgExternalLinkTarget ) {
1327 $extraAttribs['target'] = $wgExternalLinkTarget;
1329 } else {
1330 $title = Title::newFromText( $link );
1332 if ( $title ) {
1333 $title = $title->fixSpecialName();
1334 $href = $title->getLinkURL();
1335 } else {
1336 $href = 'INVALID-TITLE';
1340 $bar[$heading][] = array_merge( array(
1341 'text' => $text,
1342 'href' => $href,
1343 'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
1344 'active' => false
1345 ), $extraAttribs );
1346 } else {
1347 continue;
1352 return $bar;
1356 * This function previously controlled whether the 'mediawiki.legacy.wikiprintable' module
1357 * should be loaded by OutputPage. That module no longer exists and the return value of this
1358 * method is ignored.
1360 * If your skin doesn't provide its own print styles, the 'mediawiki.legacy.commonPrint' module
1361 * can be used instead (SkinTemplate-based skins do it automatically).
1363 * @deprecated since 1.22
1364 * @return bool
1366 public function commonPrintStylesheet() {
1367 wfDeprecated( __METHOD__, '1.22' );
1368 return false;
1372 * Gets new talk page messages for the current user and returns an
1373 * appropriate alert message (or an empty string if there are no messages)
1374 * @return String
1376 function getNewtalks() {
1378 $newMessagesAlert = '';
1379 $user = $this->getUser();
1380 $newtalks = $user->getNewMessageLinks();
1381 $out = $this->getOutput();
1383 // Allow extensions to disable or modify the new messages alert
1384 if ( !wfRunHooks( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
1385 return '';
1387 if ( $newMessagesAlert ) {
1388 return $newMessagesAlert;
1391 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
1392 $uTalkTitle = $user->getTalkPage();
1393 $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
1394 $nofAuthors = 0;
1395 if ( $lastSeenRev !== null ) {
1396 $plural = true; // Default if we have a last seen revision: if unknown, use plural
1397 $latestRev = Revision::newFromTitle( $uTalkTitle, false, Revision::READ_NORMAL );
1398 if ( $latestRev !== null ) {
1399 // Singular if only 1 unseen revision, plural if several unseen revisions.
1400 $plural = $latestRev->getParentId() !== $lastSeenRev->getId();
1401 $nofAuthors = $uTalkTitle->countAuthorsBetween(
1402 $lastSeenRev, $latestRev, 10, 'include_new' );
1404 } else {
1405 // Singular if no revision -> diff link will show latest change only in any case
1406 $plural = false;
1408 $plural = $plural ? 999 : 1;
1409 // 999 signifies "more than one revision". We don't know how many, and even if we did,
1410 // the number of revisions or authors is not necessarily the same as the number of
1411 // "messages".
1412 $newMessagesLink = Linker::linkKnown(
1413 $uTalkTitle,
1414 $this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
1415 array(),
1416 array( 'redirect' => 'no' )
1419 $newMessagesDiffLink = Linker::linkKnown(
1420 $uTalkTitle,
1421 $this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
1422 array(),
1423 $lastSeenRev !== null
1424 ? array( 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' )
1425 : array( 'diff' => 'cur' )
1428 if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
1429 $newMessagesAlert = $this->msg(
1430 'youhavenewmessagesfromusers',
1431 $newMessagesLink,
1432 $newMessagesDiffLink
1433 )->numParams( $nofAuthors, $plural );
1434 } else {
1435 // $nofAuthors === 11 signifies "11 or more" ("more than 10")
1436 $newMessagesAlert = $this->msg(
1437 $nofAuthors > 10 ? 'youhavenewmessagesmanyusers' : 'youhavenewmessages',
1438 $newMessagesLink,
1439 $newMessagesDiffLink
1440 )->numParams( $plural );
1442 $newMessagesAlert = $newMessagesAlert->text();
1443 # Disable Squid cache
1444 $out->setSquidMaxage( 0 );
1445 } elseif ( count( $newtalks ) ) {
1446 $sep = $this->msg( 'newtalkseparator' )->escaped();
1447 $msgs = array();
1449 foreach ( $newtalks as $newtalk ) {
1450 $msgs[] = Xml::element(
1451 'a',
1452 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
1455 $parts = implode( $sep, $msgs );
1456 $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
1457 $out->setSquidMaxage( 0 );
1460 return $newMessagesAlert;
1464 * Get a cached notice
1466 * @param string $name message name, or 'default' for $wgSiteNotice
1467 * @return String: HTML fragment
1469 private function getCachedNotice( $name ) {
1470 global $wgRenderHashAppend, $parserMemc, $wgContLang;
1472 wfProfileIn( __METHOD__ );
1474 $needParse = false;
1476 if ( $name === 'default' ) {
1477 // special case
1478 global $wgSiteNotice;
1479 $notice = $wgSiteNotice;
1480 if ( empty( $notice ) ) {
1481 wfProfileOut( __METHOD__ );
1482 return false;
1484 } else {
1485 $msg = $this->msg( $name )->inContentLanguage();
1486 if ( $msg->isDisabled() ) {
1487 wfProfileOut( __METHOD__ );
1488 return false;
1490 $notice = $msg->plain();
1493 // Use the extra hash appender to let eg SSL variants separately cache.
1494 $key = wfMemcKey( $name . $wgRenderHashAppend );
1495 $cachedNotice = $parserMemc->get( $key );
1496 if ( is_array( $cachedNotice ) ) {
1497 if ( md5( $notice ) == $cachedNotice['hash'] ) {
1498 $notice = $cachedNotice['html'];
1499 } else {
1500 $needParse = true;
1502 } else {
1503 $needParse = true;
1506 if ( $needParse ) {
1507 $parsed = $this->getOutput()->parse( $notice );
1508 $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
1509 $notice = $parsed;
1512 $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
1513 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
1514 wfProfileOut( __METHOD__ );
1515 return $notice;
1519 * Get a notice based on page's namespace
1521 * @return String: HTML fragment
1523 function getNamespaceNotice() {
1524 wfProfileIn( __METHOD__ );
1526 $key = 'namespacenotice-' . $this->getTitle()->getNsText();
1527 $namespaceNotice = $this->getCachedNotice( $key );
1528 if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p>&lt;' ) {
1529 $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
1530 } else {
1531 $namespaceNotice = '';
1534 wfProfileOut( __METHOD__ );
1535 return $namespaceNotice;
1539 * Get the site notice
1541 * @return String: HTML fragment
1543 function getSiteNotice() {
1544 wfProfileIn( __METHOD__ );
1545 $siteNotice = '';
1547 if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
1548 if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
1549 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1550 } else {
1551 $anonNotice = $this->getCachedNotice( 'anonnotice' );
1552 if ( !$anonNotice ) {
1553 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1554 } else {
1555 $siteNotice = $anonNotice;
1558 if ( !$siteNotice ) {
1559 $siteNotice = $this->getCachedNotice( 'default' );
1563 wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
1564 wfProfileOut( __METHOD__ );
1565 return $siteNotice;
1569 * Create a section edit link. This supersedes editSectionLink() and
1570 * editSectionLinkForOther().
1572 * @param $nt Title The title being linked to (may not be the same as
1573 * the current page, if the section is included from a template)
1574 * @param string $section The designation of the section being pointed to,
1575 * to be included in the link, like "&section=$section"
1576 * @param string $tooltip The tooltip to use for the link: will be escaped
1577 * and wrapped in the 'editsectionhint' message
1578 * @param $lang string Language code
1579 * @return string HTML to use for edit link
1581 public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
1582 // HTML generated here should probably have userlangattributes
1583 // added to it for LTR text on RTL pages
1585 $lang = wfGetLangObj( $lang );
1587 $attribs = array();
1588 if ( !is_null( $tooltip ) ) {
1589 # Bug 25462: undo double-escaping.
1590 $tooltip = Sanitizer::decodeCharReferences( $tooltip );
1591 $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
1592 ->inLanguage( $lang )->text();
1594 $link = Linker::link( $nt, wfMessage( 'editsection' )->inLanguage( $lang )->text(),
1595 $attribs,
1596 array( 'action' => 'edit', 'section' => $section ),
1597 array( 'noclasses', 'known' )
1600 # Add the brackets and the span and run the hook.
1601 $result = '<span class="mw-editsection">'
1602 . '<span class="mw-editsection-bracket">[</span>'
1603 . $link
1604 . '<span class="mw-editsection-bracket">]</span>'
1605 . '</span>';
1607 wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
1608 return $result;
1612 * Use PHP's magic __call handler to intercept legacy calls to the linker
1613 * for backwards compatibility.
1615 * @param string $fname Name of called method
1616 * @param array $args Arguments to the method
1617 * @throws MWException
1618 * @return mixed
1620 function __call( $fname, $args ) {
1621 $realFunction = array( 'Linker', $fname );
1622 if ( is_callable( $realFunction ) ) {
1623 wfDeprecated( get_class( $this ) . '::' . $fname, '1.21' );
1624 return call_user_func_array( $realFunction, $args );
1625 } else {
1626 $className = get_class( $this );
1627 throw new MWException( "Call to undefined method $className::$fname" );