return $class;
}
- /**
- * Get the action that will be executed, not necessarily the one passed
- * passed through the "action" request parameter. Actions disabled in
- * $wgDisabledActions will be replaced by "nosuchaction".
- *
- * @param $context IContextSource
- * @return string: action name
- */
- public final static function getActionName( IContextSource $context ) {
- global $wgDisabledActions;
-
- $request = $context->getRequest();
- $actionName = $request->getVal( 'action', 'view' );
-
- // Check for disabled actions
- if ( in_array( $actionName, $wgDisabledActions ) ) {
- $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';
- }
-
- $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
*
* @return String: The doctype, opening <html>, and head element.
*/
public function headElement( Skin $sk, $includeStyle = true ) {
- global $wgContLang;
+ global $wgContLang, $mediaWiki;
$userdir = $this->getLanguage()->getDir();
$sitedir = $wgContLang->getDir();
}
$bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() );
$bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() );
- $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) );
+ $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( $mediaWiki->getPerformedAction() );
$sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need
wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
* @return array
*/
public function getJSVars() {
- global $wgUseAjax, $wgEnableMWSuggest;
+ global $wgUseAjax, $wgEnableMWSuggest, $mediaWiki;
$title = $this->getTitle();
$ns = $title->getNamespace();
'wgCurRevisionId' => $title->getLatestRevID(),
'wgArticleId' => $title->getArticleId(),
'wgIsArticle' => $this->isArticle(),
- 'wgAction' => Action::getActionName( $this->getContext() ),
+ 'wgAction' => $mediaWiki->getPerformedAction(),
'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
'wgCategories' => $this->getCategories(),
*/
private $context;
+ /**
+ * @var string
+ */
+ private $performedAction = 'nosuchaction';
+
/**
* @param $x null|WebRequest
* @return WebRequest
$request = $this->context->getRequest();
$curid = $request->getInt( 'curid' );
$title = $request->getVal( 'title' );
- $action = $request->getVal( 'action', 'view' );
if ( $request->getCheck( 'search' ) ) {
// Compatibility with old search URLs which didn't use Special:Search
} elseif ( $curid ) {
// URLs like this are generated by RC, because rc_title isn't always accurate
$ret = Title::newFromID( $curid );
- } elseif ( $title == '' && $action != 'delete' ) {
+ } elseif ( $title == '' && $this->getAction() != 'delete' ) {
$ret = Title::newMainPage();
} else {
$ret = Title::newFromURL( $title );
}
/**
- * Returns the name of the action that will be executed.
+ * Returns the action that will be executed, not necessarily the one passed
+ * passed through the "action" parameter. Actions disabled in
+ * $wgDisabledActions will be replaced by "nosuchaction".
+ *
+ * The return value is merely a suggestion, not the actually performed action,
+ * which may be different. The actually performed action is determined by performAction().
+ * Requests like action=nonsense will make this function return "nonsense".
+ * Use getPerformedAction() to get the performed action.
*
* @return string: action
*/
public function getAction() {
- static $action = null;
-
- if ( $action === null ) {
- $action = Action::getActionName( $this->context );
+ global $wgDisabledActions;
+
+ $request = $this->context->getRequest();
+ $action = $request->getVal( 'action', 'view' );
+
+ // Check for disabled actions
+ if ( in_array( $action, $wgDisabledActions ) ) {
+ return 'nosuchaction';
+ }
+
+ // Workaround for bug #20966: inability of IE to provide an action dependent
+ // on which submit button is clicked.
+ if ( $action === 'historysubmit' ) {
+ if ( $request->getBool( 'revisiondelete' ) ) {
+ return 'revisiondelete';
+ } else {
+ return 'view';
+ }
+ } elseif ( $action == 'editredlink' ) {
+ return 'edit';
}
return $action;
$action = Action::factory( $act, $article );
if ( $action instanceof Action ) {
+ $this->performedAction = $act;
$action->show();
wfProfileOut( __METHOD__ );
return;
}
if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) {
+ $this->performedAction = 'nosuchaction';
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
}
wfProfileOut( __METHOD__ );
}
+ /**
+ * Returns the real action as determined by performAction.
+ * Do not use internally in this class as it depends on the actions by this class.
+ *
+ * @since 1.19
+ *
+ * @return string: action
+ */
+ public function getPerformedAction() {
+ return $this->performedAction;
+ }
+
/**
* Run the current MediaWiki instance
* index.php just calls this