diff options
author | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2011-07-01 20:07:21 +0000 |
---|---|---|
committer | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2011-07-01 20:07:21 +0000 |
commit | cf6dd13faca23af5b6e3188445b84e05d620d499 (patch) | |
tree | 33106539d3bdde0f190b856ce88aa81d59843bf1 /includes/Action.php | |
parent | a4e2af723f0b2e42f4081d6b9ebcc19222ebb8d7 (diff) | |
download | mediawikicore-cf6dd13faca23af5b6e3188445b84e05d620d499.tar.gz mediawikicore-cf6dd13faca23af5b6e3188445b84e05d620d499.zip |
* Changed action=revert to use a subclass of Action
* Added WikiPage::getActionOverrides() to be able to execute different actions depending on the namespace (obviously needed for action=revert). This is only used when the value of $wgActions for the corresponding action is true; so extension can still override this.
* Added Action::getDescription() to ease the change of the page header and the <title> element
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/91284
Diffstat (limited to 'includes/Action.php')
-rw-r--r-- | includes/Action.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/includes/Action.php b/includes/Action.php index dcdd4b328f48..ff0ce697d000 100644 --- a/includes/Action.php +++ b/includes/Action.php @@ -47,9 +47,10 @@ abstract class Action { * Get the Action subclass which should be used to handle this action, false if * the action is disabled, or null if it's not recognised * @param $action String + * @param $overrides Array * @return bool|null|string */ - private final static function getClass( $action ) { + private final static function getClass( $action, array $overrides ) { global $wgActions; $action = strtolower( $action ); @@ -59,6 +60,8 @@ abstract class Action { if ( $wgActions[$action] === false ) { return false; + } elseif ( $wgActions[$action] === true && isset( $overrides[$action] ) ) { + return $overrides[$action]; } elseif ( $wgActions[$action] === true ) { return ucfirst( $action ) . 'Action'; } else { @@ -74,7 +77,7 @@ abstract class Action { * if it is not recognised */ public final static function factory( $action, Page $page ) { - $class = self::getClass( $action ); + $class = self::getClass( $action, $page->getActionOverrides() ); if ( $class ) { $obj = new $class( $page ); return $obj; @@ -223,7 +226,7 @@ abstract class Action { protected function setHeaders() { $out = $this->getOutput(); $out->setRobotPolicy( "noindex,nofollow" ); - $out->setPageTitle( $this->getTitle()->getPrefixedText() ); + $out->setPageTitle( $this->getPageTitle() ); $this->getOutput()->setSubtitle( $this->getDescription() ); $out->setArticleRelated( true ); } @@ -233,6 +236,15 @@ abstract class Action { * * @return String */ + protected function getPageTitle() { + return $this->getTitle()->getPrefixedText(); + } + + /** + * Returns the description that goes below the \<h1\> tag + * + * @return String + */ protected function getDescription() { return wfMsg( strtolower( $this->getName() ) ); } |