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, $wgEnableAPI;
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 if ( $wgEnableAPI ) {
220 # Real Simple Discovery link, provides auto-discovery information
221 # for the MediaWiki API (and potentially additional custom API
222 # support such as WordPress or Twitter-compatible APIs for a
223 # blogging extension, etc)
224 $out->addLink( array(
226 'type' => 'application/rsd+xml',
227 'href' => wfExpandUrl( wfAppendQuery( wfScript( 'api' ), array( 'action' => 'rsd' ) ) ),
231 $this->addMetadataLinks( $out );
233 $this->mRevisionId
= $out->mRevisionId
;
235 $this->preloadExistence();
237 wfProfileOut( __METHOD__
);
241 * Preload the existence of three commonly-requested pages in a single query
243 function preloadExistence() {
247 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
250 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
252 } elseif ( $this->mTitle
->isTalkPage() ) {
253 $titles[] = $this->mTitle
->getSubjectPage();
255 $titles[] = $this->mTitle
->getTalkPage();
258 $lb = new LinkBatch( $titles );
259 $lb->setCaller( __METHOD__
);
264 * Adds metadata links below to the HTML output.
266 * <li>Creative Commons
267 * <br />See http://wiki.creativecommons.org/Extend_Metadata.
269 * <li>Dublin Core</li>
270 * <li>Use hreflang to specify canonical and alternate links
271 * <br />See http://www.google.com/support/webmasters/bin/answer.py?answer=189077
276 * @param $out Object: instance of OutputPage
278 function addMetadataLinks( OutputPage
$out ) {
279 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
280 global $wgDisableLangConversion, $wgDisableLangCanonical, $wgContLang;
281 global $wgRightsPage, $wgRightsUrl;
283 if ( $out->isArticleRelated() ) {
284 # note: buggy CC software only reads first "meta" link
285 if ( $wgEnableCreativeCommonsRdf ) {
286 $out->addMetadataLink( array(
287 'title' => 'Creative Commons',
288 'type' => 'application/rdf+xml',
289 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
293 if ( $wgEnableDublinCoreRdf ) {
294 $out->addMetadataLink( array(
295 'title' => 'Dublin Core',
296 'type' => 'application/rdf+xml',
297 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
302 if ( !$wgDisableLangConversion && !$wgDisableLangCanonical
303 && $wgContLang->hasVariants() ) {
305 $urlvar = $wgContLang->getURLVariant();
308 $variants = $wgContLang->getVariants();
309 foreach ( $variants as $_v ) {
310 $out->addLink( array(
311 'rel' => 'alternate',
313 'href' => $this->mTitle
->getLocalURL( '', $_v ) )
317 $out->addLink( array(
318 'rel' => 'canonical',
319 'href' => $this->mTitle
->getFullURL() )
325 if ( $wgRightsPage ) {
326 $copy = Title
::newFromText( $wgRightsPage );
329 $copyright = $copy->getLocalURL();
333 if ( !$copyright && $wgRightsUrl ) {
334 $copyright = $wgRightsUrl;
338 $out->addLink( array(
339 'rel' => 'copyright',
340 'href' => $copyright )
346 * Set some local variables
348 protected function setMembers() {
350 $this->mUser
= $wgUser;
351 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
352 $this->usercss
= false;
357 * @param $t Title object to use
359 public function setTitle( $t ) {
364 public function getTitle() {
365 return $this->mTitle
;
369 * Outputs the HTML generated by other functions.
370 * @param $out Object: instance of OutputPage
372 function outputPage( OutputPage
$out ) {
373 global $wgDebugComments;
374 wfProfileIn( __METHOD__
);
377 $this->initPage( $out );
379 // See self::afterContentHook() for documentation
380 $afterContent = $this->afterContentHook();
382 $out->out( $out->headElement( $this ) );
384 if ( $wgDebugComments ) {
385 $out->out( "<!-- Wiki debugging output:\n" .
386 $out->mDebugtext
. "-->\n" );
389 $out->out( $this->beforeContent() );
391 $out->out( $out->mBodytext
. "\n" );
393 $out->out( $this->afterContent() );
395 $out->out( $afterContent );
397 $out->out( $this->bottomScripts( $out ) );
399 $out->out( wfReportTime() );
401 $out->out( "\n</body></html>" );
402 wfProfileOut( __METHOD__
);
405 static function makeVariablesScript( $data ) {
407 return Html
::inlineScript(
408 ResourceLoader
::makeLoaderConditionalScript( ResourceLoader
::makeConfigSetScript( $data ) )
416 * Make a <script> tag containing global variables
417 * @param $skinName string Name of the skin
418 * The odd calling convention is for backwards compatibility
419 * @todo FIXME: Make this not depend on $wgTitle!
421 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
422 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
424 static function makeGlobalVariablesScript( $skinName ) {
425 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
427 $ns = $wgTitle->getNamespace();
428 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
430 'wgCanonicalNamespace' => $nsname,
431 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
432 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
433 'wgNamespaceNumber' => $wgTitle->getNamespace(),
434 'wgPageName' => $wgTitle->getPrefixedDBKey(),
435 'wgTitle' => $wgTitle->getText(),
436 'wgAction' => $wgRequest->getText( 'action', 'view' ),
437 'wgArticleId' => $wgTitle->getArticleId(),
438 'wgIsArticle' => $wgOut->isArticle(),
439 'wgUserName' => $wgUser->isAnon() ?
null : $wgUser->getName(),
440 'wgUserGroups' => $wgUser->getEffectiveGroups(),
441 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
442 'wgCategories' => $wgOut->getCategories(),
444 foreach ( $wgRestrictionTypes as $type ) {
445 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
447 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
448 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
451 // Allow extensions to add their custom variables to the global JS variables
452 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
454 return self
::makeVariablesScript( $vars );
458 * To make it harder for someone to slip a user a fake
459 * user-JavaScript or user-CSS preview, a random token
460 * is associated with the login session. If it's not
461 * passed back with the preview request, we won't render
464 * @param $action String: 'edit', 'submit' etc.
467 public function userCanPreview( $action ) {
468 global $wgRequest, $wgUser;
470 if ( $action != 'submit' ) {
473 if ( !$wgRequest->wasPosted() ) {
476 if ( !$this->mTitle
->userCanEditCssSubpage() ) {
479 if ( !$this->mTitle
->userCanEditJsSubpage() ) {
483 return $wgUser->matchEditToken(
484 $wgRequest->getVal( 'wpEditToken' ) );
488 * Generated JavaScript action=raw&gen=js
489 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
490 * nated together. For some bizarre reason, it does *not* return any
491 * custom user JS from subpages. Huh?
493 * There's absolutely no reason to have separate Monobook/Common JSes.
494 * Any JS that cares can just check the skin variable generated at the
495 * top. For now Monobook.js will be maintained, but it should be consi-
498 * @param $skinName String: If set, overrides the skin name
501 public function generateUserJs( $skinName = null ) {
503 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
509 * Generate user stylesheet for action=raw&gen=css
511 public function generateUserStylesheet() {
513 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
519 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
520 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
522 protected function reallyGenerateUserStylesheet() {
524 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
532 function setupUserCss( OutputPage
$out ) {
534 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
536 wfProfileIn( __METHOD__
);
538 $this->setupSkinUserCss( $out );
542 'maxage' => $wgSquidMaxage,
545 // Add any extension CSS
546 foreach ( $out->getExtStyle() as $url ) {
547 $out->addStyle( $url );
550 // Per-site custom styles
551 if ( $wgUseSiteCss ) {
552 $out->addModuleStyles( 'site' );
555 // Per-user custom styles
556 if ( $wgAllowUserCss ) {
557 if ( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
558 // @FIXME: properly escape the cdata!
559 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
561 $out->addModuleStyles( 'user' );
565 // Per-user preference styles
566 if ( $wgAllowUserCssPrefs ) {
567 $out->addModuleStyles( 'user.options' );
570 wfProfileOut( __METHOD__
);
574 * Get the query to generate a dynamic stylesheet
578 public static function getDynamicStylesheetQuery() {
579 global $wgSquidMaxage;
583 'maxage' => $wgSquidMaxage,
584 'usemsgcache' => 'yes',
585 'ctype' => 'text/css',
586 'smaxage' => $wgSquidMaxage,
591 * Add skin specific stylesheets
592 * @param $out OutputPage
594 function setupSkinUserCss( OutputPage
$out ) {
595 $out->addModuleStyles( 'mediawiki.legacy.shared' );
596 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
597 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
598 $out->addStyle( $this->getStylesheet() );
599 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
602 function getPageClasses( $title ) {
603 $numeric = 'ns-' . $title->getNamespace();
605 if ( $title->getNamespace() == NS_SPECIAL
) {
606 $type = 'ns-special';
607 } elseif ( $title->isTalkPage() ) {
610 $type = 'ns-subject';
613 $name = Sanitizer
::escapeClass( 'page-' . $title->getPrefixedText() );
615 return "$numeric $type $name";
619 * This will be called by OutputPage::headElement when it is creating the
620 * <body> tag, skins can override it if they have a need to add in any
621 * body attributes or classes of their own.
623 function addToBodyAttributes( $out, &$bodyAttrs ) {
624 // does nothing by default
636 * This will be called immediately after the <body> tag. Split into
637 * two functions to make it easier to subclass.
639 function beforeContent() {
640 return $this->doBeforeContent();
643 function doBeforeContent() {
645 wfProfileIn( __METHOD__
);
648 $qb = $this->qbSetting();
650 $langlinks = $this->otherLanguages();
657 $borderhack = 'class="top"';
660 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
661 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
663 $shove = ( $qb != 0 );
664 $left = ( $qb == 1 ||
$qb == 3 );
666 if ( $wgContLang->isRTL() ) {
671 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
672 $this->logoText() . '</td>';
674 $s .= $this->getQuickbarCompensator( $rows );
677 $l = $wgContLang->alignStart();
678 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
680 $s .= $this->topLinks();
681 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
683 $r = $wgContLang->alignEnd();
684 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
685 $s .= $this->nameAndLogin();
686 $s .= "\n<br />" . $this->searchForm() . '</td>';
689 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
692 if ( $shove && !$left ) { # Right
693 $s .= $this->getQuickbarCompensator( $rows );
696 $s .= "</tr>\n</table>\n</div>\n";
697 $s .= "\n<div id='article'>\n";
699 $notice = wfGetSiteNotice();
702 $s .= "\n<div id='siteNotice'>$notice</div>\n";
704 $s .= $this->pageTitle();
705 $s .= $this->pageSubtitle();
706 $s .= $this->getCategories();
708 wfProfileOut( __METHOD__
);
712 function getCategoryLinks() {
713 global $wgOut, $wgUseCategoryBrowser;
714 global $wgContLang, $wgUser;
716 if ( count( $wgOut->mCategoryLinks
) == 0 ) {
721 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
723 // Use Unicode bidi embedding override characters,
724 // to make sure links don't smash each other up in ugly ways.
725 $dir = $wgContLang->getDir();
726 $embed = "<span dir='$dir'>";
729 $allCats = $wgOut->getCategoryLinks();
731 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
733 if ( !empty( $allCats['normal'] ) ) {
734 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
736 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
737 $s .= '<div id="mw-normal-catlinks">' .
738 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
739 . $colon . $t . '</div>';
743 if ( isset( $allCats['hidden'] ) ) {
744 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
745 $class = 'mw-hidden-cats-user-shown';
746 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
747 $class = 'mw-hidden-cats-ns-shown';
749 $class = 'mw-hidden-cats-hidden';
752 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
753 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
754 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
758 # optional 'dmoz-like' category browser. Will be shown under the list
759 # of categories an article belong to
760 if ( $wgUseCategoryBrowser ) {
761 $s .= '<br /><hr />';
763 # get a big array of the parents tree
764 $parenttree = $this->mTitle
->getParentCategoryTree();
765 # Skin object passed by reference cause it can not be
766 # accessed under the method subfunction drawCategoryBrowser
767 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
768 # Clean out bogus first entry and sort them
769 unset( $tempout[0] );
771 # Output one per line
772 $s .= implode( "<br />\n", $tempout );
779 * Render the array as a serie of links.
780 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
781 * @param &skin Object: skin passed by reference
782 * @return String separated by >, terminate with "\n"
784 function drawCategoryBrowser( $tree, &$skin ) {
787 foreach ( $tree as $element => $parent ) {
788 if ( empty( $parent ) ) {
789 # element start a new list
792 # grab the others elements
793 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
796 # add our current element to the list
797 $eltitle = Title
::newFromText( $element );
798 $return .= $skin->link( $eltitle, $eltitle->getText() );
804 function getCategories() {
805 $catlinks = $this->getCategoryLinks();
807 $classes = 'catlinks';
809 global $wgOut, $wgUser;
811 // Check what we're showing
812 $allCats = $wgOut->getCategoryLinks();
813 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
814 $this->mTitle
->getNamespace() == NS_CATEGORY
;
816 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
817 $classes .= ' catlinks-allhidden';
820 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
823 function getQuickbarCompensator( $rows = 1 ) {
824 return "<td width='152' rowspan='{$rows}'> </td>";
828 * This runs a hook to allow extensions placing their stuff after content
829 * and article metadata (e.g. categories).
830 * Note: This function has nothing to do with afterContent().
832 * This hook is placed here in order to allow using the same hook for all
833 * skins, both the SkinTemplate based ones and the older ones, which directly
834 * use this class to get their data.
836 * The output of this function gets processed in SkinTemplate::outputPage() for
837 * the SkinTemplate based skins, all other skins should directly echo it.
839 * Returns an empty string by default, if not changed by any hook function.
841 protected function afterContentHook() {
844 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
845 // adding just some spaces shouldn't toggle the output
846 // of the whole <div/>, so we use trim() here
847 if ( trim( $data ) != '' ) {
848 // Doing this here instead of in the skins to
849 // ensure that the div has the same ID in all
851 $data = "<div id='mw-data-after-content'>\n" .
856 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
863 * Generate debug data HTML for displaying at the bottom of the main content
865 * @return String HTML containing debug data, if enabled (otherwise empty).
867 protected function generateDebugHTML() {
868 global $wgShowDebug, $wgOut;
870 if ( $wgShowDebug ) {
871 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
872 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
873 $listInternals . "</ul>\n";
879 private function formatDebugHTML( $debugText ) {
880 $lines = explode( "\n", $debugText );
884 foreach ( $lines as $line ) {
885 $display = ltrim( $line );
886 $ident = strlen( $line ) - strlen( $display );
887 $diff = $ident - $curIdent;
889 if ( $display == '' ) {
890 $display = "\xc2\xa0";
893 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
896 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
898 $display = htmlspecialchars( $display );
902 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
903 } elseif ( $diff == 0 ) {
904 $ret .= "</li><li>\n";
906 $ret .= str_repeat( "<ul><li>\n", $diff );
908 $ret .= $display . "\n";
913 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
919 * This gets called shortly before the </body> tag.
920 * @return String HTML to be put before </body>
922 function afterContent() {
923 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
924 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
928 * This gets called shortly before the </body> tag.
929 * @param $out OutputPage object
930 * @return String HTML-wrapped JS code to be put before </body>
932 function bottomScripts( $out ) {
933 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
934 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
936 return $bottomScriptText;
939 /** @return string Retrievied from HTML text */
940 function printSource() {
941 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
942 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
945 function printFooter() {
946 return "<p>" . $this->printSource() .
947 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
950 /** overloaded by derived classes */
951 function doAfterContent() {
952 return '</div></div>';
955 function pageTitleLinks() {
956 global $wgOut, $wgUser, $wgRequest, $wgLang;
958 $oldid = $wgRequest->getVal( 'oldid' );
959 $diff = $wgRequest->getVal( 'diff' );
960 $action = $wgRequest->getText( 'action' );
962 $s[] = $this->printableLink();
963 $disclaimer = $this->disclaimerLink(); # may be empty
969 $privacy = $this->privacyLink(); # may be empty too
975 if ( $wgOut->isArticleRelated() ) {
976 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
977 $name = $this->mTitle
->getDBkey();
978 $image = wfFindFile( $this->mTitle
);
981 $link = htmlspecialchars( $image->getURL() );
982 $style = $this->getInternalLinkAttributes( $link, $name );
983 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
988 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
991 wfMsg( 'currentrev' ),
994 array( 'known', 'noclasses' )
998 if ( $wgUser->getNewtalk() ) {
999 # do not show "You have new messages" text when we are viewing our
1001 if ( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1003 $wgUser->getTalkPage(),
1004 wfMsgHtml( 'newmessageslink' ),
1006 array( 'redirect' => 'no' ),
1007 array( 'known', 'noclasses' )
1011 $wgUser->getTalkPage(),
1012 wfMsgHtml( 'newmessagesdifflink' ),
1014 array( 'diff' => 'cur' ),
1015 array( 'known', 'noclasses' )
1017 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1019 $wgOut->setSquidMaxage( 0 );
1020 $wgOut->enableClientCache( false );
1024 $undelete = $this->getUndeleteLink();
1026 if ( !empty( $undelete ) ) {
1030 return $wgLang->pipeList( $s );
1033 function getUndeleteLink() {
1034 global $wgUser, $wgLang, $wgRequest;
1036 $action = $wgRequest->getVal( 'action', 'view' );
1038 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1039 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1040 $n = $this->mTitle
->isDeleted();
1043 if ( $wgUser->isAllowed( 'undelete' ) ) {
1044 $msg = 'thisisdeleted';
1046 $msg = 'viewdeleted';
1052 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1053 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1056 array( 'known', 'noclasses' )
1065 function printableLink() {
1066 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1070 if ( !$wgOut->isPrintable() ) {
1071 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1072 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1075 if ( $wgOut->isSyndicated() ) {
1076 foreach ( $wgFeedClasses as $format => $class ) {
1077 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1078 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1079 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1082 return $wgLang->pipeList( $s );
1086 * Gets the h1 element with the page title.
1089 function pageTitle() {
1091 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1095 function pageSubtitle() {
1098 $sub = $wgOut->getSubtitle();
1101 global $wgExtraSubtitle;
1102 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1105 $subpages = $this->subPageSubtitle();
1106 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1107 $s = "<p class='subtitle'>{$sub}</p>\n";
1112 function subPageSubtitle() {
1115 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) {
1121 if ( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1122 $ptext = $this->mTitle
->getPrefixedText();
1123 if ( preg_match( '/\//', $ptext ) ) {
1124 $links = explode( '/', $ptext );
1125 array_pop( $links );
1130 foreach ( $links as $link ) {
1131 $growinglink .= $link;
1133 $linkObj = Title
::newFromText( $growinglink );
1135 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1136 $getlink = $this->link(
1138 htmlspecialchars( $display ),
1141 array( 'known', 'noclasses' )
1147 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1149 $subpages .= '< ';
1152 $subpages .= $getlink;
1157 $growinglink .= '/';
1166 * Returns true if the IP should be shown in the header
1168 function showIPinHeader() {
1169 global $wgShowIPinHeader;
1170 return $wgShowIPinHeader && session_id() != '';
1173 function nameAndLogin() {
1174 global $wgUser, $wgLang, $wgContLang;
1176 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1180 if ( $wgUser->isAnon() ) {
1181 if ( $this->showIPinHeader() ) {
1184 $talkLink = $this->link( $wgUser->getTalkPage(),
1185 $wgLang->getNsText( NS_TALK
) );
1187 $ret .= "$name ($talkLink)";
1189 $ret .= wfMsg( 'notloggedin' );
1192 $returnTo = $this->mTitle
->getPrefixedDBkey();
1195 if ( $logoutPage != $returnTo ) {
1196 $query['returnto'] = $returnTo;
1199 $loginlink = $wgUser->isAllowed( 'createaccount' )
1200 ?
'nav-login-createaccount'
1202 $ret .= "\n<br />" . $this->link(
1203 SpecialPage
::getTitleFor( 'Userlogin' ),
1204 wfMsg( $loginlink ), array(), $query
1207 $returnTo = $this->mTitle
->getPrefixedDBkey();
1208 $talkLink = $this->link( $wgUser->getTalkPage(),
1209 $wgLang->getNsText( NS_TALK
) );
1211 $ret .= $this->link( $wgUser->getUserPage(),
1212 htmlspecialchars( $wgUser->getName() ) );
1213 $ret .= " ($talkLink)<br />";
1214 $ret .= $wgLang->pipeList( array(
1216 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1217 array(), array( 'returnto' => $returnTo )
1219 $this->specialLink( 'Preferences' ),
1223 $ret = $wgLang->pipeList( array(
1226 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1234 function getSearchLink() {
1235 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1236 return $searchPage->getLocalURL();
1239 function escapeSearchLink() {
1240 return htmlspecialchars( $this->getSearchLink() );
1243 function searchForm() {
1244 global $wgRequest, $wgUseTwoButtonsSearchForm;
1246 $search = $wgRequest->getText( 'search' );
1248 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
1249 . $this->escapeSearchLink() . "\">\n"
1250 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
1251 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1252 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1254 if ( $wgUseTwoButtonsSearchForm ) {
1255 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1257 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1262 // Ensure unique id's for search boxes made after the first
1263 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1268 function topLinks() {
1272 $this->mainPageLink(),
1273 $this->specialLink( 'Recentchanges' )
1276 if ( $wgOut->isArticleRelated() ) {
1277 $s[] = $this->editThisPage();
1278 $s[] = $this->historyLink();
1281 # Many people don't like this dropdown box
1282 # $s[] = $this->specialPagesList();
1284 if ( $this->variantLinks() ) {
1285 $s[] = $this->variantLinks();
1288 if ( $this->extensionTabLinks() ) {
1289 $s[] = $this->extensionTabLinks();
1292 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1293 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1297 * Compatibility for extensions adding functionality through tabs.
1298 * Eventually these old skins should be replaced with SkinTemplate-based
1302 function extensionTabLinks() {
1306 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1307 foreach ( $tabs as $tab ) {
1308 $s[] = Xml
::element( 'a',
1309 array( 'href' => $tab['href'] ),
1313 if ( count( $s ) ) {
1316 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1317 $out .= $wgLang->pipeList( $s );
1324 * Language/charset variant links for classic-style skins
1327 function variantLinks() {
1330 /* show links to different language variants */
1331 global $wgDisableLangConversion, $wgLang, $wgContLang;
1333 $variants = $wgContLang->getVariants();
1335 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1336 foreach ( $variants as $code ) {
1337 $varname = $wgContLang->getVariantname( $code );
1339 if ( $varname == 'disable' ) {
1342 $s = $wgLang->pipeList( array(
1344 '<a href="' . $this->mTitle
->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1352 function bottomLinks() {
1353 global $wgOut, $wgUser, $wgUseTrackbacks;
1354 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1357 if ( $wgOut->isArticleRelated() ) {
1358 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1360 if ( $wgUser->isLoggedIn() ) {
1361 $element[] = $this->watchThisPage();
1364 $element[] = $this->talkLink();
1365 $element[] = $this->historyLink();
1366 $element[] = $this->whatLinksHere();
1367 $element[] = $this->watchPageLinksLink();
1369 if ( $wgUseTrackbacks ) {
1370 $element[] = $this->trackbackLink();
1374 $this->mTitle
->getNamespace() == NS_USER ||
1375 $this->mTitle
->getNamespace() == NS_USER_TALK
1377 $id = User
::idFromName( $this->mTitle
->getText() );
1378 $ip = User
::isIP( $this->mTitle
->getText() );
1380 # Both anons and non-anons have contributions list
1382 $element[] = $this->userContribsLink();
1385 if ( $this->showEmailUser( $id ) ) {
1386 $element[] = $this->emailUserLink();
1390 $s = implode( $element, $sep );
1392 if ( $this->mTitle
->getArticleId() ) {
1395 // Delete/protect/move links for privileged users
1396 if ( $wgUser->isAllowed( 'delete' ) ) {
1397 $s .= $this->deleteThisPage();
1400 if ( $wgUser->isAllowed( 'protect' ) ) {
1401 $s .= $sep . $this->protectThisPage();
1404 if ( $wgUser->isAllowed( 'move' ) ) {
1405 $s .= $sep . $this->moveThisPage();
1409 $s .= "<br />\n" . $this->otherLanguages();
1415 function pageStats() {
1416 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1417 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1419 $oldid = $wgRequest->getVal( 'oldid' );
1420 $diff = $wgRequest->getVal( 'diff' );
1422 if ( !$wgOut->isArticle() ) {
1426 if ( !$wgArticle instanceof Article
) {
1430 if ( isset( $oldid ) ||
isset( $diff ) ) {
1434 if ( 0 == $wgArticle->getID() ) {
1440 if ( !$wgDisableCounters ) {
1441 $count = $wgLang->formatNum( $wgArticle->getCount() );
1444 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1448 if ( $wgMaxCredits != 0 ) {
1449 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1451 $s .= $this->lastModified();
1454 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1455 $dbr = wfGetDB( DB_SLAVE
);
1456 $res = $dbr->select(
1458 array( 'COUNT(*) AS n' ),
1460 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ),
1461 'wl_namespace' => $this->mTitle
->getNamespace()
1465 $x = $dbr->fetchObject( $res );
1467 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1468 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1472 return $s . ' ' . $this->getCopyright();
1475 function getCopyright( $type = 'detect' ) {
1476 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1478 if ( $type == 'detect' ) {
1479 $diff = $wgRequest->getVal( 'diff' );
1480 $isCur = $wgArticle && $wgArticle->isCurrent();
1482 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1489 if ( $type == 'history' ) {
1490 $msg = 'history_copyright';
1497 if ( $wgRightsPage ) {
1498 $title = Title
::newFromText( $wgRightsPage );
1499 $link = $this->linkKnown( $title, $wgRightsText );
1500 } elseif ( $wgRightsUrl ) {
1501 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1502 } elseif ( $wgRightsText ) {
1503 $link = $wgRightsText;
1509 // Allow for site and per-namespace customization of copyright notice.
1512 if ( isset( $wgArticle ) ) {
1513 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1516 if ( $forContent ) {
1517 $out .= wfMsgForContent( $msg, $link );
1519 $out .= wfMsg( $msg, $link );
1525 function getCopyrightIcon() {
1526 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1530 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1531 $out = $wgCopyrightIcon;
1532 } elseif ( $wgRightsIcon ) {
1533 $icon = htmlspecialchars( $wgRightsIcon );
1535 if ( $wgRightsUrl ) {
1536 $url = htmlspecialchars( $wgRightsUrl );
1537 $out .= '<a href="' . $url . '">';
1540 $text = htmlspecialchars( $wgRightsText );
1541 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1543 if ( $wgRightsUrl ) {
1552 * Gets the powered by MediaWiki icon.
1555 function getPoweredBy() {
1556 global $wgStylePath;
1558 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1559 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1564 function lastModified() {
1565 global $wgLang, $wgArticle;
1567 if ( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest() ) {
1568 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1570 $timestamp = $wgArticle->getTimestamp();
1574 $d = $wgLang->date( $timestamp, true );
1575 $t = $wgLang->time( $timestamp, true );
1576 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1581 if ( wfGetLB()->getLaggedSlaveMode() ) {
1582 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1588 function logoText( $align = '' ) {
1589 if ( $align != '' ) {
1590 $a = " align='{$align}'";
1595 $mp = wfMsg( 'mainpage' );
1596 $mptitle = Title
::newMainPage();
1597 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1599 $logourl = $this->getLogo();
1600 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1606 * Show a drop-down box of special pages
1608 function specialPagesList() {
1609 global $wgContLang, $wgServer, $wgRedirectScript;
1611 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1613 foreach ( $pages as $name => $page ) {
1614 $pages[$name] = $page->getDescription();
1617 $go = wfMsg( 'go' );
1618 $sp = wfMsg( 'specialpages' );
1619 $spp = $wgContLang->specialPage( 'Specialpages' );
1621 $s = '<form id="specialpages" method="get" ' .
1622 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1623 $s .= "<select name=\"wpDropdown\">\n";
1624 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1627 foreach ( $pages as $name => $desc ) {
1628 $p = $wgContLang->specialPage( $name );
1629 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1632 $s .= "</select>\n";
1633 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1640 * Gets the link to the wiki's main page.
1643 function mainPageLink() {
1645 Title
::newMainPage(),
1646 wfMsg( 'mainpage' ),
1649 array( 'known', 'noclasses' )
1655 private function footerLink( $desc, $page ) {
1656 // if the link description has been set to "-" in the default language,
1657 if ( wfMsgForContent( $desc ) == '-' ) {
1658 // then it is disabled, for all languages.
1661 // Otherwise, we display the link for the user, described in their
1662 // language (which may or may not be the same as the default language),
1663 // but we make the link target be the one site-wide page.
1664 $title = Title
::newFromText( wfMsgForContent( $page ) );
1666 return $this->linkKnown(
1668 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1674 * Gets the link to the wiki's privacy policy page.
1676 function privacyLink() {
1677 return $this->footerLink( 'privacy', 'privacypage' );
1681 * Gets the link to the wiki's about page.
1683 function aboutLink() {
1684 return $this->footerLink( 'aboutsite', 'aboutpage' );
1688 * Gets the link to the wiki's general disclaimers page.
1690 function disclaimerLink() {
1691 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1694 function editThisPage() {
1697 if ( !$wgOut->isArticleRelated() ) {
1698 $s = wfMsg( 'protectedpage' );
1700 if ( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1701 $t = wfMsg( 'editthispage' );
1702 } elseif ( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1703 $t = wfMsg( 'create-this-page' );
1705 $t = wfMsg( 'viewsource' );
1712 $this->editUrlOptions(),
1713 array( 'known', 'noclasses' )
1721 * Return URL options for the 'edit page' link.
1722 * This may include an 'oldid' specifier, if the current page view is such.
1727 function editUrlOptions() {
1730 $options = array( 'action' => 'edit' );
1732 if ( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1733 $options['oldid'] = intval( $this->mRevisionId
);
1739 function deleteThisPage() {
1740 global $wgUser, $wgRequest;
1742 $diff = $wgRequest->getVal( 'diff' );
1744 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1745 $t = wfMsg( 'deletethispage' );
1751 array( 'action' => 'delete' ),
1752 array( 'known', 'noclasses' )
1761 function protectThisPage() {
1762 global $wgUser, $wgRequest;
1764 $diff = $wgRequest->getVal( 'diff' );
1766 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1767 if ( $this->mTitle
->isProtected() ) {
1768 $text = wfMsg( 'unprotectthispage' );
1769 $query = array( 'action' => 'unprotect' );
1771 $text = wfMsg( 'protectthispage' );
1772 $query = array( 'action' => 'protect' );
1780 array( 'known', 'noclasses' )
1789 function watchThisPage() {
1791 ++
$this->mWatchLinkNum
;
1793 if ( $wgOut->isArticleRelated() ) {
1794 if ( $this->mTitle
->userIsWatching() ) {
1795 $text = wfMsg( 'unwatchthispage' );
1796 $query = array( 'action' => 'unwatch' );
1797 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1799 $text = wfMsg( 'watchthispage' );
1800 $query = array( 'action' => 'watch' );
1801 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1807 array( 'id' => $id ),
1809 array( 'known', 'noclasses' )
1812 $s = wfMsg( 'notanarticle' );
1818 function moveThisPage() {
1819 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1821 SpecialPage
::getTitleFor( 'Movepage' ),
1822 wfMsg( 'movethispage' ),
1824 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1825 array( 'known', 'noclasses' )
1828 // no message if page is protected - would be redundant
1833 function historyLink() {
1836 wfMsgHtml( 'history' ),
1837 array( 'rel' => 'archives' ),
1838 array( 'action' => 'history' )
1842 function whatLinksHere() {
1844 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1845 wfMsgHtml( 'whatlinkshere' ),
1848 array( 'known', 'noclasses' )
1852 function userContribsLink() {
1854 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1855 wfMsgHtml( 'contributions' ),
1858 array( 'known', 'noclasses' )
1862 function showEmailUser( $id ) {
1864 $targetUser = User
::newFromId( $id );
1865 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1866 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1869 function emailUserLink() {
1871 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1872 wfMsg( 'emailuser' ),
1875 array( 'known', 'noclasses' )
1879 function watchPageLinksLink() {
1882 if ( !$wgOut->isArticleRelated() ) {
1883 return '(' . wfMsg( 'notanarticle' ) . ')';
1886 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1887 wfMsg( 'recentchangeslinked-toolbox' ),
1890 array( 'known', 'noclasses' )
1895 function trackbackLink() {
1896 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1897 . wfMsg( 'trackbacklink' ) . '</a>';
1900 function otherLanguages() {
1901 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1903 if ( $wgHideInterlanguageLinks ) {
1907 $a = $wgOut->getLanguageLinks();
1909 if ( 0 == count( $a ) ) {
1913 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1916 if ( $wgContLang->isRTL() ) {
1917 $s .= '<span dir="LTR">';
1920 foreach ( $a as $l ) {
1922 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1927 $nt = Title
::newFromText( $l );
1928 $url = $nt->escapeFullURL();
1929 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1930 $title = htmlspecialchars( $nt->getText() );
1932 if ( $text == '' ) {
1936 $style = $this->getExternalLinkAttributes();
1937 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1940 if ( $wgContLang->isRTL() ) {
1947 function talkLink() {
1948 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1949 # No discussion links for special pages
1953 $linkOptions = array();
1955 if ( $this->mTitle
->isTalkPage() ) {
1956 $link = $this->mTitle
->getSubjectPage();
1957 switch( $link->getNamespace() ) {
1959 $text = wfMsg( 'articlepage' );
1962 $text = wfMsg( 'userpage' );
1965 $text = wfMsg( 'projectpage' );
1968 $text = wfMsg( 'imagepage' );
1969 # Make link known if image exists, even if the desc. page doesn't.
1970 if ( wfFindFile( $link ) )
1971 $linkOptions[] = 'known';
1974 $text = wfMsg( 'mediawikipage' );
1977 $text = wfMsg( 'templatepage' );
1980 $text = wfMsg( 'viewhelppage' );
1983 $text = wfMsg( 'categorypage' );
1986 $text = wfMsg( 'articlepage' );
1989 $link = $this->mTitle
->getTalkPage();
1990 $text = wfMsg( 'talkpage' );
1993 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1998 function commentLink() {
2001 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
2005 # __NEWSECTIONLINK___ changes behaviour here
2006 # If it is present, the link points to this page, otherwise
2007 # it points to the talk page
2008 if ( $this->mTitle
->isTalkPage() ) {
2009 $title = $this->mTitle
;
2010 } elseif ( $wgOut->showNewSectionLink() ) {
2011 $title = $this->mTitle
;
2013 $title = $this->mTitle
->getTalkPage();
2018 wfMsg( 'postcomment' ),
2024 array( 'known', 'noclasses' )
2028 function getUploadLink() {
2029 global $wgUploadNavigationUrl;
2031 if ( $wgUploadNavigationUrl ) {
2032 # Using an empty class attribute to avoid automatic setting of "external" class
2033 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
2036 SpecialPage
::getTitleFor( 'Upload' ),
2037 wfMsgHtml( 'upload' ),
2040 array( 'known', 'noclasses' )
2045 /* these are used extensively in SkinTemplate, but also some other places */
2046 static function makeMainPageUrl( $urlaction = '' ) {
2047 $title = Title
::newMainPage();
2048 self
::checkTitle( $title, '' );
2050 return $title->getLocalURL( $urlaction );
2053 static function makeSpecialUrl( $name, $urlaction = '' ) {
2054 $title = SpecialPage
::getTitleFor( $name );
2055 return $title->getLocalURL( $urlaction );
2058 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2059 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
2060 return $title->getLocalURL( $urlaction );
2063 static function makeI18nUrl( $name, $urlaction = '' ) {
2064 $title = Title
::newFromText( wfMsgForContent( $name ) );
2065 self
::checkTitle( $title, $name );
2066 return $title->getLocalURL( $urlaction );
2069 static function makeUrl( $name, $urlaction = '' ) {
2070 $title = Title
::newFromText( $name );
2071 self
::checkTitle( $title, $name );
2073 return $title->getLocalURL( $urlaction );
2077 * If url string starts with http, consider as external URL, else
2080 static function makeInternalOrExternalUrl( $name ) {
2081 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2084 return self
::makeUrl( $name );
2088 # this can be passed the NS number as defined in Language.php
2089 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
2090 $title = Title
::makeTitleSafe( $namespace, $name );
2091 self
::checkTitle( $title, $name );
2093 return $title->getLocalURL( $urlaction );
2096 /* these return an array with the 'href' and boolean 'exists' */
2097 static function makeUrlDetails( $name, $urlaction = '' ) {
2098 $title = Title
::newFromText( $name );
2099 self
::checkTitle( $title, $name );
2102 'href' => $title->getLocalURL( $urlaction ),
2103 'exists' => $title->getArticleID() != 0,
2108 * Make URL details where the article exists (or at least it's convenient to think so)
2110 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2111 $title = Title
::newFromText( $name );
2112 self
::checkTitle( $title, $name );
2115 'href' => $title->getLocalURL( $urlaction ),
2120 # make sure we have some title to operate on
2121 static function checkTitle( &$title, $name ) {
2122 if ( !is_object( $title ) ) {
2123 $title = Title
::newFromText( $name );
2124 if ( !is_object( $title ) ) {
2125 $title = Title
::newFromText( '--error: link target missing--' );
2131 * Build an array that represents the sidebar(s), the navigation bar among them
2135 function buildSidebar() {
2136 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2138 wfProfileIn( __METHOD__
);
2140 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2142 if ( $wgEnableSidebarCache ) {
2143 $cachedsidebar = $parserMemc->get( $key );
2144 if ( $cachedsidebar ) {
2145 wfProfileOut( __METHOD__
);
2146 return $cachedsidebar;
2151 $this->addToSidebar( $bar, 'sidebar' );
2153 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2154 if ( $wgEnableSidebarCache ) {
2155 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2158 wfProfileOut( __METHOD__
);
2162 * Add content from a sidebar system message
2163 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2165 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2167 * @param &$bar array
2168 * @param $message String
2170 function addToSidebar( &$bar, $message ) {
2171 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2175 * Add content from plain text
2177 * @param &$bar array
2178 * @param $text string
2180 function addToSidebarPlain( &$bar, $text ) {
2181 $lines = explode( "\n", $text );
2182 $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.
2186 foreach ( $lines as $line ) {
2187 if ( strpos( $line, '*' ) !== 0 ) {
2191 if ( strpos( $line, '**' ) !== 0 ) {
2192 $heading = trim( $line, '* ' );
2193 if ( !array_key_exists( $heading, $bar ) ) {
2194 $bar[$heading] = array();
2197 $line = trim( $line, '* ' );
2199 if ( strpos( $line, '|' ) !== false ) { // sanity check
2200 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2201 $link = wfMsgForContent( $line[0] );
2203 if ( $link == '-' ) {
2207 $text = wfMsgExt( $line[1], 'parsemag' );
2209 if ( wfEmptyMsg( $line[1], $text ) ) {
2213 if ( wfEmptyMsg( $line[0], $link ) ) {
2217 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2220 $title = Title
::newFromText( $link );
2223 $title = $title->fixSpecialName();
2224 $href = $title->getLocalURL();
2226 $href = 'INVALID-TITLE';
2230 $bar[$heading][] = array(
2233 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2236 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2237 global $wgParser, $wgTitle;
2239 $line = substr( $line, 2, strlen( $line ) - 4 );
2241 $options = new ParserOptions();
2242 $options->setEditSection( false );
2243 $options->setInterfaceMessage( true );
2244 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $options )->getText();
2251 if ( count( $wikiBar ) > 0 ) {
2252 $bar = array_merge( $bar, $wikiBar );
2259 * Should we include common/wikiprintable.css? Skins that have their own
2260 * print stylesheet should override this and return false. (This is an
2261 * ugly hack to get Monobook to play nicely with
2262 * OutputPage::headElement().)
2266 public function commonPrintStylesheet() {
2271 * Gets new talk page messages for the current user.
2272 * @return MediaWiki message or if no new talk page messages, nothing
2274 function getNewtalks() {
2275 global $wgUser, $wgOut;
2277 $newtalks = $wgUser->getNewMessageLinks();
2280 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2281 $userTitle = $this->mUser
->getUserPage();
2282 $userTalkTitle = $userTitle->getTalkPage();
2284 if ( !$userTalkTitle->equals( $this->mTitle
) ) {
2285 $newMessagesLink = $this->link(
2287 wfMsgHtml( 'newmessageslink' ),
2289 array( 'redirect' => 'no' ),
2290 array( 'known', 'noclasses' )
2293 $newMessagesDiffLink = $this->link(
2295 wfMsgHtml( 'newmessagesdifflink' ),
2297 array( 'diff' => 'cur' ),
2298 array( 'known', 'noclasses' )
2302 'youhavenewmessages',
2304 $newMessagesDiffLink
2306 # Disable Squid cache
2307 $wgOut->setSquidMaxage( 0 );
2309 } elseif ( count( $newtalks ) ) {
2310 // _>" " for BC <= 1.16
2311 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2314 foreach ( $newtalks as $newtalk ) {
2315 $msgs[] = Xml
::element(
2317 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2320 $parts = implode( $sep, $msgs );
2321 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2322 $wgOut->setSquidMaxage( 0 );