2 if ( ! defined( 'MEDIAWIKI' ) )
12 require_once( 'Linker.php' );
13 require_once( 'Image.php' );
15 # Get a list of all skins available in /skins/
16 # Build using the regular expression '^(.*).php$'
17 # Array keys are all lower case, array value keep the case used by filename
20 $skinDir = dir($IP.'/skins');
22 # while code from www.php.net
23 while (false !== ($file = $skinDir->read())) {
24 // Skip non-PHP files, hidden files, and '.dep' includes
25 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
27 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
34 * The main skin class that provide methods and properties for all other skins.
35 * This base class is also the "Standard" skin.
38 class Skin
extends Linker
{
42 var $lastdate, $lastline;
43 var $rc_cache ; # Cache for Enhanced Recent Changes
44 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
48 /** Constructor, call parent constructor */
49 function Skin() { parent
::Linker(); }
52 * Fetch the set of available skins.
53 * @return array of strings
56 function getSkinNames() {
57 global $wgValidSkinNames;
58 return $wgValidSkinNames;
62 * Normalize a skin preference value to a form that can be loaded.
63 * If a skin can't be found, it will fall back to the configured
64 * default (or the old 'Classic' skin if that's broken).
69 function normalizeKey( $key ) {
70 global $wgDefaultSkin;
71 $skinNames = Skin
::getSkinNames();
74 // Don't return the default immediately;
75 // in a misconfiguration we need to fall back.
76 $key = $wgDefaultSkin;
79 if( isset( $skinNames[$key] ) ) {
83 // Older versions of the software used a numeric setting
84 // in the user preferences.
90 if( isset( $fallback[$key] ) ){
91 $key = $fallback[$key];
94 if( isset( $skinNames[$key] ) ) {
97 // The old built-in skin
103 * Factory method for loading a skin of a given type
104 * @param string $key 'monobook', 'standard', etc
108 function &newFromKey( $key ) {
109 $key = Skin
::normalizeKey( $key );
111 $skinNames = Skin
::getSkinNames();
112 $skinName = $skinNames[$key];
116 # Grab the skin class and initialise it.
117 wfSuppressWarnings();
118 // Preload base classes to work around APC/PHP5 bug
119 include_once( $IP.'/skins/'.$skinName.'.deps.php' );
121 require_once( $IP.'/skins/'.$skinName.'.php' );
123 # Check if we got if not failback to default skin
124 $className = 'Skin'.$skinName;
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 $className = 'SkinStandard';
131 require_once( $IP.'/skins/Standard.php' );
133 $skin =& new $className;
137 /** @return string path to the skin stylesheet */
138 function getStylesheet() {
139 return 'common/wikistandard.css?1';
142 /** @return string skin name */
143 function getSkinName() {
147 function qbSetting() {
148 global $wgOut, $wgUser;
150 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
151 $q = $wgUser->getOption( 'quickbar' );
152 if ( '' == $q ) { $q = 0; }
156 function initPage( &$out ) {
159 $fname = 'Skin::initPage';
160 wfProfileIn( $fname );
162 if( false !== $wgFavicon ) {
163 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
166 $this->addMetadataLinks($out);
168 $this->mRevisionId
= $out->mRevisionId
;
170 wfProfileOut( $fname );
173 function addMetadataLinks( &$out ) {
174 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
175 global $wgRightsPage, $wgRightsUrl;
177 if( $out->isArticleRelated() ) {
178 # note: buggy CC software only reads first "meta" link
179 if( $wgEnableCreativeCommonsRdf ) {
180 $out->addMetadataLink( array(
181 'title' => 'Creative Commons',
182 'type' => 'application/rdf+xml',
183 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
185 if( $wgEnableDublinCoreRdf ) {
186 $out->addMetadataLink( array(
187 'title' => 'Dublin Core',
188 'type' => 'application/rdf+xml',
189 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
193 if( $wgRightsPage ) {
194 $copy = Title
::newFromText( $wgRightsPage );
196 $copyright = $copy->getLocalURL();
199 if( !$copyright && $wgRightsUrl ) {
200 $copyright = $wgRightsUrl;
203 $out->addLink( array(
204 'rel' => 'copyright',
205 'href' => $copyright ) );
209 function outputPage( &$out ) {
210 global $wgDebugComments;
212 wfProfileIn( 'Skin::outputPage' );
213 $this->initPage( $out );
215 $out->out( $out->headElement() );
217 $out->out( "\n<body" );
218 $ops = $this->getBodyOptions();
219 foreach ( $ops as $name => $val ) {
220 $out->out( " $name='$val'" );
223 if ( $wgDebugComments ) {
224 $out->out( "<!-- Wiki debugging output:\n" .
225 $out->mDebugtext
. "-->\n" );
228 $out->out( $this->beforeContent() );
230 $out->out( $out->mBodytext
. "\n" );
232 $out->out( $this->afterContent() );
234 $out->out( $out->reportTime() );
236 $out->out( "\n</body></html>" );
239 function getHeadScripts() {
240 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType;
241 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
242 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
243 $userpage = $wgUser->getUserPage();
244 $userjs = htmlspecialchars( $this->makeUrl(
245 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
246 'action=raw&ctype='.$wgJsMimeType));
247 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
253 * To make it harder for someone to slip a user a fake
254 * user-JavaScript or user-CSS preview, a random token
255 * is associated with the login session. If it's not
256 * passed back with the preview request, we won't render
259 * @param string $action
263 function userCanPreview( $action ) {
264 global $wgTitle, $wgRequest, $wgUser;
266 if( $action != 'submit' )
268 if( !$wgRequest->wasPosted() )
270 if( !$wgTitle->userCanEditCssJsSubpage() )
272 return $wgUser->matchEditToken(
273 $wgRequest->getVal( 'wpEditToken' ) );
276 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
277 function getUserStylesheet() {
278 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
279 $sheet = $this->getStylesheet();
280 $action = $wgRequest->getText('action');
281 $s = "@import \"$wgStylePath/$sheet\";\n";
282 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
284 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
285 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
286 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
288 $s .= $this->doGetUserStyles();
293 * placeholder, returns generated js in monobook
295 function getUserJs() { return; }
298 * Return html code that include User stylesheets
300 function getUserStyles() {
301 $s = "<style type='text/css'>\n";
302 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
303 $s .= $this->getUserStylesheet();
304 $s .= "/*]]>*/ /* */\n";
310 * Some styles that are set by user through the user settings interface.
312 function doGetUserStyles() {
313 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
317 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
318 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
319 $s .= $wgRequest->getText('wpTextbox1');
321 $userpage = $wgUser->getUserPage();
322 $s.= '@import "'.$this->makeUrl(
323 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
324 'action=raw&ctype=text/css').'";'."\n";
328 return $s . $this->reallyDoGetUserStyles();
331 function reallyDoGetUserStyles() {
334 if (($undopt = $wgUser->getOption("underline")) != 2) {
335 $underline = $undopt ?
'underline' : 'none';
336 $s .= "a { text-decoration: $underline; }\n";
338 if( $wgUser->getOption( 'highlightbroken' ) ) {
339 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
342 a.new, #quickbar a.new,
343 a.stub, #quickbar a.stub {
345 text-decoration: inherit;
347 a.new:after, #quickbar a.new:after {
350 text-decoration: $underline;
352 a.stub:after, #quickbar a.stub:after {
355 text-decoration: $underline;
359 if( $wgUser->getOption( 'justify' ) ) {
360 $s .= "#article, #bodyContent { text-align: justify; }\n";
362 if( !$wgUser->getOption( 'showtoc' ) ) {
363 $s .= "#toc { display: none; }\n";
365 if( !$wgUser->getOption( 'editsection' ) ) {
366 $s .= ".editsection { display: none; }\n";
371 function getBodyOptions() {
372 global $wgUser, $wgTitle, $wgOut, $wgRequest;
374 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
376 if ( 0 != $wgTitle->getNamespace() ) {
377 $a = array( 'bgcolor' => '#ffffec' );
379 else $a = array( 'bgcolor' => '#FFFFFF' );
380 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
381 $wgTitle->userCanEdit() ) {
382 $t = wfMsg( 'editthispage' );
383 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
384 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
385 $a +
= array ('ondblclick' => $s);
388 $a['onload'] = $wgOut->getOnloadHandler();
389 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
390 if( $a['onload'] != '' ) {
393 $a['onload'] .= 'setupRightClickEdit()';
407 * This will be called immediately after the <body> tag. Split into
408 * two functions to make it easier to subclass.
410 function beforeContent() {
411 return $this->doBeforeContent();
414 function doBeforeContent() {
416 $fname = 'Skin::doBeforeContent';
417 wfProfileIn( $fname );
420 $qb = $this->qbSetting();
422 if( $langlinks = $this->otherLanguages() ) {
428 $borderhack = 'class="top"';
431 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
432 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
435 $left = ($qb == 1 ||
$qb == 3);
436 if($wgContLang->isRTL()) $left = !$left;
439 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
440 $this->logoText() . '</td>';
442 $s .= $this->getQuickbarCompensator( $rows );
444 $l = $wgContLang->isRTL() ?
'right' : 'left';
445 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
447 $s .= $this->topLinks() ;
448 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
450 $r = $wgContLang->isRTL() ?
"left" : "right";
451 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
452 $s .= $this->nameAndLogin();
453 $s .= "\n<br />" . $this->searchForm() . "</td>";
456 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
459 if ( $shove && !$left ) { # Right
460 $s .= $this->getQuickbarCompensator( $rows );
462 $s .= "</tr>\n</table>\n</div>\n";
463 $s .= "\n<div id='article'>\n";
465 $notice = wfGetSiteNotice();
467 $s .= "\n<div id='siteNotice'>$notice</div>\n";
469 $s .= $this->pageTitle();
470 $s .= $this->pageSubtitle() ;
471 $s .= $this->getCategories();
472 wfProfileOut( $fname );
477 function getCategoryLinks () {
478 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
481 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
483 // Use Unicode bidi embedding override characters,
484 // to make sure links don't smash each other up in ugly ways.
485 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
486 $embed = "<span dir='$dir'>";
488 $t = $embed . implode ( "$pop | $embed" , $wgOut->mCategoryLinks
) . $pop;
490 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
491 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
492 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
495 # optional 'dmoz-like' category browser. Will be shown under the list
496 # of categories an article belong to
497 if($wgUseCategoryBrowser) {
498 $s .= '<br /><hr />';
500 # get a big array of the parents tree
501 $parenttree = $wgTitle->getParentCategoryTree();
502 # Skin object passed by reference cause it can not be
503 # accessed under the method subfunction drawCategoryBrowser
504 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
505 # Clean out bogus first entry and sort them
508 # Output one per line
509 $s .= implode("<br />\n", $tempout);
515 /** Render the array as a serie of links.
516 * @param array $tree Categories tree returned by Title::getParentCategoryTree
517 * @param object &skin Skin passed by reference
518 * @return string separated by >, terminate with "\n"
520 function drawCategoryBrowser($tree, &$skin) {
522 foreach ($tree as $element => $parent) {
523 if (empty($parent)) {
524 # element start a new list
527 # grab the others elements
528 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
530 # add our current element to the list
531 $eltitle = Title
::NewFromText($element);
532 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
537 function getCategories() {
538 $catlinks=$this->getCategoryLinks();
539 if(!empty($catlinks)) {
540 return "<p class='catlinks'>{$catlinks}</p>";
544 function getQuickbarCompensator( $rows = 1 ) {
545 return "<td width='152' rowspan='{$rows}'> </td>";
549 * This gets called immediately before the </body> tag.
550 * @return string HTML to be put after </body> ???
552 function afterContent() {
553 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
554 return $printfooter . $this->doAfterContent();
557 /** @return string Retrievied from HTML text */
558 function printSource() {
560 $url = htmlspecialchars( $wgTitle->getFullURL() );
561 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
564 function printFooter() {
565 return "<p>" . $this->printSource() .
566 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
569 /** overloaded by derived classes */
570 function doAfterContent() { }
572 function pageTitleLinks() {
573 global $wgOut, $wgTitle, $wgUser, $wgRequest;
575 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
576 $action = $wgRequest->getText( 'action' );
578 $s = $this->printableLink();
579 $disclaimer = $this->disclaimerLink(); # may be empty
581 $s .= ' | ' . $disclaimer;
583 $privacy = $this->privacyLink(); # may be empty too
585 $s .= ' | ' . $privacy;
588 if ( $wgOut->isArticleRelated() ) {
589 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
590 $name = $wgTitle->getDBkey();
591 $image = new Image( $wgTitle );
592 if( $image->exists() ) {
593 $link = htmlspecialchars( $image->getURL() );
594 $style = $this->getInternalLinkAttributes( $link, $name );
595 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
599 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
600 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
601 wfMsg( 'currentrev' ) );
604 if ( $wgUser->getNewtalk() ) {
605 # do not show "You have new messages" text when we are viewing our
607 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
608 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
609 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
610 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
612 $wgOut->setSquidMaxage(0);
613 $wgOut->enableClientCache(false);
617 $undelete = $this->getUndeleteLink();
618 if( !empty( $undelete ) ) {
619 $s .= ' | '.$undelete;
624 function getUndeleteLink() {
625 global $wgUser, $wgTitle, $wgContLang, $action;
626 if( $wgUser->isAllowed( 'deletedhistory' ) &&
627 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
628 ($n = $wgTitle->isDeleted() ) )
630 if ( $wgUser->isAllowed( 'delete' ) ) {
631 $msg = 'thisisdeleted';
633 $msg = 'viewdeleted';
636 $this->makeKnownLink(
637 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
638 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
643 function printableLink() {
644 global $wgOut, $wgFeedClasses, $wgRequest;
646 $baseurl = $_SERVER['REQUEST_URI'];
647 if( strpos( '?', $baseurl ) == false ) {
652 $baseurl = htmlspecialchars( $baseurl );
653 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
655 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
656 if( $wgOut->isSyndicated() ) {
657 foreach( $wgFeedClasses as $format => $class ) {
658 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
659 $s .= " | <a href=\"$feedurl\">{$format}</a>";
665 function pageTitle() {
668 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
672 function pageSubtitle() {
675 $sub = $wgOut->getSubtitle();
677 global $wgExtraSubtitle;
678 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
680 $subpages = $this->subPageSubtitle();
681 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
682 $s = "<p class='subtitle'>{$sub}</p>\n";
686 function subPageSubtitle() {
687 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
689 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
690 $ptext=$wgTitle->getPrefixedText();
691 if(preg_match('/\//',$ptext)) {
692 $links = explode('/',$ptext);
695 foreach($links as $link) {
697 if ($c<count($links)) {
698 $growinglink .= $link;
699 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
700 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
704 $subpages .= '< ';
706 $subpages .= $getlink;
715 function nameAndLogin() {
716 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
718 $li = $wgContLang->specialPage( 'Userlogin' );
719 $lo = $wgContLang->specialPage( 'Userlogout' );
722 if ( $wgUser->isAnon() ) {
723 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
726 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
727 $wgLang->getNsText( NS_TALK
) );
729 $s .= $n . ' ('.$tl.')';
731 $s .= wfMsg('notloggedin');
734 $rt = $wgTitle->getPrefixedURL();
735 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
737 } else { $q = "returnto={$rt}"; }
739 $s .= "\n<br />" . $this->makeKnownLinkObj(
740 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
741 wfMsg( 'login' ), $q );
743 $n = $wgUser->getName();
744 $rt = $wgTitle->getPrefixedURL();
745 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
746 $wgLang->getNsText( NS_TALK
) );
750 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
751 $n ) . "{$tl}<br />" .
752 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
753 "returnto={$rt}" ) . ' | ' .
754 $this->specialLink( 'preferences' );
756 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
762 function getSearchLink() {
763 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
764 return $searchPage->getLocalURL();
767 function escapeSearchLink() {
768 return htmlspecialchars( $this->getSearchLink() );
771 function searchForm() {
773 $search = $wgRequest->getText( 'search' );
775 $s = '<form name="search" class="inline" method="post" action="'
776 . $this->escapeSearchLink() . "\">\n"
777 . '<input type="text" name="search" size="19" value="'
778 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
779 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
780 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
785 function topLinks() {
789 $s = $this->mainPageLink() . $sep
790 . $this->specialLink( 'recentchanges' );
792 if ( $wgOut->isArticleRelated() ) {
793 $s .= $sep . $this->editThisPage()
794 . $sep . $this->historyLink();
796 # Many people don't like this dropdown box
797 #$s .= $sep . $this->specialPagesList();
799 /* show links to different language variants */
800 global $wgDisableLangConversion, $wgContLang, $wgTitle;
801 $variants = $wgContLang->getVariants();
802 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
803 foreach( $variants as $code ) {
804 $varname = $wgContLang->getVariantname( $code );
805 if( $varname == 'disable' )
807 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
814 function bottomLinks() {
815 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
819 if ( $wgOut->isArticleRelated() ) {
820 $s .= '<strong>' . $this->editThisPage() . '</strong>';
821 if ( $wgUser->isLoggedIn() ) {
822 $s .= $sep . $this->watchThisPage();
824 $s .= $sep . $this->talkLink()
825 . $sep . $this->historyLink()
826 . $sep . $this->whatLinksHere()
827 . $sep . $this->watchPageLinksLink();
829 if ($wgUseTrackbacks)
830 $s .= $sep . $this->trackbackLink();
832 if ( $wgTitle->getNamespace() == NS_USER
833 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
836 $id=User
::idFromName($wgTitle->getText());
837 $ip=User
::isIP($wgTitle->getText());
839 if($id ||
$ip) { # both anons and non-anons have contri list
840 $s .= $sep . $this->userContribsLink();
842 if( $this->showEmailUser( $id ) ) {
843 $s .= $sep . $this->emailUserLink();
846 if ( $wgTitle->getArticleId() ) {
848 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
849 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
850 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
852 $s .= "<br />\n" . $this->otherLanguages();
857 function pageStats() {
858 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
859 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
861 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
862 if ( ! $wgOut->isArticle() ) { return ''; }
863 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
864 if ( 0 == $wgArticle->getID() ) { return ''; }
867 if ( !$wgDisableCounters ) {
868 $count = $wgLang->formatNum( $wgArticle->getCount() );
870 $s = wfMsg( 'viewcount', $count );
874 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
875 require_once('Credits.php');
876 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
878 $s .= $this->lastModified();
881 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
882 $dbr =& wfGetDB( DB_SLAVE
);
883 extract( $dbr->tableNames( 'watchlist' ) );
884 $sql = "SELECT COUNT(*) AS n FROM $watchlist
885 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
886 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
887 $res = $dbr->query( $sql, 'Skin::pageStats');
888 $x = $dbr->fetchObject( $res );
889 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
892 return $s . ' ' . $this->getCopyright();
895 function getCopyright() {
896 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
899 $oldid = $wgRequest->getVal( 'oldid' );
900 $diff = $wgRequest->getVal( 'diff' );
902 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
903 $msg = 'history_copyright';
909 if( $wgRightsPage ) {
910 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
911 } elseif( $wgRightsUrl ) {
912 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
917 $out .= wfMsgForContent( $msg, $link );
921 function getCopyrightIcon() {
922 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
924 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
925 $out = $wgCopyrightIcon;
926 } else if ( $wgRightsIcon ) {
927 $icon = htmlspecialchars( $wgRightsIcon );
928 if ( $wgRightsUrl ) {
929 $url = htmlspecialchars( $wgRightsUrl );
930 $out .= '<a href="'.$url.'">';
932 $text = htmlspecialchars( $wgRightsText );
933 $out .= "<img src=\"$icon\" alt='$text' />";
934 if ( $wgRightsUrl ) {
941 function getPoweredBy() {
943 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
944 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
948 function lastModified() {
949 global $wgLang, $wgArticle, $wgLoadBalancer;
951 $timestamp = $wgArticle->getTimestamp();
953 $d = $wgLang->timeanddate( $timestamp, true );
954 $s = ' ' . wfMsg( 'lastmodified', $d );
958 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
959 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
964 function logoText( $align = '' ) {
965 if ( '' != $align ) { $a = " align='{$align}'"; }
968 $mp = wfMsg( 'mainpage' );
969 $titleObj = Title
::newFromText( $mp );
970 if ( is_object( $titleObj ) ) {
971 $url = $titleObj->escapeLocalURL();
976 $logourl = $this->getLogo();
977 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
982 * show a drop-down box of special pages
983 * @TODO crash bug913. Need to be rewrote completly.
985 function specialPagesList() {
986 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
987 require_once('SpecialPage.php');
989 $pages = SpecialPage
::getPages();
991 // special pages without access restriction
992 foreach ( $pages[''] as $name => $page ) {
993 $a[$name] = $page->getDescription();
996 // Other special pages that are restricted.
997 // Copied from SpecialSpecialpages.php
998 foreach($wgAvailableRights as $right) {
999 if( $wgUser->isAllowed($right) ) {
1000 /** Add all pages for this right */
1001 if(isset($pages[$right])) {
1002 foreach($pages[$right] as $name => $page) {
1003 $a[$name] = $page->getDescription();
1009 $go = wfMsg( 'go' );
1010 $sp = wfMsg( 'specialpages' );
1011 $spp = $wgContLang->specialPage( 'Specialpages' );
1013 $s = '<form id="specialpages" method="get" class="inline" ' .
1014 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1015 $s .= "<select name=\"wpDropdown\">\n";
1016 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1019 foreach ( $a as $name => $desc ) {
1020 $p = $wgContLang->specialPage( $name );
1021 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1023 $s .= "</select>\n";
1024 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1029 function mainPageLink() {
1030 $mp = wfMsgForContent( 'mainpage' );
1031 $mptxt = wfMsg( 'mainpage');
1032 $s = $this->makeKnownLink( $mp, $mptxt );
1036 function copyrightLink() {
1037 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1038 wfMsg( 'copyrightpagename' ) );
1042 function privacyLink() {
1043 $privacy = wfMsg( 'privacy' );
1044 if ($privacy == '-') {
1047 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1051 function aboutLink() {
1052 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1053 wfMsg( 'aboutsite' ) );
1057 function disclaimerLink() {
1058 $disclaimers = wfMsg( 'disclaimers' );
1059 if ($disclaimers == '-') {
1062 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1067 function editThisPage() {
1068 global $wgOut, $wgTitle;
1070 if ( ! $wgOut->isArticleRelated() ) {
1071 $s = wfMsg( 'protectedpage' );
1073 if ( $wgTitle->userCanEdit() ) {
1074 $t = wfMsg( 'editthispage' );
1076 $t = wfMsg( 'viewsource' );
1079 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1085 * Return URL options for the 'edit page' link.
1086 * This may include an 'oldid' specifier, if the current page view is such.
1091 function editUrlOptions() {
1094 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1095 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1097 return "action=edit";
1101 function deleteThisPage() {
1102 global $wgUser, $wgTitle, $wgRequest;
1104 $diff = $wgRequest->getVal( 'diff' );
1105 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1106 $t = wfMsg( 'deletethispage' );
1108 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1115 function protectThisPage() {
1116 global $wgUser, $wgTitle, $wgRequest;
1118 $diff = $wgRequest->getVal( 'diff' );
1119 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1120 if ( $wgTitle->isProtected() ) {
1121 $t = wfMsg( 'unprotectthispage' );
1122 $q = 'action=unprotect';
1124 $t = wfMsg( 'protectthispage' );
1125 $q = 'action=protect';
1127 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1134 function watchThisPage() {
1135 global $wgOut, $wgTitle;
1137 if ( $wgOut->isArticleRelated() ) {
1138 if ( $wgTitle->userIsWatching() ) {
1139 $t = wfMsg( 'unwatchthispage' );
1140 $q = 'action=unwatch';
1142 $t = wfMsg( 'watchthispage' );
1143 $q = 'action=watch';
1145 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1147 $s = wfMsg( 'notanarticle' );
1152 function moveThisPage() {
1155 if ( $wgTitle->userCanMove() ) {
1156 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1157 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1159 // no message if page is protected - would be redundant
1164 function historyLink() {
1167 return $this->makeKnownLinkObj( $wgTitle,
1168 wfMsg( 'history' ), 'action=history' );
1171 function whatLinksHere() {
1174 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1175 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1178 function userContribsLink() {
1181 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1182 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1185 function showEmailUser( $id ) {
1186 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1187 return $wgEnableEmail &&
1188 $wgEnableUserEmail &&
1189 $wgUser->isLoggedIn() && # show only to signed in users
1190 0 != $id; # we can only email to non-anons ..
1191 # '' != $id->getEmail() && # who must have an email address stored ..
1192 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1193 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1196 function emailUserLink() {
1199 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1200 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1203 function watchPageLinksLink() {
1204 global $wgOut, $wgTitle;
1206 if ( ! $wgOut->isArticleRelated() ) {
1207 return '(' . wfMsg( 'notanarticle' ) . ')';
1209 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1210 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1211 'target=' . $wgTitle->getPrefixedURL() );
1215 function trackbackLink() {
1218 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1219 . wfMsg('trackbacklink') . "</a>";
1222 function otherLanguages() {
1223 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1225 if ( $wgHideInterlanguageLinks ) {
1229 $a = $wgOut->getLanguageLinks();
1230 if ( 0 == count( $a ) ) {
1234 $s = wfMsg( 'otherlanguages' ) . ': ';
1236 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1237 foreach( $a as $l ) {
1238 if ( ! $first ) { $s .= ' | '; }
1241 $nt = Title
::newFromText( $l );
1242 $url = $nt->escapeFullURL();
1243 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1245 if ( '' == $text ) { $text = $l; }
1246 $style = $this->getExternalLinkAttributes( $l, $text );
1247 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1249 if($wgContLang->isRTL()) $s .= '</span>';
1253 function bugReportsLink() {
1254 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1255 wfMsg( 'bugreports' ) );
1259 function dateLink() {
1260 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1261 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1263 $id = $t1->getArticleID();
1266 $s = $this->makeBrokenLink( $t1->getText() );
1268 $s = $this->makeKnownLink( $t1->getText() );
1272 $id = $t2->getArticleID();
1275 $s .= $this->makeBrokenLink( $t2->getText() );
1277 $s .= $this->makeKnownLink( $t2->getText() );
1282 function talkLink() {
1285 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1286 # No discussion links for special pages
1290 if( $wgTitle->isTalkPage() ) {
1291 $link = $wgTitle->getSubjectPage();
1292 switch( $link->getNamespace() ) {
1294 $text = wfMsg('articlepage');
1297 $text = wfMsg('userpage');
1300 $text = wfMsg('wikipediapage');
1303 $text = wfMsg('imagepage');
1306 $text= wfMsg('articlepage');
1309 $link = $wgTitle->getTalkPage();
1310 $text = wfMsg( 'talkpage' );
1313 $s = $this->makeLinkObj( $link, $text );
1318 function commentLink() {
1321 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1324 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1325 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1328 /* these are used extensively in SkinTemplate, but also some other places */
1329 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1330 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1331 return $title->getLocalURL( $urlaction );
1334 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1335 $title = Title
::newFromText( wfMsgForContent($name) );
1336 $this->checkTitle($title, $name);
1337 return $title->getLocalURL( $urlaction );
1340 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1341 $title = Title
::newFromText( $name );
1342 $this->checkTitle($title, $name);
1343 return $title->getLocalURL( $urlaction );
1346 # If url string starts with http, consider as external URL, else
1348 /*static*/ function makeInternalOrExternalUrl( $name ) {
1349 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1352 return $this->makeUrl( $name );
1356 # this can be passed the NS number as defined in Language.php
1357 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1358 $title = Title
::makeTitleSafe( $namespace, $name );
1359 $this->checkTitle($title, $name);
1360 return $title->getLocalURL( $urlaction );
1363 /* these return an array with the 'href' and boolean 'exists' */
1364 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1365 $title = Title
::newFromText( $name );
1366 $this->checkTitle($title, $name);
1368 'href' => $title->getLocalURL( $urlaction ),
1369 'exists' => $title->getArticleID() != 0?
true:false
1374 * Make URL details where the article exists (or at least it's convenient to think so)
1376 function makeKnownUrlDetails( $name, $urlaction='' ) {
1377 $title = Title
::newFromText( $name );
1378 $this->checkTitle($title, $name);
1380 'href' => $title->getLocalURL( $urlaction ),
1385 # make sure we have some title to operate on
1386 /*static*/ function checkTitle ( &$title, &$name ) {
1387 if(!is_object($title)) {
1388 $title = Title
::newFromText( $name );
1389 if(!is_object($title)) {
1390 $title = Title
::newFromText( '--error: link target missing--' );
1396 * Build an array that represents the sidebar(s), the navigation bar among them
1401 function buildSidebar() {
1402 global $wgDBname, $parserMemc;
1403 global $wgLanguageCode, $wgContLanguageCode;
1405 $fname = 'SkinTemplate::buildSidebar';
1407 wfProfileIn( $fname );
1409 if ($wgLanguageCode == $wgContLanguageCode)
1410 $cacheSidebar = true;
1412 $cacheSidebar = false;
1414 if ($cacheSidebar) {
1415 $cachedsidebar=$parserMemc->get("{$wgDBname}:sidebar");
1416 if ($cachedsidebar!="") {
1417 wfProfileOut($fname);
1418 return $cachedsidebar;
1423 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1424 foreach ($lines as $line) {
1425 if (strpos($line, '*') !== 0)
1427 if (strpos($line, '**') !== 0) {
1428 $line = trim($line, '* ');
1431 if (strpos($line, '|') !== false) { // sanity check
1432 $line = explode( '|' , trim($line, '* '), 2 );
1433 $link = wfMsgForContent( $line[0] );
1436 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1438 if (wfEmptyMsg($line[0], $link))
1440 $href = $this->makeInternalOrExternalUrl( $link );
1441 $bar[$heading][] = array(
1444 'id' => 'n-' . strtr($line[1], ' ', '-'),
1447 } else { continue; }
1451 $cachednotice=$parserMemc->set("{$wgDBname}:sidebar",$bar,86400);
1452 wfProfileOut( $fname );