当前位置: 首页>>代码示例>>PHP>>正文


PHP String::toXhtml方法代码示例

本文整理汇总了PHP中String::toXhtml方法的典型用法代码示例。如果您正苦于以下问题:PHP String::toXhtml方法的具体用法?PHP String::toXhtml怎么用?PHP String::toXhtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String的用法示例。


在下文中一共展示了String::toXhtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::toHtml5($this->text);
     }
     $this->Template->text = \String::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;
 }
开发者ID:juergen83,项目名称:contao,代码行数:33,代码来源:ContentAccordion.php

示例2: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::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->Template->text = \String::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         if (!is_numeric($this->singleSRC)) {
             $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } 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);
             }
         }
     }
 }
开发者ID:rburch,项目名称:core,代码行数:32,代码来源:ContentText.php

示例3: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
     if ($objFaq === null) {
         $this->Template->faq = array();
         return;
     }
     global $objPage;
     $arrFaq = array_fill_keys($this->faq_categories, array());
     // Add FAQs
     while ($objFaq->next()) {
         $objTemp = (object) $objFaq->row();
         // Clean RTE output
         if ($objPage->outputFormat == 'xhtml') {
             $objFaq->answer = \String::toXhtml($objFaq->answer);
         } else {
             $objFaq->answer = \String::toHtml5($objFaq->answer);
         }
         $objTemp->answer = \String::encodeEmail($objFaq->answer);
         $objTemp->addImage = false;
         // Add an image
         if ($objFaq->addImage && $objFaq->singleSRC != '') {
             if (!is_numeric($objFaq->singleSRC)) {
                 $objTemp->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             } else {
                 $objModel = \FilesModel::findByPk($objFaq->singleSRC);
                 if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                     $objFaq->singleSRC = $objModel->path;
                     $this->addImageToTemplate($objTemp, $objFaq->row());
                 }
             }
         }
         $objTemp->enclosure = array();
         // Add enclosure
         if ($objFaq->addEnclosure) {
             $this->addEnclosuresToTemplate($objTemp, $objFaq->row());
         }
         $objTemp->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name);
         // Order by PID
         $arrFaq[$objFaq->pid]['items'][] = $objTemp;
         $arrFaq[$objFaq->pid]['headline'] = $objFaq->category;
     }
     $arrFaq = array_values(array_filter($arrFaq));
     $limit_i = count($arrFaq) - 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');
         $arrFaq[$i]['class'] = trim($class);
         $limit_j = count($arrFaq[$i]['items']) - 1;
         for ($j = 0; $j <= $limit_j; $j++) {
             $class = ($j == 0 ? 'first ' : '') . ($j == $limit_j ? 'last ' : '') . ($j % 2 == 0 ? 'even' : 'odd');
             $arrFaq[$i]['items'][$j]->class = trim($class);
         }
     }
     $this->Template->faq = $arrFaq;
     $this->Template->request = $this->getIndexFreeRequest(true);
     $this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop'];
 }
开发者ID:rburch,项目名称:core,代码行数:61,代码来源:ModuleFaqPage.php

示例4: generate

 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         return \String::toXhtml($this->text);
     } else {
         return \String::toHtml5($this->text);
     }
 }
开发者ID:rburch,项目名称:core,代码行数:14,代码来源:FormExplanation.php

示例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 = \String::toXhtml($this->text);
     } else {
         $this->text = \String::toHtml5($this->text);
     }
     return $this->text;
 }
开发者ID:juergen83,项目名称:contao,代码行数:17,代码来源:FormHeadline.php

示例6: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     // Accordion start
     if ($this->mooType == 'mooStart') {
         if (TL_MODE == 'FE') {
             $this->strTemplate = 'ce_accordion_start';
             $this->Template = new \FrontendTemplate($this->strTemplate);
             $this->Template->setData($this->arrData);
         } else {
             $this->strTemplate = 'be_wildcard';
             $this->Template = new \BackendTemplate($this->strTemplate);
             $this->Template->title = $this->mooHeadline;
         }
     } elseif ($this->mooType == 'mooStop') {
         if (TL_MODE == 'FE') {
             $this->strTemplate = 'ce_accordion_stop';
             $this->Template = new \FrontendTemplate($this->strTemplate);
             $this->Template->setData($this->arrData);
         } else {
             $this->strTemplate = 'be_wildcard';
             $this->Template = new \BackendTemplate($this->strTemplate);
         }
     } else {
         global $objPage;
         // Clean RTE output
         if ($objPage->outputFormat == 'xhtml') {
             $this->text = \String::toXhtml($this->text);
         } else {
             $this->text = \String::toHtml5($this->text);
         }
         $this->Template->text = \String::encodeEmail($this->text);
         $this->Template->addImage = false;
         // Add an image
         if ($this->addImage && $this->singleSRC != '') {
             if (!is_numeric($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             } 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);
                 }
             }
         }
     }
     $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;
 }
