Пример #1
0
 /**
  * Redirect to a specified URL.
  *
  * Properties needed:
  * - redirectTo - the ID of the Resource to redirect to.
  *
  * @param array $fields An array of cleaned POST fields
  * @return boolean False if unsuccessful.
  */
 public function redirect(array $fields = array())
 {
     if (empty($this->formit->config['redirectTo'])) {
         return false;
     }
     $redirectParams = !empty($this->formit->config['redirectParams']) ? $this->formit->config['redirectParams'] : '';
     if (!empty($redirectParams)) {
         $prefix = $this->modx->getOption('placeholderPrefix', $this->formit->config, 'fi.');
         $this->modx->setPlaceholders($fields, $prefix);
         $this->modx->parser->processElementTags('', $redirectParams, true, true);
         $redirectParams = $this->modx->fromJSON($redirectParams);
         if (empty($redirectParams)) {
             $redirectParams = '';
         }
     }
     $contextKey = $this->modx->context->get('key');
     $resource = $this->modx->getObject('modResource', $this->formit->config['redirectTo']);
     if ($resource) {
         $contextKey = $resource->get('context_key');
     }
     if (!is_numeric($this->formit->config['redirectTo']) && isset($fields[$this->formit->config['redirectTo']]) && is_numeric($fields[$this->formit->config['redirectTo']])) {
         $url = $this->modx->makeUrl($fields[$this->formit->config['redirectTo']], $contextKey, $redirectParams, 'full');
     } elseif (!is_numeric($this->formit->config['redirectTo']) && substr($this->formit->config['redirectTo'], 0, 4) === "http") {
         $url = $this->formit->config['redirectTo'];
     } else {
         $url = $this->modx->makeUrl($this->formit->config['redirectTo'], $contextKey, $redirectParams, 'full');
     }
     $this->setRedirectUrl($url);
     return true;
 }
Пример #2
0
 /**
  * Sets the fields to MODX placeholders
  * @return void
  */
 public function setFieldsAsPlaceholders()
 {
     $fields = $this->dictionary->toArray();
     /* better handling of checkbox values when input name is an array[] */
     $fs = array();
     /** @var mixed $v */
     foreach ($fields as $k => $v) {
         if (is_array($v) && !isset($_FILES[$k])) {
             foreach ($v as $sk => $sv) {
                 $fs[$k . '.' . $sk] = $this->convertMODXTags($sv);
             }
             $v = $this->modx->toJSON($v);
         }
         /* str_replace to prevent showing of placeholders */
         $fs[$k] = $this->convertMODXTags($v);
     }
     $this->modx->setPlaceholders($fs, $this->config['placeholderPrefix']);
 }
Пример #3
0
 /**
  * Redirect to a specified URL.
  *
  * Properties needed:
  * - redirectTo - the ID of the Resource to redirect to.
  *
  * @param array $fields An array of cleaned POST fields
  * @return boolean False if unsuccessful.
  */
 public function redirect(array $fields = array())
 {
     if (empty($this->quip->config['redirectTo'])) {
         return false;
     }
     $redirectParams = !empty($this->quip->config['redirectParams']) ? $this->quip->config['redirectParams'] : '';
     if (!empty($redirectParams)) {
         $prefix = $this->modx->getOption('placeholderPrefix', $this->quip->config, 'fi.');
         $this->modx->setPlaceholders($fields, $prefix);
         $this->modx->parser->processElementTags('', $redirectParams, true, true);
         $redirectParams = $this->modx->fromJSON($redirectParams);
         if (empty($redirectParams)) {
             $redirectParams = '';
         }
     }
     $url = $this->modx->makeUrl($this->quip->config['redirectTo'], '', $redirectParams, 'abs');
     $this->setRedirectUrl($url);
     return true;
 }
Пример #4
0
 /**
  * @param $placeholders
  * @param string $namespace
  */
 public function setPlaceholders($placeholders, $namespace = '')
 {
     $this->modx->setPlaceholders($placeholders, $namespace);
 }