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


PHP modX::stripTags方法代码示例

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


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

示例1: addAliases

 /**
  * @param $string
  *
  * @return mixed
  */
 public function addAliases($string)
 {
     $string = mb_strtoupper(str_ireplace('ё', 'е', $this->modx->stripTags($string)), 'UTF-8');
     $string = preg_replace('#\\[.*\\]#isU', '', $string);
     $pcre = $this->config['split_words'];
     $words = preg_split($pcre, $string, -1, PREG_SPLIT_NO_EMPTY);
     $words = array_unique($words);
     $forms = $this->getBaseForms($words, false);
     $q = $this->modx->newQuery('mseAlias', array('word:IN' => array_merge($words, array_keys($forms))));
     $q->select('word,alias,replace');
     $tstart = microtime(true);
     if ($q->prepare() && $q->stmt->execute()) {
         $this->modx->queryTime += microtime(true) - $tstart;
         $this->modx->executedQueries++;
         while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
             if ($row['replace']) {
                 $all = current($this->getAllForms($row['word']));
                 $all[] = $row['word'];
                 foreach ($all as $word) {
                     $key = array_search(mb_strtolower($word), $words);
                     if ($key !== false) {
                         $words[$key] = $row['alias'];
                     }
                 }
             } else {
                 $words[] = $row['alias'];
             }
         }
     }
     $words = array_unique($words);
     return implode(' ', $words);
 }
开发者ID:svyatoslavteterin,项目名称:belton.by,代码行数:37,代码来源:msearch2.class.php

示例2: findTags

 /**
  * @param string $content
  * @param array $tags
  */
 public function findTags($content, &$tags)
 {
     $parser = $this->modx->getParser();
     $collectedTags = array();
     $parser->collectElementTags($content, $collectedTags);
     foreach ($collectedTags as $tag) {
         $tagName = $tag[1];
         if (substr($tagName, 0, 1) == '!') {
             $tagName = substr($tagName, 1);
         }
         $token = substr($tagName, 0, 1);
         $tagParts = xPDO::escSplit('?', $tagName, '`', 2);
         $tagName = trim($tagParts[0]);
         $tagPropString = null;
         $tagName = trim($this->modx->stripTags($tagName));
         if (in_array($token, array('$', '+', '~', '#', '%', '-', '*'))) {
             $tagName = substr($tagName, 1);
         }
         switch ($token) {
             case '$':
                 $class = 'modChunk';
                 break;
             case '+':
             case '~':
             case '#':
             case '%':
             case '-':
             case '*':
                 continue 2;
                 break;
             default:
                 $class = 'modSnippet';
                 break;
         }
         if (isset($tagParts[1])) {
             $tagPropString = trim($tagParts[1]);
             $this->findTags($tagPropString, $tags);
             $element = $parser->getElement($class, $tagName);
             if ($element) {
                 $properties = $element->getProperties($tagPropString);
             } else {
                 $properties = array();
             }
         } else {
             $properties = array();
         }
         $this->debug('Found ' . $class . ' ' . $tagName . ' with properties ' . print_r($properties, 1));
         $tagName = $parser->realname($tagName);
         if (empty($tagName)) {
             continue;
         }
         $tags[$tagName] = array('name' => $tagName, 'class' => $class);
         foreach ($properties as $property) {
             $prop = trim($property);
             if (!empty($prop) && !is_numeric($prop) && is_string($prop)) {
                 $tags[$prop] = array('name' => $prop, 'class' => 'modChunk', 'isProperty' => true);
             }
         }
     }
 }
开发者ID:Jako,项目名称:modDevTools,代码行数:64,代码来源:moddevtools.class.php

示例3: simpleSearch

 /**
  * Search and return array with resources that matched for LIKE search
  *
  * @param $query
  *
  * @return array
  */
 public function simpleSearch($query)
 {
     $string = preg_replace('/[^_-а-яёa-z0-9\\s\\.\\/]+/iu', ' ', $this->modx->stripTags($query));
     $result = array();
     $q = $this->modx->newQuery('mseIntro');
     $q->select('`resource`');
     $q->where(array('intro:LIKE' => '%' . $string . '%'));
     if ($q->prepare() && $q->stmt->execute()) {
         $result = $q->stmt->fetchAll(PDO::FETCH_COLUMN);
     }
     return $result;
 }
开发者ID:bendasvadim,项目名称:mSearch2,代码行数:19,代码来源:msearch2.class.php

示例4: sanitize

 /**
  * Sanitize a string
  *
  * @param string $text The text to sanitize
  * @return string The sanitized text
  */
 public function sanitize($text)
 {
     $text = strip_tags($text);
     $text = preg_replace('/(\\[\\[\\+.*?\\]\\])/i', '', $text);
     return $this->modx->stripTags($text);
 }
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:12,代码来源:simplesearch.class.php

