phpDocumentor PHPShopCore
[ class tree: PHPShopCore ] [ all elements ]

Source for file search.core.php

Documentation is available at search.core.php

  1. <?php
  2. /**
  3.  * Обработчик поиска
  4.  * @author PHPShop Software
  5.  * @version 1.1
  6.  * @package PHPShopCore
  7.  */
  8. class PHPShopSearch extends PHPShopCore {
  9.  
  10.     /**
  11.      * Конструктор
  12.      */
  13.     function PHPShopSearch({
  14.  
  15.         // Отладка
  16.         $this->debug=false;
  17.  
  18.         // Список экшенов
  19.         $this->action=array("post"=>"words","nav"=>"index");
  20.         parent::PHPShopCore();
  21.     }
  22.     /**
  23.      * Экшен по умолчанию, вывод формы
  24.      */
  25.     function index({
  26.         // Подключаем шаблон
  27.         $this->parseTemplate($this->getValue('templates.search_page_list'));
  28.     }
  29.  
  30.     /**
  31.      * Экшен выборки информации поиска при наличии переменной $_POST[words]
  32.      * Поиск по страницам и новостям
  33.      */
  34.     function words({
  35.  
  36.         // Проверка на плохие символы
  37.         $this->words=PHPShopSecurity::TotalClean($_POST['words'],4);
  38.  
  39.         // Страницы HTML
  40.         $j=0;
  41.         $dir="pageHTML/";
  42.  
  43.         $this->set('pageFrom',$this->getValue('system.path'));
  44.  
  45.         if ($dh opendir($dir)) {
  46.             while (($file readdir($dh)) !== false{
  47.                 if($file != "." and $file != ".."{
  48.                     $fp fopen($dir.$file"r");
  49.                     $fstat fstat($fp);
  50.                     $fread=@fread($fp,$fstat['size']);
  51.                     $Content=strip_tags($fread);
  52.                     fclose($fp);
  53.                     $patern="/\b".$this->words."\b/i";
  54.  
  55.  
  56.                     if (preg_match($patern,$Content)) {
  57.  
  58.                         $filename=explode(".",$file);
  59.  
  60.                         $meta=$this->getMeta($fread);
  61.                         if(empty($title)) $title=$filename[0].".html";
  62.  
  63.                         if(!empty($meta['title'])) {
  64.  
  65.                             // Определяем переменные
  66.                             $this->set('productName',$meta['title']);
  67.                             $this->set('pageWords',$this->words);
  68.                             $this->set('productKey',substr(strip_tags($Content),0,300)."...");
  69.                             $this->set('pageLink',$filename[0].".html");
  70.                             $i++;
  71.                             $this->set('productNum',$i);
  72.                             
  73.                             $this->addToTemplate($this->getValue('templates.main_search_forma'));
  74.                         }
  75.                     }
  76.  
  77.                 }
  78.  
  79.  
  80.             }
  81.  
  82.             closedir($dh);
  83.         }
  84.  
  85.         $this->set('pageTitle',$this->PHPShopSystem->getParam('name').' / Страницы');
  86.         $this->set('pageNumN',"Результат: страниц - "count($dataArray));
  87.  
  88.         $this->add('<p><br></p>',true);
  89.  
  90.  
  91.         $this->set('searchString',$this->words);
  92.  
  93.         // Подключаем шаблон
  94.         if($i==0$this->add('<h3>Ничего не найдено</h3><p><br></p>
  95.     <div style="padding:5;border-style: dashed;border-width: 1px;border-color:#D3D3D3"> 
  96.     Если вы <b>не нашли</b> нужную информацию, 
  97.     воспользуйтесь <a href="/map/">картой сайта</a>
  98.      </div>',true);
  99.  
  100.         // Мета
  101.         $this->title="Поиск - ".$this->PHPShopSystem->getValue("name");
  102.  
  103.         $this->parseTemplate($this->getValue('templates.search_page_list'));
  104.     }
  105. }
  106. ?>

Documentation generated on Mon, 25 Jun 2012 15:09:51 +0400 by phpDocumentor 1.4.3