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() );
253 $out->out( $out->reportTime() );
255 $out->out( "\n</body></html>" );
258 function getHeadScripts() {
259 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType;
260 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
261 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
262 $userpage = $wgUser->getUserPage();
263 $userjs = htmlspecialchars( $this->makeUrl(
264 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
265 'action=raw&ctype='.$wgJsMimeType));
266 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
272 * To make it harder for someone to slip a user a fake
273 * user-JavaScript or user-CSS preview, a random token
274 * is associated with the login session. If it's not
275 * passed back with the preview request, we won't render
278 * @param string $action
282 function userCanPreview( $action ) {
283 global $wgTitle, $wgRequest, $wgUser;
285 if( $action != 'submit' )
287 if( !$wgRequest->wasPosted() )
289 if( !$wgTitle->userCanEditCssJsSubpage() )
291 return $wgUser->matchEditToken(
292 $wgRequest->getVal( 'wpEditToken' ) );
295 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
296 function getUserStylesheet() {
297 global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
298 $sheet = $this->getStylesheet();
299 $action = $wgRequest->getText('action');
300 $s = "@import \"$wgStylePath/$sheet\";\n";
301 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
303 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
304 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
305 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
307 $s .= $this->doGetUserStyles();
312 * placeholder, returns generated js in monobook
314 function getUserJs() { return; }
317 * Return html code that include User stylesheets
319 function getUserStyles() {
320 global $wgOut, $wgStylePath;
321 $s = "<style type='text/css'>\n";
322 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
323 $s .= $this->getUserStylesheet();
324 $s .= "/*]]>*/ /* */\n";
330 * Some styles that are set by user through the user settings interface.
332 function doGetUserStyles() {
333 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
337 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
338 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
339 $s .= $wgRequest->getText('wpTextbox1');
341 $userpage = $wgUser->getUserPage();
342 $s.= '@import "'.$this->makeUrl(
343 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
344 'action=raw&ctype=text/css').'";'."\n";
348 return $s . $this->reallyDoGetUserStyles();
351 function reallyDoGetUserStyles() {
354 if (($undopt = $wgUser->getOption("underline")) != 2) {
355 $underline = $undopt ?
'underline' : 'none';
356 $s .= "a { text-decoration: $underline; }\n";
358 if( $wgUser->getOption( 'highlightbroken' ) ) {
359 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
362 a.new, #quickbar a.new,
363 a.stub, #quickbar a.stub {
365 text-decoration: inherit;
367 a.new:after, #quickbar a.new:after {
370 text-decoration: $underline;
372 a.stub:after, #quickbar a.stub:after {
375 text-decoration: $underline;
379 if( $wgUser->getOption( 'justify' ) ) {
380 $s .= "#article, #bodyContent { text-align: justify; }\n";
382 if( !$wgUser->getOption( 'showtoc' ) ) {
383 $s .= "#toc { display: none; }\n";
385 if( !$wgUser->getOption( 'editsection' ) ) {
386 $s .= ".editsection { display: none; }\n";
391 function getBodyOptions() {
392 global $wgUser, $wgTitle, $wgOut, $wgRequest;
394 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
396 if ( 0 != $wgTitle->getNamespace() ) {
397 $a = array( 'bgcolor' => '#ffffec' );
399 else $a = array( 'bgcolor' => '#FFFFFF' );
400 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
401 $wgTitle->userCanEdit() ) {
402 $t = wfMsg( 'editthispage' );
403 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
404 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
405 $a +
= array ('ondblclick' => $s);
408 $a['onload'] = $wgOut->getOnloadHandler();
409 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
410 if( $a['onload'] != '' ) {
413 $a['onload'] .= 'setupRightClickEdit()';
427 * This will be called immediately after the <body> tag. Split into
428 * two functions to make it easier to subclass.
430 function beforeContent() {
431 return $this->doBeforeContent();
434 function doBeforeContent() {
435 global $wgOut, $wgTitle, $wgContLang;
436 $fname = 'Skin::doBeforeContent';
437 wfProfileIn( $fname );
440 $qb = $this->qbSetting();
442 if( $langlinks = $this->otherLanguages() ) {
448 $borderhack = 'class="top"';
451 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
452 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
455 $left = ($qb == 1 ||
$qb == 3);
456 if($wgContLang->isRTL()) $left = !$left;
459 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
460 $this->logoText() . '</td>';
462 $s .= $this->getQuickbarCompensator( $rows );
464 $l = $wgContLang->isRTL() ?
'right' : 'left';
465 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
467 $s .= $this->topLinks() ;
468 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
470 $r = $wgContLang->isRTL() ?
"left" : "right";
471 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
472 $s .= $this->nameAndLogin();
473 $s .= "\n<br />" . $this->searchForm() . "</td>";
476 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
479 if ( $shove && !$left ) { # Right
480 $s .= $this->getQuickbarCompensator( $rows );
482 $s .= "</tr>\n</table>\n</div>\n";
483 $s .= "\n<div id='article'>\n";
485 $notice = wfGetSiteNotice();
487 $s .= "\n<div id='siteNotice'>$notice</div>\n";
489 $s .= $this->pageTitle();
490 $s .= $this->pageSubtitle() ;
491 $s .= $this->getCategories();
492 wfProfileOut( $fname );
497 function getCategoryLinks () {
498 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
501 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
503 // Use Unicode bidi embedding override characters,
504 // to make sure links don't smash each other up in ugly ways.
505 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
506 $embed = "<span dir='$dir'>";
508 $t = $embed . implode ( "$pop | $embed" , $wgOut->mCategoryLinks
) . $pop;
510 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
511 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
512 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
515 # optional 'dmoz-like' category browser. Will be shown under the list
516 # of categories an article belong to
517 if($wgUseCategoryBrowser) {
518 $s .= '<br /><hr />';
520 # get a big array of the parents tree
521 $parenttree = $wgTitle->getParentCategoryTree();
522 # Skin object passed by reference cause it can not be
523 # accessed under the method subfunction drawCategoryBrowser
524 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
525 # Clean out bogus first entry and sort them
528 # Output one per line
529 $s .= implode("<br />\n", $tempout);
535 /** Render the array as a serie of links.
536 * @param array $tree Categories tree returned by Title::getParentCategoryTree
537 * @param object &skin Skin passed by reference
538 * @return string separated by >, terminate with "\n"
540 function drawCategoryBrowser($tree, &$skin) {
542 foreach ($tree as $element => $parent) {
543 if (empty($parent)) {
544 # element start a new list
547 # grab the others elements
548 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
550 # add our current element to the list
551 $eltitle = Title
::NewFromText($element);
552 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
557 function getCategories() {
558 $catlinks=$this->getCategoryLinks();
559 if(!empty($catlinks)) {
560 return "<p class='catlinks'>{$catlinks}</p>";
564 function getQuickbarCompensator( $rows = 1 ) {
565 return "<td width='152' rowspan='{$rows}'> </td>";
569 * This gets called immediately before the </body> tag.
570 * @return string HTML to be put after </body> ???
572 function afterContent() {
573 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
574 return $printfooter . $this->doAfterContent();
577 /** @return string Retrievied from HTML text */
578 function printSource() {
580 $url = htmlspecialchars( $wgTitle->getFullURL() );
581 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
584 function printFooter() {
585 return "<p>" . $this->printSource() .
586 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
589 /** overloaded by derived classes */
590 function doAfterContent() { }
592 function pageTitleLinks() {
593 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
595 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
596 $action = $wgRequest->getText( 'action' );
598 $s = $this->printableLink();
599 $disclaimer = $this->disclaimerLink(); # may be empty
601 $s .= ' | ' . $disclaimer;
603 $privacy = $this->privacyLink(); # may be empty too
605 $s .= ' | ' . $privacy;
608 if ( $wgOut->isArticleRelated() ) {
609 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
610 $name = $wgTitle->getDBkey();
611 $image = new Image( $wgTitle );
612 if( $image->exists() ) {
613 $link = htmlspecialchars( $image->getURL() );
614 $style = $this->getInternalLinkAttributes( $link, $name );
615 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
619 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
620 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
621 wfMsg( 'currentrev' ) );
624 if ( $wgUser->getNewtalk() ) {
625 # do not show "You have new messages" text when we are viewing our
627 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
628 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ) );
629 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
630 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
632 $wgOut->setSquidMaxage(0);
633 $wgOut->enableClientCache(false);
637 $undelete = $this->getUndeleteLink();
638 if( !empty( $undelete ) ) {
639 $s .= ' | '.$undelete;
644 function getUndeleteLink() {
645 global $wgUser, $wgTitle, $wgContLang, $action;
646 if( $wgUser->isAllowed( 'deletedhistory' ) &&
647 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
648 ($n = $wgTitle->isDeleted() ) )
650 if ( $wgUser->isAllowed( 'delete' ) ) {
651 $msg = 'thisisdeleted';
653 $msg = 'viewdeleted';
656 $this->makeKnownLink(
657 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
658 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
663 function printableLink() {
664 global $wgOut, $wgFeedClasses, $wgRequest;
666 $baseurl = $_SERVER['REQUEST_URI'];
667 if( strpos( '?', $baseurl ) == false ) {
672 $baseurl = htmlspecialchars( $baseurl );
673 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
675 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
676 if( $wgOut->isSyndicated() ) {
677 foreach( $wgFeedClasses as $format => $class ) {
678 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
679 $s .= " | <a href=\"$feedurl\">{$format}</a>";
685 function pageTitle() {
686 global $wgOut, $wgTitle, $wgUser;
688 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
692 function pageSubtitle() {
695 $sub = $wgOut->getSubtitle();
697 global $wgExtraSubtitle;
698 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
700 $subpages = $this->subPageSubtitle();
701 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
702 $s = "<p class='subtitle'>{$sub}</p>\n";
706 function subPageSubtitle() {
707 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
709 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
710 $ptext=$wgTitle->getPrefixedText();
711 if(preg_match('/\//',$ptext)) {
712 $links = explode('/',$ptext);
715 foreach($links as $link) {
717 if ($c<count($links)) {
718 $growinglink .= $link;
719 $getlink = $this->makeLink( $growinglink, $link );
720 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
724 $subpages .= '< ';
726 $subpages .= $getlink;
735 function nameAndLogin() {
736 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
738 $li = $wgContLang->specialPage( 'Userlogin' );
739 $lo = $wgContLang->specialPage( 'Userlogout' );
742 if ( $wgUser->isAnon() ) {
743 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
746 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
747 $wgLang->getNsText( NS_TALK
) );
749 $s .= $n . ' ('.$tl.')';
751 $s .= wfMsg('notloggedin');
754 $rt = $wgTitle->getPrefixedURL();
755 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
757 } else { $q = "returnto={$rt}"; }
759 $s .= "\n<br />" . $this->makeKnownLinkObj(
760 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
761 wfMsg( 'login' ), $q );
763 $n = $wgUser->getName();
764 $rt = $wgTitle->getPrefixedURL();
765 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
766 $wgLang->getNsText( NS_TALK
) );
770 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
771 $n ) . "{$tl}<br />" .
772 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
773 "returnto={$rt}" ) . ' | ' .
774 $this->specialLink( 'preferences' );
776 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
782 function getSearchLink() {
783 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
784 return $searchPage->getLocalURL();
787 function escapeSearchLink() {
788 return htmlspecialchars( $this->getSearchLink() );
791 function searchForm() {
793 $search = $wgRequest->getText( 'search' );
795 $s = '<form name="search" class="inline" method="post" action="'
796 . $this->escapeSearchLink() . "\">\n"
797 . '<input type="text" name="search" size="19" value="'
798 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
799 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
800 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
805 function topLinks() {
809 $s = $this->mainPageLink() . $sep
810 . $this->specialLink( 'recentchanges' );
812 if ( $wgOut->isArticleRelated() ) {
813 $s .= $sep . $this->editThisPage()
814 . $sep . $this->historyLink();
816 # Many people don't like this dropdown box
817 #$s .= $sep . $this->specialPagesList();
819 /* show links to different language variants */
820 global $wgDisableLangConversion, $wgContLang, $wgTitle;
821 $variants = $wgContLang->getVariants();
822 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
823 foreach( $variants as $code ) {
824 $varname = $wgContLang->getVariantname( $code );
825 if( $varname == 'disable' )
827 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
834 function bottomLinks() {
835 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
839 if ( $wgOut->isArticleRelated() ) {
840 $s .= '<strong>' . $this->editThisPage() . '</strong>';
841 if ( $wgUser->isLoggedIn() ) {
842 $s .= $sep . $this->watchThisPage();
844 $s .= $sep . $this->talkLink()
845 . $sep . $this->historyLink()
846 . $sep . $this->whatLinksHere()
847 . $sep . $this->watchPageLinksLink();
849 if ($wgUseTrackbacks)
850 $s .= $sep . $this->trackbackLink();
852 if ( $wgTitle->getNamespace() == NS_USER
853 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
856 $id=User
::idFromName($wgTitle->getText());
857 $ip=User
::isIP($wgTitle->getText());
859 if($id ||
$ip) { # both anons and non-anons have contri list
860 $s .= $sep . $this->userContribsLink();
862 if( $this->showEmailUser( $id ) ) {
863 $s .= $sep . $this->emailUserLink();
866 if ( $wgTitle->getArticleId() ) {
868 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
869 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
870 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
872 $s .= "<br />\n" . $this->otherLanguages();
877 function pageStats() {
878 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
879 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
881 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
882 if ( ! $wgOut->isArticle() ) { return ''; }
883 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
884 if ( 0 == $wgArticle->getID() ) { return ''; }
887 if ( !$wgDisableCounters ) {
888 $count = $wgLang->formatNum( $wgArticle->getCount() );
890 $s = wfMsg( 'viewcount', $count );
894 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
895 require_once('Credits.php');
896 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
898 $s .= $this->lastModified();
901 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
902 $dbr =& wfGetDB( DB_SLAVE
);
903 extract( $dbr->tableNames( 'watchlist' ) );
904 $sql = "SELECT COUNT(*) AS n FROM $watchlist
905 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
906 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
907 $res = $dbr->query( $sql, 'Skin::pageStats');
908 $x = $dbr->fetchObject( $res );
909 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
912 return $s . ' ' . $this->getCopyright();
915 function getCopyright() {
916 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
919 $oldid = $wgRequest->getVal( 'oldid' );
920 $diff = $wgRequest->getVal( 'diff' );
922 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
923 $msg = 'history_copyright';
929 if( $wgRightsPage ) {
930 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
931 } elseif( $wgRightsUrl ) {
932 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
937 $out .= wfMsgForContent( $msg, $link );
941 function getCopyrightIcon() {
942 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
944 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
945 $out = $wgCopyrightIcon;
946 } else if ( $wgRightsIcon ) {
947 $icon = htmlspecialchars( $wgRightsIcon );
948 if ( $wgRightsUrl ) {
949 $url = htmlspecialchars( $wgRightsUrl );
950 $out .= '<a href="'.$url.'">';
952 $text = htmlspecialchars( $wgRightsText );
953 $out .= "<img src=\"$icon\" alt='$text' />";
954 if ( $wgRightsUrl ) {
961 function getPoweredBy() {
963 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
964 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
968 function lastModified() {
969 global $wgLang, $wgArticle, $wgLoadBalancer;
971 $timestamp = $wgArticle->getTimestamp();
973 $d = $wgLang->timeanddate( $timestamp, true );
974 $s = ' ' . wfMsg( 'lastmodified', $d );
978 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
979 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
984 function logoText( $align = '' ) {
985 if ( '' != $align ) { $a = " align='{$align}'"; }
988 $mp = wfMsg( 'mainpage' );
989 $titleObj = Title
::newFromText( $mp );
990 if ( is_object( $titleObj ) ) {
991 $url = $titleObj->escapeLocalURL();
996 $logourl = $this->getLogo();
997 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1002 * show a drop-down box of special pages
1003 * @TODO crash bug913. Need to be rewrote completly.
1005 function specialPagesList() {
1006 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
1007 require_once('SpecialPage.php');
1009 $pages = SpecialPage
::getPages();
1011 // special pages without access restriction
1012 foreach ( $pages[''] as $name => $page ) {
1013 $a[$name] = $page->getDescription();
1016 // Other special pages that are restricted.
1017 // Copied from SpecialSpecialpages.php
1018 foreach($wgAvailableRights as $right) {
1019 if( $wgUser->isAllowed($right) ) {
1020 /** Add all pages for this right */
1021 if(isset($pages[$right])) {
1022 foreach($pages[$right] as $name => $page) {
1023 $a[$name] = $page->getDescription();
1029 $go = wfMsg( 'go' );
1030 $sp = wfMsg( 'specialpages' );
1031 $spp = $wgContLang->specialPage( 'Specialpages' );
1033 $s = '<form id="specialpages" method="get" class="inline" ' .
1034 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1035 $s .= "<select name=\"wpDropdown\">\n";
1036 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1039 foreach ( $a as $name => $desc ) {
1040 $p = $wgContLang->specialPage( $name );
1041 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1043 $s .= "</select>\n";
1044 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1049 function mainPageLink() {
1050 $mp = wfMsgForContent( 'mainpage' );
1051 $mptxt = wfMsg( 'mainpage');
1052 $s = $this->makeKnownLink( $mp, $mptxt );
1056 function copyrightLink() {
1057 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1058 wfMsg( 'copyrightpagename' ) );
1062 function privacyLink() {
1063 $privacy = wfMsg( 'privacy' );
1064 if ($privacy == '-') {
1067 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1071 function aboutLink() {
1072 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1073 wfMsg( 'aboutsite' ) );
1077 function disclaimerLink() {
1078 $disclaimers = wfMsg( 'disclaimers' );
1079 if ($disclaimers == '-') {
1082 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1087 function editThisPage() {
1088 global $wgOut, $wgTitle, $wgRequest;
1090 if ( ! $wgOut->isArticleRelated() ) {
1091 $s = wfMsg( 'protectedpage' );
1093 if ( $wgTitle->userCanEdit() ) {
1094 $t = wfMsg( 'editthispage' );
1096 $t = wfMsg( 'viewsource' );
1099 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1105 * Return URL options for the 'edit page' link.
1106 * This may include an 'oldid' specifier, if the current page view is such.
1111 function editUrlOptions() {
1114 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1115 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1117 return "action=edit";
1121 function deleteThisPage() {
1122 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1124 $diff = $wgRequest->getVal( 'diff' );
1125 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1126 $t = wfMsg( 'deletethispage' );
1128 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1135 function protectThisPage() {
1136 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1138 $diff = $wgRequest->getVal( 'diff' );
1139 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1140 if ( $wgTitle->isProtected() ) {
1141 $t = wfMsg( 'unprotectthispage' );
1142 $q = 'action=unprotect';
1144 $t = wfMsg( 'protectthispage' );
1145 $q = 'action=protect';
1147 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1154 function watchThisPage() {
1155 global $wgUser, $wgOut, $wgTitle;
1157 if ( $wgOut->isArticleRelated() ) {
1158 if ( $wgTitle->userIsWatching() ) {
1159 $t = wfMsg( 'unwatchthispage' );
1160 $q = 'action=unwatch';
1162 $t = wfMsg( 'watchthispage' );
1163 $q = 'action=watch';
1165 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1167 $s = wfMsg( 'notanarticle' );
1172 function moveThisPage() {
1175 if ( $wgTitle->userCanMove() ) {
1176 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1177 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1179 // no message if page is protected - would be redundant
1184 function historyLink() {
1187 return $this->makeKnownLinkObj( $wgTitle,
1188 wfMsg( 'history' ), 'action=history' );
1191 function whatLinksHere() {
1194 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1195 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1198 function userContribsLink() {
1201 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1202 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1205 function showEmailUser( $id ) {
1206 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1207 return $wgEnableEmail &&
1208 $wgEnableUserEmail &&
1209 $wgUser->isLoggedIn() && # show only to signed in users
1210 0 != $id; # we can only email to non-anons ..
1211 # '' != $id->getEmail() && # who must have an email address stored ..
1212 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1213 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1216 function emailUserLink() {
1219 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1220 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1223 function watchPageLinksLink() {
1224 global $wgOut, $wgTitle;
1226 if ( ! $wgOut->isArticleRelated() ) {
1227 return '(' . wfMsg( 'notanarticle' ) . ')';
1229 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1230 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1231 'target=' . $wgTitle->getPrefixedURL() );
1235 function trackbackLink() {
1238 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1239 . wfMsg('trackbacklink') . "</a>";
1242 function otherLanguages() {
1243 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1245 if ( $wgHideInterlanguageLinks ) {
1249 $a = $wgOut->getLanguageLinks();
1250 if ( 0 == count( $a ) ) {
1254 $s = wfMsg( 'otherlanguages' ) . ': ';
1256 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1257 foreach( $a as $l ) {
1258 if ( ! $first ) { $s .= ' | '; }
1261 $nt = Title
::newFromText( $l );
1262 $url = $nt->escapeFullURL();
1263 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1265 if ( '' == $text ) { $text = $l; }
1266 $style = $this->getExternalLinkAttributes( $l, $text );
1267 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1269 if($wgContLang->isRTL()) $s .= '</span>';
1273 function bugReportsLink() {
1274 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1275 wfMsg( 'bugreports' ) );
1279 function dateLink() {
1280 global $wgLinkCache;
1281 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1282 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1284 $wgLinkCache->suspend();
1285 $id = $t1->getArticleID();
1286 $wgLinkCache->resume();
1289 $s = $this->makeBrokenLink( $t1->getText() );
1291 $s = $this->makeKnownLink( $t1->getText() );
1295 $wgLinkCache->suspend();
1296 $id = $t2->getArticleID();
1297 $wgLinkCache->resume();
1300 $s .= $this->makeBrokenLink( $t2->getText() );
1302 $s .= $this->makeKnownLink( $t2->getText() );
1307 function talkLink() {
1308 global $wgTitle, $wgLinkCache;
1310 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1311 # No discussion links for special pages
1315 if( $wgTitle->isTalkPage() ) {
1316 $link = $wgTitle->getSubjectPage();
1317 switch( $link->getNamespace() ) {
1319 $text = wfMsg('articlepage');
1322 $text = wfMsg('userpage');
1325 $text = wfMsg('wikipediapage');
1328 $text = wfMsg('imagepage');
1331 $text= wfMsg('articlepage');
1334 $link = $wgTitle->getTalkPage();
1335 $text = wfMsg( 'talkpage' );
1338 $wgLinkCache->suspend();
1339 $s = $this->makeLinkObj( $link, $text );
1340 $wgLinkCache->resume();
1345 function commentLink() {
1346 global $wgContLang, $wgTitle, $wgLinkCache;
1348 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1351 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1352 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1355 /* these are used extensively in SkinPHPTal, but also some other places */
1356 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1357 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1358 return $title->getLocalURL( $urlaction );
1361 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1362 $title = Title
::newFromText( wfMsgForContent($name) );
1363 $this->checkTitle($title, $name);
1364 return $title->getLocalURL( $urlaction );
1367 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1368 $title = Title
::newFromText( $name );
1369 $this->checkTitle($title, $name);
1370 return $title->getLocalURL( $urlaction );
1373 # If url string starts with http, consider as external URL, else
1375 /*static*/ function makeInternalOrExternalUrl( $name ) {
1376 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1379 return $this->makeUrl( $name );
1383 # this can be passed the NS number as defined in Language.php
1384 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1385 $title = Title
::makeTitleSafe( $namespace, $name );
1386 $this->checkTitle($title, $name);
1387 return $title->getLocalURL( $urlaction );
1390 /* these return an array with the 'href' and boolean 'exists' */
1391 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1392 $title = Title
::newFromText( $name );
1393 $this->checkTitle($title, $name);
1395 'href' => $title->getLocalURL( $urlaction ),
1396 'exists' => $title->getArticleID() != 0?
true:false
1401 * Make URL details where the article exists (or at least it's convenient to think so)
1403 function makeKnownUrlDetails( $name, $urlaction='' ) {
1404 $title = Title
::newFromText( $name );
1405 $this->checkTitle($title, $name);
1407 'href' => $title->getLocalURL( $urlaction ),
1412 # make sure we have some title to operate on
1413 /*static*/ function checkTitle ( &$title, &$name ) {
1414 if(!is_object($title)) {
1415 $title = Title
::newFromText( $name );
1416 if(!is_object($title)) {
1417 $title = Title
::newFromText( '--error: link target missing--' );
1423 * Build an array that represents the sidebar(s), the navigation bar among them
1428 function buildSidebar() {
1429 global $wgTitle, $action;
1431 $fname = 'SkinTemplate::buildSidebar';
1432 $pageurl = $wgTitle->getLocalURL();
1433 wfProfileIn( $fname );
1436 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1437 foreach ($lines as $line) {
1438 if (strpos($line, '*') !== 0)
1440 if (strpos($line, '**') !== 0) {
1441 $line = trim($line, '* ');
1444 if (strpos($line, '|') !== false) { // sanity check
1445 $line = explode( '|' , trim($line, '* '), 2 );
1446 $link = wfMsgForContent( $line[0] );
1449 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1451 if (wfEmptyMsg($line[0], $link))
1453 $href = $this->makeInternalOrExternalUrl( $link );
1454 $bar[$heading][] = array(
1457 'id' => 'n-' . strtr($line[1], ' ', '-'),
1458 'active' => $pageurl == $href
1460 } else { continue; }
1464 wfProfileOut( $fname );