Search wikipedia.

@param string $keyword Keywords to search in wikipedia

@return mixed Array or false
770598
public static function wikiSearch($keyword)
    {
        $apiurl = 'http://wikipedia.org/w/api.php?action=opensearch&search='.urlencode($keyword).'&format=xml&limit=1';
        $data = self::curl($apiurl);
        $xml = simplexml_load_string($data);
        if ((string) $xml->Section->Item->Description) {
            $array = [];
            $array['title'] = (string) $xml->Section->Item->Text;
            $array['description'] = (string) $xml->Section->Item->Description;
            $array['url'] = (string) $xml->Section->Item->Url;
            if (isset($xml->Section->Item->Image)) {
                $img = (string) $xml->Section->Item->Image->attributes()->source;
                $array['image'] = str_replace('/50px-', '/200px-', $img);
            }

            return $array;
        }

        return false;
    }
1151656
public function isKeyword($word)
    {
        if ($this->keywords === null) {
            $this->initializeKeywords();
        }

        return isset($this->keywords[strtoupper($word)]);
    }
160903
public function find( $search ) {

		if ( ! is_array( $search ) ) {
			$search = (array) $search;
		}

		foreach ( $search as $val ) {
			if ( $this->fulltextSearchInPost( $val ) !== false ) {
				return true;
			}
			if ( $this->fulltextSearchInMeta( $val ) !== false ) {
				return true;
			}
		}

		return false;
	}
1281338
public function searchContent($word) {
		$index   = $this->addFilter(new SearchContent($word));
		$content = $this->listFiles(true);
		$this->removeFilter($index);

		return $content;
	}
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;
    }
909670
public function keyword($keyword)
    {
        $this->andWhere([
            'or',
            ['and', '{{type}}=:typeMatch', '{{keyword}}=:keyword'], // 直接匹配关键字
            ['and', '{{type}}=:typeInclude', 'INSTR(:keyword, {{keyword}})>0'], // 包含关键字
            ['and', '{{type}}=:typeRegular', ':keyword REGEXP {{keyword}}'], // 正则匹配关键字
        ])
        ->addParams([
            ':keyword' => $keyword,
            ':typeMatch' => ReplyRuleKeyword::TYPE_MATCH,
            ':typeInclude' => ReplyRuleKeyword::TYPE_INCLUDE,
            ':typeRegular' => ReplyRuleKeyword::TYPE_REGULAR
        ]);
        return $this;
    }
762982
public function headword($headword)
    {
        if ($headword instanceof Headword) {
            return $this->andWhere(['headword_guid' => $headword->guid]);
        }
        if (is_string($headword)) {
            $headword = Headword::find()->where(['word' => $headword])->one();
            if (!$headword) {
                return $this;
            }
            return $this->andWhere(['headword_guid' => $headword->guid]);
        }
    }
406545
public function filterByKeywords($keywords)
    {
        $expressions = [
            $this->query->expr()->like('g.gName', ':keywords'),
            $this->query->expr()->like('g.gDescription', ':keywords'),
        ];

        $expr = $this->query->expr();
        $this->query->andWhere(call_user_func_array([$expr, 'orX'], $expressions));
        $this->query->setParameter('keywords', '%' . $keywords . '%');
    }
945641
public function getTranslationGroupByKeywordAndDomain($keyword, $domain)
    {
        $translations = $this->findTranslations($keyword, $domain);
        $translationGroup = new TranslationGroup();
        $translationGroup->setDomain($domain);
        $translationGroup->setKeyword($keyword);
        if (empty($translations)) {
            $translationGroup->setId($this->maxId);
            ++$this->maxId;
        } else {
            $translationGroup->setId($translations[0]->getTranslationId());
        }
        $translationGroup->setTranslations($translations);

        return $translationGroup;
    }
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;
    }
894032
protected function smartGlobalSearch($keyword)
    {
        collect(explode(' ', $keyword))
            ->reject(function ($keyword) {
                return trim($keyword) === '';
            })
            ->each(function ($keyword) {
                $this->globalSearch($keyword);
            });
    }
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];
    }
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;
    }
755478
public function getKeywords()
	{
		$keywords = $this->keywords ? : $this->getDefault('keywords');
		return (is_array($keywords)) ? implode(', ', $keywords) : $keywords;
	}
