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 $this->
setFields(array(
'title',
'description'));
151 $and = (
"AND type ".$this->__getInStatement($this->
getFilter()));
152 $where = $this->__createTitleDescriptionWhereCondition();
155 $query =
"SELECT obj_id,type ".
159 "ORDER BY obj_id DESC";
164 $this->search_result->addEntry(
$row->obj_id,
$row->type,$this->__prepareFound(
$row));
174 if(!$this->options[
'lom_coverage'] and !$this->options[
'lom_structure'])
178 if($this->options[
'lom_coverage'])
181 $and = $this->__createCoverageAndCondition();
184 if($this->options[
'lom_structure'])
186 $and .= (
"AND general_structure = ".$ilDB->quote($this->options[
'lom_structure'] ,
'text').
" ");
189 $query =
"SELECT rbac_id,obj_type,obj_id ".
191 "FROM il_meta_general ".
192 "WHERE obj_type ".$this->__getInStatement($this->
getFilter()).
" ".
198 if($this->options[
'lom_coverage'])
201 if(!in_array(0,$found))
203 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,$found,
$row->obj_id);
208 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
219 if(!$this->options[
'lom_language'])
224 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_language ".
225 "WHERE language = ".$ilDB->quote($this->options[
'lom_language'] ,
'text').
" ".
226 "AND obj_type ".$this->__getInStatement($this->
getFilter()).
' '.
227 "AND parent_type = 'meta_general'";
230 #var_dump("<pre>",$query,"<pre>");
233 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
242 if(!$this->options[
'lom_role'])
247 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_contribute ".
248 "WHERE role = ".$ilDB->quote($this->options[
'lom_role'] ,
'text').
" ".
249 "AND obj_type ".$this->__getInStatement($this->
getFilter());
252 #var_dump("<pre>",$query,"<pre>");
255 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
264 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
265 $where = $this->__createEntityWhereCondition();
268 $query =
"SELECT rbac_id,obj_id,obj_type ".
270 "FROM il_meta_entity ".
277 if(!in_array(0,$found))
279 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,$found,
$row->obj_id);
290 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_requirement ";
296 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
299 #var_dump("<pre>",$query,"<pre>");
302 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
309 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_educational ";
315 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
320 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
327 if(!$this->options[
'typ_age_1'] or !$this->options[
'typ_age_2'])
332 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_typical_age_range ".
333 "WHERE typical_age_range_min >= '".(int) $this->options[
'typ_age_1'].
"' ".
334 "AND typical_age_range_max <= '".(
int) $this->options[
'typ_age_2'].
"'";
338 #var_dump("<pre>",$query,"<pre>");
341 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
348 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_rights ";
354 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
357 #var_dump("<pre>",$query,"<pre>");
360 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
367 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_classification ";
373 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
376 #var_dump("<pre>",$query,"<pre>");
379 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
388 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
389 $where = $this->__createTaxonWhereCondition();
392 $query =
"SELECT rbac_id,obj_id,obj_type ".
394 "FROM il_meta_taxon ".
401 if(!in_array(0,$found))
403 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,$found,
$row->obj_id);
414 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
415 if($a_in_classification)
417 $and .=
" AND parent_type = 'meta_classification' ";
419 $where = $this->__createKeywordWhereCondition();
422 $query =
"SELECT rbac_id,obj_id,obj_type ".
424 "FROM il_meta_keyword ".
431 if(!in_array(0,$found) or !$a_in_classification)
433 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,$found,
$row->obj_id);
445 if($this->options[
'lom_version'])
447 $where = $this->__createLifecycleWhereCondition();
452 $where =
"WHERE 1 = 1 ";
454 $and = (
"AND obj_type ".$this->__getInStatement($this->
getFilter()));
456 if($this->options[
'lom_status'])
458 $and .= (
" AND lifecycle_status = ".$ilDB->quote($this->options[
'lom_status'] ,
'text') .
"");
461 $query =
"SELECT rbac_id,obj_id,obj_type ".
463 "FROM il_meta_lifecycle ".
470 if(!in_array(0,$found))
472 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,$found,
$row->obj_id);
483 if(!$this->options[
'lom_format'])
488 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_format ".
489 "WHERE format LIKE(".$ilDB->quote($this->options[
'lom_format']).
") ".
490 "AND obj_type ".$this->__getInStatement($this->
getFilter());
493 #var_dump("<pre>",$query,"<pre>");
496 $this->search_result->addEntry(
$row->rbac_id,
$row->obj_type,array(),
$row->obj_id);
510 if($this->options[
'lom_costs'])
512 $and = $counter++ ?
'AND ' :
' ';
513 $where .= ($and.
"costs = ".$ilDB->quote($this->options[
'lom_costs'] ,
'text').
" ");
515 if($this->options[
'lom_copyright'])
517 $and = $counter++ ?
'AND ' :
' ';
518 $where .= ($and.
"cpr_and_or = ".$ilDB->quote($this->options[
'lom_copyright'] ,
'text').
" ");
520 return $counter ? $where :
'';
530 if($this->options[
'lom_purpose'])
532 $and = $counter++ ?
'AND ' :
' ';
533 $where .= ($and.
"purpose = ".$ilDB->quote($this->options[
'lom_purpose']).
" ");
535 return $counter ? $where :
'';
545 if($this->options[
'lom_interactivity'])
547 $and = $counter++ ?
'AND ' :
' ';
548 $where .= ($and.
"interactivity_type = ".$ilDB->quote($this->options[
'lom_interactivity'] ,
'text').
" ");
550 if($this->options[
'lom_resource'])
552 $and = $counter++ ?
'AND ' :
' ';
553 $where .= ($and.
"learning_resource_type = ".$ilDB->quote($this->options[
'lom_resource'] ,
'text').
" ");
555 if($this->options[
'lom_user_role'])
557 $and = $counter++ ?
'AND ' :
' ';
558 $where .= ($and.
"intended_end_user_role = ".$ilDB->quote($this->options[
'lom_user_role'] ,
'text').
" ");
560 if($this->options[
'lom_context'])
562 $and = $counter++ ?
'AND ' :
' ';
563 $where .= ($and.
"context = ".$ilDB->quote($this->options[
'lom_context'] ,
'text').
" ");
565 if($this->options[
'lom_level_start'] or $this->options[
'lom_level_end'])
567 $and = $counter++ ?
'AND ' :
' ';
569 $fields = $this->
__getDifference($this->options[
'lom_level_start'],$this->options[
'lom_level_end'],
570 array(
'VeryLow',
'Low',
'Medium',
'High',
'VeryHigh'));
574 if($this->options[
'lom_density_start'] or $this->options[
'lom_density_end'])
576 $and = $counter++ ?
'AND ' :
' ';
578 $fields = $this->
__getDifference($this->options[
'lom_density_start'],$this->options[
'lom_density_end'],
579 array(
'VeryLow',
'Low',
'Medium',
'High',
'VeryHigh'));
583 if($this->options[
'lom_difficulty_start'] or $this->options[
'lom_difficulty_end'])
585 $and = $counter++ ?
'AND ' :
' ';
587 $fields = $this->
__getDifference($this->options[
'lom_difficulty_start'],$this->options[
'lom_difficulty_end'],
588 array(
'VeryEasy',
'Easy',
'Medium',
'Difficult',
'VeryDifficult'));
593 return $counter ? $where :
'';
603 if($this->options[
'lom_operating_system'])
605 $and = $counter++ ?
'AND ' :
' ';
606 $where .= ($and.
"operating_system_name = ".$ilDB->quote($this->options[
'lom_operating_system']).
" ");
608 if($this->options[
'lom_browser'])
610 $and = $counter++ ?
'AND ' :
' ';
611 $where .= ($and.
"browser_name = ".$ilDB->quote($this->options[
'lom_browser']).
" ");
613 return $counter ? $where :
'';
618 $a_val2 = $a_val2 ? $a_val2 : count($options);
620 if($a_val1 > $a_val2)
626 foreach($options as $option)
628 if($a_val1 > ++$counter)
632 if($a_val2 < $counter)
638 return $fields ? $fields : array();
648 $in .= implode(
"','",$a_fields);