文档列表搜素
@param string $keyword
@return array
775072
public function searchList($keyword = "")
    {
        $controller = $this->config['controller'];
        $list = [];
        foreach ($controller as $class)
        {
            if(class_exists($class))
            {
                $reflection = new \ReflectionClass($class);
                $method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
                $filter_method = array_merge(['__construct'], $this->config['filter_method']);
                foreach ($method as $action){
                    if(!in_array($action->name, $filter_method))
                    {
                        $doc = new DocParser();
                        $doc_str = $action->getDocComment();
                        if($doc_str)
                        {
                            $action_doc = $doc->parse($doc_str);
                            $action_doc['name'] = $class."::".$action->name;
                            if((isset($action_doc['title']) && strpos($action_doc['title'], $keyword) !== false)
                                    || (isset($action_doc['description']) && strpos($action_doc['description'], $keyword) !== false)
                                    || (isset($action_doc['author']) && strpos($action_doc['author'], $keyword) !== false)
                                    || (isset($action_doc['url'])  && strpos($action_doc['url'], $keyword) !== false))
                            {
                                array_push($list, $action_doc);
                            }
                        }
                    }
                }
            }
        }
        return $list;
    }
411326
public function filterByKeywords($keywords)
    {
        $db = Loader::db();
        $keywordsExact = $db->quote($keywords);
        $qkeywords = $db->quote('%' . $keywords . '%');
        $keys = FileAttributeKey::getSearchableIndexedList();
        $attribsStr = '';
        foreach ($keys as $ak) {
            $cnt = $ak->getController();
            $attribsStr .= ' OR ' . $cnt->searchKeywords($keywords);
        }
        $this->filter(false, '(fvFilename like ' . $qkeywords . ' or fvDescription like ' . $qkeywords . ' or fvTitle like ' . $qkeywords . ' or fvTags like ' . $qkeywords . ' or u.uName = ' . $keywordsExact . $attribsStr . ')');
    }
1208441
private function convertFile(array $file)
    {
        if (!isset($file['name']) || !isset($file['type']) || !isset($file['tmp_name']) || !isset($file['error']) || !isset($file['size'])) {
            return null;
        }

        if (is_array($file['error'])) {
            $result = [];
            foreach ($file['error'] as $key => $error) {
                $result[$key] = $this->convertFile([
                    'name'     => $file['name'][$key],
                    'type'     => $file['type'][$key],
                    'tmp_name' => $file['tmp_name'][$key],
                    'error'    => $file['error'][$key],
                    'size'     => $file['size'][$key],
                ]);
            }
        }
        else {
            $result = new \Core\Services\UploadedFile($file['tmp_name'], $file['name'], $file['error']);
        }

        return $result;
    }
34265
private function getData(string $file): array
  {
    static $RESULT_STOP_WORDS_CACHE = array();

    if (isset($RESULT_STOP_WORDS_CACHE[$file])) {
      return $RESULT_STOP_WORDS_CACHE[$file];
    }

    $file = __DIR__ . '/stopwords/' . $file . '.php';
    if (file_exists($file)) {
      /** @noinspection PhpIncludeInspection */
      $RESULT_STOP_WORDS_CACHE[$file] = require $file;
    } else {
      $RESULT_STOP_WORDS_CACHE[$file] = array();
    }

    return $RESULT_STOP_WORDS_CACHE[$file];
  }
251673
private function getFileContents($file) {
		$content = file_get_contents($file);

		// Remove UTF-8 BOM
		if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf))
			$content = substr($content, 3);

		return $content;
	}
1180646
public function exists($keyword)
    {
        $object = null;
        $result = $this->_em->getConnection()->executeQuery(sprintf(
            'SELECT uid FROM keyword WHERE hex(lower(keyword)) = hex(lower("%s"))',
            preg_replace('#[/\"]#', '', trim($keyword))
        ))->fetchAll();

        if (0 < count($result)) {
            $uid = array_shift($result);
            $object = $this->find($uid['uid']);
        }

        return $object;
    }
886924
public function getByKeyword($keyword)
        {
            $results = $this->twitterProvider->get("search/tweets", [
                "q"           => $keyword,
                "result_type" => $this->type,
                "count"       => $this->amount,
            ]);

            return $this->processResults($results);
        }
