本文整理匯總了PHP中StringUtil::encodeEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP StringUtil::encodeEmail方法的具體用法?PHP StringUtil::encodeEmail怎麽用?PHP StringUtil::encodeEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類StringUtil
的用法示例。
在下文中一共展示了StringUtil::encodeEmail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generate
/**
* Generate the widget and return it as string
*
* @return string The widget markup
*/
public function generate()
{
$this->text = \StringUtil::toHtml5($this->text);
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = \Config::get('uploadPath') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
return \StringUtil::encodeEmail($this->text);
}
示例2: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
if (substr($this->url, 0, 7) == 'mailto:') {
$this->url = \StringUtil::encodeEmail($this->url);
} else {
$this->url = ampersand($this->url);
}
$embed = explode('%s', $this->embed);
if ($this->linkTitle == '') {
$this->linkTitle = $this->url;
}
// Use an image instead of the title
if ($this->useImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate('ce_hyperlink_image');
$this->Template = $objTemplate;
$this->Template->setData($this->arrData);
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
$this->Template->linkTitle = specialchars($this->linkTitle);
}
}
if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
$this->Template->attribute = ' rel="' . $this->rel . '"';
} else {
$this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
}
$this->Template->rel = $this->rel;
// Backwards compatibility
$this->Template->href = $this->url;
$this->Template->embed_pre = $embed[0];
$this->Template->embed_post = $embed[1];
$this->Template->link = $this->linkTitle;
$this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
$this->Template->target = '';
// Override the link target
if ($this->target) {
$this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
}
// Unset the title attributes in the back end (see #6258)
if (TL_MODE == 'BE') {
$this->Template->title = '';
$this->Template->linkTitle = '';
}
}
示例3: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \StringUtil::toXhtml($this->text);
} else {
$this->text = \StringUtil::toHtml5($this->text);
}
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = \Config::get('uploadPath') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
示例4: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \StringUtil::toXhtml($this->text);
} else {
$this->text = \StringUtil::toHtml5($this->text);
}
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
$classes = deserialize($this->mooClasses);
$this->Template->toggler = $classes[0] ?: 'toggler';
$this->Template->accordion = $classes[1] ?: 'accordion';
$this->Template->headlineStyle = $this->mooStyle;
$this->Template->headline = $this->mooHeadline;
}
示例5: compile
/**
* Generate the module
*/
protected function compile()
{
global $objPage;
$this->Template->content = '';
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
if (TL_MODE == 'FE' && BE_USER_LOGGED_IN) {
$objNewsletter = \NewsletterModel::findByIdOrAlias(\Input::get('items'));
} else {
$objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
}
if ($objNewsletter === null) {
// Do not index or cache the page
$objPage->noSearch = 1;
$objPage->cache = 0;
// Send a 404 header
header('HTTP/1.1 404 Not Found');
$this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
return;
}
// Overwrite the page title (see #2853 and #4955)
if ($objNewsletter->subject != '') {
$objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
}
// Add enclosure
if ($objNewsletter->addFile) {
$this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
}
if (!$objNewsletter->sendText) {
$nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
$strContent = '';
$objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
if ($objContentElements !== null) {
if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
define('NEWSLETTER_CONTENT_PREVIEW', true);
}
foreach ($objContentElements as $objContentElement) {
$strContent .= $this->getContentElement($objContentElement->id);
}
}
// 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;
} else {
$strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
}
// Convert relative URLs
$strContent = $this->convertRelativeUrls($strContent);
// 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;
}
示例6: generate
/**
* Generate the widget and return it as string
*
* @return string The widget markup
*/
public function generate()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \StringUtil::toXhtml($this->text);
} else {
$this->text = \StringUtil::toHtml5($this->text);
}
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = \Config::get('uploadPath') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
return \StringUtil::encodeEmail($this->text);
}
示例7: generateFields
protected function generateFields($objItem)
{
$arrItem = parent::generateFields($objItem);
global $objPage;
$arrItem['fields']['newsHeadline'] = $objItem->headline;
$arrItem['fields']['subHeadline'] = $objItem->subheadline;
$arrItem['fields']['hasSubHeadline'] = $objItem->subheadline ? true : false;
$arrItem['fields']['linkHeadline'] = ModuleNews::generateLink($this, $objItem->headline, $objItem, false);
$arrItem['fields']['more'] = ModuleNews::generateLink($this, $GLOBALS['TL_LANG']['MSC']['more'], $objItem, false, true);
$arrItem['fields']['link'] = ModuleNews::generateNewsUrl($this, $objItem, false);
$arrItem['fields']['text'] = '';
// Clean the RTE output
if ($objItem->teaser != '') {
if ($objPage->outputFormat == 'xhtml') {
$arrItem['fields']['teaser'] = \StringUtil::toXhtml($objItem->teaser);
} else {
$arrItem['fields']['teaser'] = \StringUtil::toHtml5($objItem->teaser);
}
$arrItem['fields']['teaser'] = \StringUtil::encodeEmail($arrItem['fields']['teaser']);
}
// Display the "read more" button for external/article links
if ($objItem->source != 'default') {
$arrItem['fields']['text'] = true;
} else {
$objElement = \ContentModel::findPublishedByPidAndTable($objItem->id, 'tl_news');
if ($objElement !== null) {
while ($objElement->next()) {
$arrItem['fields']['text'] .= $this->getContentElement($objElement->current());
}
}
}
$arrMeta = ModuleNews::getMetaFields($this, $objItem);
// Add the meta information
$arrItem['fields']['date'] = $arrMeta['date'];
$arrItem['fields']['hasMetaFields'] = !empty($arrMeta);
$arrItem['fields']['numberOfComments'] = $arrMeta['ccount'];
$arrItem['fields']['commentCount'] = $arrMeta['comments'];
$arrItem['fields']['timestamp'] = $objItem->date;
$arrItem['fields']['author'] = $arrMeta['author'];
$arrItem['fields']['datetime'] = date('Y-m-d\\TH:i:sP', $objItem->date);
$arrItem['fields']['addImage'] = false;
// Add an image
$this->addImage($objItem, 'singleSRC', $arrItem);
// enclosures are added in runBeforeTemplateParsing
return $arrItem;
}
示例8: compile
/**
* Generate the content element
*/
protected function compile()
{
if (substr($this->url, 0, 7) == 'mailto:') {
$this->url = \StringUtil::encodeEmail($this->url);
} else {
$this->url = ampersand($this->url);
}
$embed = explode('%s', $this->embed);
if ($this->linkTitle == '') {
$this->linkTitle = $this->url;
}
// Use an image instead of the title
if ($this->useImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
$this->Template->useImage = true;
$this->Template->linkTitle = specialchars($this->linkTitle);
}
}
if (strncmp($this->rel, 'lightbox', 8) !== 0) {
$this->Template->attribute = ' rel="' . $this->rel . '"';
} else {
$this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
}
// Deprecated since Contao 4.0, to be removed in Contao 5.0
$this->Template->rel = $this->rel;
$this->Template->href = $this->url;
$this->Template->embed_pre = $embed[0];
$this->Template->embed_post = $embed[1];
$this->Template->link = $this->linkTitle;
$this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
$this->Template->target = '';
// Override the link target
if ($this->target) {
$this->Template->target = ' target="_blank"';
}
// Unset the title attributes in the back end (see #6258)
if (TL_MODE == 'BE') {
$this->Template->title = '';
$this->Template->linkTitle = '';
}
}
示例9: compile
/**
* Generate the content element
*/
protected function compile()
{
$this->text = \StringUtil::toHtml5($this->text);
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = \Config::get('uploadPath') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
示例10: compile
/**
* Generate the content element
*/
protected function compile()
{
// Clean the RTE output
$this->text = \StringUtil::toHtml5($this->text);
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
$classes = deserialize($this->mooClasses);
$this->Template->toggler = $classes[0] ?: 'toggler';
$this->Template->accordion = $classes[1] ?: 'accordion';
$this->Template->headlineStyle = $this->mooStyle;
$this->Template->headline = $this->mooHeadline;
}
示例11: getEmailElement
public function getEmailElement($strTag)
{
$params = preg_split('/::/', $strTag);
if (is_array($params) && !empty($params)) {
// general parameters
$strInsertTag = $params[0];
$strEmail = \StringUtil::encodeEmail($params[1]);
if ($strEmail === null || $strEmail === '') {
return false;
}
switch ($strInsertTag) {
case 'email_label':
// label parameters
$strLabel = $params[2] !== null && $params[2] !== "" ? $params[2] : preg_replace('/\\?.*$/', '', $strEmail);
$strClasses = $params[3] !== null && $params[3] !== '' ? $params[3] . ' ' : '';
$strId = $params[4] !== null && $params[4] !== '' ? 'id="' . $params[4] . '" ' : '';
$strEmailLink = '<a ' . $strId . 'href="mailto:' . $strEmail . '" class="' . $strClasses . 'email">' . $strLabel . '</a>';
return $strEmailLink;
default:
return false;
}
}
return false;
}
示例12: 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;
}
示例13: renderNavigation
/**
* Recursively compile the navigation menu and return it as HTML string
*
* @param integer $pid
* @param integer $level
* @param string $host
* @param string $language
*
* @return string
*/
protected function renderNavigation($pid, $level = 1, $host = null, $language = null)
{
// Get all active subpages
$objSubpages = \PageModel::findPublishedSubpagesWithoutGuestsByPid($pid, $this->showHidden, $this instanceof \ModuleSitemap);
if ($objSubpages === null) {
return '';
}
$items = array();
$groups = array();
// Get all groups of the current front end user
if (FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
$groups = $this->User->groups;
}
// Layout template fallback
if ($this->navigationTpl == '') {
$this->navigationTpl = 'nav_default';
}
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->navigationTpl);
$objTemplate->pid = $pid;
$objTemplate->type = get_class($this);
$objTemplate->cssID = $this->cssID;
// see #4897
$objTemplate->level = 'level_' . $level++;
/** @var \PageModel $objPage */
global $objPage;
// Browse subpages
foreach ($objSubpages as $objSubpage) {
// Skip hidden sitemap pages
if ($this instanceof \ModuleSitemap && $objSubpage->sitemap == 'map_never') {
continue;
}
$subitems = '';
$_groups = deserialize($objSubpage->groups);
// Override the domain (see #3765)
if ($host !== null) {
$objSubpage->domain = $host;
}
// Do not show protected pages unless a back end or front end user is logged in
if (!$objSubpage->protected || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected || $this instanceof \ModuleSitemap && $objSubpage->sitemap == 'map_always') {
// Check whether there will be subpages
if ($objSubpage->subpages > 0 && (!$this->showLevel || $this->showLevel >= $level || !$this->hardLimit && ($objPage->id == $objSubpage->id || in_array($objPage->id, $this->Database->getChildRecords($objSubpage->id, 'tl_page'))))) {
$subitems = $this->renderNavigation($objSubpage->id, $level, $host, $language);
}
$href = null;
// Get href
switch ($objSubpage->type) {
case 'redirect':
$href = $objSubpage->url;
if (strncasecmp($href, 'mailto:', 7) === 0) {
$href = \StringUtil::encodeEmail($href);
}
break;
case 'forward':
if ($objSubpage->jumpTo) {
/** @var \PageModel $objNext */
$objNext = $objSubpage->getRelated('jumpTo');
} else {
$objNext = \PageModel::findFirstPublishedRegularByPid($objSubpage->id);
}
// Hide the link if the target page is invisible
if ($objNext === null || !$objNext->published || $objNext->start != '' && $objNext->start > time() || $objNext->stop != '' && $objNext->stop < time()) {
continue 2;
}
$href = $objNext->getFrontendUrl();
break;
default:
$href = $objSubpage->getFrontendUrl();
break;
}
$row = $objSubpage->row();
$trail = in_array($objSubpage->id, $objPage->trail);
// Active page
if (($objPage->id == $objSubpage->id || $objSubpage->type == 'forward' && $objPage->id == $objSubpage->jumpTo) && !$this instanceof \ModuleSitemap && $href == \Environment::get('request')) {
// Mark active forward pages (see #4822)
$strClass = ($objSubpage->type == 'forward' && $objPage->id == $objSubpage->jumpTo ? 'forward' . ($trail ? ' trail' : '') : 'active') . ($subitems != '' ? ' submenu' : '') . ($objSubpage->protected ? ' protected' : '') . ($objSubpage->cssClass != '' ? ' ' . $objSubpage->cssClass : '');
$row['isActive'] = true;
$row['isTrail'] = false;
} else {
$strClass = ($subitems != '' ? 'submenu' : '') . ($objSubpage->protected ? ' protected' : '') . ($trail ? ' trail' : '') . ($objSubpage->cssClass != '' ? ' ' . $objSubpage->cssClass : '');
// Mark pages on the same level (see #2419)
if ($objSubpage->pid == $objPage->pid) {
$strClass .= ' sibling';
}
$row['isActive'] = false;
$row['isTrail'] = $trail;
}
$row['subitems'] = $subitems;
$row['class'] = trim($strClass);
//.........這裏部分代碼省略.........
示例14: generateNewsUrl
/**
* Generate a URL and return it as string
*
* @param NewsModel $objItem
* @param boolean $blnAddArchive
*
* @return string
*/
public static function generateNewsUrl($objItem, $blnAddArchive = false)
{
$strCacheKey = 'id_' . $objItem->id;
// Load the URL from cache
if (isset(self::$arrUrlCache[$strCacheKey])) {
return self::$arrUrlCache[$strCacheKey];
}
// Initialize the cache
self::$arrUrlCache[$strCacheKey] = null;
switch ($objItem->source) {
// Link to an external page
case 'external':
if (substr($objItem->url, 0, 7) == 'mailto:') {
self::$arrUrlCache[$strCacheKey] = \StringUtil::encodeEmail($objItem->url);
} else {
self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url);
}
break;
// Link to an internal page
// Link to an internal page
case 'internal':
if (($objTarget = $objItem->getRelated('jumpTo')) instanceof PageModel) {
/** @var PageModel $objTarget */
self::$arrUrlCache[$strCacheKey] = ampersand($objTarget->getFrontendUrl());
}
break;
// Link to an article
// Link to an article
case 'article':
if (($objArticle = \ArticleModel::findByPk($objItem->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) instanceof PageModel) {
/** @var PageModel $objPid */
self::$arrUrlCache[$strCacheKey] = ampersand($objPid->getFrontendUrl('/articles/' . ($objArticle->alias ?: $objArticle->id)));
}
break;
}
// Link to the default page
if (self::$arrUrlCache[$strCacheKey] === null) {
$objPage = \PageModel::findByPk($objItem->getRelated('pid')->jumpTo);
if (!$objPage instanceof PageModel) {
self::$arrUrlCache[$strCacheKey] = ampersand(\Environment::get('request'), true);
} else {
self::$arrUrlCache[$strCacheKey] = ampersand($objPage->getFrontendUrl((\Config::get('useAutoItem') ? '/' : '/items/') . ($objItem->alias ?: $objItem->id)));
}
// Add the current archive parameter (news archive)
if ($blnAddArchive && \Input::get('month') != '') {
self::$arrUrlCache[$strCacheKey] .= '?month=' . \Input::get('month');
}
}
return self::$arrUrlCache[$strCacheKey];
}
示例15: 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 RTE output
if ($objPage->outputFormat == 'xhtml') {
$objTemp->answer = \StringUtil::toXhtml($objFaq->answer);
} else {
$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) {
if (!\Validator::isUuid($objFaq->singleSRC)) {
$objTemp->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (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'];
}