3 * @defgroup Skins Skins
6 if ( !defined( 'MEDIAWIKI' ) ) {
11 * The main skin class that provide methods and properties for all other skins.
12 * This base class is also the "Standard" skin.
14 * See docs/skin.txt for more information.
18 class Skin
extends Linker
{
22 var $mWatchLinkNum = 0; // Appended to end of watch link id's
23 // How many search boxes have we made? Avoid duplicate id's.
24 protected $searchboxes = '';
26 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
27 protected $skinname = 'standard';
28 // @todo Fixme: should be protected :-\
31 /** Constructor, call parent constructor */
32 function __construct() {
33 parent
::__construct();
37 * Fetch the set of available skins.
38 * @return array of strings
40 static function getSkinNames() {
41 global $wgValidSkinNames;
42 static $skinsInitialised = false;
44 if ( !$skinsInitialised ) {
45 # Get a list of available skins
46 # Build using the regular expression '^(.*).php$'
47 # Array keys are all lower case, array value keep the case used by filename
49 wfProfileIn( __METHOD__
. '-init' );
51 global $wgStyleDirectory;
53 $skinDir = dir( $wgStyleDirectory );
55 # while code from www.php.net
56 while ( false !== ( $file = $skinDir->read() ) ) {
57 // Skip non-PHP files, hidden files, and '.dep' includes
60 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
62 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
66 $skinsInitialised = true;
67 wfProfileOut( __METHOD__
. '-init' );
69 return $wgValidSkinNames;
73 * Fetch the list of usable skins in regards to $wgSkipSkins.
74 * Useful for Special:Preferences and other places where you
75 * only want to show skins users _can_ use.
76 * @return array of strings
78 public static function getUsableSkins() {
81 $usableSkins = self
::getSkinNames();
83 foreach ( $wgSkipSkins as $skip ) {
84 unset( $usableSkins[$skip] );
91 * Normalize a skin preference value to a form that can be loaded.
92 * If a skin can't be found, it will fall back to the configured
93 * default (or the old 'Classic' skin if that's broken).
94 * @param $key String: 'monobook', 'standard', etc.
97 static function normalizeKey( $key ) {
98 global $wgDefaultSkin;
100 $skinNames = Skin
::getSkinNames();
103 // Don't return the default immediately;
104 // in a misconfiguration we need to fall back.
105 $key = $wgDefaultSkin;
108 if ( isset( $skinNames[$key] ) ) {
112 // Older versions of the software used a numeric setting
113 // in the user preferences.
120 if ( isset( $fallback[$key] ) ) {
121 $key = $fallback[$key];
124 if ( isset( $skinNames[$key] ) ) {
126 } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
127 return $wgDefaultSkin;
134 * Factory method for loading a skin of a given type
135 * @param $key String: 'monobook', 'standard', etc.
138 static function &newFromKey( $key ) {
139 global $wgStyleDirectory;
141 $key = Skin
::normalizeKey( $key );
143 $skinNames = Skin
::getSkinNames();
144 $skinName = $skinNames[$key];
145 $className = 'Skin' . ucfirst( $key );
147 # Grab the skin class and initialise it.
148 if ( !class_exists( $className ) ) {
149 // Preload base classes to work around APC/PHP5 bug
150 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
152 if ( file_exists( $deps ) ) {
153 include_once( $deps );
155 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
157 # Check if we got if not failback to default skin
158 if ( !class_exists( $className ) ) {
159 # DO NOT die if the class isn't found. This breaks maintenance
160 # scripts and can cause a user account to be unrecoverable
161 # except by SQL manipulation if a previously valid skin name
162 # is no longer valid.
163 wfDebug( "Skin class does not exist: $className\n" );
164 $className = 'SkinVector';
165 require_once( "{$wgStyleDirectory}/Vector.php" );
168 $skin = new $className;
172 /** @return string path to the skin stylesheet */
173 function getStylesheet() {
174 return 'common/wikistandard.css';
177 /** @return string skin name */
178 public function getSkinName() {
179 return $this->skinname
;
182 function qbSetting() {
183 global $wgOut, $wgUser;
185 if ( $wgOut->isQuickbarSuppressed() ) {
189 $q = $wgUser->getOption( 'quickbar', 0 );
194 function initPage( OutputPage
$out ) {
195 global $wgFavicon, $wgAppleTouchIcon;
197 wfProfileIn( __METHOD__
);
199 # Generally the order of the favicon and apple-touch-icon links
200 # should not matter, but Konqueror (3.5.9 at least) incorrectly
201 # uses whichever one appears later in the HTML source. Make sure
202 # apple-touch-icon is specified first to avoid this.
203 if ( false !== $wgAppleTouchIcon ) {
204 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
207 if ( false !== $wgFavicon ) {
208 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
211 # OpenSearch description link
212 $out->addLink( array(
214 'type' => 'application/opensearchdescription+xml',
215 'href' => wfScript( 'opensearch_desc' ),
216 'title' => wfMsgForContent( 'opensearch-desc' ),
219 $this->addMetadataLinks( $out );
221 $this->mRevisionId
= $out->mRevisionId
;
223 $this->preloadExistence();
225 wfProfileOut( __METHOD__
);
229 * Preload the existence of three commonly-requested pages in a single query
231 function preloadExistence() {
235 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
238 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
240 } elseif ( $this->mTitle
->isTalkPage() ) {
241 $titles[] = $this->mTitle
->getSubjectPage();
243 $titles[] = $this->mTitle
->getTalkPage();
246 $lb = new LinkBatch( $titles );
247 $lb->setCaller( __METHOD__
);
252 * Adds metadata links below to the HTML output.
254 * <li>Creative Commons
255 * <br />See http://wiki.creativecommons.org/Extend_Metadata.
257 * <li>Dublin Core</li>
258 * <li>Use hreflang to specify canonical and alternate links
259 * <br />See http://www.google.com/support/webmasters/bin/answer.py?answer=189077
264 * @param $out Object: instance of OutputPage
266 function addMetadataLinks( OutputPage
$out ) {
267 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
268 global $wgDisableLangConversion, $wgDisableLangCanonical, $wgContLang;
269 global $wgRightsPage, $wgRightsUrl;
271 if ( $out->isArticleRelated() ) {
272 # note: buggy CC software only reads first "meta" link
273 if ( $wgEnableCreativeCommonsRdf ) {
274 $out->addMetadataLink( array(
275 'title' => 'Creative Commons',
276 'type' => 'application/rdf+xml',
277 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
281 if ( $wgEnableDublinCoreRdf ) {
282 $out->addMetadataLink( array(
283 'title' => 'Dublin Core',
284 'type' => 'application/rdf+xml',
285 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
290 if ( !$wgDisableLangConversion && !$wgDisableLangCanonical
291 && $wgContLang->hasVariants() ) {
293 $urlvar = $wgContLang->getURLVariant();
296 $variants = $wgContLang->getVariants();
297 foreach ( $variants as $_v ) {
298 $out->addLink( array(
299 'rel' => 'alternate',
301 'href' => $this->mTitle
->getLocalURL( '', $_v ) )
305 $out->addLink( array(
306 'rel' => 'canonical',
307 'href' => $this->mTitle
->getFullURL() )
313 if ( $wgRightsPage ) {
314 $copy = Title
::newFromText( $wgRightsPage );
317 $copyright = $copy->getLocalURL();
321 if ( !$copyright && $wgRightsUrl ) {
322 $copyright = $wgRightsUrl;
326 $out->addLink( array(
327 'rel' => 'copyright',
328 'href' => $copyright )
334 * Set some local variables
336 protected function setMembers() {
338 $this->mUser
= $wgUser;
339 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
340 $this->usercss
= false;
345 * @param $t Title object to use
347 public function setTitle( $t ) {
352 public function getTitle() {
353 return $this->mTitle
;
357 * Outputs the HTML generated by other functions.
358 * @param $out Object: instance of OutputPage
360 function outputPage( OutputPage
$out ) {
361 global $wgDebugComments;
362 wfProfileIn( __METHOD__
);
365 $this->initPage( $out );
367 // See self::afterContentHook() for documentation
368 $afterContent = $this->afterContentHook();
370 $out->out( $out->headElement( $this ) );
372 if ( $wgDebugComments ) {
373 $out->out( "<!-- Wiki debugging output:\n" .
374 $out->mDebugtext
. "-->\n" );
377 $out->out( $this->beforeContent() );
379 $out->out( $out->mBodytext
. "\n" );
381 $out->out( $this->afterContent() );
383 $out->out( $afterContent );
385 $out->out( $this->bottomScripts( $out ) );
387 $out->out( wfReportTime() );
389 $out->out( "\n</body></html>" );
390 wfProfileOut( __METHOD__
);
393 static function makeVariablesScript( $data ) {
395 return Html
::inlineScript(
396 ResourceLoader
::makeLoaderConditionalScript( ResourceLoader
::makeConfigSetScript( $data ) )
404 * Make a <script> tag containing global variables
405 * @param $skinName string Name of the skin
406 * The odd calling convention is for backwards compatibility
407 * @todo FIXME: Make this not depend on $wgTitle!
409 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
410 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
412 static function makeGlobalVariablesScript( $skinName ) {
413 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
415 $ns = $wgTitle->getNamespace();
416 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
418 'wgCanonicalNamespace' => $nsname,
419 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
420 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
421 'wgNamespaceNumber' => $wgTitle->getNamespace(),
422 'wgPageName' => $wgTitle->getPrefixedDBKey(),
423 'wgTitle' => $wgTitle->getText(),
424 'wgAction' => $wgRequest->getText( 'action', 'view' ),
425 'wgArticleId' => $wgTitle->getArticleId(),
426 'wgIsArticle' => $wgOut->isArticle(),
427 'wgUserName' => $wgUser->isAnon() ?
null : $wgUser->getName(),
428 'wgUserGroups' => $wgUser->getEffectiveGroups(),
429 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
430 'wgCategories' => $wgOut->getCategories(),
432 foreach ( $wgRestrictionTypes as $type ) {
433 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
435 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
436 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
439 // Allow extensions to add their custom variables to the global JS variables
440 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
442 return self
::makeVariablesScript( $vars );
446 * To make it harder for someone to slip a user a fake
447 * user-JavaScript or user-CSS preview, a random token
448 * is associated with the login session. If it's not
449 * passed back with the preview request, we won't render
452 * @param $action String: 'edit', 'submit' etc.
455 public function userCanPreview( $action ) {
456 global $wgRequest, $wgUser;
458 if ( $action != 'submit' ) {
461 if ( !$wgRequest->wasPosted() ) {
464 if ( !$this->mTitle
->userCanEditCssSubpage() ) {
467 if ( !$this->mTitle
->userCanEditJsSubpage() ) {
471 return $wgUser->matchEditToken(
472 $wgRequest->getVal( 'wpEditToken' ) );
476 * Generated JavaScript action=raw&gen=js
477 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
478 * nated together. For some bizarre reason, it does *not* return any
479 * custom user JS from subpages. Huh?
481 * There's absolutely no reason to have separate Monobook/Common JSes.
482 * Any JS that cares can just check the skin variable generated at the
483 * top. For now Monobook.js will be maintained, but it should be consi-
486 * @param $skinName String: If set, overrides the skin name
489 public function generateUserJs( $skinName = null ) {
491 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
497 * Generate user stylesheet for action=raw&gen=css
499 public function generateUserStylesheet() {
501 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
507 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
508 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
510 protected function reallyGenerateUserStylesheet() {
512 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
520 function setupUserCss( OutputPage
$out ) {
522 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
524 wfProfileIn( __METHOD__
);
526 $this->setupSkinUserCss( $out );
530 'maxage' => $wgSquidMaxage,
533 // Add any extension CSS
534 foreach ( $out->getExtStyle() as $url ) {
535 $out->addStyle( $url );
538 // Per-site custom styles
539 if ( $wgUseSiteCss ) {
540 $out->addModuleStyles( 'site' );
543 // Per-user custom styles
544 if ( $wgAllowUserCss ) {
545 if ( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
546 // @FIXME: properly escape the cdata!
547 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
549 $out->addModuleStyles( 'user' );
553 // Per-user preference styles
554 if ( $wgAllowUserCssPrefs ) {
555 $out->addModuleStyles( 'user.options' );
558 wfProfileOut( __METHOD__
);
562 * Get the query to generate a dynamic stylesheet
566 public static function getDynamicStylesheetQuery() {
567 global $wgSquidMaxage;
571 'maxage' => $wgSquidMaxage,
572 'usemsgcache' => 'yes',
573 'ctype' => 'text/css',
574 'smaxage' => $wgSquidMaxage,
579 * Add skin specific stylesheets
580 * @param $out OutputPage
582 function setupSkinUserCss( OutputPage
$out ) {
583 $out->addModuleStyles( 'mediawiki.legacy.shared' );
584 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
585 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
586 $out->addStyle( $this->getStylesheet() );
587 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
590 function getPageClasses( $title ) {
591 $numeric = 'ns-' . $title->getNamespace();
593 if ( $title->getNamespace() == NS_SPECIAL
) {
594 $type = 'ns-special';
595 } elseif ( $title->isTalkPage() ) {
598 $type = 'ns-subject';
601 $name = Sanitizer
::escapeClass( 'page-' . $title->getPrefixedText() );
603 return "$numeric $type $name";
607 * This will be called by OutputPage::headElement when it is creating the
608 * <body> tag, skins can override it if they have a need to add in any
609 * body attributes or classes of their own.
611 function addToBodyAttributes( $out, &$bodyAttrs ) {
612 // does nothing by default
624 * This will be called immediately after the <body> tag. Split into
625 * two functions to make it easier to subclass.
627 function beforeContent() {
628 return $this->doBeforeContent();
631 function doBeforeContent() {
633 wfProfileIn( __METHOD__
);
636 $qb = $this->qbSetting();
638 $langlinks = $this->otherLanguages();
645 $borderhack = 'class="top"';
648 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
649 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
651 $shove = ( $qb != 0 );
652 $left = ( $qb == 1 ||
$qb == 3 );
654 if ( $wgContLang->isRTL() ) {
659 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
660 $this->logoText() . '</td>';
662 $s .= $this->getQuickbarCompensator( $rows );
665 $l = $wgContLang->alignStart();
666 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
668 $s .= $this->topLinks();
669 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
671 $r = $wgContLang->alignEnd();
672 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
673 $s .= $this->nameAndLogin();
674 $s .= "\n<br />" . $this->searchForm() . '</td>';
677 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
680 if ( $shove && !$left ) { # Right
681 $s .= $this->getQuickbarCompensator( $rows );
684 $s .= "</tr>\n</table>\n</div>\n";
685 $s .= "\n<div id='article'>\n";
687 $notice = wfGetSiteNotice();
690 $s .= "\n<div id='siteNotice'>$notice</div>\n";
692 $s .= $this->pageTitle();
693 $s .= $this->pageSubtitle();
694 $s .= $this->getCategories();
696 wfProfileOut( __METHOD__
);
700 function getCategoryLinks() {
701 global $wgOut, $wgUseCategoryBrowser;
702 global $wgContLang, $wgUser;
704 if ( count( $wgOut->mCategoryLinks
) == 0 ) {
709 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
711 // Use Unicode bidi embedding override characters,
712 // to make sure links don't smash each other up in ugly ways.
713 $dir = $wgContLang->getDir();
714 $embed = "<span dir='$dir'>";
717 $allCats = $wgOut->getCategoryLinks();
719 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
721 if ( !empty( $allCats['normal'] ) ) {
722 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
724 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
725 $s .= '<div id="mw-normal-catlinks">' .
726 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
727 . $colon . $t . '</div>';
731 if ( isset( $allCats['hidden'] ) ) {
732 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
733 $class = 'mw-hidden-cats-user-shown';
734 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
735 $class = 'mw-hidden-cats-ns-shown';
737 $class = 'mw-hidden-cats-hidden';
740 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
741 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
742 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
746 # optional 'dmoz-like' category browser. Will be shown under the list
747 # of categories an article belong to
748 if ( $wgUseCategoryBrowser ) {
749 $s .= '<br /><hr />';
751 # get a big array of the parents tree
752 $parenttree = $this->mTitle
->getParentCategoryTree();
753 # Skin object passed by reference cause it can not be
754 # accessed under the method subfunction drawCategoryBrowser
755 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
756 # Clean out bogus first entry and sort them
757 unset( $tempout[0] );
759 # Output one per line
760 $s .= implode( "<br />\n", $tempout );
767 * Render the array as a serie of links.
768 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
769 * @param &skin Object: skin passed by reference
770 * @return String separated by >, terminate with "\n"
772 function drawCategoryBrowser( $tree, &$skin ) {
775 foreach ( $tree as $element => $parent ) {
776 if ( empty( $parent ) ) {
777 # element start a new list
780 # grab the others elements
781 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
784 # add our current element to the list
785 $eltitle = Title
::newFromText( $element );
786 $return .= $skin->link( $eltitle, $eltitle->getText() );
792 function getCategories() {
793 $catlinks = $this->getCategoryLinks();
795 $classes = 'catlinks';
797 global $wgOut, $wgUser;
799 // Check what we're showing
800 $allCats = $wgOut->getCategoryLinks();
801 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
802 $this->mTitle
->getNamespace() == NS_CATEGORY
;
804 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
805 $classes .= ' catlinks-allhidden';
808 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
811 function getQuickbarCompensator( $rows = 1 ) {
812 return "<td width='152' rowspan='{$rows}'> </td>";
816 * This runs a hook to allow extensions placing their stuff after content
817 * and article metadata (e.g. categories).
818 * Note: This function has nothing to do with afterContent().
820 * This hook is placed here in order to allow using the same hook for all
821 * skins, both the SkinTemplate based ones and the older ones, which directly
822 * use this class to get their data.
824 * The output of this function gets processed in SkinTemplate::outputPage() for
825 * the SkinTemplate based skins, all other skins should directly echo it.
827 * Returns an empty string by default, if not changed by any hook function.
829 protected function afterContentHook() {
832 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
833 // adding just some spaces shouldn't toggle the output
834 // of the whole <div/>, so we use trim() here
835 if ( trim( $data ) != '' ) {
836 // Doing this here instead of in the skins to
837 // ensure that the div has the same ID in all
839 $data = "<div id='mw-data-after-content'>\n" .
844 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
851 * Generate debug data HTML for displaying at the bottom of the main content
853 * @return String HTML containing debug data, if enabled (otherwise empty).
855 protected function generateDebugHTML() {
856 global $wgShowDebug, $wgOut;
858 if ( $wgShowDebug ) {
859 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
860 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
861 $listInternals . "</ul>\n";
867 private function formatDebugHTML( $debugText ) {
868 $lines = explode( "\n", $debugText );
872 foreach ( $lines as $line ) {
873 $display = ltrim( $line );
874 $ident = strlen( $line ) - strlen( $display );
875 $diff = $ident - $curIdent;
877 if ( $display == '' ) {
878 $display = "\xc2\xa0";
881 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
884 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
886 $display = htmlspecialchars( $display );
890 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
891 } elseif ( $diff == 0 ) {
892 $ret .= "</li><li>\n";
894 $ret .= str_repeat( "<ul><li>\n", $diff );
896 $ret .= $display . "\n";
901 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
907 * This gets called shortly before the </body> tag.
908 * @return String HTML to be put before </body>
910 function afterContent() {
911 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
912 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
916 * This gets called shortly before the </body> tag.
917 * @param $out OutputPage object
918 * @return String HTML-wrapped JS code to be put before </body>
920 function bottomScripts( $out ) {
921 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
922 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
924 return $bottomScriptText;
927 /** @return string Retrievied from HTML text */
928 function printSource() {
929 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
930 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
933 function printFooter() {
934 return "<p>" . $this->printSource() .
935 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
938 /** overloaded by derived classes */
939 function doAfterContent() {
940 return '</div></div>';
943 function pageTitleLinks() {
944 global $wgOut, $wgUser, $wgRequest, $wgLang;
946 $oldid = $wgRequest->getVal( 'oldid' );
947 $diff = $wgRequest->getVal( 'diff' );
948 $action = $wgRequest->getText( 'action' );
950 $s[] = $this->printableLink();
951 $disclaimer = $this->disclaimerLink(); # may be empty
957 $privacy = $this->privacyLink(); # may be empty too
963 if ( $wgOut->isArticleRelated() ) {
964 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
965 $name = $this->mTitle
->getDBkey();
966 $image = wfFindFile( $this->mTitle
);
969 $link = htmlspecialchars( $image->getURL() );
970 $style = $this->getInternalLinkAttributes( $link, $name );
971 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
976 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
979 wfMsg( 'currentrev' ),
982 array( 'known', 'noclasses' )
986 if ( $wgUser->getNewtalk() ) {
987 # do not show "You have new messages" text when we are viewing our
989 if ( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
991 $wgUser->getTalkPage(),
992 wfMsgHtml( 'newmessageslink' ),
994 array( 'redirect' => 'no' ),
995 array( 'known', 'noclasses' )
999 $wgUser->getTalkPage(),
1000 wfMsgHtml( 'newmessagesdifflink' ),
1002 array( 'diff' => 'cur' ),
1003 array( 'known', 'noclasses' )
1005 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1007 $wgOut->setSquidMaxage( 0 );
1008 $wgOut->enableClientCache( false );
1012 $undelete = $this->getUndeleteLink();
1014 if ( !empty( $undelete ) ) {
1018 return $wgLang->pipeList( $s );
1021 function getUndeleteLink() {
1022 global $wgUser, $wgLang, $wgRequest;
1024 $action = $wgRequest->getVal( 'action', 'view' );
1026 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1027 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1028 $n = $this->mTitle
->isDeleted();
1031 if ( $wgUser->isAllowed( 'undelete' ) ) {
1032 $msg = 'thisisdeleted';
1034 $msg = 'viewdeleted';
1040 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1041 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1044 array( 'known', 'noclasses' )
1053 function printableLink() {
1054 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1058 if ( !$wgOut->isPrintable() ) {
1059 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1060 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1063 if ( $wgOut->isSyndicated() ) {
1064 foreach ( $wgFeedClasses as $format => $class ) {
1065 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1066 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1067 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1070 return $wgLang->pipeList( $s );
1074 * Gets the h1 element with the page title.
1077 function pageTitle() {
1079 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1083 function pageSubtitle() {
1086 $sub = $wgOut->getSubtitle();
1089 global $wgExtraSubtitle;
1090 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1093 $subpages = $this->subPageSubtitle();
1094 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1095 $s = "<p class='subtitle'>{$sub}</p>\n";
1100 function subPageSubtitle() {
1103 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) {
1109 if ( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1110 $ptext = $this->mTitle
->getPrefixedText();
1111 if ( preg_match( '/\//', $ptext ) ) {
1112 $links = explode( '/', $ptext );
1113 array_pop( $links );
1118 foreach ( $links as $link ) {
1119 $growinglink .= $link;
1121 $linkObj = Title
::newFromText( $growinglink );
1123 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1124 $getlink = $this->link(
1126 htmlspecialchars( $display ),
1129 array( 'known', 'noclasses' )
1135 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1137 $subpages .= '< ';
1140 $subpages .= $getlink;
1145 $growinglink .= '/';
1154 * Returns true if the IP should be shown in the header
1156 function showIPinHeader() {
1157 global $wgShowIPinHeader;
1158 return $wgShowIPinHeader && session_id() != '';
1161 function nameAndLogin() {
1162 global $wgUser, $wgLang, $wgContLang;
1164 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1168 if ( $wgUser->isAnon() ) {
1169 if ( $this->showIPinHeader() ) {
1172 $talkLink = $this->link( $wgUser->getTalkPage(),
1173 $wgLang->getNsText( NS_TALK
) );
1175 $ret .= "$name ($talkLink)";
1177 $ret .= wfMsg( 'notloggedin' );
1180 $returnTo = $this->mTitle
->getPrefixedDBkey();
1183 if ( $logoutPage != $returnTo ) {
1184 $query['returnto'] = $returnTo;
1187 $loginlink = $wgUser->isAllowed( 'createaccount' )
1188 ?
'nav-login-createaccount'
1190 $ret .= "\n<br />" . $this->link(
1191 SpecialPage
::getTitleFor( 'Userlogin' ),
1192 wfMsg( $loginlink ), array(), $query
1195 $returnTo = $this->mTitle
->getPrefixedDBkey();
1196 $talkLink = $this->link( $wgUser->getTalkPage(),
1197 $wgLang->getNsText( NS_TALK
) );
1199 $ret .= $this->link( $wgUser->getUserPage(),
1200 htmlspecialchars( $wgUser->getName() ) );
1201 $ret .= " ($talkLink)<br />";
1202 $ret .= $wgLang->pipeList( array(
1204 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1205 array(), array( 'returnto' => $returnTo )
1207 $this->specialLink( 'Preferences' ),
1211 $ret = $wgLang->pipeList( array(
1214 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1222 function getSearchLink() {
1223 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1224 return $searchPage->getLocalURL();
1227 function escapeSearchLink() {
1228 return htmlspecialchars( $this->getSearchLink() );
1231 function searchForm() {
1232 global $wgRequest, $wgUseTwoButtonsSearchForm;
1234 $search = $wgRequest->getText( 'search' );
1236 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
1237 . $this->escapeSearchLink() . "\">\n"
1238 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
1239 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1240 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1242 if ( $wgUseTwoButtonsSearchForm ) {
1243 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1245 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1250 // Ensure unique id's for search boxes made after the first
1251 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1256 function topLinks() {
1260 $this->mainPageLink(),
1261 $this->specialLink( 'Recentchanges' )
1264 if ( $wgOut->isArticleRelated() ) {
1265 $s[] = $this->editThisPage();
1266 $s[] = $this->historyLink();
1269 # Many people don't like this dropdown box
1270 # $s[] = $this->specialPagesList();
1272 if ( $this->variantLinks() ) {
1273 $s[] = $this->variantLinks();
1276 if ( $this->extensionTabLinks() ) {
1277 $s[] = $this->extensionTabLinks();
1280 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1281 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1285 * Compatibility for extensions adding functionality through tabs.
1286 * Eventually these old skins should be replaced with SkinTemplate-based
1290 function extensionTabLinks() {
1294 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1295 foreach ( $tabs as $tab ) {
1296 $s[] = Xml
::element( 'a',
1297 array( 'href' => $tab['href'] ),
1301 if ( count( $s ) ) {
1304 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1305 $out .= $wgLang->pipeList( $s );
1312 * Language/charset variant links for classic-style skins
1315 function variantLinks() {
1318 /* show links to different language variants */
1319 global $wgDisableLangConversion, $wgLang, $wgContLang;
1321 $variants = $wgContLang->getVariants();
1323 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1324 foreach ( $variants as $code ) {
1325 $varname = $wgContLang->getVariantname( $code );
1327 if ( $varname == 'disable' ) {
1330 $s = $wgLang->pipeList( array(
1332 '<a href="' . $this->mTitle
->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1340 function bottomLinks() {
1341 global $wgOut, $wgUser, $wgUseTrackbacks;
1342 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1345 if ( $wgOut->isArticleRelated() ) {
1346 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1348 if ( $wgUser->isLoggedIn() ) {
1349 $element[] = $this->watchThisPage();
1352 $element[] = $this->talkLink();
1353 $element[] = $this->historyLink();
1354 $element[] = $this->whatLinksHere();
1355 $element[] = $this->watchPageLinksLink();
1357 if ( $wgUseTrackbacks ) {
1358 $element[] = $this->trackbackLink();
1362 $this->mTitle
->getNamespace() == NS_USER ||
1363 $this->mTitle
->getNamespace() == NS_USER_TALK
1365 $id = User
::idFromName( $this->mTitle
->getText() );
1366 $ip = User
::isIP( $this->mTitle
->getText() );
1368 # Both anons and non-anons have contributions list
1370 $element[] = $this->userContribsLink();
1373 if ( $this->showEmailUser( $id ) ) {
1374 $element[] = $this->emailUserLink();
1378 $s = implode( $element, $sep );
1380 if ( $this->mTitle
->getArticleId() ) {
1383 // Delete/protect/move links for privileged users
1384 if ( $wgUser->isAllowed( 'delete' ) ) {
1385 $s .= $this->deleteThisPage();
1388 if ( $wgUser->isAllowed( 'protect' ) ) {
1389 $s .= $sep . $this->protectThisPage();
1392 if ( $wgUser->isAllowed( 'move' ) ) {
1393 $s .= $sep . $this->moveThisPage();
1397 $s .= "<br />\n" . $this->otherLanguages();
1403 function pageStats() {
1404 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1405 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1407 $oldid = $wgRequest->getVal( 'oldid' );
1408 $diff = $wgRequest->getVal( 'diff' );
1410 if ( !$wgOut->isArticle() ) {
1414 if ( !$wgArticle instanceof Article
) {
1418 if ( isset( $oldid ) ||
isset( $diff ) ) {
1422 if ( 0 == $wgArticle->getID() ) {
1428 if ( !$wgDisableCounters ) {
1429 $count = $wgLang->formatNum( $wgArticle->getCount() );
1432 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1436 if ( $wgMaxCredits != 0 ) {
1437 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1439 $s .= $this->lastModified();
1442 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1443 $dbr = wfGetDB( DB_SLAVE
);
1444 $res = $dbr->select(
1446 array( 'COUNT(*) AS n' ),
1448 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ),
1449 'wl_namespace' => $this->mTitle
->getNamespace()
1453 $x = $dbr->fetchObject( $res );
1455 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1456 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1460 return $s . ' ' . $this->getCopyright();
1463 function getCopyright( $type = 'detect' ) {
1464 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1466 if ( $type == 'detect' ) {
1467 $diff = $wgRequest->getVal( 'diff' );
1468 $isCur = $wgArticle && $wgArticle->isCurrent();
1470 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1477 if ( $type == 'history' ) {
1478 $msg = 'history_copyright';
1485 if ( $wgRightsPage ) {
1486 $title = Title
::newFromText( $wgRightsPage );
1487 $link = $this->linkKnown( $title, $wgRightsText );
1488 } elseif ( $wgRightsUrl ) {
1489 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1490 } elseif ( $wgRightsText ) {
1491 $link = $wgRightsText;
1497 // Allow for site and per-namespace customization of copyright notice.
1500 if ( isset( $wgArticle ) ) {
1501 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1504 if ( $forContent ) {
1505 $out .= wfMsgForContent( $msg, $link );
1507 $out .= wfMsg( $msg, $link );
1513 function getCopyrightIcon() {
1514 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1518 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1519 $out = $wgCopyrightIcon;
1520 } elseif ( $wgRightsIcon ) {
1521 $icon = htmlspecialchars( $wgRightsIcon );
1523 if ( $wgRightsUrl ) {
1524 $url = htmlspecialchars( $wgRightsUrl );
1525 $out .= '<a href="' . $url . '">';
1528 $text = htmlspecialchars( $wgRightsText );
1529 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1531 if ( $wgRightsUrl ) {
1540 * Gets the powered by MediaWiki icon.
1543 function getPoweredBy() {
1544 global $wgStylePath;
1546 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1547 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1552 function lastModified() {
1553 global $wgLang, $wgArticle;
1555 if ( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest() ) {
1556 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1558 $timestamp = $wgArticle->getTimestamp();
1562 $d = $wgLang->date( $timestamp, true );
1563 $t = $wgLang->time( $timestamp, true );
1564 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1569 if ( wfGetLB()->getLaggedSlaveMode() ) {
1570 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1576 function logoText( $align = '' ) {
1577 if ( $align != '' ) {
1578 $a = " align='{$align}'";
1583 $mp = wfMsg( 'mainpage' );
1584 $mptitle = Title
::newMainPage();
1585 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1587 $logourl = $this->getLogo();
1588 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1594 * Show a drop-down box of special pages
1596 function specialPagesList() {
1597 global $wgContLang, $wgServer, $wgRedirectScript;
1599 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1601 foreach ( $pages as $name => $page ) {
1602 $pages[$name] = $page->getDescription();
1605 $go = wfMsg( 'go' );
1606 $sp = wfMsg( 'specialpages' );
1607 $spp = $wgContLang->specialPage( 'Specialpages' );
1609 $s = '<form id="specialpages" method="get" ' .
1610 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1611 $s .= "<select name=\"wpDropdown\">\n";
1612 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1615 foreach ( $pages as $name => $desc ) {
1616 $p = $wgContLang->specialPage( $name );
1617 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1620 $s .= "</select>\n";
1621 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1628 * Gets the link to the wiki's main page.
1631 function mainPageLink() {
1633 Title
::newMainPage(),
1634 wfMsg( 'mainpage' ),
1637 array( 'known', 'noclasses' )
1643 private function footerLink( $desc, $page ) {
1644 // if the link description has been set to "-" in the default language,
1645 if ( wfMsgForContent( $desc ) == '-' ) {
1646 // then it is disabled, for all languages.
1649 // Otherwise, we display the link for the user, described in their
1650 // language (which may or may not be the same as the default language),
1651 // but we make the link target be the one site-wide page.
1652 $title = Title
::newFromText( wfMsgForContent( $page ) );
1654 return $this->linkKnown(
1656 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1662 * Gets the link to the wiki's privacy policy page.
1664 function privacyLink() {
1665 return $this->footerLink( 'privacy', 'privacypage' );
1669 * Gets the link to the wiki's about page.
1671 function aboutLink() {
1672 return $this->footerLink( 'aboutsite', 'aboutpage' );
1676 * Gets the link to the wiki's general disclaimers page.
1678 function disclaimerLink() {
1679 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1682 function editThisPage() {
1685 if ( !$wgOut->isArticleRelated() ) {
1686 $s = wfMsg( 'protectedpage' );
1688 if ( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1689 $t = wfMsg( 'editthispage' );
1690 } elseif ( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1691 $t = wfMsg( 'create-this-page' );
1693 $t = wfMsg( 'viewsource' );
1700 $this->editUrlOptions(),
1701 array( 'known', 'noclasses' )
1709 * Return URL options for the 'edit page' link.
1710 * This may include an 'oldid' specifier, if the current page view is such.
1715 function editUrlOptions() {
1718 $options = array( 'action' => 'edit' );
1720 if ( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1721 $options['oldid'] = intval( $this->mRevisionId
);
1727 function deleteThisPage() {
1728 global $wgUser, $wgRequest;
1730 $diff = $wgRequest->getVal( 'diff' );
1732 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1733 $t = wfMsg( 'deletethispage' );
1739 array( 'action' => 'delete' ),
1740 array( 'known', 'noclasses' )
1749 function protectThisPage() {
1750 global $wgUser, $wgRequest;
1752 $diff = $wgRequest->getVal( 'diff' );
1754 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1755 if ( $this->mTitle
->isProtected() ) {
1756 $text = wfMsg( 'unprotectthispage' );
1757 $query = array( 'action' => 'unprotect' );
1759 $text = wfMsg( 'protectthispage' );
1760 $query = array( 'action' => 'protect' );
1768 array( 'known', 'noclasses' )
1777 function watchThisPage() {
1779 ++
$this->mWatchLinkNum
;
1781 if ( $wgOut->isArticleRelated() ) {
1782 if ( $this->mTitle
->userIsWatching() ) {
1783 $text = wfMsg( 'unwatchthispage' );
1784 $query = array( 'action' => 'unwatch' );
1785 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1787 $text = wfMsg( 'watchthispage' );
1788 $query = array( 'action' => 'watch' );
1789 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1795 array( 'id' => $id ),
1797 array( 'known', 'noclasses' )
1800 $s = wfMsg( 'notanarticle' );
1806 function moveThisPage() {
1807 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1809 SpecialPage
::getTitleFor( 'Movepage' ),
1810 wfMsg( 'movethispage' ),
1812 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1813 array( 'known', 'noclasses' )
1816 // no message if page is protected - would be redundant
1821 function historyLink() {
1824 wfMsgHtml( 'history' ),
1825 array( 'rel' => 'archives' ),
1826 array( 'action' => 'history' )
1830 function whatLinksHere() {
1832 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1833 wfMsgHtml( 'whatlinkshere' ),
1836 array( 'known', 'noclasses' )
1840 function userContribsLink() {
1842 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1843 wfMsgHtml( 'contributions' ),
1846 array( 'known', 'noclasses' )
1850 function showEmailUser( $id ) {
1852 $targetUser = User
::newFromId( $id );
1853 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1854 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1857 function emailUserLink() {
1859 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1860 wfMsg( 'emailuser' ),
1863 array( 'known', 'noclasses' )
1867 function watchPageLinksLink() {
1870 if ( !$wgOut->isArticleRelated() ) {
1871 return '(' . wfMsg( 'notanarticle' ) . ')';
1874 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1875 wfMsg( 'recentchangeslinked-toolbox' ),
1878 array( 'known', 'noclasses' )
1883 function trackbackLink() {
1884 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1885 . wfMsg( 'trackbacklink' ) . '</a>';
1888 function otherLanguages() {
1889 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1891 if ( $wgHideInterlanguageLinks ) {
1895 $a = $wgOut->getLanguageLinks();
1897 if ( 0 == count( $a ) ) {
1901 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1904 if ( $wgContLang->isRTL() ) {
1905 $s .= '<span dir="LTR">';
1908 foreach ( $a as $l ) {
1910 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1915 $nt = Title
::newFromText( $l );
1916 $url = $nt->escapeFullURL();
1917 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1918 $title = htmlspecialchars( $nt->getText() );
1920 if ( $text == '' ) {
1924 $style = $this->getExternalLinkAttributes();
1925 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1928 if ( $wgContLang->isRTL() ) {
1935 function talkLink() {
1936 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1937 # No discussion links for special pages
1941 $linkOptions = array();
1943 if ( $this->mTitle
->isTalkPage() ) {
1944 $link = $this->mTitle
->getSubjectPage();
1945 switch( $link->getNamespace() ) {
1947 $text = wfMsg( 'articlepage' );
1950 $text = wfMsg( 'userpage' );
1953 $text = wfMsg( 'projectpage' );
1956 $text = wfMsg( 'imagepage' );
1957 # Make link known if image exists, even if the desc. page doesn't.
1958 if ( wfFindFile( $link ) )
1959 $linkOptions[] = 'known';
1962 $text = wfMsg( 'mediawikipage' );
1965 $text = wfMsg( 'templatepage' );
1968 $text = wfMsg( 'viewhelppage' );
1971 $text = wfMsg( 'categorypage' );
1974 $text = wfMsg( 'articlepage' );
1977 $link = $this->mTitle
->getTalkPage();
1978 $text = wfMsg( 'talkpage' );
1981 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1986 function commentLink() {
1989 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1993 # __NEWSECTIONLINK___ changes behaviour here
1994 # If it is present, the link points to this page, otherwise
1995 # it points to the talk page
1996 if ( $this->mTitle
->isTalkPage() ) {
1997 $title = $this->mTitle
;
1998 } elseif ( $wgOut->showNewSectionLink() ) {
1999 $title = $this->mTitle
;
2001 $title = $this->mTitle
->getTalkPage();
2006 wfMsg( 'postcomment' ),
2012 array( 'known', 'noclasses' )
2016 function getUploadLink() {
2017 global $wgUploadNavigationUrl;
2019 if ( $wgUploadNavigationUrl ) {
2020 # Using an empty class attribute to avoid automatic setting of "external" class
2021 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
2024 SpecialPage
::getTitleFor( 'Upload' ),
2025 wfMsgHtml( 'upload' ),
2028 array( 'known', 'noclasses' )
2033 /* these are used extensively in SkinTemplate, but also some other places */
2034 static function makeMainPageUrl( $urlaction = '' ) {
2035 $title = Title
::newMainPage();
2036 self
::checkTitle( $title, '' );
2038 return $title->getLocalURL( $urlaction );
2041 static function makeSpecialUrl( $name, $urlaction = '' ) {
2042 $title = SpecialPage
::getTitleFor( $name );
2043 return $title->getLocalURL( $urlaction );
2046 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2047 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
2048 return $title->getLocalURL( $urlaction );
2051 static function makeI18nUrl( $name, $urlaction = '' ) {
2052 $title = Title
::newFromText( wfMsgForContent( $name ) );
2053 self
::checkTitle( $title, $name );
2054 return $title->getLocalURL( $urlaction );
2057 static function makeUrl( $name, $urlaction = '' ) {
2058 $title = Title
::newFromText( $name );
2059 self
::checkTitle( $title, $name );
2061 return $title->getLocalURL( $urlaction );
2065 * If url string starts with http, consider as external URL, else
2068 static function makeInternalOrExternalUrl( $name ) {
2069 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2072 return self
::makeUrl( $name );
2076 # this can be passed the NS number as defined in Language.php
2077 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
2078 $title = Title
::makeTitleSafe( $namespace, $name );
2079 self
::checkTitle( $title, $name );
2081 return $title->getLocalURL( $urlaction );
2084 /* these return an array with the 'href' and boolean 'exists' */
2085 static function makeUrlDetails( $name, $urlaction = '' ) {
2086 $title = Title
::newFromText( $name );
2087 self
::checkTitle( $title, $name );
2090 'href' => $title->getLocalURL( $urlaction ),
2091 'exists' => $title->getArticleID() != 0,
2096 * Make URL details where the article exists (or at least it's convenient to think so)
2098 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2099 $title = Title
::newFromText( $name );
2100 self
::checkTitle( $title, $name );
2103 'href' => $title->getLocalURL( $urlaction ),
2108 # make sure we have some title to operate on
2109 static function checkTitle( &$title, $name ) {
2110 if ( !is_object( $title ) ) {
2111 $title = Title
::newFromText( $name );
2112 if ( !is_object( $title ) ) {
2113 $title = Title
::newFromText( '--error: link target missing--' );
2119 * Build an array that represents the sidebar(s), the navigation bar among them
2123 function buildSidebar() {
2124 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2126 wfProfileIn( __METHOD__
);
2128 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2130 if ( $wgEnableSidebarCache ) {
2131 $cachedsidebar = $parserMemc->get( $key );
2132 if ( $cachedsidebar ) {
2133 wfProfileOut( __METHOD__
);
2134 return $cachedsidebar;
2139 $this->addToSidebar( $bar, 'sidebar' );
2141 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2142 if ( $wgEnableSidebarCache ) {
2143 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2146 wfProfileOut( __METHOD__
);
2150 * Add content from a sidebar system message
2151 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2153 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2155 * @param &$bar array
2156 * @param $message String
2158 function addToSidebar( &$bar, $message ) {
2159 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2163 * Add content from plain text
2165 * @param &$bar array
2166 * @param $text string
2168 function addToSidebarPlain( &$bar, $text ) {
2169 $lines = explode( "\n", $text );
2170 $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.
2174 foreach ( $lines as $line ) {
2175 if ( strpos( $line, '*' ) !== 0 ) {
2179 if ( strpos( $line, '**' ) !== 0 ) {
2180 $heading = trim( $line, '* ' );
2181 if ( !array_key_exists( $heading, $bar ) ) {
2182 $bar[$heading] = array();
2185 $line = trim( $line, '* ' );
2187 if ( strpos( $line, '|' ) !== false ) { // sanity check
2188 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2189 $link = wfMsgForContent( $line[0] );
2191 if ( $link == '-' ) {
2195 $text = wfMsgExt( $line[1], 'parsemag' );
2197 if ( wfEmptyMsg( $line[1], $text ) ) {
2201 if ( wfEmptyMsg( $line[0], $link ) ) {
2205 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2208 $title = Title
::newFromText( $link );
2211 $title = $title->fixSpecialName();
2212 $href = $title->getLocalURL();
2214 $href = 'INVALID-TITLE';
2218 $bar[$heading][] = array(
2221 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2224 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2225 global $wgParser, $wgTitle;
2227 $line = substr( $line, 2, strlen( $line ) - 4 );
2229 $options = new ParserOptions();
2230 $options->setEditSection( false );
2231 $options->setInterfaceMessage( true );
2232 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $options )->getText();
2239 if ( count( $wikiBar ) > 0 ) {
2240 $bar = array_merge( $bar, $wikiBar );
2247 * Should we include common/wikiprintable.css? Skins that have their own
2248 * print stylesheet should override this and return false. (This is an
2249 * ugly hack to get Monobook to play nicely with
2250 * OutputPage::headElement().)
2254 public function commonPrintStylesheet() {
2259 * Gets new talk page messages for the current user.
2260 * @return MediaWiki message or if no new talk page messages, nothing
2262 function getNewtalks() {
2263 global $wgUser, $wgOut;
2265 $newtalks = $wgUser->getNewMessageLinks();
2268 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2269 $userTitle = $this->mUser
->getUserPage();
2270 $userTalkTitle = $userTitle->getTalkPage();
2272 if ( !$userTalkTitle->equals( $this->mTitle
) ) {
2273 $newMessagesLink = $this->link(
2275 wfMsgHtml( 'newmessageslink' ),
2277 array( 'redirect' => 'no' ),
2278 array( 'known', 'noclasses' )
2281 $newMessagesDiffLink = $this->link(
2283 wfMsgHtml( 'newmessagesdifflink' ),
2285 array( 'diff' => 'cur' ),
2286 array( 'known', 'noclasses' )
2290 'youhavenewmessages',
2292 $newMessagesDiffLink
2294 # Disable Squid cache
2295 $wgOut->setSquidMaxage( 0 );
2297 } elseif ( count( $newtalks ) ) {
2298 // _>" " for BC <= 1.16
2299 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2302 foreach ( $newtalks as $newtalk ) {
2303 $msgs[] = Xml
::element(
2305 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2308 $parts = implode( $sep, $msgs );
2309 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2310 $wgOut->setSquidMaxage( 0 );