From: Rotem Liss Date: Fri, 22 Sep 2006 13:07:06 +0000 (+0000) Subject: (bug 7357) Make supposedly static methods of Skin actually static X-Git-Tag: 1.31.0-rc.0~55749 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=3328372650d06234fb666f5f071d81e804711881;p=lhc%2Fweb%2Fwiklou.git (bug 7357) Make supposedly static methods of Skin actually static --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b14a0dd38e..885c06c24e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -224,6 +224,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 6518) Replaced 'lastmodified' with 'lastmodifiedat' and 'lastmodifiedby' with 'lastmodifiedatby' with seperated parameters for date and time to allow better localisation. Updated all message files to display the old format for compatibility. +* (bug 7357) Make supposedly static methods of Skin actually static == Languages updated == diff --git a/includes/EditPage.php b/includes/EditPage.php index 5bf3e76321..16c36bf48e 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -942,7 +942,7 @@ class EditPage { $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) ); - $edithelpurl = $sk->makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); + $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); $edithelp = ''. htmlspecialchars( wfMsg( 'edithelp' ) ).' '. htmlspecialchars( wfMsg( 'newwindow' ) ); diff --git a/includes/Skin.php b/includes/Skin.php index 1c67864415..4c91987dc3 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -269,7 +269,7 @@ class Skin extends Linker { $out->out( "\n" ); } - /*static*/ function makeGlobalVariablesScript( $data ) { + static function makeGlobalVariablesScript( $data ) { $r = '\n"; if( $wgAllowUserJs && $wgUser->isLoggedIn() ) { $userpage = $wgUser->getUserPage(); - $userjs = htmlspecialchars( $this->makeUrl( + $userjs = htmlspecialchars( self::makeUrl( $userpage->getPrefixedText().'/'.$this->getSkinName().'.js', 'action=raw&ctype='.$wgJsMimeType)); $r .= '\n"; @@ -366,8 +366,8 @@ class Skin extends Linker { if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n"; $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; - $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" . - '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n"; + $s .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" . + '@import "' . self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n"; $s .= $this->doGetUserStyles(); return $s."\n"; @@ -403,7 +403,7 @@ class Skin extends Linker { $s .= $wgRequest->getText('wpTextbox1'); } else { $userpage = $wgUser->getUserPage(); - $s.= '@import "'.$this->makeUrl( + $s.= '@import "'.self::makeUrl( $userpage->getPrefixedText().'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n"; } @@ -1437,56 +1437,56 @@ END; } /* these are used extensively in SkinTemplate, but also some other places */ - /*static*/ function makeSpecialUrl( $name, $urlaction='' ) { + static function makeSpecialUrl( $name, $urlaction = '' ) { $title = Title::makeTitle( NS_SPECIAL, $name ); return $title->getLocalURL( $urlaction ); } - /*static*/ function makeI18nUrl ( $name, $urlaction='' ) { - $title = Title::newFromText( wfMsgForContent($name) ); - $this->checkTitle($title, $name); + static function makeI18nUrl( $name, $urlaction = '' ) { + $title = Title::newFromText( wfMsgForContent( $name ) ); + self::checkTitle( $title, $name ); return $title->getLocalURL( $urlaction ); } - /*static*/ function makeUrl ( $name, $urlaction='' ) { + static function makeUrl( $name, $urlaction = '' ) { $title = Title::newFromText( $name ); - $this->checkTitle($title, $name); + self::checkTitle( $title, $name ); return $title->getLocalURL( $urlaction ); } # If url string starts with http, consider as external URL, else # internal - /*static*/ function makeInternalOrExternalUrl( $name ) { + static function makeInternalOrExternalUrl( $name ) { if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) { return $name; } else { - return $this->makeUrl( $name ); + return self::makeUrl( $name ); } } # this can be passed the NS number as defined in Language.php - /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN ) { + static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) { $title = Title::makeTitleSafe( $namespace, $name ); - $this->checkTitle($title, $name); + self::checkTitle( $title, $name ); return $title->getLocalURL( $urlaction ); } /* these return an array with the 'href' and boolean 'exists' */ - /*static*/ function makeUrlDetails ( $name, $urlaction='' ) { + static function makeUrlDetails( $name, $urlaction = '' ) { $title = Title::newFromText( $name ); - $this->checkTitle($title, $name); + self::checkTitle( $title, $name ); return array( 'href' => $title->getLocalURL( $urlaction ), - 'exists' => $title->getArticleID() != 0?true:false + 'exists' => $title->getArticleID() != 0 ? true : false ); } /** * Make URL details where the article exists (or at least it's convenient to think so) */ - function makeKnownUrlDetails( $name, $urlaction='' ) { + static function makeKnownUrlDetails( $name, $urlaction = '' ) { $title = Title::newFromText( $name ); - $this->checkTitle($title, $name); + self::checkTitle( $title, $name ); return array( 'href' => $title->getLocalURL( $urlaction ), 'exists' => true @@ -1494,10 +1494,10 @@ END; } # make sure we have some title to operate on - /*static*/ function checkTitle ( &$title, &$name ) { - if(!is_object($title)) { + static function checkTitle( &$title, &$name ) { + if( !is_object( $title ) ) { $title = Title::newFromText( $name ); - if(!is_object($title)) { + if( !is_object( $title ) ) { $title = Title::newFromText( '--error: link target missing--' ); } } @@ -1547,7 +1547,7 @@ END; $text = $line[1]; if (wfEmptyMsg($line[0], $link)) $link = $line[0]; - $href = $this->makeInternalOrExternalUrl( $link ); + $href = self::makeInternalOrExternalUrl( $link ); $bar[$heading][] = array( 'text' => $text, 'href' => $href, diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 5a02b77642..ac83960801 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -174,11 +174,11 @@ class SkinTemplate extends Skin { $this->userpage = $userPage->getPrefixedText(); if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) { - $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage); + $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage ); } else { # This won't be used in the standard skins, but we define it to preserve the interface # To save time, we check for existence - $this->userpageUrlDetails = $this->makeKnownUrlDetails($this->userpage); + $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage ); } $this->usercss = $this->userjs = $this->userjsprev = false; @@ -275,9 +275,9 @@ class SkinTemplate extends Skin { global $wgUseSiteJs; if ($wgUseSiteJs) { if($this->loggedin) { - $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&smaxage=0&gen=js') ); + $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&smaxage=0&gen=js') ); } else { - $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&gen=js') ); + $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&gen=js') ); } } else { $tpl->set('jsvarurl', false); @@ -491,27 +491,27 @@ class SkinTemplate extends Skin { 'class' => $usertalkUrlDetails['exists']?false:'new', 'active' => ( $usertalkUrlDetails['href'] == $pageurl ) ); - $href = $this->makeSpecialUrl('Preferences'); + $href = self::makeSpecialUrl( 'Preferences' ); $personal_urls['preferences'] = array( - 'text' => wfMsg('mypreferences'), - 'href' => $this->makeSpecialUrl('Preferences'), + 'text' => wfMsg( 'mypreferences' ), + 'href' => self::makeSpecialUrl( 'Preferences' ), 'active' => ( $href == $pageurl ) ); - $href = $this->makeSpecialUrl('Watchlist'); + $href = self::makeSpecialUrl( 'Watchlist' ); $personal_urls['watchlist'] = array( - 'text' => wfMsg('watchlist'), + 'text' => wfMsg( 'watchlist' ), 'href' => $href, 'active' => ( $href == $pageurl ) ); - $href = $this->makeSpecialUrl("Contributions/$this->username"); + $href = self::makeSpecialUrl( "Contributions/$this->username" ); $personal_urls['mycontris'] = array( - 'text' => wfMsg('mycontris'), + 'text' => wfMsg( 'mycontris' ), 'href' => $href # FIXME # 'active' => ( $href == $pageurl . '/' . $this->username ) ); $personal_urls['logout'] = array( - 'text' => wfMsg('userlogout'), - 'href' => $this->makeSpecialUrl( 'Userlogout', + 'text' => wfMsg( 'userlogout' ), + 'href' => self::makeSpecialUrl( 'Userlogout', $wgTitle->getNamespace() === NS_SPECIAL && $wgTitle->getText() === 'Preferences' ? '' : "returnto={$this->thisurl}" ) ); @@ -534,14 +534,14 @@ class SkinTemplate extends Skin { ); $personal_urls['anonlogin'] = array( 'text' => wfMsg('userlogin'), - 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl ), + 'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ), 'active' => ( NS_SPECIAL == $wgTitle->getNamespace() && 'Userlogin' == $wgTitle->getDBkey() ) ); } else { $personal_urls['login'] = array( 'text' => wfMsg('userlogin'), - 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl ), + 'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ), 'active' => ( NS_SPECIAL == $wgTitle->getNamespace() && 'Userlogin' == $wgTitle->getDBkey() ) ); } @@ -585,7 +585,7 @@ class SkinTemplate extends Skin { function makeTalkUrlDetails( $name, $urlaction='' ) { $title = Title::newFromText( $name ); $title = $title->getTalkPage(); - $this->checkTitle($title, $name); + $this->checkTitle( $title, $name ); return array( 'href' => $title->getLocalURL( $urlaction ), 'exists' => $title->getArticleID() != 0?true:false @@ -595,7 +595,7 @@ class SkinTemplate extends Skin { function makeArticleUrlDetails( $name, $urlaction='' ) { $title = Title::newFromText( $name ); $title= $title->getSubjectPage(); - $this->checkTitle($title, $name); + self::checkTitle( $title, $name ); return array( 'href' => $title->getLocalURL( $urlaction ), 'exists' => $title->getArticleID() != 0?true:false @@ -713,7 +713,7 @@ class SkinTemplate extends Skin { 'class' => false, 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $n ), 'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) ) - #'href' => $this->makeSpecialUrl("Undelete/$this->thispage") + #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" ) ); } } @@ -799,20 +799,20 @@ class SkinTemplate extends Skin { $diff = $wgRequest->getVal( 'diff' ); $nav_urls = array(); - $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage')); + $nav_urls['mainpage'] = array( 'href' => self::makeI18nUrl( 'mainpage') ); if( $wgEnableUploads ) { if ($wgUploadNavigationUrl) { - $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl ); + $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl ); } else { - $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload')); + $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) ); } } else { if ($wgUploadNavigationUrl) - $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl ); + $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl ); else $nav_urls['upload'] = false; } - $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages')); + $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) ); // A print stylesheet is attached to all pages, but nobody ever @@ -869,11 +869,11 @@ class SkinTemplate extends Skin { if($id || $ip) { # both anons and non-anons have contri list $nav_urls['contributions'] = array( - 'href' => $this->makeSpecialUrl('Contributions/' . $this->mTitle->getText() ) + 'href' => self::makeSpecialUrl( 'Contributions/' . $this->mTitle->getText() ) ); if ( $wgUser->isAllowed( 'block' ) ) $nav_urls['blockip'] = array( - 'href' => $this->makeSpecialUrl( 'Blockip/' . $this->mTitle->getText() ) + 'href' => self::makeSpecialUrl( 'Blockip/' . $this->mTitle->getText() ) ); } else { $nav_urls['contributions'] = false; @@ -881,7 +881,7 @@ class SkinTemplate extends Skin { $nav_urls['emailuser'] = false; if( $this->showEmailUser( $id ) ) { $nav_urls['emailuser'] = array( - 'href' => $this->makeSpecialUrl('Emailuser/' . $this->mTitle->getText() ) + 'href' => self::makeSpecialUrl( 'Emailuser/' . $this->mTitle->getText() ) ); } wfProfileOut( $fname ); @@ -921,7 +921,7 @@ class SkinTemplate extends Skin { $usercss = $wgRequest->getText('wpTextbox1'); } else { $usercss = '@import "' . - $this->makeUrl($this->userpage . '/'.$this->skinname.'.css', + self::makeUrl($this->userpage . '/'.$this->skinname.'.css', 'action=raw&ctype=text/css') . '";' ."\n"; } @@ -933,9 +933,9 @@ class SkinTemplate extends Skin { # If we use the site's dynamic CSS, throw that in, too if ( $wgUseSiteCss ) { $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; - $sitecss .= '@import "' . $this->makeNSUrl('Common.css', $query, NS_MEDIAWIKI) . '";' . "\n"; - $sitecss .= '@import "' . $this->makeNSUrl(ucfirst($this->skinname) . '.css', $query, NS_MEDIAWIKI) . '";' . "\n"; - $sitecss .= '@import "' . $this->makeUrl('-','action=raw&gen=css' . $siteargs) . '";' . "\n"; + $sitecss .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) . '";' . "\n"; + $sitecss .= '@import "' . self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ) . '";' . "\n"; + $sitecss .= '@import "' . self::makeUrl( '-', 'action=raw&gen=css' . $siteargs ) . '";' . "\n"; } # If we use any dynamic CSS, make a little CDATA block out of it. @@ -961,7 +961,7 @@ class SkinTemplate extends Skin { # XXX: additional security check/prompt? $this->userjsprev = '/*getText('wpTextbox1') . ' /*]]>*/'; } else { - $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s'); + $this->userjs = self::makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s'); } } wfProfileOut( $fname ); diff --git a/skins/disabled/HTMLDump.php b/skins/disabled/HTMLDump.php index 33627843e2..5f739a379d 100644 --- a/skins/disabled/HTMLDump.php +++ b/skins/disabled/HTMLDump.php @@ -28,7 +28,7 @@ class SkinHTMLDump extends SkinTemplate { $badMessages = array( 'recentchanges-url', 'randompage-url' ); $badUrls = array(); foreach ( $badMessages as $msg ) { - $badUrls[] = $this->makeInternalOrExternalUrl( wfMsgForContent( $msg ) ); + $badUrls[] = self::makeInternalOrExternalUrl( wfMsgForContent( $msg ) ); } foreach ( $sections as $heading => $section ) { diff --git a/skins/disabled/MonoBookCBT.php b/skins/disabled/MonoBookCBT.php index 0474ad7cf0..f5f742d601 100644 --- a/skins/disabled/MonoBookCBT.php +++ b/skins/disabled/MonoBookCBT.php @@ -238,9 +238,9 @@ class SkinMonoBookCBT extends SkinTemplate { if ( !$wgUseSiteJs ) return ''; if ( $wgUser->isLoggedIn() ) { - $url = $this->makeUrl('-','action=raw&smaxage=0&gen=js'); + $url = self::makeUrl( '-','action=raw&smaxage=0&gen=js' ); } else { - $url = $this->makeUrl('-','action=raw&gen=js'); + $url = self::makeUrl( '-','action=raw&gen=js' ); } return cbt_value( $url, 'loggedin' ); } @@ -260,7 +260,7 @@ class SkinMonoBookCBT extends SkinTemplate { global $wgRequest; $usercss = $this->makeStylesheetCdata( $wgRequest->getText('wpTextbox1') ); } else { - $usercss = $this->makeStylesheetLink( $this->makeUrl($this->getUserPageText() . + $usercss = $this->makeStylesheetLink( self::makeUrl($this->getUserPageText() . '/'.$this->mStyleName.'.css', 'action=raw&ctype=text/css' ) ); } @@ -283,9 +283,8 @@ class SkinMonoBookCBT extends SkinTemplate { $sitecss .= $this->makeStylesheetLink( $wgStylePath . '/' . $this->mStyleName . '/rtl.css' ) . "\n"; } - $sitecss .= $this->makeStylesheetLink( $this->makeNSUrl('Common.css', $query, NS_MEDIAWIKI) ) . "\n"; - $sitecss .= $this->makeStylesheetLink( $this->makeNSUrl( - ucfirst($this->mStyleName) . '.css', $query, NS_MEDIAWIKI) ) . "\n"; + $sitecss .= $this->makeStylesheetLink( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) ) . "\n"; + $sitecss .= $this->makeStylesheetLink( self::makeNSUrl( ucfirst( $this->mStyleName ) . '.css', $query, NS_MEDIAWIKI ) ) . "\n"; // No deps return $sitecss; @@ -308,7 +307,7 @@ class SkinMonoBookCBT extends SkinTemplate { $isTemplate = false; } - $link = $this->makeStylesheetLink( $this->makeUrl('-','action=raw&gen=css' . $siteargs) ) . "\n"; + $link = $this->makeStylesheetLink( self::makeUrl('-','action=raw&gen=css' . $siteargs) ) . "\n"; if ( $wgAllowUserCss ) { $deps = 'loggedin'; @@ -330,7 +329,7 @@ class SkinMonoBookCBT extends SkinTemplate { if ( $this->isJsPreview() ) { $url = ''; } else { - $url = $this->makeUrl($this->getUserPageText().'/'.$this->mStyleName.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s'); + $url = self::makeUrl($this->getUserPageText().'/'.$this->mStyleName.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s'); } return cbt_value( $url, array( 'nonview dynamic', 'user' ) ); } @@ -765,7 +764,7 @@ class SkinMonoBookCBT extends SkinTemplate { } function logopath() { return $GLOBALS['wgLogo']; } - function mainpage() { return $this->makeI18nUrl( 'mainpage' ); } + function mainpage() { return self::makeI18nUrl( 'mainpage' ); } function sidebar( $startSection, $endSection, $innerTpl ) { $s = ''; @@ -800,7 +799,7 @@ class SkinMonoBookCBT extends SkinTemplate { $text = $line[1]; if (wfEmptyMsg($line[0], $link)) $link = $line[0]; - $href = $this->makeInternalOrExternalUrl( $link ); + $href = self::makeInternalOrExternalUrl( $link ); $s .= strtr( $innerTpl, array( @@ -911,12 +910,12 @@ class SkinMonoBookCBT extends SkinTemplate { } elseif ( $wgUploadNavigationUrl ) { return $wgUploadNavigationUrl; } else { - return $this->makeSpecialUrl('Upload'); + return self::makeSpecialUrl('Upload'); } } function nav_specialpages() { - return $this->makeSpecialUrl('Specialpages'); + return self::makeSpecialUrl('Specialpages'); } function nav_print() { @@ -1301,7 +1300,7 @@ class SkinMonoBookCBT extends SkinTemplate { /** Make a link to a special page using a template */ function makeSpecialTemplateLink( $template, $key, $specialName, $text, $query = '' ) { - $url = $this->makeSpecialUrl( $specialName, $query ); + $url = self::makeSpecialUrl( $specialName, $query ); // Ignore the query when comparing $active = ($this->mTitle->getNamespace() == NS_SPECIAL && $this->mTitle->getDBkey() == $specialName); return strtr( $template,