开发者ID:rburch,项目名称:core,代码行数:54,代码来源:ContentAccordion.php

示例7: generate

 /**
  * Generate the widget and return it as string
  *
  * @return string The widget markup
  */
 public function generate()
 {
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::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 \String::encodeEmail($this->text);
 }
开发者ID:iCodr8,项目名称:core,代码行数:21,代码来源:FormExplanation.php

示例8: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     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->generateFrontendUrl($this->objParent->row(), $link);
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->Template->text = \String::toXhtml($objArticle->teaser);
     } else {
         $this->Template->text = \String::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'];
 }
开发者ID:iCodr8,项目名称:core,代码行数:23,代码来源:ContentTeaser.php

示例9: addCommentsToTemplate

 /**
  * Add comments to a template
  * @param \FrontendTemplate
  * @param \stdClass
  * @param string
  * @param integer
  * @param mixed
  */
 public function addCommentsToTemplate(\FrontendTemplate $objTemplate, \stdClass $objConfig, $strSource, $intParent, $varNotifies)
 {
     global $objPage;
     $limit = 0;
     $offset = 0;
     $total = 0;
     $gtotal = 0;
     $arrComments = array();
     $objTemplate->comments = array();
     // see #4064
     // Pagination
     if ($objConfig->perPage > 0) {
         // Get the total number of comments
         $intTotal = \CommentsModel::countPublishedBySourceAndParent($strSource, $intParent);
         $total = $gtotal = $intTotal;
         // Calculate the key (e.g. tl_form_field becomes page_cff12)
         $key = '';
         $chunks = explode('_', substr($strSource, strncmp($strSource, 'tl_', 3) === 0 ? 3 : 0));
         foreach ($chunks as $chunk) {
             $key .= substr($chunk, 0, 1);
         }
         // Get the current page
         $id = 'page_c' . $key . $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');
             $objTemplate->allowComments = false;
             return;
         }
         // Set limit and offset
         $limit = $objConfig->perPage;
         $offset = ($page - 1) * $objConfig->perPage;
         // Initialize the pagination menu
         $objPagination = new \Pagination($total, $objConfig->perPage, \Config::get('maxPaginationLinks'), $id);
         $objTemplate->pagination = $objPagination->generate("\n  ");
     }
     $objTemplate->allowComments = true;
     // Get all published comments
     if ($limit) {
         $objComments = \CommentsModel::findPublishedBySourceAndParent($strSource, $intParent, $objConfig->order == 'descending', $limit, $offset);
     } else {
         $objComments = \CommentsModel::findPublishedBySourceAndParent($strSource, $intParent, $objConfig->order == 'descending');
     }
     // Parse the comments
     if ($objComments !== null && ($total = $objComments->count()) > 0) {
         $count = 0;
         if ($objConfig->template == '') {
             $objConfig->template = 'com_default';
         }
         $objPartial = new \FrontendTemplate($objConfig->template);
         while ($objComments->next()) {
             $objPartial->setData($objComments->row());
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $objPartial->comment = \String::toXhtml($objComments->comment);
             } else {
                 $objPartial->comment = \String::toHtml5($objComments->comment);
             }
             $objPartial->comment = trim(str_replace(array('{{', '}}'), array('&#123;&#123;', '&#125;&#125;'), $objPartial->comment));
             $objPartial->datim = \Date::parse($objPage->datimFormat, $objComments->date);
             $objPartial->date = \Date::parse($objPage->dateFormat, $objComments->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 = 'c' . $objComments->id;
             $objPartial->timestamp = $objComments->date;
             $objPartial->datetime = date('Y-m-d\\TH:i:sP', $objComments->date);
             $objPartial->addReply = false;
             // Reply
             if ($objComments->addReply && $objComments->reply != '') {
                 if (($objAuthor = $objComments->getRelated('author')) !== null) {
                     $objPartial->addReply = true;
                     $objPartial->rby = $GLOBALS['TL_LANG']['MSC']['com_reply'];
                     $objPartial->reply = $this->replaceInsertTags($objComments->reply);
                     $objPartial->author = $objAuthor;
                     // Clean the RTE output
                     if ($objPage->outputFormat == 'xhtml') {
                         $objPartial->reply = \String::toXhtml($objPartial->reply);
                     } else {
                         $objPartial->reply = \String::toHtml5($objPartial->reply);
                     }
                 }
             }
             $arrComments[] = $objPartial->parse();
             ++$count;
         }
     }
