35 include_once
'Services/Search/classes/class.ilAbstractSearch.php';
65 $this->mode = $a_mode;
74 $this->options =& $options;
89 case 'typical_age_range':
97 case 'classification':
133 case 'title_description':
142 echo
"ilMDSearch::performSearch() no mode given";
149 if(!$this->options[
'title'])
153 $this->
setFields(array(
'title',
'description'));
155 $and = (
"AND type ".$this->__getInStatement($this->
getFilter()));
156 $where = $this->__createTitleDescriptionWhereCondition();
159 $query =
"SELECT obj_id,type ".
163 "ORDER BY obj_id DESC";
165 $res = $this->db->query($query);
168 $this->search_result->addEntry($row->obj_id,$row->type,$this->__prepareFound($row));
176 if(!$this->options[
'coverage'] and !$this->options[
'structure'])
180 if($this->options[
'coverage'])
183 $and = $this->__createCoverageAndCondition();
186 if($this->options[
'structure'])
188 $and .= (
"AND general_structure = '".ilUtil::prepareDBString($this->options[
'structure']).
"' ");
191 $query =
"SELECT rbac_id,obj_type,obj_id ".
193 "FROM il_meta_general ".
194 "WHERE obj_type ".$this->__getInStatement($this->
getFilter()).
" ".
197 $res = $this->db->query($query);
200 if($this->options[
'coverage'])
203 if(!in_array(0,$found))
205 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$found,$row->obj_id);
210 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
219 if(!$this->options[
'language'])
224 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_language ".
225 "WHERE language = '".ilUtil::prepareDBString($this->options[
'language']).
"' ".
226 "AND obj_type ".$this->__getInStatement($this->
getFilter()).
' '.
227 "AND parent_type = 'meta_general'";
229 $res = $this->db->query($query);
230 #var_dump("<pre>",$query,"<pre>");
233 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
240 if(!$this->options[
'role'])
245 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_contribute ".
246 "WHERE role = '".ilUtil::prepareDBString($this->options[
'role']).
"' ".
247 "AND obj_type ".$this->__getInStatement($this->
getFilter());
249 $res = $this->db->query($query);
250 #var_dump("<pre>",$query,"<pre>");
253 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
262 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
263 $where = $this->__createEntityWhereCondition();
266 $query =
"SELECT rbac_id,obj_id,obj_type ".
268 "FROM il_meta_entity ".
271 $res = $this->db->query($query);
275 if(!in_array(0,$found))
277 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$found,$row->obj_id);
288 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_requirement ";
294 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
295 $query = $query.$where.$and;
296 $res = $this->db->query($query);
297 #var_dump("<pre>",$query,"<pre>");
300 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
307 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_educational ";
313 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
314 $query = $query.$where.$and;
315 $res = $this->db->query($query);
316 #var_dump("<pre>",$query,"<pre>");
319 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
326 if(!$this->options[
'typ_age_1'] or !$this->options[
'typ_age_2'])
331 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_typical_age_range ".
332 "WHERE typical_age_range_min >= '".(int) $this->options[
'typ_age_1'].
"' ".
333 "AND typical_age_range_max <= '".(
int) $this->options[
'typ_age_2'].
"'";
336 $res = $this->db->query($query);
337 #var_dump("<pre>",$query,"<pre>");
340 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
347 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_rights ";
353 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
354 $query = $query.$where.$and;
355 $res = $this->db->query($query);
356 #var_dump("<pre>",$query,"<pre>");
359 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
366 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_classification ";
372 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
373 $query = $query.$where.$and;
374 $res = $this->db->query($query);
375 #var_dump("<pre>",$query,"<pre>");
378 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
387 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
388 $where = $this->__createTaxonWhereCondition();
391 $query =
"SELECT rbac_id,obj_id,obj_type ".
393 "FROM il_meta_taxon ".
396 $res = $this->db->query($query);
400 if(!in_array(0,$found))
402 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$found,$row->obj_id);
413 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
414 if($a_in_classification)
416 $and .=
" AND parent_type = 'meta_classification' ";
418 $where = $this->__createKeywordWhereCondition();
421 $query =
"SELECT rbac_id,obj_id,obj_type ".
423 "FROM il_meta_keyword ".
426 $res = $this->db->query($query);
430 if(!in_array(0,$found) or !$a_in_classification)
432 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$found,$row->obj_id);
444 if($this->options[
'version'])
446 $where = $this->__createLifecycleWhereCondition();
453 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
455 if($this->options[
'status'])
457 $and .= (
" AND lifecycle_status = ".$ilDB->quote($this->options[
'status']).
" ");
460 $query =
"SELECT rbac_id,obj_id,obj_type ".
462 "FROM il_meta_lifecycle ".
465 $res = $this->db->query($query);
469 if(!in_array(0,$found))
471 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$found,$row->obj_id);
480 if(!$this->options[
'format'])
485 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_format ".
486 "WHERE format LIKE('".ilUtil::prepareDBString($this->options[
'format']).
"') ".
487 "AND obj_type ".$this->__getInStatement($this->
getFilter());
489 $res = $this->db->query($query);
490 #var_dump("<pre>",$query,"<pre>");
493 $this->search_result->addEntry($row->rbac_id,$row->obj_type,array(),$row->obj_id);
505 if($this->options[
'costs'])
507 $and = $counter++ ?
'AND ' :
' ';
510 if($this->options[
'copyright'])
512 $and = $counter++ ?
'AND ' :
' ';
513 $where .= ($and.
"copyright_and_other_restrictions = '".
ilUtil::prepareDBString($this->options[
'copyright']).
"' ");
515 return $counter ? $where :
'';
523 if($this->options[
'purpose'])
525 $and = $counter++ ?
'AND ' :
' ';
528 return $counter ? $where :
'';
536 if($this->options[
'int_type'])
538 $and = $counter++ ?
'AND ' :
' ';
541 if($this->options[
'lea_type'])
543 $and = $counter++ ?
'AND ' :
' ';
546 if($this->options[
'int_role'])
548 $and = $counter++ ?
'AND ' :
' ';
551 if($this->options[
'con'])
553 $and = $counter++ ?
'AND ' :
' ';
556 if($this->options[
'int_level_1'] or $this->options[
'int_level_2'])
558 $and = $counter++ ?
'AND ' :
' ';
560 $fields = $this->
__getDifference($this->options[
'int_level_1'],$this->options[
'int_level_2'],
561 array(
'VeryLow',
'Low',
'Medium',
'High',
'VeryHigh'));
565 if($this->options[
'sem_1'] or $this->options[
'sem_2'])
567 $and = $counter++ ?
'AND ' :
' ';
569 $fields = $this->
__getDifference($this->options[
'sem_1'],$this->options[
'sem_2'],
570 array(
'VeryLow',
'Low',
'Medium',
'High',
'VeryHigh'));
574 if($this->options[
'dif_1'] or $this->options[
'dif_2'])
576 $and = $counter++ ?
'AND ' :
' ';
578 $fields = $this->
__getDifference($this->options[
'dif_1'],$this->options[
'dif_2'],
579 array(
'VeryEasy',
'Easy',
'Medium',
'Difficult',
'VeryDifficult'));
584 return $counter ? $where :
'';
592 if($this->options[
'os'])
594 $and = $counter++ ?
'AND ' :
' ';
597 if($this->options[
'browser'])
599 $and = $counter++ ?
'AND ' :
' ';
602 return $counter ? $where :
'';
607 $a_val2 = $a_val2 ? $a_val2 : count($options);
609 if($a_val1 > $a_val2)
615 foreach($options as $option)
617 if($a_val1 > ++$counter)
621 if($a_val2 < $counter)
627 return $fields ? $fields : array();
637 $in .= implode(
"','",$a_fields);