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


PHP Sanitizer::sanitizeAndTruncateHTML方法代码示例

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


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

示例1: initializeForPage

 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'index':
             $links = array(array('title' => 'Text', 'url' => $this->buildBreadcrumbURL('text', array())), array('title' => 'Navigation Lists', 'url' => $this->buildBreadcrumbURL('nav', array())), array('title' => 'Results Lists', 'url' => $this->buildBreadcrumbURL('results', array())), array('title' => 'Search', 'url' => $this->buildBreadcrumbURL('search', array())), array('title' => 'Detail', 'url' => $this->buildBreadcrumbURL('detail', array())));
             if ($this->browser == 'native') {
                 $links[] = array('title' => 'AppQ Dialogs', 'url' => $this->buildBreadcrumbURL('dialogs', array()));
                 $links[] = array('title' => 'Truncation Form Post', 'url' => $this->buildBreadcrumbURL('truncate', array()));
             }
             $this->assign('links', $links);
             break;
         case 'text':
             break;
         case 'search':
             $formFields = $this->loadPageConfigFile($this->page, false);
             foreach ($formFields as $i => $formField) {
                 if (isset($formField['option_keys'])) {
                     $options = array();
                     foreach ($formField['option_keys'] as $j => $optionKey) {
                         $options[$optionKey] = $formField['option_values'][$j];
                     }
                     $formFields[$i]['options'] = $options;
                     unset($formFields[$i]['option_keys']);
                     unset($formFields[$i]['option_values']);
                 }
             }
             $this->assign('formFields', $formFields);
             break;
         case 'results':
             if ($title = $this->getArg('title')) {
                 $this->setPageTitles($title);
             }
             $this->assign('next', 'Next');
             $this->assign('prev', 'Prev');
             $this->assign('nextURL', $this->buildBreadcrumbURL($this->page, $this->args, false));
             $this->assign('prevURL', $this->buildBreadcrumbURL($this->page, $this->args, false));
             $this->assign('lists', $this->getListsForPage($this->page));
             break;
         case 'nav':
             if ($title = $this->getArg('title')) {
                 $this->setPageTitles($title);
             }
             $this->assign('lists', $this->getListsForPage($this->page));
             break;
         case 'articles':
             $this->setWebBridgePageRefresh(true);
             $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
             $this->addOnLoad('setupListing();');
             $this->assign('articles', $this->getListsForPage($this->page));
             break;
         case 'detail':
             $detailConfig = $this->loadPageConfigFile('detail', 'detailConfig');
             if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) {
                 $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_ITEM'));
                 $this->assign('shareEmailURL', 'john.smith@gmail.com');
                 $this->assign('shareRemark', 'This is a share remark');
                 $this->assign('shareURL', 'This is a share URL');
             }
             if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) {
                 $this->generateBookmarkOptions('fakeid');
             }
             $this->enableTabs(array_keys($detailConfig['tabs']));
             break;
         case 'dialogs':
             $buttons = array();
             $configs = $this->loadPageConfigFile($this->page, false);
             foreach ($configs as $config) {
                 if (!isset($config['title'], $config['description'], $config['api'], $config['arguments'])) {
                     continue;
                 }
                 $buttons[] = array('title' => $config['title'], 'description' => $config['description'], 'javascript' => "kgoBridge.{$config['api']}(" . implode(', ', $config['arguments']) . ", null, function (error, params) { alert('You clicked button type \\''+params['button']+'\\''); }); return false;");
             }
             $this->assign('buttons', $buttons);
             break;
         case 'truncate':
             $this->assign('action', $this->buildBreadcrumbURL('truncated', array()));
             break;
         case 'truncated':
             $length = $this->getArg('length', 0);
             $margin = $this->getArg('margin', 0);
             $minLineLength = $this->getArg('minLineLength', 40);
             $html = $this->getArg('html', '');
             if ($length && $margin && $html) {
                 $html = Sanitizer::sanitizeAndTruncateHTML($html, $truncated, $length, $margin, $minLineLength);
             }
             $this->assign('html', $html);
             break;
     }
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:89,代码来源:KitchensinkWebModule.php

