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

Services/Search/classes/class.ilAbstractSearch.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 ilAbstractSearch
00037 {
00038         /*
00039          * instance of db object
00040          */
00041         var $db = null;
00042         /*
00043          * instance of query parser
00044          */
00045         var $query_parser = null;
00046         
00047         /*
00048          * instance of result obj
00049          */
00050         var $search_result = null;
00051 
00052         /*
00053          * List of all searchable objects
00054          */
00055         var $object_types = array('cat','dbk','crs','fold','frm','grp','lm','sahs','glo','mep','htlm','exc','file','qpl','tst','svy','spl',
00056                                                  'chat','icrs','icla','webr','mcst','pg','st');
00057 
00058 
00063         function ilAbstractSearch(&$qp_obj)
00064         {
00065                 global $ilDB;
00066 
00067                 $this->query_parser =& $qp_obj;
00068                 $this->db =& $ilDB;
00069 
00070                 include_once 'Services/Search/classes/class.ilSearchResult.php';
00071 
00072                 $this->search_result = new ilSearchResult();
00073         }
00074 
00080         function setFields($a_fields)
00081         {
00082                 $this->fields = $a_fields;
00083         }
00084 
00090         function getFields()
00091         {
00092                 return $this->fields ? $this->fields : array();
00093         }
00094 
00100         function setFilter($a_filter)
00101         {
00102                 if(is_array($a_filter))
00103                 {
00104                         $this->object_types = $a_filter;
00105                 }
00106         }
00107 
00113         function appendToFilter($a_type)
00114         {
00115                 if(is_array($this->object_types))
00116                 {
00117                         if(in_array($a_type,$this->object_types))
00118                         {
00119                                 return false;
00120                         }
00121                 }
00122                 $this->object_types[] = $a_type;
00123                 
00124                 return true;
00125         }
00126 
00127 
00133         function getFilter()
00134         {
00135                 return $this->object_types ? $this->object_types : array();
00136         }
00137 
00143         function __createLocateString()
00144         {
00145                 if($this->query_parser->getCombination() == 'or')
00146                 {
00147                         return '';
00148                 }
00149                 if(count($this->fields) > 1)
00150                 {
00151                         $complete_str = 'CONCAT(';
00152                         $complete_str .= implode(',',$this->fields);
00153                         $complete_str .= ')';
00154                 }
00155                 else
00156                 {
00157                         $complete_str = $this->fields[0];
00158                 }
00159 
00160                 $counter = 0;
00161                 foreach($this->query_parser->getQuotedWords() as $word)
00162                 {
00163                         $locate .= (", LOCATE('".$word."',".$complete_str.") ");
00164                         $locate .= ("as found".$counter++." ");
00165                 }
00166                 
00167                 return $locate;
00168         }
00169 
00170         function __prepareFound(&$row)
00171         {
00172                 if($this->query_parser->getCombination() == 'or')
00173                 {
00174                         return array();
00175                 }
00176                 $counter = 0;
00177                 foreach($this->query_parser->getQuotedWords() as $word)
00178                 {
00179                         $res_found = "found".$counter++;
00180                         $found[] = $row->$res_found;
00181                 }
00182                 return $found ? $found : array();
00183         }
00184 
00185         function &performSearch()
00186         {
00187                 echo "Should be overwritten.";
00188         }
00189 
00190 
00191 }
00192 ?>

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