, left and right brackets * * @param string $s String to be URL encoded. * * @return string The URL encoded string. */ public static function encode($s) { return str_replace(['<', '>', '[', ']'], ['%3c', '%3e', '%5b', '%5d'], $s); } /** * @brief URL decode <, >, left and right brackets * * @param string $s The URL encoded string to be decoded * * @return string The decoded string. */ public static function decode($s) { return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s); } /** * @brief Query files for tag * * @param string $table The table to be queired. * @param string $s The search term * @param string $type Optional file type. * * @return string Query string. */ public static function fileQuery($table, $s, $type = 'file') { if ($type == 'file') { $str = preg_quote('[' . str_replace('%', '%%', self::encode($s)) . ']'); } else { $str = preg_quote('<' . str_replace('%', '%%', self::encode($s)) . '>'); } return " AND " . (($table) ? DBA::escape($table) . '.' : '') . "file regexp '" . DBA::escape($str) . "' "; } /** * Get file tags from array * * ex. given [music,video] return