diff options
| author | Nathan Kinkade <nath@nkinka.de> | 2011-04-22 16:54:55 +0000 |
|---|---|---|
| committer | Nathan Kinkade <nath@nkinka.de> | 2011-04-22 16:54:55 +0000 |
| commit | 1f7c1f18c651c58048e92d615c71ac0fe6691c10 (patch) | |
| tree | 4527c4bc08000a07c180cd1fe81792d71195d58b /modules/search/helpers/search.php | |
| parent | de6f3fce9110b777d61dec97f2a3a61d887a5ccd (diff) | |
| parent | 55da59c942c0f7171b515f0718fea8506ed4b116 (diff) | |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/search/helpers/search.php')
| -rw-r--r-- | modules/search/helpers/search.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 09e5e83f..bbde8feb 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -18,6 +18,22 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class search_Core { + /** + * Add more terms to the query by wildcarding the stem value of the first + * few terms in the query. + */ + static function add_query_terms($q) { + $MAX_TERMS = 5; + $terms = explode(" ", $q, $MAX_TERMS); + for ($i = 0; $i < min(count($terms), $MAX_TERMS - 1); $i++) { + // Don't wildcard quoted or already wildcarded terms + if ((substr($terms[$i], 0, 1) != '"') && (substr($terms[$i], -1, 1) != "*")) { + $terms[] = rtrim($terms[$i], "s") . "*"; + } + } + return implode(" ", $terms); + } + static function search($q, $limit, $offset) { $db = Database::instance(); $q = $db->escape($q); |
