public static function escapeToken($token, $force = false)
    {
        $escaped = preg_replace(self::RE_SPECIALS, '\\\\\\0', $token);

        if ($force || preg_match('/ /', $escaped) || strlen($token) != strlen($escaped)) {
            return '"' . $escaped . '"';
        } else {
            return $escaped;
        }
    }
public static function escapeToken($token, $force = false)
    {
        $escaped = preg_replace(self::RE_SPECIALS, '\\\\\\0', $token);

        if ($force || preg_match('/ /', $escaped) || strlen($token) != strlen($escaped)) {
            return '"' . $escaped . '"';
        } else {
            return $escaped;
        }
    }
public static function escapeToken ( $ token , $ force = false ) { $ escaped = preg_replace ( self :: RE_SPECIALS , '\\\\\\0' , $ token ) ; if ( $ force || preg_match ( '/ /' , $ escaped ) || strlen ( $ token ) != strlen ( $ escaped ) ) { return '"' . $ escaped . '"' ; } else { return $ escaped ; } }
Add '"' chars if necessary to a token value, and escape Lucene query
syntax reserved chars

@param string $token
String to escape
@param boolean $force = FALSE
Escape whatever happens

@return string
Add chars if necessary to a token value and escape Lucene query syntax reserved chars