65b16d31dcdc4c1fcd687996e8fb685091507a74
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(); }
76 function getSkinNames() {
77 global $wgValidSkinNames;
78 return $wgValidSkinNames;
81 /** @return string path to the skin stylesheet */
82 function getStylesheet() { return 'common/wikistandard.css'; }
84 /** @return string skin name */
85 function getSkinName() {
89 function qbSetting() {
90 global $wgOut, $wgUser;
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
104 $this->addMetadataLinks($out);
106 wfProfileOut( $fname );
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl;
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
129 if( $wgRightsPage ) {
130 $copy = Title
::newFromText( $wgRightsPage );
132 $copyright = $copy->getLocalURL();
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
145 function outputPage( &$out ) {
146 global $wgDebugComments;
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
150 $out->out( $out->headElement() );
152 $out->out( "\n<body" );
153 $ops = $this->getBodyOptions();
154 foreach ( $ops as $name => $val ) {
155 $out->out( " $name='$val'" );
158 if ( $wgDebugComments ) {
159 $out->out( "<!-- Wiki debugging output:\n" .
160 $out->mDebugtext
. "-->\n" );
162 $out->out( $this->beforeContent() );
164 $out->out( $out->mBodytext
. "\n" );
166 $out->out( $this->afterContent() );
169 $out->out( $out->reportTime() );
171 $out->out( "\n</body></html>" );
174 function getHeadScripts() {
175 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
176 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
177 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
178 $userpage = $wgUser->getUserPage();
179 $userjs = htmlspecialchars( $this->makeUrl(
180 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
181 'action=raw&ctype='.$wgJsMimeType));
182 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
188 * To make it harder for someone to slip a user a fake
189 * user-JavaScript or user-CSS preview, a random token
190 * is associated with the login session. If it's not
191 * passed back with the preview request, we won't render
194 * @param string $action
198 function userCanPreview( $action ) {
199 global $wgTitle, $wgRequest, $wgUser;
201 if( $action != 'submit' )
203 if( !$wgRequest->wasPosted() )
205 if( !$wgTitle->userCanEditCssJsSubpage() )
207 return $wgUser->matchEditToken(
208 $wgRequest->getVal( 'wpEditToken' ) );
211 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
212 function getUserStylesheet() {
213 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
214 $sheet = $this->getStylesheet();
215 $action = $wgRequest->getText('action');
216 $s = "@import \"$wgStylePath/$sheet\";\n";
217 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
218 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
219 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
220 $s .= $wgRequest->getText('wpTextbox1');
222 $userpage = $wgUser->getUserPage();
223 $s.= '@import "'.$this->makeUrl(
224 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
225 'action=raw&ctype=text/css').'";'."\n";
228 $s .= $this->doGetUserStyles();
233 * placeholder, returns generated js in monobook
235 function getUserJs() { return; }
238 * Return html code that include User stylesheets
240 function getUserStyles() {
241 global $wgOut, $wgStylePath, $wgLang;
242 $s = "<style type='text/css'>\n";
243 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
244 $s .= $this->getUserStylesheet();
245 $s .= "/*]]>*/ /* */\n";
251 * Some styles that are set by user through the user settings interface.
253 function doGetUserStyles() {
254 global $wgUser, $wgContLang;
256 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
257 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
259 return $s . $this->reallyDoGetUserStyles();
262 function reallyDoGetUserStyles() {
265 $underline = $wgUser->getOption( "underline" ) ?
'underline' : 'none';
266 $s .= "a { text-decoration: $underline; }\n";
267 if( $wgUser->getOption( 'highlightbroken' ) ) {
268 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
271 a.new, #quickbar a.new,
272 a.stub, #quickbar a.stub {
274 text-decoration: inherit;
276 a.new:after, #quickbar a.new:after {
279 text-decoration: $underline;
281 a.stub:after, #quickbar a.stub:after {
284 text-decoration: $underline;
288 if( $wgUser->getOption( 'justify' ) ) {
289 $s .= "#article, #bodyContent { text-align: justify; }\n";
291 if( !$wgUser->getOption( 'showtoc' ) ) {
292 $s .= "#toc { display: none; }\n";
297 function getBodyOptions() {
298 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
300 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
302 if ( 0 != $wgTitle->getNamespace() ) {
303 $a = array( 'bgcolor' => '#ffffec' );
305 else $a = array( 'bgcolor' => '#FFFFFF' );
306 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
307 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
308 $t = wfMsg( 'editthispage' );
310 if ( !empty($redirect) && $redirect == 'no' ) {
311 $red = "&redirect={$redirect}";
313 if ( !empty($oldid) && ! isset( $diff ) ) {
314 $oid = "&oldid=" . IntVal( $oldid );
316 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
317 $s = 'document.location = "' .$s .'";';
318 $a +
= array ('ondblclick' => $s);
321 $a['onload'] = $wgOut->getOnloadHandler();
322 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
323 if( $a['onload'] != '' ) {
326 $a['onload'] .= 'setupRightClickEdit()';
340 * This will be called immediately after the <body> tag. Split into
341 * two functions to make it easier to subclass.
343 function beforeContent() {
344 return $this->doBeforeContent();
347 function doBeforeContent() {
348 global $wgOut, $wgTitle, $wgContLang;
349 $fname = 'Skin::doBeforeContent';
350 wfProfileIn( $fname );
353 $qb = $this->qbSetting();
355 if( $langlinks = $this->otherLanguages() ) {
361 $borderhack = 'class="top"';
364 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
365 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
368 $left = ($qb == 1 ||
$qb == 3);
369 if($wgContLang->isRTL()) $left = !$left;
372 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
373 $this->logoText() . '</td>';
375 $s .= $this->getQuickbarCompensator( $rows );
377 $l = $wgContLang->isRTL() ?
'right' : 'left';
378 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
380 $s .= $this->topLinks() ;
381 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
383 $r = $wgContLang->isRTL() ?
"left" : "right";
384 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
385 $s .= $this->nameAndLogin();
386 $s .= "\n<br />" . $this->searchForm() . "</td>";
389 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
392 if ( $shove && !$left ) { # Right
393 $s .= $this->getQuickbarCompensator( $rows );
395 $s .= "</tr>\n</table>\n</div>\n";
396 $s .= "\n<div id='article'>\n";
398 $notice = wfGetSiteNotice();
400 $s .= "\n<div id='siteNotice'>$notice</div>\n";
402 $s .= $this->pageTitle();
403 $s .= $this->pageSubtitle() ;
404 $s .= $this->getCategories();
405 wfProfileOut( $fname );
410 function getCategoryLinks () {
411 global $wgOut, $wgTitle, $wgParser;
412 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
414 if( !$wgUseCategoryMagic ) return '' ;
415 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
417 # Taken out so that they will be displayed in previews -- TS
418 #if( !$wgOut->isArticle() ) return '';
420 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
421 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
422 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
425 # optional 'dmoz-like' category browser. Will be shown under the list
426 # of categories an article belong to
427 if($wgUseCategoryBrowser) {
428 $s .= '<br /><hr />';
430 # get a big array of the parents tree
431 $parenttree = $wgTitle->getParentCategoryTree();
433 # Skin object passed by reference cause it can not be
434 # accessed under the method subfunction walkThrough.
435 $s .= Skin
::drawCategoryBrowser($parenttree, $this);
441 # Render the array as a serie of links
442 function drawCategoryBrowser ($tree, &$skin) {
444 foreach ($tree as $element => $parent) {
445 if (empty($parent)) {
446 # element start a new list
449 # grab the others elements
450 $return .= Skin
::drawCategoryBrowser($parent, $skin);
452 # add our current element to the list
453 $eltitle = Title
::NewFromText($element);
454 if (!empty($parent)) $return .= ' > ';
455 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
460 function getCategories() {
461 $catlinks=$this->getCategoryLinks();
462 if(!empty($catlinks)) {
463 return "<p class='catlinks'>{$catlinks}</p>";
467 function getQuickbarCompensator( $rows = 1 ) {
468 return "<td width='152' rowspan='{$rows}'> </td>";
472 * This gets called immediately before the </body> tag.
473 * @return string HTML to be put after </body> ???
475 function afterContent() {
476 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
477 return $printfooter . $this->doAfterContent();
480 /** @return string Retrievied from HTML text */
481 function printSource() {
483 $url = htmlspecialchars( $wgTitle->getFullURL() );
484 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
487 function printFooter() {
488 return "<p>" . $this->printSource() .
489 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
492 /** overloaded by derived classes */
493 function doAfterContent() { }
495 function pageTitleLinks() {
496 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
498 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
499 $action = $wgRequest->getText( 'action' );
501 $s = $this->printableLink();
502 $disclaimer = $this->disclaimerLink(); # may be empty
504 $s .= ' | ' . $disclaimer;
507 if ( $wgOut->isArticleRelated() ) {
508 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
509 $name = $wgTitle->getDBkey();
510 $image = new Image( $wgTitle );
511 if( $image->exists() ) {
512 $link = htmlspecialchars( $image->getURL() );
513 $style = $this->getInternalLinkAttributes( $link, $name );
514 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
517 # This will show the "Approve" link if $wgUseApproval=true;
518 if ( isset ( $wgUseApproval ) && $wgUseApproval )
520 $t = $wgTitle->getDBkey();
521 $name = 'Approve this article' ;
522 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
523 #htmlspecialchars( wfImageUrl( $name ) );
524 $style = $this->getExternalLinkAttributes( $link, $name );
525 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
528 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
529 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
530 wfMsg( 'currentrev' ) );
533 if ( $wgUser->getNewtalk() ) {
534 # do not show "You have new messages" text when we are viewing our
537 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
538 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
539 wfMsg('newmessageslink') );
540 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
542 $wgOut->setSquidMaxage(0);
543 $wgOut->enableClientCache(false);
547 $undelete = $this->getUndeleteLink();
548 if( !empty( $undelete ) ) {
549 $s .= ' | '.$undelete;
554 function getUndeleteLink() {
555 global $wgUser, $wgTitle, $wgContLang, $action;
556 if( $wgUser->isAllowed('rollback') &&
557 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
558 ($n = $wgTitle->isDeleted() ) ) {
559 return wfMsg( 'thisisdeleted',
560 $this->makeKnownLink(
561 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
562 wfMsg( 'restorelink', $n ) ) );
567 function printableLink() {
568 global $wgOut, $wgFeedClasses, $wgRequest;
570 $baseurl = $_SERVER['REQUEST_URI'];
571 if( strpos( '?', $baseurl ) == false ) {
576 $baseurl = htmlspecialchars( $baseurl );
577 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
579 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
580 if( $wgOut->isSyndicated() ) {
581 foreach( $wgFeedClasses as $format => $class ) {
582 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
583 $s .= " | <a href=\"$feedurl\">{$format}</a>";
589 function pageTitle() {
590 global $wgOut, $wgTitle, $wgUser;
592 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
596 function pageSubtitle() {
599 $sub = $wgOut->getSubtitle();
601 global $wgExtraSubtitle;
602 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
604 $subpages = $this->subPageSubtitle();
605 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
606 $s = "<p class='subtitle'>{$sub}</p>\n";
610 function subPageSubtitle() {
611 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
613 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
614 $ptext=$wgTitle->getPrefixedText();
615 if(preg_match('/\//',$ptext)) {
616 $links = explode('/',$ptext);
619 foreach($links as $link) {
621 if ($c<count($links)) {
622 $growinglink .= $link;
623 $getlink = $this->makeLink( $growinglink, $link );
624 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
628 $subpages .= '< ';
630 $subpages .= $getlink;
639 function nameAndLogin() {
640 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
642 $li = $wgContLang->specialPage( 'Userlogin' );
643 $lo = $wgContLang->specialPage( 'Userlogout' );
646 if ( $wgUser->isAnon() ) {
647 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
650 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
651 $wgContLang->getNsText( NS_TALK
) );
653 $s .= $n . ' ('.$tl.')';
655 $s .= wfMsg('notloggedin');
658 $rt = $wgTitle->getPrefixedURL();
659 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
661 } else { $q = "returnto={$rt}"; }
663 $s .= "\n<br />" . $this->makeKnownLinkObj(
664 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
665 wfMsg( 'login' ), $q );
667 $n = $wgUser->getName();
668 $rt = $wgTitle->getPrefixedURL();
669 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
670 $wgContLang->getNsText( NS_TALK
) );
674 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
675 $n ) . "{$tl}<br />" .
676 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
677 "returnto={$rt}" ) . ' | ' .
678 $this->specialLink( 'preferences' );
680 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
686 function getSearchLink() {
687 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
688 return $searchPage->getLocalURL();
691 function escapeSearchLink() {
692 return htmlspecialchars( $this->getSearchLink() );
695 function searchForm() {
697 $search = $wgRequest->getText( 'search' );
699 $s = '<form name="search" class="inline" method="post" action="'
700 . $this->escapeSearchLink() . "\">\n"
701 . '<input type="text" name="search" size="19" value="'
702 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
703 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
704 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
709 function topLinks() {
713 $s = $this->mainPageLink() . $sep
714 . $this->specialLink( 'recentchanges' );
716 if ( $wgOut->isArticleRelated() ) {
717 $s .= $sep . $this->editThisPage()
718 . $sep . $this->historyLink();
720 # Many people don't like this dropdown box
721 #$s .= $sep . $this->specialPagesList();
723 /* show links to different language variants */
724 global $wgDisableLangConversion, $wgContLang, $wgTitle;
725 $variants = $wgContLang->getVariants();
726 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
727 foreach( $variants as $code ) {
728 $varname = $wgContLang->getVariantname( $code );
729 if( $varname == 'disable' )
731 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
738 function bottomLinks() {
739 global $wgOut, $wgUser, $wgTitle;
743 if ( $wgOut->isArticleRelated() ) {
744 $s .= '<strong>' . $this->editThisPage() . '</strong>';
745 if ( $wgUser->isLoggedIn() ) {
746 $s .= $sep . $this->watchThisPage();
748 $s .= $sep . $this->talkLink()
749 . $sep . $this->historyLink()
750 . $sep . $this->whatLinksHere()
751 . $sep . $this->watchPageLinksLink();
753 if ( $wgTitle->getNamespace() == NS_USER
754 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
757 $id=User
::idFromName($wgTitle->getText());
758 $ip=User
::isIP($wgTitle->getText());
760 if($id ||
$ip) { # both anons and non-anons have contri list
761 $s .= $sep . $this->userContribsLink();
763 if( $this->showEmailUser( $id ) ) {
764 $s .= $sep . $this->emailUserLink();
767 if ( $wgTitle->getArticleId() ) {
769 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
770 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
771 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
773 $s .= "<br />\n" . $this->otherLanguages();
778 function pageStats() {
779 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
780 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
782 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
783 if ( ! $wgOut->isArticle() ) { return ''; }
784 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
785 if ( 0 == $wgArticle->getID() ) { return ''; }
788 if ( !$wgDisableCounters ) {
789 $count = $wgLang->formatNum( $wgArticle->getCount() );
791 $s = wfMsg( 'viewcount', $count );
795 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
796 require_once('Credits.php');
797 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
799 $s .= $this->lastModified();
802 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
803 $dbr =& wfGetDB( DB_SLAVE
);
804 extract( $dbr->tableNames( 'watchlist' ) );
805 $sql = "SELECT COUNT(*) AS n FROM $watchlist
806 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
807 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
808 $res = $dbr->query( $sql, 'Skin::pageStats');
809 $x = $dbr->fetchObject( $res );
810 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
813 return $s . ' ' . $this->getCopyright();
816 function getCopyright() {
817 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
820 $oldid = $wgRequest->getVal( 'oldid' );
821 $diff = $wgRequest->getVal( 'diff' );
823 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
824 $msg = 'history_copyright';
830 if( $wgRightsPage ) {
831 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
832 } elseif( $wgRightsUrl ) {
833 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
838 $out .= wfMsgForContent( $msg, $link );
842 function getCopyrightIcon() {
843 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
845 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
846 $out = $wgCopyrightIcon;
847 } else if ( $wgRightsIcon ) {
848 $icon = htmlspecialchars( $wgRightsIcon );
849 if ( $wgRightsUrl ) {
850 $url = htmlspecialchars( $wgRightsUrl );
851 $out .= '<a href="'.$url.'">';
853 $text = htmlspecialchars( $wgRightsText );
854 $out .= "<img src=\"$icon\" alt='$text' />";
855 if ( $wgRightsUrl ) {
862 function getPoweredBy() {
864 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
865 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
869 function lastModified() {
870 global $wgLang, $wgArticle, $wgLoadBalancer;
872 $timestamp = $wgArticle->getTimestamp();
874 $d = $wgLang->timeanddate( $timestamp, true );
875 $s = ' ' . wfMsg( 'lastmodified', $d );
879 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
880 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
885 function logoText( $align = '' ) {
886 if ( '' != $align ) { $a = " align='{$align}'"; }
889 $mp = wfMsg( 'mainpage' );
890 $titleObj = Title
::newFromText( $mp );
891 if ( is_object( $titleObj ) ) {
892 $url = $titleObj->escapeLocalURL();
897 $logourl = $this->getLogo();
898 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
903 * show a drop-down box of special pages
904 * @TODO crash bug913. Need to be rewrote completly.
906 function specialPagesList() {
907 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
908 require_once('SpecialPage.php');
910 $pages = SpecialPage
::getPages();
912 // special pages without access restriction
913 foreach ( $pages[''] as $name => $page ) {
914 $a[$name] = $page->getDescription();
917 // Other special pages that are restricted.
918 // Copied from SpecialSpecialpages.php
919 foreach($wgAvailableRights as $right) {
920 if( $wgUser->isAllowed($right) ) {
921 /** Add all pages for this right */
922 if(isset($pages[$right])) {
923 foreach($pages[$right] as $name => $page) {
924 $a[$name] = $page->getDescription();
931 $sp = wfMsg( 'specialpages' );
932 $spp = $wgContLang->specialPage( 'Specialpages' );
934 $s = '<form id="specialpages" method="get" class="inline" ' .
935 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
936 $s .= "<select name=\"wpDropdown\">\n";
937 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
940 foreach ( $a as $name => $desc ) {
941 $p = $wgContLang->specialPage( $name );
942 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
945 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
950 function mainPageLink() {
951 $mp = wfMsgForContent( 'mainpage' );
952 $mptxt = wfMsg( 'mainpage');
953 $s = $this->makeKnownLink( $mp, $mptxt );
957 function copyrightLink() {
958 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
959 wfMsg( 'copyrightpagename' ) );
963 function aboutLink() {
964 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
965 wfMsg( 'aboutsite' ) );
970 function disclaimerLink() {
971 $disclaimers = wfMsg( 'disclaimers' );
972 if ($disclaimers == '-') {
975 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
980 function editThisPage() {
981 global $wgOut, $wgTitle, $wgRequest;
983 $oldid = $wgRequest->getVal( 'oldid' );
984 $diff = $wgRequest->getVal( 'diff' );
985 $redirect = $wgRequest->getVal( 'redirect' );
987 if ( ! $wgOut->isArticleRelated() ) {
988 $s = wfMsg( 'protectedpage' );
990 if ( $wgTitle->userCanEdit() ) {
991 $t = wfMsg( 'editthispage' );
993 $t = wfMsg( 'viewsource' );
997 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
998 if ( $oldid && ! isset( $diff ) ) {
999 $oid = '&oldid='.$oldid;
1001 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1006 function deleteThisPage() {
1007 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1009 $diff = $wgRequest->getVal( 'diff' );
1010 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1011 $t = wfMsg( 'deletethispage' );
1013 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1020 function protectThisPage() {
1021 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1023 $diff = $wgRequest->getVal( 'diff' );
1024 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1025 if ( $wgTitle->isProtected() ) {
1026 $t = wfMsg( 'unprotectthispage' );
1027 $q = 'action=unprotect';
1029 $t = wfMsg( 'protectthispage' );
1030 $q = 'action=protect';
1032 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1039 function watchThisPage() {
1040 global $wgUser, $wgOut, $wgTitle;
1042 if ( $wgOut->isArticleRelated() ) {
1043 if ( $wgTitle->userIsWatching() ) {
1044 $t = wfMsg( 'unwatchthispage' );
1045 $q = 'action=unwatch';
1047 $t = wfMsg( 'watchthispage' );
1048 $q = 'action=watch';
1050 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1052 $s = wfMsg( 'notanarticle' );
1057 function moveThisPage() {
1060 if ( $wgTitle->userCanMove() ) {
1061 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1062 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1064 // no message if page is protected - would be redundant
1069 function historyLink() {
1072 return $this->makeKnownLinkObj( $wgTitle,
1073 wfMsg( 'history' ), 'action=history' );
1076 function whatLinksHere() {
1079 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1080 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1083 function userContribsLink() {
1086 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1087 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1090 function showEmailUser( $id ) {
1091 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1092 return $wgEnableEmail &&
1093 $wgEnableUserEmail &&
1094 $wgUser->isLoggedIn() && # show only to signed in users
1095 0 != $id; # we can only email to non-anons ..
1096 # '' != $id->getEmail() && # who must have an email address stored ..
1097 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1098 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1101 function emailUserLink() {
1104 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1105 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1108 function watchPageLinksLink() {
1109 global $wgOut, $wgTitle;
1111 if ( ! $wgOut->isArticleRelated() ) {
1112 return '(' . wfMsg( 'notanarticle' ) . ')';
1114 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1115 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1116 'target=' . $wgTitle->getPrefixedURL() );
1120 function otherLanguages() {
1121 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1123 if ( $wgHideInterlanguageLinks ) {
1127 $a = $wgOut->getLanguageLinks();
1128 if ( 0 == count( $a ) ) {
1132 $s = wfMsg( 'otherlanguages' ) . ': ';
1134 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1135 foreach( $a as $l ) {
1136 if ( ! $first ) { $s .= ' | '; }
1139 $nt = Title
::newFromText( $l );
1140 $url = $nt->escapeFullURL();
1141 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1143 if ( '' == $text ) { $text = $l; }
1144 $style = $this->getExternalLinkAttributes( $l, $text );
1145 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1147 if($wgContLang->isRTL()) $s .= '</span>';
1151 function bugReportsLink() {
1152 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1153 wfMsg( 'bugreports' ) );
1157 function dateLink() {
1158 global $wgLinkCache;
1159 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1160 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1162 $wgLinkCache->suspend();
1163 $id = $t1->getArticleID();
1164 $wgLinkCache->resume();
1167 $s = $this->makeBrokenLink( $t1->getText() );
1169 $s = $this->makeKnownLink( $t1->getText() );
1173 $wgLinkCache->suspend();
1174 $id = $t2->getArticleID();
1175 $wgLinkCache->resume();
1178 $s .= $this->makeBrokenLink( $t2->getText() );
1180 $s .= $this->makeKnownLink( $t2->getText() );
1185 function talkLink() {
1186 global $wgTitle, $wgLinkCache;
1188 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1189 # No discussion links for special pages
1193 if( $wgTitle->isTalkPage() ) {
1194 $link = $wgTitle->getSubjectPage();
1195 switch( $link->getNamespace() ) {
1197 $text = wfMsg('articlepage');
1200 $text = wfMsg('userpage');
1203 $text = wfMsg('wikipediapage');
1206 $text = wfMsg('imagepage');
1209 $text= wfMsg('articlepage');
1212 $link = $wgTitle->getTalkPage();
1213 $text = wfMsg( 'talkpage' );
1216 $wgLinkCache->suspend();
1217 $s = $this->makeLinkObj( $link, $text );
1218 $wgLinkCache->resume();
1223 function commentLink() {
1224 global $wgContLang, $wgTitle, $wgLinkCache;
1226 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1229 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1230 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1233 /* these are used extensively in SkinPHPTal, but also some other places */
1234 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1235 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1236 return $title->getLocalURL( $urlaction );
1239 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1240 $title = Title
::newFromText( wfMsgForContent($name) );
1241 $this->checkTitle($title, $name);
1242 return $title->getLocalURL( $urlaction );
1245 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1246 $title = Title
::newFromText( $name );
1247 $this->checkTitle($title, $name);
1248 return $title->getLocalURL( $urlaction );
1251 # If url string starts with http, consider as external URL, else
1253 /*static*/ function makeInternalOrExternalUrl( $name ) {
1254 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1257 return $this->makeUrl( $name );
1261 # this can be passed the NS number as defined in Language.php
1262 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1263 $title = Title
::makeTitleSafe( $namespace, $name );
1264 $this->checkTitle($title, $name);
1265 return $title->getLocalURL( $urlaction );
1268 /* these return an array with the 'href' and boolean 'exists' */
1269 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1270 $title = Title
::newFromText( $name );
1271 $this->checkTitle($title, $name);
1273 'href' => $title->getLocalURL( $urlaction ),
1274 'exists' => $title->getArticleID() != 0?
true:false
1278 # make sure we have some title to operate on
1279 /*static*/ function checkTitle ( &$title, &$name ) {
1280 if(!is_object($title)) {
1281 $title = Title
::newFromText( $name );
1282 if(!is_object($title)) {
1283 $title = Title
::newFromText( '--error: link target missing--' );
1289 * Build an array that represents the sidebar(s), the navigation bar among them
1294 function buildSidebar() {
1295 $fname = 'SkinTemplate::buildSidebar';
1296 wfProfileIn( $fname );
1299 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1300 foreach ($lines as $line) {
1301 if (strpos($line, '*') !== 0)
1303 if (strpos($line, '**') !== 0) {
1304 $line = trim($line, '* ');
1307 if (strpos($line, '|') !== false) { // sanity check
1308 $line = explode( '|' , trim($line, '* '), 2 );
1309 $link = wfMsgForContent( $line[0] );
1312 $bar[$heading][] = array(
1313 'text' => wfMsg( $line[1] ),
1314 'href' => $this->makeInternalOrExternalUrl( $link ),
1315 'id' => 'n-' . $line[1],
1317 } else { continue; }
1321 wfProfileOut( $fname );