* Get an HTMLForm descriptor array
* @return array
*/
- abstract protected function getFormFields();
+ protected function getFormFields() {
+ // Default to an empty form with just a submit button
+ return array();
+ }
/**
* Add pre- or post-text to the form
$this->getRequest()->getQueryValues(),
array( 'action' => null, 'title' => null )
);
- $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params ) );
+ if ( $params ) {
+ $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params ) );
+ }
$form->addPreText( $this->preText() );
$form->addPostText( $this->postText() );
}
/**
- * Process the form on POST submission. If you return false from getFormFields(),
- * this will obviously never be reached. If you don't want to do anything with the
- * form, just return false here
+ * Process the form on POST submission.
+ *
+ * If you don't want to do anything with the form, just return false here.
+ *
* @param array $data
* @return bool|array True for success, false for didn't-try, array of errors on failure
*/
return '';
}
- /**
- * Just get an empty form with a single submit button
- * @return array
- */
- protected function getFormFields() {
- return array();
- }
-
public function onSubmit( $data ) {
return $this->page->doPurge();
}
return $this->msg( 'addwatch' )->escaped();
}
- /**
- * Just get an empty form with a single submit button
- * @return array
- */
- protected function getFormFields() {
- return array();
- }
-
public function onSubmit( $data ) {
self::doWatch( $this->getTitle(), $this->getUser() );
return true;
}
- /**
- * This can be either formed or formless depending on the session token given
- */
- public function show() {
- $this->setHeaders();
-
- $user = $this->getUser();
- // This will throw exceptions if there's a problem
- $this->checkCanExecute( $user );
-
- $form = $this->getForm();
- if ( $form->show() ) {
- $this->onSuccess();
- }
- }
-
protected function checkCanExecute( User $user ) {
// Must be logged in
if ( $user->isAnon() ) {