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
88 function getSkinNames() {
89 global $wgValidSkinNames;
90 return $wgValidSkinNames;
93 function getStylesheet() {
94 return 'common/wikistandard.css';
97 function getSkinName() {
101 function qbSetting() {
102 global $wgOut, $wgUser;
104 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
105 $q = $wgUser->getOption( 'quickbar' );
106 if ( '' == $q ) { $q = 0; }
110 function initPage( &$out ) {
111 $fname = 'Skin::initPage';
112 wfProfileIn( $fname );
114 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
116 $this->addMetadataLinks($out);
118 wfProfileOut( $fname );
121 function addMetadataLinks( &$out ) {
122 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
123 global $wgRightsPage, $wgRightsUrl;
125 if( $out->isArticleRelated() ) {
126 # note: buggy CC software only reads first "meta" link
127 if( $wgEnableCreativeCommonsRdf ) {
128 $out->addMetadataLink( array(
129 'title' => 'Creative Commons',
130 'type' => 'application/rdf+xml',
131 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
133 if( $wgEnableDublinCoreRdf ) {
134 $out->addMetadataLink( array(
135 'title' => 'Dublin Core',
136 'type' => 'application/rdf+xml',
137 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
141 if( $wgRightsPage ) {
142 $copy = Title
::newFromText( $wgRightsPage );
144 $copyright = $copy->getLocalURL();
147 if( !$copyright && $wgRightsUrl ) {
148 $copyright = $wgRightsUrl;
151 $out->addLink( array(
152 'rel' => 'copyright',
153 'href' => $copyright ) );
157 function outputPage( &$out ) {
158 global $wgDebugComments;
160 wfProfileIn( 'Skin::outputPage' );
161 $this->initPage( $out );
162 $out->out( $out->headElement() );
164 $out->out( "\n<body" );
165 $ops = $this->getBodyOptions();
166 foreach ( $ops as $name => $val ) {
167 $out->out( " $name='$val'" );
170 if ( $wgDebugComments ) {
171 $out->out( "<!-- Wiki debugging output:\n" .
172 $out->mDebugtext
. "-->\n" );
174 $out->out( $this->beforeContent() );
176 $out->out( $out->mBodytext
. "\n" );
178 $out->out( $this->afterContent() );
181 $out->out( $out->reportTime() );
183 $out->out( "\n</body></html>" );
186 function getHeadScripts() {
187 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
188 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
189 if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
190 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
191 $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
192 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
197 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
198 function getUserStylesheet() {
199 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
200 $sheet = $this->getStylesheet();
201 $action = $wgRequest->getText('action');
202 $s = "@import \"$wgStylePath/$sheet\";\n";
203 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
204 if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
205 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
206 $s .= $wgRequest->getText('wpTextbox1');
208 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
209 $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
212 $s .= $this->doGetUserStyles();
217 * placeholder, returns generated js in monobook
219 function getUserJs() { return; }
222 * Return html code that include User stylesheets
224 function getUserStyles() {
225 global $wgOut, $wgStylePath, $wgLang;
226 $s = "<style type='text/css'>\n";
227 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
228 $s .= $this->getUserStylesheet();
229 $s .= "/*]]>*/ /* */\n";
235 * Some styles that are set by user through the user settings interface.
237 function doGetUserStyles() {
238 global $wgUser, $wgContLang;
240 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
241 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
243 if ( 1 == $wgUser->getOption( 'underline' ) ) {
244 # Don't override browser settings
248 $s .= "a { text-decoration: none; }\n";
250 if ( 1 == $this->mOptions
['highlightbroken'] ) {
251 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
253 if ( 1 == $wgUser->getOption( 'justify' ) ) {
254 $s .= "#article { text-align: justify; }\n";
259 function getBodyOptions() {
260 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
262 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
264 if ( 0 != $wgTitle->getNamespace() ) {
265 $a = array( 'bgcolor' => '#ffffec' );
267 else $a = array( 'bgcolor' => '#FFFFFF' );
268 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
269 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
270 $t = wfMsg( 'editthispage' );
272 if ( !empty($redirect) && $redirect == 'no' ) {
273 $red = "&redirect={$redirect}";
275 if ( !empty($oldid) && ! isset( $diff ) ) {
276 $oid = "&oldid=" . IntVal( $oldid );
278 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
279 $s = 'document.location = "' .$s .'";';
280 $a +
= array ('ondblclick' => $s);
283 $a['onload'] = $wgOut->getOnloadHandler();
296 * This will be called immediately after the <body> tag. Split into
297 * two functions to make it easier to subclass.
299 function beforeContent() {
300 global $wgUser, $wgOut;
302 return $this->doBeforeContent();
305 function doBeforeContent() {
306 global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
307 $fname = 'Skin::doBeforeContent';
308 wfProfileIn( $fname );
311 $qb = $this->qbSetting();
313 if( $langlinks = $this->otherLanguages() ) {
319 $borderhack = 'class="top"';
322 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
323 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
326 $left = ($qb == 1 ||
$qb == 3);
327 if($wgContLang->isRTL()) $left = !$left;
330 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
331 $this->logoText() . '</td>';
333 $s .= $this->getQuickbarCompensator( $rows );
335 $l = $wgContLang->isRTL() ?
'right' : 'left';
336 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
338 $s .= $this->topLinks() ;
339 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
341 $r = $wgContLang->isRTL() ?
"left" : "right";
342 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
343 $s .= $this->nameAndLogin();
344 $s .= "\n<br />" . $this->searchForm() . "</td>";
347 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
350 if ( $shove && !$left ) { # Right
351 $s .= $this->getQuickbarCompensator( $rows );
353 $s .= "</tr>\n</table>\n</div>\n";
354 $s .= "\n<div id='article'>\n";
356 if( $wgSiteNotice ) {
357 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
359 $s .= $this->pageTitle();
360 $s .= $this->pageSubtitle() ;
361 $s .= $this->getCategories();
362 wfProfileOut( $fname );
367 function getCategoryLinks () {
368 global $wgOut, $wgTitle, $wgUser, $wgParser;
369 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
371 if( !$wgUseCategoryMagic ) return '' ;
372 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
374 # Taken out so that they will be displayed in previews -- TS
375 #if( !$wgOut->isArticle() ) return '';
377 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
378 $s = $this->makeKnownLink( 'Special:Categories',
379 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
382 # optional 'dmoz-like' category browser. Will be shown under the list
383 # of categories an article belong to
384 if($wgUseCategoryBrowser) {
387 # get a big array of the parents tree
388 $parenttree = $wgTitle->getParentCategoryTree();
390 # Render the array as a serie of links
391 function walkThrough ($tree) {
393 $sk = $wgUser->getSkin();
395 foreach($tree as $element => $parent) {
397 # element start a new list
400 # grab the others elements
401 $return .= walkThrough($parent);
403 # add our current element to the list
404 $eltitle = Title
::NewFromText($element);
405 # FIXME : should be makeLink() [AV]
406 $return .= $sk->makeLink($element, $eltitle->getText()).' > ';
411 $s .= walkThrough($parenttree);
417 function getCategories() {
418 $catlinks=$this->getCategoryLinks();
419 if(!empty($catlinks)) {
420 return "<p class='catlinks'>{$catlinks}</p>";
424 function getQuickbarCompensator( $rows = 1 ) {
425 return "<td width='152' rowspan='{$rows}'> </td>";
428 # This gets called immediately before the </body> tag.
430 function afterContent() {
431 global $wgUser, $wgOut, $wgServer;
432 global $wgTitle, $wgLang;
434 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
435 return $printfooter . $this->doAfterContent();
438 function printSource() {
440 $url = htmlspecialchars( $wgTitle->getFullURL() );
441 return wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" );
444 function printFooter() {
445 return "<p>" . $this->printSource() .
446 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
449 function doAfterContent() {
450 # overloaded by derived classes
453 function pageTitleLinks() {
454 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
456 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
457 $action = $wgRequest->getText( 'action' );
459 $s = $this->printableLink();
460 $disclaimer = $this->disclaimerLink(); # may be empty
462 $s .= ' | ' . $disclaimer;
465 if ( $wgOut->isArticleRelated() ) {
466 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
467 $name = $wgTitle->getDBkey();
468 $image = new Image( $wgTitle->getDBkey() );
469 if( $image->exists() ) {
470 $link = htmlspecialchars( $image->getURL() );
471 $style = $this->getInternalLinkAttributes( $link, $name );
472 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
475 # This will show the "Approve" link if $wgUseApproval=true;
476 if ( isset ( $wgUseApproval ) && $wgUseApproval )
478 $t = $wgTitle->getDBkey();
479 $name = 'Approve this article' ;
480 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
481 #htmlspecialchars( wfImageUrl( $name ) );
482 $style = $this->getExternalLinkAttributes( $link, $name );
483 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
486 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
487 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
488 wfMsg( 'currentrev' ) );
491 if ( $wgUser->getNewtalk() ) {
492 # do not show "You have new messages" text when we are viewing our
495 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
496 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
497 $n =$wgUser->getName();
498 $tl = $this->makeKnownLink( $wgContLang->getNsText(
499 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
500 wfMsg('newmessageslink') );
501 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
503 $wgOut->setSquidMaxage(0);
504 $wgOut->enableClientCache(false);
508 $undelete = $this->getUndeleteLink();
509 if( !empty( $undelete ) ) {
510 $s .= ' | '.$undelete;
515 function getUndeleteLink() {
516 global $wgUser, $wgTitle, $wgContLang, $action;
517 if( $wgUser->isAllowed('rollback') &&
518 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
519 ($n = $wgTitle->isDeleted() ) ) {
520 return wfMsg( 'thisisdeleted',
521 $this->makeKnownLink(
522 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
523 wfMsg( 'restorelink', $n ) ) );
528 function printableLink() {
529 global $wgOut, $wgFeedClasses, $wgRequest;
531 $baseurl = $_SERVER['REQUEST_URI'];
532 if( strpos( '?', $baseurl ) == false ) {
537 $baseurl = htmlspecialchars( $baseurl );
538 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
540 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
541 if( $wgOut->isSyndicated() ) {
542 foreach( $wgFeedClasses as $format => $class ) {
543 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
544 $s .= " | <a href=\"$feedurl\">{$format}</a>";
550 function pageTitle() {
551 global $wgOut, $wgTitle, $wgUser;
553 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
554 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
558 function pageSubtitle() {
561 $sub = $wgOut->getSubtitle();
563 global $wgExtraSubtitle;
564 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
566 $subpages = $this->subPageSubtitle();
567 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
568 $s = "<p class='subtitle'>{$sub}</p>\n";
572 function subPageSubtitle() {
573 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
575 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
576 $ptext=$wgTitle->getPrefixedText();
577 if(preg_match('/\//',$ptext)) {
578 $links = explode('/',$ptext);
581 foreach($links as $link) {
583 if ($c<count($links)) {
584 $growinglink .= $link;
585 $getlink = $this->makeLink( $growinglink, $link );
586 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
590 $subpages .= '< ';
592 $subpages .= $getlink;
601 function nameAndLogin() {
602 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
604 $li = $wgContLang->specialPage( 'Userlogin' );
605 $lo = $wgContLang->specialPage( 'Userlogout' );
608 if ( 0 == $wgUser->getID() ) {
609 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
612 $tl = $this->makeKnownLink( $wgContLang->getNsText(
613 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
614 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
616 $s .= $n . ' ('.$tl.')';
618 $s .= wfMsg('notloggedin');
621 $rt = $wgTitle->getPrefixedURL();
622 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
624 } else { $q = "returnto={$rt}"; }
626 $s .= "\n<br />" . $this->makeKnownLink( $li,
627 wfMsg( 'login' ), $q );
629 $n = $wgUser->getName();
630 $rt = $wgTitle->getPrefixedURL();
631 $tl = $this->makeKnownLink( $wgContLang->getNsText(
632 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
633 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
637 $s .= $this->makeKnownLink( $wgContLang->getNsText(
638 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
639 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
640 "returnto={$rt}" ) . ' | ' .
641 $this->specialLink( 'preferences' );
643 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
649 function getSearchLink() {
650 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
651 return $searchPage->getLocalURL();
654 function escapeSearchLink() {
655 return htmlspecialchars( $this->getSearchLink() );
658 function searchForm() {
660 $search = $wgRequest->getText( 'search' );
662 $s = '<form name="search" class="inline" method="post" action="'
663 . $this->escapeSearchLink() . "\">\n"
664 . '<input type="text" name="search" size="19" value="'
665 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
666 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
667 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
672 function topLinks() {
676 $s = $this->mainPageLink() . $sep
677 . $this->specialLink( 'recentchanges' );
679 if ( $wgOut->isArticleRelated() ) {
680 $s .= $sep . $this->editThisPage()
681 . $sep . $this->historyLink();
683 # Many people don't like this dropdown box
684 #$s .= $sep . $this->specialPagesList();
686 /* show links to different language variants */
687 global $wgDisableLangConversion, $wgContLang, $wgTitle;
688 $variants = $wgContLang->getVariants();
689 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
690 foreach( $variants as $code ) {
691 $varname = $wgContLang->getVariantname( $code );
692 if( $varname == 'disable' )
694 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
703 function bottomLinks() {
704 global $wgOut, $wgUser, $wgTitle;
708 if ( $wgOut->isArticleRelated() ) {
709 $s .= '<strong>' . $this->editThisPage() . '</strong>';
710 if ( 0 != $wgUser->getID() ) {
711 $s .= $sep . $this->watchThisPage();
713 $s .= $sep . $this->talkLink()
714 . $sep . $this->historyLink()
715 . $sep . $this->whatLinksHere()
716 . $sep . $this->watchPageLinksLink();
718 if ( $wgTitle->getNamespace() == Namespace::getUser()
719 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
722 $id=User
::idFromName($wgTitle->getText());
723 $ip=User
::isIP($wgTitle->getText());
725 if($id ||
$ip) { # both anons and non-anons have contri list
726 $s .= $sep . $this->userContribsLink();
728 if( $this->showEmailUser( $id ) ) {
729 $s .= $sep . $this->emailUserLink();
732 if ( $wgTitle->getArticleId() ) {
734 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
735 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
736 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
738 $s .= "<br />\n" . $this->otherLanguages();
743 function pageStats() {
744 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
745 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
747 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
748 if ( ! $wgOut->isArticle() ) { return ''; }
749 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
750 if ( 0 == $wgArticle->getID() ) { return ''; }
753 if ( !$wgDisableCounters ) {
754 $count = $wgLang->formatNum( $wgArticle->getCount() );
756 $s = wfMsg( 'viewcount', $count );
760 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
761 require_once("Credits.php");
762 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
764 $s .= $this->lastModified();
767 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
768 $dbr =& wfGetDB( DB_SLAVE
);
769 extract( $dbr->tableNames( 'watchlist' ) );
770 $sql = "SELECT COUNT(*) AS n FROM $watchlist
771 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
772 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
773 $res = $dbr->query( $sql, 'Skin::pageStats');
774 $x = $dbr->fetchObject( $res );
775 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
778 return $s . ' ' . $this->getCopyright();
781 function getCopyright() {
782 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
785 $oldid = $wgRequest->getVal( 'oldid' );
786 $diff = $wgRequest->getVal( 'diff' );
788 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
789 $msg = 'history_copyright';
795 if( $wgRightsPage ) {
796 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
797 } elseif( $wgRightsUrl ) {
798 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
803 $out .= wfMsgForContent( $msg, $link );
807 function getCopyrightIcon() {
808 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
810 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
811 $out = $wgCopyrightIcon;
812 } else if ( $wgRightsIcon ) {
813 $icon = htmlspecialchars( $wgRightsIcon );
814 if ( $wgRightsUrl ) {
815 $url = htmlspecialchars( $wgRightsUrl );
816 $out .= '<a href="'.$url.'">';
818 $text = htmlspecialchars( $wgRightsText );
819 $out .= "<img src=\"$icon\" alt='$text' />";
820 if ( $wgRightsUrl ) {
827 function getPoweredBy() {
829 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
830 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
834 function lastModified() {
835 global $wgLang, $wgArticle, $wgLoadBalancer;
837 $timestamp = $wgArticle->getTimestamp();
839 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
840 $s = ' ' . wfMsg( 'lastmodified', $d );
844 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
845 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
850 function logoText( $align = '' ) {
851 if ( '' != $align ) { $a = " align='{$align}'"; }
854 $mp = wfMsg( 'mainpage' );
855 $titleObj = Title
::newFromText( $mp );
856 if ( is_object( $titleObj ) ) {
857 $url = $titleObj->escapeLocalURL();
862 $logourl = $this->getLogo();
863 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
868 * show a drop-down box of special pages
869 * @TODO crash bug913. Need to be rewrote completly.
871 function specialPagesList() {
872 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
873 require_once('SpecialPage.php');
875 $pages = SpecialPage
::getPages();
877 foreach ( $pages[''] as $name => $page ) {
878 $a[$name] = $page->getDescription();
880 if ( $wgUser->isSysop() )
882 foreach ( $pages['sysop'] as $name => $page ) {
883 $a[$name] = $page->getDescription();
886 if ( $wgUser->isDeveloper() )
888 foreach ( $pages['developer'] as $name => $page ) {
889 $a[$name] = $page->getDescription() ;
893 $sp = wfMsg( 'specialpages' );
894 $spp = $wgContLang->specialPage( 'Specialpages' );
896 $s = '<form id="specialpages" method="get" class="inline" ' .
897 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
898 $s .= "<select name=\"wpDropdown\">\n";
899 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
901 foreach ( $a as $name => $desc ) {
902 $p = $wgContLang->specialPage( $name );
903 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
906 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
911 function mainPageLink() {
912 $mp = wfMsgForContent( 'mainpage' );
913 $mptxt = wfMsg( 'mainpage');
914 $s = $this->makeKnownLink( $mp, $mptxt );
918 function copyrightLink() {
919 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
920 wfMsg( 'copyrightpagename' ) );
924 function aboutLink() {
925 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
926 wfMsg( 'aboutsite' ) );
931 function disclaimerLink() {
932 $disclaimers = wfMsg( 'disclaimers' );
933 if ($disclaimers == '-') {
936 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
941 function editThisPage() {
942 global $wgOut, $wgTitle, $wgRequest;
944 $oldid = $wgRequest->getVal( 'oldid' );
945 $diff = $wgRequest->getVal( 'diff' );
946 $redirect = $wgRequest->getVal( 'redirect' );
948 if ( ! $wgOut->isArticleRelated() ) {
949 $s = wfMsg( 'protectedpage' );
951 $n = $wgTitle->getPrefixedText();
952 if ( $wgTitle->userCanEdit() ) {
953 $t = wfMsg( 'editthispage' );
955 #$t = wfMsg( "protectedpage" );
956 $t = wfMsg( 'viewsource' );
960 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
961 if ( $oldid && ! isset( $diff ) ) {
962 $oid = '&oldid='.$oldid;
964 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
969 function deleteThisPage() {
970 global $wgUser, $wgOut, $wgTitle, $wgRequest;
972 $diff = $wgRequest->getVal( 'diff' );
973 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
974 $n = $wgTitle->getPrefixedText();
975 $t = wfMsg( 'deletethispage' );
977 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
984 function protectThisPage() {
985 global $wgUser, $wgOut, $wgTitle, $wgRequest;
987 $diff = $wgRequest->getVal( 'diff' );
988 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
989 $n = $wgTitle->getPrefixedText();
991 if ( $wgTitle->isProtected() ) {
992 $t = wfMsg( 'unprotectthispage' );
993 $q = 'action=unprotect';
995 $t = wfMsg( 'protectthispage' );
996 $q = 'action=protect';
998 $s = $this->makeKnownLink( $n, $t, $q );
1005 function watchThisPage() {
1006 global $wgUser, $wgOut, $wgTitle;
1008 if ( $wgOut->isArticleRelated() ) {
1009 $n = $wgTitle->getPrefixedText();
1011 if ( $wgTitle->userIsWatching() ) {
1012 $t = wfMsg( 'unwatchthispage' );
1013 $q = 'action=unwatch';
1015 $t = wfMsg( 'watchthispage' );
1016 $q = 'action=watch';
1018 $s = $this->makeKnownLink( $n, $t, $q );
1020 $s = wfMsg( 'notanarticle' );
1025 function moveThisPage() {
1026 global $wgTitle, $wgContLang;
1028 if ( $wgTitle->userCanMove() ) {
1029 return $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1030 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1032 // no message if page is protected - would be redundant
1037 function historyLink() {
1040 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1041 wfMsg( 'history' ), 'action=history' );
1045 function whatLinksHere() {
1046 global $wgTitle, $wgContLang;
1048 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1049 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1053 function userContribsLink() {
1054 global $wgTitle, $wgContLang;
1056 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1057 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1061 function showEmailUser( $id ) {
1062 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1063 return $wgEnableEmail &&
1064 $wgEnableUserEmail &&
1065 0 != $wgUser->getID() && # show only to signed in users
1066 0 != $id; # we can only email to non-anons ..
1067 # '' != $id->getEmail() && # who must have an email address stored ..
1068 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1069 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1072 function emailUserLink() {
1073 global $wgTitle, $wgContLang;
1075 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1076 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1080 function watchPageLinksLink() {
1081 global $wgOut, $wgTitle, $wgContLang;
1083 if ( ! $wgOut->isArticleRelated() ) {
1084 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1086 $s = $this->makeKnownLink( $wgContLang->specialPage(
1087 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1088 'target=' . $wgTitle->getPrefixedURL() );
1093 function otherLanguages() {
1094 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1096 $a = $wgOut->getLanguageLinks();
1097 if ( 0 == count( $a ) ) {
1098 if ( !$wgUseNewInterlanguage ) return '';
1099 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1100 if ( $ns != NS_MAIN
AND $ns != NS_TALK
) return '' ;
1102 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1103 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1104 wfMsg( 'intl' ) , $x );
1107 if ( !$wgUseNewInterlanguage ) {
1108 $s = wfMsg( 'otherlanguages' ) . ': ';
1110 global $wgContLanguageCode ;
1111 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1112 $x .= '&xl='.$wgContLanguageCode ;
1113 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1114 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1117 $s = wfMsg( 'otherlanguages' ) . ': ';
1119 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1120 foreach( $a as $l ) {
1121 if ( ! $first ) { $s .= ' | '; }
1124 $nt = Title
::newFromText( $l );
1125 $url = $nt->getFullURL();
1126 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1128 if ( '' == $text ) { $text = $l; }
1129 $style = $this->getExternalLinkAttributes( $l, $text );
1130 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1132 if($wgContLang->isRTL()) $s .= '</span>';
1136 function bugReportsLink() {
1137 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1138 wfMsg( 'bugreports' ) );
1142 function dateLink() {
1143 global $wgLinkCache;
1144 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1145 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1147 $wgLinkCache->suspend();
1148 $id = $t1->getArticleID();
1149 $wgLinkCache->resume();
1152 $s = $this->makeBrokenLink( $t1->getText() );
1154 $s = $this->makeKnownLink( $t1->getText() );
1158 $wgLinkCache->suspend();
1159 $id = $t2->getArticleID();
1160 $wgLinkCache->resume();
1163 $s .= $this->makeBrokenLink( $t2->getText() );
1165 $s .= $this->makeKnownLink( $t2->getText() );
1170 function talkLink() {
1171 global $wgContLang, $wgTitle, $wgLinkCache;
1173 $tns = $wgTitle->getNamespace();
1174 if ( -1 == $tns ) { return ''; }
1176 $pn = $wgTitle->getText();
1177 $tp = wfMsg( 'talkpage' );
1178 if ( Namespace::isTalk( $tns ) ) {
1179 $lns = Namespace::getSubject( $tns );
1182 $text = wfMsg('articlepage');
1185 $text = wfMsg('userpage');
1188 $text = wfMsg('wikipediapage');
1191 $text = wfMsg('imagepage');
1194 $text= wfMsg('articlepage');
1198 $lns = Namespace::getTalk( $tns );
1201 $n = $wgContLang->getNsText( $lns );
1202 if ( '' == $n ) { $link = $pn; }
1203 else { $link = $n.':'.$pn; }
1205 $wgLinkCache->suspend();
1206 $s = $this->makeLink( $link, $text );
1207 $wgLinkCache->resume();
1212 function commentLink() {
1213 global $wgContLang, $wgTitle, $wgLinkCache;
1215 $tns = $wgTitle->getNamespace();
1216 if ( -1 == $tns ) { return ''; }
1218 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1220 # assert Namespace::isTalk( $lns )
1222 $n = $wgContLang->getNsText( $lns );
1223 $pn = $wgTitle->getText();
1227 $wgLinkCache->suspend();
1228 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1229 $wgLinkCache->resume();
1234 /* these are used extensively in SkinPHPTal, but also some other places */
1235 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1236 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1237 $this->checkTitle($title, $name);
1238 return $title->getLocalURL( $urlaction );
1240 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1241 $title = Title
::newFromText( $name );
1242 $title = $title->getTalkPage();
1243 $this->checkTitle($title, $name);
1244 return $title->getLocalURL( $urlaction );
1246 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1247 $title = Title
::newFromText( $name );
1248 $title= $title->getSubjectPage();
1249 $this->checkTitle($title, $name);
1250 return $title->getLocalURL( $urlaction );
1252 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1253 $title = Title
::newFromText( wfMsgForContent($name) );
1254 $this->checkTitle($title, $name);
1255 return $title->getLocalURL( $urlaction );
1257 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1258 $title = Title
::newFromText( $name );
1259 $this->checkTitle($title, $name);
1260 return $title->getLocalURL( $urlaction );
1263 # If url string starts with http, consider as external URL, else
1265 /*static*/ function makeInternalOrExternalUrl( $name ) {
1266 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1269 return $this->makeUrl( $name );
1273 # this can be passed the NS number as defined in Language.php
1274 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1275 $title = Title
::makeTitleSafe( $namespace, $name );
1276 $this->checkTitle($title, $name);
1277 return $title->getLocalURL( $urlaction );
1280 /* these return an array with the 'href' and boolean 'exists' */
1281 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1282 $title = Title
::newFromText( $name );
1283 $this->checkTitle($title, $name);
1285 'href' => $title->getLocalURL( $urlaction ),
1286 'exists' => $title->getArticleID() != 0?
true:false
1289 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1290 $title = Title
::newFromText( $name );
1291 $title = $title->getTalkPage();
1292 $this->checkTitle($title, $name);
1294 'href' => $title->getLocalURL( $urlaction ),
1295 'exists' => $title->getArticleID() != 0?
true:false
1298 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1299 $title = Title
::newFromText( $name );
1300 $title= $title->getSubjectPage();
1301 $this->checkTitle($title, $name);
1303 'href' => $title->getLocalURL( $urlaction ),
1304 'exists' => $title->getArticleID() != 0?
true:false
1307 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1308 $title = Title
::newFromText( wfMsgForContent($name) );
1309 $this->checkTitle($title, $name);
1311 'href' => $title->getLocalURL( $urlaction ),
1312 'exists' => $title->getArticleID() != 0?
true:false
1316 # make sure we have some title to operate on
1317 /*static*/ function checkTitle ( &$title, &$name ) {
1318 if(!is_object($title)) {
1319 $title = Title
::newFromText( $name );
1320 if(!is_object($title)) {
1321 $title = Title
::newFromText( '--error: link target missing--' );