X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=262c497f4ea81b0388a4a87bf822932fdf3fe416;hb=d42c91a23cf7c59a3cc1cc88438d087ca0d8bf6b;hp=336a868c5888b47a40e1548bb751d971fea3cb47;hpb=81f17df33b1b8d2a2d50feb04e368f3ac6e134f6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 336a868c58..262c497f4e 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,33 +1,66 @@ "Standard", - 'nostalgia' => "Nostalgia", - 'cologneblue' => "CologneBlue" +/* +$wgValidSkinNames = array( + 'standard' => 'Standard', + 'nostalgia' => 'Nostalgia', + 'cologneblue' => 'CologneBlue' ); if( $wgUsePHPTal ) { - #$wgValidSkinNames[] = "PHPTal"; - #$wgValidSkinNames['davinci'] = "DaVinci"; - #$wgValidSkinNames['mono'] = "Mono"; - $wgValidSkinNames['monobook'] = "MonoBook"; - #$wgValidSkinNames['monobookminimal'] = "MonoBookMinimal"; + #$wgValidSkinNames[] = 'PHPTal'; + #$wgValidSkinNames['davinci'] = 'DaVinci'; + #$wgValidSkinNames['mono'] = 'Mono'; + #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; + $wgValidSkinNames['monobook'] = 'MonoBook'; + $wgValidSkinNames['myskin'] = 'MySkin'; + $wgValidSkinNames['chick'] = 'Chick'; +} +*/ + +# Get a list of all skins available in /skins/ +# Build using the regular expression '^(.*).php$' +# Array keys are all lower case, array value keep the case used by filename +# + +$skinDir = dir($IP.'/skins'); + +# while code from www.php.net +while (false !== ($file = $skinDir->read())) { + if(preg_match('/^(.*).php$/',$file, $matches)) { + $aSkin = $matches[1]; + $wgValidSkinNames[strtolower($aSkin)] = $aSkin; + } } +$skinDir->close(); +unset($matches); -require_once( "RecentChange.php" ); +require_once( 'RecentChange.php' ); +/** + * @todo document + * @package MediaWiki + */ class RCCacheEntry extends RecentChange { var $secureName, $link; - var $curlink , $lastlink , $usertalklink , $versionlink ; + var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ; var $userlink, $timestamp, $watched; function newFromParent( $rc ) @@ -39,52 +72,71 @@ class RCCacheEntry extends RecentChange } } ; -class Skin { - /* private */ var $lastdate, $lastline; +/** + * The main skin class that provide methods and properties for all other skins + * including PHPTal skins. + * This base class is also the "Standard" skin. + * @package MediaWiki + */ +class Skin { + /**#@+ + * @access private + */ + var $lastdate, $lastline; var $linktrail ; # linktrail regexp var $rc_cache ; # Cache for Enhanced Recent Changes var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle var $rcMoveIndex; + var $postParseLinkColour = true; + /**#@-*/ - function Skin() - { - $this->linktrail = wfMsg("linktrail"); + function Skin() { + global $wgUseOldExistenceCheck; + $postParseLinkColour = !$wgUseOldExistenceCheck; + $this->linktrail = wfMsg('linktrail'); } - function getSkinNames() - { + function getSkinNames() { global $wgValidSkinNames; return $wgValidSkinNames; } - function getStylesheet() - { - return "wikistandard.css"; + function getStylesheet() { + return 'common/wikistandard.css'; } - function qbSetting() - { + function getSkinName() { + return 'standard'; + } + + /** + * Get/set accessor for delayed link colouring + */ + function postParseLinkColour( $setting = NULL ) { + return wfSetVar( $this->postParseLinkColour, $setting ); + } + + function qbSetting() { global $wgOut, $wgUser; if ( $wgOut->isQuickbarSuppressed() ) { return 0; } - $q = $wgUser->getOption( "quickbar" ); - if ( "" == $q ) { $q = 0; } + $q = $wgUser->getOption( 'quickbar' ); + if ( '' == $q ) { $q = 0; } return $q; } - function initPage( &$out ) - { - $fname = "Skin::initPage"; + function initPage( &$out ) { + $fname = 'Skin::initPage'; wfProfileIn( $fname ); - - $out->addLink( array( "rel" => "shortcut icon", "href" => "/favicon.ico" ) ); - + + $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) ); + $this->addMetadataLinks($out); - + wfProfileOut( $fname ); } - + function addMetadataLinks( &$out ) { global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action; global $wgRightsPage, $wgRightsUrl; @@ -95,16 +147,16 @@ class Skin { $out->addMetadataLink( array( 'title' => 'Creative Commons', 'type' => 'application/rdf+xml', - 'href' => $wgTitle->getLocalURL( "action=creativecommons") ) ); + 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) ); } if( $wgEnableDublinCoreRdf ) { $out->addMetadataLink( array( 'title' => 'Dublin Core', 'type' => 'application/rdf+xml', - 'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) ); + 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) ); } } - $copyright = ""; + $copyright = ''; if( $wgRightsPage ) { $copy = Title::newFromText( $wgRightsPage ); if( $copy ) { @@ -116,15 +168,15 @@ class Skin { } if( $copyright ) { $out->addLink( array( - "rel" => "copyright", - "href" => $copyright ) ); + 'rel' => 'copyright', + 'href' => $copyright ) ); } } - + function outputPage( &$out ) { global $wgDebugComments; - - wfProfileIn( "Skin::outputPage" ); + + wfProfileIn( 'Skin::outputPage' ); $this->initPage( $out ); $out->out( $out->headElement() ); @@ -143,7 +195,7 @@ class Skin { $out->out( $out->mBodytext . "\n" ); $out->out( $this->afterContent() ); - + wfProfileClose(); $out->out( $out->reportTime() ); @@ -151,170 +203,196 @@ class Skin { } function getHeadScripts() { - global $wgStylePath; - $r = "\n"; + global $wgStylePath, $wgUser, $wgLang, $wgAllowUserJs; + $r = "\n"; + if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in + $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); + $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript')); + $r .= '\n"; + } return $r; } - function getUserStyles() - { - global $wgOut, $wgStylePath, $wgLang; + # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way) + function getUserStylesheet() { + global $wgOut, $wgStylePath, $wgLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss; $sheet = $this->getStylesheet(); - $s = "\n"; return $s; } - function doGetUserStyles() - { - global $wgUser; + /** + * Some styles that are set by user through the user settings interface. + */ + function doGetUserStyles() { + global $wgUser, $wgLang; - $s = ""; - if ( 1 == $wgUser->getOption( "underline" ) ) { + $csspage = $wgLang->getNsText( NS_MEDIAWIKI ) . ':' . $this->getSkinName() . '.css'; + $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n"; + + if ( 1 == $wgUser->getOption( 'underline' ) ) { # Don't override browser settings } else { # CHECK MERGE @@@ # Force no underline - $s .= "a { " . - "text-decoration: none; }\n"; + $s .= "a { text-decoration: none; }\n"; } - if ( 1 == $wgUser->getOption( "highlightbroken" ) ) { + if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) { $s .= "a.new, #quickbar a.new { color: #CC2200; }\n"; } - if ( 1 == $wgUser->getOption( "justify" ) ) { + if ( 1 == $wgUser->getOption( 'justify' ) ) { $s .= "#article { text-align: justify; }\n"; } return $s; } - function getBodyOptions() - { + function getBodyOptions() { global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest; - + extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) ); if ( 0 != $wgTitle->getNamespace() ) { - $a = array( "bgcolor" => "#ffffec" ); + $a = array( 'bgcolor' => '#ffffec' ); } - else $a = array( "bgcolor" => "#FFFFFF" ); - if($wgOut->isArticle() && $wgUser->getOption("editondblclick") && + else $a = array( 'bgcolor' => '#FFFFFF' ); + if($wgOut->isArticle() && $wgUser->getOption('editondblclick') && (!$wgTitle->isProtected() || $wgUser->isSysop()) ) { - $t = wfMsg( "editthispage" ); - $oid = $red = ""; - if ( !empty($redirect) ) { - $red = "&redirect={$redirect}"; + $t = wfMsg( 'editthispage' ); + $oid = $red = ''; + if ( !empty($redirect) ) { + $red = "&redirect={$redirect}"; } if ( !empty($oldid) && ! isset( $diff ) ) { $oid = "&oldid={$oldid}"; } $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" ); - $s = "document.location = \"" .$s ."\";"; - $a += array ("ondblclick" => $s); + $s = 'document.location = "' .$s .'";'; + $a += array ('ondblclick' => $s); } $a['onload'] = $wgOut->getOnloadHandler(); return $a; } - function getExternalLinkAttributes( $link, $text ) - { + function getExternalLinkAttributes( $link, $text, $class='' ) { global $wgUser, $wgOut, $wgLang; $link = urldecode( $link ); $link = $wgLang->checkTitleEncoding( $link ); - $link = str_replace( "_", " ", $link ); - $link = wfEscapeHTML( $link ); + $link = str_replace( '_', ' ', $link ); + $link = htmlspecialchars( $link ); - $r = " class='external'"; + $r = ($class != '') ? " class='$class'" : " class='external'"; - if ( 1 == $wgUser->getOption( "hover" ) ) { + if ( 1 == $wgUser->getOption( 'hover' ) ) { $r .= " title=\"{$link}\""; } return $r; } - function getInternalLinkAttributes( $link, $text, $broken = false ) - { + function getInternalLinkAttributes( $link, $text, $broken = false ) { global $wgUser, $wgOut; $link = urldecode( $link ); - $link = str_replace( "_", " ", $link ); - $link = wfEscapeHTML( $link ); + $link = str_replace( '_', ' ', $link ); + $link = htmlspecialchars( $link ); - if ( $broken == "stub" ) { - $r = " class='stub'"; - } else if ( $broken == "yes" ) { - $r = " class='new'"; - } else { - $r = ""; + if ( $broken == 'stub' ) { + $r = ' class="stub"'; + } else if ( $broken == 'yes' ) { + $r = ' class="new"'; + } else { + $r = ''; } - if ( 1 == $wgUser->getOption( "hover" ) ) { + if ( 1 == $wgUser->getOption( 'hover' ) ) { $r .= " title=\"{$link}\""; } return $r; } - - function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) - { + + /** + * @param bool $broken + */ + function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) { global $wgUser, $wgOut; - if ( $broken == "stub" ) { - $r = " class='stub'"; - } else if ( $broken == "yes" ) { - $r = " class='new'"; - } else { - $r = ""; + if ( $broken == 'stub' ) { + $r = ' class="stub"'; + } else if ( $broken == 'yes' ) { + $r = ' class="new"'; + } else { + $r = ''; } - if ( 1 == $wgUser->getOption( "hover" ) ) { + if ( 1 == $wgUser->getOption( 'hover' ) ) { $r .= ' title ="' . $nt->getEscapedText() . '"'; } return $r; - } - - function getLogo() - { + } + + /** + * URL to the logo + */ + function getLogo() { global $wgLogo; return $wgLogo; } - # This will be called immediately after the tag. Split into - # two functions to make it easier to subclass. - # - function beforeContent() - { - global $wgUser, $wgOut, $wgSiteNotice; + /** + * This will be called immediately after the tag. Split into + * two functions to make it easier to subclass. + */ + function beforeContent() { + global $wgUser, $wgOut; - if( $wgSiteNotice ) { - $note = "\n
$wgSiteNotice
\n"; - } else { - $note = ""; - } - return $this->doBeforeContent() . $note; + return $this->doBeforeContent(); } - function doBeforeContent() - { - global $wgUser, $wgOut, $wgTitle, $wgLang; - $fname = "Skin::doBeforeContent"; + function doBeforeContent() { + global $wgUser, $wgOut, $wgTitle, $wgLang, $wgSiteNotice; + $fname = 'Skin::doBeforeContent'; wfProfileIn( $fname ); - $s = ""; + $s = ''; $qb = $this->qbSetting(); if( $langlinks = $this->otherLanguages() ) { $rows = 2; - $borderhack = ""; + $borderhack = ''; } else { $rows = 1; $langlinks = false; - $borderhack = "class='top'"; + $borderhack = 'class="top"'; } $s .= "\n
\n
\n" . @@ -323,14 +401,14 @@ class Skin { $shove = ($qb != 0); $left = ($qb == 1 || $qb == 3); if($wgLang->isRTL()) $left = !$left; - + if ( !$shove ) { $s .= "\n" . - $this->logoText() . ""; + $this->logoText() . ''; } elseif( $left ) { $s .= $this->getQuickbarCompensator( $rows ); } - $l = $wgLang->isRTL() ? "right" : "left"; + $l = $wgLang->isRTL() ? 'right' : 'left'; $s .= "\n"; $s .= $this->topLinks() ; @@ -351,63 +429,110 @@ class Skin { $s .= "\n\n
\n"; $s .= "\n
\n"; + if( $wgSiteNotice ) { + $s .= "\n
$wgSiteNotice
\n"; + } $s .= $this->pageTitle(); $s .= $this->pageSubtitle() ; $s .= $this->getCategories(); wfProfileOut( $fname ); return $s; } - - function getCategories () { + + function getCategoryLinks () { global $wgOut, $wgTitle, $wgUser, $wgParser; - global $wgUseCategoryMagic; - if( !$wgUseCategoryMagic ) return "" ; - if( count( $wgOut->mCategoryLinks ) == 0 ) return ""; - if( !$wgOut->isArticle() ) return ""; - - $t = implode ( " | " , $wgOut->mCategoryLinks ) ; - $s = $this->makeKnownLink( "Special:Categories", - wfMsg( "categories" ), "article=" . urlencode( $wgTitle->getPrefixedDBkey() ) ) - . ": " . $t; - return ""; - } - - function getQuickbarCompensator( $rows = 1 ) - { + global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang; + + if( !$wgUseCategoryMagic ) return '' ; + if( count( $wgOut->mCategoryLinks ) == 0 ) return ''; + + # Taken out so that they will be displayed in previews -- TS + #if( !$wgOut->isArticle() ) return ''; + + $t = implode ( ' | ' , $wgOut->mCategoryLinks ) ; + $s = $this->makeKnownLink( 'Special:Categories', + wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) ) + . ': ' . $t; + + # optional 'dmoz-like' category browser. Will be shown under the list + # of categories an article belong to + if($wgUseCategoryBrowser) { + $s .= '

