]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/formaction.php
FormAction extends ManagedAction
[quix0rs-gnu-social.git] / lib / formaction.php
index fda66007d87ba829df7c894dca3efcd674ea88f3..60d9b3ce130a843ab458fbd3f995ae21d7704ac2 100644 (file)
@@ -41,10 +41,12 @@ if (!defined('STATUSNET')) {
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  * @link     http://status.net/
  */
-class FormAction extends Action
+class FormAction extends ManagedAction
 {
     protected $form = null;
     protected $type = null;
+    protected $needLogin = true;
+    protected $canPost = true;
 
     protected function prepare(array $args=array()) {
         parent::prepare($args);
@@ -62,22 +64,6 @@ class FormAction extends Action
         return true;
     }
 
-    protected function handle()
-    {
-        parent::handle();
-
-        if ($this->isPost()) {
-            try {
-                $msg = $this->handlePost();
-                $this->showForm($msg, true);
-            } catch (Exception $e) {
-                $this->showForm($e->getMessage());
-            }
-        } else {
-            $this->showForm();
-        }
-    }
-
     public function isReadOnly($args) {
         return !$this->isPost();
     }
@@ -101,16 +87,15 @@ class FormAction extends Action
     public function showInstructions()
     {
         // instructions are nice, so users know what to do
+        $this->raw(common_markup_to_html($this->getInstructions()));
     }
 
-    public function showForm($msg=null, $success=false)
+    /**
+     * @return string with instructions to pass into common_markup_to_html()
+     */
+    public function getInstructions()
     {
-        if ($success) {
-            $this->msg = $msg;
-        } else {
-            $this->error = $msg;
-        }
-        $this->showPage();
+        return null;
     }
 
     /**
@@ -119,6 +104,8 @@ class FormAction extends Action
      */
     protected function handlePost()
     {
+        parent::handlePost();
+
         // check for this before token since all POST and FILES data
         // is losts when size is exceeded
         if (empty($_POST) && $_SERVER['CONTENT_LENGTH']>0) {