Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00036 class ilAbstractSearch
00037 {
00038
00039
00040
00041 var $db = null;
00042
00043
00044
00045 var $query_parser = null;
00046
00047
00048
00049
00050 var $search_result = null;
00051
00052
00053
00054
00055 var $object_types = array('cat','dbk','crs','fold','frm','grp','lm','sahs','glo','mep','htlm','exc','file','qpl','tst','svy','spl',
00056 'chat','icrs','icla','webr');
00057
00058
00063 function ilAbstractSearch(&$qp_obj)
00064 {
00065 global $ilDB;
00066
00067 $this->query_parser =& $qp_obj;
00068 $this->db =& $ilDB;
00069
00070 include_once 'Services/Search/classes/class.ilSearchResult.php';
00071
00072 $this->search_result = new ilSearchResult();
00073 }
00074
00080 function setFields($a_fields)
00081 {
00082 $this->fields = $a_fields;
00083 }
00084
00090 function getFields()
00091 {
00092 return $this->fields ? $this->fields : array();
00093 }
00094
00100 function setFilter($a_filter)
00101 {
00102 if(is_array($a_filter))
00103 {
00104 $this->object_types = $a_filter;
00105 }
00106 }
00107
00113 function appendToFilter($a_type)
00114 {
00115 if(is_array($this->object_types))
00116 {
00117 if(in_array($a_type,$this->object_types))
00118 {
00119 return false;
00120 }
00121 }
00122 $this->object_types[] = $a_type;
00123
00124 return true;
00125 }
00126
00127
00133 function getFilter()
00134 {
00135 return $this->object_types ? $this->object_types : array();
00136 }
00137
00143 function __createLocateString()
00144 {
00145 if($this->query_parser->getCombination() == 'or')
00146 {
00147 return '';
00148 }
00149 if(count($this->fields) > 1)
00150 {
00151 $complete_str = 'CONCAT(';
00152 $complete_str .= implode(',',$this->fields);
00153 $complete_str .= ')';
00154 }
00155 else
00156 {
00157 $complete_str = $this->fields[0];
00158 }
00159
00160 $counter = 0;
00161 foreach($this->query_parser->getQuotedWords() as $word)
00162 {
00163 $locate .= (", LOCATE('".$word."',".$complete_str.") ");
00164 $locate .= ("as found".$counter++." ");
00165 }
00166
00167 return $locate;
00168 }
00169
00170 function __prepareFound(&$row)
00171 {
00172 if($this->query_parser->getCombination() == 'or')
00173 {
00174 return array();
00175 }
00176 $counter = 0;
00177 foreach($this->query_parser->getQuotedWords() as $word)
00178 {
00179 $res_found = "found".$counter++;
00180 $found[] = $row->$res_found;
00181 }
00182 return $found ? $found : array();
00183 }
00184
00185 function &performSearch()
00186 {
00187 echo "Should be overwritten.";
00188 }
00189
00190
00191 }
00192 ?>