2 if ( ! defined( 'MEDIAWIKI' ) )
8 * The main skin class that provide methods and properties for all other skins.
9 * This base class is also the "Standard" skin.
11 * See docs/skin.txt for more information.
15 class Skin
extends Linker
{
19 var $mWatchLinkNum = 0; // Appended to end of watch link id's
20 // How many search boxes have we made? Avoid duplicate id's.
21 protected $searchboxes = '';
23 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
24 protected $skinname = 'standard' ;
26 /** Constructor, call parent constructor */
27 function Skin() { parent
::__construct(); }
30 * Fetch the set of available skins.
31 * @return array of strings
34 static function getSkinNames() {
35 global $wgValidSkinNames;
36 static $skinsInitialised = false;
37 if ( !$skinsInitialised ) {
38 # Get a list of available skins
39 # Build using the regular expression '^(.*).php$'
40 # Array keys are all lower case, array value keep the case used by filename
42 wfProfileIn( __METHOD__
. '-init' );
43 global $wgStyleDirectory;
44 $skinDir = dir( $wgStyleDirectory );
46 # while code from www.php.net
47 while (false !== ($file = $skinDir->read())) {
48 // Skip non-PHP files, hidden files, and '.dep' includes
50 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
52 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
56 $skinsInitialised = true;
57 wfProfileOut( __METHOD__
. '-init' );
59 return $wgValidSkinNames;
63 * Normalize a skin preference value to a form that can be loaded.
64 * If a skin can't be found, it will fall back to the configured
65 * default (or the old 'Classic' skin if that's broken).
70 static function normalizeKey( $key ) {
71 global $wgDefaultSkin;
72 $skinNames = Skin
::getSkinNames();
75 // Don't return the default immediately;
76 // in a misconfiguration we need to fall back.
77 $key = $wgDefaultSkin;
80 if( isset( $skinNames[$key] ) ) {
84 // Older versions of the software used a numeric setting
85 // in the user preferences.
91 if( isset( $fallback[$key] ) ){
92 $key = $fallback[$key];
95 if( isset( $skinNames[$key] ) ) {
103 * Factory method for loading a skin of a given type
104 * @param string $key 'monobook', 'standard', etc
108 static function &newFromKey( $key ) {
109 global $wgStyleDirectory;
111 $key = Skin
::normalizeKey( $key );
113 $skinNames = Skin
::getSkinNames();
114 $skinName = $skinNames[$key];
115 $className = 'Skin'.ucfirst($key);
117 # Grab the skin class and initialise it.
118 if ( !class_exists( $className ) ) {
119 // Preload base classes to work around APC/PHP5 bug
120 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
121 if( file_exists( $deps ) ) include_once( $deps );
122 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
124 # Check if we got if not failback to default skin
125 if( !class_exists( $className ) ) {
126 # DO NOT die if the class isn't found. This breaks maintenance
127 # scripts and can cause a user account to be unrecoverable
128 # except by SQL manipulation if a previously valid skin name
129 # is no longer valid.
130 wfDebug( "Skin class does not exist: $className\n" );
131 $className = 'SkinMonobook';
132 require_once( "{$wgStyleDirectory}/MonoBook.php" );
135 $skin = new $className;
139 /** @return string path to the skin stylesheet */
140 function getStylesheet() {
141 return 'common/wikistandard.css';
144 /** @return string skin name */
145 public function getSkinName() {
146 return $this->skinname
;
149 function qbSetting() {
150 global $wgOut, $wgUser;
152 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
153 $q = $wgUser->getOption( 'quickbar', 0 );
157 function initPage( &$out ) {
158 global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
160 wfProfileIn( __METHOD__
);
162 if( false !== $wgFavicon ) {
163 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
166 if( false !== $wgAppleTouchIcon ) {
167 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
170 # OpenSearch description link
171 $out->addLink( array(
173 'type' => 'application/opensearchdescription+xml',
174 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
175 'title' => wfMsgForContent( 'opensearch-desc' ),
178 $this->addMetadataLinks($out);
180 $this->mRevisionId
= $out->mRevisionId
;
182 $this->preloadExistence();
184 wfProfileOut( __METHOD__
);
188 * Preload the existence of three commonly-requested pages in a single query
190 function preloadExistence() {
191 global $wgUser, $wgTitle;
194 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
197 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
199 } elseif ( $wgTitle->isTalkPage() ) {
200 $titles[] = $wgTitle->getSubjectPage();
202 $titles[] = $wgTitle->getTalkPage();
205 $lb = new LinkBatch( $titles );
209 function addMetadataLinks( &$out ) {
210 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
211 global $wgRightsPage, $wgRightsUrl;
213 if( $out->isArticleRelated() ) {
214 # note: buggy CC software only reads first "meta" link
215 if( $wgEnableCreativeCommonsRdf ) {
216 $out->addMetadataLink( array(
217 'title' => 'Creative Commons',
218 'type' => 'application/rdf+xml',
219 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
221 if( $wgEnableDublinCoreRdf ) {
222 $out->addMetadataLink( array(
223 'title' => 'Dublin Core',
224 'type' => 'application/rdf+xml',
225 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
229 if( $wgRightsPage ) {
230 $copy = Title
::newFromText( $wgRightsPage );
232 $copyright = $copy->getLocalURL();
235 if( !$copyright && $wgRightsUrl ) {
236 $copyright = $wgRightsUrl;
239 $out->addLink( array(
240 'rel' => 'copyright',
241 'href' => $copyright ) );
245 function outputPage( &$out ) {
246 global $wgDebugComments;
248 wfProfileIn( __METHOD__
);
249 $this->initPage( $out );
251 $out->out( $out->headElement() );
253 $out->out( "\n<body" );
254 $ops = $this->getBodyOptions();
255 foreach ( $ops as $name => $val ) {
256 $out->out( " $name='$val'" );
259 if ( $wgDebugComments ) {
260 $out->out( "<!-- Wiki debugging output:\n" .
261 $out->mDebugtext
. "-->\n" );
264 $out->out( $this->beforeContent() );
266 $out->out( $out->mBodytext
. "\n" );
268 $out->out( $this->afterContent() );
270 $out->out( $this->bottomScripts() );
272 $out->out( wfReportTime() );
274 $out->out( "\n</body></html>" );
275 wfProfileOut( __METHOD__
);
278 static function makeVariablesScript( $data ) {
279 global $wgJsMimeType;
281 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
282 foreach ( $data as $name => $value ) {
283 $encValue = Xml
::encodeJsVar( $value );
284 $r .= "var $name = $encValue;\n";
286 $r .= "/*]]>*/</script>\n";
292 * Make a <script> tag containing global variables
293 * @param array $data Associative array containing one element:
294 * skinname => the skin name
295 * The odd calling convention is for backwards compatibility
297 static function makeGlobalVariablesScript( $data ) {
298 global $wgScript, $wgStylePath, $wgUser;
299 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
300 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
301 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
302 global $wgUseAjax, $wgAjaxWatch;
303 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
304 global $wgRestrictionTypes, $wgLivePreview;
305 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
307 $ns = $wgTitle->getNamespace();
308 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
311 'skin' => $data['skinname'],
312 'stylepath' => $wgStylePath,
313 'wgArticlePath' => $wgArticlePath,
314 'wgScriptPath' => $wgScriptPath,
315 'wgScript' => $wgScript,
316 'wgVariantArticlePath' => $wgVariantArticlePath,
317 'wgActionPaths' => $wgActionPaths,
318 'wgServer' => $wgServer,
319 'wgCanonicalNamespace' => $nsname,
320 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
321 'wgNamespaceNumber' => $wgTitle->getNamespace(),
322 'wgPageName' => $wgTitle->getPrefixedDBKey(),
323 'wgTitle' => $wgTitle->getText(),
324 'wgAction' => $wgRequest->getText( 'action', 'view' ),
325 'wgArticleId' => $wgTitle->getArticleId(),
326 'wgIsArticle' => $wgOut->isArticle(),
327 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
328 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
329 'wgUserLanguage' => $wgLang->getCode(),
330 'wgContentLanguage' => $wgContLang->getCode(),
331 'wgBreakFrames' => $wgBreakFrames,
332 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
333 'wgVersion' => $wgVersion,
334 'wgEnableAPI' => $wgEnableAPI,
335 'wgEnableWriteAPI' => $wgEnableWriteAPI,
338 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
339 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
340 $vars['wgDBname'] = $wgDBname;
341 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
342 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
345 foreach( $wgRestrictionTypes as $type )
346 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
348 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
349 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
350 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
351 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
352 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
355 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
356 $msgs = (object)array();
357 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
358 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
360 $vars['wgAjaxWatch'] = $msgs;
363 return self
::makeVariablesScript( $vars );
366 function getHeadScripts( $allowUserJs ) {
367 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
369 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
371 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
374 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
375 $r .= "<script type=\"$wgJsMimeType\" src=\"".
376 htmlspecialchars(self
::makeUrl('-',
377 "action=raw$jsCache&gen=js&useskin=" .
378 urlencode( $this->getSkinName() ) ) ) .
379 "\"><!-- site js --></script>\n";
381 if( $allowUserJs && $wgUser->isLoggedIn() ) {
382 $userpage = $wgUser->getUserPage();
383 $userjs = htmlspecialchars( self
::makeUrl(
384 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
385 'action=raw&ctype='.$wgJsMimeType));
386 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
392 * To make it harder for someone to slip a user a fake
393 * user-JavaScript or user-CSS preview, a random token
394 * is associated with the login session. If it's not
395 * passed back with the preview request, we won't render
398 * @param string $action
402 function userCanPreview( $action ) {
403 global $wgTitle, $wgRequest, $wgUser;
405 if( $action != 'submit' )
407 if( !$wgRequest->wasPosted() )
409 if( !$wgTitle->userCanEditCssJsSubpage() )
411 return $wgUser->matchEditToken(
412 $wgRequest->getVal( 'wpEditToken' ) );
415 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
416 function getUserStylesheet() {
417 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
418 $sheet = $this->getStylesheet();
419 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
420 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
421 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
422 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
424 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
425 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
426 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
428 $s .= $this->doGetUserStyles();
433 * This returns MediaWiki:Common.js, and derived classes may add other JS.
434 * Despite its name, it does *not* return any custom user JS from user
435 * subpages. The returned script is sitewide and publicly cacheable and
436 * therefore must not include anything that varies according to user,
437 * interface language, etc. (although it may vary by skin). See
438 * makeGlobalVariablesScript for things that can vary per page view and are
441 * @return string Raw JavaScript to be returned
443 public function getUserJs() {
444 wfProfileIn( __METHOD__
);
447 $s = "/* generated javascript */\n";
448 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
449 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
450 $s .= "\n\n/* MediaWiki:Common.js */\n";
451 $commonJs = wfMsgForContent('common.js');
452 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
455 wfProfileOut( __METHOD__
);
460 * Return html code that include User stylesheets
462 function getUserStyles() {
463 $s = "<style type='text/css'>\n";
464 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
465 $s .= $this->getUserStylesheet();
466 $s .= "/*]]>*/ /* */\n";
472 * Some styles that are set by user through the user settings interface.
474 function doGetUserStyles() {
475 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
479 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
480 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
481 $s .= $wgRequest->getText('wpTextbox1');
483 $userpage = $wgUser->getUserPage();
484 $s.= '@import "'.self
::makeUrl(
485 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
486 'action=raw&ctype=text/css').'";'."\n";
490 return $s . $this->reallyDoGetUserStyles();
493 function reallyDoGetUserStyles() {
496 if (($undopt = $wgUser->getOption("underline")) < 2) {
497 $underline = $undopt ?
'underline' : 'none';
498 $s .= "a { text-decoration: $underline; }\n";
500 if( $wgUser->getOption( 'highlightbroken' ) ) {
501 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
504 a.new, #quickbar a.new,
505 a.stub, #quickbar a.stub {
508 a.new:after, #quickbar a.new:after {
512 a.stub:after, #quickbar a.stub:after {
518 if( $wgUser->getOption( 'justify' ) ) {
519 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
521 if( !$wgUser->getOption( 'showtoc' ) ) {
522 $s .= "#toc { display: none; }\n";
524 if( !$wgUser->getOption( 'editsection' ) ) {
525 $s .= ".editsection { display: none; }\n";
530 function getBodyOptions() {
531 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
533 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
535 if ( 0 != $wgTitle->getNamespace() ) {
536 $a = array( 'bgcolor' => '#ffffec' );
538 else $a = array( 'bgcolor' => '#FFFFFF' );
539 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
540 $wgTitle->userCan( 'edit' ) ) {
541 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
542 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
543 $a +
= array ('ondblclick' => $s);
546 $a['onload'] = $wgOut->getOnloadHandler();
548 'mediawiki ns-'.$wgTitle->getNamespace().
549 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
550 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
563 * This will be called immediately after the <body> tag. Split into
564 * two functions to make it easier to subclass.
566 function beforeContent() {
567 return $this->doBeforeContent();
570 function doBeforeContent() {
572 $fname = 'Skin::doBeforeContent';
573 wfProfileIn( $fname );
576 $qb = $this->qbSetting();
578 if( $langlinks = $this->otherLanguages() ) {
584 $borderhack = 'class="top"';
587 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
588 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
591 $left = ($qb == 1 ||
$qb == 3);
592 if($wgContLang->isRTL()) $left = !$left;
595 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
596 $this->logoText() . '</td>';
598 $s .= $this->getQuickbarCompensator( $rows );
600 $l = $wgContLang->isRTL() ?
'right' : 'left';
601 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
603 $s .= $this->topLinks() ;
604 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
606 $r = $wgContLang->isRTL() ?
"left" : "right";
607 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
608 $s .= $this->nameAndLogin();
609 $s .= "\n<br />" . $this->searchForm() . "</td>";
612 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
615 if ( $shove && !$left ) { # Right
616 $s .= $this->getQuickbarCompensator( $rows );
618 $s .= "</tr>\n</table>\n</div>\n";
619 $s .= "\n<div id='article'>\n";
621 $notice = wfGetSiteNotice();
623 $s .= "\n<div id='siteNotice'>$notice</div>\n";
625 $s .= $this->pageTitle();
626 $s .= $this->pageSubtitle() ;
627 $s .= $this->getCategories();
628 wfProfileOut( $fname );
633 function getCategoryLinks() {
634 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
635 global $wgContLang, $wgUser;
637 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
640 $sep = wfMsgHtml( 'catseparator' );
642 // Use Unicode bidi embedding override characters,
643 // to make sure links don't smash each other up in ugly ways.
644 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
645 $embed = "<span dir='$dir'>";
648 $allCats = $wgOut->getCategoryLinks();
650 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
651 if ( !empty( $allCats['normal'] ) ) {
652 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
654 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
655 $s .= '<div id="mw-normal-catlinks">' .
656 $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
657 . $colon . $t . '</div>';
661 if ( isset( $allCats['hidden'] ) ) {
662 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
663 $class ='mw-hidden-cats-user-shown';
664 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
665 $class = 'mw-hidden-cats-ns-shown';
667 $class = 'mw-hidden-cats-hidden';
669 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
670 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
671 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
675 # optional 'dmoz-like' category browser. Will be shown under the list
676 # of categories an article belong to
677 if($wgUseCategoryBrowser) {
678 $s .= '<br /><hr />';
680 # get a big array of the parents tree
681 $parenttree = $wgTitle->getParentCategoryTree();
682 # Skin object passed by reference cause it can not be
683 # accessed under the method subfunction drawCategoryBrowser
684 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
685 # Clean out bogus first entry and sort them
688 # Output one per line
689 $s .= implode("<br />\n", $tempout);
695 /** Render the array as a serie of links.
696 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
697 * @param &skin Object: skin passed by reference
698 * @return String separated by >, terminate with "\n"
700 function drawCategoryBrowser($tree, &$skin) {
702 foreach ($tree as $element => $parent) {
703 if (empty($parent)) {
704 # element start a new list
707 # grab the others elements
708 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
710 # add our current element to the list
711 $eltitle = Title
::NewFromText($element);
712 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
717 function getCategories() {
718 $catlinks=$this->getCategoryLinks();
720 $classes = 'catlinks';
722 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
723 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
724 $classes .= ' catlinks-allhidden';
727 if( !empty( $catlinks ) ){
728 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
732 function getQuickbarCompensator( $rows = 1 ) {
733 return "<td width='152' rowspan='{$rows}'> </td>";
737 * This gets called shortly before the \</body\> tag.
738 * @return String HTML to be put before \</body\>
740 function afterContent() {
741 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
742 return $printfooter . $this->doAfterContent();
746 * This gets called shortly before the \</body\> tag.
747 * @return String HTML-wrapped JS code to be put before \</body\>
749 function bottomScripts() {
750 global $wgJsMimeType;
751 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
752 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
753 return $bottomScriptText;
756 /** @return string Retrievied from HTML text */
757 function printSource() {
759 $url = htmlspecialchars( $wgTitle->getFullURL() );
760 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
763 function printFooter() {
764 return "<p>" . $this->printSource() .
765 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
768 /** overloaded by derived classes */
769 function doAfterContent() { }
771 function pageTitleLinks() {
772 global $wgOut, $wgTitle, $wgUser, $wgRequest;
774 $oldid = $wgRequest->getVal( 'oldid' );
775 $diff = $wgRequest->getVal( 'diff' );
776 $action = $wgRequest->getText( 'action' );
778 $s = $this->printableLink();
779 $disclaimer = $this->disclaimerLink(); # may be empty
781 $s .= ' | ' . $disclaimer;
783 $privacy = $this->privacyLink(); # may be empty too
785 $s .= ' | ' . $privacy;
788 if ( $wgOut->isArticleRelated() ) {
789 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
790 $name = $wgTitle->getDBkey();
791 $image = wfFindFile( $wgTitle );
793 $link = htmlspecialchars( $image->getURL() );
794 $style = $this->getInternalLinkAttributes( $link, $name );
795 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
799 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
800 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
801 wfMsg( 'currentrev' ) );
804 if ( $wgUser->getNewtalk() ) {
805 # do not show "You have new messages" text when we are viewing our
807 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
808 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
809 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
810 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
812 $wgOut->setSquidMaxage(0);
813 $wgOut->enableClientCache(false);
817 $undelete = $this->getUndeleteLink();
818 if( !empty( $undelete ) ) {
819 $s .= ' | '.$undelete;
824 function getUndeleteLink() {
825 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
826 if( $wgUser->isAllowed( 'deletedhistory' ) &&
827 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
828 ($n = $wgTitle->isDeleted() ) )
830 if ( $wgUser->isAllowed( 'undelete' ) ) {
831 $msg = 'thisisdeleted';
833 $msg = 'viewdeleted';
836 $this->makeKnownLinkObj(
837 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
838 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
843 function printableLink() {
844 global $wgOut, $wgFeedClasses, $wgRequest;
846 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
848 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
849 if( $wgOut->isSyndicated() ) {
850 foreach( $wgFeedClasses as $format => $class ) {
851 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
852 $s .= " | <a href=\"$feedurl\">{$format}</a>";
858 function pageTitle() {
860 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
864 function pageSubtitle() {
867 $sub = $wgOut->getSubtitle();
869 global $wgExtraSubtitle;
870 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
872 $subpages = $this->subPageSubtitle();
873 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
874 $s = "<p class='subtitle'>{$sub}</p>\n";
878 function subPageSubtitle() {
880 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
883 global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
884 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
885 $ptext=$wgTitle->getPrefixedText();
886 if(preg_match('/\//',$ptext)) {
887 $links = explode('/',$ptext);
892 foreach($links as $link) {
893 $growinglink .= $link;
895 $linkObj = Title
::newFromText( $growinglink );
896 if( is_object( $linkObj ) && $linkObj->exists() ){
897 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
902 $subpages .= '< ';
904 $subpages .= $getlink;
917 * Returns true if the IP should be shown in the header
919 function showIPinHeader() {
920 global $wgShowIPinHeader;
921 return $wgShowIPinHeader && session_id() != '';
924 function nameAndLogin() {
925 global $wgUser, $wgTitle, $wgLang, $wgContLang;
927 $lo = $wgContLang->specialPage( 'Userlogout' );
930 if ( $wgUser->isAnon() ) {
931 if( $this->showIPinHeader() ) {
934 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
935 $wgLang->getNsText( NS_TALK
) );
937 $s .= $n . ' ('.$tl.')';
939 $s .= wfMsg('notloggedin');
942 $rt = $wgTitle->getPrefixedURL();
943 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
945 } else { $q = "returnto={$rt}"; }
947 $loginlink = $wgUser->isAllowed( 'createaccount' )
948 ?
'nav-login-createaccount'
950 $s .= "\n<br />" . $this->makeKnownLinkObj(
951 SpecialPage
::getTitleFor( 'Userlogin' ),
952 wfMsg( $loginlink ), $q );
954 $n = $wgUser->getName();
955 $rt = $wgTitle->getPrefixedURL();
956 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
957 $wgLang->getNsText( NS_TALK
) );
961 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
962 $n ) . "{$tl}<br />" .
963 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
964 "returnto={$rt}" ) . ' | ' .
965 $this->specialLink( 'preferences' );
967 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
973 function getSearchLink() {
974 $searchPage = SpecialPage
::getTitleFor( 'Search' );
975 return $searchPage->getLocalURL();
978 function escapeSearchLink() {
979 return htmlspecialchars( $this->getSearchLink() );
982 function searchForm() {
984 $search = $wgRequest->getText( 'search' );
986 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
987 . $this->escapeSearchLink() . "\">\n"
988 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
989 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
990 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
991 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
993 // Ensure unique id's for search boxes made after the first
994 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
999 function topLinks() {
1003 $s = $this->mainPageLink() . $sep
1004 . $this->specialLink( 'recentchanges' );
1006 if ( $wgOut->isArticleRelated() ) {
1007 $s .= $sep . $this->editThisPage()
1008 . $sep . $this->historyLink();
1010 # Many people don't like this dropdown box
1011 #$s .= $sep . $this->specialPagesList();
1013 $s .= $this->variantLinks();
1015 $s .= $this->extensionTabLinks();
1021 * Compatibility for extensions adding functionality through tabs.
1022 * Eventually these old skins should be replaced with SkinTemplate-based
1026 function extensionTabLinks() {
1029 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1030 foreach( $tabs as $tab ) {
1031 $s .= ' | ' . Xml
::element( 'a',
1032 array( 'href' => $tab['href'] ),
1039 * Language/charset variant links for classic-style skins
1042 function variantLinks() {
1044 /* show links to different language variants */
1045 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1046 $variants = $wgContLang->getVariants();
1047 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1048 foreach( $variants as $code ) {
1049 $varname = $wgContLang->getVariantname( $code );
1050 if( $varname == 'disable' )
1052 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1058 function bottomLinks() {
1059 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1063 if ( $wgOut->isArticleRelated() ) {
1064 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1065 if ( $wgUser->isLoggedIn() ) {
1066 $s .= $sep . $this->watchThisPage();
1068 $s .= $sep . $this->talkLink()
1069 . $sep . $this->historyLink()
1070 . $sep . $this->whatLinksHere()
1071 . $sep . $this->watchPageLinksLink();
1073 if ($wgUseTrackbacks)
1074 $s .= $sep . $this->trackbackLink();
1076 if ( $wgTitle->getNamespace() == NS_USER
1077 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1080 $id=User
::idFromName($wgTitle->getText());
1081 $ip=User
::isIP($wgTitle->getText());
1083 if($id ||
$ip) { # both anons and non-anons have contri list
1084 $s .= $sep . $this->userContribsLink();
1086 if( $this->showEmailUser( $id ) ) {
1087 $s .= $sep . $this->emailUserLink();
1090 if ( $wgTitle->getArticleId() ) {
1092 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1093 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1094 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1096 $s .= "<br />\n" . $this->otherLanguages();
1101 function pageStats() {
1102 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1103 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1105 $oldid = $wgRequest->getVal( 'oldid' );
1106 $diff = $wgRequest->getVal( 'diff' );
1107 if ( ! $wgOut->isArticle() ) { return ''; }
1108 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1109 if ( 0 == $wgArticle->getID() ) { return ''; }
1112 if ( !$wgDisableCounters ) {
1113 $count = $wgLang->formatNum( $wgArticle->getCount() );
1115 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1119 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1120 require_once('Credits.php');
1121 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1123 $s .= $this->lastModified();
1126 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1127 $dbr = wfGetDB( DB_SLAVE
);
1128 $watchlist = $dbr->tableName( 'watchlist' );
1129 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1130 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1131 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1132 $res = $dbr->query( $sql, 'Skin::pageStats');
1133 $x = $dbr->fetchObject( $res );
1135 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1136 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1140 return $s . ' ' . $this->getCopyright();
1143 function getCopyright( $type = 'detect' ) {
1144 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1146 if ( $type == 'detect' ) {
1147 $oldid = $wgRequest->getVal( 'oldid' );
1148 $diff = $wgRequest->getVal( 'diff' );
1150 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1157 if ( $type == 'history' ) {
1158 $msg = 'history_copyright';
1164 if( $wgRightsPage ) {
1165 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1166 } elseif( $wgRightsUrl ) {
1167 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1172 $out .= wfMsgForContent( $msg, $link );
1176 function getCopyrightIcon() {
1177 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1179 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1180 $out = $wgCopyrightIcon;
1181 } else if ( $wgRightsIcon ) {
1182 $icon = htmlspecialchars( $wgRightsIcon );
1183 if ( $wgRightsUrl ) {
1184 $url = htmlspecialchars( $wgRightsUrl );
1185 $out .= '<a href="'.$url.'">';
1187 $text = htmlspecialchars( $wgRightsText );
1188 $out .= "<img src=\"$icon\" alt='$text' />";
1189 if ( $wgRightsUrl ) {
1196 function getPoweredBy() {
1197 global $wgStylePath;
1198 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1199 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1203 function lastModified() {
1204 global $wgLang, $wgArticle;
1206 $timestamp = $wgArticle->getTimestamp();
1208 $d = $wgLang->date( $timestamp, true );
1209 $t = $wgLang->time( $timestamp, true );
1210 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1214 if ( wfGetLB()->getLaggedSlaveMode() ) {
1215 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1220 function logoText( $align = '' ) {
1221 if ( '' != $align ) { $a = " align='{$align}'"; }
1224 $mp = wfMsg( 'mainpage' );
1225 $mptitle = Title
::newMainPage();
1226 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1228 $logourl = $this->getLogo();
1229 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1234 * show a drop-down box of special pages
1236 function specialPagesList() {
1237 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1238 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1239 foreach ( $pages as $name => $page ) {
1240 $pages[$name] = $page->getDescription();
1243 $go = wfMsg( 'go' );
1244 $sp = wfMsg( 'specialpages' );
1245 $spp = $wgContLang->specialPage( 'Specialpages' );
1247 $s = '<form id="specialpages" method="get" class="inline" ' .
1248 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1249 $s .= "<select name=\"wpDropdown\">\n";
1250 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1253 foreach ( $pages as $name => $desc ) {
1254 $p = $wgContLang->specialPage( $name );
1255 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1257 $s .= "</select>\n";
1258 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1263 function mainPageLink() {
1264 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1268 function copyrightLink() {
1269 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1270 wfMsg( 'copyrightpagename' ) );
1274 private function footerLink ( $desc, $page ) {
1275 // if the link description has been set to "-" in the default language,
1276 if ( wfMsgForContent( $desc ) == '-') {
1277 // then it is disabled, for all languages.
1280 // Otherwise, we display the link for the user, described in their
1281 // language (which may or may not be the same as the default language),
1282 // but we make the link target be the one site-wide page.
1283 return $this->makeKnownLink( wfMsgForContent( $page ),
1284 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1288 function privacyLink() {
1289 return $this->footerLink( 'privacy', 'privacypage' );
1292 function aboutLink() {
1293 return $this->footerLink( 'aboutsite', 'aboutpage' );
1296 function disclaimerLink() {
1297 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1300 function editThisPage() {
1301 global $wgOut, $wgTitle;
1303 if ( !$wgOut->isArticleRelated() ) {
1304 $s = wfMsg( 'protectedpage' );
1306 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1307 $t = wfMsg( 'editthispage' );
1308 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1309 $t = wfMsg( 'create-this-page' );
1311 $t = wfMsg( 'viewsource' );
1314 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1320 * Return URL options for the 'edit page' link.
1321 * This may include an 'oldid' specifier, if the current page view is such.
1326 function editUrlOptions() {
1329 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1330 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1332 return "action=edit";
1336 function deleteThisPage() {
1337 global $wgUser, $wgTitle, $wgRequest;
1339 $diff = $wgRequest->getVal( 'diff' );
1340 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1341 $t = wfMsg( 'deletethispage' );
1343 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1350 function protectThisPage() {
1351 global $wgUser, $wgTitle, $wgRequest;
1353 $diff = $wgRequest->getVal( 'diff' );
1354 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1355 if ( $wgTitle->isProtected() ) {
1356 $t = wfMsg( 'unprotectthispage' );
1357 $q = 'action=unprotect';
1359 $t = wfMsg( 'protectthispage' );
1360 $q = 'action=protect';
1362 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1369 function watchThisPage() {
1370 global $wgOut, $wgTitle;
1371 ++
$this->mWatchLinkNum
;
1373 if ( $wgOut->isArticleRelated() ) {
1374 if ( $wgTitle->userIsWatching() ) {
1375 $t = wfMsg( 'unwatchthispage' );
1376 $q = 'action=unwatch';
1377 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1379 $t = wfMsg( 'watchthispage' );
1380 $q = 'action=watch';
1381 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1383 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1385 $s = wfMsg( 'notanarticle' );
1390 function moveThisPage() {
1393 if ( $wgTitle->userCan( 'move' ) ) {
1394 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1395 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1397 // no message if page is protected - would be redundant
1402 function historyLink() {
1405 return $this->makeKnownLinkObj( $wgTitle,
1406 wfMsg( 'history' ), 'action=history' );
1409 function whatLinksHere() {
1412 return $this->makeKnownLinkObj(
1413 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1414 wfMsg( 'whatlinkshere' ) );
1417 function userContribsLink() {
1420 return $this->makeKnownLinkObj(
1421 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1422 wfMsg( 'contributions' ) );
1425 function showEmailUser( $id ) {
1426 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1427 return $wgEnableEmail &&
1428 $wgEnableUserEmail &&
1429 $wgUser->isLoggedIn() && # show only to signed in users
1430 0 != $id; # we can only email to non-anons ..
1431 # '' != $id->getEmail() && # who must have an email address stored ..
1432 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1433 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1436 function emailUserLink() {
1439 return $this->makeKnownLinkObj(
1440 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1441 wfMsg( 'emailuser' ) );
1444 function watchPageLinksLink() {
1445 global $wgOut, $wgTitle;
1447 if ( ! $wgOut->isArticleRelated() ) {
1448 return '(' . wfMsg( 'notanarticle' ) . ')';
1450 return $this->makeKnownLinkObj(
1451 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1452 wfMsg( 'recentchangeslinked' ) );
1456 function trackbackLink() {
1459 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1460 . wfMsg('trackbacklink') . "</a>";
1463 function otherLanguages() {
1464 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1466 if ( $wgHideInterlanguageLinks ) {
1470 $a = $wgOut->getLanguageLinks();
1471 if ( 0 == count( $a ) ) {
1475 $s = wfMsg( 'otherlanguages' ) . ': ';
1477 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1478 foreach( $a as $l ) {
1479 if ( ! $first ) { $s .= ' | '; }
1482 $nt = Title
::newFromText( $l );
1483 $url = $nt->escapeFullURL();
1484 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1486 if ( '' == $text ) { $text = $l; }
1487 $style = $this->getExternalLinkAttributes( $l, $text );
1488 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1490 if($wgContLang->isRTL()) $s .= '</span>';
1494 function bugReportsLink() {
1495 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1496 wfMsg( 'bugreports' ) );
1500 function talkLink() {
1503 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1504 # No discussion links for special pages
1508 if( $wgTitle->isTalkPage() ) {
1509 $link = $wgTitle->getSubjectPage();
1510 switch( $link->getNamespace() ) {
1512 $text = wfMsg( 'articlepage' );
1515 $text = wfMsg( 'userpage' );
1518 $text = wfMsg( 'projectpage' );
1521 $text = wfMsg( 'imagepage' );
1524 $text = wfMsg( 'mediawikipage' );
1527 $text = wfMsg( 'templatepage' );
1530 $text = wfMsg( 'viewhelppage' );
1533 $text = wfMsg( 'categorypage' );
1536 $text = wfMsg( 'articlepage' );
1539 $link = $wgTitle->getTalkPage();
1540 $text = wfMsg( 'talkpage' );
1543 $s = $this->makeLinkObj( $link, $text );
1548 function commentLink() {
1549 global $wgTitle, $wgOut;
1551 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1555 # __NEWSECTIONLINK___ changes behaviour here
1556 # If it's present, the link points to this page, otherwise
1557 # it points to the talk page
1558 if( $wgTitle->isTalkPage() ) {
1560 } elseif( $wgOut->showNewSectionLink() ) {
1563 $title = $wgTitle->getTalkPage();
1566 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1569 /* these are used extensively in SkinTemplate, but also some other places */
1570 static function makeMainPageUrl( $urlaction = '' ) {
1571 $title = Title
::newMainPage();
1572 self
::checkTitle( $title, '' );
1573 return $title->getLocalURL( $urlaction );
1576 static function makeSpecialUrl( $name, $urlaction = '' ) {
1577 $title = SpecialPage
::getTitleFor( $name );
1578 return $title->getLocalURL( $urlaction );
1581 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1582 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1583 return $title->getLocalURL( $urlaction );
1586 static function makeI18nUrl( $name, $urlaction = '' ) {
1587 $title = Title
::newFromText( wfMsgForContent( $name ) );
1588 self
::checkTitle( $title, $name );
1589 return $title->getLocalURL( $urlaction );
1592 static function makeUrl( $name, $urlaction = '' ) {
1593 $title = Title
::newFromText( $name );
1594 self
::checkTitle( $title, $name );
1595 return $title->getLocalURL( $urlaction );
1598 # If url string starts with http, consider as external URL, else
1600 static function makeInternalOrExternalUrl( $name ) {
1601 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1604 return self
::makeUrl( $name );
1608 # this can be passed the NS number as defined in Language.php
1609 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1610 $title = Title
::makeTitleSafe( $namespace, $name );
1611 self
::checkTitle( $title, $name );
1612 return $title->getLocalURL( $urlaction );
1615 /* these return an array with the 'href' and boolean 'exists' */
1616 static function makeUrlDetails( $name, $urlaction = '' ) {
1617 $title = Title
::newFromText( $name );
1618 self
::checkTitle( $title, $name );
1620 'href' => $title->getLocalURL( $urlaction ),
1621 'exists' => $title->getArticleID() != 0 ?
true : false
1626 * Make URL details where the article exists (or at least it's convenient to think so)
1628 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1629 $title = Title
::newFromText( $name );
1630 self
::checkTitle( $title, $name );
1632 'href' => $title->getLocalURL( $urlaction ),
1637 # make sure we have some title to operate on
1638 static function checkTitle( &$title, $name ) {
1639 if( !is_object( $title ) ) {
1640 $title = Title
::newFromText( $name );
1641 if( !is_object( $title ) ) {
1642 $title = Title
::newFromText( '--error: link target missing--' );
1648 * Build an array that represents the sidebar(s), the navigation bar among them
1653 function buildSidebar() {
1654 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1655 global $wgLang, $wgContLang;
1657 $fname = 'SkinTemplate::buildSidebar';
1659 wfProfileIn( $fname );
1661 $key = wfMemcKey( 'sidebar' );
1662 $cacheSidebar = $wgEnableSidebarCache &&
1663 ($wgLang->getCode() == $wgContLang->getCode());
1665 if ($cacheSidebar) {
1666 $cachedsidebar = $parserMemc->get( $key );
1667 if ($cachedsidebar!="") {
1668 wfProfileOut($fname);
1669 return $cachedsidebar;
1674 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1676 foreach ($lines as $line) {
1677 if (strpos($line, '*') !== 0)
1679 if (strpos($line, '**') !== 0) {
1680 $line = trim($line, '* ');
1683 if (strpos($line, '|') !== false) { // sanity check
1684 $line = explode( '|' , trim($line, '* '), 2 );
1685 $link = wfMsgForContent( $line[0] );
1688 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1690 if (wfEmptyMsg($line[0], $link))
1693 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1696 $title = Title
::newFromText( $link );
1698 $title = $title->fixSpecialName();
1699 $href = $title->getLocalURL();
1701 $href = 'INVALID-TITLE';
1705 $bar[$heading][] = array(
1708 'id' => 'n-' . strtr($line[1], ' ', '-'),
1711 } else { continue; }
1715 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1716 wfProfileOut( $fname );