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' );
37 global $wgLinkHolders;
38 $wgLinkHolders = array(
39 'namespaces' => array(),
45 global $wgInterwikiLinkHolders;
46 $wgInterwikiLinkHolders = array();
52 class RCCacheEntry
extends RecentChange
54 var $secureName, $link;
55 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
56 var $userlink, $timestamp, $watched;
58 function newFromParent( $rc )
60 $rc2 = new RCCacheEntry
;
61 $rc2->mAttribs
= $rc->mAttribs
;
62 $rc2->mExtra
= $rc->mExtra
;
69 * The main skin class that provide methods and properties for all other skins
70 * including PHPTal skins.
71 * This base class is also the "Standard" skin.
74 class Skin
extends Linker
{
78 var $lastdate, $lastline;
79 var $rc_cache ; # Cache for Enhanced Recent Changes
80 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
84 /** Constructor, call parent constructor */
85 function Skin() { parent
::Linker(); }
87 function getSkinNames() {
88 global $wgValidSkinNames;
89 return $wgValidSkinNames;
92 /** @return string path to the skin stylesheet */
93 function getStylesheet() { return 'common/wikistandard.css'; }
95 /** @return string skin name */
96 function getSkinName() {
100 function qbSetting() {
101 global $wgOut, $wgUser;
103 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
104 $q = $wgUser->getOption( 'quickbar' );
105 if ( '' == $q ) { $q = 0; }
109 function initPage( &$out ) {
110 $fname = 'Skin::initPage';
111 wfProfileIn( $fname );
113 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
115 $this->addMetadataLinks($out);
117 wfProfileOut( $fname );
120 function addMetadataLinks( &$out ) {
121 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
122 global $wgRightsPage, $wgRightsUrl;
124 if( $out->isArticleRelated() ) {
125 # note: buggy CC software only reads first "meta" link
126 if( $wgEnableCreativeCommonsRdf ) {
127 $out->addMetadataLink( array(
128 'title' => 'Creative Commons',
129 'type' => 'application/rdf+xml',
130 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
132 if( $wgEnableDublinCoreRdf ) {
133 $out->addMetadataLink( array(
134 'title' => 'Dublin Core',
135 'type' => 'application/rdf+xml',
136 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
140 if( $wgRightsPage ) {
141 $copy = Title
::newFromText( $wgRightsPage );
143 $copyright = $copy->getLocalURL();
146 if( !$copyright && $wgRightsUrl ) {
147 $copyright = $wgRightsUrl;
150 $out->addLink( array(
151 'rel' => 'copyright',
152 'href' => $copyright ) );
156 function outputPage( &$out ) {
157 global $wgDebugComments;
159 wfProfileIn( 'Skin::outputPage' );
160 $this->initPage( $out );
161 $out->out( $out->headElement() );
163 $out->out( "\n<body" );
164 $ops = $this->getBodyOptions();
165 foreach ( $ops as $name => $val ) {
166 $out->out( " $name='$val'" );
169 if ( $wgDebugComments ) {
170 $out->out( "<!-- Wiki debugging output:\n" .
171 $out->mDebugtext
. "-->\n" );
173 $out->out( $this->beforeContent() );
175 $out->out( $out->mBodytext
. "\n" );
177 $out->out( $this->afterContent() );
180 $out->out( $out->reportTime() );
182 $out->out( "\n</body></html>" );
185 function getHeadScripts() {
186 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
187 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
188 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
189 $userpage = $wgUser->getUserPage();
190 $userjs = htmlspecialchars( $this->makeUrl(
191 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
192 'action=raw&ctype=text/javascript'));
193 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
199 * To make it harder for someone to slip a user a fake
200 * user-JavaScript or user-CSS preview, a random token
201 * is associated with the login session. If it's not
202 * passed back with the preview request, we won't render
205 * @param string $action
209 function userCanPreview( $action ) {
210 global $wgTitle, $wgRequest, $wgUser;
212 if( $action != 'submit' )
214 if( !$wgRequest->wasPosted() )
216 if( !$wgTitle->userCanEditCssJsSubpage() )
218 return $wgUser->matchEditToken(
219 $wgRequest->getVal( 'wpEditToken' ) );
222 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
223 function getUserStylesheet() {
224 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
225 $sheet = $this->getStylesheet();
226 $action = $wgRequest->getText('action');
227 $s = "@import \"$wgStylePath/$sheet\";\n";
228 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
229 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
230 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
231 $s .= $wgRequest->getText('wpTextbox1');
233 $userpage = $wgUser->getUserPage();
234 $s.= '@import "'.$this->makeUrl(
235 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
236 'action=raw&ctype=text/css').'";'."\n";
239 $s .= $this->doGetUserStyles();
244 * placeholder, returns generated js in monobook
246 function getUserJs() { return; }
249 * Return html code that include User stylesheets
251 function getUserStyles() {
252 global $wgOut, $wgStylePath, $wgLang;
253 $s = "<style type='text/css'>\n";
254 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
255 $s .= $this->getUserStylesheet();
256 $s .= "/*]]>*/ /* */\n";
262 * Some styles that are set by user through the user settings interface.
264 function doGetUserStyles() {
265 global $wgUser, $wgContLang;
267 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
268 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
270 return $s . $this->reallyDoGetUserStyles();
273 function reallyDoGetUserStyles() {
276 $underline = $wgUser->getOption( "underline" ) ?
'underline' : 'none';
277 $s .= "a { text-decoration: $underline; }\n";
278 if( $wgUser->getOption( 'highlightbroken' ) ) {
279 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
282 a.new, #quickbar a.new,
283 a.stub, #quickbar a.stub {
285 text-decoration: inherit;
287 a.new:after, #quickbar a.new:after {
290 text-decoration: $underline;
292 a.stub:after, #quickbar a.stub:after {
295 text-decoration: $underline;
299 if( $wgUser->getOption( 'justify' ) ) {
300 $s .= "#article { text-align: justify; }\n";
302 if( !$wgUser->getOption( 'showtoc' ) ) {
303 $s .= "#toc { display: none; }\n";
308 function getBodyOptions() {
309 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
311 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
313 if ( 0 != $wgTitle->getNamespace() ) {
314 $a = array( 'bgcolor' => '#ffffec' );
316 else $a = array( 'bgcolor' => '#FFFFFF' );
317 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
318 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
319 $t = wfMsg( 'editthispage' );
321 if ( !empty($redirect) && $redirect == 'no' ) {
322 $red = "&redirect={$redirect}";
324 if ( !empty($oldid) && ! isset( $diff ) ) {
325 $oid = "&oldid=" . IntVal( $oldid );
327 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
328 $s = 'document.location = "' .$s .'";';
329 $a +
= array ('ondblclick' => $s);
332 $a['onload'] = $wgOut->getOnloadHandler();
333 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
334 if( $a['onload'] != '' ) {
337 $a['onload'] .= 'setupRightClickEdit()';
351 * This will be called immediately after the <body> tag. Split into
352 * two functions to make it easier to subclass.
354 function beforeContent() {
355 return $this->doBeforeContent();
358 function doBeforeContent() {
359 global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
360 $fname = 'Skin::doBeforeContent';
361 wfProfileIn( $fname );
364 $qb = $this->qbSetting();
366 if( $langlinks = $this->otherLanguages() ) {
372 $borderhack = 'class="top"';
375 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
376 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
379 $left = ($qb == 1 ||
$qb == 3);
380 if($wgContLang->isRTL()) $left = !$left;
383 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
384 $this->logoText() . '</td>';
386 $s .= $this->getQuickbarCompensator( $rows );
388 $l = $wgContLang->isRTL() ?
'right' : 'left';
389 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
391 $s .= $this->topLinks() ;
392 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
394 $r = $wgContLang->isRTL() ?
"left" : "right";
395 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
396 $s .= $this->nameAndLogin();
397 $s .= "\n<br />" . $this->searchForm() . "</td>";
400 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
403 if ( $shove && !$left ) { # Right
404 $s .= $this->getQuickbarCompensator( $rows );
406 $s .= "</tr>\n</table>\n</div>\n";
407 $s .= "\n<div id='article'>\n";
409 if( $wgSiteNotice ) {
410 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
412 $s .= $this->pageTitle();
413 $s .= $this->pageSubtitle() ;
414 $s .= $this->getCategories();
415 wfProfileOut( $fname );
420 function getCategoryLinks () {
421 global $wgOut, $wgTitle, $wgParser;
422 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
424 if( !$wgUseCategoryMagic ) return '' ;
425 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
427 # Taken out so that they will be displayed in previews -- TS
428 #if( !$wgOut->isArticle() ) return '';
430 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
431 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
432 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
435 # optional 'dmoz-like' category browser. Will be shown under the list
436 # of categories an article belong to
437 if($wgUseCategoryBrowser) {
438 $s .= '<br /><hr />';
440 # get a big array of the parents tree
441 $parenttree = $wgTitle->getParentCategoryTree();
443 # Render the array as a serie of links
444 # Need to give skin cause $this is undefined at this level
445 function walkThrough ($tree, &$skin) {
447 foreach($tree as $element => $parent) {
449 # element start a new list
452 # grab the others elements
453 $return .= walkThrough($parent, $skin);
455 # add our current element to the list
456 $eltitle = Title
::NewFromText($element);
457 if(!empty($parent)) $return .= ' > ';
458 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
463 # Skin object passed by reference cause it can not be
464 # accessed under the method subfunction walkThrough.
465 $s .= walkThrough($parenttree, $this);
471 function getCategories() {
472 $catlinks=$this->getCategoryLinks();
473 if(!empty($catlinks)) {
474 return "<p class='catlinks'>{$catlinks}</p>";
478 function getQuickbarCompensator( $rows = 1 ) {
479 return "<td width='152' rowspan='{$rows}'> </td>";
483 * This gets called immediately before the </body> tag.
484 * @return string HTML to be put after </body> ???
486 function afterContent() {
487 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
488 return $printfooter . $this->doAfterContent();
491 /** @return string Retrievied from HTML text */
492 function printSource() {
494 $url = htmlspecialchars( $wgTitle->getFullURL() );
495 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
498 function printFooter() {
499 return "<p>" . $this->printSource() .
500 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
503 /** overloaded by derived classes */
504 function doAfterContent() { }
506 function pageTitleLinks() {
507 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
509 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
510 $action = $wgRequest->getText( 'action' );
512 $s = $this->printableLink();
513 $disclaimer = $this->disclaimerLink(); # may be empty
515 $s .= ' | ' . $disclaimer;
518 if ( $wgOut->isArticleRelated() ) {
519 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
520 $name = $wgTitle->getDBkey();
521 $image = new Image( $wgTitle->getDBkey() );
522 if( $image->exists() ) {
523 $link = htmlspecialchars( $image->getURL() );
524 $style = $this->getInternalLinkAttributes( $link, $name );
525 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
528 # This will show the "Approve" link if $wgUseApproval=true;
529 if ( isset ( $wgUseApproval ) && $wgUseApproval )
531 $t = $wgTitle->getDBkey();
532 $name = 'Approve this article' ;
533 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
534 #htmlspecialchars( wfImageUrl( $name ) );
535 $style = $this->getExternalLinkAttributes( $link, $name );
536 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
539 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
540 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
541 wfMsg( 'currentrev' ) );
544 if ( $wgUser->getNewtalk() ) {
545 # do not show "You have new messages" text when we are viewing our
548 if( $wgTitle->equals( $wgUser->getTalkPage() ) ) {
549 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
550 wfMsg('newmessageslink') );
551 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
553 $wgOut->setSquidMaxage(0);
554 $wgOut->enableClientCache(false);
558 $undelete = $this->getUndeleteLink();
559 if( !empty( $undelete ) ) {
560 $s .= ' | '.$undelete;
565 function getUndeleteLink() {
566 global $wgUser, $wgTitle, $wgContLang, $action;
567 if( $wgUser->isAllowed('rollback') &&
568 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
569 ($n = $wgTitle->isDeleted() ) ) {
570 return wfMsg( 'thisisdeleted',
571 $this->makeKnownLink(
572 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
573 wfMsg( 'restorelink', $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, $wgIP;
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 $wgContLang->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 $wgContLang->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;
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 ( $wgTitle->getNamespace() == NS_USER
765 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
768 $id=User
::idFromName($wgTitle->getText());
769 $ip=User
::isIP($wgTitle->getText());
771 if($id ||
$ip) { # both anons and non-anons have contri list
772 $s .= $sep . $this->userContribsLink();
774 if( $this->showEmailUser( $id ) ) {
775 $s .= $sep . $this->emailUserLink();
778 if ( $wgTitle->getArticleId() ) {
780 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
781 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
782 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
784 $s .= "<br />\n" . $this->otherLanguages();
789 function pageStats() {
790 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
791 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
793 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
794 if ( ! $wgOut->isArticle() ) { return ''; }
795 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
796 if ( 0 == $wgArticle->getID() ) { return ''; }
799 if ( !$wgDisableCounters ) {
800 $count = $wgLang->formatNum( $wgArticle->getCount() );
802 $s = wfMsg( 'viewcount', $count );
806 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
807 require_once('Credits.php');
808 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
810 $s .= $this->lastModified();
813 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
814 $dbr =& wfGetDB( DB_SLAVE
);
815 extract( $dbr->tableNames( 'watchlist' ) );
816 $sql = "SELECT COUNT(*) AS n FROM $watchlist
817 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
818 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
819 $res = $dbr->query( $sql, 'Skin::pageStats');
820 $x = $dbr->fetchObject( $res );
821 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
824 return $s . ' ' . $this->getCopyright();
827 function getCopyright() {
828 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
831 $oldid = $wgRequest->getVal( 'oldid' );
832 $diff = $wgRequest->getVal( 'diff' );
834 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
835 $msg = 'history_copyright';
841 if( $wgRightsPage ) {
842 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
843 } elseif( $wgRightsUrl ) {
844 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
849 $out .= wfMsgForContent( $msg, $link );
853 function getCopyrightIcon() {
854 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
856 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
857 $out = $wgCopyrightIcon;
858 } else if ( $wgRightsIcon ) {
859 $icon = htmlspecialchars( $wgRightsIcon );
860 if ( $wgRightsUrl ) {
861 $url = htmlspecialchars( $wgRightsUrl );
862 $out .= '<a href="'.$url.'">';
864 $text = htmlspecialchars( $wgRightsText );
865 $out .= "<img src=\"$icon\" alt='$text' />";
866 if ( $wgRightsUrl ) {
873 function getPoweredBy() {
875 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
876 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
880 function lastModified() {
881 global $wgLang, $wgArticle, $wgLoadBalancer;
883 $timestamp = $wgArticle->getTimestamp();
885 $d = $wgLang->timeanddate( $timestamp, true );
886 $s = ' ' . wfMsg( 'lastmodified', $d );
890 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
891 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
896 function logoText( $align = '' ) {
897 if ( '' != $align ) { $a = " align='{$align}'"; }
900 $mp = wfMsg( 'mainpage' );
901 $titleObj = Title
::newFromText( $mp );
902 if ( is_object( $titleObj ) ) {
903 $url = $titleObj->escapeLocalURL();
908 $logourl = $this->getLogo();
909 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
914 * show a drop-down box of special pages
915 * @TODO crash bug913. Need to be rewrote completly.
917 function specialPagesList() {
918 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
919 require_once('SpecialPage.php');
921 $pages = SpecialPage
::getPages();
923 // special pages without access restriction
924 foreach ( $pages[''] as $name => $page ) {
925 $a[$name] = $page->getDescription();
928 // Other special pages that are restricted.
929 // Copied from SpecialSpecialpages.php
930 foreach($wgAvailableRights as $right) {
931 if( $wgUser->isAllowed($right) ) {
932 /** Add all pages for this right */
933 if(isset($pages[$right])) {
934 foreach($pages[$right] as $name => $page) {
935 $a[$name] = $page->getDescription();
942 $sp = wfMsg( 'specialpages' );
943 $spp = $wgContLang->specialPage( 'Specialpages' );
945 $s = '<form id="specialpages" method="get" class="inline" ' .
946 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
947 $s .= "<select name=\"wpDropdown\">\n";
948 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
951 foreach ( $a as $name => $desc ) {
952 $p = $wgContLang->specialPage( $name );
953 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
956 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
961 function mainPageLink() {
962 $mp = wfMsgForContent( 'mainpage' );
963 $mptxt = wfMsg( 'mainpage');
964 $s = $this->makeKnownLink( $mp, $mptxt );
968 function copyrightLink() {
969 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
970 wfMsg( 'copyrightpagename' ) );
974 function aboutLink() {
975 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
976 wfMsg( 'aboutsite' ) );
981 function disclaimerLink() {
982 $disclaimers = wfMsg( 'disclaimers' );
983 if ($disclaimers == '-') {
986 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
991 function editThisPage() {
992 global $wgOut, $wgTitle, $wgRequest;
994 $oldid = $wgRequest->getVal( 'oldid' );
995 $diff = $wgRequest->getVal( 'diff' );
996 $redirect = $wgRequest->getVal( 'redirect' );
998 if ( ! $wgOut->isArticleRelated() ) {
999 $s = wfMsg( 'protectedpage' );
1001 if ( $wgTitle->userCanEdit() ) {
1002 $t = wfMsg( 'editthispage' );
1004 $t = wfMsg( 'viewsource' );
1008 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1009 if ( $oldid && ! isset( $diff ) ) {
1010 $oid = '&oldid='.$oldid;
1012 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1017 function deleteThisPage() {
1018 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1020 $diff = $wgRequest->getVal( 'diff' );
1021 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1022 $t = wfMsg( 'deletethispage' );
1024 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1031 function protectThisPage() {
1032 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1034 $diff = $wgRequest->getVal( 'diff' );
1035 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1036 if ( $wgTitle->isProtected() ) {
1037 $t = wfMsg( 'unprotectthispage' );
1038 $q = 'action=unprotect';
1040 $t = wfMsg( 'protectthispage' );
1041 $q = 'action=protect';
1043 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1050 function watchThisPage() {
1051 global $wgUser, $wgOut, $wgTitle;
1053 if ( $wgOut->isArticleRelated() ) {
1054 if ( $wgTitle->userIsWatching() ) {
1055 $t = wfMsg( 'unwatchthispage' );
1056 $q = 'action=unwatch';
1058 $t = wfMsg( 'watchthispage' );
1059 $q = 'action=watch';
1061 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1063 $s = wfMsg( 'notanarticle' );
1068 function moveThisPage() {
1071 if ( $wgTitle->userCanMove() ) {
1072 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1073 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1075 // no message if page is protected - would be redundant
1080 function historyLink() {
1083 return $this->makeKnownLinkObj( $wgTitle,
1084 wfMsg( 'history' ), 'action=history' );
1087 function whatLinksHere() {
1090 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1091 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1094 function userContribsLink() {
1097 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1098 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1101 function showEmailUser( $id ) {
1102 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1103 return $wgEnableEmail &&
1104 $wgEnableUserEmail &&
1105 $wgUser->isLoggedIn() && # show only to signed in users
1106 0 != $id; # we can only email to non-anons ..
1107 # '' != $id->getEmail() && # who must have an email address stored ..
1108 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1109 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1112 function emailUserLink() {
1115 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1116 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1119 function watchPageLinksLink() {
1120 global $wgOut, $wgTitle;
1122 if ( ! $wgOut->isArticleRelated() ) {
1123 return '(' . wfMsg( 'notanarticle' ) . ')';
1125 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1126 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1127 'target=' . $wgTitle->getPrefixedURL() );
1131 function otherLanguages() {
1132 global $wgOut, $wgContLang, $wgTitle;
1134 $a = $wgOut->getLanguageLinks();
1135 if ( 0 == count( $a ) ) {
1139 $s = wfMsg( 'otherlanguages' ) . ': ';
1141 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1142 foreach( $a as $l ) {
1143 if ( ! $first ) { $s .= ' | '; }
1146 $nt = Title
::newFromText( $l );
1147 $url = $nt->escapeFullURL();
1148 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1150 if ( '' == $text ) { $text = $l; }
1151 $style = $this->getExternalLinkAttributes( $l, $text );
1152 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1154 if($wgContLang->isRTL()) $s .= '</span>';
1158 function bugReportsLink() {
1159 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1160 wfMsg( 'bugreports' ) );
1164 function dateLink() {
1165 global $wgLinkCache;
1166 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1167 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1169 $wgLinkCache->suspend();
1170 $id = $t1->getArticleID();
1171 $wgLinkCache->resume();
1174 $s = $this->makeBrokenLink( $t1->getText() );
1176 $s = $this->makeKnownLink( $t1->getText() );
1180 $wgLinkCache->suspend();
1181 $id = $t2->getArticleID();
1182 $wgLinkCache->resume();
1185 $s .= $this->makeBrokenLink( $t2->getText() );
1187 $s .= $this->makeKnownLink( $t2->getText() );
1192 function talkLink() {
1193 global $wgTitle, $wgLinkCache;
1195 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1196 # No discussion links for special pages
1200 if( $wgTitle->isTalkPage() ) {
1201 $link = $wgTitle->getSubjectPage();
1202 switch( $link->getNamespace() ) {
1204 $text = wfMsg('articlepage');
1207 $text = wfMsg('userpage');
1210 $text = wfMsg('wikipediapage');
1213 $text = wfMsg('imagepage');
1216 $text= wfMsg('articlepage');
1219 $link = $wgTitle->getTalkPage();
1220 $text = wfMsg( 'talkpage' );
1223 $wgLinkCache->suspend();
1224 $s = $this->makeLinkObj( $link, $text );
1225 $wgLinkCache->resume();
1230 function commentLink() {
1231 global $wgContLang, $wgTitle, $wgLinkCache;
1233 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1236 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1237 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1240 /* these are used extensively in SkinPHPTal, but also some other places */
1241 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1242 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1243 return $title->getLocalURL( $urlaction );
1246 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1247 $title = Title
::newFromText( wfMsgForContent($name) );
1248 $this->checkTitle($title, $name);
1249 return $title->getLocalURL( $urlaction );
1252 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1253 $title = Title
::newFromText( $name );
1254 $this->checkTitle($title, $name);
1255 return $title->getLocalURL( $urlaction );
1258 # If url string starts with http, consider as external URL, else
1260 /*static*/ function makeInternalOrExternalUrl( $name ) {
1261 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1264 return $this->makeUrl( $name );
1268 # this can be passed the NS number as defined in Language.php
1269 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1270 $title = Title
::makeTitleSafe( $namespace, $name );
1271 $this->checkTitle($title, $name);
1272 return $title->getLocalURL( $urlaction );
1275 /* these return an array with the 'href' and boolean 'exists' */
1276 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1277 $title = Title
::newFromText( $name );
1278 $this->checkTitle($title, $name);
1280 'href' => $title->getLocalURL( $urlaction ),
1281 'exists' => $title->getArticleID() != 0?
true:false
1285 # make sure we have some title to operate on
1286 /*static*/ function checkTitle ( &$title, &$name ) {
1287 if(!is_object($title)) {
1288 $title = Title
::newFromText( $name );
1289 if(!is_object($title)) {
1290 $title = Title
::newFromText( '--error: link target missing--' );