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;
837 $timestamp = $wgArticle->getTimestamp();
839 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
840 $s = ' ' . wfMsg( 'lastmodified', $d );
847 function logoText( $align = '' ) {
848 if ( '' != $align ) { $a = " align='{$align}'"; }
851 $mp = wfMsg( 'mainpage' );
852 $titleObj = Title
::newFromText( $mp );
853 if ( is_object( $titleObj ) ) {
854 $url = $titleObj->escapeLocalURL();
859 $logourl = $this->getLogo();
860 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
865 * show a drop-down box of special pages
866 * @TODO crash bug913. Need to be rewrote completly.
868 function specialPagesList() {
869 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
870 require_once('SpecialPage.php');
872 $pages = SpecialPage
::getPages();
874 foreach ( $pages[''] as $name => $page ) {
875 $a[$name] = $page->getDescription();
877 if ( $wgUser->isSysop() )
879 foreach ( $pages['sysop'] as $name => $page ) {
880 $a[$name] = $page->getDescription();
883 if ( $wgUser->isDeveloper() )
885 foreach ( $pages['developer'] as $name => $page ) {
886 $a[$name] = $page->getDescription() ;
890 $sp = wfMsg( 'specialpages' );
891 $spp = $wgContLang->specialPage( 'Specialpages' );
893 $s = '<form id="specialpages" method="get" class="inline" ' .
894 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
895 $s .= "<select name=\"wpDropdown\">\n";
896 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
898 foreach ( $a as $name => $desc ) {
899 $p = $wgContLang->specialPage( $name );
900 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
903 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
908 function mainPageLink() {
909 $mp = wfMsgForContent( 'mainpage' );
910 $mptxt = wfMsg( 'mainpage');
911 $s = $this->makeKnownLink( $mp, $mptxt );
915 function copyrightLink() {
916 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
917 wfMsg( 'copyrightpagename' ) );
921 function aboutLink() {
922 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
923 wfMsg( 'aboutsite' ) );
928 function disclaimerLink() {
929 $disclaimers = wfMsg( 'disclaimers' );
930 if ($disclaimers == '-') {
933 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
938 function editThisPage() {
939 global $wgOut, $wgTitle, $wgRequest;
941 $oldid = $wgRequest->getVal( 'oldid' );
942 $diff = $wgRequest->getVal( 'diff' );
943 $redirect = $wgRequest->getVal( 'redirect' );
945 if ( ! $wgOut->isArticleRelated() ) {
946 $s = wfMsg( 'protectedpage' );
948 $n = $wgTitle->getPrefixedText();
949 if ( $wgTitle->userCanEdit() ) {
950 $t = wfMsg( 'editthispage' );
952 #$t = wfMsg( "protectedpage" );
953 $t = wfMsg( 'viewsource' );
957 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
958 if ( $oldid && ! isset( $diff ) ) {
959 $oid = '&oldid='.$oldid;
961 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
966 function deleteThisPage() {
967 global $wgUser, $wgOut, $wgTitle, $wgRequest;
969 $diff = $wgRequest->getVal( 'diff' );
970 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
971 $n = $wgTitle->getPrefixedText();
972 $t = wfMsg( 'deletethispage' );
974 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
981 function protectThisPage() {
982 global $wgUser, $wgOut, $wgTitle, $wgRequest;
984 $diff = $wgRequest->getVal( 'diff' );
985 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
986 $n = $wgTitle->getPrefixedText();
988 if ( $wgTitle->isProtected() ) {
989 $t = wfMsg( 'unprotectthispage' );
990 $q = 'action=unprotect';
992 $t = wfMsg( 'protectthispage' );
993 $q = 'action=protect';
995 $s = $this->makeKnownLink( $n, $t, $q );
1002 function watchThisPage() {
1003 global $wgUser, $wgOut, $wgTitle;
1005 if ( $wgOut->isArticleRelated() ) {
1006 $n = $wgTitle->getPrefixedText();
1008 if ( $wgTitle->userIsWatching() ) {
1009 $t = wfMsg( 'unwatchthispage' );
1010 $q = 'action=unwatch';
1012 $t = wfMsg( 'watchthispage' );
1013 $q = 'action=watch';
1015 $s = $this->makeKnownLink( $n, $t, $q );
1017 $s = wfMsg( 'notanarticle' );
1022 function moveThisPage() {
1023 global $wgTitle, $wgContLang;
1025 if ( $wgTitle->userCanMove() ) {
1026 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1027 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1028 } // no message if page is protected - would be redundant
1032 function historyLink() {
1035 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1036 wfMsg( 'history' ), 'action=history' );
1040 function whatLinksHere() {
1041 global $wgTitle, $wgContLang;
1043 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1044 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1048 function userContribsLink() {
1049 global $wgTitle, $wgContLang;
1051 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1052 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1056 function showEmailUser( $id ) {
1057 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1058 return $wgEnableEmail &&
1059 $wgEnableUserEmail &&
1060 0 != $wgUser->getID() && # show only to signed in users
1061 0 != $id; # we can only email to non-anons ..
1062 # '' != $id->getEmail() && # who must have an email address stored ..
1063 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1064 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1067 function emailUserLink() {
1068 global $wgTitle, $wgContLang;
1070 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1071 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1075 function watchPageLinksLink() {
1076 global $wgOut, $wgTitle, $wgContLang;
1078 if ( ! $wgOut->isArticleRelated() ) {
1079 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1081 $s = $this->makeKnownLink( $wgContLang->specialPage(
1082 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1083 'target=' . $wgTitle->getPrefixedURL() );
1088 function otherLanguages() {
1089 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1091 $a = $wgOut->getLanguageLinks();
1092 if ( 0 == count( $a ) ) {
1093 if ( !$wgUseNewInterlanguage ) return '';
1094 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1095 if ( $ns != NS_MAIN
AND $ns != NS_TALK
) return '' ;
1097 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1098 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1099 wfMsg( 'intl' ) , $x );
1102 if ( !$wgUseNewInterlanguage ) {
1103 $s = wfMsg( 'otherlanguages' ) . ': ';
1105 global $wgContLanguageCode ;
1106 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1107 $x .= '&xl='.$wgContLanguageCode ;
1108 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1109 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1112 $s = wfMsg( 'otherlanguages' ) . ': ';
1114 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1115 foreach( $a as $l ) {
1116 if ( ! $first ) { $s .= ' | '; }
1119 $nt = Title
::newFromText( $l );
1120 $url = $nt->getFullURL();
1121 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1123 if ( '' == $text ) { $text = $l; }
1124 $style = $this->getExternalLinkAttributes( $l, $text );
1125 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1127 if($wgContLang->isRTL()) $s .= '</span>';
1131 function bugReportsLink() {
1132 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1133 wfMsg( 'bugreports' ) );
1137 function dateLink() {
1138 global $wgLinkCache;
1139 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1140 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1142 $wgLinkCache->suspend();
1143 $id = $t1->getArticleID();
1144 $wgLinkCache->resume();
1147 $s = $this->makeBrokenLink( $t1->getText() );
1149 $s = $this->makeKnownLink( $t1->getText() );
1153 $wgLinkCache->suspend();
1154 $id = $t2->getArticleID();
1155 $wgLinkCache->resume();
1158 $s .= $this->makeBrokenLink( $t2->getText() );
1160 $s .= $this->makeKnownLink( $t2->getText() );
1165 function talkLink() {
1166 global $wgContLang, $wgTitle, $wgLinkCache;
1168 $tns = $wgTitle->getNamespace();
1169 if ( -1 == $tns ) { return ''; }
1171 $pn = $wgTitle->getText();
1172 $tp = wfMsg( 'talkpage' );
1173 if ( Namespace::isTalk( $tns ) ) {
1174 $lns = Namespace::getSubject( $tns );
1177 $text = wfMsg('articlepage');
1180 $text = wfMsg('userpage');
1183 $text = wfMsg('wikipediapage');
1186 $text = wfMsg('imagepage');
1189 $text= wfMsg('articlepage');
1193 $lns = Namespace::getTalk( $tns );
1196 $n = $wgContLang->getNsText( $lns );
1197 if ( '' == $n ) { $link = $pn; }
1198 else { $link = $n.':'.$pn; }
1200 $wgLinkCache->suspend();
1201 $s = $this->makeLink( $link, $text );
1202 $wgLinkCache->resume();
1207 function commentLink() {
1208 global $wgContLang, $wgTitle, $wgLinkCache;
1210 $tns = $wgTitle->getNamespace();
1211 if ( -1 == $tns ) { return ''; }
1213 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1215 # assert Namespace::isTalk( $lns )
1217 $n = $wgContLang->getNsText( $lns );
1218 $pn = $wgTitle->getText();
1222 $wgLinkCache->suspend();
1223 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1224 $wgLinkCache->resume();
1229 /* these are used extensively in SkinPHPTal, but also some other places */
1230 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1231 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1232 $this->checkTitle($title, $name);
1233 return $title->getLocalURL( $urlaction );
1235 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1236 $title = Title
::newFromText( $name );
1237 $title = $title->getTalkPage();
1238 $this->checkTitle($title, $name);
1239 return $title->getLocalURL( $urlaction );
1241 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1242 $title = Title
::newFromText( $name );
1243 $title= $title->getSubjectPage();
1244 $this->checkTitle($title, $name);
1245 return $title->getLocalURL( $urlaction );
1247 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1248 $title = Title
::newFromText( wfMsgForContent($name) );
1249 $this->checkTitle($title, $name);
1250 return $title->getLocalURL( $urlaction );
1252 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1253 $title = Title
::newFromText( $name );
1254 $this->checkTitle($title, $name);
1255 return $title->getLocalURL( $urlaction );
1258 # If url string starts with http, consider as external URL, else
1260 /*static*/ function makeInternalOrExternalUrl( $name ) {
1261 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1264 return $this->makeUrl( $name );
1268 # this can be passed the NS number as defined in Language.php
1269 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1270 $title = Title
::makeTitleSafe( $namespace, $name );
1271 $this->checkTitle($title, $name);
1272 return $title->getLocalURL( $urlaction );
1275 /* these return an array with the 'href' and boolean 'exists' */
1276 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1277 $title = Title
::newFromText( $name );
1278 $this->checkTitle($title, $name);
1280 'href' => $title->getLocalURL( $urlaction ),
1281 'exists' => $title->getArticleID() != 0?
true:false
1284 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1285 $title = Title
::newFromText( $name );
1286 $title = $title->getTalkPage();
1287 $this->checkTitle($title, $name);
1289 'href' => $title->getLocalURL( $urlaction ),
1290 'exists' => $title->getArticleID() != 0?
true:false
1293 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1294 $title = Title
::newFromText( $name );
1295 $title= $title->getSubjectPage();
1296 $this->checkTitle($title, $name);
1298 'href' => $title->getLocalURL( $urlaction ),
1299 'exists' => $title->getArticleID() != 0?
true:false
1302 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1303 $title = Title
::newFromText( wfMsgForContent($name) );
1304 $this->checkTitle($title, $name);
1306 'href' => $title->getLocalURL( $urlaction ),
1307 'exists' => $title->getArticleID() != 0?
true:false
1311 # make sure we have some title to operate on
1312 /*static*/ function checkTitle ( &$title, &$name ) {
1313 if(!is_object($title)) {
1314 $title = Title
::newFromText( $name );
1315 if(!is_object($title)) {
1316 $title = Title
::newFromText( '--error: link target missing--' );