'; + + # get a big array of the parents tree + $parenttree = $wgTitle->getCategorieBrowser(); + + # Render the array as a serie of links + function walkThrough ($tree) { + global $wgUser; + $sk = $wgUser->getSkin(); + $return = ''; + foreach($tree as $element => $parent) { + if(empty($parent)) { + # element start a new list + $return .= '
'; + } else { + # grab the others elements + $return .= walkThrough($parent); + } + # add our current element to the list + $eltitle = Title::NewFromText($element); + # FIXME : should be makeLink() [AV] + $return .= $sk->makeKnownLink($element, $eltitle->getText()).' > '; + } + return $return; + } + + $s .= walkThrough($parenttree); + } + + return $s; + } + + function getCategories() { + $catlinks=$this->getCategoryLinks(); + if(!empty($catlinks)) { + return ""; + } + } + + function getQuickbarCompensator( $rows = 1 ) { return " "; } # This gets called immediately before the tag. # - function afterContent() - { + function afterContent() { global $wgUser, $wgOut, $wgServer; global $wgTitle, $wgLang; - + $printfooter = "
\n" . $this->printFooter() . "
\n"; return $printfooter . $this->doAfterContent(); } - - function printFooter() { + + function printSource() { global $wgTitle; $url = htmlspecialchars( $wgTitle->getFullURL() ); - return "

