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 if ( 1 == $wgUser->getOption( 'underline' ) ) {
271 # Don't override browser settings
275 $s .= "a { text-decoration: none; }\n";
277 if ( 1 == $this->mOptions
['highlightbroken'] ) {
278 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
280 if ( 1 == $wgUser->getOption( 'justify' ) ) {
281 $s .= "#article { text-align: justify; }\n";
286 function getBodyOptions() {
287 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
289 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
291 if ( 0 != $wgTitle->getNamespace() ) {
292 $a = array( 'bgcolor' => '#ffffec' );
294 else $a = array( 'bgcolor' => '#FFFFFF' );
295 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
296 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
297 $t = wfMsg( 'editthispage' );
299 if ( !empty($redirect) && $redirect == 'no' ) {
300 $red = "&redirect={$redirect}";
302 if ( !empty($oldid) && ! isset( $diff ) ) {
303 $oid = "&oldid=" . IntVal( $oldid );
305 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
306 $s = 'document.location = "' .$s .'";';
307 $a +
= array ('ondblclick' => $s);
310 $a['onload'] = $wgOut->getOnloadHandler();
323 * This will be called immediately after the <body> tag. Split into
324 * two functions to make it easier to subclass.
326 function beforeContent() {
327 return $this->doBeforeContent();
330 function doBeforeContent() {
331 global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
332 $fname = 'Skin::doBeforeContent';
333 wfProfileIn( $fname );
336 $qb = $this->qbSetting();
338 if( $langlinks = $this->otherLanguages() ) {
344 $borderhack = 'class="top"';
347 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
348 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
351 $left = ($qb == 1 ||
$qb == 3);
352 if($wgContLang->isRTL()) $left = !$left;
355 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
356 $this->logoText() . '</td>';
358 $s .= $this->getQuickbarCompensator( $rows );
360 $l = $wgContLang->isRTL() ?
'right' : 'left';
361 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
363 $s .= $this->topLinks() ;
364 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
366 $r = $wgContLang->isRTL() ?
"left" : "right";
367 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
368 $s .= $this->nameAndLogin();
369 $s .= "\n<br />" . $this->searchForm() . "</td>";
372 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
375 if ( $shove && !$left ) { # Right
376 $s .= $this->getQuickbarCompensator( $rows );
378 $s .= "</tr>\n</table>\n</div>\n";
379 $s .= "\n<div id='article'>\n";
381 if( $wgSiteNotice ) {
382 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
384 $s .= $this->pageTitle();
385 $s .= $this->pageSubtitle() ;
386 $s .= $this->getCategories();
387 wfProfileOut( $fname );
392 function getCategoryLinks () {
393 global $wgOut, $wgTitle, $wgParser;
394 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
396 if( !$wgUseCategoryMagic ) return '' ;
397 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
399 # Taken out so that they will be displayed in previews -- TS
400 #if( !$wgOut->isArticle() ) return '';
402 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
403 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
404 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
407 # optional 'dmoz-like' category browser. Will be shown under the list
408 # of categories an article belong to
409 if($wgUseCategoryBrowser) {
410 $s .= '<br /><hr />';
412 # get a big array of the parents tree
413 $parenttree = $wgTitle->getParentCategoryTree();
415 # Render the array as a serie of links
416 # Need to give skin cause $this is undefined at this level
417 function walkThrough ($tree, &$skin) {
419 foreach($tree as $element => $parent) {
421 # element start a new list
424 # grab the others elements
425 $return .= walkThrough($parent, $skin);
427 # add our current element to the list
428 $eltitle = Title
::NewFromText($element);
429 if(!empty($parent)) $return .= ' > ';
430 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
435 # Skin object passed by reference cause it can not be
436 # accessed under the method subfunction walkThrough.
437 $s .= walkThrough($parenttree, $this);
443 function getCategories() {
444 $catlinks=$this->getCategoryLinks();
445 if(!empty($catlinks)) {
446 return "<p class='catlinks'>{$catlinks}</p>";
450 function getQuickbarCompensator( $rows = 1 ) {
451 return "<td width='152' rowspan='{$rows}'> </td>";
455 * This gets called immediately before the </body> tag.
456 * @return string HTML to be put after </body> ???
458 function afterContent() {
459 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
460 return $printfooter . $this->doAfterContent();
463 /** @return string Retrievied from HTML text */
464 function printSource() {
466 $url = htmlspecialchars( $wgTitle->getFullURL() );
467 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
470 function printFooter() {
471 return "<p>" . $this->printSource() .
472 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
475 /** overloaded by derived classes */
476 function doAfterContent() { }
478 function pageTitleLinks() {
479 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
481 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
482 $action = $wgRequest->getText( 'action' );
484 $s = $this->printableLink();
485 $disclaimer = $this->disclaimerLink(); # may be empty
487 $s .= ' | ' . $disclaimer;
490 if ( $wgOut->isArticleRelated() ) {
491 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
492 $name = $wgTitle->getDBkey();
493 $image = new Image( $wgTitle->getDBkey() );
494 if( $image->exists() ) {
495 $link = htmlspecialchars( $image->getURL() );
496 $style = $this->getInternalLinkAttributes( $link, $name );
497 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
500 # This will show the "Approve" link if $wgUseApproval=true;
501 if ( isset ( $wgUseApproval ) && $wgUseApproval )
503 $t = $wgTitle->getDBkey();
504 $name = 'Approve this article' ;
505 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
506 #htmlspecialchars( wfImageUrl( $name ) );
507 $style = $this->getExternalLinkAttributes( $link, $name );
508 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
511 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
512 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
513 wfMsg( 'currentrev' ) );
516 if ( $wgUser->getNewtalk() ) {
517 # do not show "You have new messages" text when we are viewing our
520 if( $wgTitle->equals( $wgUser->getTalkPage() ) ) {
521 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
522 wfMsg('newmessageslink') );
523 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
525 $wgOut->setSquidMaxage(0);
526 $wgOut->enableClientCache(false);
530 $undelete = $this->getUndeleteLink();
531 if( !empty( $undelete ) ) {
532 $s .= ' | '.$undelete;
537 function getUndeleteLink() {
538 global $wgUser, $wgTitle, $wgContLang, $action;
539 if( $wgUser->isAllowed('rollback') &&
540 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
541 ($n = $wgTitle->isDeleted() ) ) {
542 return wfMsg( 'thisisdeleted',
543 $this->makeKnownLink(
544 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
545 wfMsg( 'restorelink', $n ) ) );
550 function printableLink() {
551 global $wgOut, $wgFeedClasses, $wgRequest;
553 $baseurl = $_SERVER['REQUEST_URI'];
554 if( strpos( '?', $baseurl ) == false ) {
559 $baseurl = htmlspecialchars( $baseurl );
560 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
562 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
563 if( $wgOut->isSyndicated() ) {
564 foreach( $wgFeedClasses as $format => $class ) {
565 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
566 $s .= " | <a href=\"$feedurl\">{$format}</a>";
572 function pageTitle() {
573 global $wgOut, $wgTitle, $wgUser;
575 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
576 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
580 function pageSubtitle() {
583 $sub = $wgOut->getSubtitle();
585 global $wgExtraSubtitle;
586 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
588 $subpages = $this->subPageSubtitle();
589 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
590 $s = "<p class='subtitle'>{$sub}</p>\n";
594 function subPageSubtitle() {
595 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
597 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
598 $ptext=$wgTitle->getPrefixedText();
599 if(preg_match('/\//',$ptext)) {
600 $links = explode('/',$ptext);
603 foreach($links as $link) {
605 if ($c<count($links)) {
606 $growinglink .= $link;
607 $getlink = $this->makeLink( $growinglink, $link );
608 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
612 $subpages .= '< ';
614 $subpages .= $getlink;
623 function nameAndLogin() {
624 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
626 $li = $wgContLang->specialPage( 'Userlogin' );
627 $lo = $wgContLang->specialPage( 'Userlogout' );
630 if ( $wgUser->isAnon() ) {
631 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
634 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
635 $wgContLang->getNsText( NS_TALK
) );
637 $s .= $n . ' ('.$tl.')';
639 $s .= wfMsg('notloggedin');
642 $rt = $wgTitle->getPrefixedURL();
643 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
645 } else { $q = "returnto={$rt}"; }
647 $s .= "\n<br />" . $this->makeKnownLinkObj(
648 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
649 wfMsg( 'login' ), $q );
651 $n = $wgUser->getName();
652 $rt = $wgTitle->getPrefixedURL();
653 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
654 $wgContLang->getNsText( NS_TALK
) );
658 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
659 $n ) . "{$tl}<br />" .
660 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
661 "returnto={$rt}" ) . ' | ' .
662 $this->specialLink( 'preferences' );
664 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
670 function getSearchLink() {
671 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
672 return $searchPage->getLocalURL();
675 function escapeSearchLink() {
676 return htmlspecialchars( $this->getSearchLink() );
679 function searchForm() {
681 $search = $wgRequest->getText( 'search' );
683 $s = '<form name="search" class="inline" method="post" action="'
684 . $this->escapeSearchLink() . "\">\n"
685 . '<input type="text" name="search" size="19" value="'
686 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
687 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
688 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
693 function topLinks() {
697 $s = $this->mainPageLink() . $sep
698 . $this->specialLink( 'recentchanges' );
700 if ( $wgOut->isArticleRelated() ) {
701 $s .= $sep . $this->editThisPage()
702 . $sep . $this->historyLink();
704 # Many people don't like this dropdown box
705 #$s .= $sep . $this->specialPagesList();
707 /* show links to different language variants */
708 global $wgDisableLangConversion, $wgContLang, $wgTitle;
709 $variants = $wgContLang->getVariants();
710 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
711 foreach( $variants as $code ) {
712 $varname = $wgContLang->getVariantname( $code );
713 if( $varname == 'disable' )
715 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
722 function bottomLinks() {
723 global $wgOut, $wgUser, $wgTitle;
727 if ( $wgOut->isArticleRelated() ) {
728 $s .= '<strong>' . $this->editThisPage() . '</strong>';
729 if ( $wgUser->isLoggedIn() ) {
730 $s .= $sep . $this->watchThisPage();
732 $s .= $sep . $this->talkLink()
733 . $sep . $this->historyLink()
734 . $sep . $this->whatLinksHere()
735 . $sep . $this->watchPageLinksLink();
737 if ( $wgTitle->getNamespace() == NS_USER
738 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
741 $id=User
::idFromName($wgTitle->getText());
742 $ip=User
::isIP($wgTitle->getText());
744 if($id ||
$ip) { # both anons and non-anons have contri list
745 $s .= $sep . $this->userContribsLink();
747 if( $this->showEmailUser( $id ) ) {
748 $s .= $sep . $this->emailUserLink();
751 if ( $wgTitle->getArticleId() ) {
753 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
754 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
755 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
757 $s .= "<br />\n" . $this->otherLanguages();
762 function pageStats() {
763 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
764 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
766 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
767 if ( ! $wgOut->isArticle() ) { return ''; }
768 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
769 if ( 0 == $wgArticle->getID() ) { return ''; }
772 if ( !$wgDisableCounters ) {
773 $count = $wgLang->formatNum( $wgArticle->getCount() );
775 $s = wfMsg( 'viewcount', $count );
779 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
780 require_once('Credits.php');
781 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
783 $s .= $this->lastModified();
786 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
787 $dbr =& wfGetDB( DB_SLAVE
);
788 extract( $dbr->tableNames( 'watchlist' ) );
789 $sql = "SELECT COUNT(*) AS n FROM $watchlist
790 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
791 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
792 $res = $dbr->query( $sql, 'Skin::pageStats');
793 $x = $dbr->fetchObject( $res );
794 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
797 return $s . ' ' . $this->getCopyright();
800 function getCopyright() {
801 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
804 $oldid = $wgRequest->getVal( 'oldid' );
805 $diff = $wgRequest->getVal( 'diff' );
807 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
808 $msg = 'history_copyright';
814 if( $wgRightsPage ) {
815 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
816 } elseif( $wgRightsUrl ) {
817 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
822 $out .= wfMsgForContent( $msg, $link );
826 function getCopyrightIcon() {
827 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
829 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
830 $out = $wgCopyrightIcon;
831 } else if ( $wgRightsIcon ) {
832 $icon = htmlspecialchars( $wgRightsIcon );
833 if ( $wgRightsUrl ) {
834 $url = htmlspecialchars( $wgRightsUrl );
835 $out .= '<a href="'.$url.'">';
837 $text = htmlspecialchars( $wgRightsText );
838 $out .= "<img src=\"$icon\" alt='$text' />";
839 if ( $wgRightsUrl ) {
846 function getPoweredBy() {
848 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
849 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
853 function lastModified() {
854 global $wgLang, $wgArticle, $wgLoadBalancer;
856 $timestamp = $wgArticle->getTimestamp();
858 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
859 $s = ' ' . wfMsg( 'lastmodified', $d );
863 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
864 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
869 function logoText( $align = '' ) {
870 if ( '' != $align ) { $a = " align='{$align}'"; }
873 $mp = wfMsg( 'mainpage' );
874 $titleObj = Title
::newFromText( $mp );
875 if ( is_object( $titleObj ) ) {
876 $url = $titleObj->escapeLocalURL();
881 $logourl = $this->getLogo();
882 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
887 * show a drop-down box of special pages
888 * @TODO crash bug913. Need to be rewrote completly.
890 function specialPagesList() {
891 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
892 require_once('SpecialPage.php');
894 $pages = SpecialPage
::getPages();
896 // special pages without access restriction
897 foreach ( $pages[''] as $name => $page ) {
898 $a[$name] = $page->getDescription();
901 // Other special pages that are restricted.
902 // Copied from SpecialSpecialpages.php
903 foreach($wgAvailableRights as $right) {
904 if( $wgUser->isAllowed($right) ) {
905 /** Add all pages for this right */
906 if(isset($pages[$right])) {
907 foreach($pages[$right] as $name => $page) {
908 $a[$name] = $page->getDescription();
915 $sp = wfMsg( 'specialpages' );
916 $spp = $wgContLang->specialPage( 'Specialpages' );
918 $s = '<form id="specialpages" method="get" class="inline" ' .
919 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
920 $s .= "<select name=\"wpDropdown\">\n";
921 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
924 foreach ( $a as $name => $desc ) {
925 $p = $wgContLang->specialPage( $name );
926 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
929 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
934 function mainPageLink() {
935 $mp = wfMsgForContent( 'mainpage' );
936 $mptxt = wfMsg( 'mainpage');
937 $s = $this->makeKnownLink( $mp, $mptxt );
941 function copyrightLink() {
942 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
943 wfMsg( 'copyrightpagename' ) );
947 function aboutLink() {
948 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
949 wfMsg( 'aboutsite' ) );
954 function disclaimerLink() {
955 $disclaimers = wfMsg( 'disclaimers' );
956 if ($disclaimers == '-') {
959 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
964 function editThisPage() {
965 global $wgOut, $wgTitle, $wgRequest;
967 $oldid = $wgRequest->getVal( 'oldid' );
968 $diff = $wgRequest->getVal( 'diff' );
969 $redirect = $wgRequest->getVal( 'redirect' );
971 if ( ! $wgOut->isArticleRelated() ) {
972 $s = wfMsg( 'protectedpage' );
974 if ( $wgTitle->userCanEdit() ) {
975 $t = wfMsg( 'editthispage' );
977 $t = wfMsg( 'viewsource' );
981 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
982 if ( $oldid && ! isset( $diff ) ) {
983 $oid = '&oldid='.$oldid;
985 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
990 function deleteThisPage() {
991 global $wgUser, $wgOut, $wgTitle, $wgRequest;
993 $diff = $wgRequest->getVal( 'diff' );
994 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
995 $t = wfMsg( 'deletethispage' );
997 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1004 function protectThisPage() {
1005 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1007 $diff = $wgRequest->getVal( 'diff' );
1008 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1009 if ( $wgTitle->isProtected() ) {
1010 $t = wfMsg( 'unprotectthispage' );
1011 $q = 'action=unprotect';
1013 $t = wfMsg( 'protectthispage' );
1014 $q = 'action=protect';
1016 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1023 function watchThisPage() {
1024 global $wgUser, $wgOut, $wgTitle;
1026 if ( $wgOut->isArticleRelated() ) {
1027 if ( $wgTitle->userIsWatching() ) {
1028 $t = wfMsg( 'unwatchthispage' );
1029 $q = 'action=unwatch';
1031 $t = wfMsg( 'watchthispage' );
1032 $q = 'action=watch';
1034 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1036 $s = wfMsg( 'notanarticle' );
1041 function moveThisPage() {
1044 if ( $wgTitle->userCanMove() ) {
1045 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1046 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1048 // no message if page is protected - would be redundant
1053 function historyLink() {
1056 return $this->makeKnownLinkObj( $wgTitle,
1057 wfMsg( 'history' ), 'action=history' );
1060 function whatLinksHere() {
1063 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1064 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1067 function userContribsLink() {
1070 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1071 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1074 function showEmailUser( $id ) {
1075 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1076 return $wgEnableEmail &&
1077 $wgEnableUserEmail &&
1078 $wgUser->isLoggedIn() && # show only to signed in users
1079 0 != $id; # we can only email to non-anons ..
1080 # '' != $id->getEmail() && # who must have an email address stored ..
1081 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1082 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1085 function emailUserLink() {
1088 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1089 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1092 function watchPageLinksLink() {
1093 global $wgOut, $wgTitle;
1095 if ( ! $wgOut->isArticleRelated() ) {
1096 return '(' . wfMsg( 'notanarticle' ) . ')';
1098 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1099 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1100 'target=' . $wgTitle->getPrefixedURL() );
1104 function otherLanguages() {
1105 global $wgOut, $wgContLang, $wgTitle;
1107 $a = $wgOut->getLanguageLinks();
1108 if ( 0 == count( $a ) ) {
1112 $s = wfMsg( 'otherlanguages' ) . ': ';
1114 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1115 foreach( $a as $l ) {
1116 if ( ! $first ) { $s .= ' | '; }
1119 $nt = Title
::newFromText( $l );
1120 $url = $nt->escapeFullURL();
1121 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1123 if ( '' == $text ) { $text = $l; }
1124 $style = $this->getExternalLinkAttributes( $l, $text );
1125 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1127 if($wgContLang->isRTL()) $s .= '</span>';
1131 function bugReportsLink() {
1132 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1133 wfMsg( 'bugreports' ) );
1137 function dateLink() {
1138 global $wgLinkCache;
1139 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1140 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1142 $wgLinkCache->suspend();
1143 $id = $t1->getArticleID();
1144 $wgLinkCache->resume();
1147 $s = $this->makeBrokenLink( $t1->getText() );
1149 $s = $this->makeKnownLink( $t1->getText() );
1153 $wgLinkCache->suspend();
1154 $id = $t2->getArticleID();
1155 $wgLinkCache->resume();
1158 $s .= $this->makeBrokenLink( $t2->getText() );
1160 $s .= $this->makeKnownLink( $t2->getText() );
1165 function talkLink() {
1166 global $wgTitle, $wgLinkCache;
1168 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1169 # No discussion links for special pages
1173 if( $wgTitle->isTalkPage() ) {
1174 $link = $wgTitle->getSubjectPage();
1175 switch( $link->getNamespace() ) {
1177 $text = wfMsg('articlepage');
1180 $text = wfMsg('userpage');
1183 $text = wfMsg('wikipediapage');
1186 $text = wfMsg('imagepage');
1189 $text= wfMsg('articlepage');
1192 $link = $wgTitle->getTalkPage();
1193 $text = wfMsg( 'talkpage' );
1196 $wgLinkCache->suspend();
1197 $s = $this->makeLinkObj( $link, $text );
1198 $wgLinkCache->resume();
1203 function commentLink() {
1204 global $wgContLang, $wgTitle, $wgLinkCache;
1206 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1209 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1210 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1213 /* these are used extensively in SkinPHPTal, but also some other places */
1214 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1215 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1216 return $title->getLocalURL( $urlaction );
1219 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1220 $title = Title
::newFromText( wfMsgForContent($name) );
1221 $this->checkTitle($title, $name);
1222 return $title->getLocalURL( $urlaction );
1225 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1226 $title = Title
::newFromText( $name );
1227 $this->checkTitle($title, $name);
1228 return $title->getLocalURL( $urlaction );
1231 # If url string starts with http, consider as external URL, else
1233 /*static*/ function makeInternalOrExternalUrl( $name ) {
1234 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1237 return $this->makeUrl( $name );
1241 # this can be passed the NS number as defined in Language.php
1242 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1243 $title = Title
::makeTitleSafe( $namespace, $name );
1244 $this->checkTitle($title, $name);
1245 return $title->getLocalURL( $urlaction );
1248 /* these return an array with the 'href' and boolean 'exists' */
1249 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1250 $title = Title
::newFromText( $name );
1251 $this->checkTitle($title, $name);
1253 'href' => $title->getLocalURL( $urlaction ),
1254 'exists' => $title->getArticleID() != 0?
true:false
1258 # make sure we have some title to operate on
1259 /*static*/ function checkTitle ( &$title, &$name ) {
1260 if(!is_object($title)) {
1261 $title = Title
::newFromText( $name );
1262 if(!is_object($title)) {
1263 $title = Title
::newFromText( '--error: link target missing--' );