• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/MetaData/classes/class.ilMDSearch.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00036 class ilMDSearch
00037 {
00038         var $mode = '';
00039 
00040         /*
00041          * instance of query parser
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         // Private
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 ?>

Generated on Fri Dec 13 2013 10:18:31 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1