10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Linker.php' );
16 require_once( 'Image.php' );
18 # Get a list of all skins available in /skins/
19 # Build using the regular expression '^(.*).php$'
20 # Array keys are all lower case, array value keep the case used by filename
23 $skinDir = dir($IP.'/skins');
25 # while code from www.php.net
26 while (false !== ($file = $skinDir->read())) {
27 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
29 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
35 require_once( 'RecentChange.php' );
41 class RCCacheEntry
extends RecentChange
43 var $secureName, $link;
44 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
45 var $userlink, $timestamp, $watched;
47 function newFromParent( $rc )
49 $rc2 = new RCCacheEntry
;
50 $rc2->mAttribs
= $rc->mAttribs
;
51 $rc2->mExtra
= $rc->mExtra
;
58 * The main skin class that provide methods and properties for all other skins
59 * including PHPTal skins.
60 * This base class is also the "Standard" skin.
63 class Skin
extends Linker
{
67 var $lastdate, $lastline;
68 var $rc_cache ; # Cache for Enhanced Recent Changes
69 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
73 /** Constructor, call parent constructor */
74 function Skin() { parent
::Linker(); }
77 * Fetch the set of available skins.
78 * @return array of strings
81 function getSkinNames() {
82 global $wgValidSkinNames;
83 return $wgValidSkinNames;
87 * Normalize a skin preference value to a form that can be loaded.
88 * If a skin can't be found, it will fall back to the configured
89 * default (or the old 'Classic' skin if that's broken).
94 function normalizeKey( $key ) {
95 global $wgDefaultSkin;
96 $skinNames = Skin
::getSkinNames();
99 // Don't return the default immediately;
100 // in a misconfiguration we need to fall back.
101 $key = $wgDefaultSkin;
104 if( isset( $skinNames[$key] ) ) {
108 // Older versions of the software used a numeric setting
109 // in the user preferences.
113 2 => 'cologneblue' );
115 if( isset( $fallback[$key] ) ){
116 $key = $fallback[$key];
119 if( isset( $skinNames[$key] ) ) {
122 // The old built-in skin
128 * Factory method for loading a skin of a given type
129 * @param string $key 'monobook', 'standard', etc
133 function &newFromKey( $key ) {
134 $key = Skin
::normalizeKey( $key );
136 $skinNames = Skin
::getSkinNames();
137 $skinName = $skinNames[$key];
141 # Grab the skin class and initialise it. Each skin checks for PHPTal
142 # and will not load if it's not enabled.
143 require_once( $IP.'/skins/'.$skinName.'.php' );
145 # Check if we got if not failback to default skin
146 $className = 'Skin'.$skinName;
147 if( !class_exists( $className ) ) {
148 # DO NOT die if the class isn't found. This breaks maintenance
149 # scripts and can cause a user account to be unrecoverable
150 # except by SQL manipulation if a previously valid skin name
151 # is no longer valid.
152 $className = 'SkinStandard';
153 require_once( $IP.'/skins/Standard.php' );
155 $skin =& new $className;
159 /** @return string path to the skin stylesheet */
160 function getStylesheet() {
161 return 'common/wikistandard.css?1';
164 /** @return string skin name */
165 function getSkinName() {
169 function qbSetting() {
170 global $wgOut, $wgUser;
172 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
173 $q = $wgUser->getOption( 'quickbar' );
174 if ( '' == $q ) { $q = 0; }
178 function initPage( &$out ) {
179 $fname = 'Skin::initPage';
180 wfProfileIn( $fname );
182 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
184 $this->addMetadataLinks($out);
186 $this->mRevisionId
= $out->mRevisionId
;
188 wfProfileOut( $fname );
191 function addMetadataLinks( &$out ) {
192 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
193 global $wgRightsPage, $wgRightsUrl;
195 if( $out->isArticleRelated() ) {
196 # note: buggy CC software only reads first "meta" link
197 if( $wgEnableCreativeCommonsRdf ) {
198 $out->addMetadataLink( array(
199 'title' => 'Creative Commons',
200 'type' => 'application/rdf+xml',
201 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
203 if( $wgEnableDublinCoreRdf ) {
204 $out->addMetadataLink( array(
205 'title' => 'Dublin Core',
206 'type' => 'application/rdf+xml',
207 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
211 if( $wgRightsPage ) {
212 $copy = Title
::newFromText( $wgRightsPage );
214 $copyright = $copy->getLocalURL();
217 if( !$copyright && $wgRightsUrl ) {
218 $copyright = $wgRightsUrl;
221 $out->addLink( array(
222 'rel' => 'copyright',
223 'href' => $copyright ) );
227 function outputPage( &$out ) {
228 global $wgDebugComments;
230 wfProfileIn( 'Skin::outputPage' );
231 $this->initPage( $out );
233 $out->out( $out->headElement() );
235 $out->out( "\n<body" );
236 $ops = $this->getBodyOptions();
237 foreach ( $ops as $name => $val ) {
238 $out->out( " $name='$val'" );
241 if ( $wgDebugComments ) {
242 $out->out( "<!-- Wiki debugging output:\n" .
243 $out->mDebugtext
. "-->\n" );
246 $out->out( $this->beforeContent() );
248 $out->out( $out->mBodytext
. "\n" );
250 $out->out( $this->afterContent() );
252 $out->out( $out->reportTime() );
254 $out->out( "\n</body></html>" );
257 function getHeadScripts() {
258 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType;
259 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
260 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
261 $userpage = $wgUser->getUserPage();
262 $userjs = htmlspecialchars( $this->makeUrl(
263 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
264 'action=raw&ctype='.$wgJsMimeType));
265 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
271 * To make it harder for someone to slip a user a fake
272 * user-JavaScript or user-CSS preview, a random token
273 * is associated with the login session. If it's not
274 * passed back with the preview request, we won't render
277 * @param string $action
281 function userCanPreview( $action ) {
282 global $wgTitle, $wgRequest, $wgUser;
284 if( $action != 'submit' )
286 if( !$wgRequest->wasPosted() )
288 if( !$wgTitle->userCanEditCssJsSubpage() )
290 return $wgUser->matchEditToken(
291 $wgRequest->getVal( 'wpEditToken' ) );
294 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
295 function getUserStylesheet() {
296 global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
297 $sheet = $this->getStylesheet();
298 $action = $wgRequest->getText('action');
299 $s = "@import \"$wgStylePath/$sheet\";\n";
300 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
302 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
303 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
304 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
306 $s .= $this->doGetUserStyles();
311 * placeholder, returns generated js in monobook
313 function getUserJs() { return; }
316 * Return html code that include User stylesheets
318 function getUserStyles() {
319 global $wgOut, $wgStylePath;
320 $s = "<style type='text/css'>\n";
321 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
322 $s .= $this->getUserStylesheet();
323 $s .= "/*]]>*/ /* */\n";
329 * Some styles that are set by user through the user settings interface.
331 function doGetUserStyles() {
332 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
336 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
337 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
338 $s .= $wgRequest->getText('wpTextbox1');
340 $userpage = $wgUser->getUserPage();
341 $s.= '@import "'.$this->makeUrl(
342 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
343 'action=raw&ctype=text/css').'";'."\n";
347 return $s . $this->reallyDoGetUserStyles();
350 function reallyDoGetUserStyles() {
353 if (($undopt = $wgUser->getOption("underline")) != 2) {
354 $underline = $undopt ?
'underline' : 'none';
355 $s .= "a { text-decoration: $underline; }\n";
357 if( $wgUser->getOption( 'highlightbroken' ) ) {
358 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
361 a.new, #quickbar a.new,
362 a.stub, #quickbar a.stub {
364 text-decoration: inherit;
366 a.new:after, #quickbar a.new:after {
369 text-decoration: $underline;
371 a.stub:after, #quickbar a.stub:after {
374 text-decoration: $underline;
378 if( $wgUser->getOption( 'justify' ) ) {
379 $s .= "#article, #bodyContent { text-align: justify; }\n";
381 if( !$wgUser->getOption( 'showtoc' ) ) {
382 $s .= "#toc { display: none; }\n";
384 if( !$wgUser->getOption( 'editsection' ) ) {
385 $s .= ".editsection { display: none; }\n";
390 function getBodyOptions() {
391 global $wgUser, $wgTitle, $wgOut, $wgRequest;
393 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
395 if ( 0 != $wgTitle->getNamespace() ) {
396 $a = array( 'bgcolor' => '#ffffec' );
398 else $a = array( 'bgcolor' => '#FFFFFF' );
399 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
400 $wgTitle->userCanEdit() ) {
401 $t = wfMsg( 'editthispage' );
402 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
403 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
404 $a +
= array ('ondblclick' => $s);
407 $a['onload'] = $wgOut->getOnloadHandler();
408 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
409 if( $a['onload'] != '' ) {
412 $a['onload'] .= 'setupRightClickEdit()';
426 * This will be called immediately after the <body> tag. Split into
427 * two functions to make it easier to subclass.
429 function beforeContent() {
430 return $this->doBeforeContent();
433 function doBeforeContent() {
434 global $wgOut, $wgTitle, $wgContLang;
435 $fname = 'Skin::doBeforeContent';
436 wfProfileIn( $fname );
439 $qb = $this->qbSetting();
441 if( $langlinks = $this->otherLanguages() ) {
447 $borderhack = 'class="top"';
450 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
451 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
454 $left = ($qb == 1 ||
$qb == 3);
455 if($wgContLang->isRTL()) $left = !$left;
458 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
459 $this->logoText() . '</td>';
461 $s .= $this->getQuickbarCompensator( $rows );
463 $l = $wgContLang->isRTL() ?
'right' : 'left';
464 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
466 $s .= $this->topLinks() ;
467 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
469 $r = $wgContLang->isRTL() ?
"left" : "right";
470 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
471 $s .= $this->nameAndLogin();
472 $s .= "\n<br />" . $this->searchForm() . "</td>";
475 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
478 if ( $shove && !$left ) { # Right
479 $s .= $this->getQuickbarCompensator( $rows );
481 $s .= "</tr>\n</table>\n</div>\n";
482 $s .= "\n<div id='article'>\n";
484 $notice = wfGetSiteNotice();
486 $s .= "\n<div id='siteNotice'>$notice</div>\n";
488 $s .= $this->pageTitle();
489 $s .= $this->pageSubtitle() ;
490 $s .= $this->getCategories();
491 wfProfileOut( $fname );
496 function getCategoryLinks () {
497 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
500 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
502 // Use Unicode bidi embedding override characters,
503 // to make sure links don't smash each other up in ugly ways.
504 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
505 $embed = "<span dir='$dir'>";
507 $t = $embed . implode ( "$pop | $embed" , $wgOut->mCategoryLinks
) . $pop;
509 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
510 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
511 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
514 # optional 'dmoz-like' category browser. Will be shown under the list
515 # of categories an article belong to
516 if($wgUseCategoryBrowser) {
517 $s .= '<br /><hr />';
519 # get a big array of the parents tree
520 $parenttree = $wgTitle->getParentCategoryTree();
521 # Skin object passed by reference cause it can not be
522 # accessed under the method subfunction drawCategoryBrowser
523 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
524 # Clean out bogus first entry and sort them
527 # Output one per line
528 $s .= implode("<br />\n", $tempout);
534 /** Render the array as a serie of links.
535 * @param array $tree Categories tree returned by Title::getParentCategoryTree
536 * @param object &skin Skin passed by reference
537 * @return string separated by >, terminate with "\n"
539 function drawCategoryBrowser($tree, &$skin) {
541 foreach ($tree as $element => $parent) {
542 if (empty($parent)) {
543 # element start a new list
546 # grab the others elements
547 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
549 # add our current element to the list
550 $eltitle = Title
::NewFromText($element);
551 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
556 function getCategories() {
557 $catlinks=$this->getCategoryLinks();
558 if(!empty($catlinks)) {
559 return "<p class='catlinks'>{$catlinks}</p>";
563 function getQuickbarCompensator( $rows = 1 ) {
564 return "<td width='152' rowspan='{$rows}'> </td>";
568 * This gets called immediately before the </body> tag.
569 * @return string HTML to be put after </body> ???
571 function afterContent() {
572 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
573 return $printfooter . $this->doAfterContent();
576 /** @return string Retrievied from HTML text */
577 function printSource() {
579 $url = htmlspecialchars( $wgTitle->getFullURL() );
580 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
583 function printFooter() {
584 return "<p>" . $this->printSource() .
585 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
588 /** overloaded by derived classes */
589 function doAfterContent() { }
591 function pageTitleLinks() {
592 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
594 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
595 $action = $wgRequest->getText( 'action' );
597 $s = $this->printableLink();
598 $disclaimer = $this->disclaimerLink(); # may be empty
600 $s .= ' | ' . $disclaimer;
602 $privacy = $this->privacyLink(); # may be empty too
604 $s .= ' | ' . $privacy;
607 if ( $wgOut->isArticleRelated() ) {
608 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
609 $name = $wgTitle->getDBkey();
610 $image = new Image( $wgTitle );
611 if( $image->exists() ) {
612 $link = htmlspecialchars( $image->getURL() );
613 $style = $this->getInternalLinkAttributes( $link, $name );
614 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
618 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
619 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
620 wfMsg( 'currentrev' ) );
623 if ( $wgUser->getNewtalk() ) {
624 # do not show "You have new messages" text when we are viewing our
626 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
627 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ) );
628 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
629 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
631 $wgOut->setSquidMaxage(0);
632 $wgOut->enableClientCache(false);
636 $undelete = $this->getUndeleteLink();
637 if( !empty( $undelete ) ) {
638 $s .= ' | '.$undelete;
643 function getUndeleteLink() {
644 global $wgUser, $wgTitle, $wgContLang, $action;
645 if( $wgUser->isAllowed( 'deletedhistory' ) &&
646 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
647 ($n = $wgTitle->isDeleted() ) )
649 if ( $wgUser->isAllowed( 'delete' ) ) {
650 $msg = 'thisisdeleted';
652 $msg = 'viewdeleted';
655 $this->makeKnownLink(
656 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
657 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
662 function printableLink() {
663 global $wgOut, $wgFeedClasses, $wgRequest;
665 $baseurl = $_SERVER['REQUEST_URI'];
666 if( strpos( '?', $baseurl ) == false ) {
671 $baseurl = htmlspecialchars( $baseurl );
672 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
674 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
675 if( $wgOut->isSyndicated() ) {
676 foreach( $wgFeedClasses as $format => $class ) {
677 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
678 $s .= " | <a href=\"$feedurl\">{$format}</a>";
684 function pageTitle() {
685 global $wgOut, $wgTitle, $wgUser;
687 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
691 function pageSubtitle() {
694 $sub = $wgOut->getSubtitle();
696 global $wgExtraSubtitle;
697 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
699 $subpages = $this->subPageSubtitle();
700 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
701 $s = "<p class='subtitle'>{$sub}</p>\n";
705 function subPageSubtitle() {
706 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
708 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
709 $ptext=$wgTitle->getPrefixedText();
710 if(preg_match('/\//',$ptext)) {
711 $links = explode('/',$ptext);
714 foreach($links as $link) {
716 if ($c<count($links)) {
717 $growinglink .= $link;
718 $getlink = $this->makeLink( $growinglink, $link );
719 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
723 $subpages .= '< ';
725 $subpages .= $getlink;
734 function nameAndLogin() {
735 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
737 $li = $wgContLang->specialPage( 'Userlogin' );
738 $lo = $wgContLang->specialPage( 'Userlogout' );
741 if ( $wgUser->isAnon() ) {
742 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
745 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
746 $wgLang->getNsText( NS_TALK
) );
748 $s .= $n . ' ('.$tl.')';
750 $s .= wfMsg('notloggedin');
753 $rt = $wgTitle->getPrefixedURL();
754 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
756 } else { $q = "returnto={$rt}"; }
758 $s .= "\n<br />" . $this->makeKnownLinkObj(
759 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
760 wfMsg( 'login' ), $q );
762 $n = $wgUser->getName();
763 $rt = $wgTitle->getPrefixedURL();
764 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
765 $wgLang->getNsText( NS_TALK
) );
769 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
770 $n ) . "{$tl}<br />" .
771 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
772 "returnto={$rt}" ) . ' | ' .
773 $this->specialLink( 'preferences' );
775 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
781 function getSearchLink() {
782 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
783 return $searchPage->getLocalURL();
786 function escapeSearchLink() {
787 return htmlspecialchars( $this->getSearchLink() );
790 function searchForm() {
792 $search = $wgRequest->getText( 'search' );
794 $s = '<form name="search" class="inline" method="post" action="'
795 . $this->escapeSearchLink() . "\">\n"
796 . '<input type="text" name="search" size="19" value="'
797 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
798 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
799 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
804 function topLinks() {
808 $s = $this->mainPageLink() . $sep
809 . $this->specialLink( 'recentchanges' );
811 if ( $wgOut->isArticleRelated() ) {
812 $s .= $sep . $this->editThisPage()
813 . $sep . $this->historyLink();
815 # Many people don't like this dropdown box
816 #$s .= $sep . $this->specialPagesList();
818 /* show links to different language variants */
819 global $wgDisableLangConversion, $wgContLang, $wgTitle;
820 $variants = $wgContLang->getVariants();
821 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
822 foreach( $variants as $code ) {
823 $varname = $wgContLang->getVariantname( $code );
824 if( $varname == 'disable' )
826 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
833 function bottomLinks() {
834 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
838 if ( $wgOut->isArticleRelated() ) {
839 $s .= '<strong>' . $this->editThisPage() . '</strong>';
840 if ( $wgUser->isLoggedIn() ) {
841 $s .= $sep . $this->watchThisPage();
843 $s .= $sep . $this->talkLink()
844 . $sep . $this->historyLink()
845 . $sep . $this->whatLinksHere()
846 . $sep . $this->watchPageLinksLink();
848 if ($wgUseTrackbacks)
849 $s .= $sep . $this->trackbackLink();
851 if ( $wgTitle->getNamespace() == NS_USER
852 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
855 $id=User
::idFromName($wgTitle->getText());
856 $ip=User
::isIP($wgTitle->getText());
858 if($id ||
$ip) { # both anons and non-anons have contri list
859 $s .= $sep . $this->userContribsLink();
861 if( $this->showEmailUser( $id ) ) {
862 $s .= $sep . $this->emailUserLink();
865 if ( $wgTitle->getArticleId() ) {
867 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
868 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
869 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
871 $s .= "<br />\n" . $this->otherLanguages();
876 function pageStats() {
877 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
878 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
880 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
881 if ( ! $wgOut->isArticle() ) { return ''; }
882 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
883 if ( 0 == $wgArticle->getID() ) { return ''; }
886 if ( !$wgDisableCounters ) {
887 $count = $wgLang->formatNum( $wgArticle->getCount() );
889 $s = wfMsg( 'viewcount', $count );
893 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
894 require_once('Credits.php');
895 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
897 $s .= $this->lastModified();
900 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
901 $dbr =& wfGetDB( DB_SLAVE
);
902 extract( $dbr->tableNames( 'watchlist' ) );
903 $sql = "SELECT COUNT(*) AS n FROM $watchlist
904 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
905 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
906 $res = $dbr->query( $sql, 'Skin::pageStats');
907 $x = $dbr->fetchObject( $res );
908 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
911 return $s . ' ' . $this->getCopyright();
914 function getCopyright() {
915 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
918 $oldid = $wgRequest->getVal( 'oldid' );
919 $diff = $wgRequest->getVal( 'diff' );
921 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
922 $msg = 'history_copyright';
928 if( $wgRightsPage ) {
929 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
930 } elseif( $wgRightsUrl ) {
931 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
936 $out .= wfMsgForContent( $msg, $link );
940 function getCopyrightIcon() {
941 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
943 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
944 $out = $wgCopyrightIcon;
945 } else if ( $wgRightsIcon ) {
946 $icon = htmlspecialchars( $wgRightsIcon );
947 if ( $wgRightsUrl ) {
948 $url = htmlspecialchars( $wgRightsUrl );
949 $out .= '<a href="'.$url.'">';
951 $text = htmlspecialchars( $wgRightsText );
952 $out .= "<img src=\"$icon\" alt='$text' />";
953 if ( $wgRightsUrl ) {
960 function getPoweredBy() {
962 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
963 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
967 function lastModified() {
968 global $wgLang, $wgArticle, $wgLoadBalancer;
970 $timestamp = $wgArticle->getTimestamp();
972 $d = $wgLang->timeanddate( $timestamp, true );
973 $s = ' ' . wfMsg( 'lastmodified', $d );
977 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
978 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
983 function logoText( $align = '' ) {
984 if ( '' != $align ) { $a = " align='{$align}'"; }
987 $mp = wfMsg( 'mainpage' );
988 $titleObj = Title
::newFromText( $mp );
989 if ( is_object( $titleObj ) ) {
990 $url = $titleObj->escapeLocalURL();
995 $logourl = $this->getLogo();
996 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1001 * show a drop-down box of special pages
1002 * @TODO crash bug913. Need to be rewrote completly.
1004 function specialPagesList() {
1005 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
1006 require_once('SpecialPage.php');
1008 $pages = SpecialPage
::getPages();
1010 // special pages without access restriction
1011 foreach ( $pages[''] as $name => $page ) {
1012 $a[$name] = $page->getDescription();
1015 // Other special pages that are restricted.
1016 // Copied from SpecialSpecialpages.php
1017 foreach($wgAvailableRights as $right) {
1018 if( $wgUser->isAllowed($right) ) {
1019 /** Add all pages for this right */
1020 if(isset($pages[$right])) {
1021 foreach($pages[$right] as $name => $page) {
1022 $a[$name] = $page->getDescription();
1028 $go = wfMsg( 'go' );
1029 $sp = wfMsg( 'specialpages' );
1030 $spp = $wgContLang->specialPage( 'Specialpages' );
1032 $s = '<form id="specialpages" method="get" class="inline" ' .
1033 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1034 $s .= "<select name=\"wpDropdown\">\n";
1035 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1038 foreach ( $a as $name => $desc ) {
1039 $p = $wgContLang->specialPage( $name );
1040 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1042 $s .= "</select>\n";
1043 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1048 function mainPageLink() {
1049 $mp = wfMsgForContent( 'mainpage' );
1050 $mptxt = wfMsg( 'mainpage');
1051 $s = $this->makeKnownLink( $mp, $mptxt );
1055 function copyrightLink() {
1056 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1057 wfMsg( 'copyrightpagename' ) );
1061 function privacyLink() {
1062 $privacy = wfMsg( 'privacy' );
1063 if ($privacy == '-') {
1066 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1070 function aboutLink() {
1071 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1072 wfMsg( 'aboutsite' ) );
1076 function disclaimerLink() {
1077 $disclaimers = wfMsg( 'disclaimers' );
1078 if ($disclaimers == '-') {
1081 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1086 function editThisPage() {
1087 global $wgOut, $wgTitle, $wgRequest;
1089 if ( ! $wgOut->isArticleRelated() ) {
1090 $s = wfMsg( 'protectedpage' );
1092 if ( $wgTitle->userCanEdit() ) {
1093 $t = wfMsg( 'editthispage' );
1095 $t = wfMsg( 'viewsource' );
1098 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1104 * Return URL options for the 'edit page' link.
1105 * This may include an 'oldid' specifier, if the current page view is such.
1110 function editUrlOptions() {
1113 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1114 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1116 return "action=edit";
1120 function deleteThisPage() {
1121 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1123 $diff = $wgRequest->getVal( 'diff' );
1124 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1125 $t = wfMsg( 'deletethispage' );
1127 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1134 function protectThisPage() {
1135 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1137 $diff = $wgRequest->getVal( 'diff' );
1138 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1139 if ( $wgTitle->isProtected() ) {
1140 $t = wfMsg( 'unprotectthispage' );
1141 $q = 'action=unprotect';
1143 $t = wfMsg( 'protectthispage' );
1144 $q = 'action=protect';
1146 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1153 function watchThisPage() {
1154 global $wgUser, $wgOut, $wgTitle;
1156 if ( $wgOut->isArticleRelated() ) {
1157 if ( $wgTitle->userIsWatching() ) {
1158 $t = wfMsg( 'unwatchthispage' );
1159 $q = 'action=unwatch';
1161 $t = wfMsg( 'watchthispage' );
1162 $q = 'action=watch';
1164 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1166 $s = wfMsg( 'notanarticle' );
1171 function moveThisPage() {
1174 if ( $wgTitle->userCanMove() ) {
1175 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1176 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1178 // no message if page is protected - would be redundant
1183 function historyLink() {
1186 return $this->makeKnownLinkObj( $wgTitle,
1187 wfMsg( 'history' ), 'action=history' );
1190 function whatLinksHere() {
1193 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1194 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1197 function userContribsLink() {
1200 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1201 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1204 function showEmailUser( $id ) {
1205 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1206 return $wgEnableEmail &&
1207 $wgEnableUserEmail &&
1208 $wgUser->isLoggedIn() && # show only to signed in users
1209 0 != $id; # we can only email to non-anons ..
1210 # '' != $id->getEmail() && # who must have an email address stored ..
1211 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1212 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1215 function emailUserLink() {
1218 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1219 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1222 function watchPageLinksLink() {
1223 global $wgOut, $wgTitle;
1225 if ( ! $wgOut->isArticleRelated() ) {
1226 return '(' . wfMsg( 'notanarticle' ) . ')';
1228 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1229 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1230 'target=' . $wgTitle->getPrefixedURL() );
1234 function trackbackLink() {
1237 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1238 . wfMsg('trackbacklink') . "</a>";
1241 function otherLanguages() {
1242 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1244 if ( $wgHideInterlanguageLinks ) {
1248 $a = $wgOut->getLanguageLinks();
1249 if ( 0 == count( $a ) ) {
1253 $s = wfMsg( 'otherlanguages' ) . ': ';
1255 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1256 foreach( $a as $l ) {
1257 if ( ! $first ) { $s .= ' | '; }
1260 $nt = Title
::newFromText( $l );
1261 $url = $nt->escapeFullURL();
1262 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1264 if ( '' == $text ) { $text = $l; }
1265 $style = $this->getExternalLinkAttributes( $l, $text );
1266 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1268 if($wgContLang->isRTL()) $s .= '</span>';
1272 function bugReportsLink() {
1273 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1274 wfMsg( 'bugreports' ) );
1278 function dateLink() {
1279 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1280 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1282 $id = $t1->getArticleID();
1285 $s = $this->makeBrokenLink( $t1->getText() );
1287 $s = $this->makeKnownLink( $t1->getText() );
1291 $id = $t2->getArticleID();
1294 $s .= $this->makeBrokenLink( $t2->getText() );
1296 $s .= $this->makeKnownLink( $t2->getText() );
1301 function talkLink() {
1304 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1305 # No discussion links for special pages
1309 if( $wgTitle->isTalkPage() ) {
1310 $link = $wgTitle->getSubjectPage();
1311 switch( $link->getNamespace() ) {
1313 $text = wfMsg('articlepage');
1316 $text = wfMsg('userpage');
1319 $text = wfMsg('wikipediapage');
1322 $text = wfMsg('imagepage');
1325 $text= wfMsg('articlepage');
1328 $link = $wgTitle->getTalkPage();
1329 $text = wfMsg( 'talkpage' );
1332 $s = $this->makeLinkObj( $link, $text );
1337 function commentLink() {
1338 global $wgContLang, $wgTitle;
1340 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1343 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1344 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1347 /* these are used extensively in SkinPHPTal, but also some other places */
1348 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1349 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1350 return $title->getLocalURL( $urlaction );
1353 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1354 $title = Title
::newFromText( wfMsgForContent($name) );
1355 $this->checkTitle($title, $name);
1356 return $title->getLocalURL( $urlaction );
1359 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1360 $title = Title
::newFromText( $name );
1361 $this->checkTitle($title, $name);
1362 return $title->getLocalURL( $urlaction );
1365 # If url string starts with http, consider as external URL, else
1367 /*static*/ function makeInternalOrExternalUrl( $name ) {
1368 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1371 return $this->makeUrl( $name );
1375 # this can be passed the NS number as defined in Language.php
1376 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1377 $title = Title
::makeTitleSafe( $namespace, $name );
1378 $this->checkTitle($title, $name);
1379 return $title->getLocalURL( $urlaction );
1382 /* these return an array with the 'href' and boolean 'exists' */
1383 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1384 $title = Title
::newFromText( $name );
1385 $this->checkTitle($title, $name);
1387 'href' => $title->getLocalURL( $urlaction ),
1388 'exists' => $title->getArticleID() != 0?
true:false
1393 * Make URL details where the article exists (or at least it's convenient to think so)
1395 function makeKnownUrlDetails( $name, $urlaction='' ) {
1396 $title = Title
::newFromText( $name );
1397 $this->checkTitle($title, $name);
1399 'href' => $title->getLocalURL( $urlaction ),
1404 # make sure we have some title to operate on
1405 /*static*/ function checkTitle ( &$title, &$name ) {
1406 if(!is_object($title)) {
1407 $title = Title
::newFromText( $name );
1408 if(!is_object($title)) {
1409 $title = Title
::newFromText( '--error: link target missing--' );
1415 * Build an array that represents the sidebar(s), the navigation bar among them
1420 function buildSidebar() {
1421 global $wgTitle, $action;
1423 $fname = 'SkinTemplate::buildSidebar';
1424 $pageurl = $wgTitle->getLocalURL();
1425 wfProfileIn( $fname );
1428 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1429 foreach ($lines as $line) {
1430 if (strpos($line, '*') !== 0)
1432 if (strpos($line, '**') !== 0) {
1433 $line = trim($line, '* ');
1436 if (strpos($line, '|') !== false) { // sanity check
1437 $line = explode( '|' , trim($line, '* '), 2 );
1438 $link = wfMsgForContent( $line[0] );
1441 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1443 if (wfEmptyMsg($line[0], $link))
1445 $href = $this->makeInternalOrExternalUrl( $link );
1446 $bar[$heading][] = array(
1449 'id' => 'n-' . strtr($line[1], ' ', '-'),
1450 'active' => $pageurl == $href
1452 } else { continue; }
1456 wfProfileOut( $fname );