ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilShopObjectSearch.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11include_once 'Services/Search/classes/class.ilAbstractSearch.php';
12
14{
16
17 public function __construct($qp_obj)
18 {
19 parent::__construct($qp_obj);
20 $this->setFields(array('title', 'description'));
21 }
22
23 public function setCustomSearchResultObject($a_search_result_obect)
24 {
25 $this->search_result = $a_search_result_obect;
26 }
27
28 public function setFilterShopTopicId($a_topic_id)
29 {
30 $this->filter_shop_topic_id = $a_topic_id;
31 }
32 public function getFilterShopTopicId()
33 {
35 }
36
37 public function performSearch()
38 {
39 $types = array();
40 $values = array();
41
42 $in = $this->__createInStatement();
43 $where = $this->__createWhereCondition();
44 $locate = $this->__createLocateString();
45
46 $query = "SELECT object_reference.ref_id, object_data.obj_id,object_data.type ".$locate."
47 FROM payment_objects
48 INNER JOIN object_reference ON object_reference.ref_id = payment_objects.ref_id
49 INNER JOIN object_data ON object_data.obj_id = object_reference.obj_id ";
50
51 $query .= $where['query'];
52 $types = array_merge($types, $where['types']);
53 $values = array_merge($values, $where['values']);
54 $query .= $in;
55
56 $query .= " GROUP BY object_reference.ref_id, object_data.obj_id,object_data.type,object_data.title,object_data.description";
57 $query .= " ORDER BY object_data.obj_id DESC";
58
59 $statement = $this->db->queryf(
60 $query,
61 $types,
62 $values
63 );
64
65 while($row = $statement->fetchRow(DB_FETCHMODE_OBJECT))
66 {
67 $this->search_result->addEntry($row->ref_id, $row->type, $this->__prepareFound($row));
68 }
70 }
71
72 public function __createInStatement()
73 {
74 return ' AND ' . $this->db->in('type', $this->object_types, false, 'text');
75 }
76
82 public function __createLocateString()
83 {
84 global $ilDB;
85
86 if($this->query_parser->getCombination() == 'or')
87 {
88 return '';
89 }
90
91 if(!strlen($this->query_parser->getQueryString()))
92 {
93 return '';
94 }
95
96 $locate = '';
97
98 if(count($this->fields) > 1)
99 {
100 $tmp_fields = array();
101 foreach($this->fields as $field)
102 {
103 $tmp_fields[] = array($field,'text');
104 }
105 $complete_str = $ilDB->concat($tmp_fields);
106 }
107 else
108 {
109 $complete_str = $this->fields[0];
110 }
111
112 $counter = 0;
113 foreach($this->query_parser->getQuotedWords() as $word)
114 {
115 $locate .= ',';
116 $locate .= $ilDB->locate($ilDB->quote($word, 'text'), $complete_str, 1);
117 $locate .= (' found'.$counter++);
118 $locate .= ' ';
119 }
120
121 return $locate;
122 }
123
124 public function __prepareFound(&$row)
125 {
126 if($this->query_parser->getCombination() == 'or')
127 {
128 return array();
129 }
130
131 if(!strlen($this->query_parser->getQueryString()))
132 {
133 return array();
134 }
135
136 $counter = 0;
137 foreach($this->query_parser->getQuotedWords() as $word)
138 {
139 $res_found = 'found'.$counter++;
140 $found[] = $row->$res_found;
141 }
142 return $found ? $found : array();
143 }
144}
145?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setFields($a_fields)
Set fields to search.
__createLocateString()
build locate string in case of AND search
setCustomSearchResultObject($a_search_result_obect)
global $ilDB
$errors fields
Definition: imgupload.php:48