ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24  function ilLikeUserDefinedFieldSearch(&$qp_obj)
25  {
27  }
28 
34  public function setFields($a_fields)
35  {
36  foreach($a_fields as $field)
37  {
38  $fields[] = 'f_'.$field;
39  }
40  parent::setFields($fields ? $fields : array());
41  }
42 
43 
45  {
46  global $ilDB;
47 
48  $fields = $this->getFields();
49  $field = $fields[0];
50 
51  $and = " WHERE field_id = ".$ilDB->quote((int) substr($field, 2), "integer")." AND ( ";
52  $counter = 0;
53  foreach($this->query_parser->getQuotedWords() as $word)
54  {
55  if($counter++)
56  {
57  $and .= " OR ";
58  }
59 
60  if(strpos($word,'^') === 0)
61  {
62  $and .= $ilDB->like("value", "text", substr($word,1)."%");
63  }
64  else
65  {
66  $and .= $ilDB->like("value", "text", "%".$word."%");
67  }
68  }
69  return $and.") ";
70  }
71 }
72 ?>