123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- defined('GNUSOCIAL') || die();
- class FormAction extends ManagedAction
- {
- protected $form = null;
- protected $formOpts = array();
- protected $type = null;
- protected $needLogin = true;
- protected $canPost = true;
- protected function prepare(array $args = [])
- {
- parent::prepare($args);
- $this->form = $this->form ?: ucfirst($this->action);
- $this->args['form'] = $this->form;
- $this->type = !is_null($this->type) ? $this->type : $this->trimmed('type');
- $this->args['context'] = $this->trimmed('action');
- if (!$this->type) {
- $this->type = null;
- }
- return true;
- }
- public function isReadOnly($args)
- {
- return !$this->isPost();
- }
- public function showPageNotice()
- {
- $this->showInstructions();
- if (!empty($msg = $this->getError())) {
- $this->element('div', 'error', $msg);
- }
- if (!empty($msg = $this->getInfo())) {
- $this->element('div', 'info', $msg);
- }
- }
-
- public function showInstructions()
- {
-
- $this->raw(common_markup_to_html($this->getInstructions()));
- }
-
- protected function getInstructions()
- {
- return null;
- }
- public function showForm($msg=null, $success=false)
- {
- $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;
- }
- }
|