3 * @defgroup Skins Skins
6 if ( !defined( 'MEDIAWIKI' ) ) {
11 * The main skin class that provide methods and properties for all other skins.
12 * This base class is also the "Standard" skin.
14 * See docs/skin.txt for more information.
18 class Skin
extends Linker
{
22 var $mWatchLinkNum = 0; // Appended to end of watch link id's
23 // How many search boxes have we made? Avoid duplicate id's.
24 protected $searchboxes = '';
26 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
27 protected $skinname = 'standard';
28 // @todo Fixme: should be protected :-\
31 /** Constructor, call parent constructor */
32 function __construct() {
33 parent
::__construct();
37 * Fetch the set of available skins.
38 * @return array of strings
40 static function getSkinNames() {
41 global $wgValidSkinNames;
42 static $skinsInitialised = false;
44 if ( !$skinsInitialised ) {
45 # Get a list of available skins
46 # Build using the regular expression '^(.*).php$'
47 # Array keys are all lower case, array value keep the case used by filename
49 wfProfileIn( __METHOD__
. '-init' );
51 global $wgStyleDirectory;
53 $skinDir = dir( $wgStyleDirectory );
55 # while code from www.php.net
56 while ( false !== ( $file = $skinDir->read() ) ) {
57 // Skip non-PHP files, hidden files, and '.dep' includes
60 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
62 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
66 $skinsInitialised = true;
67 wfProfileOut( __METHOD__
. '-init' );
69 return $wgValidSkinNames;
73 * Fetch the list of usable skins in regards to $wgSkipSkins.
74 * Useful for Special:Preferences and other places where you
75 * only want to show skins users _can_ use.
76 * @return array of strings
78 public static function getUsableSkins() {
81 $usableSkins = self
::getSkinNames();
83 foreach ( $wgSkipSkins as $skip ) {
84 unset( $usableSkins[$skip] );
91 * Normalize a skin preference value to a form that can be loaded.
92 * If a skin can't be found, it will fall back to the configured
93 * default (or the old 'Classic' skin if that's broken).
94 * @param $key String: 'monobook', 'standard', etc.
97 static function normalizeKey( $key ) {
98 global $wgDefaultSkin;
100 $skinNames = Skin
::getSkinNames();
103 // Don't return the default immediately;
104 // in a misconfiguration we need to fall back.
105 $key = $wgDefaultSkin;
108 if ( isset( $skinNames[$key] ) ) {
112 // Older versions of the software used a numeric setting
113 // in the user preferences.
120 if ( isset( $fallback[$key] ) ) {
121 $key = $fallback[$key];
124 if ( isset( $skinNames[$key] ) ) {
126 } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
127 return $wgDefaultSkin;
134 * Factory method for loading a skin of a given type
135 * @param $key String: 'monobook', 'standard', etc.
138 static function &newFromKey( $key ) {
139 global $wgStyleDirectory;
141 $key = Skin
::normalizeKey( $key );
143 $skinNames = Skin
::getSkinNames();
144 $skinName = $skinNames[$key];
145 $className = 'Skin' . ucfirst( $key );
147 # Grab the skin class and initialise it.
148 if ( !class_exists( $className ) ) {
149 // Preload base classes to work around APC/PHP5 bug
150 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
152 if ( file_exists( $deps ) ) {
153 include_once( $deps );
155 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
157 # Check if we got if not failback to default skin
158 if ( !class_exists( $className ) ) {
159 # DO NOT die if the class isn't found. This breaks maintenance
160 # scripts and can cause a user account to be unrecoverable
161 # except by SQL manipulation if a previously valid skin name
162 # is no longer valid.
163 wfDebug( "Skin class does not exist: $className\n" );
164 $className = 'SkinVector';
165 require_once( "{$wgStyleDirectory}/Vector.php" );
168 $skin = new $className;
172 /** @return string path to the skin stylesheet */
173 function getStylesheet() {
174 return 'common/wikistandard.css';
177 /** @return string skin name */
178 public function getSkinName() {
179 return $this->skinname
;
182 function qbSetting() {
183 global $wgOut, $wgUser;
185 if ( $wgOut->isQuickbarSuppressed() ) {
189 $q = $wgUser->getOption( 'quickbar', 0 );
194 function initPage( OutputPage
$out ) {
195 global $wgFavicon, $wgAppleTouchIcon;
197 wfProfileIn( __METHOD__
);
199 # Generally the order of the favicon and apple-touch-icon links
200 # should not matter, but Konqueror (3.5.9 at least) incorrectly
201 # uses whichever one appears later in the HTML source. Make sure
202 # apple-touch-icon is specified first to avoid this.
203 if ( false !== $wgAppleTouchIcon ) {
204 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
207 if ( false !== $wgFavicon ) {
208 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
211 # OpenSearch description link
212 $out->addLink( array(
214 'type' => 'application/opensearchdescription+xml',
215 'href' => wfScript( 'opensearch_desc' ),
216 'title' => wfMsgForContent( 'opensearch-desc' ),
219 $this->addMetadataLinks( $out );
221 $this->mRevisionId
= $out->mRevisionId
;
223 $this->preloadExistence();
225 wfProfileOut( __METHOD__
);
229 * Preload the existence of three commonly-requested pages in a single query
231 function preloadExistence() {
235 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
238 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
240 } elseif ( $this->mTitle
->isTalkPage() ) {
241 $titles[] = $this->mTitle
->getSubjectPage();
243 $titles[] = $this->mTitle
->getTalkPage();
246 $lb = new LinkBatch( $titles );
247 $lb->setCaller( __METHOD__
);
252 * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
254 * @param $out Object: instance of OutputPage
256 function addMetadataLinks( OutputPage
$out ) {
257 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
258 global $wgRightsPage, $wgRightsUrl;
260 if ( $out->isArticleRelated() ) {
261 # note: buggy CC software only reads first "meta" link
262 if ( $wgEnableCreativeCommonsRdf ) {
263 $out->addMetadataLink( array(
264 'title' => 'Creative Commons',
265 'type' => 'application/rdf+xml',
266 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
270 if ( $wgEnableDublinCoreRdf ) {
271 $out->addMetadataLink( array(
272 'title' => 'Dublin Core',
273 'type' => 'application/rdf+xml',
274 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
279 if ( $wgRightsPage ) {
280 $copy = Title
::newFromText( $wgRightsPage );
283 $copyright = $copy->getLocalURL();
287 if ( !$copyright && $wgRightsUrl ) {
288 $copyright = $wgRightsUrl;
292 $out->addLink( array(
293 'rel' => 'copyright',
294 'href' => $copyright )
300 * Set some local variables
302 protected function setMembers() {
304 $this->mUser
= $wgUser;
305 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
306 $this->usercss
= false;
311 * @param $t Title object to use
313 public function setTitle( $t ) {
318 public function getTitle() {
319 return $this->mTitle
;
323 * Outputs the HTML generated by other functions.
324 * @param $out Object: instance of OutputPage
326 function outputPage( OutputPage
$out ) {
327 global $wgDebugComments;
328 wfProfileIn( __METHOD__
);
331 $this->initPage( $out );
333 // See self::afterContentHook() for documentation
334 $afterContent = $this->afterContentHook();
336 $out->out( $out->headElement( $this ) );
338 if ( $wgDebugComments ) {
339 $out->out( "<!-- Wiki debugging output:\n" .
340 $out->mDebugtext
. "-->\n" );
343 $out->out( $this->beforeContent() );
345 $out->out( $out->mBodytext
. "\n" );
347 $out->out( $this->afterContent() );
349 $out->out( $afterContent );
351 $out->out( $this->bottomScripts( $out ) );
353 $out->out( wfReportTime() );
355 $out->out( "\n</body></html>" );
356 wfProfileOut( __METHOD__
);
359 static function makeVariablesScript( $data ) {
361 return Html
::inlineScript( 'mediaWiki.config.set(' . FormatJson
::encode( $data ) . ');' );
368 * Make a <script> tag containing global variables
369 * @param $skinName string Name of the skin
370 * The odd calling convention is for backwards compatibility
371 * @todo FIXME: Make this not depend on $wgTitle!
373 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
374 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
376 static function makeGlobalVariablesScript( $skinName ) {
377 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
379 $ns = $wgTitle->getNamespace();
380 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
382 'wgCanonicalNamespace' => $nsname,
383 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
384 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
385 'wgNamespaceNumber' => $wgTitle->getNamespace(),
386 'wgPageName' => $wgTitle->getPrefixedDBKey(),
387 'wgTitle' => $wgTitle->getText(),
388 'wgAction' => $wgRequest->getText( 'action', 'view' ),
389 'wgArticleId' => $wgTitle->getArticleId(),
390 'wgIsArticle' => $wgOut->isArticle(),
391 'wgUserName' => $wgUser->isAnon() ?
null : $wgUser->getName(),
392 'wgUserGroups' => $wgUser->getEffectiveGroups(),
393 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
394 'wgCategories' => $wgOut->getCategories(),
396 foreach ( $wgRestrictionTypes as $type ) {
397 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
399 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
400 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
403 // Allow extensions to add their custom variables to the global JS variables
404 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
406 return self
::makeVariablesScript( $vars );
410 * To make it harder for someone to slip a user a fake
411 * user-JavaScript or user-CSS preview, a random token
412 * is associated with the login session. If it's not
413 * passed back with the preview request, we won't render
416 * @param $action String: 'edit', 'submit' etc.
419 public function userCanPreview( $action ) {
420 global $wgRequest, $wgUser;
422 if ( $action != 'submit' ) {
425 if ( !$wgRequest->wasPosted() ) {
428 if ( !$this->mTitle
->userCanEditCssSubpage() ) {
431 if ( !$this->mTitle
->userCanEditJsSubpage() ) {
435 return $wgUser->matchEditToken(
436 $wgRequest->getVal( 'wpEditToken' ) );
440 * Generated JavaScript action=raw&gen=js
441 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
442 * nated together. For some bizarre reason, it does *not* return any
443 * custom user JS from subpages. Huh?
445 * There's absolutely no reason to have separate Monobook/Common JSes.
446 * Any JS that cares can just check the skin variable generated at the
447 * top. For now Monobook.js will be maintained, but it should be consi-
450 * @param $skinName String: If set, overrides the skin name
453 public function generateUserJs( $skinName = null ) {
455 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
461 * Generate user stylesheet for action=raw&gen=css
463 public function generateUserStylesheet() {
465 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
471 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
472 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
474 protected function reallyGenerateUserStylesheet() {
476 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
484 function setupUserCss( OutputPage
$out ) {
486 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
488 wfProfileIn( __METHOD__
);
490 $this->setupSkinUserCss( $out );
494 'maxage' => $wgSquidMaxage,
497 // Add any extension CSS
498 foreach ( $out->getExtStyle() as $url ) {
499 $out->addStyle( $url );
502 // Per-site custom styles
503 if ( $wgUseSiteCss ) {
504 $out->addModuleStyles( 'site' );
507 // Per-user custom styles
508 if ( $wgAllowUserCss ) {
509 if ( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
510 // @FIXME: properly escape the cdata!
511 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
513 $out->addModuleStyles( 'user' );
517 // Per-user preference styles
518 if ( $wgAllowUserCssPrefs ) {
519 $out->addModuleStyles( 'user.options' );
522 wfProfileOut( __METHOD__
);
526 * Get the query to generate a dynamic stylesheet
530 public static function getDynamicStylesheetQuery() {
531 global $wgSquidMaxage;
535 'maxage' => $wgSquidMaxage,
536 'usemsgcache' => 'yes',
537 'ctype' => 'text/css',
538 'smaxage' => $wgSquidMaxage,
543 * Add skin specific stylesheets
544 * @param $out OutputPage
546 function setupSkinUserCss( OutputPage
$out ) {
547 $out->addModuleStyles( 'mediawiki.legacy.shared' );
548 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
549 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
550 $out->addStyle( $this->getStylesheet() );
551 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
554 function getPageClasses( $title ) {
555 $numeric = 'ns-' . $title->getNamespace();
557 if ( $title->getNamespace() == NS_SPECIAL
) {
558 $type = 'ns-special';
559 } elseif ( $title->isTalkPage() ) {
562 $type = 'ns-subject';
565 $name = Sanitizer
::escapeClass( 'page-' . $title->getPrefixedText() );
567 return "$numeric $type $name";
579 * This will be called immediately after the <body> tag. Split into
580 * two functions to make it easier to subclass.
582 function beforeContent() {
583 return $this->doBeforeContent();
586 function doBeforeContent() {
588 wfProfileIn( __METHOD__
);
591 $qb = $this->qbSetting();
593 $langlinks = $this->otherLanguages();
600 $borderhack = 'class="top"';
603 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
604 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
606 $shove = ( $qb != 0 );
607 $left = ( $qb == 1 ||
$qb == 3 );
609 if ( $wgContLang->isRTL() ) {
614 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
615 $this->logoText() . '</td>';
617 $s .= $this->getQuickbarCompensator( $rows );
620 $l = $wgContLang->alignStart();
621 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
623 $s .= $this->topLinks();
624 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
626 $r = $wgContLang->alignEnd();
627 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
628 $s .= $this->nameAndLogin();
629 $s .= "\n<br />" . $this->searchForm() . '</td>';
632 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
635 if ( $shove && !$left ) { # Right
636 $s .= $this->getQuickbarCompensator( $rows );
639 $s .= "</tr>\n</table>\n</div>\n";
640 $s .= "\n<div id='article'>\n";
642 $notice = wfGetSiteNotice();
645 $s .= "\n<div id='siteNotice'>$notice</div>\n";
647 $s .= $this->pageTitle();
648 $s .= $this->pageSubtitle();
649 $s .= $this->getCategories();
651 wfProfileOut( __METHOD__
);
655 function getCategoryLinks() {
656 global $wgOut, $wgUseCategoryBrowser;
657 global $wgContLang, $wgUser;
659 if ( count( $wgOut->mCategoryLinks
) == 0 ) {
664 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
666 // Use Unicode bidi embedding override characters,
667 // to make sure links don't smash each other up in ugly ways.
668 $dir = $wgContLang->getDir();
669 $embed = "<span dir='$dir'>";
672 $allCats = $wgOut->getCategoryLinks();
674 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
676 if ( !empty( $allCats['normal'] ) ) {
677 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
679 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
680 $s .= '<div id="mw-normal-catlinks">' .
681 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
682 . $colon . $t . '</div>';
686 if ( isset( $allCats['hidden'] ) ) {
687 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
688 $class = 'mw-hidden-cats-user-shown';
689 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
690 $class = 'mw-hidden-cats-ns-shown';
692 $class = 'mw-hidden-cats-hidden';
695 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
696 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
697 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
701 # optional 'dmoz-like' category browser. Will be shown under the list
702 # of categories an article belong to
703 if ( $wgUseCategoryBrowser ) {
704 $s .= '<br /><hr />';
706 # get a big array of the parents tree
707 $parenttree = $this->mTitle
->getParentCategoryTree();
708 # Skin object passed by reference cause it can not be
709 # accessed under the method subfunction drawCategoryBrowser
710 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
711 # Clean out bogus first entry and sort them
712 unset( $tempout[0] );
714 # Output one per line
715 $s .= implode( "<br />\n", $tempout );
722 * Render the array as a serie of links.
723 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
724 * @param &skin Object: skin passed by reference
725 * @return String separated by >, terminate with "\n"
727 function drawCategoryBrowser( $tree, &$skin ) {
730 foreach ( $tree as $element => $parent ) {
731 if ( empty( $parent ) ) {
732 # element start a new list
735 # grab the others elements
736 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
739 # add our current element to the list
740 $eltitle = Title
::newFromText( $element );
741 $return .= $skin->link( $eltitle, $eltitle->getText() );
747 function getCategories() {
748 $catlinks = $this->getCategoryLinks();
750 $classes = 'catlinks';
752 global $wgOut, $wgUser;
754 // Check what we're showing
755 $allCats = $wgOut->getCategoryLinks();
756 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
757 $this->mTitle
->getNamespace() == NS_CATEGORY
;
759 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
760 $classes .= ' catlinks-allhidden';
763 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
766 function getQuickbarCompensator( $rows = 1 ) {
767 return "<td width='152' rowspan='{$rows}'> </td>";
771 * This runs a hook to allow extensions placing their stuff after content
772 * and article metadata (e.g. categories).
773 * Note: This function has nothing to do with afterContent().
775 * This hook is placed here in order to allow using the same hook for all
776 * skins, both the SkinTemplate based ones and the older ones, which directly
777 * use this class to get their data.
779 * The output of this function gets processed in SkinTemplate::outputPage() for
780 * the SkinTemplate based skins, all other skins should directly echo it.
782 * Returns an empty string by default, if not changed by any hook function.
784 protected function afterContentHook() {
787 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
788 // adding just some spaces shouldn't toggle the output
789 // of the whole <div/>, so we use trim() here
790 if ( trim( $data ) != '' ) {
791 // Doing this here instead of in the skins to
792 // ensure that the div has the same ID in all
794 $data = "<div id='mw-data-after-content'>\n" .
799 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
806 * Generate debug data HTML for displaying at the bottom of the main content
808 * @return String HTML containing debug data, if enabled (otherwise empty).
810 protected function generateDebugHTML() {
811 global $wgShowDebug, $wgOut;
813 if ( $wgShowDebug ) {
814 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
815 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
816 $listInternals . "</ul>\n";
822 private function formatDebugHTML( $debugText ) {
823 $lines = explode( "\n", $debugText );
827 foreach ( $lines as $line ) {
829 $display = ltrim( $line );
830 $ident = strlen( $line ) - strlen( $display );
831 $diff = $ident - $curIdent;
833 if ( $display == '' ) {
834 $display = "\xc2\xa0";
837 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
840 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
842 $display = htmlspecialchars( $display );
846 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
847 } elseif ( $diff == 0 ) {
848 $ret .= "</li><li>\n";
850 $ret .= str_repeat( "<ul><li>\n", $diff );
852 $ret .= $display . "\n";
857 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
863 * This gets called shortly before the </body> tag.
864 * @return String HTML to be put before </body>
866 function afterContent() {
867 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
868 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
872 * This gets called shortly before the </body> tag.
873 * @param $out OutputPage object
874 * @return String HTML-wrapped JS code to be put before </body>
876 function bottomScripts( $out ) {
877 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
878 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
880 return $bottomScriptText;
883 /** @return string Retrievied from HTML text */
884 function printSource() {
885 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
886 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
889 function printFooter() {
890 return "<p>" . $this->printSource() .
891 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
894 /** overloaded by derived classes */
895 function doAfterContent() {
896 return '</div></div>';
899 function pageTitleLinks() {
900 global $wgOut, $wgUser, $wgRequest, $wgLang;
902 $oldid = $wgRequest->getVal( 'oldid' );
903 $diff = $wgRequest->getVal( 'diff' );
904 $action = $wgRequest->getText( 'action' );
906 $s[] = $this->printableLink();
907 $disclaimer = $this->disclaimerLink(); # may be empty
913 $privacy = $this->privacyLink(); # may be empty too
919 if ( $wgOut->isArticleRelated() ) {
920 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
921 $name = $this->mTitle
->getDBkey();
922 $image = wfFindFile( $this->mTitle
);
925 $link = htmlspecialchars( $image->getURL() );
926 $style = $this->getInternalLinkAttributes( $link, $name );
927 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
932 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
935 wfMsg( 'currentrev' ),
938 array( 'known', 'noclasses' )
942 if ( $wgUser->getNewtalk() ) {
943 # do not show "You have new messages" text when we are viewing our
945 if ( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
947 $wgUser->getTalkPage(),
948 wfMsgHtml( 'newmessageslink' ),
950 array( 'redirect' => 'no' ),
951 array( 'known', 'noclasses' )
955 $wgUser->getTalkPage(),
956 wfMsgHtml( 'newmessagesdifflink' ),
958 array( 'diff' => 'cur' ),
959 array( 'known', 'noclasses' )
961 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
963 $wgOut->setSquidMaxage( 0 );
964 $wgOut->enableClientCache( false );
968 $undelete = $this->getUndeleteLink();
970 if ( !empty( $undelete ) ) {
974 return $wgLang->pipeList( $s );
977 function getUndeleteLink() {
978 global $wgUser, $wgLang, $wgRequest;
980 $action = $wgRequest->getVal( 'action', 'view' );
982 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
983 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
984 $n = $this->mTitle
->isDeleted();
987 if ( $wgUser->isAllowed( 'undelete' ) ) {
988 $msg = 'thisisdeleted';
990 $msg = 'viewdeleted';
996 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
997 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1000 array( 'known', 'noclasses' )
1009 function printableLink() {
1010 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1014 if ( !$wgOut->isPrintable() ) {
1015 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1016 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1019 if ( $wgOut->isSyndicated() ) {
1020 foreach ( $wgFeedClasses as $format => $class ) {
1021 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1022 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1023 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1026 return $wgLang->pipeList( $s );
1030 * Gets the h1 element with the page title.
1033 function pageTitle() {
1035 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1039 function pageSubtitle() {
1042 $sub = $wgOut->getSubtitle();
1045 global $wgExtraSubtitle;
1046 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1049 $subpages = $this->subPageSubtitle();
1050 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1051 $s = "<p class='subtitle'>{$sub}</p>\n";
1056 function subPageSubtitle() {
1059 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
1065 if ( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1066 $ptext = $this->mTitle
->getPrefixedText();
1067 if ( preg_match( '/\//', $ptext ) ) {
1068 $links = explode( '/', $ptext );
1069 array_pop( $links );
1074 foreach ( $links as $link ) {
1075 $growinglink .= $link;
1077 $linkObj = Title
::newFromText( $growinglink );
1079 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1080 $getlink = $this->link(
1082 htmlspecialchars( $display ),
1085 array( 'known', 'noclasses' )
1091 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1093 $subpages .= '< ';
1096 $subpages .= $getlink;
1101 $growinglink .= '/';
1110 * Returns true if the IP should be shown in the header
1112 function showIPinHeader() {
1113 global $wgShowIPinHeader;
1114 return $wgShowIPinHeader && session_id() != '';
1117 function nameAndLogin() {
1118 global $wgUser, $wgLang, $wgContLang;
1120 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1124 if ( $wgUser->isAnon() ) {
1125 if ( $this->showIPinHeader() ) {
1128 $talkLink = $this->link( $wgUser->getTalkPage(),
1129 $wgLang->getNsText( NS_TALK
) );
1131 $ret .= "$name ($talkLink)";
1133 $ret .= wfMsg( 'notloggedin' );
1136 $returnTo = $this->mTitle
->getPrefixedDBkey();
1139 if ( $logoutPage != $returnTo ) {
1140 $query['returnto'] = $returnTo;
1143 $loginlink = $wgUser->isAllowed( 'createaccount' )
1144 ?
'nav-login-createaccount'
1146 $ret .= "\n<br />" . $this->link(
1147 SpecialPage
::getTitleFor( 'Userlogin' ),
1148 wfMsg( $loginlink ), array(), $query
1151 $returnTo = $this->mTitle
->getPrefixedDBkey();
1152 $talkLink = $this->link( $wgUser->getTalkPage(),
1153 $wgLang->getNsText( NS_TALK
) );
1155 $ret .= $this->link( $wgUser->getUserPage(),
1156 htmlspecialchars( $wgUser->getName() ) );
1157 $ret .= " ($talkLink)<br />";
1158 $ret .= $wgLang->pipeList( array(
1160 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1161 array(), array( 'returnto' => $returnTo )
1163 $this->specialLink( 'preferences' ),
1167 $ret = $wgLang->pipeList( array(
1170 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1178 function getSearchLink() {
1179 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1180 return $searchPage->getLocalURL();
1183 function escapeSearchLink() {
1184 return htmlspecialchars( $this->getSearchLink() );
1187 function searchForm() {
1188 global $wgRequest, $wgUseTwoButtonsSearchForm;
1190 $search = $wgRequest->getText( 'search' );
1192 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
1193 . $this->escapeSearchLink() . "\">\n"
1194 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
1195 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1196 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1198 if ( $wgUseTwoButtonsSearchForm ) {
1199 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1201 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1206 // Ensure unique id's for search boxes made after the first
1207 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1212 function topLinks() {
1216 $this->mainPageLink(),
1217 $this->specialLink( 'recentchanges' )
1220 if ( $wgOut->isArticleRelated() ) {
1221 $s[] = $this->editThisPage();
1222 $s[] = $this->historyLink();
1225 # Many people don't like this dropdown box
1226 # $s[] = $this->specialPagesList();
1228 if ( $this->variantLinks() ) {
1229 $s[] = $this->variantLinks();
1232 if ( $this->extensionTabLinks() ) {
1233 $s[] = $this->extensionTabLinks();
1236 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1237 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1241 * Compatibility for extensions adding functionality through tabs.
1242 * Eventually these old skins should be replaced with SkinTemplate-based
1246 function extensionTabLinks() {
1250 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1251 foreach ( $tabs as $tab ) {
1252 $s[] = Xml
::element( 'a',
1253 array( 'href' => $tab['href'] ),
1257 if ( count( $s ) ) {
1260 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1261 $out .= $wgLang->pipeList( $s );
1268 * Language/charset variant links for classic-style skins
1271 function variantLinks() {
1274 /* show links to different language variants */
1275 global $wgDisableLangConversion, $wgLang, $wgContLang;
1277 $variants = $wgContLang->getVariants();
1279 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1280 foreach ( $variants as $code ) {
1281 $varname = $wgContLang->getVariantname( $code );
1283 if ( $varname == 'disable' ) {
1286 $s = $wgLang->pipeList( array(
1288 '<a href="' . $this->mTitle
->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1296 function bottomLinks() {
1297 global $wgOut, $wgUser, $wgUseTrackbacks;
1298 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1301 if ( $wgOut->isArticleRelated() ) {
1302 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1304 if ( $wgUser->isLoggedIn() ) {
1305 $element[] = $this->watchThisPage();
1308 $element[] = $this->talkLink();
1309 $element[] = $this->historyLink();
1310 $element[] = $this->whatLinksHere();
1311 $element[] = $this->watchPageLinksLink();
1313 if ( $wgUseTrackbacks ) {
1314 $element[] = $this->trackbackLink();
1318 $this->mTitle
->getNamespace() == NS_USER ||
1319 $this->mTitle
->getNamespace() == NS_USER_TALK
1321 $id = User
::idFromName( $this->mTitle
->getText() );
1322 $ip = User
::isIP( $this->mTitle
->getText() );
1324 # Both anons and non-anons have contributions list
1326 $element[] = $this->userContribsLink();
1329 if ( $this->showEmailUser( $id ) ) {
1330 $element[] = $this->emailUserLink();
1334 $s = implode( $element, $sep );
1336 if ( $this->mTitle
->getArticleId() ) {
1339 // Delete/protect/move links for privileged users
1340 if ( $wgUser->isAllowed( 'delete' ) ) {
1341 $s .= $this->deleteThisPage();
1344 if ( $wgUser->isAllowed( 'protect' ) ) {
1345 $s .= $sep . $this->protectThisPage();
1348 if ( $wgUser->isAllowed( 'move' ) ) {
1349 $s .= $sep . $this->moveThisPage();
1353 $s .= "<br />\n" . $this->otherLanguages();
1359 function pageStats() {
1360 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1361 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1363 $oldid = $wgRequest->getVal( 'oldid' );
1364 $diff = $wgRequest->getVal( 'diff' );
1366 if ( !$wgOut->isArticle() ) {
1370 if ( !$wgArticle instanceof Article
) {
1374 if ( isset( $oldid ) ||
isset( $diff ) ) {
1378 if ( 0 == $wgArticle->getID() ) {
1384 if ( !$wgDisableCounters ) {
1385 $count = $wgLang->formatNum( $wgArticle->getCount() );
1388 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1392 if ( $wgMaxCredits != 0 ) {
1393 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1395 $s .= $this->lastModified();
1398 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1399 $dbr = wfGetDB( DB_SLAVE
);
1400 $res = $dbr->select(
1402 array( 'COUNT(*) AS n' ),
1404 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ),
1405 'wl_namespace' => $this->mTitle
->getNamespace()
1409 $x = $dbr->fetchObject( $res );
1411 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1412 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1416 return $s . ' ' . $this->getCopyright();
1419 function getCopyright( $type = 'detect' ) {
1420 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1422 if ( $type == 'detect' ) {
1423 $diff = $wgRequest->getVal( 'diff' );
1424 $isCur = $wgArticle && $wgArticle->isCurrent();
1426 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1433 if ( $type == 'history' ) {
1434 $msg = 'history_copyright';
1441 if ( $wgRightsPage ) {
1442 $title = Title
::newFromText( $wgRightsPage );
1443 $link = $this->linkKnown( $title, $wgRightsText );
1444 } elseif ( $wgRightsUrl ) {
1445 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1446 } elseif ( $wgRightsText ) {
1447 $link = $wgRightsText;
1453 // Allow for site and per-namespace customization of copyright notice.
1456 if ( isset( $wgArticle ) ) {
1457 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1460 if ( $forContent ) {
1461 $out .= wfMsgForContent( $msg, $link );
1463 $out .= wfMsg( $msg, $link );
1469 function getCopyrightIcon() {
1470 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1474 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1475 $out = $wgCopyrightIcon;
1476 } elseif ( $wgRightsIcon ) {
1477 $icon = htmlspecialchars( $wgRightsIcon );
1479 if ( $wgRightsUrl ) {
1480 $url = htmlspecialchars( $wgRightsUrl );
1481 $out .= '<a href="' . $url . '">';
1484 $text = htmlspecialchars( $wgRightsText );
1485 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1487 if ( $wgRightsUrl ) {
1496 * Gets the powered by MediaWiki icon.
1499 function getPoweredBy() {
1500 global $wgStylePath;
1502 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1503 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1508 function lastModified() {
1509 global $wgLang, $wgArticle;
1511 if ( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest() ) {
1512 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1514 $timestamp = $wgArticle->getTimestamp();
1518 $d = $wgLang->date( $timestamp, true );
1519 $t = $wgLang->time( $timestamp, true );
1520 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1525 if ( wfGetLB()->getLaggedSlaveMode() ) {
1526 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1532 function logoText( $align = '' ) {
1533 if ( $align != '' ) {
1534 $a = " align='{$align}'";
1539 $mp = wfMsg( 'mainpage' );
1540 $mptitle = Title
::newMainPage();
1541 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1543 $logourl = $this->getLogo();
1544 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1550 * Show a drop-down box of special pages
1552 function specialPagesList() {
1553 global $wgContLang, $wgServer, $wgRedirectScript;
1555 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1557 foreach ( $pages as $name => $page ) {
1558 $pages[$name] = $page->getDescription();
1561 $go = wfMsg( 'go' );
1562 $sp = wfMsg( 'specialpages' );
1563 $spp = $wgContLang->specialPage( 'Specialpages' );
1565 $s = '<form id="specialpages" method="get" ' .
1566 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1567 $s .= "<select name=\"wpDropdown\">\n";
1568 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1571 foreach ( $pages as $name => $desc ) {
1572 $p = $wgContLang->specialPage( $name );
1573 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1576 $s .= "</select>\n";
1577 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1584 * Gets the link to the wiki's main page.
1587 function mainPageLink() {
1589 Title
::newMainPage(),
1590 wfMsg( 'mainpage' ),
1593 array( 'known', 'noclasses' )
1599 private function footerLink( $desc, $page ) {
1600 // if the link description has been set to "-" in the default language,
1601 if ( wfMsgForContent( $desc ) == '-' ) {
1602 // then it is disabled, for all languages.
1605 // Otherwise, we display the link for the user, described in their
1606 // language (which may or may not be the same as the default language),
1607 // but we make the link target be the one site-wide page.
1608 $title = Title
::newFromText( wfMsgForContent( $page ) );
1610 return $this->linkKnown(
1612 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1618 * Gets the link to the wiki's privacy policy page.
1620 function privacyLink() {
1621 return $this->footerLink( 'privacy', 'privacypage' );
1625 * Gets the link to the wiki's about page.
1627 function aboutLink() {
1628 return $this->footerLink( 'aboutsite', 'aboutpage' );
1632 * Gets the link to the wiki's general disclaimers page.
1634 function disclaimerLink() {
1635 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1638 function editThisPage() {
1641 if ( !$wgOut->isArticleRelated() ) {
1642 $s = wfMsg( 'protectedpage' );
1644 if ( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1645 $t = wfMsg( 'editthispage' );
1646 } elseif ( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1647 $t = wfMsg( 'create-this-page' );
1649 $t = wfMsg( 'viewsource' );
1656 $this->editUrlOptions(),
1657 array( 'known', 'noclasses' )
1665 * Return URL options for the 'edit page' link.
1666 * This may include an 'oldid' specifier, if the current page view is such.
1671 function editUrlOptions() {
1674 $options = array( 'action' => 'edit' );
1676 if ( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1677 $options['oldid'] = intval( $this->mRevisionId
);
1683 function deleteThisPage() {
1684 global $wgUser, $wgRequest;
1686 $diff = $wgRequest->getVal( 'diff' );
1688 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1689 $t = wfMsg( 'deletethispage' );
1695 array( 'action' => 'delete' ),
1696 array( 'known', 'noclasses' )
1705 function protectThisPage() {
1706 global $wgUser, $wgRequest;
1708 $diff = $wgRequest->getVal( 'diff' );
1710 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1711 if ( $this->mTitle
->isProtected() ) {
1712 $text = wfMsg( 'unprotectthispage' );
1713 $query = array( 'action' => 'unprotect' );
1715 $text = wfMsg( 'protectthispage' );
1716 $query = array( 'action' => 'protect' );
1724 array( 'known', 'noclasses' )
1733 function watchThisPage() {
1735 ++
$this->mWatchLinkNum
;
1737 if ( $wgOut->isArticleRelated() ) {
1738 if ( $this->mTitle
->userIsWatching() ) {
1739 $text = wfMsg( 'unwatchthispage' );
1740 $query = array( 'action' => 'unwatch' );
1741 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1743 $text = wfMsg( 'watchthispage' );
1744 $query = array( 'action' => 'watch' );
1745 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1751 array( 'id' => $id ),
1753 array( 'known', 'noclasses' )
1756 $s = wfMsg( 'notanarticle' );
1762 function moveThisPage() {
1763 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1765 SpecialPage
::getTitleFor( 'Movepage' ),
1766 wfMsg( 'movethispage' ),
1768 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1769 array( 'known', 'noclasses' )
1772 // no message if page is protected - would be redundant
1777 function historyLink() {
1780 wfMsgHtml( 'history' ),
1781 array( 'rel' => 'archives' ),
1782 array( 'action' => 'history' )
1786 function whatLinksHere() {
1788 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1789 wfMsgHtml( 'whatlinkshere' ),
1792 array( 'known', 'noclasses' )
1796 function userContribsLink() {
1798 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1799 wfMsgHtml( 'contributions' ),
1802 array( 'known', 'noclasses' )
1806 function showEmailUser( $id ) {
1808 $targetUser = User
::newFromId( $id );
1809 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1810 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1813 function emailUserLink() {
1815 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1816 wfMsg( 'emailuser' ),
1819 array( 'known', 'noclasses' )
1823 function watchPageLinksLink() {
1826 if ( !$wgOut->isArticleRelated() ) {
1827 return '(' . wfMsg( 'notanarticle' ) . ')';
1830 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1831 wfMsg( 'recentchangeslinked-toolbox' ),
1834 array( 'known', 'noclasses' )
1839 function trackbackLink() {
1840 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1841 . wfMsg( 'trackbacklink' ) . '</a>';
1844 function otherLanguages() {
1845 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1847 if ( $wgHideInterlanguageLinks ) {
1851 $a = $wgOut->getLanguageLinks();
1853 if ( 0 == count( $a ) ) {
1857 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1860 if ( $wgContLang->isRTL() ) {
1861 $s .= '<span dir="LTR">';
1864 foreach ( $a as $l ) {
1866 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1871 $nt = Title
::newFromText( $l );
1872 $url = $nt->escapeFullURL();
1873 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1874 $title = htmlspecialchars( $nt->getText() );
1876 if ( $text == '' ) {
1880 $style = $this->getExternalLinkAttributes();
1881 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1884 if ( $wgContLang->isRTL() ) {
1891 function talkLink() {
1892 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1893 # No discussion links for special pages
1897 $linkOptions = array();
1899 if ( $this->mTitle
->isTalkPage() ) {
1900 $link = $this->mTitle
->getSubjectPage();
1901 switch( $link->getNamespace() ) {
1903 $text = wfMsg( 'articlepage' );
1906 $text = wfMsg( 'userpage' );
1909 $text = wfMsg( 'projectpage' );
1912 $text = wfMsg( 'imagepage' );
1913 # Make link known if image exists, even if the desc. page doesn't.
1914 if ( wfFindFile( $link ) )
1915 $linkOptions[] = 'known';
1918 $text = wfMsg( 'mediawikipage' );
1921 $text = wfMsg( 'templatepage' );
1924 $text = wfMsg( 'viewhelppage' );
1927 $text = wfMsg( 'categorypage' );
1930 $text = wfMsg( 'articlepage' );
1933 $link = $this->mTitle
->getTalkPage();
1934 $text = wfMsg( 'talkpage' );
1937 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1942 function commentLink() {
1945 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1949 # __NEWSECTIONLINK___ changes behaviour here
1950 # If it is present, the link points to this page, otherwise
1951 # it points to the talk page
1952 if ( $this->mTitle
->isTalkPage() ) {
1953 $title = $this->mTitle
;
1954 } elseif ( $wgOut->showNewSectionLink() ) {
1955 $title = $this->mTitle
;
1957 $title = $this->mTitle
->getTalkPage();
1962 wfMsg( 'postcomment' ),
1968 array( 'known', 'noclasses' )
1972 function getUploadLink() {
1973 global $wgUploadNavigationUrl;
1975 if ( $wgUploadNavigationUrl ) {
1976 # Using an empty class attribute to avoid automatic setting of "external" class
1977 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
1980 SpecialPage
::getTitleFor( 'Upload' ),
1981 wfMsgHtml( 'upload' ),
1984 array( 'known', 'noclasses' )
1989 /* these are used extensively in SkinTemplate, but also some other places */
1990 static function makeMainPageUrl( $urlaction = '' ) {
1991 $title = Title
::newMainPage();
1992 self
::checkTitle( $title, '' );
1994 return $title->getLocalURL( $urlaction );
1997 static function makeSpecialUrl( $name, $urlaction = '' ) {
1998 $title = SpecialPage
::getTitleFor( $name );
1999 return $title->getLocalURL( $urlaction );
2002 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2003 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
2004 return $title->getLocalURL( $urlaction );
2007 static function makeI18nUrl( $name, $urlaction = '' ) {
2008 $title = Title
::newFromText( wfMsgForContent( $name ) );
2009 self
::checkTitle( $title, $name );
2010 return $title->getLocalURL( $urlaction );
2013 static function makeUrl( $name, $urlaction = '' ) {
2014 $title = Title
::newFromText( $name );
2015 self
::checkTitle( $title, $name );
2017 return $title->getLocalURL( $urlaction );
2021 * If url string starts with http, consider as external URL, else
2024 static function makeInternalOrExternalUrl( $name ) {
2025 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2028 return self
::makeUrl( $name );
2032 # this can be passed the NS number as defined in Language.php
2033 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
2034 $title = Title
::makeTitleSafe( $namespace, $name );
2035 self
::checkTitle( $title, $name );
2037 return $title->getLocalURL( $urlaction );
2040 /* these return an array with the 'href' and boolean 'exists' */
2041 static function makeUrlDetails( $name, $urlaction = '' ) {
2042 $title = Title
::newFromText( $name );
2043 self
::checkTitle( $title, $name );
2046 'href' => $title->getLocalURL( $urlaction ),
2047 'exists' => $title->getArticleID() != 0 ?
true : false
2052 * Make URL details where the article exists (or at least it's convenient to think so)
2054 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2055 $title = Title
::newFromText( $name );
2056 self
::checkTitle( $title, $name );
2059 'href' => $title->getLocalURL( $urlaction ),
2064 # make sure we have some title to operate on
2065 static function checkTitle( &$title, $name ) {
2066 if ( !is_object( $title ) ) {
2067 $title = Title
::newFromText( $name );
2068 if ( !is_object( $title ) ) {
2069 $title = Title
::newFromText( '--error: link target missing--' );
2075 * Build an array that represents the sidebar(s), the navigation bar among them
2079 function buildSidebar() {
2080 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2082 wfProfileIn( __METHOD__
);
2084 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2086 if ( $wgEnableSidebarCache ) {
2087 $cachedsidebar = $parserMemc->get( $key );
2088 if ( $cachedsidebar ) {
2089 wfProfileOut( __METHOD__
);
2090 return $cachedsidebar;
2095 $this->addToSidebar( $bar, 'sidebar' );
2097 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2098 if ( $wgEnableSidebarCache ) {
2099 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2102 wfProfileOut( __METHOD__
);
2106 * Add content from a sidebar system message
2107 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2109 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2111 * @param &$bar array
2112 * @param $message String
2114 function addToSidebar( &$bar, $message ) {
2115 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2119 * Add content from plain text
2121 * @param &$bar array
2122 * @param $text string
2124 function addToSidebarPlain( &$bar, $text ) {
2125 $lines = explode( "\n", $text );
2126 $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.
2130 foreach ( $lines as $line ) {
2131 if ( strpos( $line, '*' ) !== 0 ) {
2135 if ( strpos( $line, '**' ) !== 0 ) {
2136 $heading = trim( $line, '* ' );
2137 if ( !array_key_exists( $heading, $bar ) ) {
2138 $bar[$heading] = array();
2141 $line = trim( $line, '* ' );
2143 if ( strpos( $line, '|' ) !== false ) { // sanity check
2144 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2145 $link = wfMsgForContent( $line[0] );
2147 if ( $link == '-' ) {
2151 $text = wfMsgExt( $line[1], 'parsemag' );
2153 if ( wfEmptyMsg( $line[1], $text ) ) {
2157 if ( wfEmptyMsg( $line[0], $link ) ) {
2161 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2164 $title = Title
::newFromText( $link );
2167 $title = $title->fixSpecialName();
2168 $href = $title->getLocalURL();
2170 $href = 'INVALID-TITLE';
2174 $bar[$heading][] = array(
2177 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2180 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2181 global $wgParser, $wgTitle;
2183 $line = substr( $line, 2, strlen( $line ) - 4 );
2185 if ( is_null( $wgParser->mOptions
) ) {
2186 $wgParser->mOptions
= new ParserOptions();
2189 $wgParser->mOptions
->setEditSection( false );
2190 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions
)->getText();
2197 if ( count( $wikiBar ) > 0 ) {
2198 $bar = array_merge( $bar, $wikiBar );
2205 * Should we include common/wikiprintable.css? Skins that have their own
2206 * print stylesheet should override this and return false. (This is an
2207 * ugly hack to get Monobook to play nicely with
2208 * OutputPage::headElement().)
2212 public function commonPrintStylesheet() {
2217 * Gets new talk page messages for the current user.
2218 * @return MediaWiki message or if no new talk page messages, nothing
2220 function getNewtalks() {
2221 global $wgUser, $wgOut;
2223 $newtalks = $wgUser->getNewMessageLinks();
2226 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2227 $userTitle = $this->mUser
->getUserPage();
2228 $userTalkTitle = $userTitle->getTalkPage();
2230 if ( !$userTalkTitle->equals( $this->mTitle
) ) {
2231 $newMessagesLink = $this->link(
2233 wfMsgHtml( 'newmessageslink' ),
2235 array( 'redirect' => 'no' ),
2236 array( 'known', 'noclasses' )
2239 $newMessagesDiffLink = $this->link(
2241 wfMsgHtml( 'newmessagesdifflink' ),
2243 array( 'diff' => 'cur' ),
2244 array( 'known', 'noclasses' )
2248 'youhavenewmessages',
2250 $newMessagesDiffLink
2252 # Disable Squid cache
2253 $wgOut->setSquidMaxage( 0 );
2255 } elseif ( count( $newtalks ) ) {
2256 // _>" " for BC <= 1.16
2257 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2260 foreach ( $newtalks as $newtalk ) {
2261 $msgs[] = Xml
::element(
2263 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2266 $parts = implode( $sep, $msgs );
2267 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2268 $wgOut->setSquidMaxage( 0 );