1 | <?php |
||
31 | abstract class FormSpecialPage extends SpecialPage { |
||
32 | /** |
||
33 | * The sub-page of the special page. |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $par = null; |
||
37 | |||
38 | /** |
||
39 | * Get an HTMLForm descriptor array |
||
40 | * @return array |
||
41 | */ |
||
42 | abstract protected function getFormFields(); |
||
43 | |||
44 | /** |
||
45 | * Add pre-text to the form |
||
46 | * @return string HTML which will be sent to $form->addPreText() |
||
47 | */ |
||
48 | protected function preText() { |
||
51 | |||
52 | /** |
||
53 | * Add post-text to the form |
||
54 | * @return string HTML which will be sent to $form->addPostText() |
||
55 | */ |
||
56 | protected function postText() { |
||
59 | |||
60 | /** |
||
61 | * Play with the HTMLForm if you need to more substantially |
||
62 | * @param HTMLForm $form |
||
63 | */ |
||
64 | protected function alterForm( HTMLForm $form ) { |
||
66 | |||
67 | /** |
||
68 | * Get message prefix for HTMLForm |
||
69 | * |
||
70 | * @since 1.21 |
||
71 | * @return string |
||
72 | */ |
||
73 | protected function getMessagePrefix() { |
||
76 | |||
77 | /** |
||
78 | * Get display format for the form. See HTMLForm documentation for available values. |
||
79 | * |
||
80 | * @since 1.25 |
||
81 | * @return string |
||
82 | */ |
||
83 | protected function getDisplayFormat() { |
||
86 | |||
87 | /** |
||
88 | * Get the HTMLForm to control behavior |
||
89 | * @return HTMLForm|null |
||
90 | */ |
||
91 | protected function getForm() { |
||
125 | |||
126 | /** |
||
127 | * Process the form on POST submission. |
||
128 | * @param array $data |
||
129 | * @param HTMLForm $form |
||
|
|||
130 | * @return bool|string|array|Status As documented for HTMLForm::trySubmit. |
||
131 | */ |
||
132 | abstract public function onSubmit( array $data /* $form = null */ ); |
||
133 | |||
134 | /** |
||
135 | * Do something exciting on successful processing of the form, most likely to show a |
||
136 | * confirmation message |
||
137 | * @since 1.22 Default is to do nothing |
||
138 | */ |
||
139 | public function onSuccess() { |
||
141 | |||
142 | /** |
||
143 | * Basic SpecialPage workflow: get a form, send it to the user; get some data back, |
||
144 | * |
||
145 | * @param string $par Subpage string if one was specified |
||
146 | */ |
||
147 | public function execute( $par ) { |
||
159 | |||
160 | /** |
||
161 | * Maybe do something interesting with the subpage parameter |
||
162 | * @param string $par |
||
163 | */ |
||
164 | protected function setParameter( $par ) { |
||
167 | |||
168 | /** |
||
169 | * Called from execute() to check if the given user can perform this action. |
||
170 | * Failures here must throw subclasses of ErrorPageError. |
||
171 | * @param User $user |
||
172 | * @throws UserBlockedError |
||
173 | */ |
||
174 | protected function checkExecutePermissions( User $user ) { |
||
186 | |||
187 | /** |
||
188 | * Whether this action requires the wiki not to be locked |
||
189 | * @return bool |
||
190 | */ |
||
191 | public function requiresWrite() { |
||
194 | |||
195 | /** |
||
196 | * Whether this action cannot be executed by a blocked user |
||
197 | * @return bool |
||
198 | */ |
||
199 | public function requiresUnblock() { |
||
202 | } |
||
203 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.