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, $wgUseTrackbacks;
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 );
151 $out->out( $out->headElement() );
153 $out->out( "\n<body" );
154 $ops = $this->getBodyOptions();
155 foreach ( $ops as $name => $val ) {
156 $out->out( " $name='$val'" );
159 if ( $wgDebugComments ) {
160 $out->out( "<!-- Wiki debugging output:\n" .
161 $out->mDebugtext
. "-->\n" );
164 $out->out( $this->beforeContent() );
166 $out->out( $out->mBodytext
. "\n" );
168 $out->out( $this->afterContent() );
171 $out->out( $out->reportTime() );
173 $out->out( "\n</body></html>" );
176 function getHeadScripts() {
177 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
178 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
179 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
180 $userpage = $wgUser->getUserPage();
181 $userjs = htmlspecialchars( $this->makeUrl(
182 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
183 'action=raw&ctype='.$wgJsMimeType));
184 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
190 * To make it harder for someone to slip a user a fake
191 * user-JavaScript or user-CSS preview, a random token
192 * is associated with the login session. If it's not
193 * passed back with the preview request, we won't render
196 * @param string $action
200 function userCanPreview( $action ) {
201 global $wgTitle, $wgRequest, $wgUser;
203 if( $action != 'submit' )
205 if( !$wgRequest->wasPosted() )
207 if( !$wgTitle->userCanEditCssJsSubpage() )
209 return $wgUser->matchEditToken(
210 $wgRequest->getVal( 'wpEditToken' ) );
213 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
214 function getUserStylesheet() {
215 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
216 $sheet = $this->getStylesheet();
217 $action = $wgRequest->getText('action');
218 $s = "@import \"$wgStylePath/$sheet\";\n";
219 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
220 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
221 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
222 $s .= $wgRequest->getText('wpTextbox1');
224 $userpage = $wgUser->getUserPage();
225 $s.= '@import "'.$this->makeUrl(
226 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
227 'action=raw&ctype=text/css').'";'."\n";
230 $s .= $this->doGetUserStyles();
235 * placeholder, returns generated js in monobook
237 function getUserJs() { return; }
240 * Return html code that include User stylesheets
242 function getUserStyles() {
243 global $wgOut, $wgStylePath, $wgLang;
244 $s = "<style type='text/css'>\n";
245 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
246 $s .= $this->getUserStylesheet();
247 $s .= "/*]]>*/ /* */\n";
253 * Some styles that are set by user through the user settings interface.
255 function doGetUserStyles() {
256 global $wgUser, $wgContLang, $wgSquidMaxage;
258 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
259 $s = '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
260 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
262 return $s . $this->reallyDoGetUserStyles();
265 function reallyDoGetUserStyles() {
268 if (($undopt = $wgUser->getOption("underline")) != 2) {
269 $underline = $undopt ?
'underline' : 'none';
270 $s .= "a { text-decoration: $underline; }\n";
272 if( $wgUser->getOption( 'highlightbroken' ) ) {
273 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
276 a.new, #quickbar a.new,
277 a.stub, #quickbar a.stub {
279 text-decoration: inherit;
281 a.new:after, #quickbar a.new:after {
284 text-decoration: $underline;
286 a.stub:after, #quickbar a.stub:after {
289 text-decoration: $underline;
293 if( $wgUser->getOption( 'justify' ) ) {
294 $s .= "#article, #bodyContent { text-align: justify; }\n";
296 if( !$wgUser->getOption( 'showtoc' ) ) {
297 $s .= "#toc { display: none; }\n";
299 if( !$wgUser->getOption( 'editsection' ) ) {
300 $s .= ".editsection { display: none; }\n";
305 function getBodyOptions() {
306 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
308 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
310 if ( 0 != $wgTitle->getNamespace() ) {
311 $a = array( 'bgcolor' => '#ffffec' );
313 else $a = array( 'bgcolor' => '#FFFFFF' );
314 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
315 $wgTitle->userCanEdit() ) {
316 $t = wfMsg( 'editthispage' );
318 if ( !empty($redirect) && $redirect == 'no' ) {
319 $red = "&redirect={$redirect}";
321 if ( !empty($oldid) && ! isset( $diff ) ) {
322 $oid = "&oldid=" . intval( $oldid );
324 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
325 $s = 'document.location = "' .$s .'";';
326 $a +
= array ('ondblclick' => $s);
329 $a['onload'] = $wgOut->getOnloadHandler();
330 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
331 if( $a['onload'] != '' ) {
334 $a['onload'] .= 'setupRightClickEdit()';
348 * This will be called immediately after the <body> tag. Split into
349 * two functions to make it easier to subclass.
351 function beforeContent() {
352 return $this->doBeforeContent();
355 function doBeforeContent() {
356 global $wgOut, $wgTitle, $wgContLang;
357 $fname = 'Skin::doBeforeContent';
358 wfProfileIn( $fname );
361 $qb = $this->qbSetting();
363 if( $langlinks = $this->otherLanguages() ) {
369 $borderhack = 'class="top"';
372 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
373 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
376 $left = ($qb == 1 ||
$qb == 3);
377 if($wgContLang->isRTL()) $left = !$left;
380 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
381 $this->logoText() . '</td>';
383 $s .= $this->getQuickbarCompensator( $rows );
385 $l = $wgContLang->isRTL() ?
'right' : 'left';
386 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
388 $s .= $this->topLinks() ;
389 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
391 $r = $wgContLang->isRTL() ?
"left" : "right";
392 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
393 $s .= $this->nameAndLogin();
394 $s .= "\n<br />" . $this->searchForm() . "</td>";
397 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
400 if ( $shove && !$left ) { # Right
401 $s .= $this->getQuickbarCompensator( $rows );
403 $s .= "</tr>\n</table>\n</div>\n";
404 $s .= "\n<div id='article'>\n";
406 $notice = wfGetSiteNotice();
408 $s .= "\n<div id='siteNotice'>$notice</div>\n";
410 $s .= $this->pageTitle();
411 $s .= $this->pageSubtitle() ;
412 $s .= $this->getCategories();
413 wfProfileOut( $fname );
418 function getCategoryLinks () {
419 global $wgOut, $wgTitle, $wgParser;
420 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
422 if( !$wgUseCategoryMagic ) return '' ;
423 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
425 # Taken out so that they will be displayed in previews -- TS
426 #if( !$wgOut->isArticle() ) return '';
428 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
429 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
430 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
433 # optional 'dmoz-like' category browser. Will be shown under the list
434 # of categories an article belong to
435 if($wgUseCategoryBrowser) {
436 $s .= '<br /><hr />';
438 # get a big array of the parents tree
439 $parenttree = $wgTitle->getParentCategoryTree();
440 # Skin object passed by reference cause it can not be
441 # accessed under the method subfunction drawCategoryBrowser
442 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
443 # Clean out bogus first entry and sort them
446 # Output one per line
447 $s .= implode("<br />\n", $tempout);
453 /** Render the array as a serie of links.
454 * @param array $tree Categories tree returned by Title::getParentCategoryTree
455 * @param object &skin Skin passed by reference
456 * @return string separated by >, terminate with "\n"
458 function drawCategoryBrowser($tree, &$skin) {
460 foreach ($tree as $element => $parent) {
461 if (empty($parent)) {
462 # element start a new list
465 # grab the others elements
466 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
468 # add our current element to the list
469 $eltitle = Title
::NewFromText($element);
470 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
475 function getCategories() {
476 $catlinks=$this->getCategoryLinks();
477 if(!empty($catlinks)) {
478 return "<p class='catlinks'>{$catlinks}</p>";
482 function getQuickbarCompensator( $rows = 1 ) {
483 return "<td width='152' rowspan='{$rows}'> </td>";
487 * This gets called immediately before the </body> tag.
488 * @return string HTML to be put after </body> ???
490 function afterContent() {
491 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
492 return $printfooter . $this->doAfterContent();
495 /** @return string Retrievied from HTML text */
496 function printSource() {
498 $url = htmlspecialchars( $wgTitle->getFullURL() );
499 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
502 function printFooter() {
503 return "<p>" . $this->printSource() .
504 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
507 /** overloaded by derived classes */
508 function doAfterContent() { }
510 function pageTitleLinks() {
511 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
513 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
514 $action = $wgRequest->getText( 'action' );
516 $s = $this->printableLink();
517 $disclaimer = $this->disclaimerLink(); # may be empty
519 $s .= ' | ' . $disclaimer;
522 if ( $wgOut->isArticleRelated() ) {
523 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
524 $name = $wgTitle->getDBkey();
525 $image = new Image( $wgTitle );
526 if( $image->exists() ) {
527 $link = htmlspecialchars( $image->getURL() );
528 $style = $this->getInternalLinkAttributes( $link, $name );
529 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
533 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
534 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
535 wfMsg( 'currentrev' ) );
538 if ( $wgUser->getNewtalk() ) {
539 # do not show "You have new messages" text when we are viewing our
542 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
543 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
544 wfMsg('newmessageslink') );
545 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
547 $wgOut->setSquidMaxage(0);
548 $wgOut->enableClientCache(false);
552 $undelete = $this->getUndeleteLink();
553 if( !empty( $undelete ) ) {
554 $s .= ' | '.$undelete;
559 function getUndeleteLink() {
560 global $wgUser, $wgTitle, $wgContLang, $action;
561 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
562 ($n = $wgTitle->isDeleted() ) )
564 if ( $wgUser->isAllowed( 'delete' ) ) {
565 $msg = 'thisisdeleted';
567 $msg = 'viewdeleted';
570 $this->makeKnownLink(
571 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
572 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
577 function printableLink() {
578 global $wgOut, $wgFeedClasses, $wgRequest;
580 $baseurl = $_SERVER['REQUEST_URI'];
581 if( strpos( '?', $baseurl ) == false ) {
586 $baseurl = htmlspecialchars( $baseurl );
587 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
589 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
590 if( $wgOut->isSyndicated() ) {
591 foreach( $wgFeedClasses as $format => $class ) {
592 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
593 $s .= " | <a href=\"$feedurl\">{$format}</a>";
599 function pageTitle() {
600 global $wgOut, $wgTitle, $wgUser;
602 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
606 function pageSubtitle() {
609 $sub = $wgOut->getSubtitle();
611 global $wgExtraSubtitle;
612 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
614 $subpages = $this->subPageSubtitle();
615 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
616 $s = "<p class='subtitle'>{$sub}</p>\n";
620 function subPageSubtitle() {
621 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
623 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
624 $ptext=$wgTitle->getPrefixedText();
625 if(preg_match('/\//',$ptext)) {
626 $links = explode('/',$ptext);
629 foreach($links as $link) {
631 if ($c<count($links)) {
632 $growinglink .= $link;
633 $getlink = $this->makeLink( $growinglink, $link );
634 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
638 $subpages .= '< ';
640 $subpages .= $getlink;
649 function nameAndLogin() {
650 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
652 $li = $wgContLang->specialPage( 'Userlogin' );
653 $lo = $wgContLang->specialPage( 'Userlogout' );
656 if ( $wgUser->isAnon() ) {
657 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
660 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
661 $wgLang->getNsText( NS_TALK
) );
663 $s .= $n . ' ('.$tl.')';
665 $s .= wfMsg('notloggedin');
668 $rt = $wgTitle->getPrefixedURL();
669 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
671 } else { $q = "returnto={$rt}"; }
673 $s .= "\n<br />" . $this->makeKnownLinkObj(
674 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
675 wfMsg( 'login' ), $q );
677 $n = $wgUser->getName();
678 $rt = $wgTitle->getPrefixedURL();
679 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
680 $wgLang->getNsText( NS_TALK
) );
684 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
685 $n ) . "{$tl}<br />" .
686 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
687 "returnto={$rt}" ) . ' | ' .
688 $this->specialLink( 'preferences' );
690 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
696 function getSearchLink() {
697 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
698 return $searchPage->getLocalURL();
701 function escapeSearchLink() {
702 return htmlspecialchars( $this->getSearchLink() );
705 function searchForm() {
707 $search = $wgRequest->getText( 'search' );
709 $s = '<form name="search" class="inline" method="post" action="'
710 . $this->escapeSearchLink() . "\">\n"
711 . '<input type="text" name="search" size="19" value="'
712 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
713 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
714 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
719 function topLinks() {
723 $s = $this->mainPageLink() . $sep
724 . $this->specialLink( 'recentchanges' );
726 if ( $wgOut->isArticleRelated() ) {
727 $s .= $sep . $this->editThisPage()
728 . $sep . $this->historyLink();
730 # Many people don't like this dropdown box
731 #$s .= $sep . $this->specialPagesList();
733 /* show links to different language variants */
734 global $wgDisableLangConversion, $wgContLang, $wgTitle;
735 $variants = $wgContLang->getVariants();
736 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
737 foreach( $variants as $code ) {
738 $varname = $wgContLang->getVariantname( $code );
739 if( $varname == 'disable' )
741 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
748 function bottomLinks() {
749 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
753 if ( $wgOut->isArticleRelated() ) {
754 $s .= '<strong>' . $this->editThisPage() . '</strong>';
755 if ( $wgUser->isLoggedIn() ) {
756 $s .= $sep . $this->watchThisPage();
758 $s .= $sep . $this->talkLink()
759 . $sep . $this->historyLink()
760 . $sep . $this->whatLinksHere()
761 . $sep . $this->watchPageLinksLink();
763 if ($wgUseTrackbacks)
764 $s .= $sep . $this->trackbackLink();
766 if ( $wgTitle->getNamespace() == NS_USER
767 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
770 $id=User
::idFromName($wgTitle->getText());
771 $ip=User
::isIP($wgTitle->getText());
773 if($id ||
$ip) { # both anons and non-anons have contri list
774 $s .= $sep . $this->userContribsLink();
776 if( $this->showEmailUser( $id ) ) {
777 $s .= $sep . $this->emailUserLink();
780 if ( $wgTitle->getArticleId() ) {
782 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
783 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
784 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
786 $s .= "<br />\n" . $this->otherLanguages();
791 function pageStats() {
792 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
793 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
795 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
796 if ( ! $wgOut->isArticle() ) { return ''; }
797 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
798 if ( 0 == $wgArticle->getID() ) { return ''; }
801 if ( !$wgDisableCounters ) {
802 $count = $wgLang->formatNum( $wgArticle->getCount() );
804 $s = wfMsg( 'viewcount', $count );
808 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
809 require_once('Credits.php');
810 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
812 $s .= $this->lastModified();
815 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
816 $dbr =& wfGetDB( DB_SLAVE
);
817 extract( $dbr->tableNames( 'watchlist' ) );
818 $sql = "SELECT COUNT(*) AS n FROM $watchlist
819 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
820 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
821 $res = $dbr->query( $sql, 'Skin::pageStats');
822 $x = $dbr->fetchObject( $res );
823 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
826 return $s . ' ' . $this->getCopyright();
829 function getCopyright() {
830 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
833 $oldid = $wgRequest->getVal( 'oldid' );
834 $diff = $wgRequest->getVal( 'diff' );
836 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
837 $msg = 'history_copyright';
843 if( $wgRightsPage ) {
844 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
845 } elseif( $wgRightsUrl ) {
846 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
851 $out .= wfMsgForContent( $msg, $link );
855 function getCopyrightIcon() {
856 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
858 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
859 $out = $wgCopyrightIcon;
860 } else if ( $wgRightsIcon ) {
861 $icon = htmlspecialchars( $wgRightsIcon );
862 if ( $wgRightsUrl ) {
863 $url = htmlspecialchars( $wgRightsUrl );
864 $out .= '<a href="'.$url.'">';
866 $text = htmlspecialchars( $wgRightsText );
867 $out .= "<img src=\"$icon\" alt='$text' />";
868 if ( $wgRightsUrl ) {
875 function getPoweredBy() {
877 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
878 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
882 function lastModified() {
883 global $wgLang, $wgArticle, $wgLoadBalancer;
885 $timestamp = $wgArticle->getTimestamp();
887 $d = $wgLang->timeanddate( $timestamp, true );
888 $s = ' ' . wfMsg( 'lastmodified', $d );
892 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
893 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
898 function logoText( $align = '' ) {
899 if ( '' != $align ) { $a = " align='{$align}'"; }
902 $mp = wfMsg( 'mainpage' );
903 $titleObj = Title
::newFromText( $mp );
904 if ( is_object( $titleObj ) ) {
905 $url = $titleObj->escapeLocalURL();
910 $logourl = $this->getLogo();
911 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
916 * show a drop-down box of special pages
917 * @TODO crash bug913. Need to be rewrote completly.
919 function specialPagesList() {
920 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
921 require_once('SpecialPage.php');
923 $pages = SpecialPage
::getPages();
925 // special pages without access restriction
926 foreach ( $pages[''] as $name => $page ) {
927 $a[$name] = $page->getDescription();
930 // Other special pages that are restricted.
931 // Copied from SpecialSpecialpages.php
932 foreach($wgAvailableRights as $right) {
933 if( $wgUser->isAllowed($right) ) {
934 /** Add all pages for this right */
935 if(isset($pages[$right])) {
936 foreach($pages[$right] as $name => $page) {
937 $a[$name] = $page->getDescription();
944 $sp = wfMsg( 'specialpages' );
945 $spp = $wgContLang->specialPage( 'Specialpages' );
947 $s = '<form id="specialpages" method="get" class="inline" ' .
948 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
949 $s .= "<select name=\"wpDropdown\">\n";
950 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
953 foreach ( $a as $name => $desc ) {
954 $p = $wgContLang->specialPage( $name );
955 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
958 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
963 function mainPageLink() {
964 $mp = wfMsgForContent( 'mainpage' );
965 $mptxt = wfMsg( 'mainpage');
966 $s = $this->makeKnownLink( $mp, $mptxt );
970 function copyrightLink() {
971 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
972 wfMsg( 'copyrightpagename' ) );
976 function aboutLink() {
977 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
978 wfMsg( 'aboutsite' ) );
983 function disclaimerLink() {
984 $disclaimers = wfMsg( 'disclaimers' );
985 if ($disclaimers == '-') {
988 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
993 function editThisPage() {
994 global $wgOut, $wgTitle, $wgRequest;
996 $oldid = $wgRequest->getVal( 'oldid' );
997 $diff = $wgRequest->getVal( 'diff' );
998 $redirect = $wgRequest->getVal( 'redirect' );
1000 if ( ! $wgOut->isArticleRelated() ) {
1001 $s = wfMsg( 'protectedpage' );
1003 if ( $wgTitle->userCanEdit() ) {
1004 $t = wfMsg( 'editthispage' );
1006 $t = wfMsg( 'viewsource' );
1010 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1011 if ( $oldid && ! isset( $diff ) ) {
1012 $oid = '&oldid='.$oldid;
1014 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1019 function deleteThisPage() {
1020 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1022 $diff = $wgRequest->getVal( 'diff' );
1023 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1024 $t = wfMsg( 'deletethispage' );
1026 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1033 function protectThisPage() {
1034 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1036 $diff = $wgRequest->getVal( 'diff' );
1037 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1038 if ( $wgTitle->isProtected() ) {
1039 $t = wfMsg( 'unprotectthispage' );
1040 $q = 'action=unprotect';
1042 $t = wfMsg( 'protectthispage' );
1043 $q = 'action=protect';
1045 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1052 function watchThisPage() {
1053 global $wgUser, $wgOut, $wgTitle;
1055 if ( $wgOut->isArticleRelated() ) {
1056 if ( $wgTitle->userIsWatching() ) {
1057 $t = wfMsg( 'unwatchthispage' );
1058 $q = 'action=unwatch';
1060 $t = wfMsg( 'watchthispage' );
1061 $q = 'action=watch';
1063 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1065 $s = wfMsg( 'notanarticle' );
1070 function moveThisPage() {
1073 if ( $wgTitle->userCanMove() ) {
1074 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1075 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1077 // no message if page is protected - would be redundant
1082 function historyLink() {
1085 return $this->makeKnownLinkObj( $wgTitle,
1086 wfMsg( 'history' ), 'action=history' );
1089 function whatLinksHere() {
1092 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1093 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1096 function userContribsLink() {
1099 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1100 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1103 function showEmailUser( $id ) {
1104 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1105 return $wgEnableEmail &&
1106 $wgEnableUserEmail &&
1107 $wgUser->isLoggedIn() && # show only to signed in users
1108 0 != $id; # we can only email to non-anons ..
1109 # '' != $id->getEmail() && # who must have an email address stored ..
1110 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1111 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1114 function emailUserLink() {
1117 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1118 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1121 function watchPageLinksLink() {
1122 global $wgOut, $wgTitle;
1124 if ( ! $wgOut->isArticleRelated() ) {
1125 return '(' . wfMsg( 'notanarticle' ) . ')';
1127 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1128 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1129 'target=' . $wgTitle->getPrefixedURL() );
1133 function trackbackLink() {
1136 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1137 . wfMsg('trackbacklink') . "</a>";
1140 function otherLanguages() {
1141 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1143 if ( $wgHideInterlanguageLinks ) {
1147 $a = $wgOut->getLanguageLinks();
1148 if ( 0 == count( $a ) ) {
1152 $s = wfMsg( 'otherlanguages' ) . ': ';
1154 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1155 foreach( $a as $l ) {
1156 if ( ! $first ) { $s .= ' | '; }
1159 $nt = Title
::newFromText( $l );
1160 $url = $nt->escapeFullURL();
1161 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1163 if ( '' == $text ) { $text = $l; }
1164 $style = $this->getExternalLinkAttributes( $l, $text );
1165 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1167 if($wgContLang->isRTL()) $s .= '</span>';
1171 function bugReportsLink() {
1172 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1173 wfMsg( 'bugreports' ) );
1177 function dateLink() {
1178 global $wgLinkCache;
1179 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1180 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1182 $wgLinkCache->suspend();
1183 $id = $t1->getArticleID();
1184 $wgLinkCache->resume();
1187 $s = $this->makeBrokenLink( $t1->getText() );
1189 $s = $this->makeKnownLink( $t1->getText() );
1193 $wgLinkCache->suspend();
1194 $id = $t2->getArticleID();
1195 $wgLinkCache->resume();
1198 $s .= $this->makeBrokenLink( $t2->getText() );
1200 $s .= $this->makeKnownLink( $t2->getText() );
1205 function talkLink() {
1206 global $wgTitle, $wgLinkCache;
1208 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1209 # No discussion links for special pages
1213 if( $wgTitle->isTalkPage() ) {
1214 $link = $wgTitle->getSubjectPage();
1215 switch( $link->getNamespace() ) {
1217 $text = wfMsg('articlepage');
1220 $text = wfMsg('userpage');
1223 $text = wfMsg('wikipediapage');
1226 $text = wfMsg('imagepage');
1229 $text= wfMsg('articlepage');
1232 $link = $wgTitle->getTalkPage();
1233 $text = wfMsg( 'talkpage' );
1236 $wgLinkCache->suspend();
1237 $s = $this->makeLinkObj( $link, $text );
1238 $wgLinkCache->resume();
1243 function commentLink() {
1244 global $wgContLang, $wgTitle, $wgLinkCache;
1246 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1249 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1250 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1253 /* these are used extensively in SkinPHPTal, but also some other places */
1254 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1255 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1256 return $title->getLocalURL( $urlaction );
1259 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1260 $title = Title
::newFromText( wfMsgForContent($name) );
1261 $this->checkTitle($title, $name);
1262 return $title->getLocalURL( $urlaction );
1265 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1266 $title = Title
::newFromText( $name );
1267 $this->checkTitle($title, $name);
1268 return $title->getLocalURL( $urlaction );
1271 # If url string starts with http, consider as external URL, else
1273 /*static*/ function makeInternalOrExternalUrl( $name ) {
1274 global $wgUrlProtocols;
1275 if ( preg_match( '/^(?:' . $wgUrlProtocols . ')/', $name ) ) {
1278 return $this->makeUrl( $name );
1282 # this can be passed the NS number as defined in Language.php
1283 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1284 $title = Title
::makeTitleSafe( $namespace, $name );
1285 $this->checkTitle($title, $name);
1286 return $title->getLocalURL( $urlaction );
1289 /* these return an array with the 'href' and boolean 'exists' */
1290 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1291 $title = Title
::newFromText( $name );
1292 $this->checkTitle($title, $name);
1294 'href' => $title->getLocalURL( $urlaction ),
1295 'exists' => $title->getArticleID() != 0?
true:false
1300 * Make URL details where the article exists (or at least it's convenient to think so)
1302 function makeKnownUrlDetails( $name, $urlaction='' ) {
1303 $title = Title
::newFromText( $name );
1304 $this->checkTitle($title, $name);
1306 'href' => $title->getLocalURL( $urlaction ),
1311 # make sure we have some title to operate on
1312 /*static*/ function checkTitle ( &$title, &$name ) {
1313 if(!is_object($title)) {
1314 $title = Title
::newFromText( $name );
1315 if(!is_object($title)) {
1316 $title = Title
::newFromText( '--error: link target missing--' );
1322 * Build an array that represents the sidebar(s), the navigation bar among them
1327 function buildSidebar() {
1328 global $wgTitle, $action;
1330 $fname = 'SkinTemplate::buildSidebar';
1331 $pageurl = $wgTitle->getLocalURL();
1332 wfProfileIn( $fname );
1335 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1336 foreach ($lines as $line) {
1337 if (strpos($line, '*') !== 0)
1339 if (strpos($line, '**') !== 0) {
1340 $line = trim($line, '* ');
1343 if (strpos($line, '|') !== false) { // sanity check
1344 $line = explode( '|' , trim($line, '* '), 2 );
1345 $link = wfMsgForContent( $line[0] );
1348 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1350 if (wfEmptyMsg($line[0], $link))
1352 $href = $this->makeInternalOrExternalUrl( $link );
1353 $bar[$heading][] = array(
1356 'id' => 'n-' . strtr($line[1], ' ', '-'),
1357 'active' => $pageurl == $href
1359 } else { continue; }
1363 wfProfileOut( $fname );