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 $image = new Image( $wgTitle->getDBkey() );
538 if( $image->exists() ) {
539 $link = htmlspecialchars( $image->getURL() );
540 $style = $this->getInternalLinkAttributes( $link, $name );
541 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
544 # This will show the "Approve" link if $wgUseApproval=true;
545 if ( isset ( $wgUseApproval ) && $wgUseApproval )
547 $t = $wgTitle->getDBkey();
548 $name = 'Approve this article' ;
549 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
550 #htmlspecialchars( wfImageUrl( $name ) );
551 $style = $this->getExternalLinkAttributes( $link, $name );
552 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
555 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
556 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
557 wfMsg( 'currentrev' ) );
560 if ( $wgUser->getNewtalk() ) {
561 # do not show "You have new messages" text when we are viewing our
564 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
565 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
566 $n =$wgUser->getName();
567 $tl = $this->makeKnownLink( $wgContLang->getNsText(
568 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
569 wfMsg('newmessageslink') );
570 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
572 $wgOut->setSquidMaxage(0);
573 $wgOut->enableClientCache(false);
577 $undelete = $this->getUndeleteLink();
578 if( !empty( $undelete ) ) {
579 $s .= ' | '.$undelete;
584 function getUndeleteLink() {
585 global $wgUser, $wgTitle, $wgContLang, $action;
586 if( $wgUser->isAllowed('rollback') &&
587 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
588 ($n = $wgTitle->isDeleted() ) ) {
589 return wfMsg( 'thisisdeleted',
590 $this->makeKnownLink(
591 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
592 wfMsg( 'restorelink', $n ) ) );
597 function printableLink() {
598 global $wgOut, $wgFeedClasses, $wgRequest;
600 $baseurl = $_SERVER['REQUEST_URI'];
601 if( strpos( '?', $baseurl ) == false ) {
606 $baseurl = htmlspecialchars( $baseurl );
607 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
609 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
610 if( $wgOut->isSyndicated() ) {
611 foreach( $wgFeedClasses as $format => $class ) {
612 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
613 $s .= " | <a href=\"$feedurl\">{$format}</a>";
619 function pageTitle() {
620 global $wgOut, $wgTitle, $wgUser;
622 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
623 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
627 function pageSubtitle() {
630 $sub = $wgOut->getSubtitle();
632 global $wgExtraSubtitle;
633 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
635 $subpages = $this->subPageSubtitle();
636 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
637 $s = "<p class='subtitle'>{$sub}</p>\n";
641 function subPageSubtitle() {
642 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
644 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
645 $ptext=$wgTitle->getPrefixedText();
646 if(preg_match('/\//',$ptext)) {
647 $links = explode('/',$ptext);
650 foreach($links as $link) {
652 if ($c<count($links)) {
653 $growinglink .= $link;
654 $getlink = $this->makeLink( $growinglink, $link );
655 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
659 $subpages .= '< ';
661 $subpages .= $getlink;
670 function nameAndLogin() {
671 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
673 $li = $wgContLang->specialPage( 'Userlogin' );
674 $lo = $wgContLang->specialPage( 'Userlogout' );
677 if ( 0 == $wgUser->getID() ) {
678 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
681 $tl = $this->makeKnownLink( $wgContLang->getNsText(
682 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
683 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
685 $s .= $n . ' ('.$tl.')';
687 $s .= wfMsg('notloggedin');
690 $rt = $wgTitle->getPrefixedURL();
691 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
693 } else { $q = "returnto={$rt}"; }
695 $s .= "\n<br />" . $this->makeKnownLink( $li,
696 wfMsg( 'login' ), $q );
698 $n = $wgUser->getName();
699 $rt = $wgTitle->getPrefixedURL();
700 $tl = $this->makeKnownLink( $wgContLang->getNsText(
701 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
702 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
706 $s .= $this->makeKnownLink( $wgContLang->getNsText(
707 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
708 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
709 "returnto={$rt}" ) . ' | ' .
710 $this->specialLink( 'preferences' );
712 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
718 function getSearchLink() {
719 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
720 return $searchPage->getLocalURL();
723 function escapeSearchLink() {
724 return htmlspecialchars( $this->getSearchLink() );
727 function searchForm() {
729 $search = $wgRequest->getText( 'search' );
731 $s = '<form name="search" class="inline" method="post" action="'
732 . $this->escapeSearchLink() . "\">\n"
733 . '<input type="text" name="search" size="19" value="'
734 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
735 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
736 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
741 function topLinks() {
745 $s = $this->mainPageLink() . $sep
746 . $this->specialLink( 'recentchanges' );
748 if ( $wgOut->isArticleRelated() ) {
749 $s .= $sep . $this->editThisPage()
750 . $sep . $this->historyLink();
752 # Many people don't like this dropdown box
753 #$s .= $sep . $this->specialPagesList();
758 function bottomLinks() {
759 global $wgOut, $wgUser, $wgTitle;
763 if ( $wgOut->isArticleRelated() ) {
764 $s .= '<strong>' . $this->editThisPage() . '</strong>';
765 if ( 0 != $wgUser->getID() ) {
766 $s .= $sep . $this->watchThisPage();
768 $s .= $sep . $this->talkLink()
769 . $sep . $this->historyLink()
770 . $sep . $this->whatLinksHere()
771 . $sep . $this->watchPageLinksLink();
773 if ( $wgTitle->getNamespace() == Namespace::getUser()
774 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
777 $id=User
::idFromName($wgTitle->getText());
778 $ip=User
::isIP($wgTitle->getText());
780 if($id ||
$ip) { # both anons and non-anons have contri list
781 $s .= $sep . $this->userContribsLink();
783 if( $this->showEmailUser( $id ) ) {
784 $s .= $sep . $this->emailUserLink();
787 if ( $wgTitle->getArticleId() ) {
789 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
790 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
791 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
793 $s .= "<br />\n" . $this->otherLanguages();
798 function pageStats() {
799 global $wgOut, $wgLang, $wgArticle, $wgRequest;
800 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
802 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
803 if ( ! $wgOut->isArticle() ) { return ''; }
804 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
805 if ( 0 == $wgArticle->getID() ) { return ''; }
808 if ( !$wgDisableCounters ) {
809 $count = $wgLang->formatNum( $wgArticle->getCount() );
811 $s = wfMsg( 'viewcount', $count );
815 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
816 require_once("Credits.php");
817 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
819 $s .= $this->lastModified();
822 return $s . ' ' . $this->getCopyright();
825 function getCopyright() {
826 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
829 $oldid = $wgRequest->getVal( 'oldid' );
830 $diff = $wgRequest->getVal( 'diff' );
832 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
833 $msg = 'history_copyright';
839 if( $wgRightsPage ) {
840 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
841 } elseif( $wgRightsUrl ) {
842 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
847 $out .= wfMsgForContent( $msg, $link );
851 function getCopyrightIcon() {
852 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
854 if( $wgRightsIcon ) {
855 $icon = htmlspecialchars( $wgRightsIcon );
857 $url = htmlspecialchars( $wgRightsUrl );
858 $out .= '<a href="'.$url.'">';
860 $text = htmlspecialchars( $wgRightsText );
861 $out .= "<img src=\"$icon\" alt='$text' />";
869 function getPoweredBy() {
871 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
872 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
876 function lastModified() {
877 global $wgLang, $wgArticle;
879 $timestamp = $wgArticle->getTimestamp();
881 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
882 $s = ' ' . wfMsg( 'lastmodified', $d );
889 function logoText( $align = '' ) {
890 if ( '' != $align ) { $a = " align='{$align}'"; }
893 $mp = wfMsg( 'mainpage' );
894 $titleObj = Title
::newFromText( $mp );
895 if ( is_object( $titleObj ) ) {
896 $url = $titleObj->escapeLocalURL();
901 $logourl = $this->getLogo();
902 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
907 * show a drop-down box of special pages
908 * @TODO crash bug913. Need to be rewrote completly.
910 function specialPagesList() {
911 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
912 require_once('SpecialPage.php');
914 $pages = SpecialPage
::getPages();
916 foreach ( $pages[''] as $name => $page ) {
917 $a[$name] = $page->getDescription();
919 if ( $wgUser->isSysop() )
921 foreach ( $pages['sysop'] as $name => $page ) {
922 $a[$name] = $page->getDescription();
925 if ( $wgUser->isDeveloper() )
927 foreach ( $pages['developer'] as $name => $page ) {
928 $a[$name] = $page->getDescription() ;
932 $sp = wfMsg( 'specialpages' );
933 $spp = $wgContLang->specialPage( 'Specialpages' );
935 $s = '<form id="specialpages" method="get" class="inline" ' .
936 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
937 $s .= "<select name=\"wpDropdown\">\n";
938 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
940 foreach ( $a as $name => $desc ) {
941 $p = $wgContLang->specialPage( $name );
942 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
945 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
950 function mainPageLink() {
951 $mp = wfMsgForContent( 'mainpage' );
952 $mptxt = wfMsg( 'mainpage');
953 $s = $this->makeKnownLink( $mp, $mptxt );
957 function copyrightLink() {
958 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
959 wfMsg( 'copyrightpagename' ) );
963 function aboutLink() {
964 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
965 wfMsg( 'aboutsite' ) );
970 function disclaimerLink() {
971 $disclaimers = wfMsg( 'disclaimers' );
972 if ($disclaimers == '-') {
975 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
980 function editThisPage() {
981 global $wgOut, $wgTitle, $wgRequest;
983 $oldid = $wgRequest->getVal( 'oldid' );
984 $diff = $wgRequest->getVal( 'diff' );
985 $redirect = $wgRequest->getVal( 'redirect' );
987 if ( ! $wgOut->isArticleRelated() ) {
988 $s = wfMsg( 'protectedpage' );
990 $n = $wgTitle->getPrefixedText();
991 if ( $wgTitle->userCanEdit() ) {
992 $t = wfMsg( 'editthispage' );
994 #$t = wfMsg( "protectedpage" );
995 $t = wfMsg( 'viewsource' );
999 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1000 if ( $oldid && ! isset( $diff ) ) {
1001 $oid = '&oldid='.$oldid;
1003 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1008 function deleteThisPage() {
1009 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1011 $diff = $wgRequest->getVal( 'diff' );
1012 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1013 $n = $wgTitle->getPrefixedText();
1014 $t = wfMsg( 'deletethispage' );
1016 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1023 function protectThisPage() {
1024 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1026 $diff = $wgRequest->getVal( 'diff' );
1027 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1028 $n = $wgTitle->getPrefixedText();
1030 if ( $wgTitle->isProtected() ) {
1031 $t = wfMsg( 'unprotectthispage' );
1032 $q = 'action=unprotect';
1034 $t = wfMsg( 'protectthispage' );
1035 $q = 'action=protect';
1037 $s = $this->makeKnownLink( $n, $t, $q );
1044 function watchThisPage() {
1045 global $wgUser, $wgOut, $wgTitle;
1047 if ( $wgOut->isArticleRelated() ) {
1048 $n = $wgTitle->getPrefixedText();
1050 if ( $wgTitle->userIsWatching() ) {
1051 $t = wfMsg( 'unwatchthispage' );
1052 $q = 'action=unwatch';
1054 $t = wfMsg( 'watchthispage' );
1055 $q = 'action=watch';
1057 $s = $this->makeKnownLink( $n, $t, $q );
1059 $s = wfMsg( 'notanarticle' );
1064 function moveThisPage() {
1065 global $wgTitle, $wgContLang;
1067 if ( $wgTitle->userCanMove() ) {
1068 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1069 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1070 } // no message if page is protected - would be redundant
1074 function historyLink() {
1077 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1078 wfMsg( 'history' ), 'action=history' );
1082 function whatLinksHere() {
1083 global $wgTitle, $wgContLang;
1085 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1086 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1090 function userContribsLink() {
1091 global $wgTitle, $wgContLang;
1093 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1094 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1098 function showEmailUser( $id ) {
1099 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1100 return $wgEnableEmail &&
1101 $wgEnableUserEmail &&
1102 0 != $wgUser->getID() && # show only to signed in users
1103 0 != $id; # can only email non-anons
1106 function emailUserLink() {
1107 global $wgTitle, $wgContLang;
1109 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1110 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1114 function watchPageLinksLink() {
1115 global $wgOut, $wgTitle, $wgContLang;
1117 if ( ! $wgOut->isArticleRelated() ) {
1118 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1120 $s = $this->makeKnownLink( $wgContLang->specialPage(
1121 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1122 'target=' . $wgTitle->getPrefixedURL() );
1127 function otherLanguages() {
1128 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1130 $a = $wgOut->getLanguageLinks();
1131 if ( 0 == count( $a ) ) {
1132 if ( !$wgUseNewInterlanguage ) return '';
1133 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1134 if ( $ns != 0 AND $ns != 1 ) return '' ;
1136 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1137 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1138 wfMsg( 'intl' ) , $x );
1141 if ( !$wgUseNewInterlanguage ) {
1142 $s = wfMsg( 'otherlanguages' ) . ': ';
1144 global $wgContLanguageCode ;
1145 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1146 $x .= '&xl='.$wgContLanguageCode ;
1147 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1148 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1151 $s = wfMsg( 'otherlanguages' ) . ': ';
1153 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1154 foreach( $a as $l ) {
1155 if ( ! $first ) { $s .= ' | '; }
1158 $nt = Title
::newFromText( $l );
1159 $url = $nt->getFullURL();
1160 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1162 if ( '' == $text ) { $text = $l; }
1163 $style = $this->getExternalLinkAttributes( $l, $text );
1164 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1166 if($wgContLang->isRTL()) $s .= '</span>';
1170 function bugReportsLink() {
1171 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1172 wfMsg( 'bugreports' ) );
1176 function dateLink() {
1177 global $wgLinkCache;
1178 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1179 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1181 $wgLinkCache->suspend();
1182 $id = $t1->getArticleID();
1183 $wgLinkCache->resume();
1186 $s = $this->makeBrokenLink( $t1->getText() );
1188 $s = $this->makeKnownLink( $t1->getText() );
1192 $wgLinkCache->suspend();
1193 $id = $t2->getArticleID();
1194 $wgLinkCache->resume();
1197 $s .= $this->makeBrokenLink( $t2->getText() );
1199 $s .= $this->makeKnownLink( $t2->getText() );
1204 function talkLink() {
1205 global $wgContLang, $wgTitle, $wgLinkCache;
1207 $tns = $wgTitle->getNamespace();
1208 if ( -1 == $tns ) { return ''; }
1210 $pn = $wgTitle->getText();
1211 $tp = wfMsg( 'talkpage' );
1212 if ( Namespace::isTalk( $tns ) ) {
1213 $lns = Namespace::getSubject( $tns );
1216 $text = wfMsg('articlepage');
1219 $text = wfMsg('userpage');
1222 $text = wfMsg('wikipediapage');
1225 $text = wfMsg('imagepage');
1228 $text= wfMsg('articlepage');
1232 $lns = Namespace::getTalk( $tns );
1235 $n = $wgContLang->getNsText( $lns );
1236 if ( '' == $n ) { $link = $pn; }
1237 else { $link = $n.':'.$pn; }
1239 $wgLinkCache->suspend();
1240 $s = $this->makeLink( $link, $text );
1241 $wgLinkCache->resume();
1246 function commentLink() {
1247 global $wgContLang, $wgTitle, $wgLinkCache;
1249 $tns = $wgTitle->getNamespace();
1250 if ( -1 == $tns ) { return ''; }
1252 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1254 # assert Namespace::isTalk( $lns )
1256 $n = $wgContLang->getNsText( $lns );
1257 $pn = $wgTitle->getText();
1261 $wgLinkCache->suspend();
1262 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1263 $wgLinkCache->resume();
1269 * After all the page content is transformed into HTML, it makes
1270 * a final pass through here for things like table backgrounds.
1271 * @todo probably deprecated [AV]
1273 function transformContent( $text ) {
1278 * Note: This function MUST call getArticleID() on the link,
1279 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1281 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1282 wfProfileIn( 'Skin::makeLink' );
1283 $nt = Title
::newFromText( $title );
1285 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1287 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1288 $result = $text == "" ?
$title : $text;
1291 wfProfileOut( 'Skin::makeLink' );
1295 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1296 $nt = Title
::newFromText( $title );
1298 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1300 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1301 return $text == '' ?
$title : $text;
1305 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1306 $nt = Title
::newFromText( $title );
1308 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1310 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1311 return $text == '' ?
$title : $text;
1315 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1316 $nt = Title
::newFromText( $title );
1318 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1320 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1321 return $text == '' ?
$title : $text;
1326 * Pass a title object, not a title string
1328 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1329 global $wgOut, $wgUser, $wgLinkHolders;
1330 $fname = 'Skin::makeLinkObj';
1331 wfProfileIn( $fname );
1334 if ( ! isset($nt) ) {
1335 # wfDebugDieBacktrace();
1336 wfProfileOut( $fname );
1337 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1340 $ns = $nt->getNamespace();
1341 $dbkey = $nt->getDBkey();
1342 if ( $nt->isExternal() ) {
1343 $u = $nt->getFullURL();
1344 $link = $nt->getPrefixedURL();
1345 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1346 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1349 if ( '' != $trail ) {
1350 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1355 # Assume $this->postParseLinkColour(). This prevents
1356 # interwiki links from being parsed as external links.
1357 global $wgInterwikiLinkHolders;
1358 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1359 $nr = array_push($wgInterwikiLinkHolders, $t);
1360 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1361 } elseif ( 0 == $ns && "" == $dbkey ) {
1362 # A self-link with a fragment; skip existence check.
1363 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1364 } elseif ( ( NS_SPECIAL
== $ns ) ||
( NS_IMAGE
== $ns ) ) {
1365 # These are always shown as existing, currently.
1366 # Special pages don't exist in the database; images may
1367 # occasionally be present when there is no description
1368 # page per se, so we always shown them.
1369 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1370 } elseif ( $this->postParseLinkColour
) {
1371 wfProfileIn( $fname.'-postparse' );
1372 # Insert a placeholder, and we'll work out the existence checks
1373 # in a big lump later.
1375 if ( '' != $trail ) {
1376 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1382 # These get picked up by Parser::replaceLinkHolders()
1383 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1384 $wgLinkHolders['dbkeys'][] = $dbkey;
1385 $wgLinkHolders['queries'][] = $query;
1386 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1387 $wgLinkHolders['titles'][] =& $nt;
1389 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1390 wfProfileOut( $fname.'-postparse' );
1392 wfProfileIn( $fname.'-immediate' );
1393 # Work out link colour immediately
1394 $aid = $nt->getArticleID() ;
1396 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1398 $threshold = $wgUser->getOption('stubthreshold') ;
1399 if ( $threshold > 0 ) {
1400 $dbr =& wfGetDB( DB_SLAVE
);
1401 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1402 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1403 if ( $s !== false ) {
1405 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1406 $size = $threshold*2 ; # Really big
1408 $dbr->freeResult( $res );
1410 $size = $threshold*2 ; # Really big
1415 if ( $size < $threshold ) {
1416 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1418 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1421 wfProfileOut( $fname.'-immediate' );
1423 wfProfileOut( $fname );
1428 * Pass a title object, not a title string
1430 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1431 global $wgOut, $wgTitle, $wgInputEncoding;
1433 $fname = 'Skin::makeKnownLinkObj';
1434 wfProfileIn( $fname );
1436 if ( !is_object( $nt ) ) {
1437 wfProfileIn( $fname );
1441 $u = $nt->escapeLocalURL( $query );
1442 if ( '' != $nt->getFragment() ) {
1443 if( $nt->getPrefixedDbkey() == '' ) {
1445 if ( '' == $text ) {
1446 $text = htmlspecialchars( $nt->getFragment() );
1449 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1450 $replacearray = array(
1454 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1456 if ( '' == $text ) {
1457 $text = htmlspecialchars( $nt->getPrefixedText() );
1459 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1462 if ( '' != $trail ) {
1463 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1468 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1469 wfProfileOut( $fname );
1474 * Pass a title object, not a title string
1476 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1478 if ( ! isset($nt) ) {
1479 # wfDebugDieBacktrace();
1480 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1483 $fname = 'Skin::makeBrokenLinkObj';
1484 wfProfileIn( $fname );
1486 if ( '' == $query ) {
1489 $q = 'action=edit&'.$query;
1491 $u = $nt->escapeLocalURL( $q );
1493 if ( '' == $text ) {
1494 $text = htmlspecialchars( $nt->getPrefixedText() );
1496 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1499 if ( '' != $trail ) {
1500 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1505 if ( $this->mOptions
['highlightbroken'] ) {
1506 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1508 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1511 wfProfileOut( $fname );
1516 * Pass a title object, not a title string
1518 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1519 $link = $nt->getPrefixedURL();
1521 $u = $nt->escapeLocalURL( $query );
1523 if ( '' == $text ) {
1524 $text = htmlspecialchars( $nt->getPrefixedText() );
1526 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1529 if ( '' != $trail ) {
1530 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1535 if ( $this->mOptions
['highlightbroken'] ) {
1536 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1538 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1543 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1544 $u = $nt->escapeLocalURL( $query );
1545 if ( '' == $text ) {
1546 $text = htmlspecialchars( $nt->getPrefixedText() );
1549 if ( '' != $trail ) {
1550 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1555 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1558 /* these are used extensively in SkinPHPTal, but also some other places */
1559 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1560 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1561 $this->checkTitle($title, $name);
1562 return $title->getLocalURL( $urlaction );
1564 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1565 $title = Title
::newFromText( $name );
1566 $title = $title->getTalkPage();
1567 $this->checkTitle($title, $name);
1568 return $title->getLocalURL( $urlaction );
1570 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1571 $title = Title
::newFromText( $name );
1572 $title= $title->getSubjectPage();
1573 $this->checkTitle($title, $name);
1574 return $title->getLocalURL( $urlaction );
1576 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1577 $title = Title
::newFromText( wfMsgForContent($name) );
1578 $this->checkTitle($title, $name);
1579 return $title->getLocalURL( $urlaction );
1581 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1582 $title = Title
::newFromText( $name );
1583 $this->checkTitle($title, $name);
1584 return $title->getLocalURL( $urlaction );
1587 # If url string starts with http, consider as external URL, else
1589 /*static*/ function makeInternalOrExternalUrl( $name ) {
1590 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1593 return $this->makeUrl( $name );
1597 # this can be passed the NS number as defined in Language.php
1598 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1599 $title = Title
::makeTitleSafe( $namespace, $name );
1600 $this->checkTitle($title, $name);
1601 return $title->getLocalURL( $urlaction );
1604 /* these return an array with the 'href' and boolean 'exists' */
1605 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1606 $title = Title
::newFromText( $name );
1607 $this->checkTitle($title, $name);
1609 'href' => $title->getLocalURL( $urlaction ),
1610 'exists' => $title->getArticleID() != 0?
true:false
1613 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1614 $title = Title
::newFromText( $name );
1615 $title = $title->getTalkPage();
1616 $this->checkTitle($title, $name);
1618 'href' => $title->getLocalURL( $urlaction ),
1619 'exists' => $title->getArticleID() != 0?
true:false
1622 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1623 $title = Title
::newFromText( $name );
1624 $title= $title->getSubjectPage();
1625 $this->checkTitle($title, $name);
1627 'href' => $title->getLocalURL( $urlaction ),
1628 'exists' => $title->getArticleID() != 0?
true:false
1631 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1632 $title = Title
::newFromText( wfMsgForContent($name) );
1633 $this->checkTitle($title, $name);
1635 'href' => $title->getLocalURL( $urlaction ),
1636 'exists' => $title->getArticleID() != 0?
true:false
1640 # make sure we have some title to operate on
1641 /*static*/ function checkTitle ( &$title, &$name ) {
1642 if(!is_object($title)) {
1643 $title = Title
::newFromText( $name );
1644 if(!is_object($title)) {
1645 $title = Title
::newFromText( '--error: link target missing--' );
1650 function fnamePart( $url ) {
1651 $basename = strrchr( $url, '/' );
1652 if ( false === $basename ) {
1655 $basename = substr( $basename, 1 );
1657 return htmlspecialchars( $basename );
1660 function makeImage( $url, $alt = '' ) {
1663 $alt = $this->fnamePart( $url );
1665 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1669 function makeImageLink( $name, $url, $alt = '' ) {
1670 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1671 return $this->makeImageLinkObj( $nt, $alt );
1674 function makeImageLinkObj( $nt, $alt = '' ) {
1675 global $wgContLang, $wgUseImageResize;
1676 $img = Image
::newFromTitle( $nt );
1677 $url = $img->getViewURL();
1680 $prefix = $postfix = '';
1682 # Check if the alt text is of the form "options|alt text"
1684 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1685 # * left no resizing, just left align. label is used for alt= only
1686 # * right same, but right aligned
1687 # * none same, but not aligned
1688 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1689 # * center center the image
1690 # * framed Keep original image size, no magnify-button.
1692 $part = explode( '|', $alt);
1694 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1695 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1696 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1697 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1698 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1699 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1700 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1703 $height = $framed = $thumb = false;
1704 $manual_thumb = "" ;
1706 foreach( $part as $key => $val ) {
1707 $val_parts = explode ( "=" , $val , 2 ) ;
1708 $left_part = array_shift ( $val_parts ) ;
1709 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1711 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1712 # use manually specified thumbnail
1714 $manual_thumb = array_shift ( $val_parts ) ;
1715 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1716 # remember to set an alignment, don't render immediately
1718 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1719 # remember to set an alignment, don't render immediately
1721 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1722 # remember to set an alignment, don't render immediately
1724 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1725 # remember to set an alignment, don't render immediately
1727 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1728 # $match is the image width in pixels
1729 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1730 $width = intval( $m[1] );
1731 $height = intval( $m[2] );
1733 $width = intval($match);
1735 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1741 if ( 'center' == $align )
1743 $prefix = '<div class="center">';
1744 $postfix = '</div>';
1748 if ( $thumb ||
$framed ) {
1750 # Create a thumbnail. Alignment depends on language
1751 # writing direction, # right aligned for left-to-right-
1752 # languages ("Western languages"), left-aligned
1753 # for right-to-left-languages ("Semitic languages")
1755 # If thumbnail width has not been provided, it is set
1756 # here to 180 pixels
1757 if ( $align == '' ) {
1758 $align = $wgContLang->isRTL() ?
'left' : 'right';
1760 if ( ! isset($width) ) {
1763 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1765 } elseif ( isset($width) ) {
1767 # Create a resized image, without the additional thumbnail
1770 if ( ( ! $height === false )
1771 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1772 $width = $img->getWidth() * $height / $img->getHeight();
1774 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1777 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1778 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1779 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1781 $u = $nt->escapeLocalURL();
1783 $s = wfMsg( 'missingimage', $img->getName() );
1784 $s .= "<br>{$alt}<br>{$url}<br>\n";
1786 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1787 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
1789 if ( '' != $align ) {
1790 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1792 return str_replace("\n", ' ',$prefix.$s.$postfix);
1796 * Make HTML for a thumbnail including image, border and caption
1797 * $img is an Image object
1799 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1800 global $wgStylePath, $wgContLang;
1801 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1802 $url = $img->getViewURL();
1804 #$label = htmlspecialchars( $label );
1805 $alt = preg_replace( '/<[^>]*>/', '', $label);
1806 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1807 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1809 $width = $height = 0;
1810 if ( $img->exists() )
1812 $width = $img->getWidth();
1813 $height = $img->getHeight();
1815 if ( 0 == $width ||
0 == $height )
1817 $width = $height = 200;
1819 if ( $boxwidth == 0 )
1825 // Use image dimensions, don't scale
1827 $oboxwidth = $boxwidth +
2;
1828 $boxheight = $height;
1831 $h = intval( $height/($width/$boxwidth) );
1832 $oboxwidth = $boxwidth +
2;
1833 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1835 $boxwidth *= $boxheight/$h;
1839 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1842 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1844 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1845 $manual_img = Image
::newFromTitle( $manual_title );
1846 $thumbUrl = $manual_img->getViewURL();
1847 if ( $manual_img->exists() )
1849 $width = $manual_img->getWidth();
1850 $height = $manual_img->getHeight();
1851 $boxwidth = $width ;
1852 $boxheight = $height ;
1853 $oboxwidth = $boxwidth +
2 ;
1857 $u = $img->getEscapeLocalURL();
1859 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1860 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1861 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1863 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1864 if ( $thumbUrl == '' ) {
1865 $s .= wfMsg( 'missingimage', $img->getName() );
1868 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1869 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1870 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
1871 'longdesc="'.$u.'" /></a>';
1875 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1876 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1877 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1878 'width="15" height="11" alt="'.$more.'" /></a></div>';
1881 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1882 return str_replace("\n", ' ', $s);
1885 function makeMediaLink( $name, $url, $alt = '' ) {
1886 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1887 return $this->makeMediaLinkObj( $nt, $alt );
1890 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
1891 if ( ! isset( $nt ) )
1893 ### HOTFIX. Instead of breaking, return empty string.
1896 $name = $nt->getDBKey();
1897 $img = Image
::newFromTitle( $nt );
1898 $url = $img->getURL();
1899 # $nourl can be set by the parser
1900 # this is a hack to mask absolute URLs, so the parser doesn't
1901 # linkify them (it is currently not context-aware)
1903 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
1904 if ( empty( $alt ) ) {
1905 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1907 $u = htmlspecialchars( $url );
1908 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1913 function specialLink( $name, $key = '' ) {
1916 if ( '' == $key ) { $key = strtolower( $name ); }
1917 $pn = $wgContLang->ucfirst( $name );
1918 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1922 function makeExternalLink( $url, $text, $escape = true ) {
1923 $style = $this->getExternalLinkAttributes( $url, $text );
1924 $url = htmlspecialchars( $url );
1926 $text = htmlspecialchars( $text );
1928 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1933 * This function is called by all recent changes variants, by the page history,
1934 * and by the user contributions list. It is responsible for formatting edit
1935 * comments. It escapes any HTML in the comment, but adds some CSS to format
1936 * auto-generated comments (from section editing) and formats [[wikilinks]].
1938 * The &$title parameter must be a title OBJECT. It is used to generate a
1939 * direct link to the section in the autocomment.
1940 * @author Erik Moeller <moeller@scireview.de>
1942 * Note: there's not always a title to pass to this function.
1943 * Since you can't set a default parameter for a reference, I've turned it
1944 * temporarily to a value pass. Should be adjusted further. --brion
1946 function formatComment($comment, $title = NULL) {
1947 $fname = 'Skin::formatComment';
1948 wfProfileIn( $fname );
1951 $comment = htmlspecialchars( $comment );
1953 # The pattern for autogen comments is / * foo * /, which makes for
1955 # We look for all comments, match any text before and after the comment,
1956 # add a separator where needed and format the comment itself with CSS
1957 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
1965 # This is hackish but should work in most cases.
1966 $section=str_replace('[[','',$section);
1967 $section=str_replace(']]','',$section);
1968 $title->mFragment
=$section;
1969 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
1973 if($pre) { $auto = $sep.' '.$auto; }
1974 if($post) { $auto .= ' '.$sep; }
1975 $auto='<span class="autocomment">'.$auto.'</span>';
1976 $comment=$pre.$auto.$post;
1979 # format regular and media links - all other wiki formatting
1981 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
1982 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
1983 # Handle link renaming [[foo|text]] will show link as "text"
1984 if( "" != $match[3] ) {
1989 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
1990 # Media link; trail not supported.
1991 $linkRegexp = '/\[\[(.*?)\]\]/';
1992 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
1994 # Other kind of link
1995 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
1996 $trail = $submatch[1];
2000 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2001 if ($match[1][0] == ':')
2002 $match[1] = substr($match[1], 1);
2003 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2005 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2007 wfProfileOut( $fname );
2011 function tocIndent($level) {
2012 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2015 function tocUnindent($level) {
2016 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2020 * parameter level defines if we are on an indentation level
2022 function tocLine( $anchor, $tocline, $level ) {
2023 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2027 return '<div class="tocline">'.$link."</div>\n";
2032 function tocTable($toc) {
2033 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2034 # try min-width & co when somebody gets a chance
2035 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2037 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2038 '<b>'.wfMsgForContent('toc').'</b>' .
2040 '</td></tr><tr id="tocinside"><td>'."\n".
2041 $toc."</td></tr></table>\n";
2045 * These two do not check for permissions: check $wgTitle->userCanEdit
2046 * before calling them
2048 function editSectionScriptForOther( $title, $section, $head ) {
2049 $ttl = Title
::newFromText( $title );
2050 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2051 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2054 function editSectionScript( $nt, $section, $head ) {
2056 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2059 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
2060 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2063 function editSectionLinkForOther( $title, $section ) {
2067 $title = Title
::newFromText($title);
2068 $editurl = '§ion='.$section;
2069 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2071 if( $wgContLang->isRTL() ) {
2073 $nearside = 'right';
2078 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2082 function editSectionLink( $nt, $section ) {
2086 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2087 # Section edit links would be out of sync on an old page.
2088 # But, if we're diffing to the current page, they'll be
2093 $editurl = '§ion='.$section;
2094 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2096 if( $wgContLang->isRTL() ) {
2098 $nearside = 'right';
2103 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2110 function suppressUrlExpansion() {