849223f451693f66e0c26770c20e8ca8bb0c03b2
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 :-\
30 protected $mRelevantTitle = null;
31 protected $mRelevantUser = null;
33 /** Constructor, call parent constructor */
34 function __construct() {
35 parent
::__construct();
39 * Fetch the set of available skins.
40 * @return array of strings
42 static function getSkinNames() {
43 global $wgValidSkinNames;
44 static $skinsInitialised = false;
46 if ( !$skinsInitialised ||
!count( $wgValidSkinNames ) ) {
47 # Get a list of available skins
48 # Build using the regular expression '^(.*).php$'
49 # Array keys are all lower case, array value keep the case used by filename
51 wfProfileIn( __METHOD__
. '-init' );
53 global $wgStyleDirectory;
55 $skinDir = dir( $wgStyleDirectory );
57 # while code from www.php.net
58 while ( false !== ( $file = $skinDir->read() ) ) {
59 // Skip non-PHP files, hidden files, and '.dep' includes
62 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
64 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
68 $skinsInitialised = true;
69 wfProfileOut( __METHOD__
. '-init' );
71 return $wgValidSkinNames;
75 * Fetch the list of usable skins in regards to $wgSkipSkins.
76 * Useful for Special:Preferences and other places where you
77 * only want to show skins users _can_ use.
78 * @return array of strings
80 public static function getUsableSkins() {
83 $usableSkins = self
::getSkinNames();
85 foreach ( $wgSkipSkins as $skip ) {
86 unset( $usableSkins[$skip] );
93 * Normalize a skin preference value to a form that can be loaded.
94 * If a skin can't be found, it will fall back to the configured
95 * default (or the old 'Classic' skin if that's broken).
96 * @param $key String: 'monobook', 'standard', etc.
99 static function normalizeKey( $key ) {
100 global $wgDefaultSkin;
102 $skinNames = Skin
::getSkinNames();
105 // Don't return the default immediately;
106 // in a misconfiguration we need to fall back.
107 $key = $wgDefaultSkin;
110 if ( isset( $skinNames[$key] ) ) {
114 // Older versions of the software used a numeric setting
115 // in the user preferences.
122 if ( isset( $fallback[$key] ) ) {
123 $key = $fallback[$key];
126 if ( isset( $skinNames[$key] ) ) {
128 } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
129 return $wgDefaultSkin;
136 * Factory method for loading a skin of a given type
137 * @param $key String: 'monobook', 'standard', etc.
140 static function &newFromKey( $key ) {
141 global $wgStyleDirectory;
143 $key = Skin
::normalizeKey( $key );
145 $skinNames = Skin
::getSkinNames();
146 $skinName = $skinNames[$key];
147 $className = "Skin{$skinName}";
149 # Grab the skin class and initialise it.
150 if ( !class_exists( $className ) ) {
151 // Preload base classes to work around APC/PHP5 bug
152 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
154 if ( file_exists( $deps ) ) {
155 include_once( $deps );
157 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
159 # Check if we got if not failback to default skin
160 if ( !class_exists( $className ) ) {
161 # DO NOT die if the class isn't found. This breaks maintenance
162 # scripts and can cause a user account to be unrecoverable
163 # except by SQL manipulation if a previously valid skin name
164 # is no longer valid.
165 wfDebug( "Skin class does not exist: $className\n" );
166 $className = 'SkinVector';
167 require_once( "{$wgStyleDirectory}/Vector.php" );
170 $skin = new $className;
174 /** @return string path to the skin stylesheet */
175 function getStylesheet() {
176 return 'common/wikistandard.css';
179 /** @return string skin name */
180 public function getSkinName() {
181 return $this->skinname
;
184 function qbSetting() {
185 global $wgOut, $wgUser;
187 if ( $wgOut->isQuickbarSuppressed() ) {
191 $q = $wgUser->getOption( 'quickbar', 0 );
196 function initPage( OutputPage
$out ) {
197 global $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI;
199 wfProfileIn( __METHOD__
);
201 # Generally the order of the favicon and apple-touch-icon links
202 # should not matter, but Konqueror (3.5.9 at least) incorrectly
203 # uses whichever one appears later in the HTML source. Make sure
204 # apple-touch-icon is specified first to avoid this.
205 if ( false !== $wgAppleTouchIcon ) {
206 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
209 if ( false !== $wgFavicon ) {
210 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
213 # OpenSearch description link
214 $out->addLink( array(
216 'type' => 'application/opensearchdescription+xml',
217 'href' => wfScript( 'opensearch_desc' ),
218 'title' => wfMsgForContent( 'opensearch-desc' ),
221 if ( $wgEnableAPI ) {
222 # Real Simple Discovery link, provides auto-discovery information
223 # for the MediaWiki API (and potentially additional custom API
224 # support such as WordPress or Twitter-compatible APIs for a
225 # blogging extension, etc)
226 $out->addLink( array(
228 'type' => 'application/rsd+xml',
229 'href' => wfExpandUrl( wfAppendQuery( wfScript( 'api' ), array( 'action' => 'rsd' ) ) ),
233 $this->addMetadataLinks( $out );
235 $this->mRevisionId
= $out->mRevisionId
;
237 $this->preloadExistence();
239 wfProfileOut( __METHOD__
);
243 * Preload the existence of three commonly-requested pages in a single query
245 function preloadExistence() {
249 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
252 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
254 } elseif ( $this->mTitle
->isTalkPage() ) {
255 $titles[] = $this->mTitle
->getSubjectPage();
257 $titles[] = $this->mTitle
->getTalkPage();
260 $lb = new LinkBatch( $titles );
261 $lb->setCaller( __METHOD__
);
266 * Adds metadata links below to the HTML output.
268 * <li>Creative Commons
269 * <br />See http://wiki.creativecommons.org/Extend_Metadata.
271 * <li>Dublin Core</li>
272 * <li>Use hreflang to specify canonical and alternate links
273 * <br />See http://www.google.com/support/webmasters/bin/answer.py?answer=189077
278 * @param $out Object: instance of OutputPage
280 function addMetadataLinks( OutputPage
$out ) {
281 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
282 global $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang;
283 global $wgRightsPage, $wgRightsUrl;
285 if ( $out->isArticleRelated() ) {
286 # note: buggy CC software only reads first "meta" link
287 if ( $wgEnableCreativeCommonsRdf ) {
288 $out->addMetadataLink( array(
289 'title' => 'Creative Commons',
290 'type' => 'application/rdf+xml',
291 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
295 if ( $wgEnableDublinCoreRdf ) {
296 $out->addMetadataLink( array(
297 'title' => 'Dublin Core',
298 'type' => 'application/rdf+xml',
299 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
304 if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks
305 && $wgContLang->hasVariants() ) {
307 $urlvar = $wgContLang->getURLVariant();
310 $variants = $wgContLang->getVariants();
311 foreach ( $variants as $_v ) {
312 $out->addLink( array(
313 'rel' => 'alternate',
315 'href' => $this->mTitle
->getLocalURL( '', $_v ) )
319 $out->addLink( array(
320 'rel' => 'canonical',
321 'href' => $this->mTitle
->getFullURL() )
327 if ( $wgRightsPage ) {
328 $copy = Title
::newFromText( $wgRightsPage );
331 $copyright = $copy->getLocalURL();
335 if ( !$copyright && $wgRightsUrl ) {
336 $copyright = $wgRightsUrl;
340 $out->addLink( array(
341 'rel' => 'copyright',
342 'href' => $copyright )
348 * Set some local variables
350 protected function setMembers() {
352 $this->mUser
= $wgUser;
353 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
354 $this->usercss
= false;
359 * @param $t Title object to use
361 public function setTitle( $t ) {
366 public function getTitle() {
367 return $this->mTitle
;
371 * Set the "relevant" title
372 * @see self::getRelevantTitle()
373 * @param $t Title object to use
375 public function setRelevantTitle( $t ) {
376 $this->mRelevantTitle
= $t;
380 * Return the "relevant" title.
381 * A "relevant" title is not necessarily the actual title of the page.
382 * Special pages like Special:MovePage use set the page they are acting on
383 * as their "relevant" title, this allows the skin system to display things
384 * such as content tabs which belong to to that page instead of displaying
385 * a basic special page tab which has almost no meaning.
387 public function getRelevantTitle() {
388 if ( isset($this->mRelevantTitle
) ) {
389 return $this->mRelevantTitle
;
391 return $this->mTitle
;
395 * Set the "relevant" user
396 * @see self::getRelevantUser()
397 * @param $u User object to use
399 public function setRelevantUser( $u ) {
400 $this->mRelevantUser
= $u;
404 * Return the "relevant" user.
405 * A "relevant" user is similar to a relevant title. Special pages like
406 * Special:Contributions mark the user which they are relevant to so that
407 * things like the toolbox can display the information they usually are only
408 * able to display on a user's userpage and talkpage.
410 public function getRelevantUser() {
411 if ( isset($this->mRelevantUser
) ) {
412 return $this->mRelevantUser
;
414 $title = $this->getRelevantTitle();
415 if( $title->getNamespace() == NS_USER ||
$title->getNamespace() == NS_USER_TALK
) {
416 $rootUser = strtok( $title->getText(), '/' );
417 if ( User
::isIP( $rootUser ) ) {
418 $this->mRelevantUser
= User
::newFromName( $rootUser, false );
420 $user = User
::newFromName( $rootUser );
421 if ( $user->isLoggedIn() ) {
422 $this->mRelevantUser
= $user;
425 return $this->mRelevantUser
;
431 * Outputs the HTML generated by other functions.
432 * @param $out Object: instance of OutputPage
434 function outputPage( OutputPage
$out ) {
435 global $wgDebugComments;
436 wfProfileIn( __METHOD__
);
439 $this->initPage( $out );
441 // See self::afterContentHook() for documentation
442 $afterContent = $this->afterContentHook();
444 $out->out( $out->headElement( $this ) );
446 if ( $wgDebugComments ) {
447 $out->out( "<!-- Wiki debugging output:\n" .
448 $out->mDebugtext
. "-->\n" );
451 $out->out( $this->beforeContent() );
453 $out->out( $out->mBodytext
. "\n" );
455 $out->out( $this->afterContent() );
457 $out->out( $afterContent );
459 $out->out( $this->bottomScripts( $out ) );
461 $out->out( wfReportTime() );
463 $out->out( "\n</body></html>" );
464 wfProfileOut( __METHOD__
);
467 static function makeVariablesScript( $data ) {
469 return Html
::inlineScript(
470 ResourceLoader
::makeLoaderConditionalScript( ResourceLoader
::makeConfigSetScript( $data ) )
478 * Make a <script> tag containing global variables
479 * @param $skinName string Name of the skin
480 * The odd calling convention is for backwards compatibility
481 * @todo FIXME: Make this not depend on $wgTitle!
483 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
484 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
486 static function makeGlobalVariablesScript( $skinName ) {
487 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
489 $ns = $wgTitle->getNamespace();
490 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
492 'wgCanonicalNamespace' => $nsname,
493 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
494 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
495 'wgNamespaceNumber' => $wgTitle->getNamespace(),
496 'wgPageName' => $wgTitle->getPrefixedDBKey(),
497 'wgTitle' => $wgTitle->getText(),
498 'wgAction' => $wgRequest->getText( 'action', 'view' ),
499 'wgArticleId' => $wgTitle->getArticleId(),
500 'wgIsArticle' => $wgOut->isArticle(),
501 'wgUserName' => $wgUser->isAnon() ?
null : $wgUser->getName(),
502 'wgUserGroups' => $wgUser->getEffectiveGroups(),
503 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
504 'wgCategories' => $wgOut->getCategories(),
505 'wgBreakFrames' => $wgOut->getFrameOptions() == 'DENY',
507 foreach ( $wgTitle->getRestrictionTypes() as $type ) {
508 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
510 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
511 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
514 // Allow extensions to add their custom variables to the global JS variables
515 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
517 return self
::makeVariablesScript( $vars );
521 * To make it harder for someone to slip a user a fake
522 * user-JavaScript or user-CSS preview, a random token
523 * is associated with the login session. If it's not
524 * passed back with the preview request, we won't render
527 * @param $action String: 'edit', 'submit' etc.
530 public function userCanPreview( $action ) {
531 global $wgRequest, $wgUser;
533 if ( $action != 'submit' ) {
536 if ( !$wgRequest->wasPosted() ) {
539 if ( !$this->mTitle
->userCanEditCssSubpage() ) {
542 if ( !$this->mTitle
->userCanEditJsSubpage() ) {
546 return $wgUser->matchEditToken(
547 $wgRequest->getVal( 'wpEditToken' ) );
551 * Generated JavaScript action=raw&gen=js
552 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
553 * nated together. For some bizarre reason, it does *not* return any
554 * custom user JS from subpages. Huh?
556 * There's absolutely no reason to have separate Monobook/Common JSes.
557 * Any JS that cares can just check the skin variable generated at the
558 * top. For now Monobook.js will be maintained, but it should be consi-
561 * @param $skinName String: If set, overrides the skin name
564 public function generateUserJs( $skinName = null ) {
566 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
572 * Generate user stylesheet for action=raw&gen=css
574 public function generateUserStylesheet() {
576 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
582 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
583 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
585 protected function reallyGenerateUserStylesheet() {
587 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
595 function setupUserCss( OutputPage
$out ) {
597 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
599 wfProfileIn( __METHOD__
);
601 $this->setupSkinUserCss( $out );
602 // Add any extension CSS
603 foreach ( $out->getExtStyle() as $url ) {
604 $out->addStyle( $url );
607 // Per-site custom styles
608 if ( $wgUseSiteCss ) {
609 $out->addModuleStyles( 'site' );
612 // Per-user custom styles
613 if ( $wgAllowUserCss ) {
614 if ( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
615 // @FIXME: properly escape the cdata!
616 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
618 $out->addModuleStyles( 'user' );
622 // Per-user preference styles
623 if ( $wgAllowUserCssPrefs ) {
624 $out->addModuleStyles( 'user.options' );
627 wfProfileOut( __METHOD__
);
631 * Get the query to generate a dynamic stylesheet
635 public static function getDynamicStylesheetQuery() {
636 global $wgSquidMaxage;
640 'maxage' => $wgSquidMaxage,
641 'usemsgcache' => 'yes',
642 'ctype' => 'text/css',
643 'smaxage' => $wgSquidMaxage,
648 * Add skin specific stylesheets
649 * @param $out OutputPage
651 function setupSkinUserCss( OutputPage
$out ) {
652 $out->addModuleStyles( 'mediawiki.legacy.shared' );
653 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
654 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
655 $out->addStyle( $this->getStylesheet() );
656 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
659 function getPageClasses( $title ) {
660 $numeric = 'ns-' . $title->getNamespace();
662 if ( $title->getNamespace() == NS_SPECIAL
) {
663 $type = 'ns-special';
664 } elseif ( $title->isTalkPage() ) {
667 $type = 'ns-subject';
670 $name = Sanitizer
::escapeClass( 'page-' . $title->getPrefixedText() );
672 return "$numeric $type $name";
676 * This will be called by OutputPage::headElement when it is creating the
677 * <body> tag, skins can override it if they have a need to add in any
678 * body attributes or classes of their own.
680 function addToBodyAttributes( $out, &$bodyAttrs ) {
681 // does nothing by default
693 * This will be called immediately after the <body> tag. Split into
694 * two functions to make it easier to subclass.
696 function beforeContent() {
697 return $this->doBeforeContent();
700 function doBeforeContent() {
702 wfProfileIn( __METHOD__
);
705 $qb = $this->qbSetting();
707 $langlinks = $this->otherLanguages();
714 $borderhack = 'class="top"';
717 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
718 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
720 $shove = ( $qb != 0 );
721 $left = ( $qb == 1 ||
$qb == 3 );
723 if ( $wgContLang->isRTL() ) {
728 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
729 $this->logoText() . '</td>';
731 $s .= $this->getQuickbarCompensator( $rows );
734 $l = $wgContLang->alignStart();
735 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
737 $s .= $this->topLinks();
738 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
740 $r = $wgContLang->alignEnd();
741 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
742 $s .= $this->nameAndLogin();
743 $s .= "\n<br />" . $this->searchForm() . '</td>';
746 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
749 if ( $shove && !$left ) { # Right
750 $s .= $this->getQuickbarCompensator( $rows );
753 $s .= "</tr>\n</table>\n</div>\n";
754 $s .= "\n<div id='article'>\n";
756 $notice = wfGetSiteNotice();
759 $s .= "\n<div id='siteNotice'>$notice</div>\n";
761 $s .= $this->pageTitle();
762 $s .= $this->pageSubtitle();
763 $s .= $this->getCategories();
765 wfProfileOut( __METHOD__
);
769 function getCategoryLinks() {
770 global $wgOut, $wgUseCategoryBrowser;
771 global $wgContLang, $wgUser;
773 if ( count( $wgOut->mCategoryLinks
) == 0 ) {
778 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
780 // Use Unicode bidi embedding override characters,
781 // to make sure links don't smash each other up in ugly ways.
782 $dir = $wgContLang->getDir();
783 $embed = "<span dir='$dir'>";
786 $allCats = $wgOut->getCategoryLinks();
788 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
790 if ( !empty( $allCats['normal'] ) ) {
791 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
793 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
794 $s .= '<div id="mw-normal-catlinks">' .
795 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
796 . $colon . $t . '</div>';
800 if ( isset( $allCats['hidden'] ) ) {
801 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
802 $class = 'mw-hidden-cats-user-shown';
803 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
804 $class = 'mw-hidden-cats-ns-shown';
806 $class = 'mw-hidden-cats-hidden';
809 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
810 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
811 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
815 # optional 'dmoz-like' category browser. Will be shown under the list
816 # of categories an article belong to
817 if ( $wgUseCategoryBrowser ) {
818 $s .= '<br /><hr />';
820 # get a big array of the parents tree
821 $parenttree = $this->mTitle
->getParentCategoryTree();
822 # Skin object passed by reference cause it can not be
823 # accessed under the method subfunction drawCategoryBrowser
824 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
825 # Clean out bogus first entry and sort them
826 unset( $tempout[0] );
828 # Output one per line
829 $s .= implode( "<br />\n", $tempout );
836 * Render the array as a serie of links.
837 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
838 * @param &skin Object: skin passed by reference
839 * @return String separated by >, terminate with "\n"
841 function drawCategoryBrowser( $tree, &$skin ) {
844 foreach ( $tree as $element => $parent ) {
845 if ( empty( $parent ) ) {
846 # element start a new list
849 # grab the others elements
850 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
853 # add our current element to the list
854 $eltitle = Title
::newFromText( $element );
855 $return .= $skin->link( $eltitle, $eltitle->getText() );
861 function getCategories() {
862 $catlinks = $this->getCategoryLinks();
864 $classes = 'catlinks';
866 global $wgOut, $wgUser;
868 // Check what we're showing
869 $allCats = $wgOut->getCategoryLinks();
870 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
871 $this->mTitle
->getNamespace() == NS_CATEGORY
;
873 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
874 $classes .= ' catlinks-allhidden';
877 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
880 function getQuickbarCompensator( $rows = 1 ) {
881 return "<td width='152' rowspan='{$rows}'> </td>";
885 * This runs a hook to allow extensions placing their stuff after content
886 * and article metadata (e.g. categories).
887 * Note: This function has nothing to do with afterContent().
889 * This hook is placed here in order to allow using the same hook for all
890 * skins, both the SkinTemplate based ones and the older ones, which directly
891 * use this class to get their data.
893 * The output of this function gets processed in SkinTemplate::outputPage() for
894 * the SkinTemplate based skins, all other skins should directly echo it.
896 * Returns an empty string by default, if not changed by any hook function.
898 protected function afterContentHook() {
901 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
902 // adding just some spaces shouldn't toggle the output
903 // of the whole <div/>, so we use trim() here
904 if ( trim( $data ) != '' ) {
905 // Doing this here instead of in the skins to
906 // ensure that the div has the same ID in all
908 $data = "<div id='mw-data-after-content'>\n" .
913 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
920 * Generate debug data HTML for displaying at the bottom of the main content
922 * @return String HTML containing debug data, if enabled (otherwise empty).
924 protected function generateDebugHTML() {
925 global $wgShowDebug, $wgOut;
927 if ( $wgShowDebug ) {
928 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
929 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
930 $listInternals . "</ul>\n";
936 private function formatDebugHTML( $debugText ) {
937 $lines = explode( "\n", $debugText );
941 foreach ( $lines as $line ) {
942 $display = ltrim( $line );
943 $ident = strlen( $line ) - strlen( $display );
944 $diff = $ident - $curIdent;
946 if ( $display == '' ) {
947 $display = "\xc2\xa0";
950 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
953 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
955 $display = htmlspecialchars( $display );
959 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
960 } elseif ( $diff == 0 ) {
961 $ret .= "</li><li>\n";
963 $ret .= str_repeat( "<ul><li>\n", $diff );
965 $ret .= $display . "\n";
970 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
976 * This gets called shortly before the </body> tag.
977 * @return String HTML to be put before </body>
979 function afterContent() {
980 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
981 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
985 * This gets called shortly before the </body> tag.
986 * @param $out OutputPage object
987 * @return String HTML-wrapped JS code to be put before </body>
989 function bottomScripts( $out ) {
990 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
991 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
993 return $bottomScriptText;
996 /** @return string Retrievied from HTML text */
997 function printSource() {
998 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
999 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
1002 function printFooter() {
1003 return "<p>" . $this->printSource() .
1004 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
1007 /** overloaded by derived classes */
1008 function doAfterContent() {
1009 return '</div></div>';
1012 function pageTitleLinks() {
1013 global $wgOut, $wgUser, $wgRequest, $wgLang;
1015 $oldid = $wgRequest->getVal( 'oldid' );
1016 $diff = $wgRequest->getVal( 'diff' );
1017 $action = $wgRequest->getText( 'action' );
1019 $s[] = $this->printableLink();
1020 $disclaimer = $this->disclaimerLink(); # may be empty
1022 if ( $disclaimer ) {
1026 $privacy = $this->privacyLink(); # may be empty too
1032 if ( $wgOut->isArticleRelated() ) {
1033 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1034 $name = $this->mTitle
->getDBkey();
1035 $image = wfFindFile( $this->mTitle
);
1038 $link = htmlspecialchars( $image->getURL() );
1039 $style = $this->getInternalLinkAttributes( $link, $name );
1040 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1045 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1046 $s[] .= $this->link(
1048 wfMsg( 'currentrev' ),
1051 array( 'known', 'noclasses' )
1055 if ( $wgUser->getNewtalk() ) {
1056 # do not show "You have new messages" text when we are viewing our
1058 if ( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1060 $wgUser->getTalkPage(),
1061 wfMsgHtml( 'newmessageslink' ),
1063 array( 'redirect' => 'no' ),
1064 array( 'known', 'noclasses' )
1068 $wgUser->getTalkPage(),
1069 wfMsgHtml( 'newmessagesdifflink' ),
1071 array( 'diff' => 'cur' ),
1072 array( 'known', 'noclasses' )
1074 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1076 $wgOut->setSquidMaxage( 0 );
1077 $wgOut->enableClientCache( false );
1081 $undelete = $this->getUndeleteLink();
1083 if ( !empty( $undelete ) ) {
1087 return $wgLang->pipeList( $s );
1090 function getUndeleteLink() {
1091 global $wgUser, $wgLang, $wgRequest;
1093 $action = $wgRequest->getVal( 'action', 'view' );
1095 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1096 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1097 $n = $this->mTitle
->isDeleted();
1100 if ( $wgUser->isAllowed( 'undelete' ) ) {
1101 $msg = 'thisisdeleted';
1103 $msg = 'viewdeleted';
1109 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1110 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1113 array( 'known', 'noclasses' )
1122 function printableLink() {
1123 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1127 if ( !$wgOut->isPrintable() ) {
1128 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1129 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1132 if ( $wgOut->isSyndicated() ) {
1133 foreach ( $wgFeedClasses as $format => $class ) {
1134 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1135 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1136 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1139 return $wgLang->pipeList( $s );
1143 * Gets the h1 element with the page title.
1146 function pageTitle() {
1148 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1152 function pageSubtitle() {
1155 $sub = $wgOut->getSubtitle();
1158 global $wgExtraSubtitle;
1159 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1162 $subpages = $this->subPageSubtitle();
1163 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1164 $s = "<p class='subtitle'>{$sub}</p>\n";
1169 function subPageSubtitle() {
1172 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) {
1178 if ( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1179 $ptext = $this->mTitle
->getPrefixedText();
1180 if ( preg_match( '/\//', $ptext ) ) {
1181 $links = explode( '/', $ptext );
1182 array_pop( $links );
1187 foreach ( $links as $link ) {
1188 $growinglink .= $link;
1190 $linkObj = Title
::newFromText( $growinglink );
1192 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1193 $getlink = $this->link(
1195 htmlspecialchars( $display ),
1198 array( 'known', 'noclasses' )
1204 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1206 $subpages .= '< ';
1209 $subpages .= $getlink;
1214 $growinglink .= '/';
1223 * Returns true if the IP should be shown in the header
1225 function showIPinHeader() {
1226 global $wgShowIPinHeader;
1227 return $wgShowIPinHeader && session_id() != '';
1230 function nameAndLogin() {
1231 global $wgUser, $wgLang, $wgContLang;
1233 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1237 if ( $wgUser->isAnon() ) {
1238 if ( $this->showIPinHeader() ) {
1241 $talkLink = $this->link( $wgUser->getTalkPage(),
1242 $wgLang->getNsText( NS_TALK
) );
1244 $ret .= "$name ($talkLink)";
1246 $ret .= wfMsg( 'notloggedin' );
1249 $returnTo = $this->mTitle
->getPrefixedDBkey();
1252 if ( $logoutPage != $returnTo ) {
1253 $query['returnto'] = $returnTo;
1256 $loginlink = $wgUser->isAllowed( 'createaccount' )
1257 ?
'nav-login-createaccount'
1259 $ret .= "\n<br />" . $this->link(
1260 SpecialPage
::getTitleFor( 'Userlogin' ),
1261 wfMsg( $loginlink ), array(), $query
1264 $returnTo = $this->mTitle
->getPrefixedDBkey();
1265 $talkLink = $this->link( $wgUser->getTalkPage(),
1266 $wgLang->getNsText( NS_TALK
) );
1268 $ret .= $this->link( $wgUser->getUserPage(),
1269 htmlspecialchars( $wgUser->getName() ) );
1270 $ret .= " ($talkLink)<br />";
1271 $ret .= $wgLang->pipeList( array(
1273 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1274 array(), array( 'returnto' => $returnTo )
1276 $this->specialLink( 'Preferences' ),
1280 $ret = $wgLang->pipeList( array(
1283 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1291 function getSearchLink() {
1292 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1293 return $searchPage->getLocalURL();
1296 function escapeSearchLink() {
1297 return htmlspecialchars( $this->getSearchLink() );
1300 function searchForm() {
1301 global $wgRequest, $wgUseTwoButtonsSearchForm;
1303 $search = $wgRequest->getText( 'search' );
1305 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
1306 . $this->escapeSearchLink() . "\">\n"
1307 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
1308 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1309 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1311 if ( $wgUseTwoButtonsSearchForm ) {
1312 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1314 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1319 // Ensure unique id's for search boxes made after the first
1320 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1325 function topLinks() {
1329 $this->mainPageLink(),
1330 $this->specialLink( 'Recentchanges' )
1333 if ( $wgOut->isArticleRelated() ) {
1334 $s[] = $this->editThisPage();
1335 $s[] = $this->historyLink();
1338 # Many people don't like this dropdown box
1339 # $s[] = $this->specialPagesList();
1341 if ( $this->variantLinks() ) {
1342 $s[] = $this->variantLinks();
1345 if ( $this->extensionTabLinks() ) {
1346 $s[] = $this->extensionTabLinks();
1349 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1350 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1354 * Compatibility for extensions adding functionality through tabs.
1355 * Eventually these old skins should be replaced with SkinTemplate-based
1359 function extensionTabLinks() {
1363 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1364 foreach ( $tabs as $tab ) {
1365 $s[] = Xml
::element( 'a',
1366 array( 'href' => $tab['href'] ),
1370 if ( count( $s ) ) {
1373 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1374 $out .= $wgLang->pipeList( $s );
1381 * Language/charset variant links for classic-style skins
1384 function variantLinks() {
1387 /* show links to different language variants */
1388 global $wgDisableLangConversion, $wgLang, $wgContLang;
1390 $variants = $wgContLang->getVariants();
1392 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1393 foreach ( $variants as $code ) {
1394 $varname = $wgContLang->getVariantname( $code );
1396 if ( $varname == 'disable' ) {
1399 $s = $wgLang->pipeList( array(
1401 '<a href="' . $this->mTitle
->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1409 function bottomLinks() {
1410 global $wgOut, $wgUser, $wgUseTrackbacks;
1411 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1414 if ( $wgOut->isArticleRelated() ) {
1415 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1417 if ( $wgUser->isLoggedIn() ) {
1418 $element[] = $this->watchThisPage();
1421 $element[] = $this->talkLink();
1422 $element[] = $this->historyLink();
1423 $element[] = $this->whatLinksHere();
1424 $element[] = $this->watchPageLinksLink();
1426 if ( $wgUseTrackbacks ) {
1427 $element[] = $this->trackbackLink();
1431 $this->mTitle
->getNamespace() == NS_USER ||
1432 $this->mTitle
->getNamespace() == NS_USER_TALK
1434 $id = User
::idFromName( $this->mTitle
->getText() );
1435 $ip = User
::isIP( $this->mTitle
->getText() );
1437 # Both anons and non-anons have contributions list
1439 $element[] = $this->userContribsLink();
1442 if ( $this->showEmailUser( $id ) ) {
1443 $element[] = $this->emailUserLink();
1447 $s = implode( $element, $sep );
1449 if ( $this->mTitle
->getArticleId() ) {
1452 // Delete/protect/move links for privileged users
1453 if ( $wgUser->isAllowed( 'delete' ) ) {
1454 $s .= $this->deleteThisPage();
1457 if ( $wgUser->isAllowed( 'protect' ) ) {
1458 $s .= $sep . $this->protectThisPage();
1461 if ( $wgUser->isAllowed( 'move' ) ) {
1462 $s .= $sep . $this->moveThisPage();
1466 $s .= "<br />\n" . $this->otherLanguages();
1472 function pageStats() {
1473 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1474 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1476 $oldid = $wgRequest->getVal( 'oldid' );
1477 $diff = $wgRequest->getVal( 'diff' );
1479 if ( !$wgOut->isArticle() ) {
1483 if ( !$wgArticle instanceof Article
) {
1487 if ( isset( $oldid ) ||
isset( $diff ) ) {
1491 if ( 0 == $wgArticle->getID() ) {
1497 if ( !$wgDisableCounters ) {
1498 $count = $wgLang->formatNum( $wgArticle->getCount() );
1501 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1505 if ( $wgMaxCredits != 0 ) {
1506 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1508 $s .= $this->lastModified();
1511 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1512 $dbr = wfGetDB( DB_SLAVE
);
1513 $res = $dbr->select(
1515 array( 'COUNT(*) AS n' ),
1517 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ),
1518 'wl_namespace' => $this->mTitle
->getNamespace()
1522 $x = $dbr->fetchObject( $res );
1524 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1525 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1529 return $s . ' ' . $this->getCopyright();
1532 function getCopyright( $type = 'detect' ) {
1533 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1535 if ( $type == 'detect' ) {
1536 $diff = $wgRequest->getVal( 'diff' );
1537 $isCur = $wgArticle && $wgArticle->isCurrent();
1539 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1546 if ( $type == 'history' ) {
1547 $msg = 'history_copyright';
1554 if ( $wgRightsPage ) {
1555 $title = Title
::newFromText( $wgRightsPage );
1556 $link = $this->linkKnown( $title, $wgRightsText );
1557 } elseif ( $wgRightsUrl ) {
1558 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1559 } elseif ( $wgRightsText ) {
1560 $link = $wgRightsText;
1566 // Allow for site and per-namespace customization of copyright notice.
1569 wfRunHooks( 'SkinCopyrightFooter', array( $this->mTitle
, $type, &$msg, &$link, &$forContent ) );
1571 if ( $forContent ) {
1572 $out .= wfMsgForContent( $msg, $link );
1574 $out .= wfMsg( $msg, $link );
1580 function getCopyrightIcon() {
1581 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1585 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1586 $out = $wgCopyrightIcon;
1587 } elseif ( $wgRightsIcon ) {
1588 $icon = htmlspecialchars( $wgRightsIcon );
1590 if ( $wgRightsUrl ) {
1591 $url = htmlspecialchars( $wgRightsUrl );
1592 $out .= '<a href="' . $url . '">';
1595 $text = htmlspecialchars( $wgRightsText );
1596 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1598 if ( $wgRightsUrl ) {
1607 * Gets the powered by MediaWiki icon.
1610 function getPoweredBy() {
1611 global $wgStylePath;
1613 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1614 $text = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1615 wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
1619 function lastModified() {
1620 global $wgLang, $wgArticle;
1622 if ( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest() ) {
1623 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1625 $timestamp = $wgArticle->getTimestamp();
1629 $d = $wgLang->date( $timestamp, true );
1630 $t = $wgLang->time( $timestamp, true );
1631 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1636 if ( wfGetLB()->getLaggedSlaveMode() ) {
1637 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1643 function logoText( $align = '' ) {
1644 if ( $align != '' ) {
1645 $a = " align='{$align}'";
1650 $mp = wfMsg( 'mainpage' );
1651 $mptitle = Title
::newMainPage();
1652 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1654 $logourl = $this->getLogo();
1655 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1661 * Show a drop-down box of special pages
1663 function specialPagesList() {
1664 global $wgContLang, $wgServer, $wgRedirectScript;
1666 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1668 foreach ( $pages as $name => $page ) {
1669 $pages[$name] = $page->getDescription();
1672 $go = wfMsg( 'go' );
1673 $sp = wfMsg( 'specialpages' );
1674 $spp = $wgContLang->specialPage( 'Specialpages' );
1676 $s = '<form id="specialpages" method="get" ' .
1677 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1678 $s .= "<select name=\"wpDropdown\">\n";
1679 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1682 foreach ( $pages as $name => $desc ) {
1683 $p = $wgContLang->specialPage( $name );
1684 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1687 $s .= "</select>\n";
1688 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1695 * Renders a $wgFooterIcons icon acording to the method's arguments
1696 * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array
1697 * @param $withImage Boolean: Whether to use the icon's image or output a text-only footericon
1699 function makeFooterIcon( $icon, $withImage = 'withImage' ) {
1700 if ( is_string( $icon ) ) {
1702 } else { // Assuming array
1703 $url = $icon["url"];
1704 unset( $icon["url"] );
1705 if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
1706 $html = Html
::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
1708 $html = htmlspecialchars( $icon["alt"] );
1711 $html = Html
::rawElement( 'a', array( "href" => $url ), $html );
1718 * Gets the link to the wiki's main page.
1721 function mainPageLink() {
1723 Title
::newMainPage(),
1724 wfMsg( 'mainpage' ),
1727 array( 'known', 'noclasses' )
1733 public function footerLink( $desc, $page ) {
1734 // if the link description has been set to "-" in the default language,
1735 if ( wfMsgForContent( $desc ) == '-' ) {
1736 // then it is disabled, for all languages.
1739 // Otherwise, we display the link for the user, described in their
1740 // language (which may or may not be the same as the default language),
1741 // but we make the link target be the one site-wide page.
1742 $title = Title
::newFromText( wfMsgForContent( $page ) );
1744 return $this->linkKnown(
1746 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1752 * Gets the link to the wiki's privacy policy page.
1754 function privacyLink() {
1755 return $this->footerLink( 'privacy', 'privacypage' );
1759 * Gets the link to the wiki's about page.
1761 function aboutLink() {
1762 return $this->footerLink( 'aboutsite', 'aboutpage' );
1766 * Gets the link to the wiki's general disclaimers page.
1768 function disclaimerLink() {
1769 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1772 function editThisPage() {
1775 if ( !$wgOut->isArticleRelated() ) {
1776 $s = wfMsg( 'protectedpage' );
1778 if ( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1779 $t = wfMsg( 'editthispage' );
1780 } elseif ( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1781 $t = wfMsg( 'create-this-page' );
1783 $t = wfMsg( 'viewsource' );
1790 $this->editUrlOptions(),
1791 array( 'known', 'noclasses' )
1799 * Return URL options for the 'edit page' link.
1800 * This may include an 'oldid' specifier, if the current page view is such.
1805 function editUrlOptions() {
1808 $options = array( 'action' => 'edit' );
1810 if ( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1811 $options['oldid'] = intval( $this->mRevisionId
);
1817 function deleteThisPage() {
1818 global $wgUser, $wgRequest;
1820 $diff = $wgRequest->getVal( 'diff' );
1822 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1823 $t = wfMsg( 'deletethispage' );
1829 array( 'action' => 'delete' ),
1830 array( 'known', 'noclasses' )
1839 function protectThisPage() {
1840 global $wgUser, $wgRequest;
1842 $diff = $wgRequest->getVal( 'diff' );
1844 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1845 if ( $this->mTitle
->isProtected() ) {
1846 $text = wfMsg( 'unprotectthispage' );
1847 $query = array( 'action' => 'unprotect' );
1849 $text = wfMsg( 'protectthispage' );
1850 $query = array( 'action' => 'protect' );
1858 array( 'known', 'noclasses' )
1867 function watchThisPage() {
1869 ++
$this->mWatchLinkNum
;
1871 if ( $wgOut->isArticleRelated() ) {
1872 if ( $this->mTitle
->userIsWatching() ) {
1873 $text = wfMsg( 'unwatchthispage' );
1874 $query = array( 'action' => 'unwatch' );
1875 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1877 $text = wfMsg( 'watchthispage' );
1878 $query = array( 'action' => 'watch' );
1879 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1885 array( 'id' => $id ),
1887 array( 'known', 'noclasses' )
1890 $s = wfMsg( 'notanarticle' );
1896 function moveThisPage() {
1897 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1899 SpecialPage
::getTitleFor( 'Movepage' ),
1900 wfMsg( 'movethispage' ),
1902 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1903 array( 'known', 'noclasses' )
1906 // no message if page is protected - would be redundant
1911 function historyLink() {
1914 wfMsgHtml( 'history' ),
1915 array( 'rel' => 'archives' ),
1916 array( 'action' => 'history' )
1920 function whatLinksHere() {
1922 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1923 wfMsgHtml( 'whatlinkshere' ),
1926 array( 'known', 'noclasses' )
1930 function userContribsLink() {
1932 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1933 wfMsgHtml( 'contributions' ),
1936 array( 'known', 'noclasses' )
1940 function showEmailUser( $id ) {
1942 $targetUser = User
::newFromId( $id );
1943 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1944 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1947 function emailUserLink() {
1949 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1950 wfMsg( 'emailuser' ),
1953 array( 'known', 'noclasses' )
1957 function watchPageLinksLink() {
1960 if ( !$wgOut->isArticleRelated() ) {
1961 return '(' . wfMsg( 'notanarticle' ) . ')';
1964 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1965 wfMsg( 'recentchangeslinked-toolbox' ),
1968 array( 'known', 'noclasses' )
1973 function trackbackLink() {
1974 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1975 . wfMsg( 'trackbacklink' ) . '</a>';
1978 function otherLanguages() {
1979 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1981 if ( $wgHideInterlanguageLinks ) {
1985 $a = $wgOut->getLanguageLinks();
1987 if ( 0 == count( $a ) ) {
1991 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1994 if ( $wgContLang->isRTL() ) {
1995 $s .= '<span dir="LTR">';
1998 foreach ( $a as $l ) {
2000 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
2005 $nt = Title
::newFromText( $l );
2006 $url = $nt->escapeFullURL();
2007 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
2008 $title = htmlspecialchars( $nt->getText() );
2010 if ( $text == '' ) {
2014 $style = $this->getExternalLinkAttributes();
2015 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
2018 if ( $wgContLang->isRTL() ) {
2025 function talkLink() {
2026 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
2027 # No discussion links for special pages
2031 $linkOptions = array();
2033 if ( $this->mTitle
->isTalkPage() ) {
2034 $link = $this->mTitle
->getSubjectPage();
2035 switch( $link->getNamespace() ) {
2037 $text = wfMsg( 'articlepage' );
2040 $text = wfMsg( 'userpage' );
2043 $text = wfMsg( 'projectpage' );
2046 $text = wfMsg( 'imagepage' );
2047 # Make link known if image exists, even if the desc. page doesn't.
2048 if ( wfFindFile( $link ) )
2049 $linkOptions[] = 'known';
2052 $text = wfMsg( 'mediawikipage' );
2055 $text = wfMsg( 'templatepage' );
2058 $text = wfMsg( 'viewhelppage' );
2061 $text = wfMsg( 'categorypage' );
2064 $text = wfMsg( 'articlepage' );
2067 $link = $this->mTitle
->getTalkPage();
2068 $text = wfMsg( 'talkpage' );
2071 $s = $this->link( $link, $text, array(), array(), $linkOptions );
2076 function commentLink() {
2079 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
2083 # __NEWSECTIONLINK___ changes behaviour here
2084 # If it is present, the link points to this page, otherwise
2085 # it points to the talk page
2086 if ( $this->mTitle
->isTalkPage() ) {
2087 $title = $this->mTitle
;
2088 } elseif ( $wgOut->showNewSectionLink() ) {
2089 $title = $this->mTitle
;
2091 $title = $this->mTitle
->getTalkPage();
2096 wfMsg( 'postcomment' ),
2102 array( 'known', 'noclasses' )
2106 function getUploadLink() {
2107 global $wgUploadNavigationUrl;
2109 if ( $wgUploadNavigationUrl ) {
2110 # Using an empty class attribute to avoid automatic setting of "external" class
2111 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
2114 SpecialPage
::getTitleFor( 'Upload' ),
2115 wfMsgHtml( 'upload' ),
2118 array( 'known', 'noclasses' )
2124 * Return a fully resolved style path url to images or styles stored in the common folder.
2125 * This method returns a url resolved using the configured skin style path
2126 * and includes the style version inside of the url.
2127 * @param $name String: The name or path of a skin resource file
2128 * @return String The fully resolved style path url including styleversion
2130 function getCommonStylePath( $name ) {
2131 global $wgStylePath, $wgStyleVersion;
2132 return "$wgStylePath/common/$name?$wgStyleVersion";
2136 * Return a fully resolved style path url to images or styles stored in the curent skins's folder.
2137 * This method returns a url resolved using the configured skin style path
2138 * and includes the style version inside of the url.
2139 * @param $name String: The name or path of a skin resource file
2140 * @return String The fully resolved style path url including styleversion
2142 function getSkinStylePath( $name ) {
2143 global $wgStylePath, $wgStyleVersion;
2144 return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
2147 /* these are used extensively in SkinTemplate, but also some other places */
2148 static function makeMainPageUrl( $urlaction = '' ) {
2149 $title = Title
::newMainPage();
2150 self
::checkTitle( $title, '' );
2152 return $title->getLocalURL( $urlaction );
2155 static function makeSpecialUrl( $name, $urlaction = '' ) {
2156 $title = SpecialPage
::getTitleFor( $name );
2157 return $title->getLocalURL( $urlaction );
2160 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2161 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
2162 return $title->getLocalURL( $urlaction );
2165 static function makeI18nUrl( $name, $urlaction = '' ) {
2166 $title = Title
::newFromText( wfMsgForContent( $name ) );
2167 self
::checkTitle( $title, $name );
2168 return $title->getLocalURL( $urlaction );
2171 static function makeUrl( $name, $urlaction = '' ) {
2172 $title = Title
::newFromText( $name );
2173 self
::checkTitle( $title, $name );
2175 return $title->getLocalURL( $urlaction );
2179 * If url string starts with http, consider as external URL, else
2182 static function makeInternalOrExternalUrl( $name ) {
2183 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2186 return self
::makeUrl( $name );
2190 # this can be passed the NS number as defined in Language.php
2191 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
2192 $title = Title
::makeTitleSafe( $namespace, $name );
2193 self
::checkTitle( $title, $name );
2195 return $title->getLocalURL( $urlaction );
2198 /* these return an array with the 'href' and boolean 'exists' */
2199 static function makeUrlDetails( $name, $urlaction = '' ) {
2200 $title = Title
::newFromText( $name );
2201 self
::checkTitle( $title, $name );
2204 'href' => $title->getLocalURL( $urlaction ),
2205 'exists' => $title->getArticleID() != 0,
2210 * Make URL details where the article exists (or at least it's convenient to think so)
2212 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2213 $title = Title
::newFromText( $name );
2214 self
::checkTitle( $title, $name );
2217 'href' => $title->getLocalURL( $urlaction ),
2222 # make sure we have some title to operate on
2223 static function checkTitle( &$title, $name ) {
2224 if ( !is_object( $title ) ) {
2225 $title = Title
::newFromText( $name );
2226 if ( !is_object( $title ) ) {
2227 $title = Title
::newFromText( '--error: link target missing--' );
2233 * Build an array that represents the sidebar(s), the navigation bar among them
2237 function buildSidebar() {
2238 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2240 wfProfileIn( __METHOD__
);
2242 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2244 if ( $wgEnableSidebarCache ) {
2245 $cachedsidebar = $parserMemc->get( $key );
2246 if ( $cachedsidebar ) {
2247 wfProfileOut( __METHOD__
);
2248 return $cachedsidebar;
2253 $this->addToSidebar( $bar, 'sidebar' );
2255 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2256 if ( $wgEnableSidebarCache ) {
2257 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2260 wfProfileOut( __METHOD__
);
2264 * Add content from a sidebar system message
2265 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2267 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2269 * @param &$bar array
2270 * @param $message String
2272 function addToSidebar( &$bar, $message ) {
2273 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2277 * Add content from plain text
2279 * @param &$bar array
2280 * @param $text string
2282 function addToSidebarPlain( &$bar, $text ) {
2283 $lines = explode( "\n", $text );
2284 $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.
2288 foreach ( $lines as $line ) {
2289 if ( strpos( $line, '*' ) !== 0 ) {
2293 if ( strpos( $line, '**' ) !== 0 ) {
2294 $heading = trim( $line, '* ' );
2295 if ( !array_key_exists( $heading, $bar ) ) {
2296 $bar[$heading] = array();
2299 $line = trim( $line, '* ' );
2301 if ( strpos( $line, '|' ) !== false ) { // sanity check
2302 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2303 $link = wfMsgForContent( $line[0] );
2305 if ( $link == '-' ) {
2309 $text = wfMsgExt( $line[1], 'parsemag' );
2311 if ( wfEmptyMsg( $line[1], $text ) ) {
2315 if ( wfEmptyMsg( $line[0], $link ) ) {
2319 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2322 $title = Title
::newFromText( $link );
2325 $title = $title->fixSpecialName();
2326 $href = $title->getLocalURL();
2328 $href = 'INVALID-TITLE';
2332 $bar[$heading][] = array(
2335 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2338 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2339 global $wgParser, $wgTitle;
2341 $line = substr( $line, 2, strlen( $line ) - 4 );
2343 $options = new ParserOptions();
2344 $options->setEditSection( false );
2345 $options->setInterfaceMessage( true );
2346 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $options )->getText();
2353 if ( count( $wikiBar ) > 0 ) {
2354 $bar = array_merge( $bar, $wikiBar );
2361 * Should we include common/wikiprintable.css? Skins that have their own
2362 * print stylesheet should override this and return false. (This is an
2363 * ugly hack to get Monobook to play nicely with
2364 * OutputPage::headElement().)
2368 public function commonPrintStylesheet() {
2373 * Gets new talk page messages for the current user.
2374 * @return MediaWiki message or if no new talk page messages, nothing
2376 function getNewtalks() {
2377 global $wgUser, $wgOut;
2379 $newtalks = $wgUser->getNewMessageLinks();
2382 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2383 $userTitle = $this->mUser
->getUserPage();
2384 $userTalkTitle = $userTitle->getTalkPage();
2386 if ( !$userTalkTitle->equals( $this->mTitle
) ) {
2387 $newMessagesLink = $this->link(
2389 wfMsgHtml( 'newmessageslink' ),
2391 array( 'redirect' => 'no' ),
2392 array( 'known', 'noclasses' )
2395 $newMessagesDiffLink = $this->link(
2397 wfMsgHtml( 'newmessagesdifflink' ),
2399 array( 'diff' => 'cur' ),
2400 array( 'known', 'noclasses' )
2404 'youhavenewmessages',
2406 $newMessagesDiffLink
2408 # Disable Squid cache
2409 $wgOut->setSquidMaxage( 0 );
2411 } elseif ( count( $newtalks ) ) {
2412 // _>" " for BC <= 1.16
2413 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2416 foreach ( $newtalks as $newtalk ) {
2417 $msgs[] = Xml
::element(
2419 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2422 $parts = implode( $sep, $msgs );
2423 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2424 $wgOut->setSquidMaxage( 0 );