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";
305 function getBodyOptions() {
306 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
308 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
310 if ( 0 != $wgTitle->getNamespace() ) {
311 $a = array( 'bgcolor' => '#ffffec' );
313 else $a = array( 'bgcolor' => '#FFFFFF' );
314 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
315 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
316 $t = wfMsg( 'editthispage' );
318 if ( !empty($redirect) && $redirect == 'no' ) {
319 $red = "&redirect={$redirect}";
321 if ( !empty($oldid) && ! isset( $diff ) ) {
322 $oid = "&oldid=" . IntVal( $oldid );
324 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
325 $s = 'document.location = "' .$s .'";';
326 $a +
= array ('ondblclick' => $s);
329 $a['onload'] = $wgOut->getOnloadHandler();
342 * This will be called immediately after the <body> tag. Split into
343 * two functions to make it easier to subclass.
345 function beforeContent() {
346 return $this->doBeforeContent();
349 function doBeforeContent() {
350 global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
351 $fname = 'Skin::doBeforeContent';
352 wfProfileIn( $fname );
355 $qb = $this->qbSetting();
357 if( $langlinks = $this->otherLanguages() ) {
363 $borderhack = 'class="top"';
366 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
367 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
370 $left = ($qb == 1 ||
$qb == 3);
371 if($wgContLang->isRTL()) $left = !$left;
374 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
375 $this->logoText() . '</td>';
377 $s .= $this->getQuickbarCompensator( $rows );
379 $l = $wgContLang->isRTL() ?
'right' : 'left';
380 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
382 $s .= $this->topLinks() ;
383 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
385 $r = $wgContLang->isRTL() ?
"left" : "right";
386 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
387 $s .= $this->nameAndLogin();
388 $s .= "\n<br />" . $this->searchForm() . "</td>";
391 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
394 if ( $shove && !$left ) { # Right
395 $s .= $this->getQuickbarCompensator( $rows );
397 $s .= "</tr>\n</table>\n</div>\n";
398 $s .= "\n<div id='article'>\n";
400 if( $wgSiteNotice ) {
401 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
403 $s .= $this->pageTitle();
404 $s .= $this->pageSubtitle() ;
405 $s .= $this->getCategories();
406 wfProfileOut( $fname );
411 function getCategoryLinks () {
412 global $wgOut, $wgTitle, $wgParser;
413 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
415 if( !$wgUseCategoryMagic ) return '' ;
416 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
418 # Taken out so that they will be displayed in previews -- TS
419 #if( !$wgOut->isArticle() ) return '';
421 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
422 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
423 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
426 # optional 'dmoz-like' category browser. Will be shown under the list
427 # of categories an article belong to
428 if($wgUseCategoryBrowser) {
429 $s .= '<br /><hr />';
431 # get a big array of the parents tree
432 $parenttree = $wgTitle->getParentCategoryTree();
434 # Render the array as a serie of links
435 # Need to give skin cause $this is undefined at this level
436 function walkThrough ($tree, &$skin) {
438 foreach($tree as $element => $parent) {
440 # element start a new list
443 # grab the others elements
444 $return .= walkThrough($parent, $skin);
446 # add our current element to the list
447 $eltitle = Title
::NewFromText($element);
448 if(!empty($parent)) $return .= ' > ';
449 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
454 # Skin object passed by reference cause it can not be
455 # accessed under the method subfunction walkThrough.
456 $s .= walkThrough($parenttree, $this);
462 function getCategories() {
463 $catlinks=$this->getCategoryLinks();
464 if(!empty($catlinks)) {
465 return "<p class='catlinks'>{$catlinks}</p>";
469 function getQuickbarCompensator( $rows = 1 ) {
470 return "<td width='152' rowspan='{$rows}'> </td>";
474 * This gets called immediately before the </body> tag.
475 * @return string HTML to be put after </body> ???
477 function afterContent() {
478 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
479 return $printfooter . $this->doAfterContent();
482 /** @return string Retrievied from HTML text */
483 function printSource() {
485 $url = htmlspecialchars( $wgTitle->getFullURL() );
486 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
489 function printFooter() {
490 return "<p>" . $this->printSource() .
491 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
494 /** overloaded by derived classes */
495 function doAfterContent() { }
497 function pageTitleLinks() {
498 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
500 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
501 $action = $wgRequest->getText( 'action' );
503 $s = $this->printableLink();
504 $disclaimer = $this->disclaimerLink(); # may be empty
506 $s .= ' | ' . $disclaimer;
509 if ( $wgOut->isArticleRelated() ) {
510 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
511 $name = $wgTitle->getDBkey();
512 $image = new Image( $wgTitle->getDBkey() );
513 if( $image->exists() ) {
514 $link = htmlspecialchars( $image->getURL() );
515 $style = $this->getInternalLinkAttributes( $link, $name );
516 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
519 # This will show the "Approve" link if $wgUseApproval=true;
520 if ( isset ( $wgUseApproval ) && $wgUseApproval )
522 $t = $wgTitle->getDBkey();
523 $name = 'Approve this article' ;
524 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
525 #htmlspecialchars( wfImageUrl( $name ) );
526 $style = $this->getExternalLinkAttributes( $link, $name );
527 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
530 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
531 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
532 wfMsg( 'currentrev' ) );
535 if ( $wgUser->getNewtalk() ) {
536 # do not show "You have new messages" text when we are viewing our
539 if( $wgTitle->equals( $wgUser->getTalkPage() ) ) {
540 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
541 wfMsg('newmessageslink') );
542 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
544 $wgOut->setSquidMaxage(0);
545 $wgOut->enableClientCache(false);
549 $undelete = $this->getUndeleteLink();
550 if( !empty( $undelete ) ) {
551 $s .= ' | '.$undelete;
556 function getUndeleteLink() {
557 global $wgUser, $wgTitle, $wgContLang, $action;
558 if( $wgUser->isAllowed('rollback') &&
559 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
560 ($n = $wgTitle->isDeleted() ) ) {
561 return wfMsg( 'thisisdeleted',
562 $this->makeKnownLink(
563 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
564 wfMsg( 'restorelink', $n ) ) );
569 function printableLink() {
570 global $wgOut, $wgFeedClasses, $wgRequest;
572 $baseurl = $_SERVER['REQUEST_URI'];
573 if( strpos( '?', $baseurl ) == false ) {
578 $baseurl = htmlspecialchars( $baseurl );
579 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
581 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
582 if( $wgOut->isSyndicated() ) {
583 foreach( $wgFeedClasses as $format => $class ) {
584 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
585 $s .= " | <a href=\"$feedurl\">{$format}</a>";
591 function pageTitle() {
592 global $wgOut, $wgTitle, $wgUser;
594 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
595 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
599 function pageSubtitle() {
602 $sub = $wgOut->getSubtitle();
604 global $wgExtraSubtitle;
605 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
607 $subpages = $this->subPageSubtitle();
608 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
609 $s = "<p class='subtitle'>{$sub}</p>\n";
613 function subPageSubtitle() {
614 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
616 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
617 $ptext=$wgTitle->getPrefixedText();
618 if(preg_match('/\//',$ptext)) {
619 $links = explode('/',$ptext);
622 foreach($links as $link) {
624 if ($c<count($links)) {
625 $growinglink .= $link;
626 $getlink = $this->makeLink( $growinglink, $link );
627 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
631 $subpages .= '< ';
633 $subpages .= $getlink;
642 function nameAndLogin() {
643 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
645 $li = $wgContLang->specialPage( 'Userlogin' );
646 $lo = $wgContLang->specialPage( 'Userlogout' );
649 if ( $wgUser->isAnon() ) {
650 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
653 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
654 $wgContLang->getNsText( NS_TALK
) );
656 $s .= $n . ' ('.$tl.')';
658 $s .= wfMsg('notloggedin');
661 $rt = $wgTitle->getPrefixedURL();
662 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
664 } else { $q = "returnto={$rt}"; }
666 $s .= "\n<br />" . $this->makeKnownLinkObj(
667 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
668 wfMsg( 'login' ), $q );
670 $n = $wgUser->getName();
671 $rt = $wgTitle->getPrefixedURL();
672 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
673 $wgContLang->getNsText( NS_TALK
) );
677 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
678 $n ) . "{$tl}<br />" .
679 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
680 "returnto={$rt}" ) . ' | ' .
681 $this->specialLink( 'preferences' );
683 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
689 function getSearchLink() {
690 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
691 return $searchPage->getLocalURL();
694 function escapeSearchLink() {
695 return htmlspecialchars( $this->getSearchLink() );
698 function searchForm() {
700 $search = $wgRequest->getText( 'search' );
702 $s = '<form name="search" class="inline" method="post" action="'
703 . $this->escapeSearchLink() . "\">\n"
704 . '<input type="text" name="search" size="19" value="'
705 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
706 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
707 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
712 function topLinks() {
716 $s = $this->mainPageLink() . $sep
717 . $this->specialLink( 'recentchanges' );
719 if ( $wgOut->isArticleRelated() ) {
720 $s .= $sep . $this->editThisPage()
721 . $sep . $this->historyLink();
723 # Many people don't like this dropdown box
724 #$s .= $sep . $this->specialPagesList();
726 /* show links to different language variants */
727 global $wgDisableLangConversion, $wgContLang, $wgTitle;
728 $variants = $wgContLang->getVariants();
729 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
730 foreach( $variants as $code ) {
731 $varname = $wgContLang->getVariantname( $code );
732 if( $varname == 'disable' )
734 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
741 function bottomLinks() {
742 global $wgOut, $wgUser, $wgTitle;
746 if ( $wgOut->isArticleRelated() ) {
747 $s .= '<strong>' . $this->editThisPage() . '</strong>';
748 if ( $wgUser->isLoggedIn() ) {
749 $s .= $sep . $this->watchThisPage();
751 $s .= $sep . $this->talkLink()
752 . $sep . $this->historyLink()
753 . $sep . $this->whatLinksHere()
754 . $sep . $this->watchPageLinksLink();
756 if ( $wgTitle->getNamespace() == NS_USER
757 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
760 $id=User
::idFromName($wgTitle->getText());
761 $ip=User
::isIP($wgTitle->getText());
763 if($id ||
$ip) { # both anons and non-anons have contri list
764 $s .= $sep . $this->userContribsLink();
766 if( $this->showEmailUser( $id ) ) {
767 $s .= $sep . $this->emailUserLink();
770 if ( $wgTitle->getArticleId() ) {
772 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
773 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
774 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
776 $s .= "<br />\n" . $this->otherLanguages();
781 function pageStats() {
782 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
783 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
785 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
786 if ( ! $wgOut->isArticle() ) { return ''; }
787 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
788 if ( 0 == $wgArticle->getID() ) { return ''; }
791 if ( !$wgDisableCounters ) {
792 $count = $wgLang->formatNum( $wgArticle->getCount() );
794 $s = wfMsg( 'viewcount', $count );
798 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
799 require_once('Credits.php');
800 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
802 $s .= $this->lastModified();
805 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
806 $dbr =& wfGetDB( DB_SLAVE
);
807 extract( $dbr->tableNames( 'watchlist' ) );
808 $sql = "SELECT COUNT(*) AS n FROM $watchlist
809 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
810 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
811 $res = $dbr->query( $sql, 'Skin::pageStats');
812 $x = $dbr->fetchObject( $res );
813 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
816 return $s . ' ' . $this->getCopyright();
819 function getCopyright() {
820 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
823 $oldid = $wgRequest->getVal( 'oldid' );
824 $diff = $wgRequest->getVal( 'diff' );
826 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
827 $msg = 'history_copyright';
833 if( $wgRightsPage ) {
834 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
835 } elseif( $wgRightsUrl ) {
836 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
841 $out .= wfMsgForContent( $msg, $link );
845 function getCopyrightIcon() {
846 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
848 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
849 $out = $wgCopyrightIcon;
850 } else if ( $wgRightsIcon ) {
851 $icon = htmlspecialchars( $wgRightsIcon );
852 if ( $wgRightsUrl ) {
853 $url = htmlspecialchars( $wgRightsUrl );
854 $out .= '<a href="'.$url.'">';
856 $text = htmlspecialchars( $wgRightsText );
857 $out .= "<img src=\"$icon\" alt='$text' />";
858 if ( $wgRightsUrl ) {
865 function getPoweredBy() {
867 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
868 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
872 function lastModified() {
873 global $wgLang, $wgArticle, $wgLoadBalancer;
875 $timestamp = $wgArticle->getTimestamp();
877 $d = $wgLang->timeanddate( $timestamp, true );
878 $s = ' ' . wfMsg( 'lastmodified', $d );
882 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
883 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
888 function logoText( $align = '' ) {
889 if ( '' != $align ) { $a = " align='{$align}'"; }
892 $mp = wfMsg( 'mainpage' );
893 $titleObj = Title
::newFromText( $mp );
894 if ( is_object( $titleObj ) ) {
895 $url = $titleObj->escapeLocalURL();
900 $logourl = $this->getLogo();
901 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
906 * show a drop-down box of special pages
907 * @TODO crash bug913. Need to be rewrote completly.
909 function specialPagesList() {
910 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
911 require_once('SpecialPage.php');
913 $pages = SpecialPage
::getPages();
915 // special pages without access restriction
916 foreach ( $pages[''] as $name => $page ) {
917 $a[$name] = $page->getDescription();
920 // Other special pages that are restricted.
921 // Copied from SpecialSpecialpages.php
922 foreach($wgAvailableRights as $right) {
923 if( $wgUser->isAllowed($right) ) {
924 /** Add all pages for this right */
925 if(isset($pages[$right])) {
926 foreach($pages[$right] as $name => $page) {
927 $a[$name] = $page->getDescription();
934 $sp = wfMsg( 'specialpages' );
935 $spp = $wgContLang->specialPage( 'Specialpages' );
937 $s = '<form id="specialpages" method="get" class="inline" ' .
938 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
939 $s .= "<select name=\"wpDropdown\">\n";
940 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
943 foreach ( $a as $name => $desc ) {
944 $p = $wgContLang->specialPage( $name );
945 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
948 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
953 function mainPageLink() {
954 $mp = wfMsgForContent( 'mainpage' );
955 $mptxt = wfMsg( 'mainpage');
956 $s = $this->makeKnownLink( $mp, $mptxt );
960 function copyrightLink() {
961 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
962 wfMsg( 'copyrightpagename' ) );
966 function aboutLink() {
967 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
968 wfMsg( 'aboutsite' ) );
973 function disclaimerLink() {
974 $disclaimers = wfMsg( 'disclaimers' );
975 if ($disclaimers == '-') {
978 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
983 function editThisPage() {
984 global $wgOut, $wgTitle, $wgRequest;
986 $oldid = $wgRequest->getVal( 'oldid' );
987 $diff = $wgRequest->getVal( 'diff' );
988 $redirect = $wgRequest->getVal( 'redirect' );
990 if ( ! $wgOut->isArticleRelated() ) {
991 $s = wfMsg( 'protectedpage' );
993 if ( $wgTitle->userCanEdit() ) {
994 $t = wfMsg( 'editthispage' );
996 $t = wfMsg( 'viewsource' );
1000 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1001 if ( $oldid && ! isset( $diff ) ) {
1002 $oid = '&oldid='.$oldid;
1004 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1009 function deleteThisPage() {
1010 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1012 $diff = $wgRequest->getVal( 'diff' );
1013 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1014 $t = wfMsg( 'deletethispage' );
1016 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1023 function protectThisPage() {
1024 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1026 $diff = $wgRequest->getVal( 'diff' );
1027 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1028 if ( $wgTitle->isProtected() ) {
1029 $t = wfMsg( 'unprotectthispage' );
1030 $q = 'action=unprotect';
1032 $t = wfMsg( 'protectthispage' );
1033 $q = 'action=protect';
1035 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1042 function watchThisPage() {
1043 global $wgUser, $wgOut, $wgTitle;
1045 if ( $wgOut->isArticleRelated() ) {
1046 if ( $wgTitle->userIsWatching() ) {
1047 $t = wfMsg( 'unwatchthispage' );
1048 $q = 'action=unwatch';
1050 $t = wfMsg( 'watchthispage' );
1051 $q = 'action=watch';
1053 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1055 $s = wfMsg( 'notanarticle' );
1060 function moveThisPage() {
1063 if ( $wgTitle->userCanMove() ) {
1064 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1065 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1067 // no message if page is protected - would be redundant
1072 function historyLink() {
1075 return $this->makeKnownLinkObj( $wgTitle,
1076 wfMsg( 'history' ), 'action=history' );
1079 function whatLinksHere() {
1082 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1083 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1086 function userContribsLink() {
1089 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1090 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1093 function showEmailUser( $id ) {
1094 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1095 return $wgEnableEmail &&
1096 $wgEnableUserEmail &&
1097 $wgUser->isLoggedIn() && # show only to signed in users
1098 0 != $id; # we can only email to non-anons ..
1099 # '' != $id->getEmail() && # who must have an email address stored ..
1100 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1101 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1104 function emailUserLink() {
1107 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1108 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1111 function watchPageLinksLink() {
1112 global $wgOut, $wgTitle;
1114 if ( ! $wgOut->isArticleRelated() ) {
1115 return '(' . wfMsg( 'notanarticle' ) . ')';
1117 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1118 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1119 'target=' . $wgTitle->getPrefixedURL() );
1123 function otherLanguages() {
1124 global $wgOut, $wgContLang, $wgTitle;
1126 $a = $wgOut->getLanguageLinks();
1127 if ( 0 == count( $a ) ) {
1131 $s = wfMsg( 'otherlanguages' ) . ': ';
1133 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1134 foreach( $a as $l ) {
1135 if ( ! $first ) { $s .= ' | '; }
1138 $nt = Title
::newFromText( $l );
1139 $url = $nt->escapeFullURL();
1140 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1142 if ( '' == $text ) { $text = $l; }
1143 $style = $this->getExternalLinkAttributes( $l, $text );
1144 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1146 if($wgContLang->isRTL()) $s .= '</span>';
1150 function bugReportsLink() {
1151 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1152 wfMsg( 'bugreports' ) );
1156 function dateLink() {
1157 global $wgLinkCache;
1158 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1159 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1161 $wgLinkCache->suspend();
1162 $id = $t1->getArticleID();
1163 $wgLinkCache->resume();
1166 $s = $this->makeBrokenLink( $t1->getText() );
1168 $s = $this->makeKnownLink( $t1->getText() );
1172 $wgLinkCache->suspend();
1173 $id = $t2->getArticleID();
1174 $wgLinkCache->resume();
1177 $s .= $this->makeBrokenLink( $t2->getText() );
1179 $s .= $this->makeKnownLink( $t2->getText() );
1184 function talkLink() {
1185 global $wgTitle, $wgLinkCache;
1187 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1188 # No discussion links for special pages
1192 if( $wgTitle->isTalkPage() ) {
1193 $link = $wgTitle->getSubjectPage();
1194 switch( $link->getNamespace() ) {
1196 $text = wfMsg('articlepage');
1199 $text = wfMsg('userpage');
1202 $text = wfMsg('wikipediapage');
1205 $text = wfMsg('imagepage');
1208 $text= wfMsg('articlepage');
1211 $link = $wgTitle->getTalkPage();
1212 $text = wfMsg( 'talkpage' );
1215 $wgLinkCache->suspend();
1216 $s = $this->makeLinkObj( $link, $text );
1217 $wgLinkCache->resume();
1222 function commentLink() {
1223 global $wgContLang, $wgTitle, $wgLinkCache;
1225 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1228 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1229 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1232 /* these are used extensively in SkinPHPTal, but also some other places */
1233 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1234 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1235 return $title->getLocalURL( $urlaction );
1238 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1239 $title = Title
::newFromText( wfMsgForContent($name) );
1240 $this->checkTitle($title, $name);
1241 return $title->getLocalURL( $urlaction );
1244 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1245 $title = Title
::newFromText( $name );
1246 $this->checkTitle($title, $name);
1247 return $title->getLocalURL( $urlaction );
1250 # If url string starts with http, consider as external URL, else
1252 /*static*/ function makeInternalOrExternalUrl( $name ) {
1253 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1256 return $this->makeUrl( $name );
1260 # this can be passed the NS number as defined in Language.php
1261 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1262 $title = Title
::makeTitleSafe( $namespace, $name );
1263 $this->checkTitle($title, $name);
1264 return $title->getLocalURL( $urlaction );
1267 /* these return an array with the 'href' and boolean 'exists' */
1268 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1269 $title = Title
::newFromText( $name );
1270 $this->checkTitle($title, $name);
1272 'href' => $title->getLocalURL( $urlaction ),
1273 'exists' => $title->getArticleID() != 0?
true:false
1277 # make sure we have some title to operate on
1278 /*static*/ function checkTitle ( &$title, &$name ) {
1279 if(!is_object($title)) {
1280 $title = Title
::newFromText( $name );
1281 if(!is_object($title)) {
1282 $title = Title
::newFromText( '--error: link target missing--' );