示例2: initializeForPage

 protected function initializeForPage()
 {
     if (!$this->feed) {
         throw new KurogoConfigurationException($this->getLocalizedString('ERROR_NOT_CONFIGURED'));
     }
     switch ($this->page) {
         case 'story':
             $searchTerms = $this->getArg('filter', false);
             if ($searchTerms) {
                 $this->feed->setOption('search', $searchTerms);
             }
             $storyID = $this->getArg(array('id', 'storyID'), false);
             $storyPage = $this->getArg('storyPage', '0');
             $story = $this->feed->getItem($storyID);
             $ajax = $this->getArg('ajax', false);
             if (!$story) {
                 throw new KurogoUserException($this->getLocalizedString('ERROR_STORY_NOT_FOUND', $storyID));
             }
             $this->setLogData($storyID, $story->getTitle());
             if (!($content = $this->cleanContent($story->getContent()))) {
                 if ($ajax) {
                     $content = $story->getDescription();
                     if ($url = $story->getLink()) {
                         $content .= $this->getLocalizedString('READ_MORE_LINK', $url);
                     }
                 } else {
                     if ($url = $story->getLink()) {
                         Kurogo::redirectToURL($url);
                     }
                     // no content or link. Attempt to get description
                     if (!($content = $story->getDescription())) {
                         throw new KurogoDataException($this->getLocalizedString('ERROR_CONTENT_NOT_FOUND', $storyID));
                     }
                 }
             }
             if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) {
                 $truncated = false;
                 $body = Sanitizer::sanitizeAndTruncateHTML($story->getDescription(), $truncated, $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MAX_LENGTH', 500), $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MAX_LENGTH_MARGIN', 50), $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MIN_LINE_LENGTH', 50), '') . "\n\n" . $story->getLink();
                 $shareEmailURL = $this->buildMailToLink("", $story->getTitle(), $body);
                 $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_STORY'));
                 $this->assign('shareEmailURL', $shareEmailURL);
                 $this->assign('shareRemark', $story->getTitle());
                 $this->assign('storyURL', $story->getLink());
             }
             if ($pubDate = $story->getPubDate()) {
                 $date = DateFormatter::formatDate($pubDate, DateFormatter::LONG_STYLE, DateFormatter::NO_STYLE);
             } else {
                 $date = "";
             }
             $this->enablePager($content, $this->feed->getEncoding(), $storyPage);
             $this->assign('date', $date);
             $this->assign('title', $this->htmlEncodeFeedString($story->getTitle()));
             $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor()));
             $this->assign('link', $story->getLink());
             $this->assign('showLink', $this->showLink);
             $this->assign('showBodyImage', $this->showBodyImage);
             $this->assign('showBodyThumbnail', $this->showBodyThumbnail);
             $this->assign('showBodyPubDate', $this->showBodyPubDate);
             $this->assign('showBodyAuthor', $this->showBodyAuthor);
             if ($this->showImages) {
                 if ($image = $story->getImage()) {
                     $this->assign('image', array('src' => $image->getURL(), 'width' => $image->getWidth(), 'height' => $image->getHeight()));
                 } elseif ($thumbnail = $story->getThumbnail()) {
                     $this->assign('thumbnail', array('src' => $thumbnail->getURL(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
                 }
             }
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $start = $this->getArg('start', 0);
             if ($searchTerms) {
                 $options = array('start' => $start);
                 $items = $this->searchItems($searchTerms, $this->maxPerPage, $options);
                 $this->setLogData($searchTerms);
                 $totalItems = $this->feed->getTotalItems();
                 $stories = array();
                 $options = array('filter' => $searchTerms, 'feed' => $this->feedIndex);
                 foreach ($items as $story) {
                     $stories[] = $this->linkForItem($story, $options);
                 }
                 $previousURL = '';
                 $nextURL = '';
                 if ($totalItems > $this->maxPerPage) {
                     $args = $this->args;
                     if ($start > 0) {
                         $args['start'] = $start - $this->maxPerPage;
                         $previousURL = $this->buildBreadcrumbURL($this->page, $args, false);
                     }
                     if ($totalItems - $start > $this->maxPerPage) {
                         $args['start'] = $start + $this->maxPerPage;
                         $nextURL = $this->buildBreadcrumbURL($this->page, $args, false);
                     }
                 }
                 $extraArgs = array('feed' => $this->feedIndex);
                 $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
                 $this->addOnLoad('setupNewsListing();');
                 $this->assign('maxPerPage', $this->maxPerPage);
                 $this->assign('extraArgs', $extraArgs);
                 $this->assign('searchTerms', $searchTerms);
                 $this->assign('stories', $stories);
//.........这里部分代码省略.........
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:NewsWebModule.php

示例3: initializeForPage

 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'index':
             $links = array(array('title' => 'Text', 'url' => $this->buildBreadcrumbURL('text', array())), array('title' => 'Navigation Lists', 'url' => $this->buildBreadcrumbURL('nav', array())), array('title' => 'Results Lists', 'url' => $this->buildBreadcrumbURL('results', array())), array('title' => 'Search', 'url' => $this->buildBreadcrumbURL('search', array())), array('title' => 'Detail', 'url' => $this->buildBreadcrumbURL('detail', array())), array('title' => 'Geolocation', 'url' => $this->buildBreadcrumbURL('location', array())), array('title' => 'HTML Truncation Form', 'url' => $this->buildBreadcrumbURL('truncate', array())), array('title' => 'Javascript API Call Test', 'url' => $this->buildBreadcrumbURL('apicall', array())));
             if ($this->browser == 'native') {
                 $appQLinks = array(array('title' => 'Dialogs', 'url' => $this->buildBreadcrumbURL('dialogs', array())), array('title' => 'Refresh Button', 'url' => $this->buildBreadcrumbURL('refresh', array())), array('title' => 'Auto Refresh', 'url' => $this->buildBreadcrumbURL('autorefresh', array())));
                 $this->assign('appQLinks', $appQLinks);
             }
             $this->assign('links', $links);
             break;
         case 'text':
             break;
         case 'apicall':
             break;
         case 'search':
             $formFields = $this->loadPageConfigArea($this->page, false);
             foreach ($formFields as $i => $formField) {
                 if (isset($formField['option_keys'])) {
                     $options = array();
                     foreach ($formField['option_keys'] as $j => $optionKey) {
                         $options[$optionKey] = $formField['option_values'][$j];
                     }
                     $formFields[$i]['options'] = $options;
                     unset($formFields[$i]['option_keys']);
                     unset($formFields[$i]['option_values']);
                 }
             }
             $this->assign('formFields', $formFields);
             break;
         case 'results':
             if ($title = $this->getArg('title')) {
                 $this->setPageTitles($title);
             }
             $this->assign('next', 'Next');
             $this->assign('prev', 'Prev');
             $this->assign('nextURL', $this->buildBreadcrumbURL($this->page, $this->args, false));
             $this->assign('prevURL', $this->buildBreadcrumbURL($this->page, $this->args, false));
             $this->assign('lists', $this->getListsForPage($this->page));
             break;
         case 'nav':
             if ($title = $this->getArg('title')) {
                 $this->setPageTitles($title);
             }
             $this->assign('lists', $this->getListsForPage($this->page));
             break;
         case 'pane':
             $this->assign('lists', $this->getListsForPage($this->page));
             break;
         case 'articles':
             $this->setWebBridgePageRefresh(true);
             $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
             $this->addOnLoad('setupListing();');
             $this->assign('articles', $this->getListsForPage($this->page));
             break;
         case 'detail':
             $detailConfig = $this->loadPageConfigArea('detail', 'detailConfig');
             if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) {
                 $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_ITEM'));
                 $this->assign('shareEmailURL', 'john.smith@gmail.com');
                 $this->assign('shareRemark', 'This is a share remark');
                 $this->assign('shareURL', 'This is a share URL');
             }
             if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) {
                 $this->generateBookmarkOptions('fakeid');
             }
             $this->enableTabs(array_keys($detailConfig['tabs']));
             break;
         case 'dialogs':
             $buttons = array();
             $configs = $this->loadPageConfigArea($this->page, false);
             foreach ($configs as $config) {
                 if (!isset($config['title'], $config['description'], $config['api'], $config['arguments'])) {
                     continue;
                 }
                 $buttons[] = array('title' => $config['title'], 'description' => $config['description'], 'javascript' => "kgoBridge.{$config['api']}(" . implode(', ', $config['arguments']) . ", null, function (error, params) { alert('You clicked button type \\''+params['button']+'\\''); }); return false;");
             }
             $this->assign('buttons', $buttons);
             break;
         case 'location':
             $links = array(array('title' => 'Watch Position Map Test', 'url' => $this->buildBreadcrumbURL('location_full', array())));
             $this->assign('links', $links);
             break;
         case 'location_full':
             $this->addExternalJavascript('http://maps.googleapis.com/maps/api/js?sensor=true');
             $this->addOnLoad('initMap();');
             $this->addInlineJavascript('var locationMarkerURL = "' . FULL_URL_PREFIX . 'common/images/map-location.png";');
             break;
         case 'truncate':
             $this->assign('action', $this->buildBreadcrumbURL('truncated', array()));
             break;
         case 'truncated':
             $length = $this->getArg('length', 0);
             $margin = $this->getArg('margin', 0);
             $minLineLength = $this->getArg('minLineLength', 40);
             $html = $this->getArg('html', '');
             if ($length && $margin && $html) {
                 $html = Sanitizer::sanitizeAndTruncateHTML($html, $truncated, $length, $margin, $minLineLength);
             }
             $this->assign('html', $html);
//.........这里部分代码省略.........
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:KitchensinkWebModule.php

示例4: initializeForPage

 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'news':
             $start = $this->getArg('start', 0);
             $section = $this->getArg('section');
             $newsFeed = $this->getNewsFeed($section);
             $newsFeed->setStart($start);
             $newsFeed->setLimit($this->maxPerPage);
             $items = $newsFeed->items();
             $totalItems = $newsFeed->getTotalItems();
             $this->setLogData($section, $newsFeed->getTitle());
             $previousURL = null;
             $nextURL = null;
             if ($totalItems > $this->maxPerPage) {
                 $args = $this->args;
                 if ($start > 0) {
                     $args['start'] = $start - $this->maxPerPage;
                     $previousURL = $this->buildBreadcrumbURL($this->page, $args, false);
                 }
                 if ($totalItems - $start > $this->maxPerPage) {
                     $args['start'] = $start + $this->maxPerPage;
                     $nextURL = $this->buildBreadcrumbURL($this->page, $args, false);
                 }
             }
             $options = array('section' => $section);
             $stories = array();
             foreach ($items as $story) {
                 $stories[] = $this->linkForNewsItem($story, $options);
             }
             $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
             $this->addOnLoad('setupNewsListing();');
             $this->assign('maxPerPage', $this->maxPerPage);
             $this->assign('stories', $stories);
             $this->assign('previousURL', $previousURL);
             $this->assign('nextURL', $nextURL);
             $this->assign('showImages', $this->showImages);
             $this->assign('showPubDate', $this->showPubDate);
             $this->assign('showAuthor', $this->showAuthor);
             break;
         case 'news_detail':
             $section = $this->getArg('section');
             $gender = $this->getArg('gender');
             $storyID = $this->getArg('storyID', false);
             $storyPage = $this->getArg('storyPage', '0');
             $feed = $this->getNewsFeed($section, $gender);
             $showBodyThumbnail = $this->getOptionalModuleVar('SHOW_BODY_THUMBNAIL', $this->showBodyThumbnail, $section, 'feeds');
             if (!($story = $feed->getItem($storyID))) {
                 throw new KurogoUserException($this->getLocalizedString('ERROR_STORY_NOT_FOUND', $storyID));
             }
             $this->setLogData($storyID, $story->getTitle());
             if (!($content = $this->cleanContent($story->getContent()))) {
                 if ($url = $story->getLink()) {
                     Kurogo::redirectToURL($url);
                 } else {
                     throw new KurogoDataException($this->getLocalizedString('ERROR_CONTENT_NOT_FOUND', $storyID));
                 }
             }
             if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) {
                 $body = Sanitizer::sanitizeAndTruncateHTML($story->getDescription(), $truncated, $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MAX_LENGTH', 500), $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MAX_LENGTH_MARGIN', 50), $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MIN_LINE_LENGTH', 50), '') . "\n\n" . $story->getLink();
                 $shareEmailURL = $this->buildMailToLink("", $story->getTitle(), $body);
                 $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_STORY'));
                 $this->assign('shareEmailURL', $shareEmailURL);
                 $this->assign('shareRemark', $story->getTitle());
                 $this->assign('storyURL', $story->getLink());
             }
             if ($pubDate = $story->getPubDate()) {
                 $date = DateFormatter::formatDate($pubDate, DateFormatter::MEDIUM_STYLE, DateFormatter::NO_STYLE);
             } else {
                 $date = "";
             }
             $this->enablePager($content, $this->newsFeed->getEncoding(), $storyPage);
             $this->assign('date', $date);
             $this->assign('title', $this->htmlEncodeFeedString($story->getTitle()));
             $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor()));
             $this->assign('image', $this->getImageForStory($story));
             $this->assign('thumbnail', $this->getThumbnailForStory($story));
             $this->assign('showBodyThumbnail', $showBodyThumbnail);
             $this->assign('link', $story->getLink());
             $this->assign('showLink', $this->showLink);
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $start = $this->getArg('start', 0);
             $section = $this->getArg('section', 'topnews');
             if ($searchTerms) {
                 $newsFeed = $this->getNewsFeed($section);
                 $newsFeed->setStart($start);
                 $newsFeed->setLimit($this->maxPerPage);
                 $items = $newsFeed->search($searchTerms);
                 $this->setLogData($searchTerms);
                 $totalItems = $newsFeed->getTotalItems();
                 $stories = array();
                 $options = array('start' => $start, 'filter' => $searchTerms, 'section' => $section);
                 foreach ($items as $story) {
                     $stories[] = $this->linkForNewsItem($story, $options);
                 }
                 $previousURL = '';
                 $nextURL = '';
                 if ($totalItems > $this->maxPerPage) {
//.........这里部分代码省略.........
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AthleticsWebModule.php


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