[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_module/mod_shop/inc/ -> frontend.search.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // Module/Plug-in Shop & Products search class
  24  
  25  class ModuleShopSearch {
  26  
  27      var $search_words            = array();
  28      var $search_result_entry    = 0;
  29      var $search_results            = array();
  30      var $search_highlight        = false;
  31      var $search_highlight_words    = false;
  32      var $search_wordlimit        = 0;
  33      var $ellipse_sign            = '&#8230;';
  34  
  35  	function search() {
  36      
  37          if(count($this->search_words)==0) {
  38              return NULL;
  39          } else {
  40              $this->search_words = implode('|', $this->search_words);
  41          }
  42          
  43          $shop_url = _getConfig( 'shop_pref_id_shop', '_shopPref' );
  44          
  45          if(!is_numeric($shop_url) && is_string($shop_url)) {
  46              $shop_url    = trim($shop_url);
  47          } elseif(is_numeric($shop_url) && intval($shop_url)) {
  48              $shop_url    = 'aid='.intval($shop_url);
  49          } else {
  50              $shop_url    = $GLOBALS['aktion'][1] ? 'aid='.$GLOBALS['aktion'][1] : 'id='.$GLOBALS['aktion'][0];
  51          }
  52      
  53          $sql  = 'SELECT shopprod_id, shopprod_category, shopprod_ordernumber, ';
  54          $sql .= 'shopprod_name1, ';
  55          $sql .= 'UNIX_TIMESTAMP(shopprod_changedate) AS shopprod_date, ';
  56          $sql .= 'CONCAT(';
  57          $sql .= "    shopprod_description0,' ',";
  58          $sql .= "    shopprod_description1,' ',";
  59          $sql .= "    shopprod_description2,' ',";
  60          $sql .= "    shopprod_description3,' ',";
  61          $sql .= "    shopprod_color,' ',";
  62          $sql .= "    shopprod_size,' ',";
  63          $sql .= "    shopprod_ordernumber,' ',";
  64          $sql .= "    shopprod_model,' ',";
  65          $sql .= "    shopprod_name1,' ',";
  66          $sql .= "    shopprod_name2,' '";
  67          $sql .= ') AS shopprod_search ';
  68          $sql .= 'FROM '.DB_PREPEND.'phpwcms_shop_products WHERE shopprod_status=1';
  69          $data = _dbQuery($sql);
  70          
  71          foreach($data as $value) {
  72          
  73              $s_result    = array();
  74          
  75              $s_text        = $value['shopprod_search'];
  76              $s_text        = str_replace( array('~', '|', ':', 'http', '//', '_blank', '&nbsp;') , ' ', $s_text );
  77              $s_text        = clean_replacement_tags($s_text, '');
  78              $s_text        = remove_unsecure_rptags($s_text);
  79              $s_text        = cleanUpSpecialHtmlEntities($s_text);
  80              
  81              preg_match_all('/'.$this->search_words.'/is', $s_text, $s_result );
  82  
  83              $s_count    = 0; //set search_result to 0
  84              foreach($s_result as $svalue) {
  85                  $s_count += count($svalue);
  86              }
  87              
  88              if($s_count) {
  89  
  90                  $id = $this->search_result_entry;
  91                  
  92                  $s_title  = $value['shopprod_ordernumber'] ? trim($value['shopprod_ordernumber']).': ' : '';
  93                  $s_title .= $value['shopprod_name1'];
  94                  $s_title  = html_specialchars($s_title);
  95  
  96                  $s_text   = trim($s_text);
  97                  $s_text   = getCleanSubString($s_text, $this->search_wordlimit, $this->ellipse_sign, 'word');
  98                  $s_text   = html_specialchars($s_text);
  99                  
 100                  $this->search_results[$id]["id"]    = $value['shopprod_id'];
 101                  $this->search_results[$id]["cid"]    = 0;
 102                  $this->search_results[$id]["rank"]    = $s_count;
 103                  $this->search_results[$id]["title"]    = $this->search_highlight ? highlightSearchResult($s_title, $this->search_highlight_words) : $s_title;
 104                  $this->search_results[$id]["date"]    = $value['shopprod_date'];
 105                  $this->search_results[$id]["user"]    = '';
 106                  $this->search_results[$id]['query']    = $shop_url.'&amp;shop_cat='.$value['shopprod_category'].'&amp;shop_detail='.$value['shopprod_id'];
 107                  
 108                  if($this->search_highlight) {
 109                      $s_text = highlightSearchResult($s_text, $this->search_highlight_words);
 110                  }
 111                  $this->search_results[$id]["text"]    = $s_text;
 112                  
 113                  $this->search_result_entry++;
 114              }
 115          }
 116      }
 117  
 118  }
 119  
 120  
 121  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7