//.........这里部分代码省略.........
开发者ID:iCodr8,项目名称:core,代码行数:101,代码来源:Comments.php

示例10: replaceInsertTags


//.........这里部分代码省略.........
                 } elseif ($objEvent->source == 'internal') {
                     $strUrl = $this->generateFrontendUrl($objEvent->getRelated('jumpTo')->row());
                 } elseif ($objEvent->source == 'article') {
                     $objArticle = \ArticleModel::findByPk($objEvent->articleId, array('eager' => true));
                     $strUrl = $this->generateFrontendUrl($objArticle->pid, '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
                 } elseif ($objEvent->source == 'external') {
                     $strUrl = $objEvent->url;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objEvent->pid, ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/events/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objEvent->alias != '' ? $objEvent->alias : $objEvent->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'event':
                         $strLink = specialchars($objEvent->title);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         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] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser));
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser));
                     }
                 }
                 break;
                 // News teaser
             // News teaser
             case 'news_teaser':
                 $objTeaser = \NewsModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($objTeaser->teaser);
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($objTeaser->teaser);
                     }
                 }
                 break;
                 // Event teaser
             // Event teaser
             case 'event_teaser':
                 $objTeaser = \CalendarEventsModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($objTeaser->teaser);
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($objTeaser->teaser);
                     }
                 }
                 break;
                 // News feed URL
             // News feed URL
             case 'news_feed':
开发者ID:rikaix,项目名称:core,代码行数:67,代码来源:Controller.php

示例11: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     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 ($objEvent === 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->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>';
         return;
     }
     // Overwrite the page title
     if ($objEvent->title != '') {
         $objPage->pageTitle = strip_insert_tags($objEvent->title);
     }
     // Overwrite the page description
     if ($objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($objEvent->teaser);
     }
     $span = \Calendar::calculateSpan($objEvent->startTime, $objEvent->endTime);
     if ($objPage->outputFormat == 'xhtml') {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
     } else {
         $strTimeStart = '<time datetime="' . date('Y-m-d\\TH:i:sP', $objEvent->startTime) . '">';
         $strTimeEnd = '<time datetime="' . date('Y-m-d\\TH:i:sP', $objEvent->endTime) . '">';
         $strTimeClose = '</time>';
     }
     // Get date
     if ($span > 0) {
         $date = $strTimeStart . $this->parseDate($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $objEvent->startTime) . $strTimeClose . ' - ' . $strTimeEnd . $this->parseDate($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $objEvent->endTime) . $strTimeClose;
     } elseif ($objEvent->startTime == $objEvent->endTime) {
         $date = $strTimeStart . $this->parseDate($objPage->dateFormat, $objEvent->startTime) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $objEvent->startTime) . ')' : '') . $strTimeClose;
     } else {
         $date = $strTimeStart . $this->parseDate($objPage->dateFormat, $objEvent->startTime) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $objEvent->startTime) . $strTimeClose . ' - ' . $strTimeEnd . $this->parseDate($objPage->timeFormat, $objEvent->endTime) . ')' : '') . $strTimeClose;
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         $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'], $this->parseDate($objPage->dateFormat, $objEvent->repeatEnd));
         }
     }
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0) {
             $objEvent->size = $this->imgSize;
         }
     }
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData($objEvent->row());
     $objTemplate->date = $date;
     $objTemplate->start = $objEvent->startTime;
     $objTemplate->end = $objEvent->endTime;
     $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
     $objTemplate->recurring = $recurring;
     $objTemplate->until = $until;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $objEvent->details = \String::toXhtml($objEvent->details);
     } else {
         $objEvent->details = \String::toHtml5($objEvent->details);
     }
     $objTemplate->details = \String::encodeEmail($objEvent->details);
     $objTemplate->addImage = false;
     // Add an image
     if ($objEvent->addImage && $objEvent->singleSRC != '') {
         if (!is_numeric($objEvent->singleSRC)) {
             $objTemplate->details = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } else {
             $objModel = \FilesModel::findByPk($objEvent->singleSRC);
             if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                 $objEvent->singleSRC = $objModel->path;
                 $this->addImageToTemplate($objTemplate, $objEvent->row());
             }
         }
     }
     $objTemplate->enclosure = array();
     // Add enclosures
     if ($objEvent->addEnclosure) {
         $this->addEnclosuresToTemplate($objTemplate, $objEvent->row());
     }
     $this->Template->event = $objTemplate->parse();
     // HOOK: comments extension required
     if ($objEvent->noComments || !in_array('comments', $this->Config->getActiveModules())) {
//.........这里部分代码省略.........
开发者ID:rikaix,项目名称:core,代码行数:101,代码来源:ModuleEventReader.php

示例12: replace


//.........这里部分代码省略.........
                     }
                 } 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':
                         $strLink = specialchars($objEvent->title);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         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] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache));
                     } else {
                         $arrCache[$strTag] = \String::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] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache));
                     } else {
                         $arrCache[$strTag] = \String::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] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache));
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache));
                     }
                 }
                 break;
                 // News feed URL
             // News feed URL
             case 'news_feed':
