本文整理汇总了PHP中Contao\StringUtil::encodeEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::encodeEmail方法的具体用法?PHP StringUtil::encodeEmail怎么用?PHP StringUtil::encodeEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contao\StringUtil
的用法示例。
在下文中一共展示了StringUtil::encodeEmail方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$this->Template->event = '';
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
// Get the current event
$objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar);
if (null === $objEvent) {
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}
// Overwrite the page title (see #2853 and #4955)
if ($objEvent->title != '') {
$objPage->pageTitle = strip_tags(\StringUtil::stripInsertTags($objEvent->title));
}
// Overwrite the page description
if ($objEvent->teaser != '') {
$objPage->description = $this->prepareMetaDescription($objEvent->teaser);
}
$intStartTime = $objEvent->startTime;
$intEndTime = $objEvent->endTime;
$span = \Calendar::calculateSpan($intStartTime, $intEndTime);
// Do not show dates in the past if the event is recurring (see #923)
if ($objEvent->recurring) {
$arrRange = \StringUtil::deserialize($objEvent->repeatEach);
if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
while ($intStartTime < time() && $intEndTime < $objEvent->repeatEnd) {
$intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime);
$intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime);
}
}
}
$strDate = \Date::parse($objPage->dateFormat, $intStartTime);
if ($span > 0) {
$strDate = \Date::parse($objPage->dateFormat, $intStartTime) . ' – ' . \Date::parse($objPage->dateFormat, $intEndTime);
}
$strTime = '';
if ($objEvent->addTime) {
if ($span > 0) {
$strDate = \Date::parse($objPage->datimFormat, $intStartTime) . ' – ' . \Date::parse($objPage->datimFormat, $intEndTime);
} elseif ($intStartTime == $intEndTime) {
$strTime = \Date::parse($objPage->timeFormat, $intStartTime);
} else {
$strTime = \Date::parse($objPage->timeFormat, $intStartTime) . ' – ' . \Date::parse($objPage->timeFormat, $intEndTime);
}
}
$until = '';
$recurring = '';
// Recurring event
if ($objEvent->recurring) {
$arrRange = \StringUtil::deserialize($objEvent->repeatEach);
if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
$strKey = 'cal_' . $arrRange['unit'];
$recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
if ($objEvent->recurrences > 0) {
$until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
}
}
}
/** @var FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->cal_template);
$objTemplate->setData($objEvent->row());
$objTemplate->date = $strDate;
$objTemplate->time = $strTime;
$objTemplate->datetime = $objEvent->addTime ? date('Y-m-d\\TH:i:sP', $intStartTime) : date('Y-m-d', $intStartTime);
$objTemplate->begin = $intStartTime;
$objTemplate->end = $intEndTime;
$objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
$objTemplate->recurring = $recurring;
$objTemplate->until = $until;
$objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location'];
$objTemplate->details = '';
$objTemplate->hasDetails = false;
$objTemplate->hasTeaser = false;
// Clean the RTE output
if ($objEvent->teaser != '') {
$objTemplate->hasTeaser = true;
$objTemplate->teaser = \StringUtil::toHtml5($objEvent->teaser);
$objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser);
}
// Display the "read more" button for external/article links
if ($objEvent->source != 'default') {
$objTemplate->details = true;
$objTemplate->hasDetails = true;
} else {
$id = $objEvent->id;
$objTemplate->details = function () use($id) {
$strDetails = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
if ($objElement !== null) {
while ($objElement->next()) {
$strDetails .= $this->getContentElement($objElement->current());
}
}
return $strDetails;
};
//.........这里部分代码省略.........
示例2: getTemplateParameters
/**
* Returns the template parameters.
*
* @param string $view The name of the view
* @param int $statusCode The HTTP status code
* @param GetResponseForExceptionEvent $event The event object
*
* @return array|null The template parameters or null
*/
private function getTemplateParameters($view, $statusCode, GetResponseForExceptionEvent $event)
{
if (null === ($labels = $this->loadLanguageStrings())) {
return null;
}
/** @var Config $config */
$config = $this->framework->getAdapter('Contao\\Config');
$encoded = StringUtil::encodeEmail($config->get('adminEmail'));
return ['statusCode' => $statusCode, 'statusName' => Response::$statusTexts[$statusCode], 'error' => $labels, 'template' => $view, 'base' => $event->getRequest()->getBasePath(), 'adminEmail' => 'mailto:' . $encoded, 'exception' => $event->getException()->getMessage()];
}
示例3: parseBbCode
/**
* Replace bbcode and return the HTML string
*
* Supports the following tags:
*
* * [b][/b] bold
* * [i][/i] italic
* * [u][/u] underline
* * [img][/img]
* * [code][/code]
* * [color=#ff0000][/color]
* * [quote][/quote]
* * [quote=tim][/quote]
* * [url][/url]
* * [url=http://][/url]
* * [email][/email]
* * [email=name@example.com][/email]
*
* @param string $strComment
*
* @return string
*/
public function parseBbCode($strComment)
{
$arrSearch = array('@\\[b\\](.*)\\[/b\\]@Uis', '@\\[i\\](.*)\\[/i\\]@Uis', '@\\[u\\](.*)\\[/u\\]@Uis', '@\\s*\\[code\\](.*)\\[/code\\]\\s*@Uis', '@\\[color=([^\\]" ]+)\\](.*)\\[/color\\]@Uis', '@\\s*\\[quote\\](.*)\\[/quote\\]\\s*@Uis', '@\\s*\\[quote=([^\\]]+)\\](.*)\\[/quote\\]\\s*@Uis', '@\\[img\\]\\s*([^\\[" ]+\\.(jpe?g|png|gif|bmp|tiff?|ico))\\s*\\[/img\\]@i', '@\\[url\\]\\s*([^\\[" ]+)\\s*\\[/url\\]@i', '@\\[url=([^\\]" ]+)\\](.*)\\[/url\\]@Uis', '@\\[email\\]\\s*([^\\[" ]+)\\s*\\[/email\\]@i', '@\\[email=([^\\]" ]+)\\](.*)\\[/email\\]@Uis', '@href="(([a-z0-9]+\\.)*[a-z0-9]+\\.([a-z]{2}|asia|biz|com|info|name|net|org|tel)(/|"))@i');
$arrReplace = array('<strong>$1</strong>', '<em>$1</em>', '<span style="text-decoration:underline">$1</span>', "\n\n" . '<div class="code"><p>' . $GLOBALS['TL_LANG']['MSC']['com_code'] . '</p><pre>$1</pre></div>' . "\n\n", '<span style="color:$1">$2</span>', "\n\n" . '<div class="quote">$1</div>' . "\n\n", "\n\n" . '<div class="quote"><p>' . sprintf($GLOBALS['TL_LANG']['MSC']['com_quote'], '$1') . '</p>$2</div>' . "\n\n", '<img src="$1" alt="" />', '<a href="$1">$1</a>', '<a href="$1">$2</a>', '<a href="mailto:$1">$1</a>', '<a href="mailto:$1">$2</a>', 'href="http://$1');
$strComment = preg_replace($arrSearch, $arrReplace, $strComment);
// Encode e-mail addresses
if (strpos($strComment, 'mailto:') !== false) {
$strComment = \StringUtil::encodeEmail($strComment);
}
return $strComment;
}
示例4: formatValue
/**
* Format a value
*
* @param string $k
* @param mixed $value
* @param boolean $blnListSingle
*
* @return mixed
*/
protected function formatValue($k, $value, $blnListSingle = false)
{
$value = \StringUtil::deserialize($value);
// Return if empty
if (empty($value)) {
return '';
}
/** @var PageModel $objPage */
global $objPage;
// Array
if (is_array($value)) {
$value = implode(', ', $value);
} elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'date') {
$value = \Date::parse($objPage->dateFormat, $value);
} elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'time') {
$value = \Date::parse($objPage->timeFormat, $value);
} elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'datim') {
$value = \Date::parse($objPage->datimFormat, $value);
} elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'url' && preg_match('@^(https?://|ftp://)@i', $value)) {
$value = \Idna::decode($value);
// see #5946
$value = '<a href="' . $value . '" target="_blank">' . $value . '</a>';
} elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'email') {
$value = \StringUtil::encodeEmail(\Idna::decode($value));
// see #5946
$value = '<a href="mailto:' . $value . '">' . $value . '</a>';
} elseif (is_array($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'])) {
$value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'][$value];
} elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'])) {
if ($blnListSingle) {
$value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value];
} else {
$value = '<span class="value">[' . $value . ']</span> ' . $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value];
}
}
return $value;
}
示例5: compile
/**
* Generate the module
*/
protected function compile()
{
$objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
if ($objFaq === null) {
$this->Template->faq = array();
return;
}
/** @var PageModel $objPage */
global $objPage;
$arrFaqs = array_fill_keys($this->faq_categories, array());
// Add FAQs
while ($objFaq->next()) {
/** @var FaqModel $objFaq */
$objTemp = (object) $objFaq->row();
// Clean the RTE output
$objTemp->answer = \StringUtil::toHtml5($objFaq->answer);
$objTemp->answer = \StringUtil::encodeEmail($objTemp->answer);
$objTemp->addImage = false;
// Add an image
if ($objFaq->addImage && $objFaq->singleSRC != '') {
$objModel = \FilesModel::findByUuid($objFaq->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
// Do not override the field now that we have a model registry (see #6303)
$arrFaq = $objFaq->row();
$arrFaq['singleSRC'] = $objModel->path;
$strLightboxId = 'lightbox[' . substr(md5('mod_faqpage_' . $objFaq->id), 0, 6) . ']';
// see #5810
$this->addImageToTemplate($objTemp, $arrFaq, null, $strLightboxId);
}
}
$objTemp->enclosure = array();
// Add enclosure
if ($objFaq->addEnclosure) {
$this->addEnclosuresToTemplate($objTemp, $objFaq->row());
}
/** @var UserModel $objAuthor */
$objAuthor = $objFaq->getRelated('author');
$objTemp->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], \Date::parse($objPage->dateFormat, $objFaq->tstamp), $objAuthor->name);
/** @var FaqCategoryModel $objPid */
$objPid = $objFaq->getRelated('pid');
// Order by PID
$arrFaqs[$objFaq->pid]['items'][] = $objTemp;
$arrFaqs[$objFaq->pid]['headline'] = $objPid->headline;
$arrFaqs[$objFaq->pid]['title'] = $objPid->title;
}
$arrFaqs = array_values(array_filter($arrFaqs));
$limit_i = count($arrFaqs) - 1;
// Add classes first, last, even and odd
for ($i = 0; $i <= $limit_i; $i++) {
$class = ($i == 0 ? 'first ' : '') . ($i == $limit_i ? 'last ' : '') . ($i % 2 == 0 ? 'even' : 'odd');
$arrFaqs[$i]['class'] = trim($class);
$limit_j = count($arrFaqs[$i]['items']) - 1;
for ($j = 0; $j <= $limit_j; $j++) {
$class = ($j == 0 ? 'first ' : '') . ($j == $limit_j ? 'last ' : '') . ($j % 2 == 0 ? 'even' : 'odd');
$arrFaqs[$i]['items'][$j]->class = trim($class);
}
}
$this->Template->faq = $arrFaqs;
$this->Template->request = \Environment::get('indexFreeRequest');
$this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop'];
}
示例6: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$this->Template->content = '';
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
$objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
if (null === $objNewsletter) {
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}
// Overwrite the page title (see #2853 and #4955)
if ($objNewsletter->subject != '') {
$objPage->pageTitle = strip_tags(\StringUtil::stripInsertTags($objNewsletter->subject));
}
// Add enclosure
if ($objNewsletter->addFile) {
$this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
}
// Support plain text newsletters (thanks to Hagen Klemp)
if ($objNewsletter->sendText) {
$strContent = nl2br_html5($objNewsletter->text);
} else {
$strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
}
// Parse simple tokens and insert tags
$strContent = $this->replaceInsertTags($strContent);
$strContent = \StringUtil::parseSimpleTokens($strContent, array());
// Encode e-mail addresses
$strContent = \StringUtil::encodeEmail($strContent);
$this->Template->content = $strContent;
$this->Template->subject = $objNewsletter->subject;
}
示例7: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$type = null;
$pageId = $objPage->id;
$pages = array($objPage);
$items = array();
// Get all pages up to the root page
$objPages = \PageModel::findParentsById($objPage->pid);
if ($objPages !== null) {
while ($pageId > 0 && $type != 'root' && $objPages->next()) {
$type = $objPages->type;
$pageId = $objPages->pid;
$pages[] = $objPages->current();
}
}
// Get the first active regular page and display it instead of the root page
if ($type == 'root') {
$objFirstPage = \PageModel::findFirstPublishedByPid($objPages->id);
$items[] = array('isRoot' => true, 'isActive' => false, 'href' => $objFirstPage !== null ? $objFirstPage->getFrontendUrl() : \Environment::get('base'), 'title' => \StringUtil::specialchars($objPages->pageTitle ?: $objPages->title, true), 'link' => $objPages->title, 'data' => $objFirstPage->row(), 'class' => '');
array_pop($pages);
}
/** @var PageModel[] $pages */
for ($i = count($pages) - 1; $i > 0; $i--) {
if ($pages[$i]->hide && !$this->showHidden || !$pages[$i]->published && !BE_USER_LOGGED_IN) {
continue;
}
// Get href
switch ($pages[$i]->type) {
case 'redirect':
$href = $pages[$i]->url;
if (strncasecmp($href, 'mailto:', 7) === 0) {
$href = \StringUtil::encodeEmail($href);
}
break;
case 'forward':
if (($objNext = $pages[$i]->getRelated('jumpTo')) instanceof PageModel || ($objNext = \PageModel::findFirstPublishedRegularByPid($pages[$i]->id)) instanceof PageModel) {
/** @var PageModel $objNext */
$href = $objNext->getFrontendUrl();
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
$href = $pages[$i]->getFrontendUrl();
break;
}
$items[] = array('isRoot' => false, 'isActive' => false, 'href' => $href, 'title' => \StringUtil::specialchars($pages[$i]->pageTitle ?: $pages[$i]->title, true), 'link' => $pages[$i]->title, 'data' => $pages[$i]->row(), 'class' => '');
}
// Active article
if (isset($_GET['articles'])) {
$items[] = array('isRoot' => false, 'isActive' => false, 'href' => $pages[0]->getFrontendUrl(), 'title' => \StringUtil::specialchars($pages[0]->pageTitle ?: $pages[0]->title, true), 'link' => $pages[0]->title, 'data' => $pages[0]->row(), 'class' => '');
list($strSection, $strArticle) = explode(':', \Input::get('articles'));
if ($strArticle === null) {
$strArticle = $strSection;
}
$objArticle = \ArticleModel::findByIdOrAlias($strArticle);
$strAlias = $objArticle->alias ?: $objArticle->id;
if ($objArticle->inColumn != 'main') {
$strAlias = $objArticle->inColumn . ':' . $strAlias;
}
if ($objArticle !== null) {
$items[] = array('isRoot' => false, 'isActive' => true, 'href' => $pages[0]->getFrontendUrl('/articles/' . $strAlias), 'title' => \StringUtil::specialchars($objArticle->title, true), 'link' => $objArticle->title, 'data' => $objArticle->row(), 'class' => '');
}
} else {
$items[] = array('isRoot' => false, 'isActive' => true, 'href' => $pages[0]->getFrontendUrl(), 'title' => \StringUtil::specialchars($pages[0]->pageTitle ?: $pages[0]->title), 'link' => $pages[0]->title, 'data' => $pages[0]->row(), 'class' => '');
}
// Mark the first element (see #4833)
$items[0]['class'] = 'first';
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['generateBreadcrumb']) && is_array($GLOBALS['TL_HOOKS']['generateBreadcrumb'])) {
foreach ($GLOBALS['TL_HOOKS']['generateBreadcrumb'] as $callback) {
$this->import($callback[0]);
$items = $this->{$callback[0]}->{$callback[1]}($items, $this);
}
}
$this->Template->items = $items;
}
示例8: encodeEmail
/**
* Encode all e-mail addresses within a string.
*
* @param string $strString The string to encode.
*
* @return string The encoded string
*/
public static function encodeEmail($strString)
{
if (self::isStringUtilAvailable()) {
return StringUtil::encodeEmail($strString);
}
return \Contao\String::encodeEmail($strString);
}
示例9: doReplace
/**
* Replace insert tags with their values
*
* @param string $strBuffer The text with the tags to be replaced
* @param boolean $blnCache If false, non-cacheable tags will be replaced
*
* @return string The text with the replaced tags
*/
protected function doReplace($strBuffer, $blnCache)
{
/** @var PageModel $objPage */
global $objPage;
// Preserve insert tags
if (\Config::get('disableInsertTags')) {
return \StringUtil::restoreBasicEntities($strBuffer);
}
$tags = preg_split('/{{([^{}]+)}}/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE);
if (count($tags) < 2) {
return \StringUtil::restoreBasicEntities($strBuffer);
}
$strBuffer = '';
// Create one cache per cache setting (see #7700)
static $arrItCache;
$arrCache =& $arrItCache[$blnCache];
for ($_rit = 0, $_cnt = count($tags); $_rit < $_cnt; $_rit += 2) {
$strBuffer .= $tags[$_rit];
$strTag = $tags[$_rit + 1];
// Skip empty tags
if ($strTag == '') {
continue;
}
$flags = explode('|', $strTag);
$tag = array_shift($flags);
$elements = explode('::', $tag);
// Load the value from cache
if (isset($arrCache[$strTag]) && !in_array('refresh', $flags)) {
$strBuffer .= $arrCache[$strTag];
continue;
}
// Skip certain elements if the output will be cached
if ($blnCache) {
if ($elements[0] == 'date' || $elements[0] == 'ua' || $elements[0] == 'post' || $elements[0] == 'file' && !\Validator::isStringUuid($elements[1]) || $elements[1] == 'back' || $elements[1] == 'referer' || $elements[0] == 'request_token' || $elements[0] == 'toggle_view' || strncmp($elements[0], 'cache_', 6) === 0 || in_array('uncached', $flags)) {
/** @var FragmentHandler $fragmentHandler */
$fragmentHandler = \System::getContainer()->get('fragment.handler');
$strBuffer .= $fragmentHandler->render(new ControllerReference('contao.controller.insert_tags:renderAction', ['insertTag' => '{{' . $strTag . '}}']), 'esi');
continue;
}
}
$arrCache[$strTag] = '';
// Replace the tag
switch (strtolower($elements[0])) {
// Date
case 'date':
$arrCache[$strTag] = \Date::parse($elements[1] ?: \Config::get('dateFormat'));
break;
// Accessibility tags
// Accessibility tags
case 'lang':
if ($elements[1] == '') {
$arrCache[$strTag] = '</span>';
} else {
$arrCache[$strTag] = $arrCache[$strTag] = '<span lang="' . \StringUtil::specialchars($elements[1]) . '">';
}
break;
// Line break
// Line break
case 'br':
$arrCache[$strTag] = '<br>';
break;
// E-mail addresses
// E-mail addresses
case 'email':
case 'email_open':
case 'email_url':
if ($elements[1] == '') {
$arrCache[$strTag] = '';
break;
}
$strEmail = \StringUtil::encodeEmail($elements[1]);
// Replace the tag
switch (strtolower($elements[0])) {
case 'email':
$arrCache[$strTag] = '<a href="mailto:' . $strEmail . '" class="email">' . preg_replace('/\\?.*$/', '', $strEmail) . '</a>';
break;
case 'email_open':
$arrCache[$strTag] = '<a href="mailto:' . $strEmail . '" title="' . $strEmail . '" class="email">';
break;
case 'email_url':
$arrCache[$strTag] = $strEmail;
break;
}
break;
// Label tags
// Label tags
case 'label':
$keys = explode(':', $elements[1]);
if (count($keys) < 2) {
$arrCache[$strTag] = '';
break;
}
//.........这里部分代码省略.........
示例10: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
$this->Template->referer = 'javascript:history.go(-1)';
$objFaq = \FaqModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->faq_categories);
if (null === $objFaq) {
throw new PageNotFoundException('Page not found');
}
// Overwrite the page title and description (see #2853 and #4955)
if ($objFaq->question != '') {
$objPage->pageTitle = strip_tags(strip_insert_tags($objFaq->question));
$objPage->description = $this->prepareMetaDescription($objFaq->question);
}
$this->Template->question = $objFaq->question;
// Clean the RTE output
$objFaq->answer = \StringUtil::toHtml5($objFaq->answer);
$this->Template->answer = \StringUtil::encodeEmail($objFaq->answer);
$this->Template->addImage = false;
// Add image
if ($objFaq->addImage && $objFaq->singleSRC != '') {
$objModel = \FilesModel::findByUuid($objFaq->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
// Do not override the field now that we have a model registry (see #6303)
$arrFaq = $objFaq->row();
$arrFaq['singleSRC'] = $objModel->path;
$this->addImageToTemplate($this->Template, $arrFaq);
}
}
$this->Template->enclosure = array();
// Add enclosure
if ($objFaq->addEnclosure) {
$this->addEnclosuresToTemplate($this->Template, $objFaq->row());
}
$strAuthor = '';
// Add the author
if (($objAuthor = $objFaq->getRelated('author')) !== null) {
$strAuthor = $objAuthor->name;
}
$this->Template->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], \Date::parse($objPage->dateFormat, $objFaq->tstamp), $strAuthor);
$bundles = \System::getContainer()->getParameter('kernel.bundles');
// HOOK: comments extension required
if ($objFaq->noComments || !isset($bundles['ContaoCommentsBundle'])) {
$this->Template->allowComments = false;
return;
}
/** @var FaqCategoryModel $objCategory */
$objCategory = $objFaq->getRelated('pid');
$this->Template->allowComments = $objCategory->allowComments;
// Comments are not allowed
if (!$objCategory->allowComments) {
return;
}
// Adjust the comments headline level
$intHl = min(intval(str_replace('h', '', $this->hl)), 5);
$this->Template->hlc = 'h' . ($intHl + 1);
$this->import('Comments');
$arrNotifies = array();
// Notify the system administrator
if ($objCategory->notify != 'notify_author') {
$arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL'];
}
// Notify the author
if ($objCategory->notify != 'notify_admin') {
/** @var UserModel $objAuthor */
if (($objAuthor = $objFaq->getRelated('author')) !== null && $objAuthor->email != '') {
$arrNotifies[] = $objAuthor->email;
}
}
$objConfig = new \stdClass();
$objConfig->perPage = $objCategory->perPage;
$objConfig->order = $objCategory->sortOrder;
$objConfig->template = $this->com_template;
$objConfig->requireLogin = $objCategory->requireLogin;
$objConfig->disableCaptcha = $objCategory->disableCaptcha;
$objConfig->bbcode = $objCategory->bbcode;
$objConfig->moderate = $objCategory->moderate;
$this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_faq', $objFaq->id, $arrNotifies);
}
示例11: getTemplateParameters
/**
* Returns the template parameters.
*
* @param string $view The name of the view
* @param int $statusCode The HTTP status code
* @param string $basePath The base path
*
* @return array|null The template parameters or null
*/
private function getTemplateParameters($view, $statusCode, $basePath)
{
if (null === ($labels = $this->loadLanguageStrings())) {
return null;
}
$encoded = StringUtil::encodeEmail($this->config->get('adminEmail'));
return ['statusCode' => $statusCode, 'error' => $labels, 'template' => $view, 'base' => $basePath, 'adminEmail' => 'mailto:' . $encoded];
}