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. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'search/SearchQuery.class.php';
26 class ExportProjectSearchQuery extends SearchQuery {
31 * @param string $words words we are searching for
32 * @param int $offset offset
33 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
35 function ExportProjectSearchQuery($words, $offset, $isExact) {
36 $this->SearchQuery($words, $offset, $isExact, 200);
40 * getQuery - get the query built to get the search results
42 * @return array query+params array
46 $qpa = db_construct_qpa () ;
47 if (forge_get_config('use_fti')) {
48 $words = $this->getFTIwords();
50 $qpa = db_construct_qpa ($qpa,
51 'SELECT ts_headline(unix_group_name, q) as unix_group_name, ts_headline(short_description, q) as short_description, type_id, groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) q ',
52 array (implode (' ', $words))) ;
53 $qpa = db_construct_qpa ($qpa,
54 'WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id',
58 $qpa = db_construct_qpa ($qpa,
59 ' AND (vectors @@ q' ) ;
60 if (count($this->phrases)) {
61 $qpa = db_construct_qpa ($qpa,
62 $this->getOperator()) ;
63 $qpa = db_construct_qpa ($qpa,
65 $qpa = $this->addMatchCondition($qpa, 'group_name');
66 $qpa = db_construct_qpa ($qpa,
68 $qpa = $this->addMatchCondition($qpa, 'unix_group_name');
69 $qpa = db_construct_qpa ($qpa,
71 $qpa = $this->addMatchCondition($qpa, 'short_description');
72 $qpa = db_construct_qpa ($qpa,
75 $qpa = db_construct_qpa ($qpa,
76 ') ORDER BY ts_rank(vectors, q) DESC, group_name ASC') ;
78 $qpa = db_construct_qpa ($qpa,
79 'SELECT group_name,unix_group_name,type_id,groups.group_id, short_description,license,register_time FROM groups WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id',
83 $qpa = db_construct_qpa ($qpa,
85 $qpa = $this->addIlikeCondition ($qpa, 'group_name') ;
86 $qpa = db_construct_qpa ($qpa,
88 $qpa = $this->addIlikeCondition ($qpa, 'unix_group_name') ;
89 $qpa = db_construct_qpa ($qpa,
91 $qpa = $this->addIlikeCondition ($qpa, 'short_description') ;
92 $qpa = db_construct_qpa ($qpa,
101 // c-file-style: "bsd"