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.         // 1. Выборка данных страницы
  40.         $this->set('pageFrom',"page");
  41.         $this->set('pageDomen',$_SERVER['SERVER_NAME']."/page/");
  42.         $j=0;
  43.         $i=0;
  44.  
  45.         $PHPShopOrm &new PHPShopOrm($this->getValue('base.table_name11'));
  46.         $PHPShopOrm->debug=$this->debug;
  47.         $dataArray=$PHPShopOrm->select(array('*'),array('content'=>" LIKE '%".$this->words."%'","enabled"=>"!='0'"),array('order'=>'link'),array('limit'=>100));
  48.         if(is_array($dataArray))
  49.             foreach($dataArray as $row{
  50.  
  51.                 // Определяем переменные
  52.                 $this->set('productName',$row['name']);
  53.                 $this->set('pageWords',$this->words);
  54.                 $this->set('productKey',substr(strip_tags($row['content']),0,300)."...");
  55.                 $this->set('pageLink',$row['link'].".html");
  56.                 $i++;
  57.                 $this->set('productNum',$i);
  58.  
  59.                 if($j==0{
  60.                     $this->set('pageTitle',$this->PHPShopSystem->getParam('name').' / Страницы');
  61.                     $this->set('pageNumN',"Результат: страниц - "count($dataArray));
  62.                 }
  63.                 else {
  64.                     $this->set('pageTitle',false);
  65.                     $this->set('pageNumN',false);
  66.                 }
  67.  
  68.                 $j++;
  69.  
  70.  
  71.  
  72.                 // Подключаем шаблон
  73.                 $this->addToTemplate($this->getValue('templates.main_search_forma'));
  74.             }
  75.  
  76.        $this->add('<p><br></p>',true);
  77.  
  78.         // 2. Выборка данных новости
  79.         $this->set('pageFrom',"news");
  80.         $this->set('pageDomen',$_SERVER['SERVER_NAME']."/news/");
  81.         $j=0;
  82.         
  83.         $PHPShopOrm &new PHPShopOrm($this->getValue('base.table_name8'));
  84.         $PHPShopOrm->debug=$this->debug;
  85.         $PHPShopOrm->Option['where']=" or ";
  86.         $dataArray=$PHPShopOrm->select(array('*'),array('description'=>" LIKE '%".$this->words."%'",'title'=>" LIKE '%".$this->words."%'",
  87.                 'content'=>" LIKE '%".$this->words."%'"),array('order'=>'id desc'),array('limit'=>100));
  88.         if(is_array($dataArray))
  89.             foreach($dataArray as $row{
  90.  
  91.                 // Определяем переменные
  92.                 $this->set('productName',$row['title']);
  93.                 $this->set('pageWords',$this->words);
  94.                 $this->set('productKey',substr(strip_tags($row['description']),0,300)."...");
  95.                 $this->set('pageLink',"ID_".$row['id'].".html");
  96.                 $i++;
  97.                 $this->set('productNum',$i);
  98.  
  99.                 if($j==0{
  100.                     $this->set('pageTitle',$this->PHPShopSystem->getParam('name').' / Новости');
  101.                     $this->set('pageNumN',"Результат: страниц - "count($dataArray));
  102.                 }
  103.                 else {
  104.                     $this->set('pageTitle',false);
  105.                     $this->set('pageNumN',false);
  106.                 }
  107.  
  108.                 $j++;
  109.  
  110.                 // Подключаем шаблон
  111.                 $this->addToTemplate($this->getValue('templates.main_search_forma'));
  112.             }
  113.  
  114.  
  115.         $this->set('searchString',$this->words);
  116.  
  117.         // Подключаем шаблон
  118.         if($i==0$this->add('<h3>Ничего не найдено</h3><p><br></p>
  119.     <div style="padding:5;border-style: dashed;border-width: 1px;border-color:#D3D3D3"> 
  120.     Если вы <b>не нашли</b> нужную информацию, 
  121.     воспользуйтесь <a href="/map/">картой сайта</a>
  122.      </div>',true);
  123.  
  124.          // Мета
  125.         $this->title="Поиск - ".$this->PHPShopSystem->getValue("name");
  126.             
  127.         $this->parseTemplate($this->getValue('templates.search_page_list'));
  128.     }
  129. }
  130. ?>

Documentation generated on Thu, 17 Feb 2011 15:58:52 +0300 by phpDocumentor 1.4.3