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 # Real Simple Discovery link, provides auto-discovery information
220 # for the MediaWiki API (and potentially additional custom API
221 # support such as WordPress or Twitter-compatible APIs for a
222 # blogging extension, etc)
223 $out->addLink( array(
225 'type' => 'application/rsd+xml',
226 'href' => wfExpandUrl( wfAppendQuery( wfScript( 'api' ), array( 'action' => 'rsd' ) ) ),
229 $this->addMetadataLinks( $out );
231 $this->mRevisionId
= $out->mRevisionId
;
233 $this->preloadExistence();
235 wfProfileOut( __METHOD__
);
239 * Preload the existence of three commonly-requested pages in a single query
241 function preloadExistence() {
245 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
248 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
250 } elseif ( $this->mTitle
->isTalkPage() ) {
251 $titles[] = $this->mTitle
->getSubjectPage();
253 $titles[] = $this->mTitle
->getTalkPage();
256 $lb = new LinkBatch( $titles );
257 $lb->setCaller( __METHOD__
);
262 * Adds metadata links below to the HTML output.
264 * <li>Creative Commons
265 * <br />See http://wiki.creativecommons.org/Extend_Metadata.
267 * <li>Dublin Core</li>
268 * <li>Use hreflang to specify canonical and alternate links
269 * <br />See http://www.google.com/support/webmasters/bin/answer.py?answer=189077
274 * @param $out Object: instance of OutputPage
276 function addMetadataLinks( OutputPage
$out ) {
277 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
278 global $wgDisableLangConversion, $wgDisableLangCanonical, $wgContLang;
279 global $wgRightsPage, $wgRightsUrl;
281 if ( $out->isArticleRelated() ) {
282 # note: buggy CC software only reads first "meta" link
283 if ( $wgEnableCreativeCommonsRdf ) {
284 $out->addMetadataLink( array(
285 'title' => 'Creative Commons',
286 'type' => 'application/rdf+xml',
287 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
291 if ( $wgEnableDublinCoreRdf ) {
292 $out->addMetadataLink( array(
293 'title' => 'Dublin Core',
294 'type' => 'application/rdf+xml',
295 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
300 if ( !$wgDisableLangConversion && !$wgDisableLangCanonical
301 && $wgContLang->hasVariants() ) {
303 $urlvar = $wgContLang->getURLVariant();
306 $variants = $wgContLang->getVariants();
307 foreach ( $variants as $_v ) {
308 $out->addLink( array(
309 'rel' => 'alternate',
311 'href' => $this->mTitle
->getLocalURL( '', $_v ) )
315 $out->addLink( array(
316 'rel' => 'canonical',
317 'href' => $this->mTitle
->getFullURL() )
323 if ( $wgRightsPage ) {
324 $copy = Title
::newFromText( $wgRightsPage );
327 $copyright = $copy->getLocalURL();
331 if ( !$copyright && $wgRightsUrl ) {
332 $copyright = $wgRightsUrl;
336 $out->addLink( array(
337 'rel' => 'copyright',
338 'href' => $copyright )
344 * Set some local variables
346 protected function setMembers() {
348 $this->mUser
= $wgUser;
349 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
350 $this->usercss
= false;
355 * @param $t Title object to use
357 public function setTitle( $t ) {
362 public function getTitle() {
363 return $this->mTitle
;
367 * Outputs the HTML generated by other functions.
368 * @param $out Object: instance of OutputPage
370 function outputPage( OutputPage
$out ) {
371 global $wgDebugComments;
372 wfProfileIn( __METHOD__
);
375 $this->initPage( $out );
377 // See self::afterContentHook() for documentation
378 $afterContent = $this->afterContentHook();
380 $out->out( $out->headElement( $this ) );
382 if ( $wgDebugComments ) {
383 $out->out( "<!-- Wiki debugging output:\n" .
384 $out->mDebugtext
. "-->\n" );
387 $out->out( $this->beforeContent() );
389 $out->out( $out->mBodytext
. "\n" );
391 $out->out( $this->afterContent() );
393 $out->out( $afterContent );
395 $out->out( $this->bottomScripts( $out ) );
397 $out->out( wfReportTime() );
399 $out->out( "\n</body></html>" );
400 wfProfileOut( __METHOD__
);
403 static function makeVariablesScript( $data ) {
405 return Html
::inlineScript(
406 ResourceLoader
::makeLoaderConditionalScript( ResourceLoader
::makeConfigSetScript( $data ) )
414 * Make a <script> tag containing global variables
415 * @param $skinName string Name of the skin
416 * The odd calling convention is for backwards compatibility
417 * @todo FIXME: Make this not depend on $wgTitle!
419 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
420 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
422 static function makeGlobalVariablesScript( $skinName ) {
423 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
425 $ns = $wgTitle->getNamespace();
426 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
428 'wgCanonicalNamespace' => $nsname,
429 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
430 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
431 'wgNamespaceNumber' => $wgTitle->getNamespace(),
432 'wgPageName' => $wgTitle->getPrefixedDBKey(),
433 'wgTitle' => $wgTitle->getText(),
434 'wgAction' => $wgRequest->getText( 'action', 'view' ),
435 'wgArticleId' => $wgTitle->getArticleId(),
436 'wgIsArticle' => $wgOut->isArticle(),
437 'wgUserName' => $wgUser->isAnon() ?
null : $wgUser->getName(),
438 'wgUserGroups' => $wgUser->getEffectiveGroups(),
439 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
440 'wgCategories' => $wgOut->getCategories(),
442 foreach ( $wgRestrictionTypes as $type ) {
443 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
445 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
446 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
449 // Allow extensions to add their custom variables to the global JS variables
450 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
452 return self
::makeVariablesScript( $vars );
456 * To make it harder for someone to slip a user a fake
457 * user-JavaScript or user-CSS preview, a random token
458 * is associated with the login session. If it's not
459 * passed back with the preview request, we won't render
462 * @param $action String: 'edit', 'submit' etc.
465 public function userCanPreview( $action ) {
466 global $wgRequest, $wgUser;
468 if ( $action != 'submit' ) {
471 if ( !$wgRequest->wasPosted() ) {
474 if ( !$this->mTitle
->userCanEditCssSubpage() ) {
477 if ( !$this->mTitle
->userCanEditJsSubpage() ) {
481 return $wgUser->matchEditToken(
482 $wgRequest->getVal( 'wpEditToken' ) );
486 * Generated JavaScript action=raw&gen=js
487 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
488 * nated together. For some bizarre reason, it does *not* return any
489 * custom user JS from subpages. Huh?
491 * There's absolutely no reason to have separate Monobook/Common JSes.
492 * Any JS that cares can just check the skin variable generated at the
493 * top. For now Monobook.js will be maintained, but it should be consi-
496 * @param $skinName String: If set, overrides the skin name
499 public function generateUserJs( $skinName = null ) {
501 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
507 * Generate user stylesheet for action=raw&gen=css
509 public function generateUserStylesheet() {
511 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
517 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
518 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
520 protected function reallyGenerateUserStylesheet() {
522 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
530 function setupUserCss( OutputPage
$out ) {
532 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
534 wfProfileIn( __METHOD__
);
536 $this->setupSkinUserCss( $out );
540 'maxage' => $wgSquidMaxage,
543 // Add any extension CSS
544 foreach ( $out->getExtStyle() as $url ) {
545 $out->addStyle( $url );
548 // Per-site custom styles
549 if ( $wgUseSiteCss ) {
550 $out->addModuleStyles( 'site' );
553 // Per-user custom styles
554 if ( $wgAllowUserCss ) {
555 if ( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
556 // @FIXME: properly escape the cdata!
557 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
559 $out->addModuleStyles( 'user' );
563 // Per-user preference styles
564 if ( $wgAllowUserCssPrefs ) {
565 $out->addModuleStyles( 'user.options' );
568 wfProfileOut( __METHOD__
);
572 * Get the query to generate a dynamic stylesheet
576 public static function getDynamicStylesheetQuery() {
577 global $wgSquidMaxage;
581 'maxage' => $wgSquidMaxage,
582 'usemsgcache' => 'yes',
583 'ctype' => 'text/css',
584 'smaxage' => $wgSquidMaxage,
589 * Add skin specific stylesheets
590 * @param $out OutputPage
592 function setupSkinUserCss( OutputPage
$out ) {
593 $out->addModuleStyles( 'mediawiki.legacy.shared' );
594 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
595 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
596 $out->addStyle( $this->getStylesheet() );
597 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
600 function getPageClasses( $title ) {
601 $numeric = 'ns-' . $title->getNamespace();
603 if ( $title->getNamespace() == NS_SPECIAL
) {
604 $type = 'ns-special';
605 } elseif ( $title->isTalkPage() ) {
608 $type = 'ns-subject';
611 $name = Sanitizer
::escapeClass( 'page-' . $title->getPrefixedText() );
613 return "$numeric $type $name";
617 * This will be called by OutputPage::headElement when it is creating the
618 * <body> tag, skins can override it if they have a need to add in any
619 * body attributes or classes of their own.
621 function addToBodyAttributes( $out, &$bodyAttrs ) {
622 // does nothing by default
634 * This will be called immediately after the <body> tag. Split into
635 * two functions to make it easier to subclass.
637 function beforeContent() {
638 return $this->doBeforeContent();
641 function doBeforeContent() {
643 wfProfileIn( __METHOD__
);
646 $qb = $this->qbSetting();
648 $langlinks = $this->otherLanguages();
655 $borderhack = 'class="top"';
658 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
659 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
661 $shove = ( $qb != 0 );
662 $left = ( $qb == 1 ||
$qb == 3 );
664 if ( $wgContLang->isRTL() ) {
669 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
670 $this->logoText() . '</td>';
672 $s .= $this->getQuickbarCompensator( $rows );
675 $l = $wgContLang->alignStart();
676 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
678 $s .= $this->topLinks();
679 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
681 $r = $wgContLang->alignEnd();
682 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
683 $s .= $this->nameAndLogin();
684 $s .= "\n<br />" . $this->searchForm() . '</td>';
687 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
690 if ( $shove && !$left ) { # Right
691 $s .= $this->getQuickbarCompensator( $rows );
694 $s .= "</tr>\n</table>\n</div>\n";
695 $s .= "\n<div id='article'>\n";
697 $notice = wfGetSiteNotice();
700 $s .= "\n<div id='siteNotice'>$notice</div>\n";
702 $s .= $this->pageTitle();
703 $s .= $this->pageSubtitle();
704 $s .= $this->getCategories();
706 wfProfileOut( __METHOD__
);
710 function getCategoryLinks() {
711 global $wgOut, $wgUseCategoryBrowser;
712 global $wgContLang, $wgUser;
714 if ( count( $wgOut->mCategoryLinks
) == 0 ) {
719 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
721 // Use Unicode bidi embedding override characters,
722 // to make sure links don't smash each other up in ugly ways.
723 $dir = $wgContLang->getDir();
724 $embed = "<span dir='$dir'>";
727 $allCats = $wgOut->getCategoryLinks();
729 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
731 if ( !empty( $allCats['normal'] ) ) {
732 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
734 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
735 $s .= '<div id="mw-normal-catlinks">' .
736 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
737 . $colon . $t . '</div>';
741 if ( isset( $allCats['hidden'] ) ) {
742 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
743 $class = 'mw-hidden-cats-user-shown';
744 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
745 $class = 'mw-hidden-cats-ns-shown';
747 $class = 'mw-hidden-cats-hidden';
750 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
751 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
752 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
756 # optional 'dmoz-like' category browser. Will be shown under the list
757 # of categories an article belong to
758 if ( $wgUseCategoryBrowser ) {
759 $s .= '<br /><hr />';
761 # get a big array of the parents tree
762 $parenttree = $this->mTitle
->getParentCategoryTree();
763 # Skin object passed by reference cause it can not be
764 # accessed under the method subfunction drawCategoryBrowser
765 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
766 # Clean out bogus first entry and sort them
767 unset( $tempout[0] );
769 # Output one per line
770 $s .= implode( "<br />\n", $tempout );
777 * Render the array as a serie of links.
778 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
779 * @param &skin Object: skin passed by reference
780 * @return String separated by >, terminate with "\n"
782 function drawCategoryBrowser( $tree, &$skin ) {
785 foreach ( $tree as $element => $parent ) {
786 if ( empty( $parent ) ) {
787 # element start a new list
790 # grab the others elements
791 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
794 # add our current element to the list
795 $eltitle = Title
::newFromText( $element );
796 $return .= $skin->link( $eltitle, $eltitle->getText() );
802 function getCategories() {
803 $catlinks = $this->getCategoryLinks();
805 $classes = 'catlinks';
807 global $wgOut, $wgUser;
809 // Check what we're showing
810 $allCats = $wgOut->getCategoryLinks();
811 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
812 $this->mTitle
->getNamespace() == NS_CATEGORY
;
814 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
815 $classes .= ' catlinks-allhidden';
818 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
821 function getQuickbarCompensator( $rows = 1 ) {
822 return "<td width='152' rowspan='{$rows}'> </td>";
826 * This runs a hook to allow extensions placing their stuff after content
827 * and article metadata (e.g. categories).
828 * Note: This function has nothing to do with afterContent().
830 * This hook is placed here in order to allow using the same hook for all
831 * skins, both the SkinTemplate based ones and the older ones, which directly
832 * use this class to get their data.
834 * The output of this function gets processed in SkinTemplate::outputPage() for
835 * the SkinTemplate based skins, all other skins should directly echo it.
837 * Returns an empty string by default, if not changed by any hook function.
839 protected function afterContentHook() {
842 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
843 // adding just some spaces shouldn't toggle the output
844 // of the whole <div/>, so we use trim() here
845 if ( trim( $data ) != '' ) {
846 // Doing this here instead of in the skins to
847 // ensure that the div has the same ID in all
849 $data = "<div id='mw-data-after-content'>\n" .
854 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
861 * Generate debug data HTML for displaying at the bottom of the main content
863 * @return String HTML containing debug data, if enabled (otherwise empty).
865 protected function generateDebugHTML() {
866 global $wgShowDebug, $wgOut;
868 if ( $wgShowDebug ) {
869 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
870 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
871 $listInternals . "</ul>\n";
877 private function formatDebugHTML( $debugText ) {
878 $lines = explode( "\n", $debugText );
882 foreach ( $lines as $line ) {
883 $display = ltrim( $line );
884 $ident = strlen( $line ) - strlen( $display );
885 $diff = $ident - $curIdent;
887 if ( $display == '' ) {
888 $display = "\xc2\xa0";
891 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
894 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
896 $display = htmlspecialchars( $display );
900 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
901 } elseif ( $diff == 0 ) {
902 $ret .= "</li><li>\n";
904 $ret .= str_repeat( "<ul><li>\n", $diff );
906 $ret .= $display . "\n";
911 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
917 * This gets called shortly before the </body> tag.
918 * @return String HTML to be put before </body>
920 function afterContent() {
921 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
922 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
926 * This gets called shortly before the </body> tag.
927 * @param $out OutputPage object
928 * @return String HTML-wrapped JS code to be put before </body>
930 function bottomScripts( $out ) {
931 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
932 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
934 return $bottomScriptText;
937 /** @return string Retrievied from HTML text */
938 function printSource() {
939 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
940 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
943 function printFooter() {
944 return "<p>" . $this->printSource() .
945 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
948 /** overloaded by derived classes */
949 function doAfterContent() {
950 return '</div></div>';
953 function pageTitleLinks() {
954 global $wgOut, $wgUser, $wgRequest, $wgLang;
956 $oldid = $wgRequest->getVal( 'oldid' );
957 $diff = $wgRequest->getVal( 'diff' );
958 $action = $wgRequest->getText( 'action' );
960 $s[] = $this->printableLink();
961 $disclaimer = $this->disclaimerLink(); # may be empty
967 $privacy = $this->privacyLink(); # may be empty too
973 if ( $wgOut->isArticleRelated() ) {
974 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
975 $name = $this->mTitle
->getDBkey();
976 $image = wfFindFile( $this->mTitle
);
979 $link = htmlspecialchars( $image->getURL() );
980 $style = $this->getInternalLinkAttributes( $link, $name );
981 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
986 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
989 wfMsg( 'currentrev' ),
992 array( 'known', 'noclasses' )
996 if ( $wgUser->getNewtalk() ) {
997 # do not show "You have new messages" text when we are viewing our
999 if ( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1001 $wgUser->getTalkPage(),
1002 wfMsgHtml( 'newmessageslink' ),
1004 array( 'redirect' => 'no' ),
1005 array( 'known', 'noclasses' )
1009 $wgUser->getTalkPage(),
1010 wfMsgHtml( 'newmessagesdifflink' ),
1012 array( 'diff' => 'cur' ),
1013 array( 'known', 'noclasses' )
1015 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1017 $wgOut->setSquidMaxage( 0 );
1018 $wgOut->enableClientCache( false );
1022 $undelete = $this->getUndeleteLink();
1024 if ( !empty( $undelete ) ) {
1028 return $wgLang->pipeList( $s );
1031 function getUndeleteLink() {
1032 global $wgUser, $wgLang, $wgRequest;
1034 $action = $wgRequest->getVal( 'action', 'view' );
1036 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1037 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1038 $n = $this->mTitle
->isDeleted();
1041 if ( $wgUser->isAllowed( 'undelete' ) ) {
1042 $msg = 'thisisdeleted';
1044 $msg = 'viewdeleted';
1050 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1051 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1054 array( 'known', 'noclasses' )
1063 function printableLink() {
1064 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1068 if ( !$wgOut->isPrintable() ) {
1069 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1070 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1073 if ( $wgOut->isSyndicated() ) {
1074 foreach ( $wgFeedClasses as $format => $class ) {
1075 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1076 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1077 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1080 return $wgLang->pipeList( $s );
1084 * Gets the h1 element with the page title.
1087 function pageTitle() {
1089 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1093 function pageSubtitle() {
1096 $sub = $wgOut->getSubtitle();
1099 global $wgExtraSubtitle;
1100 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1103 $subpages = $this->subPageSubtitle();
1104 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1105 $s = "<p class='subtitle'>{$sub}</p>\n";
1110 function subPageSubtitle() {
1113 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) {
1119 if ( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1120 $ptext = $this->mTitle
->getPrefixedText();
1121 if ( preg_match( '/\//', $ptext ) ) {
1122 $links = explode( '/', $ptext );
1123 array_pop( $links );
1128 foreach ( $links as $link ) {
1129 $growinglink .= $link;
1131 $linkObj = Title
::newFromText( $growinglink );
1133 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1134 $getlink = $this->link(
1136 htmlspecialchars( $display ),
1139 array( 'known', 'noclasses' )
1145 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1147 $subpages .= '< ';
1150 $subpages .= $getlink;
1155 $growinglink .= '/';
1164 * Returns true if the IP should be shown in the header
1166 function showIPinHeader() {
1167 global $wgShowIPinHeader;
1168 return $wgShowIPinHeader && session_id() != '';
1171 function nameAndLogin() {
1172 global $wgUser, $wgLang, $wgContLang;
1174 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1178 if ( $wgUser->isAnon() ) {
1179 if ( $this->showIPinHeader() ) {
1182 $talkLink = $this->link( $wgUser->getTalkPage(),
1183 $wgLang->getNsText( NS_TALK
) );
1185 $ret .= "$name ($talkLink)";
1187 $ret .= wfMsg( 'notloggedin' );
1190 $returnTo = $this->mTitle
->getPrefixedDBkey();
1193 if ( $logoutPage != $returnTo ) {
1194 $query['returnto'] = $returnTo;
1197 $loginlink = $wgUser->isAllowed( 'createaccount' )
1198 ?
'nav-login-createaccount'
1200 $ret .= "\n<br />" . $this->link(
1201 SpecialPage
::getTitleFor( 'Userlogin' ),
1202 wfMsg( $loginlink ), array(), $query
1205 $returnTo = $this->mTitle
->getPrefixedDBkey();
1206 $talkLink = $this->link( $wgUser->getTalkPage(),
1207 $wgLang->getNsText( NS_TALK
) );
1209 $ret .= $this->link( $wgUser->getUserPage(),
1210 htmlspecialchars( $wgUser->getName() ) );
1211 $ret .= " ($talkLink)<br />";
1212 $ret .= $wgLang->pipeList( array(
1214 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1215 array(), array( 'returnto' => $returnTo )
1217 $this->specialLink( 'Preferences' ),
1221 $ret = $wgLang->pipeList( array(
1224 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1232 function getSearchLink() {
1233 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1234 return $searchPage->getLocalURL();
1237 function escapeSearchLink() {
1238 return htmlspecialchars( $this->getSearchLink() );
1241 function searchForm() {
1242 global $wgRequest, $wgUseTwoButtonsSearchForm;
1244 $search = $wgRequest->getText( 'search' );
1246 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
1247 . $this->escapeSearchLink() . "\">\n"
1248 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
1249 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1250 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1252 if ( $wgUseTwoButtonsSearchForm ) {
1253 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1255 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1260 // Ensure unique id's for search boxes made after the first
1261 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1266 function topLinks() {
1270 $this->mainPageLink(),
1271 $this->specialLink( 'Recentchanges' )
1274 if ( $wgOut->isArticleRelated() ) {
1275 $s[] = $this->editThisPage();
1276 $s[] = $this->historyLink();
1279 # Many people don't like this dropdown box
1280 # $s[] = $this->specialPagesList();
1282 if ( $this->variantLinks() ) {
1283 $s[] = $this->variantLinks();
1286 if ( $this->extensionTabLinks() ) {
1287 $s[] = $this->extensionTabLinks();
1290 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1291 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1295 * Compatibility for extensions adding functionality through tabs.
1296 * Eventually these old skins should be replaced with SkinTemplate-based
1300 function extensionTabLinks() {
1304 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1305 foreach ( $tabs as $tab ) {
1306 $s[] = Xml
::element( 'a',
1307 array( 'href' => $tab['href'] ),
1311 if ( count( $s ) ) {
1314 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1315 $out .= $wgLang->pipeList( $s );
1322 * Language/charset variant links for classic-style skins
1325 function variantLinks() {
1328 /* show links to different language variants */
1329 global $wgDisableLangConversion, $wgLang, $wgContLang;
1331 $variants = $wgContLang->getVariants();
1333 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1334 foreach ( $variants as $code ) {
1335 $varname = $wgContLang->getVariantname( $code );
1337 if ( $varname == 'disable' ) {
1340 $s = $wgLang->pipeList( array(
1342 '<a href="' . $this->mTitle
->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1350 function bottomLinks() {
1351 global $wgOut, $wgUser, $wgUseTrackbacks;
1352 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1355 if ( $wgOut->isArticleRelated() ) {
1356 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1358 if ( $wgUser->isLoggedIn() ) {
1359 $element[] = $this->watchThisPage();
1362 $element[] = $this->talkLink();
1363 $element[] = $this->historyLink();
1364 $element[] = $this->whatLinksHere();
1365 $element[] = $this->watchPageLinksLink();
1367 if ( $wgUseTrackbacks ) {
1368 $element[] = $this->trackbackLink();
1372 $this->mTitle
->getNamespace() == NS_USER ||
1373 $this->mTitle
->getNamespace() == NS_USER_TALK
1375 $id = User
::idFromName( $this->mTitle
->getText() );
1376 $ip = User
::isIP( $this->mTitle
->getText() );
1378 # Both anons and non-anons have contributions list
1380 $element[] = $this->userContribsLink();
1383 if ( $this->showEmailUser( $id ) ) {
1384 $element[] = $this->emailUserLink();
1388 $s = implode( $element, $sep );
1390 if ( $this->mTitle
->getArticleId() ) {
1393 // Delete/protect/move links for privileged users
1394 if ( $wgUser->isAllowed( 'delete' ) ) {
1395 $s .= $this->deleteThisPage();
1398 if ( $wgUser->isAllowed( 'protect' ) ) {
1399 $s .= $sep . $this->protectThisPage();
1402 if ( $wgUser->isAllowed( 'move' ) ) {
1403 $s .= $sep . $this->moveThisPage();
1407 $s .= "<br />\n" . $this->otherLanguages();
1413 function pageStats() {
1414 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1415 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1417 $oldid = $wgRequest->getVal( 'oldid' );
1418 $diff = $wgRequest->getVal( 'diff' );
1420 if ( !$wgOut->isArticle() ) {
1424 if ( !$wgArticle instanceof Article
) {
1428 if ( isset( $oldid ) ||
isset( $diff ) ) {
1432 if ( 0 == $wgArticle->getID() ) {
1438 if ( !$wgDisableCounters ) {
1439 $count = $wgLang->formatNum( $wgArticle->getCount() );
1442 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1446 if ( $wgMaxCredits != 0 ) {
1447 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1449 $s .= $this->lastModified();
1452 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1453 $dbr = wfGetDB( DB_SLAVE
);
1454 $res = $dbr->select(
1456 array( 'COUNT(*) AS n' ),
1458 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ),
1459 'wl_namespace' => $this->mTitle
->getNamespace()
1463 $x = $dbr->fetchObject( $res );
1465 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1466 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1470 return $s . ' ' . $this->getCopyright();
1473 function getCopyright( $type = 'detect' ) {
1474 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1476 if ( $type == 'detect' ) {
1477 $diff = $wgRequest->getVal( 'diff' );
1478 $isCur = $wgArticle && $wgArticle->isCurrent();
1480 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1487 if ( $type == 'history' ) {
1488 $msg = 'history_copyright';
1495 if ( $wgRightsPage ) {
1496 $title = Title
::newFromText( $wgRightsPage );
1497 $link = $this->linkKnown( $title, $wgRightsText );
1498 } elseif ( $wgRightsUrl ) {
1499 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1500 } elseif ( $wgRightsText ) {
1501 $link = $wgRightsText;
1507 // Allow for site and per-namespace customization of copyright notice.
1510 if ( isset( $wgArticle ) ) {
1511 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1514 if ( $forContent ) {
1515 $out .= wfMsgForContent( $msg, $link );
1517 $out .= wfMsg( $msg, $link );
1523 function getCopyrightIcon() {
1524 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1528 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1529 $out = $wgCopyrightIcon;
1530 } elseif ( $wgRightsIcon ) {
1531 $icon = htmlspecialchars( $wgRightsIcon );
1533 if ( $wgRightsUrl ) {
1534 $url = htmlspecialchars( $wgRightsUrl );
1535 $out .= '<a href="' . $url . '">';
1538 $text = htmlspecialchars( $wgRightsText );
1539 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1541 if ( $wgRightsUrl ) {
1550 * Gets the powered by MediaWiki icon.
1553 function getPoweredBy() {
1554 global $wgStylePath;
1556 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1557 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1562 function lastModified() {
1563 global $wgLang, $wgArticle;
1565 if ( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest() ) {
1566 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1568 $timestamp = $wgArticle->getTimestamp();
1572 $d = $wgLang->date( $timestamp, true );
1573 $t = $wgLang->time( $timestamp, true );
1574 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1579 if ( wfGetLB()->getLaggedSlaveMode() ) {
1580 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1586 function logoText( $align = '' ) {
1587 if ( $align != '' ) {
1588 $a = " align='{$align}'";
1593 $mp = wfMsg( 'mainpage' );
1594 $mptitle = Title
::newMainPage();
1595 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1597 $logourl = $this->getLogo();
1598 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1604 * Show a drop-down box of special pages
1606 function specialPagesList() {
1607 global $wgContLang, $wgServer, $wgRedirectScript;
1609 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1611 foreach ( $pages as $name => $page ) {
1612 $pages[$name] = $page->getDescription();
1615 $go = wfMsg( 'go' );
1616 $sp = wfMsg( 'specialpages' );
1617 $spp = $wgContLang->specialPage( 'Specialpages' );
1619 $s = '<form id="specialpages" method="get" ' .
1620 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1621 $s .= "<select name=\"wpDropdown\">\n";
1622 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1625 foreach ( $pages as $name => $desc ) {
1626 $p = $wgContLang->specialPage( $name );
1627 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1630 $s .= "</select>\n";
1631 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1638 * Gets the link to the wiki's main page.
1641 function mainPageLink() {
1643 Title
::newMainPage(),
1644 wfMsg( 'mainpage' ),
1647 array( 'known', 'noclasses' )
1653 private function footerLink( $desc, $page ) {
1654 // if the link description has been set to "-" in the default language,
1655 if ( wfMsgForContent( $desc ) == '-' ) {
1656 // then it is disabled, for all languages.
1659 // Otherwise, we display the link for the user, described in their
1660 // language (which may or may not be the same as the default language),
1661 // but we make the link target be the one site-wide page.
1662 $title = Title
::newFromText( wfMsgForContent( $page ) );
1664 return $this->linkKnown(
1666 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1672 * Gets the link to the wiki's privacy policy page.
1674 function privacyLink() {
1675 return $this->footerLink( 'privacy', 'privacypage' );
1679 * Gets the link to the wiki's about page.
1681 function aboutLink() {
1682 return $this->footerLink( 'aboutsite', 'aboutpage' );
1686 * Gets the link to the wiki's general disclaimers page.
1688 function disclaimerLink() {
1689 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1692 function editThisPage() {
1695 if ( !$wgOut->isArticleRelated() ) {
1696 $s = wfMsg( 'protectedpage' );
1698 if ( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1699 $t = wfMsg( 'editthispage' );
1700 } elseif ( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1701 $t = wfMsg( 'create-this-page' );
1703 $t = wfMsg( 'viewsource' );
1710 $this->editUrlOptions(),
1711 array( 'known', 'noclasses' )
1719 * Return URL options for the 'edit page' link.
1720 * This may include an 'oldid' specifier, if the current page view is such.
1725 function editUrlOptions() {
1728 $options = array( 'action' => 'edit' );
1730 if ( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1731 $options['oldid'] = intval( $this->mRevisionId
);
1737 function deleteThisPage() {
1738 global $wgUser, $wgRequest;
1740 $diff = $wgRequest->getVal( 'diff' );
1742 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1743 $t = wfMsg( 'deletethispage' );
1749 array( 'action' => 'delete' ),
1750 array( 'known', 'noclasses' )
1759 function protectThisPage() {
1760 global $wgUser, $wgRequest;
1762 $diff = $wgRequest->getVal( 'diff' );
1764 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1765 if ( $this->mTitle
->isProtected() ) {
1766 $text = wfMsg( 'unprotectthispage' );
1767 $query = array( 'action' => 'unprotect' );
1769 $text = wfMsg( 'protectthispage' );
1770 $query = array( 'action' => 'protect' );
1778 array( 'known', 'noclasses' )
1787 function watchThisPage() {
1789 ++
$this->mWatchLinkNum
;
1791 if ( $wgOut->isArticleRelated() ) {
1792 if ( $this->mTitle
->userIsWatching() ) {
1793 $text = wfMsg( 'unwatchthispage' );
1794 $query = array( 'action' => 'unwatch' );
1795 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1797 $text = wfMsg( 'watchthispage' );
1798 $query = array( 'action' => 'watch' );
1799 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1805 array( 'id' => $id ),
1807 array( 'known', 'noclasses' )
1810 $s = wfMsg( 'notanarticle' );
1816 function moveThisPage() {
1817 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1819 SpecialPage
::getTitleFor( 'Movepage' ),
1820 wfMsg( 'movethispage' ),
1822 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1823 array( 'known', 'noclasses' )
1826 // no message if page is protected - would be redundant
1831 function historyLink() {
1834 wfMsgHtml( 'history' ),
1835 array( 'rel' => 'archives' ),
1836 array( 'action' => 'history' )
1840 function whatLinksHere() {
1842 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1843 wfMsgHtml( 'whatlinkshere' ),
1846 array( 'known', 'noclasses' )
1850 function userContribsLink() {
1852 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1853 wfMsgHtml( 'contributions' ),
1856 array( 'known', 'noclasses' )
1860 function showEmailUser( $id ) {
1862 $targetUser = User
::newFromId( $id );
1863 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1864 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1867 function emailUserLink() {
1869 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1870 wfMsg( 'emailuser' ),
1873 array( 'known', 'noclasses' )
1877 function watchPageLinksLink() {
1880 if ( !$wgOut->isArticleRelated() ) {
1881 return '(' . wfMsg( 'notanarticle' ) . ')';
1884 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1885 wfMsg( 'recentchangeslinked-toolbox' ),
1888 array( 'known', 'noclasses' )
1893 function trackbackLink() {
1894 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1895 . wfMsg( 'trackbacklink' ) . '</a>';
1898 function otherLanguages() {
1899 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1901 if ( $wgHideInterlanguageLinks ) {
1905 $a = $wgOut->getLanguageLinks();
1907 if ( 0 == count( $a ) ) {
1911 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1914 if ( $wgContLang->isRTL() ) {
1915 $s .= '<span dir="LTR">';
1918 foreach ( $a as $l ) {
1920 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1925 $nt = Title
::newFromText( $l );
1926 $url = $nt->escapeFullURL();
1927 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1928 $title = htmlspecialchars( $nt->getText() );
1930 if ( $text == '' ) {
1934 $style = $this->getExternalLinkAttributes();
1935 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1938 if ( $wgContLang->isRTL() ) {
1945 function talkLink() {
1946 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1947 # No discussion links for special pages
1951 $linkOptions = array();
1953 if ( $this->mTitle
->isTalkPage() ) {
1954 $link = $this->mTitle
->getSubjectPage();
1955 switch( $link->getNamespace() ) {
1957 $text = wfMsg( 'articlepage' );
1960 $text = wfMsg( 'userpage' );
1963 $text = wfMsg( 'projectpage' );
1966 $text = wfMsg( 'imagepage' );
1967 # Make link known if image exists, even if the desc. page doesn't.
1968 if ( wfFindFile( $link ) )
1969 $linkOptions[] = 'known';
1972 $text = wfMsg( 'mediawikipage' );
1975 $text = wfMsg( 'templatepage' );
1978 $text = wfMsg( 'viewhelppage' );
1981 $text = wfMsg( 'categorypage' );
1984 $text = wfMsg( 'articlepage' );
1987 $link = $this->mTitle
->getTalkPage();
1988 $text = wfMsg( 'talkpage' );
1991 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1996 function commentLink() {
1999 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
2003 # __NEWSECTIONLINK___ changes behaviour here
2004 # If it is present, the link points to this page, otherwise
2005 # it points to the talk page
2006 if ( $this->mTitle
->isTalkPage() ) {
2007 $title = $this->mTitle
;
2008 } elseif ( $wgOut->showNewSectionLink() ) {
2009 $title = $this->mTitle
;
2011 $title = $this->mTitle
->getTalkPage();
2016 wfMsg( 'postcomment' ),
2022 array( 'known', 'noclasses' )
2026 function getUploadLink() {
2027 global $wgUploadNavigationUrl;
2029 if ( $wgUploadNavigationUrl ) {
2030 # Using an empty class attribute to avoid automatic setting of "external" class
2031 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
2034 SpecialPage
::getTitleFor( 'Upload' ),
2035 wfMsgHtml( 'upload' ),
2038 array( 'known', 'noclasses' )
2043 /* these are used extensively in SkinTemplate, but also some other places */
2044 static function makeMainPageUrl( $urlaction = '' ) {
2045 $title = Title
::newMainPage();
2046 self
::checkTitle( $title, '' );
2048 return $title->getLocalURL( $urlaction );
2051 static function makeSpecialUrl( $name, $urlaction = '' ) {
2052 $title = SpecialPage
::getTitleFor( $name );
2053 return $title->getLocalURL( $urlaction );
2056 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2057 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
2058 return $title->getLocalURL( $urlaction );
2061 static function makeI18nUrl( $name, $urlaction = '' ) {
2062 $title = Title
::newFromText( wfMsgForContent( $name ) );
2063 self
::checkTitle( $title, $name );
2064 return $title->getLocalURL( $urlaction );
2067 static function makeUrl( $name, $urlaction = '' ) {
2068 $title = Title
::newFromText( $name );
2069 self
::checkTitle( $title, $name );
2071 return $title->getLocalURL( $urlaction );
2075 * If url string starts with http, consider as external URL, else
2078 static function makeInternalOrExternalUrl( $name ) {
2079 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2082 return self
::makeUrl( $name );
2086 # this can be passed the NS number as defined in Language.php
2087 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
2088 $title = Title
::makeTitleSafe( $namespace, $name );
2089 self
::checkTitle( $title, $name );
2091 return $title->getLocalURL( $urlaction );
2094 /* these return an array with the 'href' and boolean 'exists' */
2095 static function makeUrlDetails( $name, $urlaction = '' ) {
2096 $title = Title
::newFromText( $name );
2097 self
::checkTitle( $title, $name );
2100 'href' => $title->getLocalURL( $urlaction ),
2101 'exists' => $title->getArticleID() != 0,
2106 * Make URL details where the article exists (or at least it's convenient to think so)
2108 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2109 $title = Title
::newFromText( $name );
2110 self
::checkTitle( $title, $name );
2113 'href' => $title->getLocalURL( $urlaction ),
2118 # make sure we have some title to operate on
2119 static function checkTitle( &$title, $name ) {
2120 if ( !is_object( $title ) ) {
2121 $title = Title
::newFromText( $name );
2122 if ( !is_object( $title ) ) {
2123 $title = Title
::newFromText( '--error: link target missing--' );
2129 * Build an array that represents the sidebar(s), the navigation bar among them
2133 function buildSidebar() {
2134 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2136 wfProfileIn( __METHOD__
);
2138 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2140 if ( $wgEnableSidebarCache ) {
2141 $cachedsidebar = $parserMemc->get( $key );
2142 if ( $cachedsidebar ) {
2143 wfProfileOut( __METHOD__
);
2144 return $cachedsidebar;
2149 $this->addToSidebar( $bar, 'sidebar' );
2151 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2152 if ( $wgEnableSidebarCache ) {
2153 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2156 wfProfileOut( __METHOD__
);
2160 * Add content from a sidebar system message
2161 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2163 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2165 * @param &$bar array
2166 * @param $message String
2168 function addToSidebar( &$bar, $message ) {
2169 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2173 * Add content from plain text
2175 * @param &$bar array
2176 * @param $text string
2178 function addToSidebarPlain( &$bar, $text ) {
2179 $lines = explode( "\n", $text );
2180 $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.
2184 foreach ( $lines as $line ) {
2185 if ( strpos( $line, '*' ) !== 0 ) {
2189 if ( strpos( $line, '**' ) !== 0 ) {
2190 $heading = trim( $line, '* ' );
2191 if ( !array_key_exists( $heading, $bar ) ) {
2192 $bar[$heading] = array();
2195 $line = trim( $line, '* ' );
2197 if ( strpos( $line, '|' ) !== false ) { // sanity check
2198 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2199 $link = wfMsgForContent( $line[0] );
2201 if ( $link == '-' ) {
2205 $text = wfMsgExt( $line[1], 'parsemag' );
2207 if ( wfEmptyMsg( $line[1], $text ) ) {
2211 if ( wfEmptyMsg( $line[0], $link ) ) {
2215 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2218 $title = Title
::newFromText( $link );
2221 $title = $title->fixSpecialName();
2222 $href = $title->getLocalURL();
2224 $href = 'INVALID-TITLE';
2228 $bar[$heading][] = array(
2231 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2234 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2235 global $wgParser, $wgTitle;
2237 $line = substr( $line, 2, strlen( $line ) - 4 );
2239 $options = new ParserOptions();
2240 $options->setEditSection( false );
2241 $options->setInterfaceMessage( true );
2242 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $options )->getText();
2249 if ( count( $wikiBar ) > 0 ) {
2250 $bar = array_merge( $bar, $wikiBar );
2257 * Should we include common/wikiprintable.css? Skins that have their own
2258 * print stylesheet should override this and return false. (This is an
2259 * ugly hack to get Monobook to play nicely with
2260 * OutputPage::headElement().)
2264 public function commonPrintStylesheet() {
2269 * Gets new talk page messages for the current user.
2270 * @return MediaWiki message or if no new talk page messages, nothing
2272 function getNewtalks() {
2273 global $wgUser, $wgOut;
2275 $newtalks = $wgUser->getNewMessageLinks();
2278 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2279 $userTitle = $this->mUser
->getUserPage();
2280 $userTalkTitle = $userTitle->getTalkPage();
2282 if ( !$userTalkTitle->equals( $this->mTitle
) ) {
2283 $newMessagesLink = $this->link(
2285 wfMsgHtml( 'newmessageslink' ),
2287 array( 'redirect' => 'no' ),
2288 array( 'known', 'noclasses' )
2291 $newMessagesDiffLink = $this->link(
2293 wfMsgHtml( 'newmessagesdifflink' ),
2295 array( 'diff' => 'cur' ),
2296 array( 'known', 'noclasses' )
2300 'youhavenewmessages',
2302 $newMessagesDiffLink
2304 # Disable Squid cache
2305 $wgOut->setSquidMaxage( 0 );
2307 } elseif ( count( $newtalks ) ) {
2308 // _>" " for BC <= 1.16
2309 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2312 foreach ( $newtalks as $newtalk ) {
2313 $msgs[] = Xml
::element(
2315 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2318 $parts = implode( $sep, $msgs );
2319 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2320 $wgOut->setSquidMaxage( 0 );