3 * FusionForge search engine
5 * Copyright 1999-2001, VA Linux Systems, Inc
6 * Copyright 2004, Guillaume Smet/Open Wide
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once $gfcommon.'search/SearchQuery.class.php';
28 class SkillSearchQuery extends SearchQuery {
33 * @param string $words words we are searching for
34 * @param int $offset offset
35 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
37 function SkillSearchQuery($words, $offset, $isExact) {
38 $this->SearchQuery($words, $offset, $isExact);
42 * getQuery - get the query built to get the search results
44 * @return array query+params array
49 $qpa = db_construct_qpa () ;
52 if(count($this->words)) {
53 $words = $this->getFormattedWords();
54 $qpa = db_construct_qpa ($qpa,
55 'SELECT skills_data.skills_data_id, skills_data.type, skills_data.start, skills_data.finish, headline(skills_data.title, q) as title, headline(skills_data.keywords, q) as keywords FROM skills_data, users, skills_data_types, to_tsquery($1) AS q, skills_data_idx WHERE (vectors @@ q ',
58 $qpa = db_construct_qpa ($qpa,
59 'SELECT skills_data.skills_data_id, skills_data.type, skills_data.start, skills_data.finish, FROM skills_data, users, skills_data_types WHERE (vectors @@ q ') ;
62 if (count ($this->phrases)) {
63 if (count ($this->words)) {
64 $qpa = db_construct_qpa ($qpa,
65 $this->getOperator()) ;
67 $qpa = db_construct_qpa ($qpa,
69 $qpa = $this->addMatchCondition ($qpa, 'skills_data.title') ;
70 $qpa = db_construct_qpa ($qpa,
72 $qpa = $this->addMatchCondition ($qpa, 'skills_data.keywords') ;
73 $qpa = db_construct_qpa ($qpa,
76 $qpa = db_construct_qpa ($qpa,
78 if (count ($this->words)) {
79 $qpa = db_construct_qpa ($qpa,
80 'AND skills_data.skills_data_id = skills_data_idx.skills_data_id ') ;
82 $qpa = db_construct_qpa ($qpa,
83 'AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ') ;
84 if (count ($this->words)) {
85 $qpa = db_construct_qpa ($qpa,
86 'ORDER BY rank(vectors, q) DESC, finish DESC') ;
88 $qpa = db_construct_qpa ($qpa,
89 'ORDER BY finish DESC') ;
92 $qpa = db_construct_qpa ($qpa,
93 'SELECT * FROM skills_data, users, skills_data_types WHERE ((') ;
94 $qpa = $this->addIlikeCondition ($qpa, 'skills_data.title') ;
95 $qpa = db_construct_qpa ($qpa,
97 $qpa = $this->addIlikeCondition ($qpa, 'skills_data.keywords') ;
98 $qpa = db_construct_qpa ($qpa,
99 ')) AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ORDER BY finish DESC') ;
107 // c-file-style: "bsd"