X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=includes%2FSpecialPage.php;h=eb643411d2ea406ff045125e5130c733d8601428;hb=103be1dda1e572d6af600228eff01b1a929ca7a6;hp=4da06a895e7e053a8d50556fa0a337f49ec5ba5e;hpb=a6d47f47ffb57840625997063ce01a93d204cdc2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 4da06a895e..eb643411d2 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -16,11 +16,6 @@ */ -/** - * - */ -global $wgSpecialPages, $wgUser; - /** * @access private */ @@ -33,25 +28,33 @@ $wgSpecialPages = array( 'Userlogout' => new UnlistedSpecialPage( 'Userlogout' ), 'Preferences' => new SpecialPage( 'Preferences' ), 'Watchlist' => new SpecialPage( 'Watchlist' ), - + 'Recentchanges' => new IncludableSpecialPage( 'Recentchanges' ), 'Upload' => new SpecialPage( 'Upload' ), 'Imagelist' => new SpecialPage( 'Imagelist' ), - 'Newimages' => new SpecialPage( 'Newimages' ), + 'Newimages' => new IncludableSpecialPage( 'Newimages' ), 'Listusers' => new SpecialPage( 'Listusers' ), 'Statistics' => new SpecialPage( 'Statistics' ), 'Random' => new SpecialPage( 'Randompage' ), 'Lonelypages' => new SpecialPage( 'Lonelypages' ), 'Uncategorizedpages'=> new SpecialPage( 'Uncategorizedpages' ), 'Uncategorizedcategories'=> new SpecialPage( 'Uncategorizedcategories' ), + 'Unusedcategories' => new SpecialPage( 'Unusedcategories' ), 'Unusedimages' => new SpecialPage( 'Unusedimages' ), - 'Wantedpages' => new SpecialPage( 'Wantedpages' ), + 'Wantedpages' => new IncludableSpecialPage( 'Wantedpages' ), + 'Wantedcategories' => new SpecialPage( 'Wantedcategories' ), + 'Mostlinked' => new SpecialPage( 'Mostlinked' ), + 'Mostlinkedcategories' => new SpecialPage( 'Mostlinkedcategories' ), + 'Mostcategories' => new SpecialPage( 'Mostcategories' ), + 'Mostimages' => new SpecialPage( 'Mostimages' ), + 'Mostrevisions' => new SpecialPage( 'Mostrevisions' ), 'Shortpages' => new SpecialPage( 'Shortpages' ), 'Longpages' => new SpecialPage( 'Longpages' ), 'Newpages' => new IncludableSpecialPage( 'Newpages' ), 'Ancientpages' => new SpecialPage( 'Ancientpages' ), 'Deadendpages' => new SpecialPage( 'Deadendpages' ), 'Allpages' => new IncludableSpecialPage( 'Allpages' ), + 'Prefixindex' => new IncludableSpecialPage( 'Prefixindex' ) , 'Ipblocklist' => new SpecialPage( 'Ipblocklist' ), 'Specialpages' => new UnlistedSpecialPage( 'Specialpages' ), 'Contributions' => new UnlistedSpecialPage( 'Contributions' ), @@ -67,29 +70,25 @@ $wgSpecialPages = array( 'Allmessages' => new SpecialPage( 'Allmessages' ), 'Log' => new SpecialPage( 'Log' ), 'Blockip' => new SpecialPage( 'Blockip', 'block' ), - 'Undelete' => new SpecialPage( 'Undelete', 'delete' ), + 'Undelete' => new SpecialPage( 'Undelete', 'deletedhistory' ), "Import" => new SpecialPage( "Import", 'import' ), 'Lockdb' => new SpecialPage( 'Lockdb', 'siteadmin' ), 'Unlockdb' => new SpecialPage( 'Unlockdb', 'siteadmin' ), 'Userrights' => new SpecialPage( 'Userrights', 'userrights' ), - // 'Groups' => new SpecialPage( 'Groups' ), # currently borken + 'MIMEsearch' => new SpecialPage( 'MIMEsearch' ), + 'Unwatchedpages' => new SpecialPage( 'Unwatchedpages', 'unwatchedpages' ), + 'Listredirects' => new SpecialPage( 'Listredirects' ), + 'Revisiondelete' => new SpecialPage( 'Revisiondelete', 'deleterevision' ), ); -global $wgUseValidation ; -if ( $wgUseValidation ) - $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' ); - -global $wgDisableCounters; if( !$wgDisableCounters ) { $wgSpecialPages['Popularpages'] = new SpecialPage( 'Popularpages' ); } -global $wgDisableInternalSearch; if( !$wgDisableInternalSearch ) { - $wgSpecialPages['Search'] = new UnlistedSpecialPage( 'Search' ); + $wgSpecialPages['Search'] = new SpecialPage( 'Search' ); } -global $wgEmailAuthentication; if( $wgEmailAuthentication ) { $wgSpecialPages['Confirmemail'] = new UnlistedSpecialPage( 'Confirmemail' ); } @@ -134,11 +133,11 @@ class SpecialPage * Whether the special page can be included in an article */ var $mIncludable; - + /**#@-*/ - + /** * Add a page to the list of valid special pages * $obj->execute() must send HTML to $wgOut then return @@ -165,7 +164,7 @@ class SpecialPage * @static * @param string $name */ - function &getPage( $name ) { + function getPage( $name ) { global $wgSpecialPages; if ( array_key_exists( $name, $wgSpecialPages ) ) { return $wgSpecialPages[$name]; @@ -173,28 +172,25 @@ class SpecialPage return NULL; } } - + /** * @static * @param string $name * @return mixed Title object if the redirect exists, otherwise NULL */ - function &getRedirect( $name ) { + function getRedirect( $name ) { global $wgUser; - switch ( $name ) { - case 'Mypage': - return Title::makeTitle( NS_USER, $wgUser->getName() ); - case 'Mytalk': - return Title::makeTitle( NS_USER_TALK, $wgUser->getName() ); - case 'Mycontributions': - return Title::makeTitle( NS_SPECIAL, 'Contributions/' . $wgUser->getName() ); - case 'Listadmins': - return Title::makeTitle( NS_SPECIAL, 'Listusers' ); - case 'Randompage': - return Title::makeTitle( NS_SPECIAL, 'Random' ); - default: - return NULL; - } + + $redirects = array( + 'Mypage' => Title::makeTitle( NS_USER, $wgUser->getName() ), + 'Mytalk' => Title::makeTitle( NS_USER_TALK, $wgUser->getName() ), + 'Mycontributions' => Title::makeTitle( NS_SPECIAL, 'Contributions/' . $wgUser->getName() ), + 'Listadmins' => Title::makeTitle( NS_SPECIAL, 'Listusers/sysop' ), # @bug 2832 + 'Randompage' => Title::makeTitle( NS_SPECIAL, 'Random' ) + ); + wfRunHooks( 'SpecialPageGetRedirect', array( &$redirects ) ); + + return isset( $redirects[$name] ) ? $redirects[$name] : null; } /** @@ -223,14 +219,16 @@ class SpecialPage * The path may contain parameters, e.g. Special:Name/Params * Extracts the special page name and call the execute method, passing the parameters * - * Returns a title object if the page is redirected, false if there was no such special + * Returns a title object if the page is redirected, false if there was no such special * page, and true if it was successful. * * @param $title a title object * @param $including output is being captured for use in {{special:whatever}} */ function executePath( &$title, $including = false ) { - global $wgSpecialPages, $wgOut, $wgTitle; + global $wgOut, $wgTitle; + $fname = 'SpecialPage::executePath'; + wfProfileIn( $fname ); $bits = split( "/", $title->getDBkey(), 2 ); $name = $bits[0]; @@ -240,27 +238,30 @@ class SpecialPage $par = $bits[1]; } - $page =& SpecialPage::getPage( $name ); + $page = SpecialPage::getPage( $name ); if ( is_null( $page ) ) { if ( $including ) { + wfProfileOut( $fname ); return false; } else { - $redir =& SpecialPage::getRedirect( $name ); + $redir = SpecialPage::getRedirect( $name ); if ( isset( $redir ) ) { - if ( isset( $par ) ) + if ( isset( $par ) ) $wgOut->redirect( $redir->getFullURL() . '/' . $par ); else $wgOut->redirect( $redir->getFullURL() ); $retVal = $redir; } else { $wgOut->setArticleRelated( false ); - $wgOut->setRobotpolicy( "noindex,follow" ); - $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); + $wgOut->setRobotpolicy( 'noindex,follow' ); + $wgOut->setStatusCode( 404 ); + $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' ); $retVal = false; } } } else { if ( $including && !$page->includable() ) { + wfProfileOut( $fname ); return false; } if($par !== NULL) { @@ -270,9 +271,13 @@ class SpecialPage } $page->including( $including ); + $profName = 'Special:' . $page->getName(); + wfProfileIn( $profName ); $page->execute( $par ); + wfProfileOut( $profName ); $retVal = true; } + wfProfileOut( $fname ); return $retVal; } @@ -288,7 +293,7 @@ class SpecialPage $oldTitle = $wgTitle; $oldOut = $wgOut; $wgOut = new OutputPage; - + $ret = SpecialPage::executePath( $title, true ); if ( $ret === true ) { $ret = $wgOut->getHTML(); @@ -331,13 +336,28 @@ class SpecialPage } } - # Accessor functions, see the descriptions of the associated variables above + /**#@+ + * Accessor + * + * @deprecated + */ function getName() { return $this->mName; } function getRestriction() { return $this->mRestriction; } - function isListed() { return $this->mListed; } function getFile() { return $this->mFile; } + function isListed() { return $this->mListed; } + /**#@-*/ + + /**#@+ + * Accessor and mutator + */ + function name( $x = NULL ) { return wfSetVar( $this->mName, $x ); } + function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions, $x ); } + function listed( $x = NULL) { return wfSetVar( $this->mListed, $x ); } + function func( $x = NULL) { return wfSetVar( $this->mFunction, $x ); } + function file( $x = NULL) { return wfSetVar( $this->mFile, $x ); } + function includable( $x = NULL ) { return wfSetVar( $this->mIncludable, $x ); } function including( $x = NULL ) { return wfSetVar( $this->mIncluding, $x ); } - function includable( $x = NULL ) { return wfSetVar( $this->mIncludable, $x ); } + /**#@-*/ /** * Checks if the given user (identified by an object) can execute this @@ -360,11 +380,7 @@ class SpecialPage */ function displayRestrictionError() { global $wgOut; - if ( $this->mRestriction == "developer" ) { - $wgOut->developerRequired(); - } else { - $wgOut->sysopRequired(); - } + $wgOut->permissionRequired( $this->mRestriction ); } /** @@ -382,21 +398,38 @@ class SpecialPage * Checks user permissions, calls the function given in mFunction */ function execute( $par ) { - global $wgUser, $wgOut, $wgTitle; + global $wgUser; $this->setHeaders(); if ( $this->userCanExecute( $wgUser ) ) { - if ( $this->mFile ) { + $func = $this->mFunction; + // only load file if the function does not exist + if(!function_exists($func) and $this->mFile) { require_once( $this->mFile ); } - $func = $this->mFunction; + if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) ) + $this->outputHeader(); + if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) ) + return; $func( $par, $this ); + if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) ) + return; } else { $this->displayRestrictionError(); } } + function outputHeader() { + global $wgOut, $wgContLang; + + $msg = $wgContLang->lc( $this->name() ) . '-summary'; + $out = wfMsg( $msg ); + if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) + $wgOut->addWikiText( $out ); + + } + # Returns the name that goes in the

in the special page itself, and also the name that # will be listed in Special:Specialpages # @@ -435,6 +468,7 @@ class UnlistedSpecialPage extends SpecialPage /** * Shortcut to construct an includable special page + * @package MediaWiki */ class IncludableSpecialPage extends SpecialPage {