本文整理汇总了PHP中StringUtil::toXhtml方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::toXhtml方法的具体用法?PHP StringUtil::toXhtml怎么用?PHP StringUtil::toXhtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::toXhtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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;
}
示例3: 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);
}
return $this->text;
}
示例4: 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);
}
示例5: 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;
}
示例6: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
$link = '/articles/';
$objArticle = $this->objArticle;
if ($objArticle->inColumn != 'main') {
$link .= $objArticle->inColumn . ':';
}
$link .= $objArticle->alias != '' && !\Config::get('disableAlias') ? $objArticle->alias : $objArticle->id;
$this->Template->href = $this->objParent->getFrontendUrl($link);
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->Template->text = \StringUtil::toXhtml($objArticle->teaser);
} else {
$this->Template->text = \StringUtil::toHtml5($objArticle->teaser);
}
$this->Template->headline = $objArticle->title;
$this->Template->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title));
$this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
}
示例7: compile
/**
* Generate content element
*/
protected function compile()
{
global $objPage;
if ($this->teaser_page_link) {
$objArticle = $this->Database->prepare("\n\t\t\t\tSELECT\n\t\t\t\t\tp.id AS id,\n\t\t\t\t\tp.alias AS alias,\n\t\t\t\t\ta.id AS aid,\n\t\t\t\t\ta.title AS title,\n\t\t\t\t\ta.alias AS aalias,\n\t\t\t\t\ta.teaser AS teaser,\n\t\t\t\t\ta.inColumn AS inColumn,\n\t\t\t\t\ta.cssID AS cssID\n\t\t\t\tFROM\n\t\t\t\t\ttl_article a,\n\t\t\t\t\ttl_page p\n\t\t\t\tWHERE\n\t\t\t\t\ta.id=?\n\t\t\t\t\tAND a.pid=p.id\n\t\t\t")->limit(1)->execute($this->article);
if ($objArticle->numRows < 1) {
return;
}
$link = $this->generateFrontendUrl($objArticle->row());
if (version_compare(VERSION, '2.9', '>')) {
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$articleTeaser = \StringUtil::toXhtml($objArticle->teaser);
} else {
$articleTeaser = \StringUtil::toHtml5($objArticle->teaser);
}
} else {
$articleTeaser = $objArticle->teaser;
}
if ($this->teaser_fragment_identifier) {
$cssID = deserialize($objArticle->cssID, true);
if (strlen($cssID[0])) {
$link .= '#' . $cssID[0];
} else {
$link .= '#' . $objArticle->aalias;
}
}
$this->Template->href = $link;
$this->Template->headline = $objArticle->title;
$this->Template->text = $articleTeaser;
$this->Template->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title));
$this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
} else {
parent::compile();
}
}
示例8: 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'];
}
示例9: 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) {
/** @var \PageError404 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($objPage->id);
}
// 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 RTE output
if ($objPage->outputFormat == 'xhtml') {
$objFaq->answer = \StringUtil::toXhtml($objFaq->answer);
} else {
$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) {
if (!\Validator::isUuid($objFaq->singleSRC)) {
$this->Template->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;
$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);
// HOOK: comments extension required
if ($objFaq->noComments || !in_array('comments', \ModuleLoader::getActive())) {
$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);
}
示例10: compile
/**
* Generate content element
*/
protected function compile()
{
if (TL_MODE == 'FE' || defined('EX_TL_MODE_FE')) {
global $objPage;
} else {
$objArticle = \Database::getInstance()->prepare("SELECT `pid` FROM `tl_article` WHERE `id`=?")->execute($this->pid);
if ($objArticle->next()) {
$objPage = \Database::getInstance()->prepare("SELECT * FROM `tl_page` WHERE `id`=?")->execute($objArticle->pid)->next();
}
}
$rootPage = $this->getRootPage($objPage->id);
if (TL_MODE == 'BE' && !defined('EX_TL_MODE_FE')) {
$objPage->domain = $rootPage['dns'];
$objPage->rootLanguage = $rootPage['language'];
}
$objTargetPage = \Database::getInstance()->prepare("\n\t\t\tSELECT\n\t\t\t\t`id`,\n\t\t\t\t`alias`,\n\t\t\t\t`title`,\n\t\t\t\t`type`\n\t\t\tFROM\n\t\t\t\t`tl_page`\n\t\t\tWHERE\n\t\t\t\t" . (!\Input::cookie('FE_PREVIEW') && TL_MODE == 'FE' ? "`published`='1' AND " : "") . "\n\t\t\t\t`id`=?")->limit(1)->execute($this->page_teaser_page);
$link = '';
if ($objTargetPage->numRows < 1) {
$this->pageCode = -1;
$this->pageLink = sprintf($GLOBALS['TL_LANG']['page_teaser']['not_found'], $this->page_teaser_page);
} else {
$targetId = $objTargetPage->id;
if ($targetRoot = $this->getRootPage($objTargetPage->id)) {
if ($objPage->domain != $targetRoot['dns']) {
$link = ($this->Environment->ssl ? 'https://' : 'http://') . $targetRoot['dns'] . '/';
}
if ($rootPage['id'] != $targetRoot['id']) {
$this->pageCode = 1;
}
}
if ($objTargetPage->type != 'root') {
if (version_compare(VERSION, '3.5', '>=')) {
$link = $this->generateFrontendUrl($objTargetPage->row(), null, null, true);
} elseif (version_compare(VERSION, '2.10', '>') && $GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$link .= $this->generateFrontendUrl($objTargetPage->row(), null, $targetRoot['language']);
} else {
$link .= $this->generateFrontendUrl($objTargetPage->row());
}
}
}
$this->pageLink = $link;
if (version_compare(VERSION, '2.9', '>')) {
// 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 = $GLOBALS['TL_CONFIG']['uploadPath'] . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
$this->cssID = array($this->cssID[0], $this->cssID[1] . (PAGE_TEASER_JS_LINK == 1 ? ' ce_teaser_link' : ''));
$this->Template->href = $link;
$this->Template->headline = $this->headline;
$this->Template->text = $this->text;
$this->Template->showMore = $this->page_teaser_show_more;
$this->Template->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objTargetPage->title));
$this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
if (version_compare(VERSION, '3', '>=')) {
if (version_compare(VERSION, '3.2', '>=')) {
$objModel = \FilesModel::findByUuid($this->singleSRC);
} else {
$objModel = \FilesModel::findByPk($this->singleSRC);
}
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
} else {
if ($this->addImage && strlen($this->singleSRC) && is_file(TL_ROOT . '/' . $this->singleSRC)) {
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
}
示例11: parseArticle
/**
* Parse an item and return it as string
*
* @param \NewsModel $objArticle
* @param boolean $blnAddArchive
* @param string $strClass
* @param integer $intCount
*
* @return string
*/
protected function parseArticle($objArticle, $blnAddArchive = false, $strClass = '', $intCount = 0)
{
/** @var \PageModel $objPage */
global $objPage;
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->news_template);
$objTemplate->setData($objArticle->row());
$objTemplate->class = ($objArticle->cssClass != '' ? ' ' . $objArticle->cssClass : '') . $strClass;
$objTemplate->newsHeadline = $objArticle->headline;
$objTemplate->subHeadline = $objArticle->subheadline;
$objTemplate->hasSubHeadline = $objArticle->subheadline ? true : false;
$objTemplate->linkHeadline = $this->generateLink($objArticle->headline, $objArticle, $blnAddArchive);
$objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objArticle, $blnAddArchive, true);
$objTemplate->link = $this->generateNewsUrl($objArticle, $blnAddArchive);
$objTemplate->archive = $objArticle->getRelated('pid');
$objTemplate->count = $intCount;
// see #5708
$objTemplate->text = '';
// Clean the RTE output
if ($objArticle->teaser != '') {
if ($objPage->outputFormat == 'xhtml') {
$objTemplate->teaser = \StringUtil::toXhtml($objArticle->teaser);
} else {
$objTemplate->teaser = \StringUtil::toHtml5($objArticle->teaser);
}
$objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser);
}
// Display the "read more" button for external/article links
if ($objArticle->source != 'default') {
$objTemplate->text = true;
} else {
$id = $objArticle->id;
$objTemplate->text = function () use($id) {
$strText = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_news');
if ($objElement !== null) {
while ($objElement->next()) {
$strText .= $this->getContentElement($objElement->current());
}
}
return $strText;
};
}
$arrMeta = $this->getMetaFields($objArticle);
// Add the meta information
$objTemplate->date = $arrMeta['date'];
$objTemplate->hasMetaFields = !empty($arrMeta);
$objTemplate->numberOfComments = $arrMeta['ccount'];
$objTemplate->commentCount = $arrMeta['comments'];
$objTemplate->timestamp = $objArticle->date;
$objTemplate->author = $arrMeta['author'];
$objTemplate->datetime = date('Y-m-d\\TH:i:sP', $objArticle->date);
$objTemplate->addImage = false;
// Add an image
if ($objArticle->addImage && $objArticle->singleSRC != '') {
$objModel = \FilesModel::findByUuid($objArticle->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($objArticle->singleSRC)) {
$objTemplate->text = '<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)
$arrArticle = $objArticle->row();
// Override the default image size
if ($this->imgSize != '') {
$size = deserialize($this->imgSize);
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
$arrArticle['size'] = $this->imgSize;
}
}
$arrArticle['singleSRC'] = $objModel->path;
$this->addImageToTemplate($objTemplate, $arrArticle);
}
}
$objTemplate->enclosure = array();
// Add enclosures
if ($objArticle->addEnclosure) {
$this->addEnclosuresToTemplate($objTemplate, $objArticle->row());
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['parseArticles']) && is_array($GLOBALS['TL_HOOKS']['parseArticles'])) {
foreach ($GLOBALS['TL_HOOKS']['parseArticles'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objTemplate, $objArticle->row(), $this);
}
}
return $objTemplate->parse();
}
示例12: replace
//.........这里部分代码省略.........
$strUrl = $this->generateFrontendUrl($objJumpTo->row());
}
} elseif ($objEvent->source == 'article') {
if (($objArticle = \ArticleModel::findByPk($objEvent->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
$strUrl = $this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
}
} else {
if (($objCalendar = $objEvent->getRelated('pid')) !== null && ($objJumpTo = $objCalendar->getRelated('jumpTo')) !== null) {
$strUrl = $this->generateFrontendUrl($objJumpTo->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/events/') . (!\Config::get('disableAlias') && $objEvent->alias != '' ? $objEvent->alias : $objEvent->id));
}
}
// Replace the tag
switch (strtolower($elements[0])) {
case 'event':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, specialchars($objEvent->title), $objEvent->title);
break;
case 'event_open':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objEvent->title));
break;
case 'event_url':
$arrCache[$strTag] = $strUrl;
break;
case 'event_title':
$arrCache[$strTag] = specialchars($objEvent->title);
break;
}
break;
// Article teaser
// Article teaser
case 'article_teaser':
$objTeaser = \ArticleModel::findByIdOrAlias($elements[1]);
if ($objTeaser !== null) {
if ($objPage->outputFormat == 'xhtml') {
$arrCache[$strTag] = \StringUtil::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache));
} else {
$arrCache[$strTag] = \StringUtil::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache));
}
}
break;
// News teaser
// News teaser
case 'news_teaser':
$objTeaser = \NewsModel::findByIdOrAlias($elements[1]);
if ($objTeaser !== null) {
if ($objPage->outputFormat == 'xhtml') {
$arrCache[$strTag] = \StringUtil::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache));
} else {
$arrCache[$strTag] = \StringUtil::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache));
}
}
break;
// Event teaser
// Event teaser
case 'event_teaser':
$objTeaser = \CalendarEventsModel::findByIdOrAlias($elements[1]);
if ($objTeaser !== null) {
if ($objPage->outputFormat == 'xhtml') {
$arrCache[$strTag] = \StringUtil::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache));
} else {
$arrCache[$strTag] = \StringUtil::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache));
}
}
break;
// News feed URL
// News feed URL
case 'news_feed':
示例13: 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) {
/** @var \PageError404 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($objPage->id);
}
// Overwrite the page title (see #2853 and #4955)
if ($objEvent->title != '') {
$objPage->pageTitle = strip_tags(strip_insert_tags($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 = 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 = 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;
if ($objPage->outputFormat == 'xhtml') {
$objTemplate->teaser = \StringUtil::toXhtml($objEvent->teaser);
} else {
$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) {
//.........这里部分代码省略.........
示例14: getAlbumTemplateVars
/**
* Set the template-vars to the template object for the selected album
* @param $intAlbumId
*/
protected function getAlbumTemplateVars($intAlbumId)
{
global $objPage;
// Load the current album from db
$objAlbum = \GalleryCreatorAlbumsModel::findByPk($intAlbumId);
if ($objAlbum === null) {
return;
}
// add meta tags to the page object
if (TL_MODE == 'FE' && $this->viewMode == 'detail_view') {
$objPage->description = $objAlbum->description != '' ? specialchars($objAlbum->description) : $objPage->description;
$GLOBALS['TL_KEYWORDS'] = ltrim($GLOBALS['TL_KEYWORDS'] . ',' . specialchars($objAlbum->keywords), ',');
}
//store all album-data in the array
foreach ($objAlbum->row() as $k => $v) {
$this->Template->arrAlbumdata = $objAlbum->row();
}
// store the data of the current album in the session
$_SESSION['gallery_creator']['CURRENT_ALBUM'] = $this->Template->arrAlbumdata;
//der back-Link
$this->Template->backLink = $this->generateBackLink($intAlbumId);
//Der dem Bild uebergeordnete Albumname
$this->Template->Albumname = $objAlbum->name;
// Albumbesucher (Anzahl Klicks)
$this->Template->visitors = $objAlbum->vistors;
//Der Kommentar zum gewaehlten Album
$this->Template->albumComment = $objPage->outputFormat == 'xhtml' ? \StringUtil::toXhtml($objAlbum->comment) : \StringUtil::toHtml5($objAlbum->comment);
// In der Detailansicht kann optional ein Artikel vor dem Album hinzugefuegt werden
$this->Template->insertArticlePre = $objAlbum->insert_article_pre ? sprintf('{{insert_article::%s}}', $objAlbum->insert_article_pre) : null;
// In der Detailansicht kann optional ein Artikel nach dem Album hinzugefuegt werden
$this->Template->insertArticlePost = $objAlbum->insert_article_post ? sprintf('{{insert_article::%s}}', $objAlbum->insert_article_post) : null;
//Das Event-Datum des Albums als unix-timestamp
$this->Template->eventTstamp = $objAlbum->date;
//Das Event-Datum des Albums formatiert
$this->Template->eventDate = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objAlbum->date);
//Abstaende
$this->Template->imagemargin = $this->viewMode == 'detail_view' ? $this->generateMargin(deserialize($this->gc_imagemargin_detailview), 'margin') : $this->generateMargin(deserialize($this->gc_imagemargin_albumlisting), 'margin');
//Anzahl Spalten pro Reihe
$this->Template->colsPerRow = $this->gc_rows == "" ? 4 : $this->gc_rows;
$this->Template->objElement = $this;
}
示例15: addTestimonialsToTemplate
public function addTestimonialsToTemplate(\FrontendTemplate $objTemplate, \stdClass $objConfig, $intParent, $arrNotifies)
{
global $objPage;
$limit = 0;
$offset = 0;
$total = 0;
$gtotal = 0;
$arrTestimonials = array();
$objTemplate->testimonials = array();
// Pagination
if ($objConfig->perPage > 0) {
// Get the total number of testimonials
$intTotal = \TestimonialsModel::countPublishedTestimonials($intParent);
$total = $gtotal = $intTotal;
// Get the current page
$id = 'page_entry' . $intParent;
// see #4141
$page = \Input::get($id) ?: 1;
// Do not index or cache the page if the page number is outside the range
if ($page < 1 || $page > max(ceil($total / $objConfig->perPage), 1)) {
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
// Send a 404 header
header('HTTP/1.1 404 Not Found');
return;
}
// Set limit and offset
$limit = $objConfig->perPage;
$offset = ($page - 1) * $objConfig->perPage;
// Initialize the pagination menu
$objPagination = new \Pagination($total, $objConfig->perPage, 7, $id);
$objTemplate->pagination = $objPagination->generate("\n ");
}
// Get all published testimonials
if ($limit) {
$objTestimonials = \TestimonialsModel::findPublishedTestimonials($intParent, $objConfig->order == 'descending', $limit, $offset);
} else {
$objTestimonials = \TestimonialsModel::findPublishedTestimonials($intParent, $objConfig->order == 'descending');
}
// Parse the testimonials
if ($objTestimonials !== null && ($total = $objTestimonials->count()) > 0) {
$count = 0;
if ($objConfig->template == '') {
$objConfig->template = 'testimonial_entry';
}
$objPartial = new \FrontendTemplate($objConfig->template);
while ($objTestimonials->next()) {
$objPartial->setData($objTestimonials->row());
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$objTestimonials->testimonial = \StringUtil::toXhtml($objTestimonials->testimonial);
} else {
$objTestimonials->testimonial = \StringUtil::toHtml5($objTestimonials->testimonial);
}
$objPartial->testimonial = trim(str_replace(array('{{', '}}'), array('{{', '}}'), $objTestimonials->testimonial));
$objPartial->datim = $this->parseDate($objPage->datimFormat, $objTestimonials->date);
$objPartial->date = $this->parseDate($objPage->dateFormat, $objTestimonials->date);
$objPartial->class = ($count < 1 ? ' first' : '') . ($count >= $total - 1 ? ' last' : '') . ($count % 2 == 0 ? ' even' : ' odd');
$objPartial->by = $GLOBALS['TL_LANG']['MSC']['com_by'];
$objPartial->id = 'entry_' . $objTestimonials->id;
$objPartial->timestamp = $objTestimonials->date;
$objPartial->datetime = date('Y-m-d\\TH:i:sP', $objTestimonials->date);
$objPartial->avatar = $this->get_gravatar($objTestimonials->email, $objTestimonials->name, $objConfig->AvatarMode, $objConfig->AvatarSize, $objConfig->DefaultGravatar, $objConfig->DefaultGravatarRating, $objConfig->DefaultAvatar);
$objPartial->titel = $objTestimonials->title;
$objPartial->addVote = $objConfig->addVote;
$objPartial->enableVoteField1 = $objConfig->enableVoteField1;
$objPartial->enableVoteField2 = $objConfig->enableVoteField2;
$objPartial->enableVoteField3 = $objConfig->enableVoteField3;
$objPartial->enableVoteField4 = $objConfig->enableVoteField4;
$objPartial->enableVoteField5 = $objConfig->enableVoteField5;
$objPartial->enableVoteField6 = $objConfig->enableVoteField6;
$objPartial->VoteField1Name = $objConfig->VoteField1Name;
$objPartial->VoteField2Name = $objConfig->VoteField2Name;
$objPartial->VoteField3Name = $objConfig->VoteField3Name;
$objPartial->VoteField4Name = $objConfig->VoteField4Name;
$objPartial->VoteField5Name = $objConfig->VoteField5Name;
$objPartial->VoteField6Name = $objConfig->VoteField6Name;
$objPartial->design = $objConfig->design;
$arrTestimonials[] = $objPartial->parse();
++$count;
}
}
$objTemplate->testimonials = $arrTestimonials;
$objTemplate->addVote = $objConfig->addVote;
$objTemplate->name = $GLOBALS['TL_LANG']['MSC']['tm_name'];
$objTemplate->email = $GLOBALS['TL_LANG']['MSC']['tm_email'];
$objTemplate->url = $GLOBALS['TL_LANG']['MSC']['tm_website'];
$objTemplate->company = $GLOBALS['TL_LANG']['MSC']['tm_company'];
$objTemplate->title = $GLOBALS['TL_LANG']['MSC']['tm_title'];
$objTemplate->TestimonialsTotal = $limit ? $gtotal : $total;
// Add a form to create new testimonials
$this->renderTestimonialForm($objTemplate, $objConfig, $intParent);
}