10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Image.php' );
17 # Get a list of all skins available in /skins/
18 # Build using the regular expression '^(.*).php$'
19 # Array keys are all lower case, array value keep the case used by filename
22 $skinDir = dir($IP.'/skins');
24 # while code from www.php.net
25 while (false !== ($file = $skinDir->read())) {
26 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
28 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
34 require_once( 'RecentChange.php' );
36 global $wgLinkHolders;
37 $wgLinkHolders = array(
38 'namespaces' => array(),
44 global $wgInterwikiLinkHolders;
45 $wgInterwikiLinkHolders = array();
51 class RCCacheEntry
extends RecentChange
53 var $secureName, $link;
54 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
55 var $userlink, $timestamp, $watched;
57 function newFromParent( $rc )
59 $rc2 = new RCCacheEntry
;
60 $rc2->mAttribs
= $rc->mAttribs
;
61 $rc2->mExtra
= $rc->mExtra
;
68 * The main skin class that provide methods and properties for all other skins
69 * including PHPTal skins.
70 * This base class is also the "Standard" skin.
77 var $lastdate, $lastline;
78 var $linktrail ; # linktrail regexp
79 var $rc_cache ; # Cache for Enhanced Recent Changes
80 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
82 var $postParseLinkColour = false;
86 $this->linktrail
= wfMsgForContent('linktrail');
88 # Cache option lookups done very frequently
89 $options = array( 'highlightbroken', 'hover' );
90 foreach( $options as $opt ) {
92 $this->mOptions
[$opt] = $wgUser->getOption( $opt );
96 function getSkinNames() {
97 global $wgValidSkinNames;
98 return $wgValidSkinNames;
101 function getStylesheet() {
102 return 'common/wikistandard.css';
105 function getSkinName() {
110 * Get/set accessor for delayed link colouring
112 function postParseLinkColour( $setting = NULL ) {
113 return wfSetVar( $this->postParseLinkColour
, $setting );
116 function qbSetting() {
117 global $wgOut, $wgUser;
119 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
120 $q = $wgUser->getOption( 'quickbar' );
121 if ( '' == $q ) { $q = 0; }
125 function initPage( &$out ) {
126 $fname = 'Skin::initPage';
127 wfProfileIn( $fname );
129 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
131 $this->addMetadataLinks($out);
133 wfProfileOut( $fname );
136 function addMetadataLinks( &$out ) {
137 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
138 global $wgRightsPage, $wgRightsUrl;
140 if( $out->isArticleRelated() ) {
141 # note: buggy CC software only reads first "meta" link
142 if( $wgEnableCreativeCommonsRdf ) {
143 $out->addMetadataLink( array(
144 'title' => 'Creative Commons',
145 'type' => 'application/rdf+xml',
146 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
148 if( $wgEnableDublinCoreRdf ) {
149 $out->addMetadataLink( array(
150 'title' => 'Dublin Core',
151 'type' => 'application/rdf+xml',
152 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
156 if( $wgRightsPage ) {
157 $copy = Title
::newFromText( $wgRightsPage );
159 $copyright = $copy->getLocalURL();
162 if( !$copyright && $wgRightsUrl ) {
163 $copyright = $wgRightsUrl;
166 $out->addLink( array(
167 'rel' => 'copyright',
168 'href' => $copyright ) );
172 function outputPage( &$out ) {
173 global $wgDebugComments;
175 wfProfileIn( 'Skin::outputPage' );
176 $this->initPage( $out );
177 $out->out( $out->headElement() );
179 $out->out( "\n<body" );
180 $ops = $this->getBodyOptions();
181 foreach ( $ops as $name => $val ) {
182 $out->out( " $name='$val'" );
185 if ( $wgDebugComments ) {
186 $out->out( "<!-- Wiki debugging output:\n" .
187 $out->mDebugtext
. "-->\n" );
189 $out->out( $this->beforeContent() );
191 $out->out( $out->mBodytext
. "\n" );
193 $out->out( $this->afterContent() );
196 $out->out( $out->reportTime() );
198 $out->out( "\n</body></html>" );
201 function getHeadScripts() {
202 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
203 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
204 if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
205 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
206 $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
207 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
212 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
213 function getUserStylesheet() {
214 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
215 $sheet = $this->getStylesheet();
216 $action = $wgRequest->getText('action');
217 $s = "@import \"$wgStylePath/$sheet\";\n";
218 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
219 if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
220 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
221 $s .= $wgRequest->getText('wpTextbox1');
223 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
224 $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
227 $s .= $this->doGetUserStyles();
232 * placeholder, returns generated js in monobook
234 function getUserJs() { return; }
237 * Return html code that include User stylesheets
239 function getUserStyles() {
240 global $wgOut, $wgStylePath, $wgLang;
241 $s = "<style type='text/css'>\n";
242 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
243 $s .= $this->getUserStylesheet();
244 $s .= "/*]]>*/ /* */\n";
250 * Some styles that are set by user through the user settings interface.
252 function doGetUserStyles() {
253 global $wgUser, $wgContLang;
255 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
256 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
258 if ( 1 == $wgUser->getOption( 'underline' ) ) {
259 # Don't override browser settings
263 $s .= "a { text-decoration: none; }\n";
265 if ( 1 == $this->mOptions
['highlightbroken'] ) {
266 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
268 if ( 1 == $wgUser->getOption( 'justify' ) ) {
269 $s .= "#article { text-align: justify; }\n";
274 function getBodyOptions() {
275 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
277 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
279 if ( 0 != $wgTitle->getNamespace() ) {
280 $a = array( 'bgcolor' => '#ffffec' );
282 else $a = array( 'bgcolor' => '#FFFFFF' );
283 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
284 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
285 $t = wfMsg( 'editthispage' );
287 if ( !empty($redirect) && $redirect == 'no' ) {
288 $red = "&redirect={$redirect}";
290 if ( !empty($oldid) && ! isset( $diff ) ) {
291 $oid = "&oldid=" . IntVal( $oldid );
293 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
294 $s = 'document.location = "' .$s .'";';
295 $a +
= array ('ondblclick' => $s);
298 $a['onload'] = $wgOut->getOnloadHandler();
302 function getExternalLinkAttributes( $link, $text, $class='' ) {
305 $same = ($link == $text);
306 $link = urldecode( $link );
307 $link = $wgContLang->checkTitleEncoding( $link );
308 $link = str_replace( '_', ' ', $link );
309 $link = htmlspecialchars( $link );
311 $r = ($class != '') ?
" class='$class'" : " class='external'";
313 if( !$same && $this->mOptions
['hover'] ) {
314 $r .= " title=\"{$link}\"";
319 function getInternalLinkAttributes( $link, $text, $broken = false ) {
320 $link = urldecode( $link );
321 $link = str_replace( '_', ' ', $link );
322 $link = htmlspecialchars( $link );
324 if( $broken == 'stub' ) {
325 $r = ' class="stub"';
326 } else if ( $broken == 'yes' ) {
332 if( $this->mOptions
['hover'] ) {
333 $r .= " title=\"{$link}\"";
339 * @param bool $broken
341 function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
342 if( $broken == 'stub' ) {
343 $r = ' class="stub"';
344 } else if ( $broken == 'yes' ) {
350 if( $this->mOptions
['hover'] ) {
351 $r .= ' title="' . $nt->getEscapedText() . '"';
365 * This will be called immediately after the <body> tag. Split into
366 * two functions to make it easier to subclass.
368 function beforeContent() {
369 global $wgUser, $wgOut;
371 return $this->doBeforeContent();
374 function doBeforeContent() {
375 global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
376 $fname = 'Skin::doBeforeContent';
377 wfProfileIn( $fname );
380 $qb = $this->qbSetting();
382 if( $langlinks = $this->otherLanguages() ) {
388 $borderhack = 'class="top"';
391 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
392 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
395 $left = ($qb == 1 ||
$qb == 3);
396 if($wgContLang->isRTL()) $left = !$left;
399 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
400 $this->logoText() . '</td>';
402 $s .= $this->getQuickbarCompensator( $rows );
404 $l = $wgContLang->isRTL() ?
'right' : 'left';
405 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
407 $s .= $this->topLinks() ;
408 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
410 $r = $wgContLang->isRTL() ?
"left" : "right";
411 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
412 $s .= $this->nameAndLogin();
413 $s .= "\n<br />" . $this->searchForm() . "</td>";
416 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
419 if ( $shove && !$left ) { # Right
420 $s .= $this->getQuickbarCompensator( $rows );
422 $s .= "</tr>\n</table>\n</div>\n";
423 $s .= "\n<div id='article'>\n";
425 if( $wgSiteNotice ) {
426 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
428 $s .= $this->pageTitle();
429 $s .= $this->pageSubtitle() ;
430 $s .= $this->getCategories();
431 wfProfileOut( $fname );
436 function getCategoryLinks () {
437 global $wgOut, $wgTitle, $wgUser, $wgParser;
438 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
440 if( !$wgUseCategoryMagic ) return '' ;
441 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
443 # Taken out so that they will be displayed in previews -- TS
444 #if( !$wgOut->isArticle() ) return '';
446 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
447 $s = $this->makeKnownLink( 'Special:Categories',
448 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
451 # optional 'dmoz-like' category browser. Will be shown under the list
452 # of categories an article belong to
453 if($wgUseCategoryBrowser) {
456 # get a big array of the parents tree
457 $parenttree = $wgTitle->getParentCategoryTree();
459 # Render the array as a serie of links
460 function walkThrough ($tree) {
462 $sk = $wgUser->getSkin();
464 foreach($tree as $element => $parent) {
466 # element start a new list
469 # grab the others elements
470 $return .= walkThrough($parent);
472 # add our current element to the list
473 $eltitle = Title
::NewFromText($element);
474 # FIXME : should be makeLink() [AV]
475 $return .= $sk->makeLink($element, $eltitle->getText()).' > ';
480 $s .= walkThrough($parenttree);
486 function getCategories() {
487 $catlinks=$this->getCategoryLinks();
488 if(!empty($catlinks)) {
489 return "<p class='catlinks'>{$catlinks}</p>";
493 function getQuickbarCompensator( $rows = 1 ) {
494 return "<td width='152' rowspan='{$rows}'> </td>";
497 # This gets called immediately before the </body> tag.
499 function afterContent() {
500 global $wgUser, $wgOut, $wgServer;
501 global $wgTitle, $wgLang;
503 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
504 return $printfooter . $this->doAfterContent();
507 function printSource() {
509 $url = htmlspecialchars( $wgTitle->getFullURL() );
510 return wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" );
513 function printFooter() {
514 return "<p>" . $this->printSource() .
515 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
518 function doAfterContent() {
519 # overloaded by derived classes
522 function pageTitleLinks() {
523 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
525 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
526 $action = $wgRequest->getText( 'action' );
528 $s = $this->printableLink();
529 $disclaimer = $this->disclaimerLink(); # may be empty
531 $s .= ' | ' . $disclaimer;
534 if ( $wgOut->isArticleRelated() ) {
535 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
536 $name = $wgTitle->getDBkey();
537 $link = htmlspecialchars( Image
::wfImageUrl( $name ) );
538 $style = $this->getInternalLinkAttributes( $link, $name );
539 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
541 # This will show the "Approve" link if $wgUseApproval=true;
542 if ( isset ( $wgUseApproval ) && $wgUseApproval )
544 $t = $wgTitle->getDBkey();
545 $name = 'Approve this article' ;
546 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
547 #htmlspecialchars( wfImageUrl( $name ) );
548 $style = $this->getExternalLinkAttributes( $link, $name );
549 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
552 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
553 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
554 wfMsg( 'currentrev' ) );
557 if ( $wgUser->getNewtalk() ) {
558 # do not show "You have new messages" text when we are viewing our
561 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
562 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
563 $n =$wgUser->getName();
564 $tl = $this->makeKnownLink( $wgContLang->getNsText(
565 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
566 wfMsg('newmessageslink') );
567 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
569 $wgOut->setSquidMaxage(0);
570 $wgOut->enableClientCache(false);
574 $undelete = $this->getUndeleteLink();
575 if( !empty( $undelete ) ) {
576 $s .= ' | '.$undelete;
581 function getUndeleteLink() {
582 global $wgUser, $wgTitle, $wgContLang, $action;
583 if( $wgUser->isAllowed('rollback') &&
584 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
585 ($n = $wgTitle->isDeleted() ) ) {
586 return wfMsg( 'thisisdeleted',
587 $this->makeKnownLink(
588 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
589 wfMsg( 'restorelink', $n ) ) );
594 function printableLink() {
595 global $wgOut, $wgFeedClasses, $wgRequest;
597 $baseurl = $_SERVER['REQUEST_URI'];
598 if( strpos( '?', $baseurl ) == false ) {
603 $baseurl = htmlspecialchars( $baseurl );
604 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
606 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
607 if( $wgOut->isSyndicated() ) {
608 foreach( $wgFeedClasses as $format => $class ) {
609 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
610 $s .= " | <a href=\"$feedurl\">{$format}</a>";
616 function pageTitle() {
617 global $wgOut, $wgTitle, $wgUser;
619 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
620 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
624 function pageSubtitle() {
627 $sub = $wgOut->getSubtitle();
629 global $wgExtraSubtitle;
630 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
632 $subpages = $this->subPageSubtitle();
633 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
634 $s = "<p class='subtitle'>{$sub}</p>\n";
638 function subPageSubtitle() {
639 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
641 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
642 $ptext=$wgTitle->getPrefixedText();
643 if(preg_match('/\//',$ptext)) {
644 $links = explode('/',$ptext);
647 foreach($links as $link) {
649 if ($c<count($links)) {
650 $growinglink .= $link;
651 $getlink = $this->makeLink( $growinglink, $link );
652 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
656 $subpages .= '< ';
658 $subpages .= $getlink;
667 function nameAndLogin() {
668 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
670 $li = $wgContLang->specialPage( 'Userlogin' );
671 $lo = $wgContLang->specialPage( 'Userlogout' );
674 if ( 0 == $wgUser->getID() ) {
675 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
678 $tl = $this->makeKnownLink( $wgContLang->getNsText(
679 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
680 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
682 $s .= $n . ' ('.$tl.')';
684 $s .= wfMsg('notloggedin');
687 $rt = $wgTitle->getPrefixedURL();
688 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
690 } else { $q = "returnto={$rt}"; }
692 $s .= "\n<br />" . $this->makeKnownLink( $li,
693 wfMsg( 'login' ), $q );
695 $n = $wgUser->getName();
696 $rt = $wgTitle->getPrefixedURL();
697 $tl = $this->makeKnownLink( $wgContLang->getNsText(
698 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
699 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
703 $s .= $this->makeKnownLink( $wgContLang->getNsText(
704 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
705 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
706 "returnto={$rt}" ) . ' | ' .
707 $this->specialLink( 'preferences' );
709 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
715 function getSearchLink() {
716 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
717 return $searchPage->getLocalURL();
720 function escapeSearchLink() {
721 return htmlspecialchars( $this->getSearchLink() );
724 function searchForm() {
726 $search = $wgRequest->getText( 'search' );
728 $s = '<form name="search" class="inline" method="post" action="'
729 . $this->escapeSearchLink() . "\">\n"
730 . '<input type="text" name="search" size="19" value="'
731 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
732 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
733 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
738 function topLinks() {
742 $s = $this->mainPageLink() . $sep
743 . $this->specialLink( 'recentchanges' );
745 if ( $wgOut->isArticleRelated() ) {
746 $s .= $sep . $this->editThisPage()
747 . $sep . $this->historyLink();
749 # Many people don't like this dropdown box
750 #$s .= $sep . $this->specialPagesList();
755 function bottomLinks() {
756 global $wgOut, $wgUser, $wgTitle;
760 if ( $wgOut->isArticleRelated() ) {
761 $s .= '<strong>' . $this->editThisPage() . '</strong>';
762 if ( 0 != $wgUser->getID() ) {
763 $s .= $sep . $this->watchThisPage();
765 $s .= $sep . $this->talkLink()
766 . $sep . $this->historyLink()
767 . $sep . $this->whatLinksHere()
768 . $sep . $this->watchPageLinksLink();
770 if ( $wgTitle->getNamespace() == Namespace::getUser()
771 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
774 $id=User
::idFromName($wgTitle->getText());
775 $ip=User
::isIP($wgTitle->getText());
777 if($id ||
$ip) { # both anons and non-anons have contri list
778 $s .= $sep . $this->userContribsLink();
780 if( $this->showEmailUser( $id ) ) {
781 $s .= $sep . $this->emailUserLink();
784 if ( $wgTitle->getArticleId() ) {
786 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
787 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
788 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
790 $s .= "<br />\n" . $this->otherLanguages();
795 function pageStats() {
796 global $wgOut, $wgLang, $wgArticle, $wgRequest;
797 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
799 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
800 if ( ! $wgOut->isArticle() ) { return ''; }
801 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
802 if ( 0 == $wgArticle->getID() ) { return ''; }
805 if ( !$wgDisableCounters ) {
806 $count = $wgLang->formatNum( $wgArticle->getCount() );
808 $s = wfMsg( 'viewcount', $count );
812 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
813 require_once("Credits.php");
814 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
816 $s .= $this->lastModified();
819 return $s . ' ' . $this->getCopyright();
822 function getCopyright() {
823 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
826 $oldid = $wgRequest->getVal( 'oldid' );
827 $diff = $wgRequest->getVal( 'diff' );
829 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
830 $msg = 'history_copyright';
836 if( $wgRightsPage ) {
837 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
838 } elseif( $wgRightsUrl ) {
839 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
844 $out .= wfMsgForContent( $msg, $link );
848 function getCopyrightIcon() {
849 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
851 if( $wgRightsIcon ) {
852 $icon = htmlspecialchars( $wgRightsIcon );
854 $url = htmlspecialchars( $wgRightsUrl );
855 $out .= '<a href="'.$url.'">';
857 $text = htmlspecialchars( $wgRightsText );
858 $out .= "<img src=\"$icon\" alt='$text' />";
866 function getPoweredBy() {
868 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
869 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
873 function lastModified() {
874 global $wgLang, $wgArticle;
876 $timestamp = $wgArticle->getTimestamp();
878 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
879 $s = ' ' . wfMsg( 'lastmodified', $d );
886 function logoText( $align = '' ) {
887 if ( '' != $align ) { $a = " align='{$align}'"; }
890 $mp = wfMsg( 'mainpage' );
891 $titleObj = Title
::newFromText( $mp );
892 if ( is_object( $titleObj ) ) {
893 $url = $titleObj->escapeLocalURL();
898 $logourl = $this->getLogo();
899 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
904 * show a drop-down box of special pages
905 * @TODO crash bug913. Need to be rewrote completly.
907 function specialPagesList() {
908 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
909 require_once('SpecialPage.php');
911 $pages = SpecialPage
::getPages();
913 foreach ( $pages[''] as $name => $page ) {
914 $a[$name] = $page->getDescription();
916 if ( $wgUser->isSysop() )
918 foreach ( $pages['sysop'] as $name => $page ) {
919 $a[$name] = $page->getDescription();
922 if ( $wgUser->isDeveloper() )
924 foreach ( $pages['developer'] as $name => $page ) {
925 $a[$name] = $page->getDescription() ;
929 $sp = wfMsg( 'specialpages' );
930 $spp = $wgContLang->specialPage( 'Specialpages' );
932 $s = '<form id="specialpages" method="get" class="inline" ' .
933 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
934 $s .= "<select name=\"wpDropdown\">\n";
935 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
937 foreach ( $a as $name => $desc ) {
938 $p = $wgContLang->specialPage( $name );
939 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
942 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
947 function mainPageLink() {
948 $mp = wfMsgForContent( 'mainpage' );
949 $mptxt = wfMsg( 'mainpage');
950 $s = $this->makeKnownLink( $mp, $mptxt );
954 function copyrightLink() {
955 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
956 wfMsg( 'copyrightpagename' ) );
960 function aboutLink() {
961 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
962 wfMsg( 'aboutsite' ) );
967 function disclaimerLink() {
968 $disclaimers = wfMsg( 'disclaimers' );
969 if ($disclaimers == '-') {
972 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
977 function editThisPage() {
978 global $wgOut, $wgTitle, $wgRequest;
980 $oldid = $wgRequest->getVal( 'oldid' );
981 $diff = $wgRequest->getVal( 'diff' );
982 $redirect = $wgRequest->getVal( 'redirect' );
984 if ( ! $wgOut->isArticleRelated() ) {
985 $s = wfMsg( 'protectedpage' );
987 $n = $wgTitle->getPrefixedText();
988 if ( $wgTitle->userCanEdit() ) {
989 $t = wfMsg( 'editthispage' );
991 #$t = wfMsg( "protectedpage" );
992 $t = wfMsg( 'viewsource' );
996 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
997 if ( $oldid && ! isset( $diff ) ) {
998 $oid = '&oldid='.$oldid;
1000 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1005 function deleteThisPage() {
1006 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1008 $diff = $wgRequest->getVal( 'diff' );
1009 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1010 $n = $wgTitle->getPrefixedText();
1011 $t = wfMsg( 'deletethispage' );
1013 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1020 function protectThisPage() {
1021 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1023 $diff = $wgRequest->getVal( 'diff' );
1024 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1025 $n = $wgTitle->getPrefixedText();
1027 if ( $wgTitle->isProtected() ) {
1028 $t = wfMsg( 'unprotectthispage' );
1029 $q = 'action=unprotect';
1031 $t = wfMsg( 'protectthispage' );
1032 $q = 'action=protect';
1034 $s = $this->makeKnownLink( $n, $t, $q );
1041 function watchThisPage() {
1042 global $wgUser, $wgOut, $wgTitle;
1044 if ( $wgOut->isArticleRelated() ) {
1045 $n = $wgTitle->getPrefixedText();
1047 if ( $wgTitle->userIsWatching() ) {
1048 $t = wfMsg( 'unwatchthispage' );
1049 $q = 'action=unwatch';
1051 $t = wfMsg( 'watchthispage' );
1052 $q = 'action=watch';
1054 $s = $this->makeKnownLink( $n, $t, $q );
1056 $s = wfMsg( 'notanarticle' );
1061 function moveThisPage() {
1062 global $wgTitle, $wgContLang;
1064 if ( $wgTitle->userCanMove() ) {
1065 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1066 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1067 } // no message if page is protected - would be redundant
1071 function historyLink() {
1074 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1075 wfMsg( 'history' ), 'action=history' );
1079 function whatLinksHere() {
1080 global $wgTitle, $wgContLang;
1082 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1083 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1087 function userContribsLink() {
1088 global $wgTitle, $wgContLang;
1090 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1091 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1095 function showEmailUser( $id ) {
1096 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1097 return $wgEnableEmail &&
1098 $wgEnableUserEmail &&
1099 0 != $wgUser->getID() && # show only to signed in users
1100 0 != $id; # can only email non-anons
1103 function emailUserLink() {
1104 global $wgTitle, $wgContLang;
1106 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1107 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1111 function watchPageLinksLink() {
1112 global $wgOut, $wgTitle, $wgContLang;
1114 if ( ! $wgOut->isArticleRelated() ) {
1115 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1117 $s = $this->makeKnownLink( $wgContLang->specialPage(
1118 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1119 'target=' . $wgTitle->getPrefixedURL() );
1124 function otherLanguages() {
1125 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1127 $a = $wgOut->getLanguageLinks();
1128 if ( 0 == count( $a ) ) {
1129 if ( !$wgUseNewInterlanguage ) return '';
1130 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1131 if ( $ns != 0 AND $ns != 1 ) return '' ;
1133 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1134 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1135 wfMsg( 'intl' ) , $x );
1138 if ( !$wgUseNewInterlanguage ) {
1139 $s = wfMsg( 'otherlanguages' ) . ': ';
1141 global $wgContLanguageCode ;
1142 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1143 $x .= '&xl='.$wgContLanguageCode ;
1144 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1145 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1148 $s = wfMsg( 'otherlanguages' ) . ': ';
1150 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1151 foreach( $a as $l ) {
1152 if ( ! $first ) { $s .= ' | '; }
1155 $nt = Title
::newFromText( $l );
1156 $url = $nt->getFullURL();
1157 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1159 if ( '' == $text ) { $text = $l; }
1160 $style = $this->getExternalLinkAttributes( $l, $text );
1161 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1163 if($wgContLang->isRTL()) $s .= '</span>';
1167 function bugReportsLink() {
1168 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1169 wfMsg( 'bugreports' ) );
1173 function dateLink() {
1174 global $wgLinkCache;
1175 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1176 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1178 $wgLinkCache->suspend();
1179 $id = $t1->getArticleID();
1180 $wgLinkCache->resume();
1183 $s = $this->makeBrokenLink( $t1->getText() );
1185 $s = $this->makeKnownLink( $t1->getText() );
1189 $wgLinkCache->suspend();
1190 $id = $t2->getArticleID();
1191 $wgLinkCache->resume();
1194 $s .= $this->makeBrokenLink( $t2->getText() );
1196 $s .= $this->makeKnownLink( $t2->getText() );
1201 function talkLink() {
1202 global $wgContLang, $wgTitle, $wgLinkCache;
1204 $tns = $wgTitle->getNamespace();
1205 if ( -1 == $tns ) { return ''; }
1207 $pn = $wgTitle->getText();
1208 $tp = wfMsg( 'talkpage' );
1209 if ( Namespace::isTalk( $tns ) ) {
1210 $lns = Namespace::getSubject( $tns );
1213 $text = wfMsg('articlepage');
1216 $text = wfMsg('userpage');
1219 $text = wfMsg('wikipediapage');
1222 $text = wfMsg('imagepage');
1225 $text= wfMsg('articlepage');
1229 $lns = Namespace::getTalk( $tns );
1232 $n = $wgContLang->getNsText( $lns );
1233 if ( '' == $n ) { $link = $pn; }
1234 else { $link = $n.':'.$pn; }
1236 $wgLinkCache->suspend();
1237 $s = $this->makeLink( $link, $text );
1238 $wgLinkCache->resume();
1243 function commentLink() {
1244 global $wgContLang, $wgTitle, $wgLinkCache;
1246 $tns = $wgTitle->getNamespace();
1247 if ( -1 == $tns ) { return ''; }
1249 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1251 # assert Namespace::isTalk( $lns )
1253 $n = $wgContLang->getNsText( $lns );
1254 $pn = $wgTitle->getText();
1258 $wgLinkCache->suspend();
1259 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1260 $wgLinkCache->resume();
1266 * After all the page content is transformed into HTML, it makes
1267 * a final pass through here for things like table backgrounds.
1268 * @todo probably deprecated [AV]
1270 function transformContent( $text ) {
1275 * Note: This function MUST call getArticleID() on the link,
1276 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1278 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1279 wfProfileIn( 'Skin::makeLink' );
1280 $nt = Title
::newFromText( $title );
1282 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1284 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1285 $result = $text == "" ?
$title : $text;
1288 wfProfileOut( 'Skin::makeLink' );
1292 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1293 $nt = Title
::newFromText( $title );
1295 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1297 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1298 return $text == '' ?
$title : $text;
1302 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1303 $nt = Title
::newFromText( $title );
1305 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1307 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1308 return $text == '' ?
$title : $text;
1312 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1313 $nt = Title
::newFromText( $title );
1315 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1317 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1318 return $text == '' ?
$title : $text;
1323 * Pass a title object, not a title string
1325 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1326 global $wgOut, $wgUser, $wgLinkHolders;
1327 $fname = 'Skin::makeLinkObj';
1328 wfProfileIn( $fname );
1331 if ( ! isset($nt) ) {
1332 # wfDebugDieBacktrace();
1333 wfProfileOut( $fname );
1334 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1337 $ns = $nt->getNamespace();
1338 $dbkey = $nt->getDBkey();
1339 if ( $nt->isExternal() ) {
1340 $u = $nt->getFullURL();
1341 $link = $nt->getPrefixedURL();
1342 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1343 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1346 if ( '' != $trail ) {
1347 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1352 # Assume $this->postParseLinkColour(). This prevents
1353 # interwiki links from being parsed as external links.
1354 global $wgInterwikiLinkHolders;
1355 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1356 $nr = array_push($wgInterwikiLinkHolders, $t);
1357 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1358 } elseif ( 0 == $ns && "" == $dbkey ) {
1359 # A self-link with a fragment; skip existence check.
1360 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1361 } elseif ( ( NS_SPECIAL
== $ns ) ||
( NS_IMAGE
== $ns ) ) {
1362 # These are always shown as existing, currently.
1363 # Special pages don't exist in the database; images may
1364 # occasionally be present when there is no description
1365 # page per se, so we always shown them.
1366 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1367 } elseif ( $this->postParseLinkColour
) {
1368 wfProfileIn( $fname.'-postparse' );
1369 # Insert a placeholder, and we'll work out the existence checks
1370 # in a big lump later.
1372 if ( '' != $trail ) {
1373 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1379 # These get picked up by Parser::replaceLinkHolders()
1380 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1381 $wgLinkHolders['dbkeys'][] = $dbkey;
1382 $wgLinkHolders['queries'][] = $query;
1383 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1384 $wgLinkHolders['titles'][] =& $nt;
1386 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1387 wfProfileOut( $fname.'-postparse' );
1389 wfProfileIn( $fname.'-immediate' );
1390 # Work out link colour immediately
1391 $aid = $nt->getArticleID() ;
1393 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1395 $threshold = $wgUser->getOption('stubthreshold') ;
1396 if ( $threshold > 0 ) {
1397 $dbr =& wfGetDB( DB_SLAVE
);
1398 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1399 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1400 if ( $s !== false ) {
1402 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1403 $size = $threshold*2 ; # Really big
1405 $dbr->freeResult( $res );
1407 $size = $threshold*2 ; # Really big
1412 if ( $size < $threshold ) {
1413 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1415 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1418 wfProfileOut( $fname.'-immediate' );
1420 wfProfileOut( $fname );
1425 * Pass a title object, not a title string
1427 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1428 global $wgOut, $wgTitle, $wgInputEncoding;
1430 $fname = 'Skin::makeKnownLinkObj';
1431 wfProfileIn( $fname );
1433 if ( !is_object( $nt ) ) {
1434 wfProfileIn( $fname );
1438 $u = $nt->escapeLocalURL( $query );
1439 if ( '' != $nt->getFragment() ) {
1440 if( $nt->getPrefixedDbkey() == '' ) {
1442 if ( '' == $text ) {
1443 $text = htmlspecialchars( $nt->getFragment() );
1446 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1447 $replacearray = array(
1451 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1453 if ( '' == $text ) {
1454 $text = htmlspecialchars( $nt->getPrefixedText() );
1456 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1459 if ( '' != $trail ) {
1460 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1465 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1466 wfProfileOut( $fname );
1471 * Pass a title object, not a title string
1473 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1475 if ( ! isset($nt) ) {
1476 # wfDebugDieBacktrace();
1477 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1480 $fname = 'Skin::makeBrokenLinkObj';
1481 wfProfileIn( $fname );
1483 if ( '' == $query ) {
1486 $q = 'action=edit&'.$query;
1488 $u = $nt->escapeLocalURL( $q );
1490 if ( '' == $text ) {
1491 $text = htmlspecialchars( $nt->getPrefixedText() );
1493 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1496 if ( '' != $trail ) {
1497 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1502 if ( $this->mOptions
['highlightbroken'] ) {
1503 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1505 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1508 wfProfileOut( $fname );
1513 * Pass a title object, not a title string
1515 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1516 $link = $nt->getPrefixedURL();
1518 $u = $nt->escapeLocalURL( $query );
1520 if ( '' == $text ) {
1521 $text = htmlspecialchars( $nt->getPrefixedText() );
1523 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1526 if ( '' != $trail ) {
1527 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1532 if ( $this->mOptions
['highlightbroken'] ) {
1533 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1535 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1540 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1541 $u = $nt->escapeLocalURL( $query );
1542 if ( '' == $text ) {
1543 $text = htmlspecialchars( $nt->getPrefixedText() );
1546 if ( '' != $trail ) {
1547 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1552 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1555 /* these are used extensively in SkinPHPTal, but also some other places */
1556 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1557 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1558 $this->checkTitle($title, $name);
1559 return $title->getLocalURL( $urlaction );
1561 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1562 $title = Title
::newFromText( $name );
1563 $title = $title->getTalkPage();
1564 $this->checkTitle($title, $name);
1565 return $title->getLocalURL( $urlaction );
1567 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1568 $title = Title
::newFromText( $name );
1569 $title= $title->getSubjectPage();
1570 $this->checkTitle($title, $name);
1571 return $title->getLocalURL( $urlaction );
1573 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1574 $title = Title
::newFromText( wfMsgForContent($name) );
1575 $this->checkTitle($title, $name);
1576 return $title->getLocalURL( $urlaction );
1578 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1579 $title = Title
::newFromText( $name );
1580 $this->checkTitle($title, $name);
1581 return $title->getLocalURL( $urlaction );
1584 # If url string starts with http, consider as external URL, else
1586 /*static*/ function makeInternalOrExternalUrl( $name ) {
1587 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1590 return $this->makeUrl( $name );
1594 # this can be passed the NS number as defined in Language.php
1595 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1596 $title = Title
::makeTitleSafe( $namespace, $name );
1597 $this->checkTitle($title, $name);
1598 return $title->getLocalURL( $urlaction );
1601 /* these return an array with the 'href' and boolean 'exists' */
1602 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1603 $title = Title
::newFromText( $name );
1604 $this->checkTitle($title, $name);
1606 'href' => $title->getLocalURL( $urlaction ),
1607 'exists' => $title->getArticleID() != 0?
true:false
1610 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1611 $title = Title
::newFromText( $name );
1612 $title = $title->getTalkPage();
1613 $this->checkTitle($title, $name);
1615 'href' => $title->getLocalURL( $urlaction ),
1616 'exists' => $title->getArticleID() != 0?
true:false
1619 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1620 $title = Title
::newFromText( $name );
1621 $title= $title->getSubjectPage();
1622 $this->checkTitle($title, $name);
1624 'href' => $title->getLocalURL( $urlaction ),
1625 'exists' => $title->getArticleID() != 0?
true:false
1628 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1629 $title = Title
::newFromText( wfMsgForContent($name) );
1630 $this->checkTitle($title, $name);
1632 'href' => $title->getLocalURL( $urlaction ),
1633 'exists' => $title->getArticleID() != 0?
true:false
1637 # make sure we have some title to operate on
1638 /*static*/ function checkTitle ( &$title, &$name ) {
1639 if(!is_object($title)) {
1640 $title = Title
::newFromText( $name );
1641 if(!is_object($title)) {
1642 $title = Title
::newFromText( '--error: link target missing--' );
1647 function fnamePart( $url ) {
1648 $basename = strrchr( $url, '/' );
1649 if ( false === $basename ) {
1652 $basename = substr( $basename, 1 );
1654 return htmlspecialchars( $basename );
1657 function makeImage( $url, $alt = '' ) {
1660 $alt = $this->fnamePart( $url );
1662 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1666 function makeImageLink( $name, $url, $alt = '' ) {
1667 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1668 return $this->makeImageLinkObj( $nt, $alt );
1671 function makeImageLinkObj( $nt, $alt = '' ) {
1672 global $wgContLang, $wgUseImageResize;
1673 $img = Image
::newFromTitle( $nt );
1674 $url = $img->getViewURL();
1677 $prefix = $postfix = '';
1679 # Check if the alt text is of the form "options|alt text"
1681 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1682 # * left no resizing, just left align. label is used for alt= only
1683 # * right same, but right aligned
1684 # * none same, but not aligned
1685 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1686 # * center center the image
1687 # * framed Keep original image size, no magnify-button.
1689 $part = explode( '|', $alt);
1691 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1692 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1693 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1694 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1695 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1696 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1697 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1700 $height = $framed = $thumb = false;
1701 $manual_thumb = "" ;
1703 foreach( $part as $key => $val ) {
1704 $val_parts = explode ( "=" , $val , 2 ) ;
1705 $left_part = array_shift ( $val_parts ) ;
1706 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1708 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1709 # use manually specified thumbnail
1711 $manual_thumb = array_shift ( $val_parts ) ;
1712 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1713 # remember to set an alignment, don't render immediately
1715 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1716 # remember to set an alignment, don't render immediately
1718 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1719 # remember to set an alignment, don't render immediately
1721 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1722 # remember to set an alignment, don't render immediately
1724 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1725 # $match is the image width in pixels
1726 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1727 $width = intval( $m[1] );
1728 $height = intval( $m[2] );
1730 $width = intval($match);
1732 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1738 if ( 'center' == $align )
1740 $prefix = '<div class="center">';
1741 $postfix = '</div>';
1745 if ( $thumb ||
$framed ) {
1747 # Create a thumbnail. Alignment depends on language
1748 # writing direction, # right aligned for left-to-right-
1749 # languages ("Western languages"), left-aligned
1750 # for right-to-left-languages ("Semitic languages")
1752 # If thumbnail width has not been provided, it is set
1753 # here to 180 pixels
1754 if ( $align == '' ) {
1755 $align = $wgContLang->isRTL() ?
'left' : 'right';
1757 if ( ! isset($width) ) {
1760 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1762 } elseif ( isset($width) ) {
1764 # Create a resized image, without the additional thumbnail
1767 if ( ( ! $height === false )
1768 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1769 $width = $img->getWidth() * $height / $img->getHeight();
1771 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1774 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1775 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1776 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1778 $u = $nt->escapeLocalURL();
1780 $s = wfMsg( 'missingimage', $img->getName() );
1781 $s .= "<br>{$alt}<br>{$url}<br>\n";
1783 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1784 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
1786 if ( '' != $align ) {
1787 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1789 return str_replace("\n", ' ',$prefix.$s.$postfix);
1793 * Make HTML for a thumbnail including image, border and caption
1794 * $img is an Image object
1796 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1797 global $wgStylePath, $wgContLang;
1798 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1799 $url = $img->getViewURL();
1801 #$label = htmlspecialchars( $label );
1802 $alt = preg_replace( '/<[^>]*>/', '', $label);
1803 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1804 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1806 $width = $height = 0;
1807 if ( $img->exists() )
1809 $width = $img->getWidth();
1810 $height = $img->getHeight();
1812 if ( 0 == $width ||
0 == $height )
1814 $width = $height = 200;
1816 if ( $boxwidth == 0 )
1822 // Use image dimensions, don't scale
1824 $oboxwidth = $boxwidth +
2;
1825 $boxheight = $height;
1828 $h = intval( $height/($width/$boxwidth) );
1829 $oboxwidth = $boxwidth +
2;
1830 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1832 $boxwidth *= $boxheight/$h;
1836 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1839 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1841 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1842 $manual_img = Image
::newFromTitle( $manual_title );
1843 $thumbUrl = $manual_img->getViewURL();
1844 if ( $manual_img->exists() )
1846 $width = $manual_img->getWidth();
1847 $height = $manual_img->getHeight();
1848 $boxwidth = $width ;
1849 $boxheight = $height ;
1850 $oboxwidth = $boxwidth +
2 ;
1854 $u = $img->getEscapeLocalURL();
1856 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1857 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1858 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1860 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1861 if ( $thumbUrl == '' ) {
1862 $s .= wfMsg( 'missingimage', $img->getName() );
1865 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1866 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1867 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
1868 'longdesc="'.$u.'" /></a>';
1872 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1873 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1874 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1875 'width="15" height="11" alt="'.$more.'" /></a></div>';
1878 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1879 return str_replace("\n", ' ', $s);
1882 function makeMediaLink( $name, $url, $alt = '' ) {
1883 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1884 return $this->makeMediaLinkObj( $nt, $alt );
1887 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
1888 if ( ! isset( $nt ) )
1890 ### HOTFIX. Instead of breaking, return empty string.
1893 $name = $nt->getDBKey();
1894 $img = Image
::newFromTitle( $nt );
1895 $url = $img->getURL();
1896 # $nourl can be set by the parser
1897 # this is a hack to mask absolute URLs, so the parser doesn't
1898 # linkify them (it is currently not context-aware)
1900 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
1901 if ( empty( $alt ) ) {
1902 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1904 $u = htmlspecialchars( $url );
1905 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1910 function specialLink( $name, $key = '' ) {
1913 if ( '' == $key ) { $key = strtolower( $name ); }
1914 $pn = $wgContLang->ucfirst( $name );
1915 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1919 function makeExternalLink( $url, $text, $escape = true ) {
1920 $style = $this->getExternalLinkAttributes( $url, $text );
1921 $url = htmlspecialchars( $url );
1923 $text = htmlspecialchars( $text );
1925 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1930 * This function is called by all recent changes variants, by the page history,
1931 * and by the user contributions list. It is responsible for formatting edit
1932 * comments. It escapes any HTML in the comment, but adds some CSS to format
1933 * auto-generated comments (from section editing) and formats [[wikilinks]].
1935 * The &$title parameter must be a title OBJECT. It is used to generate a
1936 * direct link to the section in the autocomment.
1937 * @author Erik Moeller <moeller@scireview.de>
1939 * Note: there's not always a title to pass to this function.
1940 * Since you can't set a default parameter for a reference, I've turned it
1941 * temporarily to a value pass. Should be adjusted further. --brion
1943 function formatComment($comment, $title = NULL) {
1944 $fname = 'Skin::formatComment';
1945 wfProfileIn( $fname );
1948 $comment = htmlspecialchars( $comment );
1950 # The pattern for autogen comments is / * foo * /, which makes for
1952 # We look for all comments, match any text before and after the comment,
1953 # add a separator where needed and format the comment itself with CSS
1954 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
1962 # This is hackish but should work in most cases.
1963 $section=str_replace('[[','',$section);
1964 $section=str_replace(']]','',$section);
1965 $title->mFragment
=$section;
1966 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
1970 if($pre) { $auto = $sep.' '.$auto; }
1971 if($post) { $auto .= ' '.$sep; }
1972 $auto='<span class="autocomment">'.$auto.'</span>';
1973 $comment=$pre.$auto.$post;
1976 # format regular and media links - all other wiki formatting
1978 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
1979 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
1980 # Handle link renaming [[foo|text]] will show link as "text"
1981 if( "" != $match[3] ) {
1986 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
1987 # Media link; trail not supported.
1988 $linkRegexp = '/\[\[(.*?)\]\]/';
1989 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
1991 # Other kind of link
1992 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
1993 $trail = $submatch[1];
1997 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
1998 if ($match[1][0] == ':')
1999 $match[1] = substr($match[1], 1);
2000 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2002 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2004 wfProfileOut( $fname );
2008 function tocIndent($level) {
2009 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2012 function tocUnindent($level) {
2013 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2017 * parameter level defines if we are on an indentation level
2019 function tocLine( $anchor, $tocline, $level ) {
2020 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2024 return '<div class="tocline">'.$link."</div>\n";
2029 function tocTable($toc) {
2030 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2031 # try min-width & co when somebody gets a chance
2032 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2034 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2035 '<b>'.wfMsgForContent('toc').'</b>' .
2037 '</td></tr><tr id="tocinside"><td>'."\n".
2038 $toc."</td></tr></table>\n";
2042 * These two do not check for permissions: check $wgTitle->userCanEdit
2043 * before calling them
2045 function editSectionScriptForOther( $title, $section, $head ) {
2046 $ttl = Title
::newFromText( $title );
2047 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2048 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2051 function editSectionScript( $nt, $section, $head ) {
2053 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2056 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
2057 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2060 function editSectionLinkForOther( $title, $section ) {
2064 $title = Title
::newFromText($title);
2065 $editurl = '§ion='.$section;
2066 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2068 if( $wgContLang->isRTL() ) {
2070 $nearside = 'right';
2075 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2079 function editSectionLink( $nt, $section ) {
2083 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2084 # Section edit links would be out of sync on an old page.
2085 # But, if we're diffing to the current page, they'll be
2090 $editurl = '§ion='.$section;
2091 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2093 if( $wgContLang->isRTL() ) {
2095 $nearside = 'right';
2100 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2107 function suppressUrlExpansion() {