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;
810 if( $wgRightsIcon ) {
811 $icon = htmlspecialchars( $wgRightsIcon );
813 $url = htmlspecialchars( $wgRightsUrl );
814 $out .= '<a href="'.$url.'">';
816 $text = htmlspecialchars( $wgRightsText );
817 $out .= "<img src=\"$icon\" alt='$text' />";
825 function getPoweredBy() {
827 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
828 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
832 function lastModified() {
833 global $wgLang, $wgArticle;
835 $timestamp = $wgArticle->getTimestamp();
837 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
838 $s = ' ' . wfMsg( 'lastmodified', $d );
845 function logoText( $align = '' ) {
846 if ( '' != $align ) { $a = " align='{$align}'"; }
849 $mp = wfMsg( 'mainpage' );
850 $titleObj = Title
::newFromText( $mp );
851 if ( is_object( $titleObj ) ) {
852 $url = $titleObj->escapeLocalURL();
857 $logourl = $this->getLogo();
858 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
863 * show a drop-down box of special pages
864 * @TODO crash bug913. Need to be rewrote completly.
866 function specialPagesList() {
867 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
868 require_once('SpecialPage.php');
870 $pages = SpecialPage
::getPages();
872 foreach ( $pages[''] as $name => $page ) {
873 $a[$name] = $page->getDescription();
875 if ( $wgUser->isSysop() )
877 foreach ( $pages['sysop'] as $name => $page ) {
878 $a[$name] = $page->getDescription();
881 if ( $wgUser->isDeveloper() )
883 foreach ( $pages['developer'] as $name => $page ) {
884 $a[$name] = $page->getDescription() ;
888 $sp = wfMsg( 'specialpages' );
889 $spp = $wgContLang->specialPage( 'Specialpages' );
891 $s = '<form id="specialpages" method="get" class="inline" ' .
892 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
893 $s .= "<select name=\"wpDropdown\">\n";
894 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
896 foreach ( $a as $name => $desc ) {
897 $p = $wgContLang->specialPage( $name );
898 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
901 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
906 function mainPageLink() {
907 $mp = wfMsgForContent( 'mainpage' );
908 $mptxt = wfMsg( 'mainpage');
909 $s = $this->makeKnownLink( $mp, $mptxt );
913 function copyrightLink() {
914 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
915 wfMsg( 'copyrightpagename' ) );
919 function aboutLink() {
920 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
921 wfMsg( 'aboutsite' ) );
926 function disclaimerLink() {
927 $disclaimers = wfMsg( 'disclaimers' );
928 if ($disclaimers == '-') {
931 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
936 function editThisPage() {
937 global $wgOut, $wgTitle, $wgRequest;
939 $oldid = $wgRequest->getVal( 'oldid' );
940 $diff = $wgRequest->getVal( 'diff' );
941 $redirect = $wgRequest->getVal( 'redirect' );
943 if ( ! $wgOut->isArticleRelated() ) {
944 $s = wfMsg( 'protectedpage' );
946 $n = $wgTitle->getPrefixedText();
947 if ( $wgTitle->userCanEdit() ) {
948 $t = wfMsg( 'editthispage' );
950 #$t = wfMsg( "protectedpage" );
951 $t = wfMsg( 'viewsource' );
955 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
956 if ( $oldid && ! isset( $diff ) ) {
957 $oid = '&oldid='.$oldid;
959 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
964 function deleteThisPage() {
965 global $wgUser, $wgOut, $wgTitle, $wgRequest;
967 $diff = $wgRequest->getVal( 'diff' );
968 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
969 $n = $wgTitle->getPrefixedText();
970 $t = wfMsg( 'deletethispage' );
972 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
979 function protectThisPage() {
980 global $wgUser, $wgOut, $wgTitle, $wgRequest;
982 $diff = $wgRequest->getVal( 'diff' );
983 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
984 $n = $wgTitle->getPrefixedText();
986 if ( $wgTitle->isProtected() ) {
987 $t = wfMsg( 'unprotectthispage' );
988 $q = 'action=unprotect';
990 $t = wfMsg( 'protectthispage' );
991 $q = 'action=protect';
993 $s = $this->makeKnownLink( $n, $t, $q );
1000 function watchThisPage() {
1001 global $wgUser, $wgOut, $wgTitle;
1003 if ( $wgOut->isArticleRelated() ) {
1004 $n = $wgTitle->getPrefixedText();
1006 if ( $wgTitle->userIsWatching() ) {
1007 $t = wfMsg( 'unwatchthispage' );
1008 $q = 'action=unwatch';
1010 $t = wfMsg( 'watchthispage' );
1011 $q = 'action=watch';
1013 $s = $this->makeKnownLink( $n, $t, $q );
1015 $s = wfMsg( 'notanarticle' );
1020 function moveThisPage() {
1021 global $wgTitle, $wgContLang;
1023 if ( $wgTitle->userCanMove() ) {
1024 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1025 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1026 } // no message if page is protected - would be redundant
1030 function historyLink() {
1033 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1034 wfMsg( 'history' ), 'action=history' );
1038 function whatLinksHere() {
1039 global $wgTitle, $wgContLang;
1041 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1042 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1046 function userContribsLink() {
1047 global $wgTitle, $wgContLang;
1049 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1050 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1054 function showEmailUser( $id ) {
1055 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1056 return $wgEnableEmail &&
1057 $wgEnableUserEmail &&
1058 0 != $wgUser->getID() && # show only to signed in users
1059 0 != $id; # we can only email to non-anons ..
1060 # '' != $id->getEmail() && # who must have an email address stored ..
1061 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1062 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1065 function emailUserLink() {
1066 global $wgTitle, $wgContLang;
1068 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1069 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1073 function watchPageLinksLink() {
1074 global $wgOut, $wgTitle, $wgContLang;
1076 if ( ! $wgOut->isArticleRelated() ) {
1077 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1079 $s = $this->makeKnownLink( $wgContLang->specialPage(
1080 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1081 'target=' . $wgTitle->getPrefixedURL() );
1086 function otherLanguages() {
1087 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1089 $a = $wgOut->getLanguageLinks();
1090 if ( 0 == count( $a ) ) {
1091 if ( !$wgUseNewInterlanguage ) return '';
1092 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1093 if ( $ns != 0 AND $ns != 1 ) return '' ;
1095 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1096 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1097 wfMsg( 'intl' ) , $x );
1100 if ( !$wgUseNewInterlanguage ) {
1101 $s = wfMsg( 'otherlanguages' ) . ': ';
1103 global $wgContLanguageCode ;
1104 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1105 $x .= '&xl='.$wgContLanguageCode ;
1106 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1107 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1110 $s = wfMsg( 'otherlanguages' ) . ': ';
1112 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1113 foreach( $a as $l ) {
1114 if ( ! $first ) { $s .= ' | '; }
1117 $nt = Title
::newFromText( $l );
1118 $url = $nt->getFullURL();
1119 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1121 if ( '' == $text ) { $text = $l; }
1122 $style = $this->getExternalLinkAttributes( $l, $text );
1123 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1125 if($wgContLang->isRTL()) $s .= '</span>';
1129 function bugReportsLink() {
1130 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1131 wfMsg( 'bugreports' ) );
1135 function dateLink() {
1136 global $wgLinkCache;
1137 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1138 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1140 $wgLinkCache->suspend();
1141 $id = $t1->getArticleID();
1142 $wgLinkCache->resume();
1145 $s = $this->makeBrokenLink( $t1->getText() );
1147 $s = $this->makeKnownLink( $t1->getText() );
1151 $wgLinkCache->suspend();
1152 $id = $t2->getArticleID();
1153 $wgLinkCache->resume();
1156 $s .= $this->makeBrokenLink( $t2->getText() );
1158 $s .= $this->makeKnownLink( $t2->getText() );
1163 function talkLink() {
1164 global $wgContLang, $wgTitle, $wgLinkCache;
1166 $tns = $wgTitle->getNamespace();
1167 if ( -1 == $tns ) { return ''; }
1169 $pn = $wgTitle->getText();
1170 $tp = wfMsg( 'talkpage' );
1171 if ( Namespace::isTalk( $tns ) ) {
1172 $lns = Namespace::getSubject( $tns );
1175 $text = wfMsg('articlepage');
1178 $text = wfMsg('userpage');
1181 $text = wfMsg('wikipediapage');
1184 $text = wfMsg('imagepage');
1187 $text= wfMsg('articlepage');
1191 $lns = Namespace::getTalk( $tns );
1194 $n = $wgContLang->getNsText( $lns );
1195 if ( '' == $n ) { $link = $pn; }
1196 else { $link = $n.':'.$pn; }
1198 $wgLinkCache->suspend();
1199 $s = $this->makeLink( $link, $text );
1200 $wgLinkCache->resume();
1205 function commentLink() {
1206 global $wgContLang, $wgTitle, $wgLinkCache;
1208 $tns = $wgTitle->getNamespace();
1209 if ( -1 == $tns ) { return ''; }
1211 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1213 # assert Namespace::isTalk( $lns )
1215 $n = $wgContLang->getNsText( $lns );
1216 $pn = $wgTitle->getText();
1220 $wgLinkCache->suspend();
1221 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1222 $wgLinkCache->resume();
1227 /* these are used extensively in SkinPHPTal, but also some other places */
1228 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1229 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1230 $this->checkTitle($title, $name);
1231 return $title->getLocalURL( $urlaction );
1233 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1234 $title = Title
::newFromText( $name );
1235 $title = $title->getTalkPage();
1236 $this->checkTitle($title, $name);
1237 return $title->getLocalURL( $urlaction );
1239 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1240 $title = Title
::newFromText( $name );
1241 $title= $title->getSubjectPage();
1242 $this->checkTitle($title, $name);
1243 return $title->getLocalURL( $urlaction );
1245 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1246 $title = Title
::newFromText( wfMsgForContent($name) );
1247 $this->checkTitle($title, $name);
1248 return $title->getLocalURL( $urlaction );
1250 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1251 $title = Title
::newFromText( $name );
1252 $this->checkTitle($title, $name);
1253 return $title->getLocalURL( $urlaction );
1256 # If url string starts with http, consider as external URL, else
1258 /*static*/ function makeInternalOrExternalUrl( $name ) {
1259 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1262 return $this->makeUrl( $name );
1266 # this can be passed the NS number as defined in Language.php
1267 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1268 $title = Title
::makeTitleSafe( $namespace, $name );
1269 $this->checkTitle($title, $name);
1270 return $title->getLocalURL( $urlaction );
1273 /* these return an array with the 'href' and boolean 'exists' */
1274 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1275 $title = Title
::newFromText( $name );
1276 $this->checkTitle($title, $name);
1278 'href' => $title->getLocalURL( $urlaction ),
1279 'exists' => $title->getArticleID() != 0?
true:false
1282 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1283 $title = Title
::newFromText( $name );
1284 $title = $title->getTalkPage();
1285 $this->checkTitle($title, $name);
1287 'href' => $title->getLocalURL( $urlaction ),
1288 'exists' => $title->getArticleID() != 0?
true:false
1291 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1292 $title = Title
::newFromText( $name );
1293 $title= $title->getSubjectPage();
1294 $this->checkTitle($title, $name);
1296 'href' => $title->getLocalURL( $urlaction ),
1297 'exists' => $title->getArticleID() != 0?
true:false
1300 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1301 $title = Title
::newFromText( wfMsgForContent($name) );
1302 $this->checkTitle($title, $name);
1304 'href' => $title->getLocalURL( $urlaction ),
1305 'exists' => $title->getArticleID() != 0?
true:false
1309 # make sure we have some title to operate on
1310 /*static*/ function checkTitle ( &$title, &$name ) {
1311 if(!is_object($title)) {
1312 $title = Title
::newFromText( $name );
1313 if(!is_object($title)) {
1314 $title = Title
::newFromText( '--error: link target missing--' );