多个关键词（标签字符串）统一格式

关键词直接用半角逗号隔开

@param string $keywords
@return string
338244
public static function keywordsFormat($keywords) {
		$keywords = trim($keywords, ', ');

		if($keywords) {
			$keywords = htmlspecialchars(strip_tags($keywords)); // 去掉html和特殊符号
			$keywords = preg_replace("/(\\r\\n\\s|\\-|\\||，|、|　)/s", ",", $keywords); // 将空格，全角符号转为半角符号
			$keywords = preg_replace("/,+/", ",", $keywords);

			// 去掉重复的标签
			$keywords = explode(',', $keywords);
			$keywords = array_unique($keywords);
			$keywords = implode(',', $keywords);
		}

		return $keywords;
	}
753701
public static function getKeywordSuggestionsFromGoogle($keyword)
    {
        $data = self::curl('http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl=en-US&q='.urlencode($keyword));
        if (($data = json_decode($data, true)) !== null && !empty($data[1])) {
            return $data[1];
        }

        return false;
    }
938080
public function setHeadwords($headwords)
    {
        $results = [];
        foreach ($headwords as $headword) {
            $results[] = $this->setHeadword($headword);
        }
        return $results;
    }
982031
public function getKeyword($keyword, $lang = null)
    {
        $parts = $this->_callInternalLocale('getKeywords', null, $lang, false);
        return isset($parts[$keyword]) ? $parts[$keyword] : null;
    }
1286492
protected function getKeyword($key): Keyword
    {
        if ($key instanceof Keyword) {
            return $key;
        }

        if (! isset($this->cachedKeyword[$key])) {
            $this->cachedKeyword[$key] = Keyword::make($key);
        }

        return $this->cachedKeyword[$key];
    }
115509
public function getKeywordsFromElements(&$elements = array())
    {
        if (0 === count($elements)) {
            return array();
        }

        $uids = array();
        $assoc = array();
        foreach ($elements as &$element) {
            if ($element instanceof Keyword) {
                $uids[] = $element->value;
                $assoc[$element->value] = &$element;
            } elseif (true === is_string($element)) {
                $uids[] = trim($element);
            }
        }
        unset($element);

        $objects = $this->createQueryBuilder('k')
                ->where('k._uid IN (:uids)')
                ->setParameter('uids', $uids)
                ->getQuery()
                ->getResult();

        foreach ($objects as $object) {
            if (true === array_key_exists($object->getUid(), $assoc)) {
                $assoc[$object->getUid()]->setParam('objectkeyword', [$object]);
            }
        }

        return $objects;
    }
16200
public function setKeywords($keywords)
    {
        self::writeFullTag(
            $keywords,
            'keywords',
            false,
            'news:keywords',
            $this->validator,
            'validateKeywords',
            $this->exception,
            'Provided keyword list is not a valid value.'
        );

        return $this;
    }
354386
protected function globalSearch($keyword)
    {
        $keyword = $this->config->isCaseInsensitive() ? Str::lower($keyword) : $keyword;

        $this->collection = $this->collection->filter(function ($row) use ($keyword) {
            $this->isFilterApplied = true;

            $data = $this->serialize($row);
            foreach ($this->request->searchableColumnIndex() as $index) {
                $column = $this->getColumnName($index);
                $value = Arr::get($data, $column);
                if (! $value || is_array($value)) {
                    if (! is_numeric($value)) {
                        continue;
                    }

                    $value = (string) $value;
                }

                $value = $this->config->isCaseInsensitive() ? Str::lower($value) : $value;
                if (Str::contains($value, $keyword)) {
                    return true;
                }
            }

            return false;
        });
    }
730958
public function buildTrigrams($keyword)
    {
        $t        = "__".$keyword."__";
        $trigrams = "";
        for ($i = 0; $i < strlen($t) - 2; $i++) {
            $trigrams .= mb_substr($t, $i, 3)." ";
        }

        return trim($trigrams);
    }
981779
public function getSecret($words) {
    $words = explode(' ', $words);
    $w = array();
    $x = '';
    foreach($words as $word) {
      if(trim($word) !== '') {
        list($key) = array_keys($this->dictionary, $word);
        $w[] = $key;
      }
      if(sizeof($w) === 3) {
        $xI = $w[0] + $this->n * $this->_mod($w[1] - $w[0], $this->n) + pow($this->n, 2) * $this->_mod($w[2] - $w[1], $this->n);
        $hexI = dechex($xI);
        if(strlen($hexI) === 7) {
          $x .= '0'.$hexI;
        } else {
          $x .= $hexI;
        }


        $w = array();
      }
    }
    return $x;


  }
431082
public function getKeyword($text)
    {
        $found = null;
        $text = trim($text);
        $iText = strtoupper(TextNormalizer::stripDiacritics($text));
        foreach ($this->keywords as $keyword) {
            /** @var Keyword $keyword */
            $tmpText = trim($keyword->getText());
            if ($tmpText === $text
                || (
                    empty($keyword->isCaseSensitive()) &&
                    strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText)
            ) {
                $found = $keyword;
                break;
            }
        }

        return $found;
    }
