Exemplo n.º 1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // create bogus form
     $frm = new BackendForm('meta');
     // get parameters
     $URL = \SpoonFilter::getPostValue('url', null, '', 'string');
     $metaId = \SpoonFilter::getPostValue('meta_id', null, null);
     $baseFieldName = \SpoonFilter::getPostValue('baseFieldName', null, '', 'string');
     $custom = \SpoonFilter::getPostValue('custom', null, false, 'bool');
     $className = \SpoonFilter::getPostValue('className', null, '', 'string');
     $methodName = \SpoonFilter::getPostValue('methodName', null, '', 'string');
     $parameters = \SpoonFilter::getPostValue('parameters', null, '', 'string');
     // cleanup values
     $metaId = $metaId ? (int) $metaId : null;
     $parameters = @unserialize($parameters);
     // meta object
     $this->meta = new BackendMeta($frm, $metaId, $baseFieldName, $custom);
     // set callback for generating an unique URL
     $this->meta->setUrlCallback($className, $methodName, $parameters);
     // fetch generated meta url
     $URL = urldecode($this->meta->generateURL($URL));
     // output
     $this->output(self::OK, $URL);
 }
Exemplo n.º 2
0
 /**
  * Checks if the form is valid
  *
  * @return bool
  */
 private function isValid()
 {
     $fields = $this->form->getFields();
     $fields['name']->isFilled(Language::err('FieldIsRequired'));
     $fields['description']->isFilled(Language::err('FieldIsRequired'));
     $this->meta->validate();
     return $this->form->isCorrect();
 }
Exemplo n.º 3
0
 /**
  * @param BackendMeta $meta
  *
  * @return self
  */
 public static function fromBackendMeta(BackendMeta $meta)
 {
     $metaData = $meta->getData();
     return new self($metaData['keywords'], $metaData['keywords_overwrite'] === 'Y', $metaData['description'], $metaData['description_overwrite'] === 'Y', $metaData['title'], $metaData['title_overwrite'] === 'Y', $metaData['url'], $metaData['url_overwrite'] === 'Y', $metaData['custom'], isset($metaData['data']) ? $metaData['data'] : [], $meta->getId());
 }