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

Source for file elements.class.php

Documentation is available at elements.class.php

  1. <?php
  2. /**
  3.  * Родительский класс создания элементов
  4.  * Примеры использования размещены в папке phpshop/inc/
  5.  * @author PHPShop Software
  6.  * @version 1.2
  7.  * @package PHPShopClass
  8.  */
  9. class PHPShopElements {
  10.     /**
  11.      * @var string имя БД
  12.      */
  13.     var $objBase;
  14.     var $objPath;
  15.     /**
  16.      * @var bool режим отладки
  17.      */
  18.     var $debug=false;
  19.     /**
  20.      * @var string результат работы парсера
  21.      */
  22.     var $Disp;
  23.     /**
  24.      * @var bool включить парсер php функций в *.html файлах
  25.      */
  26.     var $parser=false;
  27.     /**
  28.      * Конструктор
  29.      * @global obj $PHPShopSystem
  30.      * @global obj $PHPShopNav
  31.      * @global obj $PHPShopModules
  32.      */
  33.     function PHPShopElements({
  34.         global $PHPShopSystem,$PHPShopNav,$PHPShopModules;
  35.  
  36.         $this->SysValue=&$GLOBALS['SysValue'];
  37.         $this->PHPShopSystem=&$PHPShopSystem;
  38.         $this->PHPShopNav=&$PHPShopNav;
  39.         $this->LoadItems=&$GLOBALS['LoadItems'];
  40.         $this->PHPShopModules=&$PHPShopModules;
  41.     }
  42.  
  43.     /**
  44.      * Возврат содержимого файла
  45.      * @global array $SysValue настройки
  46.      * @param string $path имя файла без расширения
  47.      * @return string
  48.      */
  49.     function OpenHTML($path{
  50.         global $SysValue;
  51.         $dir="pageHTML/";
  52.         $pages=$path.".html";
  53.         $handle=opendir($dir);
  54.         while ($file readdir($handle)) {
  55.             if($file==$pages{
  56.                 $urlfile=fopen ("$dir$file","r");
  57.                 $text=fread($urlfile,1000000);
  58.                 $text=Parser($text,$this->parser);
  59.                 return $text;
  60.             }
  61.         }
  62.         return false;
  63.     }
  64.  
  65.     /**
  66.      * Добавление в переменную вывода через парсер
  67.      * @param string $template имя шаблона для паисинга
  68.      */
  69.     function addToTemplate($template{
  70.         $this->Disp.=ParseTemplateReturn($template);
  71.     }
  72.     /**
  73.      * Добавление в переменную вывода
  74.      * @param sting $content контент
  75.      */
  76.     function add($content{
  77.         $this->Disp.=$content;
  78.     }
  79.     /**
  80.      * Парсинг шаблона
  81.      * @param string $template имя шаблона
  82.      * @return string
  83.      */
  84.     function parseTemplate($template{
  85.         return ParseTemplateReturn($template);
  86.     }
  87.     /**
  88.      * Создание системной переменной для парсинга
  89.      * @param string $name имя
  90.      * @param mixed $value значение
  91.      * @param bool $flag [1] - добавить, [0] - переписать
  92.      */
  93.     function set($name,$value,$flag=false{
  94.         if($flag$this->SysValue['other'][$name].=$value;
  95.         else $this->SysValue['other'][$name]=$value;
  96.     }
  97.     /**
  98.      * Выдача системной переменной
  99.      * @param string $param раздел.имя переменной
  100.      * @return mixed
  101.      */
  102.     function getValue($param{
  103.         $param=explode(".",$param);
  104.         return $this->SysValue[$param[0]][$param[1]];
  105.     }
  106.     /**
  107.      * Выдача переменной из кэша
  108.      * @param string $param раздел.имя переменной
  109.      * @return string
  110.      */
  111.     function getValueCache($param{
  112.         return $this->LoadItems[$param];
  113.     }
  114.  
  115.     /**
  116.      * Иницилизация переменной по результату выполенния функции
  117.      * @param string $method_name имя функции
  118.      * @param bool $flag добавление данных в переменную
  119.      */
  120.     function init($method_name,$flag=false{
  121.  
  122.         // Если переменная не определена модулем
  123.         if(!empty($flagand $this->isAction($method_name)) $this->set($method_name,call_user_func(array(&$this$method_name)),true);
  124.  
  125.         elseif(empty($this->SysValue['other'][$method_name])) {
  126.             if($this->isAction($method_name)) $this->set($method_name,call_user_func(array(&$this$method_name)));
  127.             elseif($this->isAction("index")) $this->set($method_name,call_user_func(array(&$this'index')));
  128.             else $this->setError("index","метод не существует");
  129.         }
  130.     }
  131.  
  132.     /**
  133.      * Проверка экшена
  134.      * @param string $method_name имя метода
  135.      * @return bool
  136.      */
  137.     function isAction($method_name{
  138.         if(method_exists($this,$method_name)) return true;
  139.     }
  140.  
  141.     /**
  142.      * Сообщение об ошибке
  143.      * @param string $name имя функции
  144.      * @param string $action сообщение
  145.      */
  146.     function setError($name,$action{
  147.         echo '<p><span style="color:red">Ошибка обработчика события: </span> <strong>'.$name.'()</strong>
  148.      <br><em>'.$action.'</em></p>';
  149.     }
  150. }
  151. ?>

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