<?php
+/**
+ * @defgroup Actions Action done on pages
+ */
+
/**
* Actions are things which can be done to pages (edit, delete, rollback, etc). They
* are distinct from Special Pages because an action must apply to exactly one page.
* @param $action String
* @param $page Page
* @param $context IContextSource
- * @return Action|false|null false if the action is disabled, null
+ * @return Action|bool|null false if the action is disabled, null
* if it is not recognised
*/
public final static function factory( $action, Page $page, IContextSource $context = null ) {
return $class;
}
+ /**
+ * Get the action that will be executed, not necessarily the one passed
+ * passed through the "action" request parameter. Actions disabled in
+ * $wgActions will be replaced by "nosuchaction".
+ *
+ * @since 1.19
+ * @param $context IContextSource
+ * @return string: action name
+ */
+ public final static function getActionName( IContextSource $context ) {
+ global $wgActions;
+
+ $request = $context->getRequest();
+ $actionName = $request->getVal( 'action', 'view' );
+
+ // Check for disabled actions
+ if ( isset( $wgActions[$actionName] ) && $wgActions[$actionName] === false ) {
+ $actionName = 'nosuchaction';
+ }
+
+ // Workaround for bug #20966: inability of IE to provide an action dependent
+ // on which submit button is clicked.
+ if ( $actionName === 'historysubmit' ) {
+ if ( $request->getBool( 'revisiondelete' ) ) {
+ $actionName = 'revisiondelete';
+ } else {
+ $actionName = 'view';
+ }
+ } elseif ( $actionName == 'editredlink' ) {
+ $actionName = 'edit';
+ }
+
+ // Trying to get a WikiPage for NS_SPECIAL etc. will result
+ // in WikiPage::factory throwing "Invalid or virtual namespace -1 given."
+ // For SpecialPages et al, default to action=view.
+ if ( !$context->canUseWikiPage() ) {
+ return 'view';
+ }
+
+ $action = Action::factory( $actionName, $context->getWikiPage() );
+ if ( $action instanceof Action ) {
+ return $action->getName();
+ }
+
+ return 'nosuchaction';
+ }
+
/**
* Check if a given action is recognised, even if it's disabled
*
}
if ( $this->requiresUnblock() && $user->isBlocked() ) {
- $block = $user->mBlock;
+ $block = $user->getBlock();
throw new UserBlockedError( $block );
}
* @return String
*/
protected function getDescription() {
- return wfMsg( strtolower( $this->getName() ) );
+ return wfMsgHtml( strtolower( $this->getName() ) );
}
/**
/**
* We don't want an HTMLForm
+ * @return bool
*/
protected function getFormFields() {
return false;