本文整理汇总了PHP中modX::toPlaceholders方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::toPlaceholders方法的具体用法?PHP modX::toPlaceholders怎么用?PHP modX::toPlaceholders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::toPlaceholders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserTop
public function getUserTop()
{
/* topbar profile links. Moved from class Discuss */
if ($this->discuss->user->isLoggedIn) {
$authphs = array('authLink' => '<a href="' . $this->discuss->request->makeUrl('logout') . '">Logout</a>');
$authphs = array_merge($this->discuss->user->toArray('user.'), $authphs);
$authphs['user.avatar_url'] = $this->discuss->user->getAvatarUrl();
/* Get counts */
$authphs['user.unread_messages_count'] = $newMessages = $this->discuss->user->countUnreadMessages();
$authphs['user.unread_posts_count'] = $unreadPosts = $this->discuss->user->countUnreadPosts();
$authphs['user.new_replies_count'] = $newReplies = $this->discuss->user->countNewReplies();
$authphs['user.unanswered_questions_count'] = $unansweredQuestions = $this->discuss->user->countUnansweredQuestions();
$authphs['user.no_replies_count'] = $noReplies = $this->discuss->user->countWithoutReplies();
/* Format counts nicely */
$authphs['user.unread_messages'] = $newMessages > 1 ? $this->modx->lexicon('discuss.user.new_messages', array('total' => $newMessages)) : ($newMessages == 1 ? $this->modx->lexicon('discuss.user.one_new_message') : $this->modx->lexicon('discuss.user.no_new_messages'));
$authphs['user.unread_posts'] = $unreadPosts > 1 ? $this->modx->lexicon('discuss.user.new_posts', array('total' => $unreadPosts)) : ($unreadPosts == 1 ? $this->modx->lexicon('discuss.user.one_new_post') : $this->modx->lexicon('discuss.user.no_new_posts'));
$authphs['user.new_replies'] = $newReplies > 1 ? $this->modx->lexicon('discuss.user.new_replies', array('total' => $newReplies)) : ($newReplies == 1 ? $this->modx->lexicon('discuss.user.one_new_reply') : $this->modx->lexicon('discuss.user.no_new_replies'));
$authphs['user.unanswered_questions'] = $unansweredQuestions > 1 ? $this->modx->lexicon('discuss.user.unanswered_questions', array('total' => $unansweredQuestions)) : ($unansweredQuestions == 1 ? $this->modx->lexicon('discuss.user.one_unanswered_question') : $this->modx->lexicon('discuss.user.no_unanswered_questions'));
$authphs['user.no_replies'] = $noReplies > 1 ? $this->modx->lexicon('discuss.user.no_replies', array('total' => $noReplies)) : ($noReplies == 1 ? $this->modx->lexicon('discuss.user.one_no_reply') : $this->modx->lexicon('discuss.user.no_no_replies'));
$this->discuss->user->isGlobalModerator();
$this->discuss->user->isAdmin();
} else {
$authphs = array('authLink' => '<a href="' . $this->discuss->request->makeUrl('login') . '">Login</a>', 'user.avatar_url' => '', 'user.unread_messages' => '');
}
$this->modx->toPlaceholders($authphs, 'discuss');
}
示例2: process
/**
* Process the template variable and return the output.
*
* {@inheritdoc}
*/
public function process($properties = null, $content = null)
{
parent::process($properties, $content);
if (!$this->_processed) {
$this->_content = $this->renderOutput($this->xpdo->resourceIdentifier);
/* copy the content source to the output buffer */
$this->_output = $this->_content;
if (is_string($this->_output) && !empty($this->_output)) {
/* turn the processed properties into placeholders */
$scope = $this->xpdo->toPlaceholders($this->_properties, '', '.', true);
/* collect element tags in the content and process them */
$maxIterations = intval($this->xpdo->getOption('parser_max_iterations', null, 10));
$this->xpdo->parser->processElementTags($this->_tag, $this->_output, $this->xpdo->parser->isProcessingUncacheable(), $this->xpdo->parser->isRemovingUnprocessed(), '[[', ']]', array(), $maxIterations);
/* remove the placeholders set from the properties of this element and restore global values */
if (isset($scope['keys'])) {
$this->xpdo->unsetPlaceholders($scope['keys']);
}
if (isset($scope['restore'])) {
$this->xpdo->toPlaceholders($scope['restore']);
}
}
/* apply output filtering */
$this->filterOutput();
/* cache the content */
$this->cache();
$this->_processed = true;
}
$this->xpdo->parser->setProcessingElement(false);
/* finally, return the processed element content */
return $this->_output;
}
示例3: processErrors
/**
* Process the errors that have occurred and setup the appropriate placeholders
* @return void
*/
public function processErrors()
{
$this->modx->toPlaceholders($this->getErrors(), $this->config['placeholderPrefix'] . 'error');
$bulkErrTpl = $this->getOption('validationErrorBulkTpl');
$errs = array();
foreach ($this->getRawErrors() as $field => $err) {
$errs[] = str_replace(array('[[+field]]', '[[+error]]'), array($field, $err), $bulkErrTpl);
}
$errs = implode($this->getOption('validationErrorBulkSeparator'), $errs);
$validationErrorMessage = str_replace('[[+errors]]', $errs, $this->getOption('validationErrorMessage'));
$this->modx->setPlaceholder($this->getOption('placeholderPrefix') . 'validation_error', true);
$this->modx->setPlaceholder($this->getOption('placeholderPrefix') . 'validation_error_message', $validationErrorMessage);
}
示例4: processErrors
/**
* Process the errors that have occurred and setup the appropriate placeholders
* @return void
*/
public function processErrors()
{
$this->modx->toPlaceholders($this->getErrors(), $this->config['placeholderPrefix'] . 'error');
$errs = array();
foreach ($this->getRawErrors() as $field => $err) {
$err = $field . ': ' . $err;
$errs[] = str_replace('[[+error]]', $err, $this->config['validationErrorBulkTpl']);
}
$errs = implode($this->config['validationErrorBulkSeparator'], $errs);
$validationErrorMessage = str_replace('[[+errors]]', $errs, $this->config['validationErrorMessage']);
$this->modx->setPlaceholder($this->config['placeholderPrefix'] . 'validation_error', true);
$this->modx->setPlaceholder($this->config['placeholderPrefix'] . 'validation_error_message', $validationErrorMessage);
}
示例5: gatherFields
/**
* Gather fields and set them into placeholders for pre-fetching
* @return array
*/
public function gatherFields()
{
if (empty($this->fields)) {
return array();
}
$fs = $this->getValues();
/* better handling of checkbox values when input name is an array[] */
foreach ($fs as $f => $v) {
if (is_array($v)) {
$v = implode(',', $v);
}
$fs[$f] = $v;
}
$this->modx->toPlaceholders($fs, $this->config['placeholderPrefix'], '');
return $this->getValues();
}
示例6: toPlaceholders
/**
* @param $subject
* @param string $prefix
* @param string $separator
* @param bool|false $restore
*
* @return array
*/
public function toPlaceholders($subject, $prefix = '', $separator = '.', $restore = false)
{
return $this->modx->toPlaceholders($subject, $prefix, $separator, $restore);
}