/** * Create the snippets content * * This is a stub function either override getHtmlOutput() or override render() * * @param \Zend_View_Abstract $view Just in case it is needed here * @return \MUtil_Html_HtmlInterface Something that can be rendered */ public function getHtmlOutput(\Zend_View_Abstract $view) { $html = $this->getHtmlSequence(); $org = $this->token->getOrganization(); $tracker = $this->loader->getTracker(); $html->h3($this->_('Token')); if ($this->token->hasRelation()) { $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->token->getRelation()->getName())); $html->pInfo(sprintf($this->_('We kindly ask you to answer a survey about %s.'), $this->token->getRespondent()->getName())); } else { $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->token->getRespondentName())); } $p->br(); $p->br(); if ($this->wasAnswered) { $html->pInfo(sprintf($this->_('Thank you for answering the "%s" survey.'), $this->token->getSurveyName())); // $html->pInfo($this->_('Please click the button below to answer the next survey.')); } else { if ($welcome = $org->getWelcome()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html')); } // $html->pInfo(sprintf($this->_('Please click the button below to answer the survey for token %s.'), strtoupper($this->token->getTokenId()))); } // Only valid or answerd in the last $where = "(gto_completion_time IS NULL AND gto_valid_from <= CURRENT_TIMESTAMP AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP))"; // Do we always look back if ($this->lookbackInHours) { $where .= $this->db->quoteInto("OR DATE_ADD(gto_completion_time, INTERVAL ? HOUR) >= CURRENT_TIMESTAMP", $this->lookbackInHours, \Zend_Db::INT_TYPE); } // We always look back from the entered token if ($this->token->isCompleted()) { $filterTime = $this->token->getCompletionTime(); $filterTime->subHour(1); $where .= $this->db->quoteInto(" OR gto_completion_time >= ?", $filterTime->toString('yyyy-MM-dd HH:mm:ss')); } // Get the tokens $tokens = $this->token->getAllUnansweredTokens($where); if ($tokens) { $currentToken = $this->token->isCompleted() ? false : $this->token->getTokenId(); $lastRound = false; $lastTrack = false; $open = 0; $pStart = $html->pInfo(); foreach ($tokens as $row) { if ($row['gtr_track_name'] !== $lastTrack) { $lastTrack = $row['gtr_track_name']; $div = $html->div(); $div->class = 'askTrack'; $div->append($this->_('Track')); $div->append(' '); $div->strong($row['gtr_track_name']); if ($row['gr2t_track_info']) { $div->small(sprintf($this->_(' (%s)'), $row['gr2t_track_info'])); } } if ($row['gto_round_description'] && $row['gto_round_description'] !== $lastRound) { $lastRound = $row['gto_round_description']; $div = $html->div(); $div->class = 'askRound'; $div->strong(sprintf($this->_('Round: %s'), $row['gto_round_description'])); $div->br(); } $token = $tracker->getToken($row); $div = $html->div(); $div->class = 'askSurvey'; if ($token->isCompleted()) { $div->actionDisabled($token->getSurveyName()); $div->append(' '); $div->append($this->formatCompletion($token->getCompletionTime())); } else { $open++; $a = $div->actionLink($this->getTokenHref($token), $token->getSurveyName()); $div->append(' '); $div->append($this->formatDuration($token->getSurvey()->getDuration())); $div->append($this->formatUntil($token->getValidUntil())); /* if (false === $currentToken) { $currentToken = $token->getTokenId(); } if ($token->getTokenId() == $currentToken) { $a->appendAttrib('class', 'currentRow'); } // */ } } if ($open) { $pStart->append($this->plural('Please answer the open survey.', 'Please answer the open surveys.', $open)); } else { $html->pInfo($this->_('Thank you for answering all open surveys.')); } } else { $html->pInfo($this->_('There are no surveys to show for this token.')); } if ($sig = $org->getSignature()) { $p = $html->pInfo(); $p->br(); $p->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html')); } return $html; }
/** * Style the template previews * @param array $templateArray template data * @return array html and text views */ protected function getPreview($templateArray) { $multi = false; if (count($templateArray) > 1) { $multi = true; $allLanguages = $this->util->getLocalized()->getLanguages(); } $htmlView = \MUtil_Html::create()->div(); $textView = \MUtil_Html::create()->div(); foreach ($templateArray as $template) { $content = ''; if ($template['gctt_subject'] || $template['gctt_body']) { if ($multi) { $htmlView->h3()->append($allLanguages[$template['gctt_lang']]); $textView->h3()->append($allLanguages[$template['gctt_lang']]); } $content .= '[b]'; $content .= $this->_('Subject:'); $content .= '[/b] [i]'; $content .= $this->mailer->applyFields($template['gctt_subject']); $content .= "[/i]\n\n"; $content .= $this->mailer->applyFields($template['gctt_body']); $htmlView->div(array('class' => 'mailpreview'))->raw(\MUtil_Markup::render($content, 'Bbcode', 'Html')); $textView->pre(array('class' => 'mailpreview'))->raw(\MUtil_Markup::render($content, 'Bbcode', 'Text')); } } return array('html' => $htmlView, 'text' => $textView); }
/** * Create the snippets content * * This is a stub function either override getHtmlOutput() or override render() * * @param \Zend_View_Abstract $view Just in case it is needed here * @return \MUtil_Html_HtmlInterface Something that can be rendered */ public function getHtmlOutput(\Zend_View_Abstract $view) { $messages = false; if ($this->wasAnswered) { $this->currentToken = $this->token->getNextUnansweredToken(); } else { $validator = $this->loader->getTracker()->getTokenValidator(); if ($validator->isValid($this->token->getTokenId())) { $this->currentToken = $this->token; } else { $messages = $validator->getMessages(); $this->currentToken = $this->token->getNextUnansweredToken(); } } if ($this->currentToken instanceof \Gems_Tracker_Token) { $href = $this->getTokenHref($this->currentToken); $url = $href->render($this->view); // Redirect at once header('Location: ' . $url); exit; } // After the header() so that the patient does not see the messages after answering surveys if ($messages) { $this->addMessage($messages); } $org = $this->token->getOrganization(); $html = $this->getHtmlSequence(); $html->h3($this->_('Token')); $html->pInfo(sprintf($this->_('Thank you %s,'), $this->token->getRespondentName())); if ($welcome = $org->getWelcome()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html')); } $p = $html->pInfo()->spaced(); if ($this->wasAnswered) { $p->append($this->_('Thanks for answering our questions.')); } elseif (!$this->isValid) { if ($this->token->isExpired()) { $this->addMessage($this->_('This survey has expired. You can no longer answer it.')); } else { $this->addMessage($this->_('This survey is no longer valid.')); } } $p->append($this->_('We have no further questions for you at the moment.')); $p->append($this->_('We appreciate your cooperation very much.')); if ($sig = $org->getSignature()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html')); } /* $html->br(); $href = array($this->request->getActionKey() => 'index', \MUtil_Model::REQUEST_ID => null); $buttonDiv = $html->buttonDiv(array('class' => 'centerAlign')); $buttonDiv->actionLink($href, $this->_('OK')); // */ return $html; }
public static function bbToHtml($bbcode) { $text = ''; if (!empty($bbcode)) { $text = \MUtil_Markup::render($bbcode, 'Bbcode', 'Html'); } $div = \MUtil_Html::create()->div(array('class' => 'mailpreview')); $div->raw($text); return $div; }
/** * Set both the Html and Text versions of a message * * @param string $content * @return \MUtil_Mail (continuation pattern) */ public function setBodyBBCode($content) { $this->setBodyHtml(\MUtil_Markup::render($content, 'Bbcode', 'Html')); $this->setBodyText(\MUtil_Markup::render($content, 'Bbcode', 'Text')); return $this; }
public static function render($content, $parser, $renderer = 'Html', array $options = array()) { $renderer = \MUtil_Markup::factory($parser, $renderer, $options); return $renderer->render($content); }
/** * Create the snippets content * * This is a stub function either override getHtmlOutput() or override render() * * @param \Zend_View_Abstract $view Just in case it is needed here * @return \MUtil_Html_HtmlInterface Something that can be rendered */ public function getHtmlOutput(\Zend_View_Abstract $view) { $delay = $this->project->getAskDelay($this->request, $this->wasAnswered); $href = $this->getTokenHref($this->showToken); $html = $this->getHtmlSequence(); $org = $this->showToken->getOrganization(); $url = $href->render($this->view); switch ($delay) { case 0: // Redirect at once header('Location: ' . $url); exit; case -1: break; default: // Let the page load after stated interval $this->view->headMeta()->appendHttpEquiv('Refresh', $delay . '; url=' . $url); } $html->h3($this->_('Token')); if ($this->token->hasRelation()) { $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRelation()->getName())); $html->pInfo(sprintf($this->_('We kindly ask you to answer a survey about %s.'), $this->showToken->getRespondent()->getName())); } else { $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRespondentName())); } if ($this->wasAnswered) { $html->pInfo(sprintf($this->_('Thank you for answering the "%s" survey.'), $this->token->getSurveyName())); $html->pInfo($this->_('Please click the button below to answer the next survey.')); } else { if ($welcome = $org->getWelcome()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html')); } $html->pInfo(sprintf($this->_('Please click the button below to answer the survey for token %s.'), strtoupper($this->showToken->getTokenId()))); } if ($delay > 0) { $html->pInfo(sprintf($this->plural('Wait one second to open the survey automatically or click on Cancel to stop.', 'Wait %d seconds to open the survey automatically or click on Cancel to stop.', $delay), $delay)); } $buttonDiv = $html->buttonDiv(array('class' => 'centerAlign')); $buttonDiv->actionLink($href, $this->showToken->getSurveyName()); if ($delay > 0) { $buttonDiv->actionLink(array('delay_cancelled' => 1), $this->_('Cancel')); } if ($next = $this->showToken->getTokenCountUnanswered()) { $html->pInfo(sprintf($this->plural('After this survey there is one other survey we would like you to answer.', 'After this survey there are another %d surveys we would like you to answer.', $next), $next)); } if ($sig = $org->getSignature()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html')); } return $html; }
/** * Hook that loads the form data from $_POST or the model * * Or from whatever other source you specify here. */ protected function loadFormData() { $presetTargetData = $this->mailer->getPresetTargetData(); if ($this->request->isPost()) { $requestData = $this->request->getPost(); foreach ($requestData as $key => $value) { if (!is_array($value)) { $this->formData[$key] = htmlspecialchars($value); } else { $this->formData[$key] = array_map('htmlspecialchars', $value); } } } if (empty($this->formData['preview']) && !isset($this->formData['send'])) { if (isset($this->formData['select_template']) && !empty($this->formData['select_template'])) { if ($template = $this->mailer->getTemplate($this->formData['select_template'])) { $this->formData['subject'] = $template['gctt_subject']; $this->formData['mailBody'] = $template['gctt_body']; } } } $this->formData['available_fields'] = $this->mailElements->displayMailFields($this->mailer->getMailFields()); if (!empty($this->formData['subject']) || !empty($this->formData['mailBody'])) { $content = '[b]'; $content .= $this->_('Subject:'); $content .= '[/b] [i]'; $content .= $this->mailer->applyFields($this->formData['subject']); $content .= "[/i]\n\n"; $content .= $this->mailer->applyFields($this->formData['mailBody']); } else { $content = ' '; } $htmlView = \MUtil_Html::create()->div(); $textView = \MUtil_Html::create()->div(); $htmlView->div(array('class' => 'mailpreview'))->raw(\MUtil_Markup::render($content, 'Bbcode', 'Html')); $textView->pre(array('class' => 'mailpreview'))->raw(\MUtil_Markup::render($content, 'Bbcode', 'Text')); $this->formData['preview_html'] = $htmlView; $this->formData['preview_text'] = $textView; $this->formData = array_merge($this->formData, $presetTargetData); }