* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Form action extendable class
* @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 $formOpts = array();
protected $type = null;
protected $needLogin = true;
+ protected $canPost = true;
protected function prepare(array $args=array()) {
parent::prepare($args);
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();
}
public function showForm($msg=null, $success=false)
{
- if ($success) {
- $this->msg = $msg;
- } else {
- $this->error = $msg;
- }
+ $this->msg = $msg;
+ $this->success = $success;
$this->showPage();
}
+ protected function showContent()
+ {
+ $form = $this->getForm();
+ $form->show();
+ }
+
+ protected function getForm()
+ {
+ $class = $this->form.'Form';
+ $form = new $class($this, $this->formOpts);
+ return $form;
+ }
+
/**
* Gets called from handle() if isPost() is true;
* @return void
throw new ClientException($msg);
}
- $this->checkSessionToken();
+ return parent::handlePost();
}
}