" . wfMsg( "retrievedfrom", "$url" ) . + return wfMsg( "retrievedfrom", "$url" ); + } + + function printFooter() { + return "

" . $this->printSource() . "

\n\n

" . $this->pageStats() . "

\n"; } - - function doAfterContent() - { + + function doAfterContent() { global $wgUser, $wgOut, $wgLang; - $fname = "Skin::doAfterContent"; + $fname = 'Skin::doAfterContent'; wfProfileIn( $fname ); - wfProfileIn( "$fname-1" ); + wfProfileIn( $fname.'-1' ); $s = "\n

\n"; $s .= "\n\n
\n"; - - wfProfileOut( "$fname-3" ); - wfProfileIn( "$fname-4" ); + + wfProfileOut( $fname.'-3' ); + wfProfileIn( $fname.'-4' ); if ( 0 != $qb ) { $s .= $this->quickBar(); } - wfProfileOut( "$fname-4" ); + wfProfileOut( $fname.'-4' ); wfProfileOut( $fname ); return $s; } - function pageTitleLinks() - { + function pageTitleLinks() { global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest; extract( $wgRequest->getValues( 'oldid', 'diff' ) ); $action = $wgRequest->getText( 'action' ); $s = $this->printableLink(); - if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ; + if ( wfMsg ( 'disclaimers' ) != '-' ) $s .= ' | ' . $this->makeKnownLink( wfMsg( 'disclaimerpage' ), wfMsg( 'disclaimers' ) ) ; if ( $wgOut->isArticleRelated() ) { if ( $wgTitle->getNamespace() == Namespace::getImage() ) { $name = $wgTitle->getDBkey(); - $link = wfEscapeHTML( Image::wfImageUrl( $name ) ); + $link = htmlspecialchars( Image::wfImageUrl( $name ) ); $style = $this->getInternalLinkAttributes( $link, $name ); $s .= " | {$name}"; } @@ -464,56 +588,67 @@ class Skin { if ( isset ( $wgUseApproval ) && $wgUseApproval ) { $t = $wgTitle->getDBkey(); - $name = "Approve this article" ; + $name = 'Approve this article' ; $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ; - #wfEscapeHTML( wfImageUrl( $name ) ); + #htmlspecialchars( wfImageUrl( $name ) ); $style = $this->getExternalLinkAttributes( $link, $name ); $s .= " | {$name}" ; - } + } } - if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) { - $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(), - wfMsg( "currentrev" ) ); + if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) { + $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(), + wfMsg( 'currentrev' ) ); } if ( $wgUser->getNewtalk() ) { - # do not show "You have new messages" text when we are viewing our - # own talk page + # do not show "You have new messages" text when we are viewing our + # own talk page if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 && $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) { $n =$wgUser->getName(); $tl = $this->makeKnownLink( $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}", - wfMsg("newmessageslink") ); - $s.=" | ". wfMsg( "newmessages", $tl ) . ""; + wfMsg('newmessageslink') ); + $s.= ' | '. wfMsg( 'newmessages', $tl ) . ''; + # disable caching + $wgOut->setSquidMaxage(0); } } - if( $wgUser->isSysop() && - (($wgTitle->getArticleId() == 0) || ($action == "history")) && - ($n = $wgTitle->isDeleted() ) ) { - $s .= " | " . wfMsg( "thisisdeleted", - $this->makeKnownLink( - $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ), - wfMsg( "restorelink", $n ) ) ); + + $undelete = $this->getUndeleteLink(); + if( !empty( $undelete ) ) { + $s .= ' | '.$undelete; } return $s; } - function printableLink() - { + function getUndeleteLink() { + global $wgUser, $wgTitle, $wgLang, $action; + if( $wgUser->isSysop() && + (($wgTitle->getArticleId() == 0) || ($action == "history")) && + ($n = $wgTitle->isDeleted() ) ) { + return wfMsg( 'thisisdeleted', + $this->makeKnownLink( + $wgLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ), + wfMsg( 'restorelink', $n ) ) ); + } + return ''; + } + + function printableLink() { global $wgOut, $wgFeedClasses, $wgRequest; $baseurl = $_SERVER['REQUEST_URI']; - if( strpos( "?", $baseurl ) == false ) { - $baseurl .= "?"; + if( strpos( '?', $baseurl ) == false ) { + $baseurl .= '?'; } else { - $baseurl .= "&"; + $baseurl .= '&'; } $baseurl = htmlspecialchars( $baseurl ); - $printurl = $wgRequest->escapeAppendQuery( "printable=yes" ); - - $s = "" . wfMsg( "printableversion" ) . ""; + $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' ); + + $s = "" . wfMsg( 'printableversion' ) . ''; if( $wgOut->isSyndicated() ) { foreach( $wgFeedClasses as $format => $class ) { $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" ); @@ -523,23 +658,21 @@ class Skin { return $s; } - function pageTitle() - { + function pageTitle() { global $wgOut, $wgTitle, $wgUser; - $s = "

