當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StringHelper::stripHtml方法代碼示例

本文整理匯總了PHP中StringHelper::stripHtml方法的典型用法代碼示例。如果您正苦於以下問題:PHP StringHelper::stripHtml方法的具體用法?PHP StringHelper::stripHtml怎麽用?PHP StringHelper::stripHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在StringHelper的用法示例。


在下文中一共展示了StringHelper::stripHtml方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createSlug

 /**
  * Creates a slug based on a given string.
  *
  * @param string $str
  *
  * @return string
  */
 public static function createSlug($str)
 {
     // Remove HTML tags
     $str = StringHelper::stripHtml($str);
     // Convert to kebab case
     $glue = craft()->config->get('slugWordSeparator');
     $lower = !craft()->config->get('allowUppercaseInSlug');
     $str = StringHelper::toKebabCase($str, $glue, $lower, false);
     return $str;
 }
開發者ID:jmstan,項目名稱:craft-website,代碼行數:17,代碼來源:ElementHelper.php

示例2: getTableAttributeHtml

 /**
  * @inheritDoc IPreviewableFieldType::getTableAttributeHtml()
  *
  * @param mixed $value
  *
  * @return string
  */
 public function getTableAttributeHtml($value)
 {
     $value = (string) $value;
     return StringHelper::stripHtml($value);
 }
開發者ID:sweetroll,項目名稱:craft-test,代碼行數:12,代碼來源:BaseFieldType.php

示例3: _getElementExcerpt

 /**
  * Get an element's excerpt.
  *
  * @param array $element
  *
  * @return string
  */
 private function _getElementExcerpt($element)
 {
     // What is our excerpt key?
     $excerptKey = $this->_getCollectionSetting('excerptKey');
     // Do we have an excerpt option?
     if (empty($excerptKey) || !isset($element[$excerptKey])) {
         return '';
     }
     // Get our full string
     $fullString = $element[$excerptKey];
     // Strip HTML from string
     $fullString = StringHelper::stripHtml($fullString);
     // Do we even have keywords?
     if (!$this->_keywords) {
         return $fullString;
     }
     // Excerpt settings
     $prefix = $this->_excerptPrefix;
     $suffix = $this->_excerptSuffix;
     // Where are the keywords located?
     $keywordsPosition = stripos($fullString, $this->_keywords);
     // Find start
     $extractStart = $keywordsPosition - $this->_charsBeforeKeywords;
     if ($extractStart < 0) {
         $extractStart = 0;
         $prefix = '';
     }
     // Find end
     $extractEnd = $keywordsPosition + strlen($this->_keywords) + $this->_charsAfterKeywords;
     if ($extractEnd > strlen($fullString)) {
         $extractEnd = strlen($fullString);
         $suffix = '';
     }
     // Get excerpt!
     $plainText = substr($fullString, $extractStart, $extractEnd - $extractStart);
     $plainText = preg_replace("/(" . $this->_keywords . ")/i", "<strong>\$1</strong>", StringHelper::convertToUTF8($plainText));
     // Handle CP request differently, otherwise while testing, the excerpt has become an object
     if (craft()->request->isCpRequest()) {
         return $prefix . $plainText . $suffix;
     }
     return new \Twig_Markup($prefix . $plainText . $suffix, craft()->templates->getTwig()->getCharset());
 }
開發者ID:am-impact,項目名稱:amsearch,代碼行數:49,代碼來源:AmSearch_SearchService.php


注:本文中的StringHelper::stripHtml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。