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

Source for file opros.core.php

Documentation is available at opros.core.php

  1. <?php
  2. /**
  3.  * Обработчик опроса
  4.  * @author PHPShop Software
  5.  * @version 1.0
  6.  * @package PHPShopCore
  7.  */
  8.  
  9. class PHPShopOpros extends PHPShopCore {
  10.     
  11.     /**
  12.      * Конструктор
  13.      */
  14.     function PHPShopOpros({
  15.         global $PHPShopOprosElement;
  16.         
  17.         // Отладка
  18.         $this->debug=false;
  19.         
  20.         // Элименты опроса
  21.         $this->element=$PHPShopOprosElement;
  22.         
  23.         // Список экшенов
  24.         $this->action=array("post"=>"getopros","nav"=>"index","get"=>"add_forma");
  25.         parent::PHPShopCore();
  26.     }
  27.     
  28.     /**
  29.      * Экшен по умолчанию, вывод результата опроса
  30.      */
  31.     function index({
  32.         
  33.         // Выборка данных
  34.         $PHPShopOrm &new PHPShopOrm($this->getValue('base.table_name21'));
  35.         $PHPShopOrm->debug=$this->debug;
  36.         $dataArray=$PHPShopOrm->select(array('*'),array('flag'=>"='1'"),array('order'=>'id DESC'),array('limit'=>10));
  37.         $content='';
  38.         if(is_array($dataArray))
  39.             foreach($dataArray as $row{
  40.                 
  41.                 // Определяем переменные
  42.                 $content.="<h1>".$row['name']."</h1>";
  43.                 $content.=$this->element->getOprosValue($row['id'],"RESULT");
  44.                 $content.='<p><br></p>';
  45.                 
  46.             }
  47.         
  48.  
  49.         // Мета
  50.         $this->title="Опрос - ".$this->PHPShopSystem->getValue("name");
  51.  
  52.         $this->set('oprosName',false);
  53.         $this->set('oprosContent',$content);
  54.         
  55.         // Подключаем шаблон
  56.         $this->parseTemplate($this->getValue('templates.opros_page_list'));
  57.     }
  58.     
  59.     /**
  60.      * Экшен обновления опроса при наличии переменной $_POST[getopros]
  61.      */
  62.     function getopros({
  63.         
  64.         if(!empty($_COOKIE['opros']))
  65.             $this->update($_POST['getopros'],false);
  66.         else {
  67.             // Пишим куку
  68.             setcookie("opros"$_POST['getopros']time()+60*60*24*1"/opros/"$_SERVER['SERVER_NAME']0);
  69.             $this->update($_POST['getopros'],true);
  70.         }
  71.     }
  72.     
  73.     /**
  74.      * Запись опроса
  75.      * @param int $valueID ИД опроса
  76.      * @param Bool $flag проверка на новый голос
  77.      */
  78.     function update($valueID,$flag{
  79.         $valueID=PHPShopSecurity::TotalClean($valueID,1);
  80.         
  81.         // Новый голос
  82.         if($flag{
  83.             
  84.             $PHPShopOrm &new PHPShopOrm($this->getValue('base.table_name20'));
  85.             $dataArray=$PHPShopOrm->select(array('total'),array('id'=>"=$valueID"),false,array('limit'=>1));
  86.             $total=$dataArray['total']+1;
  87.             $PHPShopOrm->update(array('total'=>$total),array('id'=>"=$valueID"),$prefix='');
  88.             
  89.             
  90.             // Определяем переменные
  91.             $this->set('mesageText','<FONT style="font-size:14px;color:red"><B>'.$this->getValue('lang.good_opros_mesage_1').'</B></FONT>
  92.             <BR>'.$this->getValue('lang.good_opros_mesage_2'));
  93.             
  94.         }
  95.         
  96.         // Старый голос
  97.         else {
  98.             
  99.             // Определяем переменные
  100.             $this->set('mesageText','<FONT style="font-size:14px;color:red"><B>'.$this->getValue('lang.bad_opros_mesage_1').'</B></FONT>
  101.             <BR>'.$this->getValue('lang.bad_opros_mesage_2'));
  102.             
  103.         }
  104.         
  105.         $this->parseTemplate($this->getValue('templates.news_forma_mesage'));
  106.     }
  107.     
  108. }
  109. ?>

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