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

Services/Search/classes/class.ilMetaDataSearch.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 
00035 include_once 'Services/Search/classes/class.ilAbstractSearch.php';
00036 
00037 class ilMetaDataSearch extends ilAbstractSearch
00038 {
00039         var $mode = '';
00040 
00041         /*
00042          * instance of query parser
00043          */
00044         var $query_parser = null;
00045 
00046         var $db = null;
00047 
00052         function ilMetaDataSearch(&$qp_obj)
00053         {
00054                 parent::ilAbstractSearch($qp_obj);
00055         }
00056 
00063         function setMode($a_mode)
00064         {
00065                 $this->mode = $a_mode;
00066         }
00067         function getMode()
00068         {
00069                 return $this->mode;
00070         }
00071 
00072 
00073         function &performSearch()
00074         {
00075                 switch($this->getMode())
00076                 {
00077                         case 'keyword':
00078                                 return $this->__searchKeywords();
00079 
00080                         case 'contribute':
00081                                 return $this->__searchContribute();
00082 
00083                         case 'title':
00084                                 return $this->__searchTitles();
00085 
00086                         case 'description':
00087                                 return $this->__searchDescriptions();
00088 
00089                         default:
00090                                 echo "ilMDSearch::performSearch() no mode given";
00091                                 return false;
00092                 }
00093         }
00094 
00095 
00096 
00097         // Private
00098         function __createInStatement()
00099         {
00100                 if(!$this->getFilter())
00101                 {
00102                         return '';
00103                 }
00104                 else
00105                 {
00106                         $type = "('";
00107                         $type .= implode("','",$this->getFilter());
00108                         $type .= "')";
00109                         
00110                         $in = " AND obj_type IN ".$type;
00111 
00112                         return $in;
00113                 }
00114         }
00115         function __searchContribute()
00116         {
00117                 $this->setFields(array('entity'));
00118 
00119                 $in = $this->__createInStatement();
00120                 $where = $this->__createContributeWhereCondition();
00121                 $locate = $this->__createLocateString();
00122 
00123                 $query = "SELECT rbac_id,obj_id,obj_type ".
00124                         $locate.
00125                         "FROM il_meta_entity ".
00126                         $where." ".$in.' ';
00127 
00128                 $res = $this->db->query($query);
00129                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00130                 {
00131                         $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
00132                 }
00133 
00134                 return $this->search_result;
00135         }               
00136 
00137 
00138         function __searchKeywords()
00139         {
00140                 $this->setFields(array('keyword'));
00141 
00142                 $in = $this->__createInStatement();
00143                 $where = $this->__createKeywordWhereCondition();
00144                 $locate = $this->__createLocateString();
00145 
00146                 $query = "SELECT rbac_id,obj_id,obj_type ".
00147                         $locate.
00148                         "FROM il_meta_keyword ".
00149                         $where." ".$in.' ';
00150 
00151                 $res = $this->db->query($query);
00152                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00153                 {
00154                         $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
00155                 }
00156 
00157                 return $this->search_result;
00158         }               
00159         function __searchTitles()
00160         {
00161                 $this->setFields(array('title'));
00162 
00163                 $in = $this->__createInStatement();
00164                 $where = $this->__createTitleWhereCondition();
00165                 $locate = $this->__createLocateString();
00166 
00167                 $query = "SELECT rbac_id,obj_id,obj_type ".
00168                         $locate.
00169                         "FROM il_meta_general ".
00170                         $where." ".$in.' ';
00171 
00172                 $res = $this->db->query($query);
00173                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00174                 {
00175                         $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
00176                 }
00177 
00178                 return $this->search_result;
00179         }               
00180         function __searchDescriptions()
00181         {
00182                 $this->setFields(array('description'));
00183 
00184                 $in = $this->__createInStatement();
00185                 $where = $this->__createDescriptionWhereCondition();
00186                 $locate = $this->__createLocateString();
00187 
00188                 $query = "SELECT rbac_id,obj_id,obj_type ".
00189                         $locate.
00190                         "FROM il_meta_description ".
00191                         $where." ".$in.' ';
00192 
00193                 $res = $this->db->query($query);
00194                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00195                 {
00196                         $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
00197                 }
00198 
00199                 return $this->search_result;
00200         }               
00201 }
00202 ?>

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