]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Form- and ManagedAction improvements
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 6 Jul 2014 10:55:18 +0000 (12:55 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 6 Jul 2014 10:55:18 +0000 (12:55 +0200)
lib/action.php
lib/formaction.php
lib/managedaction.php

index 65ef84cdf1601b2a221d43c3d87a40e1b7f7028e..b26db428d41568ecf7d60788380eabafcf6b2f25 100644 (file)
@@ -238,7 +238,11 @@ class Action extends HTMLOutputter // lawsuit
         $this->element('title', null, _m('TITLE','Notice'));
         $this->elementEnd('head');
         $this->elementStart('body');
-        $this->showContent();
+        if ($this->getError()) {
+            $this->element('p', array('id'=>'error'), $msg);
+        } else {
+            $this->showContent();
+        }
         $this->elementEnd('body');
         $this->endHTML();
     }
index 1740bd1b49c8dda080650f0ab1ed0bde013dd067..73576bf46a464604cafb8af2e847f82eb514dedc 100644 (file)
@@ -44,6 +44,7 @@ if (!defined('STATUSNET')) {
 class FormAction extends ManagedAction
 {
     protected $form = null;
+    protected $formOpts = array();
     protected $type = null;
     protected $needLogin = true;
     protected $canPost = true;
@@ -114,7 +115,7 @@ class FormAction extends ManagedAction
     protected function getForm()
     {
         $class = $this->form.'Form';
-        $form = new $class($this);
+        $form = new $class($this, $this->formOpts);
         return $form;
     }
 
index 3df73731aeecaf0b52813b25afcd68f9a2095142..278131b7a6461db41501a8ad417ccfa09fc52874 100644 (file)
@@ -32,6 +32,20 @@ if (!defined('GNUSOCIAL')) { exit(1); }
 
 class ManagedAction extends Action
 {
+    protected function prepare(array $args=array())
+    {
+        if (!parent::prepare($args)) {
+            return false;
+        }
+        $this->doPreparation();
+        return true;
+    }
+
+    protected function doPreparation()
+    {
+        // pass by default
+    }
+
     /**
      * Handler method
      */
@@ -53,5 +67,6 @@ class ManagedAction extends Action
     protected function handlePost()
     {
         // This will only be run if the Action has the property canPost==true
+        assert($this->canPost);
     }
 }