3 * @defgroup Skins Skins
6 if ( !defined( 'MEDIAWIKI' ) ) {
11 * The main skin class that provide methods and properties for all other skins.
12 * This base class is also the "Standard" skin.
14 * See docs/skin.txt for more information.
18 class Skin
extends Linker
{
22 var $mWatchLinkNum = 0; // Appended to end of watch link id's
23 // How many search boxes have we made? Avoid duplicate id's.
24 protected $searchboxes = '';
26 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
27 protected $skinname = 'standard';
28 // @todo Fixme: should be protected :-\
31 /** Constructor, call parent constructor */
32 function __construct() {
33 parent
::__construct();
37 * Fetch the set of available skins.
38 * @return array of strings
40 static function getSkinNames() {
41 global $wgValidSkinNames;
42 static $skinsInitialised = false;
44 if ( !$skinsInitialised ) {
45 # Get a list of available skins
46 # Build using the regular expression '^(.*).php$'
47 # Array keys are all lower case, array value keep the case used by filename
49 wfProfileIn( __METHOD__
. '-init' );
51 global $wgStyleDirectory;
53 $skinDir = dir( $wgStyleDirectory );
55 # while code from www.php.net
56 while ( false !== ( $file = $skinDir->read() ) ) {
57 // Skip non-PHP files, hidden files, and '.dep' includes
60 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
62 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
66 $skinsInitialised = true;
67 wfProfileOut( __METHOD__
. '-init' );
69 return $wgValidSkinNames;
73 * Fetch the list of usable skins in regards to $wgSkipSkins.
74 * Useful for Special:Preferences and other places where you
75 * only want to show skins users _can_ use.
76 * @return array of strings
78 public static function getUsableSkins() {
81 $usableSkins = self
::getSkinNames();
83 foreach ( $wgSkipSkins as $skip ) {
84 unset( $usableSkins[$skip] );
91 * Normalize a skin preference value to a form that can be loaded.
92 * If a skin can't be found, it will fall back to the configured
93 * default (or the old 'Classic' skin if that's broken).
94 * @param $key String: 'monobook', 'standard', etc.
97 static function normalizeKey( $key ) {
98 global $wgDefaultSkin;
100 $skinNames = Skin
::getSkinNames();
103 // Don't return the default immediately;
104 // in a misconfiguration we need to fall back.
105 $key = $wgDefaultSkin;
108 if ( isset( $skinNames[$key] ) ) {
112 // Older versions of the software used a numeric setting
113 // in the user preferences.
120 if ( isset( $fallback[$key] ) ) {
121 $key = $fallback[$key];
124 if ( isset( $skinNames[$key] ) ) {
126 } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
127 return $wgDefaultSkin;
134 * Factory method for loading a skin of a given type
135 * @param $key String: 'monobook', 'standard', etc.
138 static function &newFromKey( $key ) {
139 global $wgStyleDirectory;
141 $key = Skin
::normalizeKey( $key );
143 $skinNames = Skin
::getSkinNames();
144 $skinName = $skinNames[$key];
145 $className = 'Skin' . ucfirst( $key );
147 # Grab the skin class and initialise it.
148 if ( !class_exists( $className ) ) {
149 // Preload base classes to work around APC/PHP5 bug
150 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
152 if ( file_exists( $deps ) ) {
153 include_once( $deps );
155 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
157 # Check if we got if not failback to default skin
158 if ( !class_exists( $className ) ) {
159 # DO NOT die if the class isn't found. This breaks maintenance
160 # scripts and can cause a user account to be unrecoverable
161 # except by SQL manipulation if a previously valid skin name
162 # is no longer valid.
163 wfDebug( "Skin class does not exist: $className\n" );
164 $className = 'SkinVector';
165 require_once( "{$wgStyleDirectory}/Vector.php" );
168 $skin = new $className;
172 /** @return string path to the skin stylesheet */
173 function getStylesheet() {
174 return 'common/wikistandard.css';
177 /** @return string skin name */
178 public function getSkinName() {
179 return $this->skinname
;
182 function qbSetting() {
183 global $wgOut, $wgUser;
185 if ( $wgOut->isQuickbarSuppressed() ) {
189 $q = $wgUser->getOption( 'quickbar', 0 );
194 function initPage( OutputPage
$out ) {
195 global $wgFavicon, $wgAppleTouchIcon;
197 wfProfileIn( __METHOD__
);
199 # Generally the order of the favicon and apple-touch-icon links
200 # should not matter, but Konqueror (3.5.9 at least) incorrectly
201 # uses whichever one appears later in the HTML source. Make sure
202 # apple-touch-icon is specified first to avoid this.
203 if ( false !== $wgAppleTouchIcon ) {
204 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
207 if ( false !== $wgFavicon ) {
208 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
211 # OpenSearch description link
212 $out->addLink( array(
214 'type' => 'application/opensearchdescription+xml',
215 'href' => wfScript( 'opensearch_desc' ),
216 'title' => wfMsgForContent( 'opensearch-desc' ),
219 $this->addMetadataLinks( $out );
221 $this->mRevisionId
= $out->mRevisionId
;
223 $this->preloadExistence();
225 wfProfileOut( __METHOD__
);
229 * Preload the existence of three commonly-requested pages in a single query
231 function preloadExistence() {
235 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
238 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
240 } elseif ( $this->mTitle
->isTalkPage() ) {
241 $titles[] = $this->mTitle
->getSubjectPage();
243 $titles[] = $this->mTitle
->getTalkPage();
246 $lb = new LinkBatch( $titles );
247 $lb->setCaller( __METHOD__
);
252 * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
254 * @param $out Object: instance of OutputPage
256 function addMetadataLinks( OutputPage
$out ) {
257 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
258 global $wgRightsPage, $wgRightsUrl;
260 if ( $out->isArticleRelated() ) {
261 # note: buggy CC software only reads first "meta" link
262 if ( $wgEnableCreativeCommonsRdf ) {
263 $out->addMetadataLink( array(
264 'title' => 'Creative Commons',
265 'type' => 'application/rdf+xml',
266 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
270 if ( $wgEnableDublinCoreRdf ) {
271 $out->addMetadataLink( array(
272 'title' => 'Dublin Core',
273 'type' => 'application/rdf+xml',
274 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
279 if ( $wgRightsPage ) {
280 $copy = Title
::newFromText( $wgRightsPage );
283 $copyright = $copy->getLocalURL();
287 if ( !$copyright && $wgRightsUrl ) {
288 $copyright = $wgRightsUrl;
292 $out->addLink( array(
293 'rel' => 'copyright',
294 'href' => $copyright )
300 * Set some local variables
302 protected function setMembers() {
304 $this->mUser
= $wgUser;
305 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
306 $this->usercss
= false;
311 * @param $t Title object to use
313 public function setTitle( $t ) {
318 public function getTitle() {
319 return $this->mTitle
;
323 * Outputs the HTML generated by other functions.
324 * @param $out Object: instance of OutputPage
326 function outputPage( OutputPage
$out ) {
327 global $wgDebugComments;
328 wfProfileIn( __METHOD__
);
331 $this->initPage( $out );
333 // See self::afterContentHook() for documentation
334 $afterContent = $this->afterContentHook();
336 $out->out( $out->headElement( $this ) );
338 if ( $wgDebugComments ) {
339 $out->out( "<!-- Wiki debugging output:\n" .
340 $out->mDebugtext
. "-->\n" );
343 $out->out( $this->beforeContent() );
345 $out->out( $out->mBodytext
. "\n" );
347 $out->out( $this->afterContent() );
349 $out->out( $afterContent );
351 $out->out( $this->bottomScripts( $out ) );
353 $out->out( wfReportTime() );
355 $out->out( "\n</body></html>" );
356 wfProfileOut( __METHOD__
);
359 static function makeVariablesScript( $data ) {
361 return Html
::inlineScript(
362 ResourceLoader
::makeLoaderConditionalScript( ResourceLoader
::makeConfigSetScript( $data ) )
370 * Make a <script> tag containing global variables
371 * @param $skinName string Name of the skin
372 * The odd calling convention is for backwards compatibility
373 * @todo FIXME: Make this not depend on $wgTitle!
375 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
376 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
378 static function makeGlobalVariablesScript( $skinName ) {
379 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
381 $ns = $wgTitle->getNamespace();
382 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
384 'wgCanonicalNamespace' => $nsname,
385 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
386 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
387 'wgNamespaceNumber' => $wgTitle->getNamespace(),
388 'wgPageName' => $wgTitle->getPrefixedDBKey(),
389 'wgTitle' => $wgTitle->getText(),
390 'wgAction' => $wgRequest->getText( 'action', 'view' ),
391 'wgArticleId' => $wgTitle->getArticleId(),
392 'wgIsArticle' => $wgOut->isArticle(),
393 'wgUserName' => $wgUser->isAnon() ?
null : $wgUser->getName(),
394 'wgUserGroups' => $wgUser->getEffectiveGroups(),
395 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
396 'wgCategories' => $wgOut->getCategories(),
398 foreach ( $wgRestrictionTypes as $type ) {
399 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
401 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
402 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
405 // Allow extensions to add their custom variables to the global JS variables
406 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
408 return self
::makeVariablesScript( $vars );
412 * To make it harder for someone to slip a user a fake
413 * user-JavaScript or user-CSS preview, a random token
414 * is associated with the login session. If it's not
415 * passed back with the preview request, we won't render
418 * @param $action String: 'edit', 'submit' etc.
421 public function userCanPreview( $action ) {
422 global $wgRequest, $wgUser;
424 if ( $action != 'submit' ) {
427 if ( !$wgRequest->wasPosted() ) {
430 if ( !$this->mTitle
->userCanEditCssSubpage() ) {
433 if ( !$this->mTitle
->userCanEditJsSubpage() ) {
437 return $wgUser->matchEditToken(
438 $wgRequest->getVal( 'wpEditToken' ) );
442 * Generated JavaScript action=raw&gen=js
443 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
444 * nated together. For some bizarre reason, it does *not* return any
445 * custom user JS from subpages. Huh?
447 * There's absolutely no reason to have separate Monobook/Common JSes.
448 * Any JS that cares can just check the skin variable generated at the
449 * top. For now Monobook.js will be maintained, but it should be consi-
452 * @param $skinName String: If set, overrides the skin name
455 public function generateUserJs( $skinName = null ) {
457 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
463 * Generate user stylesheet for action=raw&gen=css
465 public function generateUserStylesheet() {
467 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
473 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
474 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
476 protected function reallyGenerateUserStylesheet() {
478 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
486 function setupUserCss( OutputPage
$out ) {
488 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
490 wfProfileIn( __METHOD__
);
492 $this->setupSkinUserCss( $out );
496 'maxage' => $wgSquidMaxage,
499 // Add any extension CSS
500 foreach ( $out->getExtStyle() as $url ) {
501 $out->addStyle( $url );
504 // Per-site custom styles
505 if ( $wgUseSiteCss ) {
506 $out->addModuleStyles( 'site' );
509 // Per-user custom styles
510 if ( $wgAllowUserCss ) {
511 if ( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
512 // @FIXME: properly escape the cdata!
513 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
515 $out->addModuleStyles( 'user' );
519 // Per-user preference styles
520 if ( $wgAllowUserCssPrefs ) {
521 $out->addModuleStyles( 'user.options' );
524 wfProfileOut( __METHOD__
);
528 * Get the query to generate a dynamic stylesheet
532 public static function getDynamicStylesheetQuery() {
533 global $wgSquidMaxage;
537 'maxage' => $wgSquidMaxage,
538 'usemsgcache' => 'yes',
539 'ctype' => 'text/css',
540 'smaxage' => $wgSquidMaxage,
545 * Add skin specific stylesheets
546 * @param $out OutputPage
548 function setupSkinUserCss( OutputPage
$out ) {
549 $out->addModuleStyles( 'mediawiki.legacy.shared' );
550 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
551 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
552 $out->addStyle( $this->getStylesheet() );
553 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
556 function getPageClasses( $title ) {
557 $numeric = 'ns-' . $title->getNamespace();
559 if ( $title->getNamespace() == NS_SPECIAL
) {
560 $type = 'ns-special';
561 } elseif ( $title->isTalkPage() ) {
564 $type = 'ns-subject';
567 $name = Sanitizer
::escapeClass( 'page-' . $title->getPrefixedText() );
569 return "$numeric $type $name";
573 * This will be called by OutputPage::headElement when it is creating the
574 * <body> tag, skins can override it if they have a need to add in any
575 * body attributes or classes of their own.
577 function addToBodyAttributes( $out, &$bodyAttrs ) {
578 // does nothing by default
590 * This will be called immediately after the <body> tag. Split into
591 * two functions to make it easier to subclass.
593 function beforeContent() {
594 return $this->doBeforeContent();
597 function doBeforeContent() {
599 wfProfileIn( __METHOD__
);
602 $qb = $this->qbSetting();
604 $langlinks = $this->otherLanguages();
611 $borderhack = 'class="top"';
614 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
615 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
617 $shove = ( $qb != 0 );
618 $left = ( $qb == 1 ||
$qb == 3 );
620 if ( $wgContLang->isRTL() ) {
625 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
626 $this->logoText() . '</td>';
628 $s .= $this->getQuickbarCompensator( $rows );
631 $l = $wgContLang->alignStart();
632 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
634 $s .= $this->topLinks();
635 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
637 $r = $wgContLang->alignEnd();
638 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
639 $s .= $this->nameAndLogin();
640 $s .= "\n<br />" . $this->searchForm() . '</td>';
643 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
646 if ( $shove && !$left ) { # Right
647 $s .= $this->getQuickbarCompensator( $rows );
650 $s .= "</tr>\n</table>\n</div>\n";
651 $s .= "\n<div id='article'>\n";
653 $notice = wfGetSiteNotice();
656 $s .= "\n<div id='siteNotice'>$notice</div>\n";
658 $s .= $this->pageTitle();
659 $s .= $this->pageSubtitle();
660 $s .= $this->getCategories();
662 wfProfileOut( __METHOD__
);
666 function getCategoryLinks() {
667 global $wgOut, $wgUseCategoryBrowser;
668 global $wgContLang, $wgUser;
670 if ( count( $wgOut->mCategoryLinks
) == 0 ) {
675 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
677 // Use Unicode bidi embedding override characters,
678 // to make sure links don't smash each other up in ugly ways.
679 $dir = $wgContLang->getDir();
680 $embed = "<span dir='$dir'>";
683 $allCats = $wgOut->getCategoryLinks();
685 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
687 if ( !empty( $allCats['normal'] ) ) {
688 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
690 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
691 $s .= '<div id="mw-normal-catlinks">' .
692 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
693 . $colon . $t . '</div>';
697 if ( isset( $allCats['hidden'] ) ) {
698 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
699 $class = 'mw-hidden-cats-user-shown';
700 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
701 $class = 'mw-hidden-cats-ns-shown';
703 $class = 'mw-hidden-cats-hidden';
706 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
707 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
708 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
712 # optional 'dmoz-like' category browser. Will be shown under the list
713 # of categories an article belong to
714 if ( $wgUseCategoryBrowser ) {
715 $s .= '<br /><hr />';
717 # get a big array of the parents tree
718 $parenttree = $this->mTitle
->getParentCategoryTree();
719 # Skin object passed by reference cause it can not be
720 # accessed under the method subfunction drawCategoryBrowser
721 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
722 # Clean out bogus first entry and sort them
723 unset( $tempout[0] );
725 # Output one per line
726 $s .= implode( "<br />\n", $tempout );
733 * Render the array as a serie of links.
734 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
735 * @param &skin Object: skin passed by reference
736 * @return String separated by >, terminate with "\n"
738 function drawCategoryBrowser( $tree, &$skin ) {
741 foreach ( $tree as $element => $parent ) {
742 if ( empty( $parent ) ) {
743 # element start a new list
746 # grab the others elements
747 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
750 # add our current element to the list
751 $eltitle = Title
::newFromText( $element );
752 $return .= $skin->link( $eltitle, $eltitle->getText() );
758 function getCategories() {
759 $catlinks = $this->getCategoryLinks();
761 $classes = 'catlinks';
763 global $wgOut, $wgUser;
765 // Check what we're showing
766 $allCats = $wgOut->getCategoryLinks();
767 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
768 $this->mTitle
->getNamespace() == NS_CATEGORY
;
770 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
771 $classes .= ' catlinks-allhidden';
774 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
777 function getQuickbarCompensator( $rows = 1 ) {
778 return "<td width='152' rowspan='{$rows}'> </td>";
782 * This runs a hook to allow extensions placing their stuff after content
783 * and article metadata (e.g. categories).
784 * Note: This function has nothing to do with afterContent().
786 * This hook is placed here in order to allow using the same hook for all
787 * skins, both the SkinTemplate based ones and the older ones, which directly
788 * use this class to get their data.
790 * The output of this function gets processed in SkinTemplate::outputPage() for
791 * the SkinTemplate based skins, all other skins should directly echo it.
793 * Returns an empty string by default, if not changed by any hook function.
795 protected function afterContentHook() {
798 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
799 // adding just some spaces shouldn't toggle the output
800 // of the whole <div/>, so we use trim() here
801 if ( trim( $data ) != '' ) {
802 // Doing this here instead of in the skins to
803 // ensure that the div has the same ID in all
805 $data = "<div id='mw-data-after-content'>\n" .
810 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
817 * Generate debug data HTML for displaying at the bottom of the main content
819 * @return String HTML containing debug data, if enabled (otherwise empty).
821 protected function generateDebugHTML() {
822 global $wgShowDebug, $wgOut;
824 if ( $wgShowDebug ) {
825 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
826 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
827 $listInternals . "</ul>\n";
833 private function formatDebugHTML( $debugText ) {
834 $lines = explode( "\n", $debugText );
838 foreach ( $lines as $line ) {
840 $display = ltrim( $line );
841 $ident = strlen( $line ) - strlen( $display );
842 $diff = $ident - $curIdent;
844 if ( $display == '' ) {
845 $display = "\xc2\xa0";
848 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
851 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
853 $display = htmlspecialchars( $display );
857 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
858 } elseif ( $diff == 0 ) {
859 $ret .= "</li><li>\n";
861 $ret .= str_repeat( "<ul><li>\n", $diff );
863 $ret .= $display . "\n";
868 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
874 * This gets called shortly before the </body> tag.
875 * @return String HTML to be put before </body>
877 function afterContent() {
878 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
879 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
883 * This gets called shortly before the </body> tag.
884 * @param $out OutputPage object
885 * @return String HTML-wrapped JS code to be put before </body>
887 function bottomScripts( $out ) {
888 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
889 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
891 return $bottomScriptText;
894 /** @return string Retrievied from HTML text */
895 function printSource() {
896 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
897 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
900 function printFooter() {
901 return "<p>" . $this->printSource() .
902 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
905 /** overloaded by derived classes */
906 function doAfterContent() {
907 return '</div></div>';
910 function pageTitleLinks() {
911 global $wgOut, $wgUser, $wgRequest, $wgLang;
913 $oldid = $wgRequest->getVal( 'oldid' );
914 $diff = $wgRequest->getVal( 'diff' );
915 $action = $wgRequest->getText( 'action' );
917 $s[] = $this->printableLink();
918 $disclaimer = $this->disclaimerLink(); # may be empty
924 $privacy = $this->privacyLink(); # may be empty too
930 if ( $wgOut->isArticleRelated() ) {
931 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
932 $name = $this->mTitle
->getDBkey();
933 $image = wfFindFile( $this->mTitle
);
936 $link = htmlspecialchars( $image->getURL() );
937 $style = $this->getInternalLinkAttributes( $link, $name );
938 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
943 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
946 wfMsg( 'currentrev' ),
949 array( 'known', 'noclasses' )
953 if ( $wgUser->getNewtalk() ) {
954 # do not show "You have new messages" text when we are viewing our
956 if ( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
958 $wgUser->getTalkPage(),
959 wfMsgHtml( 'newmessageslink' ),
961 array( 'redirect' => 'no' ),
962 array( 'known', 'noclasses' )
966 $wgUser->getTalkPage(),
967 wfMsgHtml( 'newmessagesdifflink' ),
969 array( 'diff' => 'cur' ),
970 array( 'known', 'noclasses' )
972 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
974 $wgOut->setSquidMaxage( 0 );
975 $wgOut->enableClientCache( false );
979 $undelete = $this->getUndeleteLink();
981 if ( !empty( $undelete ) ) {
985 return $wgLang->pipeList( $s );
988 function getUndeleteLink() {
989 global $wgUser, $wgLang, $wgRequest;
991 $action = $wgRequest->getVal( 'action', 'view' );
993 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
994 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
995 $n = $this->mTitle
->isDeleted();
998 if ( $wgUser->isAllowed( 'undelete' ) ) {
999 $msg = 'thisisdeleted';
1001 $msg = 'viewdeleted';
1007 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1008 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1011 array( 'known', 'noclasses' )
1020 function printableLink() {
1021 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1025 if ( !$wgOut->isPrintable() ) {
1026 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1027 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1030 if ( $wgOut->isSyndicated() ) {
1031 foreach ( $wgFeedClasses as $format => $class ) {
1032 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1033 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1034 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1037 return $wgLang->pipeList( $s );
1041 * Gets the h1 element with the page title.
1044 function pageTitle() {
1046 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1050 function pageSubtitle() {
1053 $sub = $wgOut->getSubtitle();
1056 global $wgExtraSubtitle;
1057 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1060 $subpages = $this->subPageSubtitle();
1061 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1062 $s = "<p class='subtitle'>{$sub}</p>\n";
1067 function subPageSubtitle() {
1070 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) {
1076 if ( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1077 $ptext = $this->mTitle
->getPrefixedText();
1078 if ( preg_match( '/\//', $ptext ) ) {
1079 $links = explode( '/', $ptext );
1080 array_pop( $links );
1085 foreach ( $links as $link ) {
1086 $growinglink .= $link;
1088 $linkObj = Title
::newFromText( $growinglink );
1090 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1091 $getlink = $this->link(
1093 htmlspecialchars( $display ),
1096 array( 'known', 'noclasses' )
1102 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1104 $subpages .= '< ';
1107 $subpages .= $getlink;
1112 $growinglink .= '/';
1121 * Returns true if the IP should be shown in the header
1123 function showIPinHeader() {
1124 global $wgShowIPinHeader;
1125 return $wgShowIPinHeader && session_id() != '';
1128 function nameAndLogin() {
1129 global $wgUser, $wgLang, $wgContLang;
1131 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1135 if ( $wgUser->isAnon() ) {
1136 if ( $this->showIPinHeader() ) {
1139 $talkLink = $this->link( $wgUser->getTalkPage(),
1140 $wgLang->getNsText( NS_TALK
) );
1142 $ret .= "$name ($talkLink)";
1144 $ret .= wfMsg( 'notloggedin' );
1147 $returnTo = $this->mTitle
->getPrefixedDBkey();
1150 if ( $logoutPage != $returnTo ) {
1151 $query['returnto'] = $returnTo;
1154 $loginlink = $wgUser->isAllowed( 'createaccount' )
1155 ?
'nav-login-createaccount'
1157 $ret .= "\n<br />" . $this->link(
1158 SpecialPage
::getTitleFor( 'Userlogin' ),
1159 wfMsg( $loginlink ), array(), $query
1162 $returnTo = $this->mTitle
->getPrefixedDBkey();
1163 $talkLink = $this->link( $wgUser->getTalkPage(),
1164 $wgLang->getNsText( NS_TALK
) );
1166 $ret .= $this->link( $wgUser->getUserPage(),
1167 htmlspecialchars( $wgUser->getName() ) );
1168 $ret .= " ($talkLink)<br />";
1169 $ret .= $wgLang->pipeList( array(
1171 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1172 array(), array( 'returnto' => $returnTo )
1174 $this->specialLink( 'Preferences' ),
1178 $ret = $wgLang->pipeList( array(
1181 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1189 function getSearchLink() {
1190 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1191 return $searchPage->getLocalURL();
1194 function escapeSearchLink() {
1195 return htmlspecialchars( $this->getSearchLink() );
1198 function searchForm() {
1199 global $wgRequest, $wgUseTwoButtonsSearchForm;
1201 $search = $wgRequest->getText( 'search' );
1203 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
1204 . $this->escapeSearchLink() . "\">\n"
1205 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
1206 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1207 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1209 if ( $wgUseTwoButtonsSearchForm ) {
1210 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1212 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1217 // Ensure unique id's for search boxes made after the first
1218 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1223 function topLinks() {
1227 $this->mainPageLink(),
1228 $this->specialLink( 'Recentchanges' )
1231 if ( $wgOut->isArticleRelated() ) {
1232 $s[] = $this->editThisPage();
1233 $s[] = $this->historyLink();
1236 # Many people don't like this dropdown box
1237 # $s[] = $this->specialPagesList();
1239 if ( $this->variantLinks() ) {
1240 $s[] = $this->variantLinks();
1243 if ( $this->extensionTabLinks() ) {
1244 $s[] = $this->extensionTabLinks();
1247 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1248 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1252 * Compatibility for extensions adding functionality through tabs.
1253 * Eventually these old skins should be replaced with SkinTemplate-based
1257 function extensionTabLinks() {
1261 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1262 foreach ( $tabs as $tab ) {
1263 $s[] = Xml
::element( 'a',
1264 array( 'href' => $tab['href'] ),
1268 if ( count( $s ) ) {
1271 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1272 $out .= $wgLang->pipeList( $s );
1279 * Language/charset variant links for classic-style skins
1282 function variantLinks() {
1285 /* show links to different language variants */
1286 global $wgDisableLangConversion, $wgLang, $wgContLang;
1288 $variants = $wgContLang->getVariants();
1290 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1291 foreach ( $variants as $code ) {
1292 $varname = $wgContLang->getVariantname( $code );
1294 if ( $varname == 'disable' ) {
1297 $s = $wgLang->pipeList( array(
1299 '<a href="' . $this->mTitle
->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1307 function bottomLinks() {
1308 global $wgOut, $wgUser, $wgUseTrackbacks;
1309 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1312 if ( $wgOut->isArticleRelated() ) {
1313 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1315 if ( $wgUser->isLoggedIn() ) {
1316 $element[] = $this->watchThisPage();
1319 $element[] = $this->talkLink();
1320 $element[] = $this->historyLink();
1321 $element[] = $this->whatLinksHere();
1322 $element[] = $this->watchPageLinksLink();
1324 if ( $wgUseTrackbacks ) {
1325 $element[] = $this->trackbackLink();
1329 $this->mTitle
->getNamespace() == NS_USER ||
1330 $this->mTitle
->getNamespace() == NS_USER_TALK
1332 $id = User
::idFromName( $this->mTitle
->getText() );
1333 $ip = User
::isIP( $this->mTitle
->getText() );
1335 # Both anons and non-anons have contributions list
1337 $element[] = $this->userContribsLink();
1340 if ( $this->showEmailUser( $id ) ) {
1341 $element[] = $this->emailUserLink();
1345 $s = implode( $element, $sep );
1347 if ( $this->mTitle
->getArticleId() ) {
1350 // Delete/protect/move links for privileged users
1351 if ( $wgUser->isAllowed( 'delete' ) ) {
1352 $s .= $this->deleteThisPage();
1355 if ( $wgUser->isAllowed( 'protect' ) ) {
1356 $s .= $sep . $this->protectThisPage();
1359 if ( $wgUser->isAllowed( 'move' ) ) {
1360 $s .= $sep . $this->moveThisPage();
1364 $s .= "<br />\n" . $this->otherLanguages();
1370 function pageStats() {
1371 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1372 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1374 $oldid = $wgRequest->getVal( 'oldid' );
1375 $diff = $wgRequest->getVal( 'diff' );
1377 if ( !$wgOut->isArticle() ) {
1381 if ( !$wgArticle instanceof Article
) {
1385 if ( isset( $oldid ) ||
isset( $diff ) ) {
1389 if ( 0 == $wgArticle->getID() ) {
1395 if ( !$wgDisableCounters ) {
1396 $count = $wgLang->formatNum( $wgArticle->getCount() );
1399 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1403 if ( $wgMaxCredits != 0 ) {
1404 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1406 $s .= $this->lastModified();
1409 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1410 $dbr = wfGetDB( DB_SLAVE
);
1411 $res = $dbr->select(
1413 array( 'COUNT(*) AS n' ),
1415 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ),
1416 'wl_namespace' => $this->mTitle
->getNamespace()
1420 $x = $dbr->fetchObject( $res );
1422 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1423 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1427 return $s . ' ' . $this->getCopyright();
1430 function getCopyright( $type = 'detect' ) {
1431 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1433 if ( $type == 'detect' ) {
1434 $diff = $wgRequest->getVal( 'diff' );
1435 $isCur = $wgArticle && $wgArticle->isCurrent();
1437 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1444 if ( $type == 'history' ) {
1445 $msg = 'history_copyright';
1452 if ( $wgRightsPage ) {
1453 $title = Title
::newFromText( $wgRightsPage );
1454 $link = $this->linkKnown( $title, $wgRightsText );
1455 } elseif ( $wgRightsUrl ) {
1456 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1457 } elseif ( $wgRightsText ) {
1458 $link = $wgRightsText;
1464 // Allow for site and per-namespace customization of copyright notice.
1467 if ( isset( $wgArticle ) ) {
1468 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1471 if ( $forContent ) {
1472 $out .= wfMsgForContent( $msg, $link );
1474 $out .= wfMsg( $msg, $link );
1480 function getCopyrightIcon() {
1481 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1485 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1486 $out = $wgCopyrightIcon;
1487 } elseif ( $wgRightsIcon ) {
1488 $icon = htmlspecialchars( $wgRightsIcon );
1490 if ( $wgRightsUrl ) {
1491 $url = htmlspecialchars( $wgRightsUrl );
1492 $out .= '<a href="' . $url . '">';
1495 $text = htmlspecialchars( $wgRightsText );
1496 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1498 if ( $wgRightsUrl ) {
1507 * Gets the powered by MediaWiki icon.
1510 function getPoweredBy() {
1511 global $wgStylePath;
1513 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1514 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1519 function lastModified() {
1520 global $wgLang, $wgArticle;
1522 if ( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest() ) {
1523 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1525 $timestamp = $wgArticle->getTimestamp();
1529 $d = $wgLang->date( $timestamp, true );
1530 $t = $wgLang->time( $timestamp, true );
1531 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1536 if ( wfGetLB()->getLaggedSlaveMode() ) {
1537 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1543 function logoText( $align = '' ) {
1544 if ( $align != '' ) {
1545 $a = " align='{$align}'";
1550 $mp = wfMsg( 'mainpage' );
1551 $mptitle = Title
::newMainPage();
1552 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1554 $logourl = $this->getLogo();
1555 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1561 * Show a drop-down box of special pages
1563 function specialPagesList() {
1564 global $wgContLang, $wgServer, $wgRedirectScript;
1566 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1568 foreach ( $pages as $name => $page ) {
1569 $pages[$name] = $page->getDescription();
1572 $go = wfMsg( 'go' );
1573 $sp = wfMsg( 'specialpages' );
1574 $spp = $wgContLang->specialPage( 'Specialpages' );
1576 $s = '<form id="specialpages" method="get" ' .
1577 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1578 $s .= "<select name=\"wpDropdown\">\n";
1579 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1582 foreach ( $pages as $name => $desc ) {
1583 $p = $wgContLang->specialPage( $name );
1584 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1587 $s .= "</select>\n";
1588 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1595 * Gets the link to the wiki's main page.
1598 function mainPageLink() {
1600 Title
::newMainPage(),
1601 wfMsg( 'mainpage' ),
1604 array( 'known', 'noclasses' )
1610 private function footerLink( $desc, $page ) {
1611 // if the link description has been set to "-" in the default language,
1612 if ( wfMsgForContent( $desc ) == '-' ) {
1613 // then it is disabled, for all languages.
1616 // Otherwise, we display the link for the user, described in their
1617 // language (which may or may not be the same as the default language),
1618 // but we make the link target be the one site-wide page.
1619 $title = Title
::newFromText( wfMsgForContent( $page ) );
1621 return $this->linkKnown(
1623 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1629 * Gets the link to the wiki's privacy policy page.
1631 function privacyLink() {
1632 return $this->footerLink( 'privacy', 'privacypage' );
1636 * Gets the link to the wiki's about page.
1638 function aboutLink() {
1639 return $this->footerLink( 'aboutsite', 'aboutpage' );
1643 * Gets the link to the wiki's general disclaimers page.
1645 function disclaimerLink() {
1646 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1649 function editThisPage() {
1652 if ( !$wgOut->isArticleRelated() ) {
1653 $s = wfMsg( 'protectedpage' );
1655 if ( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1656 $t = wfMsg( 'editthispage' );
1657 } elseif ( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1658 $t = wfMsg( 'create-this-page' );
1660 $t = wfMsg( 'viewsource' );
1667 $this->editUrlOptions(),
1668 array( 'known', 'noclasses' )
1676 * Return URL options for the 'edit page' link.
1677 * This may include an 'oldid' specifier, if the current page view is such.
1682 function editUrlOptions() {
1685 $options = array( 'action' => 'edit' );
1687 if ( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1688 $options['oldid'] = intval( $this->mRevisionId
);
1694 function deleteThisPage() {
1695 global $wgUser, $wgRequest;
1697 $diff = $wgRequest->getVal( 'diff' );
1699 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1700 $t = wfMsg( 'deletethispage' );
1706 array( 'action' => 'delete' ),
1707 array( 'known', 'noclasses' )
1716 function protectThisPage() {
1717 global $wgUser, $wgRequest;
1719 $diff = $wgRequest->getVal( 'diff' );
1721 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1722 if ( $this->mTitle
->isProtected() ) {
1723 $text = wfMsg( 'unprotectthispage' );
1724 $query = array( 'action' => 'unprotect' );
1726 $text = wfMsg( 'protectthispage' );
1727 $query = array( 'action' => 'protect' );
1735 array( 'known', 'noclasses' )
1744 function watchThisPage() {
1746 ++
$this->mWatchLinkNum
;
1748 if ( $wgOut->isArticleRelated() ) {
1749 if ( $this->mTitle
->userIsWatching() ) {
1750 $text = wfMsg( 'unwatchthispage' );
1751 $query = array( 'action' => 'unwatch' );
1752 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1754 $text = wfMsg( 'watchthispage' );
1755 $query = array( 'action' => 'watch' );
1756 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1762 array( 'id' => $id ),
1764 array( 'known', 'noclasses' )
1767 $s = wfMsg( 'notanarticle' );
1773 function moveThisPage() {
1774 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1776 SpecialPage
::getTitleFor( 'Movepage' ),
1777 wfMsg( 'movethispage' ),
1779 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1780 array( 'known', 'noclasses' )
1783 // no message if page is protected - would be redundant
1788 function historyLink() {
1791 wfMsgHtml( 'history' ),
1792 array( 'rel' => 'archives' ),
1793 array( 'action' => 'history' )
1797 function whatLinksHere() {
1799 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1800 wfMsgHtml( 'whatlinkshere' ),
1803 array( 'known', 'noclasses' )
1807 function userContribsLink() {
1809 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1810 wfMsgHtml( 'contributions' ),
1813 array( 'known', 'noclasses' )
1817 function showEmailUser( $id ) {
1819 $targetUser = User
::newFromId( $id );
1820 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1821 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1824 function emailUserLink() {
1826 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1827 wfMsg( 'emailuser' ),
1830 array( 'known', 'noclasses' )
1834 function watchPageLinksLink() {
1837 if ( !$wgOut->isArticleRelated() ) {
1838 return '(' . wfMsg( 'notanarticle' ) . ')';
1841 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1842 wfMsg( 'recentchangeslinked-toolbox' ),
1845 array( 'known', 'noclasses' )
1850 function trackbackLink() {
1851 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1852 . wfMsg( 'trackbacklink' ) . '</a>';
1855 function otherLanguages() {
1856 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1858 if ( $wgHideInterlanguageLinks ) {
1862 $a = $wgOut->getLanguageLinks();
1864 if ( 0 == count( $a ) ) {
1868 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1871 if ( $wgContLang->isRTL() ) {
1872 $s .= '<span dir="LTR">';
1875 foreach ( $a as $l ) {
1877 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1882 $nt = Title
::newFromText( $l );
1883 $url = $nt->escapeFullURL();
1884 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1885 $title = htmlspecialchars( $nt->getText() );
1887 if ( $text == '' ) {
1891 $style = $this->getExternalLinkAttributes();
1892 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1895 if ( $wgContLang->isRTL() ) {
1902 function talkLink() {
1903 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1904 # No discussion links for special pages
1908 $linkOptions = array();
1910 if ( $this->mTitle
->isTalkPage() ) {
1911 $link = $this->mTitle
->getSubjectPage();
1912 switch( $link->getNamespace() ) {
1914 $text = wfMsg( 'articlepage' );
1917 $text = wfMsg( 'userpage' );
1920 $text = wfMsg( 'projectpage' );
1923 $text = wfMsg( 'imagepage' );
1924 # Make link known if image exists, even if the desc. page doesn't.
1925 if ( wfFindFile( $link ) )
1926 $linkOptions[] = 'known';
1929 $text = wfMsg( 'mediawikipage' );
1932 $text = wfMsg( 'templatepage' );
1935 $text = wfMsg( 'viewhelppage' );
1938 $text = wfMsg( 'categorypage' );
1941 $text = wfMsg( 'articlepage' );
1944 $link = $this->mTitle
->getTalkPage();
1945 $text = wfMsg( 'talkpage' );
1948 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1953 function commentLink() {
1956 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1960 # __NEWSECTIONLINK___ changes behaviour here
1961 # If it is present, the link points to this page, otherwise
1962 # it points to the talk page
1963 if ( $this->mTitle
->isTalkPage() ) {
1964 $title = $this->mTitle
;
1965 } elseif ( $wgOut->showNewSectionLink() ) {
1966 $title = $this->mTitle
;
1968 $title = $this->mTitle
->getTalkPage();
1973 wfMsg( 'postcomment' ),
1979 array( 'known', 'noclasses' )
1983 function getUploadLink() {
1984 global $wgUploadNavigationUrl;
1986 if ( $wgUploadNavigationUrl ) {
1987 # Using an empty class attribute to avoid automatic setting of "external" class
1988 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
1991 SpecialPage
::getTitleFor( 'Upload' ),
1992 wfMsgHtml( 'upload' ),
1995 array( 'known', 'noclasses' )
2000 /* these are used extensively in SkinTemplate, but also some other places */
2001 static function makeMainPageUrl( $urlaction = '' ) {
2002 $title = Title
::newMainPage();
2003 self
::checkTitle( $title, '' );
2005 return $title->getLocalURL( $urlaction );
2008 static function makeSpecialUrl( $name, $urlaction = '' ) {
2009 $title = SpecialPage
::getTitleFor( $name );
2010 return $title->getLocalURL( $urlaction );
2013 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2014 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
2015 return $title->getLocalURL( $urlaction );
2018 static function makeI18nUrl( $name, $urlaction = '' ) {
2019 $title = Title
::newFromText( wfMsgForContent( $name ) );
2020 self
::checkTitle( $title, $name );
2021 return $title->getLocalURL( $urlaction );
2024 static function makeUrl( $name, $urlaction = '' ) {
2025 $title = Title
::newFromText( $name );
2026 self
::checkTitle( $title, $name );
2028 return $title->getLocalURL( $urlaction );
2032 * If url string starts with http, consider as external URL, else
2035 static function makeInternalOrExternalUrl( $name ) {
2036 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2039 return self
::makeUrl( $name );
2043 # this can be passed the NS number as defined in Language.php
2044 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
2045 $title = Title
::makeTitleSafe( $namespace, $name );
2046 self
::checkTitle( $title, $name );
2048 return $title->getLocalURL( $urlaction );
2051 /* these return an array with the 'href' and boolean 'exists' */
2052 static function makeUrlDetails( $name, $urlaction = '' ) {
2053 $title = Title
::newFromText( $name );
2054 self
::checkTitle( $title, $name );
2057 'href' => $title->getLocalURL( $urlaction ),
2058 'exists' => $title->getArticleID() != 0,
2063 * Make URL details where the article exists (or at least it's convenient to think so)
2065 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2066 $title = Title
::newFromText( $name );
2067 self
::checkTitle( $title, $name );
2070 'href' => $title->getLocalURL( $urlaction ),
2075 # make sure we have some title to operate on
2076 static function checkTitle( &$title, $name ) {
2077 if ( !is_object( $title ) ) {
2078 $title = Title
::newFromText( $name );
2079 if ( !is_object( $title ) ) {
2080 $title = Title
::newFromText( '--error: link target missing--' );
2086 * Build an array that represents the sidebar(s), the navigation bar among them
2090 function buildSidebar() {
2091 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2093 wfProfileIn( __METHOD__
);
2095 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2097 if ( $wgEnableSidebarCache ) {
2098 $cachedsidebar = $parserMemc->get( $key );
2099 if ( $cachedsidebar ) {
2100 wfProfileOut( __METHOD__
);
2101 return $cachedsidebar;
2106 $this->addToSidebar( $bar, 'sidebar' );
2108 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2109 if ( $wgEnableSidebarCache ) {
2110 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2113 wfProfileOut( __METHOD__
);
2117 * Add content from a sidebar system message
2118 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2120 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2122 * @param &$bar array
2123 * @param $message String
2125 function addToSidebar( &$bar, $message ) {
2126 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2130 * Add content from plain text
2132 * @param &$bar array
2133 * @param $text string
2135 function addToSidebarPlain( &$bar, $text ) {
2136 $lines = explode( "\n", $text );
2137 $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.
2141 foreach ( $lines as $line ) {
2142 if ( strpos( $line, '*' ) !== 0 ) {
2146 if ( strpos( $line, '**' ) !== 0 ) {
2147 $heading = trim( $line, '* ' );
2148 if ( !array_key_exists( $heading, $bar ) ) {
2149 $bar[$heading] = array();
2152 $line = trim( $line, '* ' );
2154 if ( strpos( $line, '|' ) !== false ) { // sanity check
2155 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2156 $link = wfMsgForContent( $line[0] );
2158 if ( $link == '-' ) {
2162 $text = wfMsgExt( $line[1], 'parsemag' );
2164 if ( wfEmptyMsg( $line[1], $text ) ) {
2168 if ( wfEmptyMsg( $line[0], $link ) ) {
2172 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2175 $title = Title
::newFromText( $link );
2178 $title = $title->fixSpecialName();
2179 $href = $title->getLocalURL();
2181 $href = 'INVALID-TITLE';
2185 $bar[$heading][] = array(
2188 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2191 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2192 global $wgParser, $wgTitle;
2194 $line = substr( $line, 2, strlen( $line ) - 4 );
2196 if ( is_null( $wgParser->mOptions
) ) {
2197 $wgParser->mOptions
= new ParserOptions();
2200 $wgParser->mOptions
->setEditSection( false );
2201 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions
)->getText();
2208 if ( count( $wikiBar ) > 0 ) {
2209 $bar = array_merge( $bar, $wikiBar );
2216 * Should we include common/wikiprintable.css? Skins that have their own
2217 * print stylesheet should override this and return false. (This is an
2218 * ugly hack to get Monobook to play nicely with
2219 * OutputPage::headElement().)
2223 public function commonPrintStylesheet() {
2228 * Gets new talk page messages for the current user.
2229 * @return MediaWiki message or if no new talk page messages, nothing
2231 function getNewtalks() {
2232 global $wgUser, $wgOut;
2234 $newtalks = $wgUser->getNewMessageLinks();
2237 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2238 $userTitle = $this->mUser
->getUserPage();
2239 $userTalkTitle = $userTitle->getTalkPage();
2241 if ( !$userTalkTitle->equals( $this->mTitle
) ) {
2242 $newMessagesLink = $this->link(
2244 wfMsgHtml( 'newmessageslink' ),
2246 array( 'redirect' => 'no' ),
2247 array( 'known', 'noclasses' )
2250 $newMessagesDiffLink = $this->link(
2252 wfMsgHtml( 'newmessagesdifflink' ),
2254 array( 'diff' => 'cur' ),
2255 array( 'known', 'noclasses' )
2259 'youhavenewmessages',
2261 $newMessagesDiffLink
2263 # Disable Squid cache
2264 $wgOut->setSquidMaxage( 0 );
2266 } elseif ( count( $newtalks ) ) {
2267 // _>" " for BC <= 1.16
2268 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2271 foreach ( $newtalks as $newtalk ) {
2272 $msgs[] = Xml
::element(
2274 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2277 $parts = implode( $sep, $msgs );
2278 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2279 $wgOut->setSquidMaxage( 0 );