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

Services/AdvancedMetaData/classes/class.ilAdvancedMDSearch.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 
00033 include_once 'Services/Search/classes/class.ilAbstractSearch.php';
00034 
00035 class ilAdvancedMDSearch extends ilAbstractSearch
00036 {
00037         protected $definition;
00038         
00046         public function __construct($query_parser)
00047         {
00048                 parent::__construct($query_parser);
00049         }
00050         
00058         public function setDefinition($a_def)
00059         {
00060                 $this->definition = $a_def;
00061         }
00062         
00069         public function getDefinition()
00070         {
00071                 return $this->definition;
00072         }
00073         
00081         public function performSearch()
00082         {
00083                 $this->setFields(array('value'));
00084                 
00085                 $and = '';
00086                 if(count($this->getFilter()))
00087                 {
00088                         $and = "AND type IN ('".implode("','",$this->getFilter())."')";
00089                 }
00090                 
00091                 
00092                 switch($this->getDefinition()->getFieldType())
00093                 {
00094                         case ilAdvancedMDFieldDefinition::TYPE_DATE:
00095                                 $query = "SELECT amv.obj_id,type ".
00096                                         "FROM adv_md_values AS amv ".
00097                                         "JOIN object_data USING (obj_id) ".
00098                                         "WHERE value >= ".(int) $this->range_start." ".
00099                                         "AND value <= ".(int) $this->range_end." ".
00100                                         "AND field_id = ".$this->db->quote($this->getDefinition()->getFieldId())." ".
00101                                         $and;
00102                                 break;
00103                         
00104                         case ilAdvancedMDFieldDefinition::TYPE_SELECT:
00105                         case ilAdvancedMDFieldDefinition::TYPE_TEXT:
00106                                 $where = $this->__createWhereCondition();
00107                                 $locate = $this->__createLocateString();
00108                                 
00109                                 $query = "SELECT amv.obj_id,type ".
00110                                         $locate.
00111                                         "FROM adv_md_values as amv ".
00112                                         "JOIN object_data USING(obj_id) ".
00113                                         $where.
00114                                         "AND field_id = ".$this->db->quote($this->getDefinition()->getFieldId())." ".
00115                                         $and;
00116                                 break;
00117                         
00118                 }
00119                 
00120                 if($query)
00121                 {
00122                         $res = $this->db->query($query);
00123                         while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00124                         {
00125                                 $this->search_result->addEntry($row->obj_id,$row->type,$this->__prepareFound($row));
00126                         }
00127                 }
00128                 return $this->search_result;
00129         }
00130         
00139         public function setTimeRange($start,$end)
00140         {
00141                 $this->range_start = $start;
00142                 $this->range_end = $end;
00143         }
00144         
00145 }
00146 
00147 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1