Exemplo n.º 1
0
 /**
  * Инициализация вьюера
  *
  * @param bool $bLocal
  *
  * @return null|string
  */
 public function Init($bLocal = false)
 {
     $this->bLocal = $bLocal;
     // если не созданы вспомогательные папки, то создаем
     if (!is_dir(Config::Get('path.smarty.compiled'))) {
         @mkdir(Config::Get('path.smarty.compiled'), 0775, true);
     }
     if (!is_dir(Config::Get('path.smarty.cache'))) {
         @mkdir(Config::Get('path.smarty.cache'), 0775, true);
     }
     $xResult = parent::Init($bLocal);
     $this->sCurentPath = ACE::CurrentRoute();
     // хуки шаблонизатора
     $this->InitHooks();
     if (Config::Get($this->sPlugin . '.saved.path.smarty.template')) {
         $this->AddTemplateDir(Config::Get($this->sPlugin . '.saved.path.smarty.template'));
     }
     $this->oSmarty->addPluginsDir(dirname(__FILE__) . '/plugs');
     $this->oSmarty->default_template_handler_func = array($this, 'TemplateHandler');
     // устанавливаем опции Smarty
     $this->aSmartyOptions = (array) Config::Get('plugin.aceadminpanel.smarty.options');
     foreach ($this->aSmartyOptions as $sKey => $xVal) {
         switch ($sKey) {
             case 'compile_check':
                 $this->oSmarty->compile_check = (bool) $xVal;
                 break;
             case 'force_compile':
                 // Если массив, то задаются значения для разных путей
                 if (is_array($xVal)) {
                     $bResult = null;
                     foreach ($xVal as $sKey => $aPaths) {
                         if (!is_array($aPaths)) {
                             $aPaths = explode(',', $aPaths);
                         }
                         if (ACE::InPath($this->sCurentPath, $aPaths)) {
                             $bResult = (is_null($bResult) ? true : false and ACE::Boolean($sKey));
                         } else {
                             // Если есть только ключи 'off', то считаем, что по умолчанию - 'on'
                             if (is_null($bResult) and !ACE::Boolean($sKey)) {
                                 $bResult = true;
                             }
                         }
                     }
                 } else {
                     $bResult = ACE::Boolean($xVal);
                 }
                 $this->oSmarty->force_compile = (bool) $bResult;
                 break;
             case 'caching':
                 if ($xVal === true) {
                     $xVal = 1;
                 } elseif (intval($xVal) > 2) {
                     $xVal = 1;
                 } elseif (intval($xVal) < 0) {
                     $xVal = 0;
                 }
                 $this->oSmarty->caching = intval($xVal);
                 break;
             case 'cache_lifetime':
                 $this->oSmarty->cache_lifetime = intval($xVal);
                 break;
         }
     }
     return $xResult;
 }