3 * FusionForge search engine
5 * Copyright 1999-2001, VA Linux Systems, Inc
6 * Copyright 2004, Guillaume Smet/Open Wide
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'search/SearchQuery.class.php';
27 class SkillSearchQuery extends SearchQuery {
32 * @param string $words words we are searching for
33 * @param int $offset offset
34 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
36 function SkillSearchQuery($words, $offset, $isExact) {
37 $this->SearchQuery($words, $offset, $isExact);
41 * getQuery - get the query built to get the search results
43 * @return array query+params array
48 $qpa = db_construct_qpa () ;
50 if (forge_get_config('use_fti')) {
51 if(count($this->words)) {
52 $words = $this->getFormattedWords();
53 $qpa = db_construct_qpa ($qpa,
54 '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 ',
57 $qpa = db_construct_qpa ($qpa,
58 '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 ') ;
61 if (count ($this->phrases)) {
62 if (count ($this->words)) {
63 $qpa = db_construct_qpa ($qpa,
64 $this->getOperator()) ;
66 $qpa = db_construct_qpa ($qpa,
68 $qpa = $this->addMatchCondition ($qpa, 'skills_data.title') ;
69 $qpa = db_construct_qpa ($qpa,
71 $qpa = $this->addMatchCondition ($qpa, 'skills_data.keywords') ;
72 $qpa = db_construct_qpa ($qpa,
75 $qpa = db_construct_qpa ($qpa,
77 if (count ($this->words)) {
78 $qpa = db_construct_qpa ($qpa,
79 'AND skills_data.skills_data_id = skills_data_idx.skills_data_id ') ;
81 $qpa = db_construct_qpa ($qpa,
82 'AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ') ;
83 if (count ($this->words)) {
84 $qpa = db_construct_qpa ($qpa,
85 'ORDER BY rank(vectors, q) DESC, finish DESC') ;
87 $qpa = db_construct_qpa ($qpa,
88 'ORDER BY finish DESC') ;
91 $qpa = db_construct_qpa ($qpa,
92 'SELECT * FROM skills_data, users, skills_data_types WHERE ((') ;
93 $qpa = $this->addIlikeCondition ($qpa, 'skills_data.title') ;
94 $qpa = db_construct_qpa ($qpa,
96 $qpa = $this->addIlikeCondition ($qpa, 'skills_data.keywords') ;
97 $qpa = db_construct_qpa ($qpa,
98 ')) AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ORDER BY finish DESC') ;
106 // c-file-style: "bsd"