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
21 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
22 protected $skinname = 'standard' ;
24 /** Constructor, call parent constructor */
25 function Skin() { parent
::__construct(); }
28 * Fetch the set of available skins.
29 * @return array of strings
32 static function getSkinNames() {
33 global $wgValidSkinNames;
34 static $skinsInitialised = false;
35 if ( !$skinsInitialised ) {
36 # Get a list of available skins
37 # Build using the regular expression '^(.*).php$'
38 # Array keys are all lower case, array value keep the case used by filename
40 wfProfileIn( __METHOD__
. '-init' );
41 global $wgStyleDirectory;
42 $skinDir = dir( $wgStyleDirectory );
44 # while code from www.php.net
45 while (false !== ($file = $skinDir->read())) {
46 // Skip non-PHP files, hidden files, and '.dep' includes
48 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
50 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
54 $skinsInitialised = true;
55 wfProfileOut( __METHOD__
. '-init' );
57 return $wgValidSkinNames;
61 * Normalize a skin preference value to a form that can be loaded.
62 * If a skin can't be found, it will fall back to the configured
63 * default (or the old 'Classic' skin if that's broken).
68 static function normalizeKey( $key ) {
69 global $wgDefaultSkin;
70 $skinNames = Skin
::getSkinNames();
73 // Don't return the default immediately;
74 // in a misconfiguration we need to fall back.
75 $key = $wgDefaultSkin;
78 if( isset( $skinNames[$key] ) ) {
82 // Older versions of the software used a numeric setting
83 // in the user preferences.
89 if( isset( $fallback[$key] ) ){
90 $key = $fallback[$key];
93 if( isset( $skinNames[$key] ) ) {
101 * Factory method for loading a skin of a given type
102 * @param string $key 'monobook', 'standard', etc
106 static function &newFromKey( $key ) {
107 global $wgStyleDirectory;
109 $key = Skin
::normalizeKey( $key );
111 $skinNames = Skin
::getSkinNames();
112 $skinName = $skinNames[$key];
113 $className = 'Skin'.ucfirst($key);
115 # Grab the skin class and initialise it.
116 if ( !class_exists( $className ) ) {
117 // Preload base classes to work around APC/PHP5 bug
118 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
119 if( file_exists( $deps ) ) include_once( $deps );
120 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
122 # Check if we got if not failback to default skin
123 if( !class_exists( $className ) ) {
124 # DO NOT die if the class isn't found. This breaks maintenance
125 # scripts and can cause a user account to be unrecoverable
126 # except by SQL manipulation if a previously valid skin name
127 # is no longer valid.
128 wfDebug( "Skin class does not exist: $className\n" );
129 $className = 'SkinMonobook';
130 require_once( "{$wgStyleDirectory}/MonoBook.php" );
133 $skin = new $className;
137 /** @return string path to the skin stylesheet */
138 function getStylesheet() {
139 return 'common/wikistandard.css';
142 /** @return string skin name */
143 public function getSkinName() {
144 return $this->skinname
;
147 function qbSetting() {
148 global $wgOut, $wgUser;
150 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
151 $q = $wgUser->getOption( 'quickbar', 0 );
155 function initPage( &$out ) {
156 global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgSitename, $wgContLang, $wgScriptExtension;
158 wfProfileIn( __METHOD__
);
160 if( false !== $wgFavicon ) {
161 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
164 if( false !== $wgAppleTouchIcon ) {
165 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
168 $code = $wgContLang->getCode();
169 $name = $wgContLang->getLanguageName( $code );
170 $langName = $name ?
$name : $code;
172 # OpenSearch description link
173 $out->addLink( array(
175 'type' => 'application/opensearchdescription+xml',
176 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
177 'title' => "$wgSitename ($langName)",
180 $this->addMetadataLinks($out);
182 $this->mRevisionId
= $out->mRevisionId
;
184 $this->preloadExistence();
186 wfProfileOut( __METHOD__
);
190 * Preload the existence of three commonly-requested pages in a single query
192 function preloadExistence() {
193 global $wgUser, $wgTitle;
196 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
199 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
201 } elseif ( $wgTitle->isTalkPage() ) {
202 $titles[] = $wgTitle->getSubjectPage();
204 $titles[] = $wgTitle->getTalkPage();
207 $lb = new LinkBatch( $titles );
211 function addMetadataLinks( &$out ) {
212 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
213 global $wgRightsPage, $wgRightsUrl;
215 if( $out->isArticleRelated() ) {
216 # note: buggy CC software only reads first "meta" link
217 if( $wgEnableCreativeCommonsRdf ) {
218 $out->addMetadataLink( array(
219 'title' => 'Creative Commons',
220 'type' => 'application/rdf+xml',
221 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
223 if( $wgEnableDublinCoreRdf ) {
224 $out->addMetadataLink( array(
225 'title' => 'Dublin Core',
226 'type' => 'application/rdf+xml',
227 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
231 if( $wgRightsPage ) {
232 $copy = Title
::newFromText( $wgRightsPage );
234 $copyright = $copy->getLocalURL();
237 if( !$copyright && $wgRightsUrl ) {
238 $copyright = $wgRightsUrl;
241 $out->addLink( array(
242 'rel' => 'copyright',
243 'href' => $copyright ) );
247 function outputPage( &$out ) {
248 global $wgDebugComments;
250 wfProfileIn( __METHOD__
);
251 $this->initPage( $out );
253 $out->out( $out->headElement() );
255 $out->out( "\n<body" );
256 $ops = $this->getBodyOptions();
257 foreach ( $ops as $name => $val ) {
258 $out->out( " $name='$val'" );
261 if ( $wgDebugComments ) {
262 $out->out( "<!-- Wiki debugging output:\n" .
263 $out->mDebugtext
. "-->\n" );
266 $out->out( $this->beforeContent() );
268 $out->out( $out->mBodytext
. "\n" );
270 $out->out( $this->afterContent() );
272 $out->out( $this->bottomScripts() );
274 $out->out( $out->reportTime() );
276 $out->out( "\n</body></html>" );
277 wfProfileOut( __METHOD__
);
280 static function makeVariablesScript( $data ) {
281 global $wgJsMimeType;
283 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
284 foreach ( $data as $name => $value ) {
285 $encValue = Xml
::encodeJsVar( $value );
286 $r .= "var $name = $encValue;\n";
288 $r .= "/*]]>*/</script>\n";
294 * Make a <script> tag containing global variables
295 * @param array $data Associative array containing one element:
296 * skinname => the skin name
297 * The odd calling convention is for backwards compatibility
299 static function makeGlobalVariablesScript( $data ) {
300 global $wgScript, $wgStylePath, $wgUser;
301 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
302 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
303 global $wgBreakFrames, $wgRequest;
304 global $wgUseAjax, $wgAjaxWatch;
305 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
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 'wgServer' => $wgServer,
317 'wgCanonicalNamespace' => $nsname,
318 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
319 'wgNamespaceNumber' => $wgTitle->getNamespace(),
320 'wgPageName' => $wgTitle->getPrefixedDBKey(),
321 'wgTitle' => $wgTitle->getText(),
322 'wgAction' => $wgRequest->getText( 'action', 'view' ),
323 'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ),
324 'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ),
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 global $wgLivePreview;
339 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
340 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
341 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
342 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
343 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
346 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
347 $msgs = (object)array();
348 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
349 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
351 $vars['wgAjaxWatch'] = $msgs;
354 return self
::makeVariablesScript( $vars );
357 function getHeadScripts( $allowUserJs ) {
358 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
360 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
362 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
365 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
366 $r .= "<script type=\"$wgJsMimeType\" src=\"".
367 htmlspecialchars(self
::makeUrl('-',
368 "action=raw$jsCache&gen=js&useskin=" .
369 urlencode( $this->getSkinName() ) ) ) .
370 "\"><!-- site js --></script>\n";
372 if( $allowUserJs && $wgUser->isLoggedIn() ) {
373 $userpage = $wgUser->getUserPage();
374 $userjs = htmlspecialchars( self
::makeUrl(
375 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
376 'action=raw&ctype='.$wgJsMimeType));
377 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
383 * To make it harder for someone to slip a user a fake
384 * user-JavaScript or user-CSS preview, a random token
385 * is associated with the login session. If it's not
386 * passed back with the preview request, we won't render
389 * @param string $action
393 function userCanPreview( $action ) {
394 global $wgTitle, $wgRequest, $wgUser;
396 if( $action != 'submit' )
398 if( !$wgRequest->wasPosted() )
400 if( !$wgTitle->userCanEditCssJsSubpage() )
402 return $wgUser->matchEditToken(
403 $wgRequest->getVal( 'wpEditToken' ) );
406 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
407 function getUserStylesheet() {
408 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
409 $sheet = $this->getStylesheet();
410 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
411 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
412 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
413 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
415 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
416 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
417 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
419 $s .= $this->doGetUserStyles();
424 * This returns MediaWiki:Common.js, and derived classes may add other JS.
425 * Despite its name, it does *not* return any custom user JS from user
426 * subpages. The returned script is sitewide and publicly cacheable and
427 * therefore must not include anything that varies according to user,
428 * interface language, etc. (although it may vary by skin). See
429 * makeGlobalVariablesScript for things that can vary per page view and are
432 * @return string Raw JavaScript to be returned
434 public function getUserJs() {
435 wfProfileIn( __METHOD__
);
438 $s = "/* generated javascript */\n";
439 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
440 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
441 $s .= "\n\n/* MediaWiki:Common.js */\n";
442 $commonJs = wfMsgForContent('common.js');
443 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
446 wfProfileOut( __METHOD__
);
451 * Return html code that include User stylesheets
453 function getUserStyles() {
454 $s = "<style type='text/css'>\n";
455 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
456 $s .= $this->getUserStylesheet();
457 $s .= "/*]]>*/ /* */\n";
463 * Some styles that are set by user through the user settings interface.
465 function doGetUserStyles() {
466 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
470 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
471 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
472 $s .= $wgRequest->getText('wpTextbox1');
474 $userpage = $wgUser->getUserPage();
475 $s.= '@import "'.self
::makeUrl(
476 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
477 'action=raw&ctype=text/css').'";'."\n";
481 return $s . $this->reallyDoGetUserStyles();
484 function reallyDoGetUserStyles() {
487 if (($undopt = $wgUser->getOption("underline")) < 2) {
488 $underline = $undopt ?
'underline' : 'none';
489 $s .= "a { text-decoration: $underline; }\n";
491 if( $wgUser->getOption( 'highlightbroken' ) ) {
492 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
495 a.new, #quickbar a.new,
496 a.stub, #quickbar a.stub {
499 a.new:after, #quickbar a.new:after {
503 a.stub:after, #quickbar a.stub:after {
509 if( $wgUser->getOption( 'justify' ) ) {
510 $s .= "#article, #bodyContent { text-align: justify; }\n";
512 if( !$wgUser->getOption( 'showtoc' ) ) {
513 $s .= "#toc { display: none; }\n";
515 if( !$wgUser->getOption( 'editsection' ) ) {
516 $s .= ".editsection { display: none; }\n";
521 function getBodyOptions() {
522 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
524 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
526 if ( 0 != $wgTitle->getNamespace() ) {
527 $a = array( 'bgcolor' => '#ffffec' );
529 else $a = array( 'bgcolor' => '#FFFFFF' );
530 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
531 $wgTitle->userCan( 'edit' ) ) {
532 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
533 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
534 $a +
= array ('ondblclick' => $s);
537 $a['onload'] = $wgOut->getOnloadHandler();
538 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
539 if( $a['onload'] != '' ) {
542 $a['onload'] .= 'setupRightClickEdit()';
544 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
545 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
558 * This will be called immediately after the <body> tag. Split into
559 * two functions to make it easier to subclass.
561 function beforeContent() {
562 return $this->doBeforeContent();
565 function doBeforeContent() {
567 $fname = 'Skin::doBeforeContent';
568 wfProfileIn( $fname );
571 $qb = $this->qbSetting();
573 if( $langlinks = $this->otherLanguages() ) {
579 $borderhack = 'class="top"';
582 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
583 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
586 $left = ($qb == 1 ||
$qb == 3);
587 if($wgContLang->isRTL()) $left = !$left;
590 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
591 $this->logoText() . '</td>';
593 $s .= $this->getQuickbarCompensator( $rows );
595 $l = $wgContLang->isRTL() ?
'right' : 'left';
596 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
598 $s .= $this->topLinks() ;
599 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
601 $r = $wgContLang->isRTL() ?
"left" : "right";
602 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
603 $s .= $this->nameAndLogin();
604 $s .= "\n<br />" . $this->searchForm() . "</td>";
607 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
610 if ( $shove && !$left ) { # Right
611 $s .= $this->getQuickbarCompensator( $rows );
613 $s .= "</tr>\n</table>\n</div>\n";
614 $s .= "\n<div id='article'>\n";
616 $notice = wfGetSiteNotice();
618 $s .= "\n<div id='siteNotice'>$notice</div>\n";
620 $s .= $this->pageTitle();
621 $s .= $this->pageSubtitle() ;
622 $s .= $this->getCategories();
623 wfProfileOut( $fname );
628 function getCategoryLinks () {
629 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
632 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
635 $sep = wfMsgHtml( 'catseparator' );
637 // Use Unicode bidi embedding override characters,
638 // to make sure links don't smash each other up in ugly ways.
639 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
640 $embed = "<span dir='$dir'>";
642 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
644 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
645 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
648 # optional 'dmoz-like' category browser. Will be shown under the list
649 # of categories an article belong to
650 if($wgUseCategoryBrowser) {
651 $s .= '<br /><hr />';
653 # get a big array of the parents tree
654 $parenttree = $wgTitle->getParentCategoryTree();
655 # Skin object passed by reference cause it can not be
656 # accessed under the method subfunction drawCategoryBrowser
657 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
658 # Clean out bogus first entry and sort them
661 # Output one per line
662 $s .= implode("<br />\n", $tempout);
668 /** Render the array as a serie of links.
669 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
670 * @param &skin Object: skin passed by reference
671 * @return String separated by >, terminate with "\n"
673 function drawCategoryBrowser($tree, &$skin) {
675 foreach ($tree as $element => $parent) {
676 if (empty($parent)) {
677 # element start a new list
680 # grab the others elements
681 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
683 # add our current element to the list
684 $eltitle = Title
::NewFromText($element);
685 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
690 function getCategories() {
691 $catlinks=$this->getCategoryLinks();
692 if(!empty($catlinks)) {
693 return "<p class='catlinks'>{$catlinks}</p>";
697 function getQuickbarCompensator( $rows = 1 ) {
698 return "<td width='152' rowspan='{$rows}'> </td>";
702 * This gets called shortly before the \</body\> tag.
703 * @return String HTML to be put before \</body\>
705 function afterContent() {
706 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
707 return $printfooter . $this->doAfterContent();
711 * This gets called shortly before the \</body\> tag.
712 * @return String HTML-wrapped JS code to be put before \</body\>
714 function bottomScripts() {
715 global $wgJsMimeType;
716 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
717 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
718 return $bottomScriptText;
721 /** @return string Retrievied from HTML text */
722 function printSource() {
724 $url = htmlspecialchars( $wgTitle->getFullURL() );
725 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
728 function printFooter() {
729 return "<p>" . $this->printSource() .
730 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
733 /** overloaded by derived classes */
734 function doAfterContent() { }
736 function pageTitleLinks() {
737 global $wgOut, $wgTitle, $wgUser, $wgRequest;
739 $oldid = $wgRequest->getVal( 'oldid' );
740 $diff = $wgRequest->getVal( 'diff' );
741 $action = $wgRequest->getText( 'action' );
743 $s = $this->printableLink();
744 $disclaimer = $this->disclaimerLink(); # may be empty
746 $s .= ' | ' . $disclaimer;
748 $privacy = $this->privacyLink(); # may be empty too
750 $s .= ' | ' . $privacy;
753 if ( $wgOut->isArticleRelated() ) {
754 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
755 $name = $wgTitle->getDBkey();
756 $image = wfFindFile( $wgTitle );
758 $link = htmlspecialchars( $image->getURL() );
759 $style = $this->getInternalLinkAttributes( $link, $name );
760 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
764 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
765 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
766 wfMsg( 'currentrev' ) );
769 if ( $wgUser->getNewtalk() ) {
770 # do not show "You have new messages" text when we are viewing our
772 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
773 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
774 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
775 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
777 $wgOut->setSquidMaxage(0);
778 $wgOut->enableClientCache(false);
782 $undelete = $this->getUndeleteLink();
783 if( !empty( $undelete ) ) {
784 $s .= ' | '.$undelete;
789 function getUndeleteLink() {
790 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
791 if( $wgUser->isAllowed( 'deletedhistory' ) &&
792 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
793 ($n = $wgTitle->isDeleted() ) )
795 if ( $wgUser->isAllowed( 'undelete' ) ) {
796 $msg = 'thisisdeleted';
798 $msg = 'viewdeleted';
801 $this->makeKnownLinkObj(
802 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
803 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
808 function printableLink() {
809 global $wgOut, $wgFeedClasses, $wgRequest;
811 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
813 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
814 if( $wgOut->isSyndicated() ) {
815 foreach( $wgFeedClasses as $format => $class ) {
816 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
817 $s .= " | <a href=\"$feedurl\">{$format}</a>";
823 function pageTitle() {
825 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
829 function pageSubtitle() {
832 $sub = $wgOut->getSubtitle();
834 global $wgExtraSubtitle;
835 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
837 $subpages = $this->subPageSubtitle();
838 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
839 $s = "<p class='subtitle'>{$sub}</p>\n";
843 function subPageSubtitle() {
845 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
848 global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
849 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
850 $ptext=$wgTitle->getPrefixedText();
851 if(preg_match('/\//',$ptext)) {
852 $links = explode('/',$ptext);
855 foreach($links as $link) {
857 if ($c<count($links)) {
858 $growinglink .= $link;
859 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
860 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
864 $subpages .= '< ';
866 $subpages .= $getlink;
876 * Returns true if the IP should be shown in the header
878 function showIPinHeader() {
879 global $wgShowIPinHeader;
880 return $wgShowIPinHeader && session_id() != '';
883 function nameAndLogin() {
884 global $wgUser, $wgTitle, $wgLang, $wgContLang;
886 $lo = $wgContLang->specialPage( 'Userlogout' );
889 if ( $wgUser->isAnon() ) {
890 if( $this->showIPinHeader() ) {
893 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
894 $wgLang->getNsText( NS_TALK
) );
896 $s .= $n . ' ('.$tl.')';
898 $s .= wfMsg('notloggedin');
901 $rt = $wgTitle->getPrefixedURL();
902 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
904 } else { $q = "returnto={$rt}"; }
906 $s .= "\n<br />" . $this->makeKnownLinkObj(
907 SpecialPage
::getTitleFor( 'Userlogin' ),
908 wfMsg( 'login' ), $q );
910 $n = $wgUser->getName();
911 $rt = $wgTitle->getPrefixedURL();
912 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
913 $wgLang->getNsText( NS_TALK
) );
917 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
918 $n ) . "{$tl}<br />" .
919 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
920 "returnto={$rt}" ) . ' | ' .
921 $this->specialLink( 'preferences' );
923 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
929 function getSearchLink() {
930 $searchPage = SpecialPage
::getTitleFor( 'Search' );
931 return $searchPage->getLocalURL();
934 function escapeSearchLink() {
935 return htmlspecialchars( $this->getSearchLink() );
938 function searchForm() {
940 $search = $wgRequest->getText( 'search' );
942 $s = '<form name="search" class="inline" method="post" action="'
943 . $this->escapeSearchLink() . "\">\n"
944 . '<input type="text" name="search" size="19" value="'
945 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
946 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
947 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
952 function topLinks() {
956 $s = $this->mainPageLink() . $sep
957 . $this->specialLink( 'recentchanges' );
959 if ( $wgOut->isArticleRelated() ) {
960 $s .= $sep . $this->editThisPage()
961 . $sep . $this->historyLink();
963 # Many people don't like this dropdown box
964 #$s .= $sep . $this->specialPagesList();
966 $s .= $this->variantLinks();
968 $s .= $this->extensionTabLinks();
974 * Compatibility for extensions adding functionality through tabs.
975 * Eventually these old skins should be replaced with SkinTemplate-based
979 function extensionTabLinks() {
982 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
983 foreach( $tabs as $tab ) {
984 $s .= ' | ' . Xml
::element( 'a',
985 array( 'href' => $tab['href'] ),
992 * Language/charset variant links for classic-style skins
995 function variantLinks() {
997 /* show links to different language variants */
998 global $wgDisableLangConversion, $wgContLang, $wgTitle;
999 $variants = $wgContLang->getVariants();
1000 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1001 foreach( $variants as $code ) {
1002 $varname = $wgContLang->getVariantname( $code );
1003 if( $varname == 'disable' )
1005 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1011 function bottomLinks() {
1012 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1016 if ( $wgOut->isArticleRelated() ) {
1017 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1018 if ( $wgUser->isLoggedIn() ) {
1019 $s .= $sep . $this->watchThisPage();
1021 $s .= $sep . $this->talkLink()
1022 . $sep . $this->historyLink()
1023 . $sep . $this->whatLinksHere()
1024 . $sep . $this->watchPageLinksLink();
1026 if ($wgUseTrackbacks)
1027 $s .= $sep . $this->trackbackLink();
1029 if ( $wgTitle->getNamespace() == NS_USER
1030 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1033 $id=User
::idFromName($wgTitle->getText());
1034 $ip=User
::isIP($wgTitle->getText());
1036 if($id ||
$ip) { # both anons and non-anons have contri list
1037 $s .= $sep . $this->userContribsLink();
1039 if( $this->showEmailUser( $id ) ) {
1040 $s .= $sep . $this->emailUserLink();
1043 if ( $wgTitle->getArticleId() ) {
1045 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1046 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1047 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1049 $s .= "<br />\n" . $this->otherLanguages();
1054 function pageStats() {
1055 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1056 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1058 $oldid = $wgRequest->getVal( 'oldid' );
1059 $diff = $wgRequest->getVal( 'diff' );
1060 if ( ! $wgOut->isArticle() ) { return ''; }
1061 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1062 if ( 0 == $wgArticle->getID() ) { return ''; }
1065 if ( !$wgDisableCounters ) {
1066 $count = $wgLang->formatNum( $wgArticle->getCount() );
1068 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1072 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1073 require_once('Credits.php');
1074 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1076 $s .= $this->lastModified();
1079 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1080 $dbr = wfGetDB( DB_SLAVE
);
1081 $watchlist = $dbr->tableName( 'watchlist' );
1082 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1083 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1084 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1085 $res = $dbr->query( $sql, 'Skin::pageStats');
1086 $x = $dbr->fetchObject( $res );
1088 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1089 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1093 return $s . ' ' . $this->getCopyright();
1096 function getCopyright( $type = 'detect' ) {
1097 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1099 if ( $type == 'detect' ) {
1100 $oldid = $wgRequest->getVal( 'oldid' );
1101 $diff = $wgRequest->getVal( 'diff' );
1103 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1110 if ( $type == 'history' ) {
1111 $msg = 'history_copyright';
1117 if( $wgRightsPage ) {
1118 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1119 } elseif( $wgRightsUrl ) {
1120 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1125 $out .= wfMsgForContent( $msg, $link );
1129 function getCopyrightIcon() {
1130 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1132 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1133 $out = $wgCopyrightIcon;
1134 } else if ( $wgRightsIcon ) {
1135 $icon = htmlspecialchars( $wgRightsIcon );
1136 if ( $wgRightsUrl ) {
1137 $url = htmlspecialchars( $wgRightsUrl );
1138 $out .= '<a href="'.$url.'">';
1140 $text = htmlspecialchars( $wgRightsText );
1141 $out .= "<img src=\"$icon\" alt='$text' />";
1142 if ( $wgRightsUrl ) {
1149 function getPoweredBy() {
1150 global $wgStylePath;
1151 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1152 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1156 function lastModified() {
1157 global $wgLang, $wgArticle, $wgLoadBalancer;
1159 $timestamp = $wgArticle->getTimestamp();
1161 $d = $wgLang->date( $timestamp, true );
1162 $t = $wgLang->time( $timestamp, true );
1163 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1167 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1168 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1173 function logoText( $align = '' ) {
1174 if ( '' != $align ) { $a = " align='{$align}'"; }
1177 $mp = wfMsg( 'mainpage' );
1178 $mptitle = Title
::newMainPage();
1179 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1181 $logourl = $this->getLogo();
1182 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1187 * show a drop-down box of special pages
1189 function specialPagesList() {
1190 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1191 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1192 foreach ( $pages as $name => $page ) {
1193 $pages[$name] = $page->getDescription();
1196 $go = wfMsg( 'go' );
1197 $sp = wfMsg( 'specialpages' );
1198 $spp = $wgContLang->specialPage( 'Specialpages' );
1200 $s = '<form id="specialpages" method="get" class="inline" ' .
1201 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1202 $s .= "<select name=\"wpDropdown\">\n";
1203 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1206 foreach ( $pages as $name => $desc ) {
1207 $p = $wgContLang->specialPage( $name );
1208 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1210 $s .= "</select>\n";
1211 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1216 function mainPageLink() {
1217 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1221 function copyrightLink() {
1222 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1223 wfMsg( 'copyrightpagename' ) );
1227 private function footerLink ( $desc, $page ) {
1228 // if the link description has been set to "-" in the default language,
1229 if ( wfMsgForContent( $desc ) == '-') {
1230 // then it is disabled, for all languages.
1233 // Otherwise, we display the link for the user, described in their
1234 // language (which may or may not be the same as the default language),
1235 // but we make the link target be the one site-wide page.
1236 return $this->makeKnownLink( wfMsgForContent( $page ),
1237 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1241 function privacyLink() {
1242 return $this->footerLink( 'privacy', 'privacypage' );
1245 function aboutLink() {
1246 return $this->footerLink( 'aboutsite', 'aboutpage' );
1249 function disclaimerLink() {
1250 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1253 function editThisPage() {
1254 global $wgOut, $wgTitle;
1256 if ( ! $wgOut->isArticleRelated() ) {
1257 $s = wfMsg( 'protectedpage' );
1259 if ( $wgTitle->userCan( 'edit' ) ) {
1260 $t = wfMsg( 'editthispage' );
1262 $t = wfMsg( 'viewsource' );
1265 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1271 * Return URL options for the 'edit page' link.
1272 * This may include an 'oldid' specifier, if the current page view is such.
1277 function editUrlOptions() {
1280 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1281 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1283 return "action=edit";
1287 function deleteThisPage() {
1288 global $wgUser, $wgTitle, $wgRequest;
1290 $diff = $wgRequest->getVal( 'diff' );
1291 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1292 $t = wfMsg( 'deletethispage' );
1294 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1301 function protectThisPage() {
1302 global $wgUser, $wgTitle, $wgRequest;
1304 $diff = $wgRequest->getVal( 'diff' );
1305 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1306 if ( $wgTitle->isProtected() ) {
1307 $t = wfMsg( 'unprotectthispage' );
1308 $q = 'action=unprotect';
1310 $t = wfMsg( 'protectthispage' );
1311 $q = 'action=protect';
1313 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1320 function watchThisPage() {
1321 global $wgOut, $wgTitle;
1322 ++
$this->mWatchLinkNum
;
1324 if ( $wgOut->isArticleRelated() ) {
1325 if ( $wgTitle->userIsWatching() ) {
1326 $t = wfMsg( 'unwatchthispage' );
1327 $q = 'action=unwatch';
1328 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1330 $t = wfMsg( 'watchthispage' );
1331 $q = 'action=watch';
1332 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1334 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1336 $s = wfMsg( 'notanarticle' );
1341 function moveThisPage() {
1344 if ( $wgTitle->userCan( 'move' ) ) {
1345 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1346 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1348 // no message if page is protected - would be redundant
1353 function historyLink() {
1356 return $this->makeKnownLinkObj( $wgTitle,
1357 wfMsg( 'history' ), 'action=history' );
1360 function whatLinksHere() {
1363 return $this->makeKnownLinkObj(
1364 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1365 wfMsg( 'whatlinkshere' ) );
1368 function userContribsLink() {
1371 return $this->makeKnownLinkObj(
1372 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1373 wfMsg( 'contributions' ) );
1376 function showEmailUser( $id ) {
1377 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1378 return $wgEnableEmail &&
1379 $wgEnableUserEmail &&
1380 $wgUser->isLoggedIn() && # show only to signed in users
1381 0 != $id; # we can only email to non-anons ..
1382 # '' != $id->getEmail() && # who must have an email address stored ..
1383 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1384 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1387 function emailUserLink() {
1390 return $this->makeKnownLinkObj(
1391 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1392 wfMsg( 'emailuser' ) );
1395 function watchPageLinksLink() {
1396 global $wgOut, $wgTitle;
1398 if ( ! $wgOut->isArticleRelated() ) {
1399 return '(' . wfMsg( 'notanarticle' ) . ')';
1401 return $this->makeKnownLinkObj(
1402 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1403 wfMsg( 'recentchangeslinked' ) );
1407 function trackbackLink() {
1410 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1411 . wfMsg('trackbacklink') . "</a>";
1414 function otherLanguages() {
1415 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1417 if ( $wgHideInterlanguageLinks ) {
1421 $a = $wgOut->getLanguageLinks();
1422 if ( 0 == count( $a ) ) {
1426 $s = wfMsg( 'otherlanguages' ) . ': ';
1428 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1429 foreach( $a as $l ) {
1430 if ( ! $first ) { $s .= ' | '; }
1433 $nt = Title
::newFromText( $l );
1434 $url = $nt->escapeFullURL();
1435 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1437 if ( '' == $text ) { $text = $l; }
1438 $style = $this->getExternalLinkAttributes( $l, $text );
1439 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1441 if($wgContLang->isRTL()) $s .= '</span>';
1445 function bugReportsLink() {
1446 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1447 wfMsg( 'bugreports' ) );
1451 function talkLink() {
1454 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1455 # No discussion links for special pages
1459 if( $wgTitle->isTalkPage() ) {
1460 $link = $wgTitle->getSubjectPage();
1461 switch( $link->getNamespace() ) {
1463 $text = wfMsg( 'articlepage' );
1466 $text = wfMsg( 'userpage' );
1469 $text = wfMsg( 'projectpage' );
1472 $text = wfMsg( 'imagepage' );
1475 $text = wfMsg( 'mediawikipage' );
1478 $text = wfMsg( 'templatepage' );
1481 $text = wfMsg( 'viewhelppage' );
1484 $text = wfMsg( 'categorypage' );
1487 $text = wfMsg( 'articlepage' );
1490 $link = $wgTitle->getTalkPage();
1491 $text = wfMsg( 'talkpage' );
1494 $s = $this->makeLinkObj( $link, $text );
1499 function commentLink() {
1500 global $wgTitle, $wgOut;
1502 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1506 # __NEWSECTIONLINK___ changes behaviour here
1507 # If it's present, the link points to this page, otherwise
1508 # it points to the talk page
1509 if( $wgTitle->isTalkPage() ) {
1511 } elseif( $wgOut->showNewSectionLink() ) {
1514 $title = $wgTitle->getTalkPage();
1517 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1520 /* these are used extensively in SkinTemplate, but also some other places */
1521 static function makeMainPageUrl( $urlaction = '' ) {
1522 $title = Title
::newMainPage();
1523 self
::checkTitle( $title, '' );
1524 return $title->getLocalURL( $urlaction );
1527 static function makeSpecialUrl( $name, $urlaction = '' ) {
1528 $title = SpecialPage
::getTitleFor( $name );
1529 return $title->getLocalURL( $urlaction );
1532 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1533 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1534 return $title->getLocalURL( $urlaction );
1537 static function makeI18nUrl( $name, $urlaction = '' ) {
1538 $title = Title
::newFromText( wfMsgForContent( $name ) );
1539 self
::checkTitle( $title, $name );
1540 return $title->getLocalURL( $urlaction );
1543 static function makeUrl( $name, $urlaction = '' ) {
1544 $title = Title
::newFromText( $name );
1545 self
::checkTitle( $title, $name );
1546 return $title->getLocalURL( $urlaction );
1549 # If url string starts with http, consider as external URL, else
1551 static function makeInternalOrExternalUrl( $name ) {
1552 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1555 return self
::makeUrl( $name );
1559 # this can be passed the NS number as defined in Language.php
1560 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1561 $title = Title
::makeTitleSafe( $namespace, $name );
1562 self
::checkTitle( $title, $name );
1563 return $title->getLocalURL( $urlaction );
1566 /* these return an array with the 'href' and boolean 'exists' */
1567 static function makeUrlDetails( $name, $urlaction = '' ) {
1568 $title = Title
::newFromText( $name );
1569 self
::checkTitle( $title, $name );
1571 'href' => $title->getLocalURL( $urlaction ),
1572 'exists' => $title->getArticleID() != 0 ?
true : false
1577 * Make URL details where the article exists (or at least it's convenient to think so)
1579 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1580 $title = Title
::newFromText( $name );
1581 self
::checkTitle( $title, $name );
1583 'href' => $title->getLocalURL( $urlaction ),
1588 # make sure we have some title to operate on
1589 static function checkTitle( &$title, $name ) {
1590 if( !is_object( $title ) ) {
1591 $title = Title
::newFromText( $name );
1592 if( !is_object( $title ) ) {
1593 $title = Title
::newFromText( '--error: link target missing--' );
1599 * Build an array that represents the sidebar(s), the navigation bar among them
1604 function buildSidebar() {
1605 global $parserMemc, $wgEnableSidebarCache;
1606 global $wgLang, $wgContLang;
1608 $fname = 'SkinTemplate::buildSidebar';
1610 wfProfileIn( $fname );
1612 $key = wfMemcKey( 'sidebar' );
1613 $cacheSidebar = $wgEnableSidebarCache &&
1614 ($wgLang->getCode() == $wgContLang->getCode());
1616 if ($cacheSidebar) {
1617 $cachedsidebar = $parserMemc->get( $key );
1618 if ($cachedsidebar!="") {
1619 wfProfileOut($fname);
1620 return $cachedsidebar;
1625 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1627 foreach ($lines as $line) {
1628 if (strpos($line, '*') !== 0)
1630 if (strpos($line, '**') !== 0) {
1631 $line = trim($line, '* ');
1634 if (strpos($line, '|') !== false) { // sanity check
1635 $line = explode( '|' , trim($line, '* '), 2 );
1636 $link = wfMsgForContent( $line[0] );
1639 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1641 if (wfEmptyMsg($line[0], $link))
1644 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1647 $title = Title
::newFromText( $link );
1649 $title = $title->fixSpecialName();
1650 $href = $title->getLocalURL();
1652 $href = 'INVALID-TITLE';
1656 $bar[$heading][] = array(
1659 'id' => 'n-' . strtr($line[1], ' ', '-'),
1662 } else { continue; }
1666 $parserMemc->set( $key, $bar, 86400 );
1667 wfProfileOut( $fname );