MediaWiki  REL1_23
FormlessAction.php
Go to the documentation of this file.
00001 <?php
00029 abstract class FormlessAction extends Action {
00030 
00036     abstract public function onView();
00037 
00042     protected function getFormFields() {
00043         return false;
00044     }
00045 
00050     public function onSubmit( $data ) {
00051         return false;
00052     }
00053 
00057     public function onSuccess() {
00058         return false;
00059     }
00060 
00061     public function show() {
00062         $this->setHeaders();
00063 
00064         // This will throw exceptions if there's a problem
00065         $this->checkCanExecute( $this->getUser() );
00066 
00067         $this->getOutput()->addHTML( $this->onView() );
00068     }
00069 
00078     public function execute( array $data = null, $captureErrors = true ) {
00079         try {
00080             // Set a new context so output doesn't leak.
00081             $this->context = clone $this->getContext();
00082             if ( is_array( $data ) ) {
00083                 $this->context->setRequest( new FauxRequest( $data, false ) );
00084             }
00085 
00086             // This will throw exceptions if there's a problem
00087             $this->checkCanExecute( $this->getUser() );
00088 
00089             $this->onView();
00090             return true;
00091         }
00092         catch ( ErrorPageError $e ) {
00093             if ( $captureErrors ) {
00094                 return false;
00095             } else {
00096                 throw $e;
00097             }
00098         }
00099     }
00100 }