本文整理汇总了PHP中modX::setPlaceholders方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::setPlaceholders方法的具体用法?PHP modX::setPlaceholders怎么用?PHP modX::setPlaceholders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::setPlaceholders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
/**
* 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: setFieldsAsPlaceholders
/**
* 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: redirect
/**
* 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: setPlaceholders
/**
* @param $placeholders
* @param string $namespace
*/
public function setPlaceholders($placeholders, $namespace = '')
{
$this->modx->setPlaceholders($placeholders, $namespace);
}