3 * FusionForge search engine
5 * Copyright 1999-2001, VA Linux Systems, Inc
6 * Copyright 2004, Guillaume Smet/Open Wide
7 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
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 ExportProjectSearchQuery 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 __construct($words, $offset, $isExact) {
37 parent::__construct($words, $offset, $isExact, 200);
41 * getQuery - get the query built to get the search results
43 * @return array query+params array
47 $qpa = db_construct_qpa () ;
48 if (forge_get_config('use_fti')) {
49 $words = $this->getFTIwords();
51 $qpa = db_construct_qpa ($qpa,
52 '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 ',
53 array (implode (' ', $words))) ;
54 $qpa = db_construct_qpa ($qpa,
55 'WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id',
59 $qpa = db_construct_qpa ($qpa,
60 ' AND (vectors @@ q' ) ;
61 if (count($this->phrases)) {
62 $qpa = db_construct_qpa ($qpa,
63 $this->getOperator()) ;
64 $qpa = db_construct_qpa ($qpa,
66 $qpa = $this->addMatchCondition($qpa, 'group_name');
67 $qpa = db_construct_qpa ($qpa,
69 $qpa = $this->addMatchCondition($qpa, 'unix_group_name');
70 $qpa = db_construct_qpa ($qpa,
72 $qpa = $this->addMatchCondition($qpa, 'short_description');
73 $qpa = db_construct_qpa ($qpa,
76 $qpa = db_construct_qpa ($qpa,
77 ') ORDER BY ts_rank(vectors, q) DESC, group_name ASC') ;
79 $qpa = db_construct_qpa ($qpa,
80 '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',
84 $qpa = db_construct_qpa ($qpa,
86 $qpa = $this->addIlikeCondition ($qpa, 'group_name') ;
87 $qpa = db_construct_qpa ($qpa,
89 $qpa = $this->addIlikeCondition ($qpa, 'unix_group_name') ;
90 $qpa = db_construct_qpa ($qpa,
92 $qpa = $this->addIlikeCondition ($qpa, 'short_description') ;
93 $qpa = db_construct_qpa ($qpa,
102 // c-file-style: "bsd"