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 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
430 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
431 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
434 # optional 'dmoz-like' category browser. Will be shown under the list
435 # of categories an article belong to
436 if($wgUseCategoryBrowser) {
437 $s .= '<br /><hr />';
439 # get a big array of the parents tree
440 $parenttree = $wgTitle->getParentCategoryTree();
441 # Skin object passed by reference cause it can not be
442 # accessed under the method subfunction drawCategoryBrowser
443 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
444 # Clean out bogus first entry and sort them
447 # Output one per line
448 $s .= implode("<br />\n", $tempout);
454 /** Render the array as a serie of links.
455 * @param array $tree Categories tree returned by Title::getParentCategoryTree
456 * @param object &skin Skin passed by reference
457 * @return string separated by >, terminate with "\n"
459 function drawCategoryBrowser($tree, &$skin) {
461 foreach ($tree as $element => $parent) {
462 if (empty($parent)) {
463 # element start a new list
466 # grab the others elements
467 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
469 # add our current element to the list
470 $eltitle = Title
::NewFromText($element);
471 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
476 function getCategories() {
477 $catlinks=$this->getCategoryLinks();
478 if(!empty($catlinks)) {
479 return "<p class='catlinks'>{$catlinks}</p>";
483 function getQuickbarCompensator( $rows = 1 ) {
484 return "<td width='152' rowspan='{$rows}'> </td>";
488 * This gets called immediately before the </body> tag.
489 * @return string HTML to be put after </body> ???
491 function afterContent() {
492 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
493 return $printfooter . $this->doAfterContent();
496 /** @return string Retrievied from HTML text */
497 function printSource() {
499 $url = htmlspecialchars( $wgTitle->getFullURL() );
500 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
503 function printFooter() {
504 return "<p>" . $this->printSource() .
505 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
508 /** overloaded by derived classes */
509 function doAfterContent() { }
511 function pageTitleLinks() {
512 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
514 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
515 $action = $wgRequest->getText( 'action' );
517 $s = $this->printableLink();
518 $disclaimer = $this->disclaimerLink(); # may be empty
520 $s .= ' | ' . $disclaimer;
523 if ( $wgOut->isArticleRelated() ) {
524 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
525 $name = $wgTitle->getDBkey();
526 $image = new Image( $wgTitle );
527 if( $image->exists() ) {
528 $link = htmlspecialchars( $image->getURL() );
529 $style = $this->getInternalLinkAttributes( $link, $name );
530 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
534 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
535 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
536 wfMsg( 'currentrev' ) );
539 if ( $wgUser->getNewtalk() ) {
540 # do not show "You have new messages" text when we are viewing our
543 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
544 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
545 wfMsg('newmessageslink') );
546 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
548 $wgOut->setSquidMaxage(0);
549 $wgOut->enableClientCache(false);
553 $undelete = $this->getUndeleteLink();
554 if( !empty( $undelete ) ) {
555 $s .= ' | '.$undelete;
560 function getUndeleteLink() {
561 global $wgUser, $wgTitle, $wgContLang, $action;
562 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
563 ($n = $wgTitle->isDeleted() ) )
565 if ( $wgUser->isAllowed( 'delete' ) ) {
566 $msg = 'thisisdeleted';
568 $msg = 'viewdeleted';
571 $this->makeKnownLink(
572 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
573 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
578 function printableLink() {
579 global $wgOut, $wgFeedClasses, $wgRequest;
581 $baseurl = $_SERVER['REQUEST_URI'];
582 if( strpos( '?', $baseurl ) == false ) {
587 $baseurl = htmlspecialchars( $baseurl );
588 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
590 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
591 if( $wgOut->isSyndicated() ) {
592 foreach( $wgFeedClasses as $format => $class ) {
593 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
594 $s .= " | <a href=\"$feedurl\">{$format}</a>";
600 function pageTitle() {
601 global $wgOut, $wgTitle, $wgUser;
603 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
607 function pageSubtitle() {
610 $sub = $wgOut->getSubtitle();
612 global $wgExtraSubtitle;
613 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
615 $subpages = $this->subPageSubtitle();
616 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
617 $s = "<p class='subtitle'>{$sub}</p>\n";
621 function subPageSubtitle() {
622 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
624 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
625 $ptext=$wgTitle->getPrefixedText();
626 if(preg_match('/\//',$ptext)) {
627 $links = explode('/',$ptext);
630 foreach($links as $link) {
632 if ($c<count($links)) {
633 $growinglink .= $link;
634 $getlink = $this->makeLink( $growinglink, $link );
635 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
639 $subpages .= '< ';
641 $subpages .= $getlink;
650 function nameAndLogin() {
651 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
653 $li = $wgContLang->specialPage( 'Userlogin' );
654 $lo = $wgContLang->specialPage( 'Userlogout' );
657 if ( $wgUser->isAnon() ) {
658 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
661 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
662 $wgLang->getNsText( NS_TALK
) );
664 $s .= $n . ' ('.$tl.')';
666 $s .= wfMsg('notloggedin');
669 $rt = $wgTitle->getPrefixedURL();
670 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
672 } else { $q = "returnto={$rt}"; }
674 $s .= "\n<br />" . $this->makeKnownLinkObj(
675 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
676 wfMsg( 'login' ), $q );
678 $n = $wgUser->getName();
679 $rt = $wgTitle->getPrefixedURL();
680 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
681 $wgLang->getNsText( NS_TALK
) );
685 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
686 $n ) . "{$tl}<br />" .
687 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
688 "returnto={$rt}" ) . ' | ' .
689 $this->specialLink( 'preferences' );
691 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
697 function getSearchLink() {
698 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
699 return $searchPage->getLocalURL();
702 function escapeSearchLink() {
703 return htmlspecialchars( $this->getSearchLink() );
706 function searchForm() {
708 $search = $wgRequest->getText( 'search' );
710 $s = '<form name="search" class="inline" method="post" action="'
711 . $this->escapeSearchLink() . "\">\n"
712 . '<input type="text" name="search" size="19" value="'
713 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
714 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
715 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
720 function topLinks() {
724 $s = $this->mainPageLink() . $sep
725 . $this->specialLink( 'recentchanges' );
727 if ( $wgOut->isArticleRelated() ) {
728 $s .= $sep . $this->editThisPage()
729 . $sep . $this->historyLink();
731 # Many people don't like this dropdown box
732 #$s .= $sep . $this->specialPagesList();
734 /* show links to different language variants */
735 global $wgDisableLangConversion, $wgContLang, $wgTitle;
736 $variants = $wgContLang->getVariants();
737 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
738 foreach( $variants as $code ) {
739 $varname = $wgContLang->getVariantname( $code );
740 if( $varname == 'disable' )
742 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
749 function bottomLinks() {
750 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
754 if ( $wgOut->isArticleRelated() ) {
755 $s .= '<strong>' . $this->editThisPage() . '</strong>';
756 if ( $wgUser->isLoggedIn() ) {
757 $s .= $sep . $this->watchThisPage();
759 $s .= $sep . $this->talkLink()
760 . $sep . $this->historyLink()
761 . $sep . $this->whatLinksHere()
762 . $sep . $this->watchPageLinksLink();
764 if ($wgUseTrackbacks)
765 $s .= $sep . $this->trackbackLink();
767 if ( $wgTitle->getNamespace() == NS_USER
768 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
771 $id=User
::idFromName($wgTitle->getText());
772 $ip=User
::isIP($wgTitle->getText());
774 if($id ||
$ip) { # both anons and non-anons have contri list
775 $s .= $sep . $this->userContribsLink();
777 if( $this->showEmailUser( $id ) ) {
778 $s .= $sep . $this->emailUserLink();
781 if ( $wgTitle->getArticleId() ) {
783 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
784 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
785 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
787 $s .= "<br />\n" . $this->otherLanguages();
792 function pageStats() {
793 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
794 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
796 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
797 if ( ! $wgOut->isArticle() ) { return ''; }
798 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
799 if ( 0 == $wgArticle->getID() ) { return ''; }
802 if ( !$wgDisableCounters ) {
803 $count = $wgLang->formatNum( $wgArticle->getCount() );
805 $s = wfMsg( 'viewcount', $count );
809 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
810 require_once('Credits.php');
811 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
813 $s .= $this->lastModified();
816 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
817 $dbr =& wfGetDB( DB_SLAVE
);
818 extract( $dbr->tableNames( 'watchlist' ) );
819 $sql = "SELECT COUNT(*) AS n FROM $watchlist
820 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
821 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
822 $res = $dbr->query( $sql, 'Skin::pageStats');
823 $x = $dbr->fetchObject( $res );
824 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
827 return $s . ' ' . $this->getCopyright();
830 function getCopyright() {
831 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
834 $oldid = $wgRequest->getVal( 'oldid' );
835 $diff = $wgRequest->getVal( 'diff' );
837 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
838 $msg = 'history_copyright';
844 if( $wgRightsPage ) {
845 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
846 } elseif( $wgRightsUrl ) {
847 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
852 $out .= wfMsgForContent( $msg, $link );
856 function getCopyrightIcon() {
857 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
859 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
860 $out = $wgCopyrightIcon;
861 } else if ( $wgRightsIcon ) {
862 $icon = htmlspecialchars( $wgRightsIcon );
863 if ( $wgRightsUrl ) {
864 $url = htmlspecialchars( $wgRightsUrl );
865 $out .= '<a href="'.$url.'">';
867 $text = htmlspecialchars( $wgRightsText );
868 $out .= "<img src=\"$icon\" alt='$text' />";
869 if ( $wgRightsUrl ) {
876 function getPoweredBy() {
878 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
879 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
883 function lastModified() {
884 global $wgLang, $wgArticle, $wgLoadBalancer;
886 $timestamp = $wgArticle->getTimestamp();
888 $d = $wgLang->timeanddate( $timestamp, true );
889 $s = ' ' . wfMsg( 'lastmodified', $d );
893 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
894 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
899 function logoText( $align = '' ) {
900 if ( '' != $align ) { $a = " align='{$align}'"; }
903 $mp = wfMsg( 'mainpage' );
904 $titleObj = Title
::newFromText( $mp );
905 if ( is_object( $titleObj ) ) {
906 $url = $titleObj->escapeLocalURL();
911 $logourl = $this->getLogo();
912 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
917 * show a drop-down box of special pages
918 * @TODO crash bug913. Need to be rewrote completly.
920 function specialPagesList() {
921 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
922 require_once('SpecialPage.php');
924 $pages = SpecialPage
::getPages();
926 // special pages without access restriction
927 foreach ( $pages[''] as $name => $page ) {
928 $a[$name] = $page->getDescription();
931 // Other special pages that are restricted.
932 // Copied from SpecialSpecialpages.php
933 foreach($wgAvailableRights as $right) {
934 if( $wgUser->isAllowed($right) ) {
935 /** Add all pages for this right */
936 if(isset($pages[$right])) {
937 foreach($pages[$right] as $name => $page) {
938 $a[$name] = $page->getDescription();
945 $sp = wfMsg( 'specialpages' );
946 $spp = $wgContLang->specialPage( 'Specialpages' );
948 $s = '<form id="specialpages" method="get" class="inline" ' .
949 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
950 $s .= "<select name=\"wpDropdown\">\n";
951 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
954 foreach ( $a as $name => $desc ) {
955 $p = $wgContLang->specialPage( $name );
956 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
959 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
964 function mainPageLink() {
965 $mp = wfMsgForContent( 'mainpage' );
966 $mptxt = wfMsg( 'mainpage');
967 $s = $this->makeKnownLink( $mp, $mptxt );
971 function copyrightLink() {
972 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
973 wfMsg( 'copyrightpagename' ) );
977 function aboutLink() {
978 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
979 wfMsg( 'aboutsite' ) );
984 function disclaimerLink() {
985 $disclaimers = wfMsg( 'disclaimers' );
986 if ($disclaimers == '-') {
989 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
994 function editThisPage() {
995 global $wgOut, $wgTitle, $wgRequest;
997 $oldid = $wgRequest->getVal( 'oldid' );
998 $diff = $wgRequest->getVal( 'diff' );
999 $redirect = $wgRequest->getVal( 'redirect' );
1001 if ( ! $wgOut->isArticleRelated() ) {
1002 $s = wfMsg( 'protectedpage' );
1004 if ( $wgTitle->userCanEdit() ) {
1005 $t = wfMsg( 'editthispage' );
1007 $t = wfMsg( 'viewsource' );
1011 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1012 if ( $oldid && ! isset( $diff ) ) {
1013 $oid = '&oldid='.$oldid;
1015 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1020 function deleteThisPage() {
1021 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1023 $diff = $wgRequest->getVal( 'diff' );
1024 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1025 $t = wfMsg( 'deletethispage' );
1027 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1034 function protectThisPage() {
1035 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1037 $diff = $wgRequest->getVal( 'diff' );
1038 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1039 if ( $wgTitle->isProtected() ) {
1040 $t = wfMsg( 'unprotectthispage' );
1041 $q = 'action=unprotect';
1043 $t = wfMsg( 'protectthispage' );
1044 $q = 'action=protect';
1046 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1053 function watchThisPage() {
1054 global $wgUser, $wgOut, $wgTitle;
1056 if ( $wgOut->isArticleRelated() ) {
1057 if ( $wgTitle->userIsWatching() ) {
1058 $t = wfMsg( 'unwatchthispage' );
1059 $q = 'action=unwatch';
1061 $t = wfMsg( 'watchthispage' );
1062 $q = 'action=watch';
1064 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1066 $s = wfMsg( 'notanarticle' );
1071 function moveThisPage() {
1074 if ( $wgTitle->userCanMove() ) {
1075 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1076 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1078 // no message if page is protected - would be redundant
1083 function historyLink() {
1086 return $this->makeKnownLinkObj( $wgTitle,
1087 wfMsg( 'history' ), 'action=history' );
1090 function whatLinksHere() {
1093 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1094 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1097 function userContribsLink() {
1100 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1101 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1104 function showEmailUser( $id ) {
1105 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1106 return $wgEnableEmail &&
1107 $wgEnableUserEmail &&
1108 $wgUser->isLoggedIn() && # show only to signed in users
1109 0 != $id; # we can only email to non-anons ..
1110 # '' != $id->getEmail() && # who must have an email address stored ..
1111 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1112 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1115 function emailUserLink() {
1118 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1119 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1122 function watchPageLinksLink() {
1123 global $wgOut, $wgTitle;
1125 if ( ! $wgOut->isArticleRelated() ) {
1126 return '(' . wfMsg( 'notanarticle' ) . ')';
1128 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1129 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1130 'target=' . $wgTitle->getPrefixedURL() );
1134 function trackbackLink() {
1137 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1138 . wfMsg('trackbacklink') . "</a>";
1141 function otherLanguages() {
1142 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1144 if ( $wgHideInterlanguageLinks ) {
1148 $a = $wgOut->getLanguageLinks();
1149 if ( 0 == count( $a ) ) {
1153 $s = wfMsg( 'otherlanguages' ) . ': ';
1155 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1156 foreach( $a as $l ) {
1157 if ( ! $first ) { $s .= ' | '; }
1160 $nt = Title
::newFromText( $l );
1161 $url = $nt->escapeFullURL();
1162 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1164 if ( '' == $text ) { $text = $l; }
1165 $style = $this->getExternalLinkAttributes( $l, $text );
1166 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1168 if($wgContLang->isRTL()) $s .= '</span>';
1172 function bugReportsLink() {
1173 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1174 wfMsg( 'bugreports' ) );
1178 function dateLink() {
1179 global $wgLinkCache;
1180 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1181 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1183 $wgLinkCache->suspend();
1184 $id = $t1->getArticleID();
1185 $wgLinkCache->resume();
1188 $s = $this->makeBrokenLink( $t1->getText() );
1190 $s = $this->makeKnownLink( $t1->getText() );
1194 $wgLinkCache->suspend();
1195 $id = $t2->getArticleID();
1196 $wgLinkCache->resume();
1199 $s .= $this->makeBrokenLink( $t2->getText() );
1201 $s .= $this->makeKnownLink( $t2->getText() );
1206 function talkLink() {
1207 global $wgTitle, $wgLinkCache;
1209 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1210 # No discussion links for special pages
1214 if( $wgTitle->isTalkPage() ) {
1215 $link = $wgTitle->getSubjectPage();
1216 switch( $link->getNamespace() ) {
1218 $text = wfMsg('articlepage');
1221 $text = wfMsg('userpage');
1224 $text = wfMsg('wikipediapage');
1227 $text = wfMsg('imagepage');
1230 $text= wfMsg('articlepage');
1233 $link = $wgTitle->getTalkPage();
1234 $text = wfMsg( 'talkpage' );
1237 $wgLinkCache->suspend();
1238 $s = $this->makeLinkObj( $link, $text );
1239 $wgLinkCache->resume();
1244 function commentLink() {
1245 global $wgContLang, $wgTitle, $wgLinkCache;
1247 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1250 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1251 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1254 /* these are used extensively in SkinPHPTal, but also some other places */
1255 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1256 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1257 return $title->getLocalURL( $urlaction );
1260 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1261 $title = Title
::newFromText( wfMsgForContent($name) );
1262 $this->checkTitle($title, $name);
1263 return $title->getLocalURL( $urlaction );
1266 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1267 $title = Title
::newFromText( $name );
1268 $this->checkTitle($title, $name);
1269 return $title->getLocalURL( $urlaction );
1272 # If url string starts with http, consider as external URL, else
1274 /*static*/ function makeInternalOrExternalUrl( $name ) {
1275 global $wgUrlProtocols;
1276 if ( preg_match( '/^(?:' . $wgUrlProtocols . ')/', $name ) ) {
1279 return $this->makeUrl( $name );
1283 # this can be passed the NS number as defined in Language.php
1284 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1285 $title = Title
::makeTitleSafe( $namespace, $name );
1286 $this->checkTitle($title, $name);
1287 return $title->getLocalURL( $urlaction );
1290 /* these return an array with the 'href' and boolean 'exists' */
1291 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1292 $title = Title
::newFromText( $name );
1293 $this->checkTitle($title, $name);
1295 'href' => $title->getLocalURL( $urlaction ),
1296 'exists' => $title->getArticleID() != 0?
true:false
1301 * Make URL details where the article exists (or at least it's convenient to think so)
1303 function makeKnownUrlDetails( $name, $urlaction='' ) {
1304 $title = Title
::newFromText( $name );
1305 $this->checkTitle($title, $name);
1307 'href' => $title->getLocalURL( $urlaction ),
1312 # make sure we have some title to operate on
1313 /*static*/ function checkTitle ( &$title, &$name ) {
1314 if(!is_object($title)) {
1315 $title = Title
::newFromText( $name );
1316 if(!is_object($title)) {
1317 $title = Title
::newFromText( '--error: link target missing--' );
1323 * Build an array that represents the sidebar(s), the navigation bar among them
1328 function buildSidebar() {
1329 global $wgTitle, $action;
1331 $fname = 'SkinTemplate::buildSidebar';
1332 $pageurl = $wgTitle->getLocalURL();
1333 wfProfileIn( $fname );
1336 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1337 foreach ($lines as $line) {
1338 if (strpos($line, '*') !== 0)
1340 if (strpos($line, '**') !== 0) {
1341 $line = trim($line, '* ');
1344 if (strpos($line, '|') !== false) { // sanity check
1345 $line = explode( '|' , trim($line, '* '), 2 );
1346 $link = wfMsgForContent( $line[0] );
1349 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1351 if (wfEmptyMsg($line[0], $link))
1353 $href = $this->makeInternalOrExternalUrl( $link );
1354 $bar[$heading][] = array(
1357 'id' => 'n-' . strtr($line[1], ' ', '-'),
1358 'active' => $pageurl == $href
1360 } else { continue; }
1364 wfProfileOut( $fname );