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 ilMDSearch
00037 {
00038 var $mode = '';
00039
00040
00041
00042
00043 var $query_parser = null;
00044
00045 var $db = null;
00046
00051 function ilMDSearch(&$qp_obj)
00052 {
00053 global $ilDB;
00054
00055 $this->query_parser =& $qp_obj;
00056 $this->db =& $ilDB;
00057
00058 include_once 'Services/Search/classes/class.ilSearchResult.php';
00059
00060 $this->search_result = new ilSearchResult();
00061 }
00062
00069 function setMode($a_mode)
00070 {
00071 $this->mode = $a_mode;
00072 }
00073 function getMode()
00074 {
00075 return $this->mode;
00076 }
00077
00078
00079 function &performSearch()
00080 {
00081 switch($this->getMode())
00082 {
00083 case 'all':
00084 break;
00085 case 'keyword':
00086 return $this->__searchKeywordsOnly();
00087 break;
00088
00089 default:
00090 echo "ilMDSearch::performSearch() no mode given";
00091 return false;
00092 }
00093 }
00094
00095
00096
00097
00098 function __searchKeywordsOnly()
00099 {
00100 $where = " WHERE ";
00101 $field = " keyword ";
00102 foreach($this->query_parser->getWords() as $word)
00103 {
00104 if($counter++)
00105 {
00106 $where .= strtoupper($this->query_parser->getCombination());
00107 }
00108 $where .= $field;
00109 $where .= ("LIKE ('%".$word."%')");
00110 }
00111
00112 $query = "SELECT * FROM il_meta_keyword".
00113 $where.
00114 "ORDER BY meta_keyword_id DESC";
00115
00116 $res = $this->db->query($query);
00117 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00118 {
00119 $this->search_result->addEntry($row->obj_id,$row->obj_type,$row->rbac_id);
00120 }
00121
00122 return $this->search_result;
00123 }
00124 }
00125 ?>