• Main Page
  • Related Pages
  • 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');
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         }
00112         function getFilter()
00113         {
00114                 return $this->object_types ? $this->object_types : array();
00115         }
00116 
00122         function __createLocateString()
00123         {
00124                 if($this->query_parser->getCombination() == 'or')
00125                 {
00126                         return '';
00127                 }
00128                 if(count($this->fields) > 1)
00129                 {
00130                         $complete_str = 'CONCAT(';
00131                         $complete_str .= implode(',',$this->fields);
00132                         $complete_str .= ')';
00133                 }
00134                 else
00135                 {
00136                         $complete_str = $this->fields[0];
00137                 }
00138 
00139                 $counter = 0;
00140                 foreach($this->query_parser->getQuotedWords() as $word)
00141                 {
00142                         $locate .= (", LOCATE('".$word."',".$complete_str.") ");
00143                         $locate .= ("as found".$counter++." ");
00144                 }
00145                 
00146                 return $locate;
00147         }
00148 
00149         function __prepareFound(&$row)
00150         {
00151                 if($this->query_parser->getCombination() == 'or')
00152                 {
00153                         return array();
00154                 }
00155                 $counter = 0;
00156                 foreach($this->query_parser->getQuotedWords() as $word)
00157                 {
00158                         $res_found = "found".$counter++;
00159                         $found[] = $row->$res_found;
00160                 }
00161                 return $found ? $found : array();
00162         }
00163 
00164         function &performSearch()
00165         {
00166                 echo "Should be overwritten.";
00167         }
00168 
00169 
00170 }
00171 ?>

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