636426
public function searchDirectory(string $word) {
		$index   = $this->addFilter(new Search($word));
		$content = $this->listDirectories(true);
		$this->removeFilter($index);

		return $content;
	}
1236174
public static function search($keyword, $pos = 1)
    {
        global $config;
        $html="<h1 id='personSearch'>"._("Personnes")."</h1>";
        $keyword = str_replace(' ', '%%', $keyword);
        $req="SELECT idPersonne
            FROM `personne`
            WHERE `prenom` LIKE '%".mysql_real_escape_string($keyword)."%'
            OR `nom` LIKE '%".mysql_real_escape_string($keyword)."%'
            OR CONCAT_WS(' ', nom, prenom) LIKE '%".mysql_real_escape_string($keyword)."%'
            OR CONCAT_WS(' ', prenom, nom) LIKE '%".mysql_real_escape_string($keyword)."%'";
        $res = $config->connexionBdd->requete($req);
        $nbPeople=mysql_num_rows($res);
        $maxPos=round($nbPeople/10);
        if ($maxPos<1) {
            $maxPos=1;
        }
        $minPos=1;
        $prevPos=$pos-1;
        $nextPos=$pos+1;
        if ($prevPos < $minPos) {
            $prevPos=$minPos;
        }

        if ($nextPos > $maxPos) {
            $nextPos=$maxPos;
        }
        $req="SELECT idPersonne, nom, prenom, idMetier
            FROM `personne`
            WHERE `prenom` LIKE '%".mysql_real_escape_string($keyword)."%'
            OR `nom` LIKE '%".mysql_real_escape_string($keyword)."%'
            OR CONCAT_WS(' ', nom, prenom) LIKE '%".mysql_real_escape_string($keyword)."%'
            OR CONCAT_WS(' ', prenom, nom) LIKE '%".mysql_real_escape_string($keyword)."%'
            LIMIT ".(($pos-1)*10).", ".($pos*10);
        $res = $config->connexionBdd->requete($req);
        while ($person=mysql_fetch_object($res)) {
            $people[]=($person);
        }
        $t=new Template('modules/archi/templates/');
        $t->set_filenames(array('listeAdresses'=>'listeAdresses.tpl'));
        $t->assign_block_vars(
            't',
            array(
                'urlPrecedent'         => $config->creerUrl("", "recherche", array("motcle"=>$_GET["motcle"], "pos"=>$prevPos, "submit"=>"Rechercher"))."#personSearch",
                'urlPrecedentOnClick'    => "",
                'urlSuivant'           => $config->creerUrl("", "recherche", array("motcle"=>$_GET["motcle"], "pos"=>$nextPos, "submit"=>"Rechercher"))."#personSearch",
                'urlSuivantOnClick'    => "",
                'nbReponses'           => $nbPeople." ".ngettext("réponse", "réponses", $nbPeople)
            )
        );
        for ($i=$minPos; $i<=$maxPos; $i++) {
            $t->assign_block_vars(
                "t.nav",
                array(
                    "nb"=>$i,
                    "urlNb"=>$config->creerUrl("", "recherche", array("motcle"=>$_GET["motcle"], "pos"=>$i, "submit"=>"Rechercher"))."#personSearch"
                )
            );
            if ($i==$pos) {
                $t->assign_block_vars("t.nav.courant", array());
            }
        }
        if (isset($people)) {
            foreach ($people as $person) {
                $req="SELECT nom
                    FROM `metier`
                    WHERE `idMetier` =".$person->idMetier;
                $res = $config->connexionBdd->requete($req);
                $job=mysql_fetch_object($res)->nom;
                $t->assign_block_vars(
                    "t.adresses",
                    array(
                        "nom"=>stripslashes($person->prenom." ".$person->nom),
                        "urlDetailHref"=>$config->creerUrl(
                            "",
                            "evenementListe",
                            array("selection"=>"personne", "id"=>$person->idPersonne)
                        ),
                        "urlImageIllustration"=>archiPersonne::getImage($person->idPersonne, "mini", false),
                        "titresEvenements"=>$job
                    )
                );
            }
        }
        ob_start();
        $t->pparse('listeAdresses');
        $html.=ob_get_contents();
        ob_end_clean();
        return $html;
    }
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;
    }