2 if ( ! defined( 'MEDIAWIKI' ) )
13 * The main skin class that provide methods and properties for all other skins.
14 * This base class is also the "Standard" skin.
16 class Skin
extends Linker
{
20 var $lastdate, $lastline;
21 var $rc_cache ; # Cache for Enhanced Recent Changes
22 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
24 var $mWatchLinkNum = 0; // Appended to end of watch link id's
27 /** Constructor, call parent constructor */
28 function Skin() { parent
::__construct(); }
31 * Fetch the set of available skins.
32 * @return array of strings
35 static function getSkinNames() {
36 global $wgValidSkinNames;
37 static $skinsInitialised = false;
38 if ( !$skinsInitialised ) {
39 # Get a list of available skins
40 # Build using the regular expression '^(.*).php$'
41 # Array keys are all lower case, array value keep the case used by filename
43 wfProfileIn( __METHOD__
. '-init' );
44 global $wgStyleDirectory;
45 $skinDir = dir( $wgStyleDirectory );
47 # while code from www.php.net
48 while (false !== ($file = $skinDir->read())) {
49 // Skip non-PHP files, hidden files, and '.dep' includes
51 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
53 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
57 $skinsInitialised = true;
58 wfProfileOut( __METHOD__
. '-init' );
60 return $wgValidSkinNames;
64 * Normalize a skin preference value to a form that can be loaded.
65 * If a skin can't be found, it will fall back to the configured
66 * default (or the old 'Classic' skin if that's broken).
71 static function normalizeKey( $key ) {
72 global $wgDefaultSkin;
73 $skinNames = Skin
::getSkinNames();
76 // Don't return the default immediately;
77 // in a misconfiguration we need to fall back.
78 $key = $wgDefaultSkin;
81 if( isset( $skinNames[$key] ) ) {
85 // Older versions of the software used a numeric setting
86 // in the user preferences.
92 if( isset( $fallback[$key] ) ){
93 $key = $fallback[$key];
96 if( isset( $skinNames[$key] ) ) {
99 // The old built-in skin
105 * Factory method for loading a skin of a given type
106 * @param string $key 'monobook', 'standard', etc
110 static function &newFromKey( $key ) {
111 global $wgStyleDirectory;
113 $key = Skin
::normalizeKey( $key );
115 $skinNames = Skin
::getSkinNames();
116 $skinName = $skinNames[$key];
118 # Grab the skin class and initialise it.
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 $className = 'Skin'.$skinName;
126 if( !class_exists( $className ) ) {
127 # DO NOT die if the class isn't found. This breaks maintenance
128 # scripts and can cause a user account to be unrecoverable
129 # except by SQL manipulation if a previously valid skin name
130 # is no longer valid.
131 wfDebug( "Skin class does not exist: $className\n" );
132 $className = 'SkinStandard';
133 require_once( "{$wgStyleDirectory}/Standard.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 function getSkinName() {
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, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
160 $fname = 'Skin::initPage';
161 wfProfileIn( $fname );
163 if( false !== $wgFavicon ) {
164 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
167 # OpenSearch description link
168 $out->addLink( array(
170 'type' => 'application/opensearchdescription+xml',
171 'href' => "$wgScriptPath/opensearch_desc.php",
172 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
175 $this->addMetadataLinks($out);
177 $this->mRevisionId
= $out->mRevisionId
;
179 $this->preloadExistence();
181 wfProfileOut( $fname );
185 * Preload the existence of three commonly-requested pages in a single query
187 function preloadExistence() {
188 global $wgUser, $wgTitle;
191 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
194 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
196 } elseif ( $wgTitle->isTalkPage() ) {
197 $titles[] = $wgTitle->getSubjectPage();
199 $titles[] = $wgTitle->getTalkPage();
202 $lb = new LinkBatch( $titles );
206 function addMetadataLinks( &$out ) {
207 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
208 global $wgRightsPage, $wgRightsUrl;
210 if( $out->isArticleRelated() ) {
211 # note: buggy CC software only reads first "meta" link
212 if( $wgEnableCreativeCommonsRdf ) {
213 $out->addMetadataLink( array(
214 'title' => 'Creative Commons',
215 'type' => 'application/rdf+xml',
216 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
218 if( $wgEnableDublinCoreRdf ) {
219 $out->addMetadataLink( array(
220 'title' => 'Dublin Core',
221 'type' => 'application/rdf+xml',
222 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
226 if( $wgRightsPage ) {
227 $copy = Title
::newFromText( $wgRightsPage );
229 $copyright = $copy->getLocalURL();
232 if( !$copyright && $wgRightsUrl ) {
233 $copyright = $wgRightsUrl;
236 $out->addLink( array(
237 'rel' => 'copyright',
238 'href' => $copyright ) );
242 function outputPage( &$out ) {
243 global $wgDebugComments;
245 wfProfileIn( 'Skin::outputPage' );
246 $this->initPage( $out );
248 $out->out( $out->headElement() );
250 $out->out( "\n<body" );
251 $ops = $this->getBodyOptions();
252 foreach ( $ops as $name => $val ) {
253 $out->out( " $name='$val'" );
256 if ( $wgDebugComments ) {
257 $out->out( "<!-- Wiki debugging output:\n" .
258 $out->mDebugtext
. "-->\n" );
261 $out->out( $this->beforeContent() );
263 $out->out( $out->mBodytext
. "\n" );
265 $out->out( $this->afterContent() );
267 $out->out( $this->bottomScripts() );
269 $out->out( $out->reportTime() );
271 $out->out( "\n</body></html>" );
274 static function makeVariablesScript( $data ) {
275 global $wgJsMimeType;
277 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
278 foreach ( $data as $name => $value ) {
279 $encValue = Xml
::encodeJsVar( $value );
280 $r .= "var $name = $encValue;\n";
282 $r .= "/*]]>*/</script>\n";
288 * Make a <script> tag containing global variables
289 * @param array $data Associative array containing one element:
290 * skinname => the skin name
291 * The odd calling convention is for backwards compatibility
293 static function makeGlobalVariablesScript( $data ) {
294 global $wgStylePath, $wgUser;
295 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
296 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
297 global $wgBreakFrames;
299 $ns = $wgTitle->getNamespace();
300 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
303 'skin' => $data['skinname'],
304 'stylepath' => $wgStylePath,
305 'wgArticlePath' => $wgArticlePath,
306 'wgScriptPath' => $wgScriptPath,
307 'wgServer' => $wgServer,
308 'wgCanonicalNamespace' => $nsname,
309 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
310 'wgNamespaceNumber' => $wgTitle->getNamespace(),
311 'wgPageName' => $wgTitle->getPrefixedDBKey(),
312 'wgTitle' => $wgTitle->getText(),
313 'wgArticleId' => $wgTitle->getArticleId(),
314 'wgIsArticle' => $wgOut->isArticle(),
315 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
316 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
317 'wgUserLanguage' => $wgLang->getCode(),
318 'wgContentLanguage' => $wgContLang->getCode(),
319 'wgBreakFrames' => $wgBreakFrames,
320 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
323 global $wgLivePreview;
324 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
325 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
326 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
327 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
328 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
331 return self
::makeVariablesScript( $vars );
334 function getHeadScripts() {
335 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
337 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
339 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
342 if ($wgUser->isLoggedIn()) {
343 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
345 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
348 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
349 $userpage = $wgUser->getUserPage();
350 $userjs = htmlspecialchars( self
::makeUrl(
351 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
352 'action=raw&ctype='.$wgJsMimeType));
353 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
359 * To make it harder for someone to slip a user a fake
360 * user-JavaScript or user-CSS preview, a random token
361 * is associated with the login session. If it's not
362 * passed back with the preview request, we won't render
365 * @param string $action
369 function userCanPreview( $action ) {
370 global $wgTitle, $wgRequest, $wgUser;
372 if( $action != 'submit' )
374 if( !$wgRequest->wasPosted() )
376 if( !$wgTitle->userCanEditCssJsSubpage() )
378 return $wgUser->matchEditToken(
379 $wgRequest->getVal( 'wpEditToken' ) );
382 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
383 function getUserStylesheet() {
384 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
385 $sheet = $this->getStylesheet();
386 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
387 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
388 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
390 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
391 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
392 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
394 $s .= $this->doGetUserStyles();
399 * This returns MediaWiki:Common.js. For some bizarre reason, it does
400 * *not* return any custom user JS from user subpages. Huh?
404 function getUserJs() {
405 wfProfileIn( __METHOD__
);
408 $s = "/* generated javascript */\n";
409 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
410 $s .= "\n\n/* MediaWiki:Common.js */\n";
411 $commonJs = wfMsgForContent('common.js');
412 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
416 global $wgUseAjax, $wgAjaxWatch;
417 if($wgUseAjax && $wgAjaxWatch) {
420 /* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
422 watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
423 unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
424 watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
425 unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
429 wfProfileOut( __METHOD__
);
434 * Return html code that include User stylesheets
436 function getUserStyles() {
437 $s = "<style type='text/css'>\n";
438 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
439 $s .= $this->getUserStylesheet();
440 $s .= "/*]]>*/ /* */\n";
446 * Some styles that are set by user through the user settings interface.
448 function doGetUserStyles() {
449 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
453 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
454 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
455 $s .= $wgRequest->getText('wpTextbox1');
457 $userpage = $wgUser->getUserPage();
458 $s.= '@import "'.self
::makeUrl(
459 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
460 'action=raw&ctype=text/css').'";'."\n";
464 return $s . $this->reallyDoGetUserStyles();
467 function reallyDoGetUserStyles() {
470 if (($undopt = $wgUser->getOption("underline")) != 2) {
471 $underline = $undopt ?
'underline' : 'none';
472 $s .= "a { text-decoration: $underline; }\n";
474 if( $wgUser->getOption( 'highlightbroken' ) ) {
475 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
478 a.new, #quickbar a.new,
479 a.stub, #quickbar a.stub {
481 text-decoration: inherit;
483 a.new:after, #quickbar a.new:after {
486 text-decoration: $underline;
488 a.stub:after, #quickbar a.stub:after {
491 text-decoration: $underline;
495 if( $wgUser->getOption( 'justify' ) ) {
496 $s .= "#article, #bodyContent { text-align: justify; }\n";
498 if( !$wgUser->getOption( 'showtoc' ) ) {
499 $s .= "#toc { display: none; }\n";
501 if( !$wgUser->getOption( 'editsection' ) ) {
502 $s .= ".editsection { display: none; }\n";
507 function getBodyOptions() {
508 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
510 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
512 if ( 0 != $wgTitle->getNamespace() ) {
513 $a = array( 'bgcolor' => '#ffffec' );
515 else $a = array( 'bgcolor' => '#FFFFFF' );
516 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
517 $wgTitle->userCan( 'edit' ) ) {
518 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
519 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
520 $a +
= array ('ondblclick' => $s);
523 $a['onload'] = $wgOut->getOnloadHandler();
524 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
525 if( $a['onload'] != '' ) {
528 $a['onload'] .= 'setupRightClickEdit()';
530 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
531 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
544 * This will be called immediately after the <body> tag. Split into
545 * two functions to make it easier to subclass.
547 function beforeContent() {
548 return $this->doBeforeContent();
551 function doBeforeContent() {
553 $fname = 'Skin::doBeforeContent';
554 wfProfileIn( $fname );
557 $qb = $this->qbSetting();
559 if( $langlinks = $this->otherLanguages() ) {
565 $borderhack = 'class="top"';
568 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
569 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
572 $left = ($qb == 1 ||
$qb == 3);
573 if($wgContLang->isRTL()) $left = !$left;
576 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
577 $this->logoText() . '</td>';
579 $s .= $this->getQuickbarCompensator( $rows );
581 $l = $wgContLang->isRTL() ?
'right' : 'left';
582 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
584 $s .= $this->topLinks() ;
585 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
587 $r = $wgContLang->isRTL() ?
"left" : "right";
588 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
589 $s .= $this->nameAndLogin();
590 $s .= "\n<br />" . $this->searchForm() . "</td>";
593 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
596 if ( $shove && !$left ) { # Right
597 $s .= $this->getQuickbarCompensator( $rows );
599 $s .= "</tr>\n</table>\n</div>\n";
600 $s .= "\n<div id='article'>\n";
602 $notice = wfGetSiteNotice();
604 $s .= "\n<div id='siteNotice'>$notice</div>\n";
606 $s .= $this->pageTitle();
607 $s .= $this->pageSubtitle() ;
608 $s .= $this->getCategories();
609 wfProfileOut( $fname );
614 function getCategoryLinks () {
615 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
618 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
621 $sep = wfMsgHtml( 'catseparator' );
623 // Use Unicode bidi embedding override characters,
624 // to make sure links don't smash each other up in ugly ways.
625 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
626 $embed = "<span dir='$dir'>";
628 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
630 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
631 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
634 # optional 'dmoz-like' category browser. Will be shown under the list
635 # of categories an article belong to
636 if($wgUseCategoryBrowser) {
637 $s .= '<br /><hr />';
639 # get a big array of the parents tree
640 $parenttree = $wgTitle->getParentCategoryTree();
641 # Skin object passed by reference cause it can not be
642 # accessed under the method subfunction drawCategoryBrowser
643 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
644 # Clean out bogus first entry and sort them
647 # Output one per line
648 $s .= implode("<br />\n", $tempout);
654 /** Render the array as a serie of links.
655 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
656 * @param &skin Object: skin passed by reference
657 * @return String separated by >, terminate with "\n"
659 function drawCategoryBrowser($tree, &$skin) {
661 foreach ($tree as $element => $parent) {
662 if (empty($parent)) {
663 # element start a new list
666 # grab the others elements
667 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
669 # add our current element to the list
670 $eltitle = Title
::NewFromText($element);
671 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
676 function getCategories() {
677 $catlinks=$this->getCategoryLinks();
678 if(!empty($catlinks)) {
679 return "<p class='catlinks'>{$catlinks}</p>";
683 function getQuickbarCompensator( $rows = 1 ) {
684 return "<td width='152' rowspan='{$rows}'> </td>";
688 * This gets called shortly before the \</body\> tag.
689 * @return String HTML to be put before \</body\>
691 function afterContent() {
692 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
693 return $printfooter . $this->doAfterContent();
697 * This gets called shortly before the \</body\> tag.
698 * @return String HTML-wrapped JS code to be put before \</body\>
700 function bottomScripts() {
701 global $wgJsMimeType;
702 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
705 /** @return string Retrievied from HTML text */
706 function printSource() {
708 $url = htmlspecialchars( $wgTitle->getFullURL() );
709 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
712 function printFooter() {
713 return "<p>" . $this->printSource() .
714 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
717 /** overloaded by derived classes */
718 function doAfterContent() { }
720 function pageTitleLinks() {
721 global $wgOut, $wgTitle, $wgUser, $wgRequest;
723 $oldid = $wgRequest->getVal( 'oldid' );
724 $diff = $wgRequest->getVal( 'diff' );
725 $action = $wgRequest->getText( 'action' );
727 $s = $this->printableLink();
728 $disclaimer = $this->disclaimerLink(); # may be empty
730 $s .= ' | ' . $disclaimer;
732 $privacy = $this->privacyLink(); # may be empty too
734 $s .= ' | ' . $privacy;
737 if ( $wgOut->isArticleRelated() ) {
738 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
739 $name = $wgTitle->getDBkey();
740 $image = new Image( $wgTitle );
741 if( $image->exists() ) {
742 $link = htmlspecialchars( $image->getURL() );
743 $style = $this->getInternalLinkAttributes( $link, $name );
744 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
748 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
749 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
750 wfMsg( 'currentrev' ) );
753 if ( $wgUser->getNewtalk() ) {
754 # do not show "You have new messages" text when we are viewing our
756 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
757 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
758 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
759 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
761 $wgOut->setSquidMaxage(0);
762 $wgOut->enableClientCache(false);
766 $undelete = $this->getUndeleteLink();
767 if( !empty( $undelete ) ) {
768 $s .= ' | '.$undelete;
773 function getUndeleteLink() {
774 global $wgUser, $wgTitle, $wgContLang, $action;
775 if( $wgUser->isAllowed( 'deletedhistory' ) &&
776 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
777 ($n = $wgTitle->isDeleted() ) )
779 if ( $wgUser->isAllowed( 'delete' ) ) {
780 $msg = 'thisisdeleted';
782 $msg = 'viewdeleted';
785 $this->makeKnownLinkObj(
786 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
787 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
792 function printableLink() {
793 global $wgOut, $wgFeedClasses, $wgRequest;
795 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
797 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
798 if( $wgOut->isSyndicated() ) {
799 foreach( $wgFeedClasses as $format => $class ) {
800 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
801 $s .= " | <a href=\"$feedurl\">{$format}</a>";
807 function pageTitle() {
809 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
813 function pageSubtitle() {
816 $sub = $wgOut->getSubtitle();
818 global $wgExtraSubtitle;
819 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
821 $subpages = $this->subPageSubtitle();
822 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
823 $s = "<p class='subtitle'>{$sub}</p>\n";
827 function subPageSubtitle() {
828 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
830 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
831 $ptext=$wgTitle->getPrefixedText();
832 if(preg_match('/\//',$ptext)) {
833 $links = explode('/',$ptext);
836 foreach($links as $link) {
838 if ($c<count($links)) {
839 $growinglink .= $link;
840 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
841 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
845 $subpages .= '< ';
847 $subpages .= $getlink;
857 * Returns true if the IP should be shown in the header
859 function showIPinHeader() {
860 global $wgShowIPinHeader;
861 return $wgShowIPinHeader && session_id() != '';
864 function nameAndLogin() {
865 global $wgUser, $wgTitle, $wgLang, $wgContLang;
867 $lo = $wgContLang->specialPage( 'Userlogout' );
870 if ( $wgUser->isAnon() ) {
871 if( $this->showIPinHeader() ) {
874 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
875 $wgLang->getNsText( NS_TALK
) );
877 $s .= $n . ' ('.$tl.')';
879 $s .= wfMsg('notloggedin');
882 $rt = $wgTitle->getPrefixedURL();
883 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
885 } else { $q = "returnto={$rt}"; }
887 $s .= "\n<br />" . $this->makeKnownLinkObj(
888 SpecialPage
::getTitleFor( 'Userlogin' ),
889 wfMsg( 'login' ), $q );
891 $n = $wgUser->getName();
892 $rt = $wgTitle->getPrefixedURL();
893 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
894 $wgLang->getNsText( NS_TALK
) );
898 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
899 $n ) . "{$tl}<br />" .
900 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
901 "returnto={$rt}" ) . ' | ' .
902 $this->specialLink( 'preferences' );
904 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
910 function getSearchLink() {
911 $searchPage = SpecialPage
::getTitleFor( 'Search' );
912 return $searchPage->getLocalURL();
915 function escapeSearchLink() {
916 return htmlspecialchars( $this->getSearchLink() );
919 function searchForm() {
921 $search = $wgRequest->getText( 'search' );
923 $s = '<form name="search" class="inline" method="post" action="'
924 . $this->escapeSearchLink() . "\">\n"
925 . '<input type="text" name="search" size="19" value="'
926 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
927 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
928 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
933 function topLinks() {
937 $s = $this->mainPageLink() . $sep
938 . $this->specialLink( 'recentchanges' );
940 if ( $wgOut->isArticleRelated() ) {
941 $s .= $sep . $this->editThisPage()
942 . $sep . $this->historyLink();
944 # Many people don't like this dropdown box
945 #$s .= $sep . $this->specialPagesList();
947 $s .= $this->variantLinks();
949 $s .= $this->extensionTabLinks();
955 * Compatibility for extensions adding functionality through tabs.
956 * Eventually these old skins should be replaced with SkinTemplate-based
960 function extensionTabLinks() {
963 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
964 foreach( $tabs as $tab ) {
965 $s .= ' | ' . Xml
::element( 'a',
966 array( 'href' => $tab['href'] ),
973 * Language/charset variant links for classic-style skins
976 function variantLinks() {
978 /* show links to different language variants */
979 global $wgDisableLangConversion, $wgContLang, $wgTitle;
980 $variants = $wgContLang->getVariants();
981 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
982 foreach( $variants as $code ) {
983 $varname = $wgContLang->getVariantname( $code );
984 if( $varname == 'disable' )
986 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
992 function bottomLinks() {
993 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
997 if ( $wgOut->isArticleRelated() ) {
998 $s .= '<strong>' . $this->editThisPage() . '</strong>';
999 if ( $wgUser->isLoggedIn() ) {
1000 $s .= $sep . $this->watchThisPage();
1002 $s .= $sep . $this->talkLink()
1003 . $sep . $this->historyLink()
1004 . $sep . $this->whatLinksHere()
1005 . $sep . $this->watchPageLinksLink();
1007 if ($wgUseTrackbacks)
1008 $s .= $sep . $this->trackbackLink();
1010 if ( $wgTitle->getNamespace() == NS_USER
1011 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1014 $id=User
::idFromName($wgTitle->getText());
1015 $ip=User
::isIP($wgTitle->getText());
1017 if($id ||
$ip) { # both anons and non-anons have contri list
1018 $s .= $sep . $this->userContribsLink();
1020 if( $this->showEmailUser( $id ) ) {
1021 $s .= $sep . $this->emailUserLink();
1024 if ( $wgTitle->getArticleId() ) {
1026 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1027 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1028 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1030 $s .= "<br />\n" . $this->otherLanguages();
1035 function pageStats() {
1036 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1037 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1039 $oldid = $wgRequest->getVal( 'oldid' );
1040 $diff = $wgRequest->getVal( 'diff' );
1041 if ( ! $wgOut->isArticle() ) { return ''; }
1042 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1043 if ( 0 == $wgArticle->getID() ) { return ''; }
1046 if ( !$wgDisableCounters ) {
1047 $count = $wgLang->formatNum( $wgArticle->getCount() );
1049 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1053 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1054 require_once('Credits.php');
1055 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1057 $s .= $this->lastModified();
1060 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1061 $dbr = wfGetDB( DB_SLAVE
);
1062 $watchlist = $dbr->tableName( 'watchlist' );
1063 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1064 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1065 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1066 $res = $dbr->query( $sql, 'Skin::pageStats');
1067 $x = $dbr->fetchObject( $res );
1068 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1071 return $s . ' ' . $this->getCopyright();
1074 function getCopyright( $type = 'detect' ) {
1075 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1077 if ( $type == 'detect' ) {
1078 $oldid = $wgRequest->getVal( 'oldid' );
1079 $diff = $wgRequest->getVal( 'diff' );
1081 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1088 if ( $type == 'history' ) {
1089 $msg = 'history_copyright';
1095 if( $wgRightsPage ) {
1096 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1097 } elseif( $wgRightsUrl ) {
1098 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1103 $out .= wfMsgForContent( $msg, $link );
1107 function getCopyrightIcon() {
1108 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1110 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1111 $out = $wgCopyrightIcon;
1112 } else if ( $wgRightsIcon ) {
1113 $icon = htmlspecialchars( $wgRightsIcon );
1114 if ( $wgRightsUrl ) {
1115 $url = htmlspecialchars( $wgRightsUrl );
1116 $out .= '<a href="'.$url.'">';
1118 $text = htmlspecialchars( $wgRightsText );
1119 $out .= "<img src=\"$icon\" alt='$text' />";
1120 if ( $wgRightsUrl ) {
1127 function getPoweredBy() {
1128 global $wgStylePath;
1129 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1130 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1134 function lastModified() {
1135 global $wgLang, $wgArticle, $wgLoadBalancer;
1137 $timestamp = $wgArticle->getTimestamp();
1139 $d = $wgLang->date( $timestamp, true );
1140 $t = $wgLang->time( $timestamp, true );
1141 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1145 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1146 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1151 function logoText( $align = '' ) {
1152 if ( '' != $align ) { $a = " align='{$align}'"; }
1155 $mp = wfMsg( 'mainpage' );
1156 $mptitle = Title
::newMainPage();
1157 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1159 $logourl = $this->getLogo();
1160 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1165 * show a drop-down box of special pages
1167 function specialPagesList() {
1168 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1169 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1170 foreach ( $pages as $name => $page ) {
1171 $pages[$name] = $page->getDescription();
1174 $go = wfMsg( 'go' );
1175 $sp = wfMsg( 'specialpages' );
1176 $spp = $wgContLang->specialPage( 'Specialpages' );
1178 $s = '<form id="specialpages" method="get" class="inline" ' .
1179 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1180 $s .= "<select name=\"wpDropdown\">\n";
1181 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1184 foreach ( $pages as $name => $desc ) {
1185 $p = $wgContLang->specialPage( $name );
1186 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1188 $s .= "</select>\n";
1189 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1194 function mainPageLink() {
1195 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1199 function copyrightLink() {
1200 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1201 wfMsg( 'copyrightpagename' ) );
1205 private function footerLink ( $desc, $page ) {
1206 // if the link description has been set to "-" in the default language,
1207 if ( wfMsgForContent( $desc ) == '-') {
1208 // then it is disabled, for all languages.
1211 // Otherwise, we display the link for the user, described in their
1212 // language (which may or may not be the same as the default language),
1213 // but we make the link target be the one site-wide page.
1214 return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
1218 function privacyLink() {
1219 return $this->footerLink( 'privacy', 'privacypage' );
1222 function aboutLink() {
1223 return $this->footerLink( 'aboutsite', 'aboutpage' );
1226 function disclaimerLink() {
1227 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1230 function editThisPage() {
1231 global $wgOut, $wgTitle;
1233 if ( ! $wgOut->isArticleRelated() ) {
1234 $s = wfMsg( 'protectedpage' );
1236 if ( $wgTitle->userCan( 'edit' ) ) {
1237 $t = wfMsg( 'editthispage' );
1239 $t = wfMsg( 'viewsource' );
1242 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1248 * Return URL options for the 'edit page' link.
1249 * This may include an 'oldid' specifier, if the current page view is such.
1254 function editUrlOptions() {
1257 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1258 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1260 return "action=edit";
1264 function deleteThisPage() {
1265 global $wgUser, $wgTitle, $wgRequest;
1267 $diff = $wgRequest->getVal( 'diff' );
1268 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1269 $t = wfMsg( 'deletethispage' );
1271 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1278 function protectThisPage() {
1279 global $wgUser, $wgTitle, $wgRequest;
1281 $diff = $wgRequest->getVal( 'diff' );
1282 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1283 if ( $wgTitle->isProtected() ) {
1284 $t = wfMsg( 'unprotectthispage' );
1285 $q = 'action=unprotect';
1287 $t = wfMsg( 'protectthispage' );
1288 $q = 'action=protect';
1290 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1297 function watchThisPage() {
1298 global $wgOut, $wgTitle;
1299 ++
$this->mWatchLinkNum
;
1301 if ( $wgOut->isArticleRelated() ) {
1302 if ( $wgTitle->userIsWatching() ) {
1303 $t = wfMsg( 'unwatchthispage' );
1304 $q = 'action=unwatch';
1305 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1307 $t = wfMsg( 'watchthispage' );
1308 $q = 'action=watch';
1309 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1311 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1313 $s = wfMsg( 'notanarticle' );
1318 function moveThisPage() {
1321 if ( $wgTitle->userCan( 'move' ) ) {
1322 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1323 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1325 // no message if page is protected - would be redundant
1330 function historyLink() {
1333 return $this->makeKnownLinkObj( $wgTitle,
1334 wfMsg( 'history' ), 'action=history' );
1337 function whatLinksHere() {
1340 return $this->makeKnownLinkObj(
1341 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1342 wfMsg( 'whatlinkshere' ) );
1345 function userContribsLink() {
1348 return $this->makeKnownLinkObj(
1349 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1350 wfMsg( 'contributions' ) );
1353 function showEmailUser( $id ) {
1354 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1355 return $wgEnableEmail &&
1356 $wgEnableUserEmail &&
1357 $wgUser->isLoggedIn() && # show only to signed in users
1358 0 != $id; # we can only email to non-anons ..
1359 # '' != $id->getEmail() && # who must have an email address stored ..
1360 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1361 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1364 function emailUserLink() {
1367 return $this->makeKnownLinkObj(
1368 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1369 wfMsg( 'emailuser' ) );
1372 function watchPageLinksLink() {
1373 global $wgOut, $wgTitle;
1375 if ( ! $wgOut->isArticleRelated() ) {
1376 return '(' . wfMsg( 'notanarticle' ) . ')';
1378 return $this->makeKnownLinkObj(
1379 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1380 wfMsg( 'recentchangeslinked' ) );
1384 function trackbackLink() {
1387 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1388 . wfMsg('trackbacklink') . "</a>";
1391 function otherLanguages() {
1392 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1394 if ( $wgHideInterlanguageLinks ) {
1398 $a = $wgOut->getLanguageLinks();
1399 if ( 0 == count( $a ) ) {
1403 $s = wfMsg( 'otherlanguages' ) . ': ';
1405 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1406 foreach( $a as $l ) {
1407 if ( ! $first ) { $s .= ' | '; }
1410 $nt = Title
::newFromText( $l );
1411 $url = $nt->escapeFullURL();
1412 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1414 if ( '' == $text ) { $text = $l; }
1415 $style = $this->getExternalLinkAttributes( $l, $text );
1416 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1418 if($wgContLang->isRTL()) $s .= '</span>';
1422 function bugReportsLink() {
1423 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1424 wfMsg( 'bugreports' ) );
1428 function dateLink() {
1429 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1430 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1432 $id = $t1->getArticleID();
1435 $s = $this->makeBrokenLink( $t1->getText() );
1437 $s = $this->makeKnownLink( $t1->getText() );
1441 $id = $t2->getArticleID();
1444 $s .= $this->makeBrokenLink( $t2->getText() );
1446 $s .= $this->makeKnownLink( $t2->getText() );
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' ) );
1626 foreach ($lines as $line) {
1627 if (strpos($line, '*') !== 0)
1629 if (strpos($line, '**') !== 0) {
1630 $line = trim($line, '* ');
1633 if (strpos($line, '|') !== false) { // sanity check
1634 $line = explode( '|' , trim($line, '* '), 2 );
1635 $link = wfMsgForContent( $line[0] );
1638 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1640 if (wfEmptyMsg($line[0], $link))
1643 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1646 $title = Title
::newFromText( $link );
1648 $title = $title->fixSpecialName();
1649 $href = $title->getLocalURL();
1651 $href = 'INVALID-TITLE';
1655 $bar[$heading][] = array(
1658 'id' => 'n-' . strtr($line[1], ' ', '-'),
1661 } else { continue; }
1665 $parserMemc->set( $key, $bar, 86400 );
1666 wfProfileOut( $fname );