" . htmlspecialchars( $wgOut->getPageTitle() ) . "

"; - if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);} + $s = '

' . htmlspecialchars( $wgOut->getPageTitle() ) . '

'; + if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);} return $s; } - function pageSubtitle() - { + function pageSubtitle() { global $wgOut; $sub = $wgOut->getSubtitle(); - if ( "" == $sub ) { + if ( '' == $sub ) { global $wgExtraSubtitle; - $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle; + $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle; } $subpages = $this->subPageSubtitle(); $sub .= !empty($subpages)?"

$subpages":''; @@ -547,29 +680,28 @@ class Skin { return $s; } - function subPageSubtitle() - { + function subPageSubtitle() { global $wgOut,$wgTitle,$wgNamespacesWithSubpages; $subpages = ''; if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) { $ptext=$wgTitle->getPrefixedText(); - if(preg_match("/\//",$ptext)) { - $links=explode("/",$ptext); - $c=0; - $growinglink=""; + if(preg_match('/\//',$ptext)) { + $links = explode('/',$ptext); + $c = 0; + $growinglink = ''; foreach($links as $link) { $c++; if ($cmakeLink( $growinglink, $link ); - if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time + if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time if ($c>1) { - $subpages .= " | "; + $subpages .= ' | '; } else { - $subpages .="< "; + $subpages .= '< '; } $subpages .= $getlink; - $growinglink.="/"; + $growinglink .= '/'; } } } @@ -577,34 +709,33 @@ class Skin { return $subpages; } - function nameAndLogin() - { + function nameAndLogin() { global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader, $wgIP; - $li = $wgLang->specialPage( "Userlogin" ); - $lo = $wgLang->specialPage( "Userlogout" ); + $li = $wgLang->specialPage( 'Userlogin' ); + $lo = $wgLang->specialPage( 'Userlogout' ); - $s = ""; + $s = ''; if ( 0 == $wgUser->getID() ) { - if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) { + if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) { $n = $wgIP; $tl = $this->makeKnownLink( $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}", $wgLang->getNsText( Namespace::getTalk( 0 ) ) ); - - $s .= $n . " (".$tl.")"; + + $s .= $n . ' ('.$tl.')'; } else { - $s .= wfMsg("notloggedin"); + $s .= wfMsg('notloggedin'); } - + $rt = $wgTitle->getPrefixedURL(); if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) { - $q = ""; + $q = ''; } else { $q = "returnto={$rt}"; } - + $s .= "\n
" . $this->makeKnownLink( $li, - wfMsg( "login" ), $q ); + wfMsg( 'login' ), $q ); } else { $n = $wgUser->getName(); $rt = $wgTitle->getPrefixedURL(); @@ -612,51 +743,49 @@ class Skin { Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}", $wgLang->getNsText( Namespace::getTalk( 0 ) ) ); - $tl = " ({$tl})"; - + $tl = " ({$tl})"; + $s .= $this->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}
" . - $this->makeKnownLink( $lo, wfMsg( "logout" ), - "returnto={$rt}" ) . " | " . - $this->specialLink( "preferences" ); + $this->makeKnownLink( $lo, wfMsg( 'logout' ), + "returnto={$rt}" ) . ' | ' . + $this->specialLink( 'preferences' ); } - $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ), - wfMsg( "help" ) ); + $s .= ' | ' . $this->makeKnownLink( wfMsg( 'helppage' ), + wfMsg( 'help' ) ); return $s; } - + function getSearchLink() { - $searchPage =& Title::makeTitle( NS_SPECIAL, "Search" ); + $searchPage =& Title::makeTitle( NS_SPECIAL, 'Search' ); return $searchPage->getLocalURL(); } - + function escapeSearchLink() { return htmlspecialchars( $this->getSearchLink() ); } - - function searchForm() - { + + function searchForm() { global $wgRequest; $search = $wgRequest->getText( 'search' ); - - $s = "