示例5: cleanAlias

 /**
  * Transforms a string to form a valid URL representation.
  *
  * @param string $alias A string to transform into a valid URL representation.
  * @param array $options Options to append to or override configuration settings.
  * @return string The transformed string.
  */
 public function cleanAlias($alias, array $options = array())
 {
     /* setup the various options */
     $iconv = function_exists('iconv');
     $mbext = function_exists('mb_strlen') && (bool) $this->xpdo->getOption('use_multibyte', false);
     $charset = strtoupper((string) $this->xpdo->getOption('modx_charset', $options, 'UTF-8'));
     $delimiter = $this->xpdo->getOption('friendly_alias_word_delimiter', $options, '-');
     $delimiters = $this->xpdo->getOption('friendly_alias_word_delimiters', $options, '-_');
     $maxlength = (int) $this->xpdo->getOption('friendly_alias_max_length', $options, 0);
     $stripElementTags = (bool) $this->xpdo->getOption('friendly_alias_strip_element_tags', $options, true);
     $trimchars = $this->xpdo->getOption('friendly_alias_trim_chars', $options, '/.' . $delimiters);
     $restrictchars = $this->xpdo->getOption('friendly_alias_restrict_chars', $options, 'pattern');
     $restrictcharspattern = $this->xpdo->getOption('friendly_alias_restrict_chars_pattern', $options, '/[\\0\\x0B\\t\\n\\r\\f\\a&=+%#<>"~`@\\?\\[\\]\\{\\}\\|\\^\'\\\\]/');
     $lowercase = (bool) $this->xpdo->getOption('friendly_alias_lowercase_only', $options, true);
     $translit = $this->xpdo->getOption('friendly_alias_translit', $options, $iconv ? 'iconv' : 'none');
     $translitClass = $this->xpdo->getOption('friendly_alias_translit_class', $options, 'translit.modTransliterate');
     /* strip html and optionally MODX element tags (stripped by default) */
     if ($this->xpdo instanceof modX) {
         $alias = $this->xpdo->stripTags($alias, '', $stripElementTags ? array() : null);
     }
     /* replace &nbsp; with the specified word delimiter */
     $alias = str_replace('&nbsp;', $delimiter, $alias);
     /* decode named entities to the appropriate character for the character set */
     $alias = html_entity_decode($alias, ENT_QUOTES, $charset);
     /* replace any remaining & with a lexicon value if available */
     if ($this->xpdo instanceof modX && $this->xpdo->getService('lexicon', 'modLexicon')) {
         $alias = str_replace('&', $this->xpdo->lexicon('and') ? ' ' . $this->xpdo->lexicon('and') . ' ' : ' and ', $alias);
     }
     /* apply transliteration as configured */
     switch ($translit) {
         case '':
         case 'none':
             /* no transliteration */
             break;
         case 'iconv':
             /* if iconv is available, use the built-in transliteration it provides */
             $alias = iconv($mbext ? mb_detect_encoding($alias) : $charset, $charset . '//TRANSLIT//IGNORE', $alias);
             break;
         default:
             /* otherwise look for a transliteration service class that will accept named transliteration tables */
             if ($this->xpdo instanceof modX) {
                 $translitClassPath = $this->xpdo->getOption('friendly_alias_translit_class_path', $options, $this->xpdo->getOption('core_path', $options, MODX_CORE_PATH) . 'components/');
                 if ($this->xpdo->getService('translit', $translitClass, $translitClassPath, $options)) {
                     $alias = $this->xpdo->translit->translate($alias, $translit);
                 }
             }
             break;
     }
     /* restrict characters as configured */
     switch ($restrictchars) {
         case 'alphanumeric':
             /* restrict alias to alphanumeric characters only */
             $alias = preg_replace('/[^\\.%A-Za-z0-9 _-]/', '', $alias);
             break;
         case 'alpha':
             /* restrict alias to alpha characters only */
             $alias = preg_replace('/[^\\.%A-Za-z _-]/', '', $alias);
             break;
         case 'legal':
             /* restrict alias to legal URL characters only */
             $alias = preg_replace('/[\\0\\x0B\\t\\n\\r\\f\\a&=+%#<>"~`@\\?\\[\\]\\{\\}\\|\\^\'\\\\]/', '', $alias);
             break;
         case 'pattern':
         default:
             /* restrict alias using regular expression pattern configured (same as legal by default) */
             if (!empty($restrictcharspattern)) {
                 $alias = preg_replace($restrictcharspattern, '', $alias);
             }
     }
     /* replace one or more space characters with word delimiter */
     $alias = preg_replace('/\\s+/u', $delimiter, $alias);
     /* replace one or more instances of word delimiters with word delimiter */
     $delimiterTokens = array();
     for ($d = 0; $d < strlen($delimiters); $d++) {
         $delimiterTokens[] = $delimiters[$d];
     }
     $delimiterPattern = '/[' . implode('|', $delimiterTokens) . ']+/';
     $alias = preg_replace($delimiterPattern, $delimiter, $alias);
     /* unless lowercase_only preference is explicitly off, change case to lowercase */
     if ($lowercase) {
         if ($mbext) {
             /* if the mb extension is available use it to protect multi-byte chars */
             $alias = mb_convert_case($alias, MB_CASE_LOWER, $charset);
         } else {
             /* otherwise, just use strtolower */
             $alias = strtolower($alias);
         }
     }
     /* trim specified chars from both ends of the alias */
     $alias = trim($alias, $trimchars);
     /* get the strlen of the alias (use mb extension if available) */
     $length = $mbext ? mb_strlen($alias, $charset) : strlen($alias);
     /* if maxlength is specified and exceeded, return substr with additional trim applied */
//.........这里部分代码省略.........
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:101,代码来源:modresource.class.php


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