MediaWiki  1.23.15
FormlessAction.php
Go to the documentation of this file.
1 <?php
29 abstract class FormlessAction extends Action {
30 
36  abstract public function onView();
37 
42  protected function getFormFields() {
43  return false;
44  }
45 
50  public function onSubmit( $data ) {
51  return false;
52  }
53 
57  public function onSuccess() {
58  return false;
59  }
60 
61  public function show() {
62  $this->setHeaders();
63 
64  // This will throw exceptions if there's a problem
65  $this->checkCanExecute( $this->getUser() );
66 
67  $this->getOutput()->addHTML( $this->onView() );
68  }
69 
78  public function execute( array $data = null, $captureErrors = true ) {
79  try {
80  // Set a new context so output doesn't leak.
81  $this->context = clone $this->getContext();
82  if ( is_array( $data ) ) {
83  $this->context->setRequest( new FauxRequest( $data, false ) );
84  }
85 
86  // This will throw exceptions if there's a problem
87  $this->checkCanExecute( $this->getUser() );
88 
89  $this->onView();
90  return true;
91  }
92  catch ( ErrorPageError $e ) {
93  if ( $captureErrors ) {
94  return false;
95  } else {
96  throw $e;
97  }
98  }
99  }
100 }
FormlessAction\onView
onView()
Show something on GET request.
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: WebRequest.php:1275
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Action\setHeaders
setHeaders()
Set output headers for noindexing etc.
Definition: Action.php:338
FormlessAction
An action which just does something, without showing a form first.
Definition: FormlessAction.php:29
FormlessAction\show
show()
The main action entry point.
Definition: FormlessAction.php:61
Action
Actions are things which can be done to pages (edit, delete, rollback, etc).
Definition: Action.php:37
Action\getContext
getContext()
Get the IContextSource in use here.
Definition: Action.php:164
Action\checkCanExecute
checkCanExecute(User $user)
Checks if the given user (identified by an object) can perform this action.
Definition: Action.php:295
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Action\getUser
getUser()
Shortcut to get the User being used for this instance.
Definition: Action.php:200
FormlessAction\onSuccess
onSuccess()
Definition: FormlessAction.php:57
FormlessAction\execute
execute(array $data=null, $captureErrors=true)
Execute the action silently, not giving any output.
Definition: FormlessAction.php:78
FormlessAction\onSubmit
onSubmit( $data)
Definition: FormlessAction.php:50
FormlessAction\getFormFields
getFormFields()
We don't want an HTMLForm.
Definition: FormlessAction.php:42
Action\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: Action.php:191
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632