开发者ID:juergen83,项目名称:contao,代码行数:67,代码来源:InsertTags.php

示例13: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     if ($this->blnNoMarkup) {
         /** @var \FrontendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('mod_article_plain');
         $this->Template = $objTemplate;
         $this->Template->setData($this->arrData);
     }
     $alias = $this->alias ?: 'article';
     if (in_array($alias, array('article', 'top', 'wrapper', 'header', 'container', 'left', 'main', 'right', 'footer'))) {
         $alias .= '-' . $this->id;
     }
     $alias = standardize($alias);
     // Generate the cssID if it is not set
     if ($this->cssID[0] == '') {
         $this->cssID = array($alias, $this->cssID[1]);
     }
     $this->Template->column = $this->inColumn;
     // Add the modification date
     $this->Template->timestamp = $this->tstamp;
     $this->Template->date = \Date::parse($objPage->datimFormat, $this->tstamp);
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->teaser = \String::toXhtml($this->teaser);
     } else {
         $this->teaser = \String::toHtml5($this->teaser);
     }
     // Show the teaser only
     if ($this->multiMode && $this->showTeaser) {
         /** @var \FrontendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('mod_article_teaser');
         $this->Template = $objTemplate;
         $this->Template->setData($this->arrData);
         $this->cssID = array($alias, '');
         $arrCss = deserialize($this->teaserCssID);
         // Override the CSS ID and class
         if (is_array($arrCss) && count($arrCss) == 2) {
             if ($arrCss[0] == '') {
                 $arrCss[0] = $alias;
             }
             $this->cssID = $arrCss;
         }
         $article = !\Config::get('disableAlias') && $this->alias != '' ? $this->alias : $this->id;
         $href = '/articles/' . ($this->inColumn != 'main' ? $this->inColumn . ':' : '') . $article;
         $this->Template->headline = $this->headline;
         $this->Template->href = $this->generateFrontendUrl($objPage->row(), $href);
         $this->Template->teaser = $this->teaser;
         $this->Template->readMore = 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(strip_insert_tags($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 = 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;
//.........这里部分代码省略.........
开发者ID:juergen83,项目名称:contao,代码行数:101,代码来源:ModuleArticle.php

示例14: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     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 ($objFaq === 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->error = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     // Overwrite the page title and description
     if ($objFaq->question != '') {
         $objPage->pageTitle = 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 = \String::toXhtml($objFaq->answer);
     } else {
         $objFaq->answer = \String::toHtml5($objFaq->answer);
     }
     $this->Template->answer = \String::encodeEmail($objFaq->answer);
     $this->Template->addImage = false;
     // Add image
     if ($objFaq->addImage && $objFaq->singleSRC != '') {
         if (!is_numeric($objFaq->singleSRC)) {
             $this->Template->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } else {
             $objModel = \FilesModel::findByPk($objFaq->singleSRC);
             if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                 $objFaq->singleSRC = $objModel->path;
                 $this->addImageToTemplate($this->Template, $objFaq->row());
             }
         }
     }
     $this->Template->enclosure = array();
     // Add enclosure
     if ($objFaq->addEnclosure) {
         $this->addEnclosuresToTemplate($this->Template, $objFaq->row());
     }
     $this->Template->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name);
     // HOOK: comments extension required
     if ($objFaq->noComments || !in_array('comments', $this->Config->getActiveModules())) {
         $this->Template->allowComments = false;
         return;
     }
     $objCategory = $objFaq->getRelated('pid');
     // Check whether comments are allowed
     if (!$objCategory->allowComments) {
         $this->Template->allowComments = false;
         return;
     }
     $this->Template->allowComments = true;
     // 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') {
         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);
 }
开发者ID:rikaix,项目名称:core,代码行数:87,代码来源:ModuleFaqReader.php

示例15: addEvent

 /**
  * Add an event to the array of active events
  * @param object
  * @param integer
  * @param integer
  * @param string
  * @param integer
  * @param integer
  * @param integer
  */
 protected function addEvent($objEvents, $intStart, $intEnd, $strUrl, $intBegin, $intLimit, $intCalendar)
 {
     global $objPage;
     $intDate = $intStart;
     $intKey = date('Ymd', $intStart);
     $span = \Calendar::calculateSpan($intStart, $intEnd);
     $strDate = $this->parseDate($objPage->dateFormat, $intStart);
     $strDay = $GLOBALS['TL_LANG']['DAYS'][date('w', $intStart)];
     $strMonth = $GLOBALS['TL_LANG']['MONTHS'][date('n', $intStart) - 1];
     if ($span > 0) {
         $strDate = $this->parseDate($objPage->dateFormat, $intStart) . ' - ' . $this->parseDate($objPage->dateFormat, $intEnd);
         $strDay = '';
     }
     $strTime = '';
     if ($objEvents->addTime) {
         if ($span > 0) {
             $strDate = $this->parseDate($objPage->datimFormat, $intStart) . ' - ' . $this->parseDate($objPage->datimFormat, $intEnd);
         } elseif ($intStart == $intEnd) {
             $strTime = $this->parseDate($objPage->timeFormat, $intStart);
         } else {
             $strTime = $this->parseDate($objPage->timeFormat, $intStart) . ' - ' . $this->parseDate($objPage->timeFormat, $intEnd);
         }
     }
     // Store raw data
     $arrEvent = $objEvents->row();
     // Overwrite some settings
     $arrEvent['time'] = $strTime;
     $arrEvent['date'] = $strDate;
     $arrEvent['day'] = $strDay;
     $arrEvent['month'] = $strMonth;
     $arrEvent['parent'] = $intCalendar;
     $arrEvent['link'] = $objEvents->title;
     $arrEvent['target'] = '';
     $arrEvent['title'] = specialchars($objEvents->title, true);
     $arrEvent['href'] = $this->generateEventUrl($objEvents, $strUrl);
     $arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
     $arrEvent['details'] = \String::encodeEmail($objEvents->details);
     $arrEvent['start'] = $intStart;
     $arrEvent['end'] = $intEnd;
     // Override the link target
     if ($objEvents->source == 'external' && $objEvents->target) {
         $arrEvent['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
     // Clean the RTE output
     if ($arrEvent['teaser'] != '') {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['teaser'] = \String::toXhtml($arrEvent['teaser']);
         } else {
             $arrEvent['teaser'] = \String::toHtml5($arrEvent['teaser']);
         }
     }
     // Display the "read more" button for external/article links
     if (($objEvents->source == 'external' || $objEvents->source == 'article') && $objEvents->details == '') {
         $arrEvent['details'] = true;
     } else {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['details'] = \String::toXhtml($arrEvent['details']);
         } else {
             $arrEvent['details'] = \String::toHtml5($arrEvent['details']);
         }
     }
     // Get todays start and end timestamp
     if ($this->intTodayBegin === null) {
         $this->intTodayBegin = strtotime('00:00:00');
     }
     if ($this->intTodayEnd === null) {
         $this->intTodayEnd = strtotime('23:59:59');
     }
     // Mark past and upcoming events (see #3692)
     if ($intEnd < $this->intTodayBegin) {
         $arrEvent['class'] .= ' bygone';
     } elseif ($intStart > $this->intTodayEnd) {
         $arrEvent['class'] .= ' upcoming';
     } else {
         $arrEvent['class'] .= ' current';
     }
     $this->arrEvents[$intKey][$intStart][] = $arrEvent;
     // Multi-day event
     for ($i = 1; $i <= $span && $intDate <= $intLimit; $i++) {
         // Only show first occurrence
         if ($this->cal_noSpan && $intDate >= $intBegin) {
             break;
         }
         $intDate = strtotime('+ 1 day', $intDate);
         $intNextKey = date('Ymd', $intDate);
         $this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
     }
 }
开发者ID:rikaix,项目名称:core,代码行数:98,代码来源:Events.php


注:本文中的String::toXhtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。