563378
protected function _prepareMetaKeyword($keywords, $removeDuplicatedWords = true)
    {
        $keywords = '';
        if (($activeCategory = $this->getActiveCategory())) {
            $keywordsList = [];

            if ($categoryTree = $this->getCategoryTree()) {
                foreach ($categoryTree->getPath() as $category) {
                    $keywordsList[] = trim($category->oxcategories__oxtitle->value);
                }
            }

            $subCategories = $activeCategory->getSubCats();
            if (is_array($subCategories)) {
                foreach ($subCategories as $subCategory) {
                    $keywordsList[] = $subCategory->oxcategories__oxtitle->value;
                }
            }

            if (count($keywordsList) > 0) {
                $keywords = implode(", ", $keywordsList);
            }
        }

        $keywords = parent::_prepareMetaDescription($keywords, -1, $removeDuplicatedWords);

        return trim($keywords);
    }
1347798
public function scopeKeywords($query, $keyword)
    {
        return $query->where(function ($query) use ($keyword) {
            $query->where('name', 'LIKE', "%$keyword%")
            ->orWhere('description', 'LIKE', "%$keyword%");
        });
    }
929989
public static function wordFormat($keyword): string
    {
        // 将全角角逗号换为空格
        $keyword = str_replace(['，', ','], ' ', $keyword);

        return preg_replace([
            // 去掉两个空格以上的
            '/\s(?=\s)/',
            // 将非空格替换为一个空格
            '/[\n\r\t]/'
        ], ['', ' '], trim($keyword));
    }
1151656
public function isKeyword($word)
    {
        if ($this->keywords === null) {
            $this->initializeKeywords();
        }

        return isset($this->keywords[strtoupper($word)]);
    }
212706
public function fuzzySearch($keyword)
    {
        $prefix         = substr($keyword, 0, $this->fuzzy_prefix_length);
        $searchWordlist = "SELECT * FROM wordlist WHERE term like :keyword ORDER BY num_hits DESC LIMIT {$this->fuzzy_max_expansions}";
        $stmtWord       = $this->index->prepare($searchWordlist);
        $stmtWord->bindValue(':keyword', mb_strtolower($prefix)."%");
        $stmtWord->execute();
        $matches = $stmtWord->fetchAll(PDO::FETCH_ASSOC);

        $resultSet = [];
        foreach ($matches as $match) {
            $distance = levenshtein($match['term'], $keyword);
            if ($distance <= $this->fuzzy_distance) {
                $match['distance'] = $distance;
                $resultSet[]       = $match;
            }
        }

        // Sort the data by distance, and than by num_hits
        $distance = [];
        $hits     = [];
        foreach ($resultSet as $key => $row) {
            $distance[$key] = $row['distance'];
            $hits[$key]     = $row['num_hits'];
        }
        array_multisort($distance, SORT_ASC, $hits, SORT_DESC, $resultSet);

        return $resultSet;
    }
202279
public static function getKeywords()
    {
        static $keywords = null;

        if ($keywords === null) {
            $keywords = [];

            $keywordsStrings = [
                'T_ABSTRACT', 'T_ARRAY', 'T_AS', 'T_BREAK', 'T_CALLABLE', 'T_CASE',
                'T_CATCH', 'T_CLASS', 'T_CLONE', 'T_CONST', 'T_CONTINUE', 'T_DECLARE', 'T_DEFAULT', 'T_DO',
                'T_ECHO', 'T_ELSE', 'T_ELSEIF', 'T_EMPTY', 'T_ENDDECLARE', 'T_ENDFOR', 'T_ENDFOREACH',
                'T_ENDIF', 'T_ENDSWITCH', 'T_ENDWHILE', 'T_EVAL', 'T_EXIT', 'T_EXTENDS', 'T_FINAL',
                'T_FINALLY', 'T_FOR', 'T_FOREACH', 'T_FUNCTION', 'T_GLOBAL', 'T_GOTO', 'T_HALT_COMPILER',
                'T_IF', 'T_IMPLEMENTS', 'T_INCLUDE', 'T_INCLUDE_ONCE', 'T_INSTANCEOF', 'T_INSTEADOF',
                'T_INTERFACE', 'T_ISSET', 'T_LIST', 'T_LOGICAL_AND', 'T_LOGICAL_OR', 'T_LOGICAL_XOR',
                'T_NAMESPACE', 'T_NEW', 'T_PRINT', 'T_PRIVATE', 'T_PROTECTED', 'T_PUBLIC', 'T_REQUIRE',
                'T_REQUIRE_ONCE', 'T_RETURN', 'T_STATIC', 'T_SWITCH', 'T_THROW', 'T_TRAIT', 'T_TRY',
                'T_UNSET', 'T_USE', 'T_VAR', 'T_WHILE', 'T_YIELD',
            ];

            foreach ($keywordsStrings as $keywordName) {
                if (defined($keywordName)) {
                    $keyword = constant($keywordName);
                    $keywords[$keyword] = $keyword;
                }
            }
        }

        return $keywords;
    }