escapeSearchLink() . "\">\n" - . "\n" - . " " - . "\n
"; + . ' ' + . '\n"; return $s; } - function topLinks() - { + function topLinks() { global $wgOut; $sep = " |\n"; $s = $this->mainPageLink() . $sep - . $this->specialLink( "recentchanges" ); + . $this->specialLink( 'recentchanges' ); if ( $wgOut->isArticleRelated() ) { $s .= $sep . $this->editThisPage() @@ -668,14 +797,13 @@ class Skin { return $s; } - function bottomLinks() - { + function bottomLinks() { global $wgOut, $wgUser, $wgTitle; $sep = " |\n"; - $s = ""; + $s = ''; if ( $wgOut->isArticleRelated() ) { - $s .= "" . $this->editThisPage() . ""; + $s .= '' . $this->editThisPage() . ''; if ( 0 != $wgUser->getID() ) { $s .= $sep . $this->watchThisPage(); } @@ -686,11 +814,11 @@ class Skin { if ( $wgTitle->getNamespace() == Namespace::getUser() || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) ) - + { $id=User::idFromName($wgTitle->getText()); $ip=User::isIP($wgTitle->getText()); - + if($id || $ip) { # both anons and non-anons have contri list $s .= $sep . $this->userContribsLink(); } @@ -710,115 +838,47 @@ class Skin { return $s; } - function pageStats() - { + function pageStats() { global $wgOut, $wgLang, $wgArticle, $wgRequest; - global $wgDisableCounters; + global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax; extract( $wgRequest->getValues( 'oldid', 'diff' ) ); - if ( ! $wgOut->isArticle() ) { return ""; } - if ( isset( $oldid ) || isset( $diff ) ) { return ""; } - if ( 0 == $wgArticle->getID() ) { return ""; } + if ( ! $wgOut->isArticle() ) { return ''; } + if ( isset( $oldid ) || isset( $diff ) ) { return ''; } + if ( 0 == $wgArticle->getID() ) { return ''; } - $s = ""; + $s = ''; if ( !$wgDisableCounters ) { $count = $wgLang->formatNum( $wgArticle->getCount() ); if ( $count ) { - $s = wfMsg( "viewcount", $count ); + $s = wfMsg( 'viewcount', $count ); } } - $s .= " " . $this->getCredits(); - - return $s . " " . $this->getCopyright(); - } - - function getCredits() { - global $wgMaxCredits; - - $s = ''; - - if (!isset($wgMaxCredits) || $wgMaxCredits == 0) { - $s = $this->lastModified(); - } else { - $s = $this->getAuthorCredits(); - if ($wgMaxCredits > 1) { - $s .= " " . $this->getContributorCredits(); - } - } - - return $s; - } - - function getAuthorCredits() { - global $wgLang, $wgArticle; - - $last_author = $wgArticle->getUser(); - - if ($last_author == 0) { - $author_credit = wfMsg("anonymous"); + if (isset($wgMaxCredits) && $wgMaxCredits != 0) { + require_once("Credits.php"); + $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { - $real_name = User::whoIsReal($last_author); - if (!empty($real_name)) { - $author_credit = $real_name; - } else { - $author_credit = wfMsg("siteuser", User::whoIs($last_author)); - } - } - - $timestamp = $wgArticle->getTimestamp(); - if ( $timestamp ) { - $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true ); - } else { - $d = ""; + $s .= $this->lastModified(); } - return wfMsg("lastmodifiedby", $d, $author_credit); - } - function getContributorCredits() { - - global $wgArticle, $wgMaxCredits, $wgLang; + return $s . ' ' . $this->getCopyright(); + } - # don't count last editor + function getCopyright() { + global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest; - $contributors = $wgArticle->getContributors($wgMaxCredits - 1); - - $real_names = array(); - $user_names = array(); - # Sift for real versus user names - - foreach ($contributors as $user_id => $user_parts) { - if ($user_id != 0) { - if (!empty($user_parts[1])) { - $real_names[$user_id] = $user_parts[1]; - } else { - $user_names[$user_id] = $user_parts[0]; - } - } - } - - $real = $wgLang->listToText(array_values($real_names)); - $user = $wgLang->listToText(array_values($user_names)); + $oldid = $wgRequest->getVal( 'oldid' ); + $diff = $wgRequest->getVal( 'diff' ); - if (!empty($user)) { - $user = wfMsg("siteusers", $user); - } - - if ($contributors[0] && $contributors[0][0] > 0) { - $anon = wfMsg("anonymous"); + if ( !is_null( $oldid ) && is_null( $diff ) && wfMsg( 'history_copyright' ) !== '-' ) { + $msg = 'history_copyright'; } else { - $anon = ''; + $msg = 'copyright'; } - - $creds = $wgLang->listToText(array($real, $user, $anon)); - - return wfMsg("othercontribs", $creds); - } - - function getCopyright() { - global $wgRightsPage, $wgRightsUrl, $wgRightsText; - $out = ""; + + $out = ''; if( $wgRightsPage ) { $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText ); } elseif( $wgRightsUrl ) { @@ -827,68 +887,70 @@ class Skin { # Give up now return $out; } - $out .= wfMsg( "copyright", $link ); + $out .= wfMsg( $msg, $link ); return $out; } - + function getCopyrightIcon() { global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon; - $out = ""; + $out = ''; if( $wgRightsIcon ) { $icon = htmlspecialchars( $wgRightsIcon ); if( $wgRightsUrl ) { $url = htmlspecialchars( $wgRightsUrl ); - $out .= ""; + $out .= ''; } $text = htmlspecialchars( $wgRightsText ); $out .= "$text"; if( $wgRightsUrl ) { - $out .= ""; + $out .= ''; } } return $out; } - + function getPoweredBy() { global $wgStylePath; - $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" ); - $img = "MediaWiki"; + $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" ); + $img = 'MediaWiki'; return $img; } - function lastModified() - { + function lastModified() { global $wgLang, $wgArticle; - + $timestamp = $wgArticle->getTimestamp(); if ( $timestamp ) { $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true ); - $s = " " . wfMsg( "lastmodified", $d ); + $s = ' ' . wfMsg( 'lastmodified', $d ); } else { - $s = ""; + $s = ''; } return $s; } - function logoText( $align = "" ) - { - if ( "" != $align ) { $a = " align='{$align}'"; } - else { $a = ""; } - - $mp = wfMsg( "mainpage" ); + function logoText( $align = '' ) { + if ( '' != $align ) { $a = " align='{$align}'"; } + else { $a = ''; } + + $mp = wfMsg( 'mainpage' ); $titleObj = Title::newFromText( $mp ); - $s = "escapeLocalURL() - . "\">getLogo() . "\" alt=\"" . "[{$mp}]\" />"; + if ( is_object( $titleObj ) ) { + $url = $titleObj->escapeLocalURL(); + } else { + $url = ''; + } + + $logourl = $this->getLogo(); + $s = ""; return $s; } - function quickBar() - { + function quickBar() { global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang; global $wgDisableUploads, $wgRemoteUploads; - - $fname = "Skin::quickBar"; + + $fname = 'Skin::quickBar'; wfProfileIn( $fname ); $action = $wgRequest->getText( 'action' ); @@ -900,69 +962,69 @@ class Skin { $sep = "\n
"; $s .= $this->mainPageLink() - . $sep . $this->specialLink( "recentchanges" ) - . $sep . $this->specialLink( "randompage" ); - if ($wgUser->getID()) { - $s.= $sep . $this->specialLink( "watchlist" ) ; - $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ), - wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) ); - + . $sep . $this->specialLink( 'recentchanges' ) + . $sep . $this->specialLink( 'randompage' ); + if ($wgUser->getID()) { + $s.= $sep . $this->specialLink( 'watchlist' ) ; + $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( 'Contributions' ), + wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) ); + } // only show watchlist link if logged in - if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ; + if ( wfMsg ( 'currentevents' ) != '-' ) $s .= $sep . $this->makeKnownLink( wfMsg( 'currentevents' ), '' ) ; $s .= "\n

"; $articleExists = $wgTitle->getArticleId(); - if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) { + if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) { if($wgOut->isArticle()) { - $s .= "" . $this->editThisPage() . ""; + $s .= '' . $this->editThisPage() . ''; } else { # backlink to the article in edit or history mode if($articleExists){ # no backlink if no article switch($tns) { case 0: - $text = wfMsg("articlepage"); + $text = wfMsg('articlepage'); break; case 1: - $text = wfMsg("viewtalkpage"); + $text = wfMsg('viewtalkpage'); break; case 2: - $text = wfMsg("userpage"); + $text = wfMsg('userpage'); break; case 3: - $text = wfMsg("viewtalkpage"); - break; - case 4: - $text = wfMsg("wikipediapage"); + $text = wfMsg('viewtalkpage'); + break; + case 4: + $text = wfMsg('wikipediapage'); break; - case 5: - $text = wfMsg("viewtalkpage"); + case 5: + $text = wfMsg('viewtalkpage'); break; case 6: - $text = wfMsg("imagepage"); + $text = wfMsg('imagepage'); break; case 7: - $text = wfMsg("viewtalkpage"); + $text = wfMsg('viewtalkpage'); break; default: - $text= wfMsg("articlepage"); + $text= wfMsg('articlepage'); } - + $link = $wgTitle->getText(); if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary - $link = $nstext . ":" . $link ; - } + $link = $nstext . ':' . $link ; + } $s .= $this->makeLink( $link, $text ); } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) { # we just throw in a "New page" text to tell the user that he's in edit mode, # and to avoid messing with the separator that is prepended to the next item - $s .= "" . wfMsg("newpage") . ""; + $s .= '' . wfMsg('newpage') . ''; } - + } - - if( $tns%2 && $action!="edit" && !$wpPreview) { - $s.="
".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit§ion=new"); + + if( $tns%2 && $action!='edit' && !$wpPreview) { + $s.= '
'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new'); } /* @@ -972,7 +1034,7 @@ class Skin { unwatched. Therefore we do not show the "Watch this page" link in edit mode */ if ( 0 != $wgUser->getID() && $articleExists) { - if($action!="edit" && $action != "submit" ) + if($action!='edit' && $action != 'submit' ) { $s .= $sep . $this->watchThisPage(); } @@ -984,86 +1046,78 @@ class Skin { $sep . $this->protectThisPage(); } $s .= $sep . $this->talkLink(); - if ($articleExists && $action !="history") { + if ($articleExists && $action !='history') { $s .= $sep . $this->historyLink(); } $s.=$sep . $this->whatLinksHere(); - + if($wgOut->isArticleRelated()) { $s .= $sep . $this->watchPageLinksLink(); } - if ( Namespace::getUser() == $wgTitle->getNamespace() + if ( Namespace::getUser() == $wgTitle->getNamespace() || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) ) { - + $id=User::idFromName($wgTitle->getText()); $ip=User::isIP($wgTitle->getText()); - + if($id||$ip) { $s .= $sep . $this->userContribsLink(); } if ( 0 != $wgUser->getID() ) { if($id) { # can only email real users - $s .= $sep . $this->emailUserLink(); + $s .= $sep . $this->emailUserLink(); } } } $s .= "\n

"; - } - + } + if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) { - $s .= $this->specialLink( "upload" ) . $sep; + $s .= $this->specialLink( 'upload' ) . $sep; } - $s .= $this->specialLink( "specialpages" ) + $s .= $this->specialLink( 'specialpages' ) . $sep . $this->bugReportsLink(); - + global $wgSiteSupportPage; if( $wgSiteSupportPage ) { $s .= "\n
" . wfMsg( "sitesupport" ) . ""; + '" class="internal">' . wfMsg( 'sitesupport' ) . ''; } - + $s .= "\n
\n"; wfProfileOut( $fname ); return $s; } - function specialPagesList() - { + function specialPagesList() { global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript; + require_once('SpecialPage.php'); $a = array(); + $pages = SpecialPage::getPages(); - $validSP = $wgLang->getValidSpecialPages(); - - foreach ( $validSP as $name => $desc ) { - if ( "" == $desc ) { continue; } - $a[$name] = $desc; + foreach ( $pages[''] as $name => $page ) { + $a[$name] = $page->getDescription(); } if ( $wgUser->isSysop() ) - { - $sysopSP = $wgLang->getSysopSpecialPages(); - - foreach ( $sysopSP as $name => $desc ) { - if ( "" == $desc ) { continue; } - $a[$name] = $desc ; + { + foreach ( $pages['sysop'] as $name => $page ) { + $a[$name] = $page->getDescription(); } } if ( $wgUser->isDeveloper() ) - { - $devSP = $wgLang->getDeveloperSpecialPages(); - - foreach ( $devSP as $name => $desc ) { - if ( "" == $desc ) { continue; } - $a[$name] = $desc ; + { + foreach ( $pages['developer'] as $name => $page ) { + $a[$name] = $page->getDescription() ; } } - $go = wfMsg( "go" ); - $sp = wfMsg( "specialpages" ); - $spp = $wgLang->specialPage( "Specialpages" ); + $go = wfMsg( 'go' ); + $sp = wfMsg( 'specialpages' ); + $spp = $wgLang->specialPage( 'Specialpages' ); - $s = "
\n"; + $s = '\n"; $s .= "