b6405a3dbb77250c8eadaffd3d1eb74be6bfea78
10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Linker.php' );
16 require_once( 'Image.php' );
18 # Get a list of all skins available in /skins/
19 # Build using the regular expression '^(.*).php$'
20 # Array keys are all lower case, array value keep the case used by filename
23 $skinDir = dir($IP.'/skins');
25 # while code from www.php.net
26 while (false !== ($file = $skinDir->read())) {
27 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
29 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
35 require_once( 'RecentChange.php' );
41 class RCCacheEntry
extends RecentChange
43 var $secureName, $link;
44 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
45 var $userlink, $timestamp, $watched;
47 function newFromParent( $rc )
49 $rc2 = new RCCacheEntry
;
50 $rc2->mAttribs
= $rc->mAttribs
;
51 $rc2->mExtra
= $rc->mExtra
;
58 * The main skin class that provide methods and properties for all other skins
59 * including PHPTal skins.
60 * This base class is also the "Standard" skin.
63 class Skin
extends Linker
{
67 var $lastdate, $lastline;
68 var $rc_cache ; # Cache for Enhanced Recent Changes
69 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
73 /** Constructor, call parent constructor */
74 function Skin() { parent
::Linker(); }
76 function getSkinNames() {
77 global $wgValidSkinNames;
78 return $wgValidSkinNames;
81 /** @return string path to the skin stylesheet */
82 function getStylesheet() { return 'common/wikistandard.css'; }
84 /** @return string skin name */
85 function getSkinName() {
89 function qbSetting() {
90 global $wgOut, $wgUser;
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
104 $this->addMetadataLinks($out);
106 wfProfileOut( $fname );
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl;
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
129 if( $wgRightsPage ) {
130 $copy = Title
::newFromText( $wgRightsPage );
132 $copyright = $copy->getLocalURL();
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
145 function outputPage( &$out ) {
146 global $wgDebugComments;
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
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;
258 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
259 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
261 return $s . $this->reallyDoGetUserStyles();
264 function reallyDoGetUserStyles() {
267 $underline = $wgUser->getOption( "underline" ) ?
'underline' : 'none';
268 $s .= "a { text-decoration: $underline; }\n";
269 if( $wgUser->getOption( 'highlightbroken' ) ) {
270 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
273 a.new, #quickbar a.new,
274 a.stub, #quickbar a.stub {
276 text-decoration: inherit;
278 a.new:after, #quickbar a.new:after {
281 text-decoration: $underline;
283 a.stub:after, #quickbar a.stub:after {
286 text-decoration: $underline;
290 if( $wgUser->getOption( 'justify' ) ) {
291 $s .= "#article, #bodyContent { text-align: justify; }\n";
293 if( !$wgUser->getOption( 'showtoc' ) ) {
294 $s .= "#toc { display: none; }\n";
296 if( !$wgUser->getOption( 'editsection' ) ) {
297 $s .= ".editsection { display: none; }\n";
302 function getBodyOptions() {
303 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
305 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
307 if ( 0 != $wgTitle->getNamespace() ) {
308 $a = array( 'bgcolor' => '#ffffec' );
310 else $a = array( 'bgcolor' => '#FFFFFF' );
311 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
312 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
313 $t = wfMsg( 'editthispage' );
315 if ( !empty($redirect) && $redirect == 'no' ) {
316 $red = "&redirect={$redirect}";
318 if ( !empty($oldid) && ! isset( $diff ) ) {
319 $oid = "&oldid=" . IntVal( $oldid );
321 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
322 $s = 'document.location = "' .$s .'";';
323 $a +
= array ('ondblclick' => $s);
326 $a['onload'] = $wgOut->getOnloadHandler();
327 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
328 if( $a['onload'] != '' ) {
331 $a['onload'] .= 'setupRightClickEdit()';
345 * This will be called immediately after the <body> tag. Split into
346 * two functions to make it easier to subclass.
348 function beforeContent() {
349 return $this->doBeforeContent();
352 function doBeforeContent() {
353 global $wgOut, $wgTitle, $wgContLang;
354 $fname = 'Skin::doBeforeContent';
355 wfProfileIn( $fname );
358 $qb = $this->qbSetting();
360 if( $langlinks = $this->otherLanguages() ) {
366 $borderhack = 'class="top"';
369 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
370 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
373 $left = ($qb == 1 ||
$qb == 3);
374 if($wgContLang->isRTL()) $left = !$left;
377 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
378 $this->logoText() . '</td>';
380 $s .= $this->getQuickbarCompensator( $rows );
382 $l = $wgContLang->isRTL() ?
'right' : 'left';
383 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
385 $s .= $this->topLinks() ;
386 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
388 $r = $wgContLang->isRTL() ?
"left" : "right";
389 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
390 $s .= $this->nameAndLogin();
391 $s .= "\n<br />" . $this->searchForm() . "</td>";
394 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
397 if ( $shove && !$left ) { # Right
398 $s .= $this->getQuickbarCompensator( $rows );
400 $s .= "</tr>\n</table>\n</div>\n";
401 $s .= "\n<div id='article'>\n";
403 $notice = wfGetSiteNotice();
405 $s .= "\n<div id='siteNotice'>$notice</div>\n";
407 $s .= $this->pageTitle();
408 $s .= $this->pageSubtitle() ;
409 $s .= $this->getCategories();
410 wfProfileOut( $fname );
415 function getCategoryLinks () {
416 global $wgOut, $wgTitle, $wgParser;
417 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
419 if( !$wgUseCategoryMagic ) return '' ;
420 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
422 # Taken out so that they will be displayed in previews -- TS
423 #if( !$wgOut->isArticle() ) return '';
425 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
426 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
427 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
430 # optional 'dmoz-like' category browser. Will be shown under the list
431 # of categories an article belong to
432 if($wgUseCategoryBrowser) {
433 $s .= '<br /><hr />';
435 # get a big array of the parents tree
436 $parenttree = $wgTitle->getParentCategoryTree();
438 # Skin object passed by reference cause it can not be
439 # accessed under the method subfunction walkThrough.
440 $s .= Skin
::drawCategoryBrowser($parenttree, $this);
446 # Render the array as a serie of links
447 function drawCategoryBrowser ($tree, &$skin) {
449 foreach ($tree as $element => $parent) {
450 if (empty($parent)) {
451 # element start a new list
454 # grab the others elements
455 $return .= Skin
::drawCategoryBrowser($parent, $skin);
457 # add our current element to the list
458 $eltitle = Title
::NewFromText($element);
459 if (!empty($parent)) $return .= ' > ';
460 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
465 function getCategories() {
466 $catlinks=$this->getCategoryLinks();
467 if(!empty($catlinks)) {
468 return "<p class='catlinks'>{$catlinks}</p>";
472 function getQuickbarCompensator( $rows = 1 ) {
473 return "<td width='152' rowspan='{$rows}'> </td>";
477 * This gets called immediately before the </body> tag.
478 * @return string HTML to be put after </body> ???
480 function afterContent() {
481 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
482 return $printfooter . $this->doAfterContent();
485 /** @return string Retrievied from HTML text */
486 function printSource() {
488 $url = htmlspecialchars( $wgTitle->getFullURL() );
489 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
492 function printFooter() {
493 return "<p>" . $this->printSource() .
494 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
497 /** overloaded by derived classes */
498 function doAfterContent() { }
500 function pageTitleLinks() {
501 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
503 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
504 $action = $wgRequest->getText( 'action' );
506 $s = $this->printableLink();
507 $disclaimer = $this->disclaimerLink(); # may be empty
509 $s .= ' | ' . $disclaimer;
512 if ( $wgOut->isArticleRelated() ) {
513 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
514 $name = $wgTitle->getDBkey();
515 $image = new Image( $wgTitle );
516 if( $image->exists() ) {
517 $link = htmlspecialchars( $image->getURL() );
518 $style = $this->getInternalLinkAttributes( $link, $name );
519 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
523 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
524 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
525 wfMsg( 'currentrev' ) );
528 if ( $wgUser->getNewtalk() ) {
529 # do not show "You have new messages" text when we are viewing our
532 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
533 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
534 wfMsg('newmessageslink') );
535 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
537 $wgOut->setSquidMaxage(0);
538 $wgOut->enableClientCache(false);
542 $undelete = $this->getUndeleteLink();
543 if( !empty( $undelete ) ) {
544 $s .= ' | '.$undelete;
549 function getUndeleteLink() {
550 global $wgUser, $wgTitle, $wgContLang, $action;
551 if( $wgUser->isAllowed('rollback') &&
552 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
553 ($n = $wgTitle->isDeleted() ) ) {
554 return wfMsg( 'thisisdeleted',
555 $this->makeKnownLink(
556 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
557 wfMsg( 'restorelink', $n ) ) );
562 function printableLink() {
563 global $wgOut, $wgFeedClasses, $wgRequest;
565 $baseurl = $_SERVER['REQUEST_URI'];
566 if( strpos( '?', $baseurl ) == false ) {
571 $baseurl = htmlspecialchars( $baseurl );
572 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
574 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
575 if( $wgOut->isSyndicated() ) {
576 foreach( $wgFeedClasses as $format => $class ) {
577 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
578 $s .= " | <a href=\"$feedurl\">{$format}</a>";
584 function pageTitle() {
585 global $wgOut, $wgTitle, $wgUser;
587 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
591 function pageSubtitle() {
594 $sub = $wgOut->getSubtitle();
596 global $wgExtraSubtitle;
597 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
599 $subpages = $this->subPageSubtitle();
600 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
601 $s = "<p class='subtitle'>{$sub}</p>\n";
605 function subPageSubtitle() {
606 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
608 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
609 $ptext=$wgTitle->getPrefixedText();
610 if(preg_match('/\//',$ptext)) {
611 $links = explode('/',$ptext);
614 foreach($links as $link) {
616 if ($c<count($links)) {
617 $growinglink .= $link;
618 $getlink = $this->makeLink( $growinglink, $link );
619 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
623 $subpages .= '< ';
625 $subpages .= $getlink;
634 function nameAndLogin() {
635 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
637 $li = $wgContLang->specialPage( 'Userlogin' );
638 $lo = $wgContLang->specialPage( 'Userlogout' );
641 if ( $wgUser->isAnon() ) {
642 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
645 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
646 $wgContLang->getNsText( NS_TALK
) );
648 $s .= $n . ' ('.$tl.')';
650 $s .= wfMsg('notloggedin');
653 $rt = $wgTitle->getPrefixedURL();
654 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
656 } else { $q = "returnto={$rt}"; }
658 $s .= "\n<br />" . $this->makeKnownLinkObj(
659 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
660 wfMsg( 'login' ), $q );
662 $n = $wgUser->getName();
663 $rt = $wgTitle->getPrefixedURL();
664 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
665 $wgContLang->getNsText( NS_TALK
) );
669 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
670 $n ) . "{$tl}<br />" .
671 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
672 "returnto={$rt}" ) . ' | ' .
673 $this->specialLink( 'preferences' );
675 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
681 function getSearchLink() {
682 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
683 return $searchPage->getLocalURL();
686 function escapeSearchLink() {
687 return htmlspecialchars( $this->getSearchLink() );
690 function searchForm() {
692 $search = $wgRequest->getText( 'search' );
694 $s = '<form name="search" class="inline" method="post" action="'
695 . $this->escapeSearchLink() . "\">\n"
696 . '<input type="text" name="search" size="19" value="'
697 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
698 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
699 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
704 function topLinks() {
708 $s = $this->mainPageLink() . $sep
709 . $this->specialLink( 'recentchanges' );
711 if ( $wgOut->isArticleRelated() ) {
712 $s .= $sep . $this->editThisPage()
713 . $sep . $this->historyLink();
715 # Many people don't like this dropdown box
716 #$s .= $sep . $this->specialPagesList();
718 /* show links to different language variants */
719 global $wgDisableLangConversion, $wgContLang, $wgTitle;
720 $variants = $wgContLang->getVariants();
721 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
722 foreach( $variants as $code ) {
723 $varname = $wgContLang->getVariantname( $code );
724 if( $varname == 'disable' )
726 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
733 function bottomLinks() {
734 global $wgOut, $wgUser, $wgTitle;
738 if ( $wgOut->isArticleRelated() ) {
739 $s .= '<strong>' . $this->editThisPage() . '</strong>';
740 if ( $wgUser->isLoggedIn() ) {
741 $s .= $sep . $this->watchThisPage();
743 $s .= $sep . $this->talkLink()
744 . $sep . $this->historyLink()
745 . $sep . $this->whatLinksHere()
746 . $sep . $this->watchPageLinksLink();
748 if ( $wgTitle->getNamespace() == NS_USER
749 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
752 $id=User
::idFromName($wgTitle->getText());
753 $ip=User
::isIP($wgTitle->getText());
755 if($id ||
$ip) { # both anons and non-anons have contri list
756 $s .= $sep . $this->userContribsLink();
758 if( $this->showEmailUser( $id ) ) {
759 $s .= $sep . $this->emailUserLink();
762 if ( $wgTitle->getArticleId() ) {
764 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
765 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
766 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
768 $s .= "<br />\n" . $this->otherLanguages();
773 function pageStats() {
774 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
775 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
777 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
778 if ( ! $wgOut->isArticle() ) { return ''; }
779 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
780 if ( 0 == $wgArticle->getID() ) { return ''; }
783 if ( !$wgDisableCounters ) {
784 $count = $wgLang->formatNum( $wgArticle->getCount() );
786 $s = wfMsg( 'viewcount', $count );
790 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
791 require_once('Credits.php');
792 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
794 $s .= $this->lastModified();
797 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
798 $dbr =& wfGetDB( DB_SLAVE
);
799 extract( $dbr->tableNames( 'watchlist' ) );
800 $sql = "SELECT COUNT(*) AS n FROM $watchlist
801 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
802 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
803 $res = $dbr->query( $sql, 'Skin::pageStats');
804 $x = $dbr->fetchObject( $res );
805 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
808 return $s . ' ' . $this->getCopyright();
811 function getCopyright() {
812 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
815 $oldid = $wgRequest->getVal( 'oldid' );
816 $diff = $wgRequest->getVal( 'diff' );
818 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
819 $msg = 'history_copyright';
825 if( $wgRightsPage ) {
826 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
827 } elseif( $wgRightsUrl ) {
828 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
833 $out .= wfMsgForContent( $msg, $link );
837 function getCopyrightIcon() {
838 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
840 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
841 $out = $wgCopyrightIcon;
842 } else if ( $wgRightsIcon ) {
843 $icon = htmlspecialchars( $wgRightsIcon );
844 if ( $wgRightsUrl ) {
845 $url = htmlspecialchars( $wgRightsUrl );
846 $out .= '<a href="'.$url.'">';
848 $text = htmlspecialchars( $wgRightsText );
849 $out .= "<img src=\"$icon\" alt='$text' />";
850 if ( $wgRightsUrl ) {
857 function getPoweredBy() {
859 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
860 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
864 function lastModified() {
865 global $wgLang, $wgArticle, $wgLoadBalancer;
867 $timestamp = $wgArticle->getTimestamp();
869 $d = $wgLang->timeanddate( $timestamp, true );
870 $s = ' ' . wfMsg( 'lastmodified', $d );
874 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
875 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
880 function logoText( $align = '' ) {
881 if ( '' != $align ) { $a = " align='{$align}'"; }
884 $mp = wfMsg( 'mainpage' );
885 $titleObj = Title
::newFromText( $mp );
886 if ( is_object( $titleObj ) ) {
887 $url = $titleObj->escapeLocalURL();
892 $logourl = $this->getLogo();
893 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
898 * show a drop-down box of special pages
899 * @TODO crash bug913. Need to be rewrote completly.
901 function specialPagesList() {
902 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
903 require_once('SpecialPage.php');
905 $pages = SpecialPage
::getPages();
907 // special pages without access restriction
908 foreach ( $pages[''] as $name => $page ) {
909 $a[$name] = $page->getDescription();
912 // Other special pages that are restricted.
913 // Copied from SpecialSpecialpages.php
914 foreach($wgAvailableRights as $right) {
915 if( $wgUser->isAllowed($right) ) {
916 /** Add all pages for this right */
917 if(isset($pages[$right])) {
918 foreach($pages[$right] as $name => $page) {
919 $a[$name] = $page->getDescription();
926 $sp = wfMsg( 'specialpages' );
927 $spp = $wgContLang->specialPage( 'Specialpages' );
929 $s = '<form id="specialpages" method="get" class="inline" ' .
930 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
931 $s .= "<select name=\"wpDropdown\">\n";
932 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
935 foreach ( $a as $name => $desc ) {
936 $p = $wgContLang->specialPage( $name );
937 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
940 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
945 function mainPageLink() {
946 $mp = wfMsgForContent( 'mainpage' );
947 $mptxt = wfMsg( 'mainpage');
948 $s = $this->makeKnownLink( $mp, $mptxt );
952 function copyrightLink() {
953 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
954 wfMsg( 'copyrightpagename' ) );
958 function aboutLink() {
959 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
960 wfMsg( 'aboutsite' ) );
965 function disclaimerLink() {
966 $disclaimers = wfMsg( 'disclaimers' );
967 if ($disclaimers == '-') {
970 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
975 function editThisPage() {
976 global $wgOut, $wgTitle, $wgRequest;
978 $oldid = $wgRequest->getVal( 'oldid' );
979 $diff = $wgRequest->getVal( 'diff' );
980 $redirect = $wgRequest->getVal( 'redirect' );
982 if ( ! $wgOut->isArticleRelated() ) {
983 $s = wfMsg( 'protectedpage' );
985 if ( $wgTitle->userCanEdit() ) {
986 $t = wfMsg( 'editthispage' );
988 $t = wfMsg( 'viewsource' );
992 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
993 if ( $oldid && ! isset( $diff ) ) {
994 $oid = '&oldid='.$oldid;
996 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1001 function deleteThisPage() {
1002 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1004 $diff = $wgRequest->getVal( 'diff' );
1005 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1006 $t = wfMsg( 'deletethispage' );
1008 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1015 function protectThisPage() {
1016 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1018 $diff = $wgRequest->getVal( 'diff' );
1019 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1020 if ( $wgTitle->isProtected() ) {
1021 $t = wfMsg( 'unprotectthispage' );
1022 $q = 'action=unprotect';
1024 $t = wfMsg( 'protectthispage' );
1025 $q = 'action=protect';
1027 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1034 function watchThisPage() {
1035 global $wgUser, $wgOut, $wgTitle;
1037 if ( $wgOut->isArticleRelated() ) {
1038 if ( $wgTitle->userIsWatching() ) {
1039 $t = wfMsg( 'unwatchthispage' );
1040 $q = 'action=unwatch';
1042 $t = wfMsg( 'watchthispage' );
1043 $q = 'action=watch';
1045 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1047 $s = wfMsg( 'notanarticle' );
1052 function moveThisPage() {
1055 if ( $wgTitle->userCanMove() ) {
1056 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1057 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1059 // no message if page is protected - would be redundant
1064 function historyLink() {
1067 return $this->makeKnownLinkObj( $wgTitle,
1068 wfMsg( 'history' ), 'action=history' );
1071 function whatLinksHere() {
1074 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1075 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1078 function userContribsLink() {
1081 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1082 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1085 function showEmailUser( $id ) {
1086 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1087 return $wgEnableEmail &&
1088 $wgEnableUserEmail &&
1089 $wgUser->isLoggedIn() && # show only to signed in users
1090 0 != $id; # we can only email to non-anons ..
1091 # '' != $id->getEmail() && # who must have an email address stored ..
1092 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1093 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1096 function emailUserLink() {
1099 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1100 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1103 function watchPageLinksLink() {
1104 global $wgOut, $wgTitle;
1106 if ( ! $wgOut->isArticleRelated() ) {
1107 return '(' . wfMsg( 'notanarticle' ) . ')';
1109 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1110 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1111 'target=' . $wgTitle->getPrefixedURL() );
1115 function otherLanguages() {
1116 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1118 if ( $wgHideInterlanguageLinks ) {
1122 $a = $wgOut->getLanguageLinks();
1123 if ( 0 == count( $a ) ) {
1127 $s = wfMsg( 'otherlanguages' ) . ': ';
1129 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1130 foreach( $a as $l ) {
1131 if ( ! $first ) { $s .= ' | '; }
1134 $nt = Title
::newFromText( $l );
1135 $url = $nt->escapeFullURL();
1136 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1138 if ( '' == $text ) { $text = $l; }
1139 $style = $this->getExternalLinkAttributes( $l, $text );
1140 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1142 if($wgContLang->isRTL()) $s .= '</span>';
1146 function bugReportsLink() {
1147 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1148 wfMsg( 'bugreports' ) );
1152 function dateLink() {
1153 global $wgLinkCache;
1154 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1155 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1157 $wgLinkCache->suspend();
1158 $id = $t1->getArticleID();
1159 $wgLinkCache->resume();
1162 $s = $this->makeBrokenLink( $t1->getText() );
1164 $s = $this->makeKnownLink( $t1->getText() );
1168 $wgLinkCache->suspend();
1169 $id = $t2->getArticleID();
1170 $wgLinkCache->resume();
1173 $s .= $this->makeBrokenLink( $t2->getText() );
1175 $s .= $this->makeKnownLink( $t2->getText() );
1180 function talkLink() {
1181 global $wgTitle, $wgLinkCache;
1183 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1184 # No discussion links for special pages
1188 if( $wgTitle->isTalkPage() ) {
1189 $link = $wgTitle->getSubjectPage();
1190 switch( $link->getNamespace() ) {
1192 $text = wfMsg('articlepage');
1195 $text = wfMsg('userpage');
1198 $text = wfMsg('wikipediapage');
1201 $text = wfMsg('imagepage');
1204 $text= wfMsg('articlepage');
1207 $link = $wgTitle->getTalkPage();
1208 $text = wfMsg( 'talkpage' );
1211 $wgLinkCache->suspend();
1212 $s = $this->makeLinkObj( $link, $text );
1213 $wgLinkCache->resume();
1218 function commentLink() {
1219 global $wgContLang, $wgTitle, $wgLinkCache;
1221 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1224 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1225 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1228 /* these are used extensively in SkinPHPTal, but also some other places */
1229 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1230 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1231 return $title->getLocalURL( $urlaction );
1234 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1235 $title = Title
::newFromText( wfMsgForContent($name) );
1236 $this->checkTitle($title, $name);
1237 return $title->getLocalURL( $urlaction );
1240 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1241 $title = Title
::newFromText( $name );
1242 $this->checkTitle($title, $name);
1243 return $title->getLocalURL( $urlaction );
1246 # If url string starts with http, consider as external URL, else
1248 /*static*/ function makeInternalOrExternalUrl( $name ) {
1249 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1252 return $this->makeUrl( $name );
1256 # this can be passed the NS number as defined in Language.php
1257 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1258 $title = Title
::makeTitleSafe( $namespace, $name );
1259 $this->checkTitle($title, $name);
1260 return $title->getLocalURL( $urlaction );
1263 /* these return an array with the 'href' and boolean 'exists' */
1264 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1265 $title = Title
::newFromText( $name );
1266 $this->checkTitle($title, $name);
1268 'href' => $title->getLocalURL( $urlaction ),
1269 'exists' => $title->getArticleID() != 0?
true:false
1273 # make sure we have some title to operate on
1274 /*static*/ function checkTitle ( &$title, &$name ) {
1275 if(!is_object($title)) {
1276 $title = Title
::newFromText( $name );
1277 if(!is_object($title)) {
1278 $title = Title
::newFromText( '--error: link target missing--' );
1284 * Build an array that represents the sidebar(s), the navigation bar among them
1289 function buildSidebar() {
1290 $fname = 'SkinTemplate::buildSidebar';
1291 wfProfileIn( $fname );
1294 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1295 foreach ($lines as $line) {
1296 if (strpos($line, '*') !== 0)
1298 if (strpos($line, '**') !== 0) {
1299 $line = trim($line, '* ');
1302 if (strpos($line, '|') !== false) { // sanity check
1303 $line = explode( '|' , trim($line, '* '), 2 );
1304 $link = wfMsgForContent( $line[0] );
1307 $bar[$heading][] = array(
1308 'text' => wfMsg( $line[1] ),
1309 'href' => $this->makeInternalOrExternalUrl( $link ),
1310 'id' => 'n-' . $line[1],
1312 } else { continue; }
1316 wfProfileOut( $fname );