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?1'; }
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, $wgRequest, $wgContLang, $wgSquidMaxage;
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";
221 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
222 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
223 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
225 $s .= $this->doGetUserStyles();
230 * placeholder, returns generated js in monobook
232 function getUserJs() { return; }
235 * Return html code that include User stylesheets
237 function getUserStyles() {
238 global $wgOut, $wgStylePath, $wgLang;
239 $s = "<style type='text/css'>\n";
240 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
241 $s .= $this->getUserStylesheet();
242 $s .= "/*]]>*/ /* */\n";
248 * Some styles that are set by user through the user settings interface.
250 function doGetUserStyles() {
251 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
255 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
256 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
257 $s .= $wgRequest->getText('wpTextbox1');
259 $userpage = $wgUser->getUserPage();
260 $s.= '@import "'.$this->makeUrl(
261 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
262 'action=raw&ctype=text/css').'";'."\n";
266 return $s . $this->reallyDoGetUserStyles();
269 function reallyDoGetUserStyles() {
272 if (($undopt = $wgUser->getOption("underline")) != 2) {
273 $underline = $undopt ?
'underline' : 'none';
274 $s .= "a { text-decoration: $underline; }\n";
276 if( $wgUser->getOption( 'highlightbroken' ) ) {
277 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
280 a.new, #quickbar a.new,
281 a.stub, #quickbar a.stub {
283 text-decoration: inherit;
285 a.new:after, #quickbar a.new:after {
288 text-decoration: $underline;
290 a.stub:after, #quickbar a.stub:after {
293 text-decoration: $underline;
297 if( $wgUser->getOption( 'justify' ) ) {
298 $s .= "#article, #bodyContent { text-align: justify; }\n";
300 if( !$wgUser->getOption( 'showtoc' ) ) {
301 $s .= "#toc { display: none; }\n";
303 if( !$wgUser->getOption( 'editsection' ) ) {
304 $s .= ".editsection { display: none; }\n";
309 function getBodyOptions() {
310 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
312 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
314 if ( 0 != $wgTitle->getNamespace() ) {
315 $a = array( 'bgcolor' => '#ffffec' );
317 else $a = array( 'bgcolor' => '#FFFFFF' );
318 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
319 $wgTitle->userCanEdit() ) {
320 $t = wfMsg( 'editthispage' );
322 if ( !empty($redirect) && $redirect == 'no' ) {
323 $red = "&redirect={$redirect}";
325 if ( !empty($oldid) && ! isset( $diff ) ) {
326 $oid = "&oldid=" . intval( $oldid );
328 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
329 $s = 'document.location = "' .$s .'";';
330 $a +
= array ('ondblclick' => $s);
333 $a['onload'] = $wgOut->getOnloadHandler();
334 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
335 if( $a['onload'] != '' ) {
338 $a['onload'] .= 'setupRightClickEdit()';
352 * This will be called immediately after the <body> tag. Split into
353 * two functions to make it easier to subclass.
355 function beforeContent() {
356 return $this->doBeforeContent();
359 function doBeforeContent() {
360 global $wgOut, $wgTitle, $wgContLang;
361 $fname = 'Skin::doBeforeContent';
362 wfProfileIn( $fname );
365 $qb = $this->qbSetting();
367 if( $langlinks = $this->otherLanguages() ) {
373 $borderhack = 'class="top"';
376 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
377 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
380 $left = ($qb == 1 ||
$qb == 3);
381 if($wgContLang->isRTL()) $left = !$left;
384 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
385 $this->logoText() . '</td>';
387 $s .= $this->getQuickbarCompensator( $rows );
389 $l = $wgContLang->isRTL() ?
'right' : 'left';
390 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
392 $s .= $this->topLinks() ;
393 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
395 $r = $wgContLang->isRTL() ?
"left" : "right";
396 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
397 $s .= $this->nameAndLogin();
398 $s .= "\n<br />" . $this->searchForm() . "</td>";
401 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
404 if ( $shove && !$left ) { # Right
405 $s .= $this->getQuickbarCompensator( $rows );
407 $s .= "</tr>\n</table>\n</div>\n";
408 $s .= "\n<div id='article'>\n";
410 $notice = wfGetSiteNotice();
412 $s .= "\n<div id='siteNotice'>$notice</div>\n";
414 $s .= $this->pageTitle();
415 $s .= $this->pageSubtitle() ;
416 $s .= $this->getCategories();
417 wfProfileOut( $fname );
422 function getCategoryLinks () {
423 global $wgOut, $wgTitle, $wgParser;
424 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgContLang;
426 if( !$wgUseCategoryMagic ) return '' ;
427 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
429 // Use Unicode bidi embedding override characters,
430 // to make sure links don't smash each other up in ugly ways.
431 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
432 $embed = "<span dir='$dir'>";
434 $t = $embed . implode ( "$pop | $embed" , $wgOut->mCategoryLinks
) . $pop;
436 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
437 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
438 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
441 # optional 'dmoz-like' category browser. Will be shown under the list
442 # of categories an article belong to
443 if($wgUseCategoryBrowser) {
444 $s .= '<br /><hr />';
446 # get a big array of the parents tree
447 $parenttree = $wgTitle->getParentCategoryTree();
448 # Skin object passed by reference cause it can not be
449 # accessed under the method subfunction drawCategoryBrowser
450 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
451 # Clean out bogus first entry and sort them
454 # Output one per line
455 $s .= implode("<br />\n", $tempout);
461 /** Render the array as a serie of links.
462 * @param array $tree Categories tree returned by Title::getParentCategoryTree
463 * @param object &skin Skin passed by reference
464 * @return string separated by >, terminate with "\n"
466 function drawCategoryBrowser($tree, &$skin) {
468 foreach ($tree as $element => $parent) {
469 if (empty($parent)) {
470 # element start a new list
473 # grab the others elements
474 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
476 # add our current element to the list
477 $eltitle = Title
::NewFromText($element);
478 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
483 function getCategories() {
484 $catlinks=$this->getCategoryLinks();
485 if(!empty($catlinks)) {
486 return "<p class='catlinks'>{$catlinks}</p>";
490 function getQuickbarCompensator( $rows = 1 ) {
491 return "<td width='152' rowspan='{$rows}'> </td>";
495 * This gets called immediately before the </body> tag.
496 * @return string HTML to be put after </body> ???
498 function afterContent() {
499 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
500 return $printfooter . $this->doAfterContent();
503 /** @return string Retrievied from HTML text */
504 function printSource() {
506 $url = htmlspecialchars( $wgTitle->getFullURL() );
507 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
510 function printFooter() {
511 return "<p>" . $this->printSource() .
512 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
515 /** overloaded by derived classes */
516 function doAfterContent() { }
518 function pageTitleLinks() {
519 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
521 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
522 $action = $wgRequest->getText( 'action' );
524 $s = $this->printableLink();
525 $disclaimer = $this->disclaimerLink(); # may be empty
527 $s .= ' | ' . $disclaimer;
529 $privacy = $this->privacyLink(); # may be empty too
531 $s .= ' | ' . $privacy;
534 if ( $wgOut->isArticleRelated() ) {
535 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
536 $name = $wgTitle->getDBkey();
537 $image = new Image( $wgTitle );
538 if( $image->exists() ) {
539 $link = htmlspecialchars( $image->getURL() );
540 $style = $this->getInternalLinkAttributes( $link, $name );
541 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
545 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
546 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
547 wfMsg( 'currentrev' ) );
550 if ( $wgUser->getNewtalk() ) {
551 # do not show "You have new messages" text when we are viewing our
554 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
555 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
556 wfMsg('newmessageslink') );
557 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
559 $wgOut->setSquidMaxage(0);
560 $wgOut->enableClientCache(false);
564 $undelete = $this->getUndeleteLink();
565 if( !empty( $undelete ) ) {
566 $s .= ' | '.$undelete;
571 function getUndeleteLink() {
572 global $wgUser, $wgTitle, $wgContLang, $action;
573 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
574 ($n = $wgTitle->isDeleted() ) )
576 if ( $wgUser->isAllowed( 'delete' ) ) {
577 $msg = 'thisisdeleted';
579 $msg = 'viewdeleted';
582 $this->makeKnownLink(
583 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
584 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
589 function printableLink() {
590 global $wgOut, $wgFeedClasses, $wgRequest;
592 $baseurl = $_SERVER['REQUEST_URI'];
593 if( strpos( '?', $baseurl ) == false ) {
598 $baseurl = htmlspecialchars( $baseurl );
599 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
601 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
602 if( $wgOut->isSyndicated() ) {
603 foreach( $wgFeedClasses as $format => $class ) {
604 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
605 $s .= " | <a href=\"$feedurl\">{$format}</a>";
611 function pageTitle() {
612 global $wgOut, $wgTitle, $wgUser;
614 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
618 function pageSubtitle() {
621 $sub = $wgOut->getSubtitle();
623 global $wgExtraSubtitle;
624 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
626 $subpages = $this->subPageSubtitle();
627 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
628 $s = "<p class='subtitle'>{$sub}</p>\n";
632 function subPageSubtitle() {
633 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
635 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
636 $ptext=$wgTitle->getPrefixedText();
637 if(preg_match('/\//',$ptext)) {
638 $links = explode('/',$ptext);
641 foreach($links as $link) {
643 if ($c<count($links)) {
644 $growinglink .= $link;
645 $getlink = $this->makeLink( $growinglink, $link );
646 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
650 $subpages .= '< ';
652 $subpages .= $getlink;
661 function nameAndLogin() {
662 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
664 $li = $wgContLang->specialPage( 'Userlogin' );
665 $lo = $wgContLang->specialPage( 'Userlogout' );
668 if ( $wgUser->isAnon() ) {
669 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
672 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
673 $wgLang->getNsText( NS_TALK
) );
675 $s .= $n . ' ('.$tl.')';
677 $s .= wfMsg('notloggedin');
680 $rt = $wgTitle->getPrefixedURL();
681 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
683 } else { $q = "returnto={$rt}"; }
685 $s .= "\n<br />" . $this->makeKnownLinkObj(
686 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
687 wfMsg( 'login' ), $q );
689 $n = $wgUser->getName();
690 $rt = $wgTitle->getPrefixedURL();
691 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
692 $wgLang->getNsText( NS_TALK
) );
696 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
697 $n ) . "{$tl}<br />" .
698 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
699 "returnto={$rt}" ) . ' | ' .
700 $this->specialLink( 'preferences' );
702 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
708 function getSearchLink() {
709 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
710 return $searchPage->getLocalURL();
713 function escapeSearchLink() {
714 return htmlspecialchars( $this->getSearchLink() );
717 function searchForm() {
719 $search = $wgRequest->getText( 'search' );
721 $s = '<form name="search" class="inline" method="post" action="'
722 . $this->escapeSearchLink() . "\">\n"
723 . '<input type="text" name="search" size="19" value="'
724 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
725 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
726 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
731 function topLinks() {
735 $s = $this->mainPageLink() . $sep
736 . $this->specialLink( 'recentchanges' );
738 if ( $wgOut->isArticleRelated() ) {
739 $s .= $sep . $this->editThisPage()
740 . $sep . $this->historyLink();
742 # Many people don't like this dropdown box
743 #$s .= $sep . $this->specialPagesList();
745 /* show links to different language variants */
746 global $wgDisableLangConversion, $wgContLang, $wgTitle;
747 $variants = $wgContLang->getVariants();
748 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
749 foreach( $variants as $code ) {
750 $varname = $wgContLang->getVariantname( $code );
751 if( $varname == 'disable' )
753 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
760 function bottomLinks() {
761 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
765 if ( $wgOut->isArticleRelated() ) {
766 $s .= '<strong>' . $this->editThisPage() . '</strong>';
767 if ( $wgUser->isLoggedIn() ) {
768 $s .= $sep . $this->watchThisPage();
770 $s .= $sep . $this->talkLink()
771 . $sep . $this->historyLink()
772 . $sep . $this->whatLinksHere()
773 . $sep . $this->watchPageLinksLink();
775 if ($wgUseTrackbacks)
776 $s .= $sep . $this->trackbackLink();
778 if ( $wgTitle->getNamespace() == NS_USER
779 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
782 $id=User
::idFromName($wgTitle->getText());
783 $ip=User
::isIP($wgTitle->getText());
785 if($id ||
$ip) { # both anons and non-anons have contri list
786 $s .= $sep . $this->userContribsLink();
788 if( $this->showEmailUser( $id ) ) {
789 $s .= $sep . $this->emailUserLink();
792 if ( $wgTitle->getArticleId() ) {
794 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
795 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
796 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
798 $s .= "<br />\n" . $this->otherLanguages();
803 function pageStats() {
804 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
805 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
807 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
808 if ( ! $wgOut->isArticle() ) { return ''; }
809 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
810 if ( 0 == $wgArticle->getID() ) { return ''; }
813 if ( !$wgDisableCounters ) {
814 $count = $wgLang->formatNum( $wgArticle->getCount() );
816 $s = wfMsg( 'viewcount', $count );
820 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
821 require_once('Credits.php');
822 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
824 $s .= $this->lastModified();
827 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
828 $dbr =& wfGetDB( DB_SLAVE
);
829 extract( $dbr->tableNames( 'watchlist' ) );
830 $sql = "SELECT COUNT(*) AS n FROM $watchlist
831 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
832 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
833 $res = $dbr->query( $sql, 'Skin::pageStats');
834 $x = $dbr->fetchObject( $res );
835 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
838 return $s . ' ' . $this->getCopyright();
841 function getCopyright() {
842 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
845 $oldid = $wgRequest->getVal( 'oldid' );
846 $diff = $wgRequest->getVal( 'diff' );
848 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
849 $msg = 'history_copyright';
855 if( $wgRightsPage ) {
856 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
857 } elseif( $wgRightsUrl ) {
858 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
863 $out .= wfMsgForContent( $msg, $link );
867 function getCopyrightIcon() {
868 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
870 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
871 $out = $wgCopyrightIcon;
872 } else if ( $wgRightsIcon ) {
873 $icon = htmlspecialchars( $wgRightsIcon );
874 if ( $wgRightsUrl ) {
875 $url = htmlspecialchars( $wgRightsUrl );
876 $out .= '<a href="'.$url.'">';
878 $text = htmlspecialchars( $wgRightsText );
879 $out .= "<img src=\"$icon\" alt='$text' />";
880 if ( $wgRightsUrl ) {
887 function getPoweredBy() {
889 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
890 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
894 function lastModified() {
895 global $wgLang, $wgArticle, $wgLoadBalancer;
897 $timestamp = $wgArticle->getTimestamp();
899 $d = $wgLang->timeanddate( $timestamp, true );
900 $s = ' ' . wfMsg( 'lastmodified', $d );
904 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
905 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
910 function logoText( $align = '' ) {
911 if ( '' != $align ) { $a = " align='{$align}'"; }
914 $mp = wfMsg( 'mainpage' );
915 $titleObj = Title
::newFromText( $mp );
916 if ( is_object( $titleObj ) ) {
917 $url = $titleObj->escapeLocalURL();
922 $logourl = $this->getLogo();
923 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
928 * show a drop-down box of special pages
929 * @TODO crash bug913. Need to be rewrote completly.
931 function specialPagesList() {
932 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
933 require_once('SpecialPage.php');
935 $pages = SpecialPage
::getPages();
937 // special pages without access restriction
938 foreach ( $pages[''] as $name => $page ) {
939 $a[$name] = $page->getDescription();
942 // Other special pages that are restricted.
943 // Copied from SpecialSpecialpages.php
944 foreach($wgAvailableRights as $right) {
945 if( $wgUser->isAllowed($right) ) {
946 /** Add all pages for this right */
947 if(isset($pages[$right])) {
948 foreach($pages[$right] as $name => $page) {
949 $a[$name] = $page->getDescription();
956 $sp = wfMsg( 'specialpages' );
957 $spp = $wgContLang->specialPage( 'Specialpages' );
959 $s = '<form id="specialpages" method="get" class="inline" ' .
960 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
961 $s .= "<select name=\"wpDropdown\">\n";
962 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
965 foreach ( $a as $name => $desc ) {
966 $p = $wgContLang->specialPage( $name );
967 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
970 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
975 function mainPageLink() {
976 $mp = wfMsgForContent( 'mainpage' );
977 $mptxt = wfMsg( 'mainpage');
978 $s = $this->makeKnownLink( $mp, $mptxt );
982 function copyrightLink() {
983 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
984 wfMsg( 'copyrightpagename' ) );
988 function privacyLink() {
989 $privacy = wfMsg( 'privacy' );
990 if ($privacy == '-') {
993 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
997 function aboutLink() {
998 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
999 wfMsg( 'aboutsite' ) );
1003 function disclaimerLink() {
1004 $disclaimers = wfMsg( 'disclaimers' );
1005 if ($disclaimers == '-') {
1008 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1013 function editThisPage() {
1014 global $wgOut, $wgTitle, $wgRequest;
1016 $oldid = $wgRequest->getVal( 'oldid' );
1017 $diff = $wgRequest->getVal( 'diff' );
1018 $redirect = $wgRequest->getVal( 'redirect' );
1020 if ( ! $wgOut->isArticleRelated() ) {
1021 $s = wfMsg( 'protectedpage' );
1023 if ( $wgTitle->userCanEdit() ) {
1024 $t = wfMsg( 'editthispage' );
1026 $t = wfMsg( 'viewsource' );
1030 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1031 if ( $oldid && ! isset( $diff ) ) {
1032 $oid = '&oldid='.$oldid;
1034 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1039 function deleteThisPage() {
1040 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1042 $diff = $wgRequest->getVal( 'diff' );
1043 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1044 $t = wfMsg( 'deletethispage' );
1046 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1053 function protectThisPage() {
1054 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1056 $diff = $wgRequest->getVal( 'diff' );
1057 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1058 if ( $wgTitle->isProtected() ) {
1059 $t = wfMsg( 'unprotectthispage' );
1060 $q = 'action=unprotect';
1062 $t = wfMsg( 'protectthispage' );
1063 $q = 'action=protect';
1065 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1072 function watchThisPage() {
1073 global $wgUser, $wgOut, $wgTitle;
1075 if ( $wgOut->isArticleRelated() ) {
1076 if ( $wgTitle->userIsWatching() ) {
1077 $t = wfMsg( 'unwatchthispage' );
1078 $q = 'action=unwatch';
1080 $t = wfMsg( 'watchthispage' );
1081 $q = 'action=watch';
1083 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1085 $s = wfMsg( 'notanarticle' );
1090 function moveThisPage() {
1093 if ( $wgTitle->userCanMove() ) {
1094 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1095 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1097 // no message if page is protected - would be redundant
1102 function historyLink() {
1105 return $this->makeKnownLinkObj( $wgTitle,
1106 wfMsg( 'history' ), 'action=history' );
1109 function whatLinksHere() {
1112 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1113 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1116 function userContribsLink() {
1119 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1120 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1123 function showEmailUser( $id ) {
1124 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1125 return $wgEnableEmail &&
1126 $wgEnableUserEmail &&
1127 $wgUser->isLoggedIn() && # show only to signed in users
1128 0 != $id; # we can only email to non-anons ..
1129 # '' != $id->getEmail() && # who must have an email address stored ..
1130 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1131 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1134 function emailUserLink() {
1137 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1138 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1141 function watchPageLinksLink() {
1142 global $wgOut, $wgTitle;
1144 if ( ! $wgOut->isArticleRelated() ) {
1145 return '(' . wfMsg( 'notanarticle' ) . ')';
1147 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1148 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1149 'target=' . $wgTitle->getPrefixedURL() );
1153 function trackbackLink() {
1156 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1157 . wfMsg('trackbacklink') . "</a>";
1160 function otherLanguages() {
1161 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1163 if ( $wgHideInterlanguageLinks ) {
1167 $a = $wgOut->getLanguageLinks();
1168 if ( 0 == count( $a ) ) {
1172 $s = wfMsg( 'otherlanguages' ) . ': ';
1174 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1175 foreach( $a as $l ) {
1176 if ( ! $first ) { $s .= ' | '; }
1179 $nt = Title
::newFromText( $l );
1180 $url = $nt->escapeFullURL();
1181 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1183 if ( '' == $text ) { $text = $l; }
1184 $style = $this->getExternalLinkAttributes( $l, $text );
1185 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1187 if($wgContLang->isRTL()) $s .= '</span>';
1191 function bugReportsLink() {
1192 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1193 wfMsg( 'bugreports' ) );
1197 function dateLink() {
1198 global $wgLinkCache;
1199 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1200 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1202 $wgLinkCache->suspend();
1203 $id = $t1->getArticleID();
1204 $wgLinkCache->resume();
1207 $s = $this->makeBrokenLink( $t1->getText() );
1209 $s = $this->makeKnownLink( $t1->getText() );
1213 $wgLinkCache->suspend();
1214 $id = $t2->getArticleID();
1215 $wgLinkCache->resume();
1218 $s .= $this->makeBrokenLink( $t2->getText() );
1220 $s .= $this->makeKnownLink( $t2->getText() );
1225 function talkLink() {
1226 global $wgTitle, $wgLinkCache;
1228 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1229 # No discussion links for special pages
1233 if( $wgTitle->isTalkPage() ) {
1234 $link = $wgTitle->getSubjectPage();
1235 switch( $link->getNamespace() ) {
1237 $text = wfMsg('articlepage');
1240 $text = wfMsg('userpage');
1243 $text = wfMsg('wikipediapage');
1246 $text = wfMsg('imagepage');
1249 $text= wfMsg('articlepage');
1252 $link = $wgTitle->getTalkPage();
1253 $text = wfMsg( 'talkpage' );
1256 $wgLinkCache->suspend();
1257 $s = $this->makeLinkObj( $link, $text );
1258 $wgLinkCache->resume();
1263 function commentLink() {
1264 global $wgContLang, $wgTitle, $wgLinkCache;
1266 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1269 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1270 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1273 /* these are used extensively in SkinPHPTal, but also some other places */
1274 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1275 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1276 return $title->getLocalURL( $urlaction );
1279 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1280 $title = Title
::newFromText( wfMsgForContent($name) );
1281 $this->checkTitle($title, $name);
1282 return $title->getLocalURL( $urlaction );
1285 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1286 $title = Title
::newFromText( $name );
1287 $this->checkTitle($title, $name);
1288 return $title->getLocalURL( $urlaction );
1291 # If url string starts with http, consider as external URL, else
1293 /*static*/ function makeInternalOrExternalUrl( $name ) {
1294 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1297 return $this->makeUrl( $name );
1301 # this can be passed the NS number as defined in Language.php
1302 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1303 $title = Title
::makeTitleSafe( $namespace, $name );
1304 $this->checkTitle($title, $name);
1305 return $title->getLocalURL( $urlaction );
1308 /* these return an array with the 'href' and boolean 'exists' */
1309 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1310 $title = Title
::newFromText( $name );
1311 $this->checkTitle($title, $name);
1313 'href' => $title->getLocalURL( $urlaction ),
1314 'exists' => $title->getArticleID() != 0?
true:false
1319 * Make URL details where the article exists (or at least it's convenient to think so)
1321 function makeKnownUrlDetails( $name, $urlaction='' ) {
1322 $title = Title
::newFromText( $name );
1323 $this->checkTitle($title, $name);
1325 'href' => $title->getLocalURL( $urlaction ),
1330 # make sure we have some title to operate on
1331 /*static*/ function checkTitle ( &$title, &$name ) {
1332 if(!is_object($title)) {
1333 $title = Title
::newFromText( $name );
1334 if(!is_object($title)) {
1335 $title = Title
::newFromText( '--error: link target missing--' );
1341 * Build an array that represents the sidebar(s), the navigation bar among them
1346 function buildSidebar() {
1347 global $wgTitle, $action;
1349 $fname = 'SkinTemplate::buildSidebar';
1350 $pageurl = $wgTitle->getLocalURL();
1351 wfProfileIn( $fname );
1354 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1355 foreach ($lines as $line) {
1356 if (strpos($line, '*') !== 0)
1358 if (strpos($line, '**') !== 0) {
1359 $line = trim($line, '* ');
1362 if (strpos($line, '|') !== false) { // sanity check
1363 $line = explode( '|' , trim($line, '* '), 2 );
1364 $link = wfMsgForContent( $line[0] );
1367 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1369 if (wfEmptyMsg($line[0], $link))
1371 $href = $this->makeInternalOrExternalUrl( $link );
1372 $bar[$heading][] = array(
1375 'id' => 'n-' . strtr($line[1], ' ', '-'),
1376 'active' => $pageurl == $href
1378 } else { continue; }
1382 wfProfileOut( $fname );