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');
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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();
 }
Exemple #6
0
 /**
  * @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);
 }