本文整理汇总了PHP中StringUtil::toHtml5方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::toHtml5方法的具体用法?PHP StringUtil::toHtml5怎么用?PHP StringUtil::toHtml5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::toHtml5方法的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;
// 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);
}
}
}
示例3: 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;
}
示例4: replaceInsertTag
public function replaceInsertTag($strTag)
{
$arrSplit = explode('::', $strTag);
if ($arrSplit[0] != 'textsnippet') {
return false;
}
if (isset($arrSplit[1])) {
$objTextsnippet = $this->getTextsnippet($arrSplit[1]);
return \StringUtil::toHtml5($this->replaceInsertTag($objTextsnippet->text, true));
}
}
示例5: 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;
}
示例6: compile
/**
* Generate the content element
*/
protected function compile()
{
$link = '/articles/';
$objArticle = $this->objArticle;
if ($objArticle->inColumn != 'main') {
$link .= $objArticle->inColumn . ':';
}
$link .= $objArticle->alias ?: $objArticle->id;
$this->Template->href = $this->generateFrontendUrl($this->objParent->row(), $link);
// Clean the RTE output
$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: 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);
}
示例8: 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;
}
示例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: 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'];
}
示例12: 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();
}
}
示例13: doReplace
//.........这里部分代码省略.........
break;
// Article
// Article
case 'article':
case 'article_open':
case 'article_url':
case 'article_title':
if (($objArticle = \ArticleModel::findByIdOrAlias($elements[1])) === null || !($objPid = $objArticle->getRelated('pid')) instanceof PageModel) {
break;
}
/** @var PageModel $objPid */
$strUrl = $objPid->getFrontendUrl('/articles/' . ($objArticle->alias ?: $objArticle->id));
// Replace the tag
switch (strtolower($elements[0])) {
case 'article':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, \StringUtil::specialchars($objArticle->title), $objArticle->title);
break;
case 'article_open':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, \StringUtil::specialchars($objArticle->title));
break;
case 'article_url':
$arrCache[$strTag] = $strUrl;
break;
case 'article_title':
$arrCache[$strTag] = \StringUtil::specialchars($objArticle->title);
break;
}
break;
// Article teaser
// Article teaser
case 'article_teaser':
$objTeaser = \ArticleModel::findByIdOrAlias($elements[1]);
if ($objTeaser !== null) {
$arrCache[$strTag] = \StringUtil::toHtml5($objTeaser->teaser);
}
break;
// Last update
// Last update
case 'last_update':
$strQuery = "SELECT MAX(tstamp) AS tc";
$bundles = \System::getContainer()->getParameter('kernel.bundles');
if (isset($bundles['ContaoNewsBundle'])) {
$strQuery .= ", (SELECT MAX(tstamp) FROM tl_news) AS tn";
}
if (isset($bundles['ContaoCalendarBundle'])) {
$strQuery .= ", (SELECT MAX(tstamp) FROM tl_calendar_events) AS te";
}
$strQuery .= " FROM tl_content";
$objUpdate = \Database::getInstance()->query($strQuery);
if ($objUpdate->numRows) {
$arrCache[$strTag] = \Date::parse($elements[1] ?: \Config::get('datimFormat'), max($objUpdate->tc, $objUpdate->tn, $objUpdate->te));
}
break;
// Version
// Version
case 'version':
$arrCache[$strTag] = VERSION . '.' . BUILD;
break;
// Request token
// Request token
case 'request_token':
$arrCache[$strTag] = REQUEST_TOKEN;
break;
// POST data
// POST data
case 'post':
示例14: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$id = 'article-' . $this->id;
// Generate the CSS ID if it is not set
if (empty($this->cssID[0])) {
$this->cssID = array($id, $this->cssID[1]);
}
$this->Template->column = $this->inColumn;
$this->Template->noMarkup = $this->blnNoMarkup;
// Add the modification date
$this->Template->timestamp = $this->tstamp;
$this->Template->date = \Date::parse($objPage->datimFormat, $this->tstamp);
// Clean the RTE output
$this->teaser = \StringUtil::toHtml5($this->teaser);
// Show the teaser only
if ($this->multiMode && $this->showTeaser) {
$this->cssID = array($id, '');
$arrCss = \StringUtil::deserialize($this->teaserCssID);
// Override the CSS ID and class
if (is_array($arrCss) && count($arrCss) == 2) {
if ($arrCss[0] == '') {
$arrCss[0] = $id;
}
$this->cssID = $arrCss;
}
$article = $this->alias ?: $this->id;
$href = '/articles/' . ($this->inColumn != 'main' ? $this->inColumn . ':' : '') . $article;
$this->Template->teaserOnly = true;
$this->Template->headline = $this->headline;
$this->Template->href = $objPage->getFrontendUrl($href);
$this->Template->teaser = $this->teaser;
$this->Template->readMore = \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $this->headline), true);
$this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
return;
}
// Get section and article alias
list($strSection, $strArticle) = explode(':', \Input::get('articles'));
if ($strArticle === null) {
$strArticle = $strSection;
}
// Overwrite the page title (see #2853 and #4955)
if (!$this->blnNoMarkup && $strArticle != '' && ($strArticle == $this->id || $strArticle == $this->alias) && $this->title != '') {
$objPage->pageTitle = strip_tags(\StringUtil::stripInsertTags($this->title));
if ($this->teaser != '') {
$objPage->description = $this->prepareMetaDescription($this->teaser);
}
}
$this->Template->printable = false;
$this->Template->backlink = false;
// Back link
if (!$this->multiMode && $strArticle != '' && ($strArticle == $this->id || $strArticle == $this->alias)) {
$this->Template->backlink = 'javascript:history.go(-1)';
// see #6955
$this->Template->back = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['goBack']);
}
$arrElements = array();
$objCte = \ContentModel::findPublishedByPidAndTable($this->id, 'tl_article');
if ($objCte !== null) {
$intCount = 0;
$intLast = $objCte->count() - 1;
while ($objCte->next()) {
$arrCss = array();
/** @var ContentModel $objRow */
$objRow = $objCte->current();
// Add the "first" and "last" classes (see #2583)
if ($intCount == 0 || $intCount == $intLast) {
if ($intCount == 0) {
$arrCss[] = 'first';
}
if ($intCount == $intLast) {
$arrCss[] = 'last';
}
}
$objRow->classes = $arrCss;
$arrElements[] = $this->getContentElement($objRow, $this->strColumn);
++$intCount;
}
}
$this->Template->teaser = $this->teaser;
$this->Template->elements = $arrElements;
if ($this->keywords != '') {
$GLOBALS['TL_KEYWORDS'] .= ($GLOBALS['TL_KEYWORDS'] != '' ? ', ' : '') . $this->keywords;
}
// Deprecated since Contao 4.0, to be removed in Contao 5.0
if ($this->printable == 1) {
@trigger_error('Setting tl_article.printable to "1" has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
$this->Template->printable = true;
$this->Template->pdfButton = true;
} elseif ($this->printable != '') {
$options = \StringUtil::deserialize($this->printable);
if (!empty($options) && is_array($options)) {
$this->Template->printable = true;
$this->Template->printButton = in_array('print', $options);
$this->Template->pdfButton = in_array('pdf', $options);
$this->Template->facebookButton = in_array('facebook', $options);
//.........这里部分代码省略.........
示例15: 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);
}
}
}
}