1213042
protected function prepareKeyword($keyword)
    {
        if ($this->config->isCaseInsensitive()) {
            $keyword = Str::lower($keyword);
        }

        if ($this->config->isWildcard()) {
            $keyword = Helper::wildcardLikeString($keyword);
        }

        if ($this->config->isSmartSearch()) {
            $keyword = "%$keyword%";
        }

        return $keyword;
    }
358952
public function addKeyword($keyword)
    {
        if (is_array($keyword)):
            $this->keywords = array_merge($keyword, $this->keywords);
        else:
            $this->keywords[] = strip_tags($keyword);
        endif;

        return $this;
    }
490732
private function getTranslationArrayFromFile($file)
    {
        $extension = pathinfo($file, PATHINFO_EXTENSION);
        switch ($extension) {
            default:
                return [];
            case 'php':
                $loader = new Loader\PhpArrayTranslationsLoader($file);
                break;
        }

        return $loader->getTranslationArray();
    }
387019
public function findByKeyword($keyword)
    {
        if ($keyword !== false) {
            $data = $this->getKeywordListFromCache();

            // 如果有完全匹配,直接返回
            if (isset($data[static::EXACT_MATCH][$keyword])) {
                return $this->findByIdFromCache($data[static::EXACT_MATCH][$keyword]);
            }

            // 判断是否有部分匹配
            foreach ($data[static::PARTIAL_MATCH] as $partialKeyword => $id) {
                if (strpos($keyword, (string) $partialKeyword) !== false) {
                    return $this->findByIdFromCache($id);
                }
            }
        }

        return '';
    }
638901
public function getWordlistByKeyword($keyword, $isLastWord = false)
    {
        $searchWordlist = "SELECT * FROM wordlist WHERE term like :keyword LIMIT 1";
        $stmtWord       = $this->index->prepare($searchWordlist);

        if ($this->asYouType && $isLastWord) {
            $searchWordlist = "SELECT * FROM wordlist WHERE term like :keyword ORDER BY length(term) ASC, num_hits DESC LIMIT 1";
            $stmtWord       = $this->index->prepare($searchWordlist);
            $stmtWord->bindValue(':keyword', mb_strtolower($keyword)."%");
        } else {
            $stmtWord->bindValue(':keyword', mb_strtolower($keyword));
        }
        $stmtWord->execute();
        $res = $stmtWord->fetchAll(PDO::FETCH_ASSOC);

        if ($this->fuzziness && !isset($res[0])) {
            return $this->fuzzySearch($keyword);
        }
        return $res;
    }
833050
public function process($keyword){
        switch($keyword){
            case 'DATE_NOW':
                return strval(time());
            case 'DATE_Y4':
            case 'DATE_YEAR':
                return date('Y');
            case 'DATE_Y2':
                return date('y');
            case 'DATE_M':
            case 'DATE_MONTH':
                return date('m');
            case 'DATE_N':
                return date('n');
            case 'DATE_D':
            case 'DATE_DAY':
                return date('d');
            case 'DATE_J':
                return date('j');
            case 'DATE_H24':
            case 'DATE_HOUR':
                return date('H');
            case 'DATE_H12':
                return date('h');
            case 'DATE_I':
            case 'DATE_MINUTE':
                return date('i');
            case 'DATE_S':
            case 'DATE_SECOND':
                return date('s');
            case 'DATE_U':
            case 'DATE_MSEC':
                $t = microtime(true);
                return sprintf("%06d",($t - floor($t)) * 1000000);
        }
        return NULL;
    }
1272178
protected function getFileInfo($file)
    {
        $normalized = [
            'type'      => 'file',
            'path'      => $file->getName(),
            'timestamp' => substr($file->getUploadTimestamp(), 0, -3),
            'size'      => $file->getSize(),
        ];

        return $normalized;
    }
1004924
private function prepareKeywords($keywords)
    {
        if ($keywords === null)
            return null;

        if (is_array($keywords))
            $keywords = implode(', ', $keywords);

        return strtolower(strip_tags($keywords));
    }
990857
public function getAllDocumentsForKeyword($keyword, $noLimit = false, $isLastKeyword = false)
    {
        $word = $this->getWordlistByKeyword($keyword, $isLastKeyword);
        if (!isset($word[0])) {
            return new Collection([]);
        }
        if ($this->fuzziness) {
            return $this->getAllDocumentsForFuzzyKeyword($word, $noLimit);
        }

        return $this->getAllDocumentsForStrictKeyword($word, $noLimit);
    }
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;
        });
    }