phpbb\search\fulltext_sphinx::split_keywords PHP Method

split_keywords() public method

Splits keywords entered by a user into an array of words stored in $this->split_words Stores the tidied search query in $this->search_query
public split_keywords ( string &$keywords, string $terms ) : false
$keywords string Contains the keyword as entered by the user
$terms string is either 'all' or 'any'
return false if no valid keywords were found and otherwise true
    public function split_keywords(&$keywords, $terms)
    {
        if ($terms == 'all') {
            $match = array('#\\sand\\s#i', '#\\sor\\s#i', '#\\snot\\s#i', '#\\+#', '#-#', '#\\|#', '#@#');
            $replace = array(' & ', ' | ', '  - ', ' +', ' -', ' |', '');
            $replacements = 0;
            $keywords = preg_replace($match, $replace, $keywords);
            $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED);
        } else {
            $this->sphinx->SetMatchMode(SPH_MATCH_ANY);
        }
        // Keep quotes and new lines
        $keywords = str_replace(array('"', "\n"), array('"', ' '), trim($keywords));
        if (strlen($keywords) > 0) {
            $this->search_query = str_replace('"', '"', $keywords);
            return true;
        }
        return false;
    }