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 $counter = 0;
00103 foreach($this->query_parser->getQuotedWords() as $word)
00104 {
00105 if($counter++)
00106 {
00107 $where .= strtoupper($this->query_parser->getCombination());
00108 }
00109 $where .= $field;
00110 $where .= ("LIKE (".$ilDB->quote("%".$word."%").")");
00111 }
00112
00113 $query = "SELECT * FROM il_meta_keyword".
00114 $where.
00115 "ORDER BY meta_keyword_id DESC";
00116
00117 $res = $this->db->query($query);
00118 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00119 {
00120 $this->search_result->addEntry($row->obj_id,$row->obj_type,$row->rbac_id);
00121 }
00122
00123 return $this->search_result;
00124 }
00125 }
00126 ?>