From 9a92b8ba33e445174aae46acac58c91c78df5f9b Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 6 Jul 2014 12:55:18 +0200 Subject: [PATCH] Form- and ManagedAction improvements --- lib/action.php | 6 +++++- lib/formaction.php | 3 ++- lib/managedaction.php | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/action.php b/lib/action.php index 65ef84cdf1..b26db428d4 100644 --- a/lib/action.php +++ b/lib/action.php @@ -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(); } diff --git a/lib/formaction.php b/lib/formaction.php index 1740bd1b49..73576bf46a 100644 --- a/lib/formaction.php +++ b/lib/formaction.php @@ -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; } diff --git a/lib/managedaction.php b/lib/managedaction.php index 3df73731ae..278131b7a6 100644 --- a/lib/managedaction.php +++ b/lib/managedaction.php @@ -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); } }