ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLikeUserDefinedFieldSearch.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once 'Services/Search/classes/class.ilUserDefinedFieldSearch.php';
5 
18 {
19 
25  public function setFields($a_fields)
26  {
27  foreach ($a_fields as $field) {
28  $fields[] = 'f_' . $field;
29  }
30  parent::setFields($fields ? $fields : array());
31  }
32 
33 
34  public function __createWhereCondition()
35  {
36  global $ilDB;
37 
38  $fields = $this->getFields();
39  $field = $fields[0];
40 
41  $and = " WHERE field_id = " . $ilDB->quote((int) substr($field, 2), "integer") . " AND ( ";
42  $counter = 0;
43  foreach ($this->query_parser->getQuotedWords() as $word) {
44  if ($counter++) {
45  $and .= " OR ";
46  }
47 
48  if (strpos($word, '^') === 0) {
49  $and .= $ilDB->like("value", "text", substr($word, 1) . "%");
50  } else {
51  $and .= $ilDB->like("value", "text", "%" . $word . "%");
52  }
53  }
54  return $and . ") ";
55  }
56 }
getFields()
Get fields to search.
$counter
Create styles array
The data for the language used.
global $ilDB