コード例 #1
0
ファイル: Viewer.class.php プロジェクト: anp135/altocms
 /**
  * Инициализация шаблонизатора
  *
  */
 protected function _tplInit()
 {
     if ($this->oSmarty) {
         return;
     }
     // * Создаём объект Smarty
     $this->oSmarty = $this->CreateSmartyObject();
     // * Устанавливаем необходимые параметры для Smarty
     $this->oSmarty->compile_check = (bool) Config::Get('smarty.compile_check');
     $this->oSmarty->force_compile = (bool) Config::Get('smarty.force_compile');
     $this->oSmarty->merge_compiled_includes = (bool) Config::Get('smarty.merge_compiled_includes');
     // * Подавляем NOTICE ошибки - в этом вся прелесть смарти )
     $this->oSmarty->error_reporting = error_reporting() & ~E_NOTICE;
     // * Папки расположения шаблонов по умолчанию
     $aDirs = F::File_NormPath(F::Str2Array(Config::Get('path.smarty.template')));
     if (sizeof($aDirs) == 1) {
         $sDir = $aDirs[0];
         $aDirs['themes'] = F::File_NormPath($sDir . '/themes');
         $aDirs['tpls'] = F::File_NormPath($sDir . '/tpls');
     }
     $this->oSmarty->setTemplateDir($aDirs);
     if (Config::Get('smarty.dir.templates')) {
         $this->oSmarty->addTemplateDir(F::File_NormPath(F::Str2Array(Config::Get('smarty.dir.templates'))));
     }
     // * Для каждого скина устанавливаем свою директорию компиляции шаблонов
     $sCompilePath = F::File_NormPath(Config::Get('path.smarty.compiled'));
     F::File_CheckDir($sCompilePath);
     $this->oSmarty->setCompileDir($sCompilePath);
     $this->oSmarty->setCacheDir(Config::Get('path.smarty.cache'));
     // * Папки расположения пдагинов Smarty
     $this->oSmarty->addPluginsDir(array(Config::Get('path.smarty.plug'), 'plugins'));
     if (Config::Get('smarty.dir.plugins')) {
         $this->oSmarty->addPluginsDir(F::File_NormPath(F::Str2Array(Config::Get('smarty.dir.plugins'))));
     }
     $this->oSmarty->default_template_handler_func = array($this, 'SmartyDefaultTemplateHandler');
     // * Параметры кеширования, если заданы
     if (Config::Get('smarty.cache_lifetime')) {
         $this->oSmarty->caching = Smarty::CACHING_LIFETIME_SAVED;
         $this->oSmarty->cache_lifetime = F::ToSeconds(Config::Get('smarty.cache_lifetime'));
     }
     // Settings for Smarty 3.1.16 and more
     $this->oSmarty->inheritance_merge_compiled_includes = false;
     F::IncludeFile('./plugs/resource.file.php');
     $this->oSmarty->registerResource('file', new Smarty_Resource_File());
     // Mutes expected Smarty minor errors
     $this->oSmarty->muteExpectedErrors();
 }
コード例 #2
0
 /**
  * @param string $sFile
  *
  * @return string|bool
  */
 public function SaveUpload($sFile)
 {
     if ($oImage = $this->GetImage()) {
         if ($sTmpFile = F::File_GetUploadDir() . F::RandomStr() . '.' . pathinfo($sFile, PATHINFO_EXTENSION)) {
             if (F::File_CheckDir(dirname($sTmpFile))) {
                 $oImage->save($sTmpFile);
                 if (E::ModuleUploader()->Move($sTmpFile, $sFile)) {
                     return $sFile;
                 }
             }
         }
     }
     return false;
 }
コード例 #3
0
ファイル: index.php プロジェクト: hard990/altocms
 /**
  * @param string      $sDir
  * @param string|null $sVarName
  *
  * @return bool
  */
 protected function checkDir($sDir, $sVarName = null)
 {
     if (!F::File_CheckDir($sDir)) {
         if ($sVarName) {
             $this->Assign($sVarName, '<span style="color:red;">' . $this->Lang('no') . '</span>');
         }
         $bResult = false;
     } else {
         if ($sVarName) {
             $this->Assign($sVarName, '<span style="color:green;">' . $this->Lang('yes') . '</span>');
         }
         $bResult = true;
     }
     return $bResult;
 }
コード例 #4
0
ファイル: Cache.class.php プロジェクト: AlexSSN/altocms
 /**
  * Инициализируем нужный тип кеша
  *
  */
 public function Init()
 {
     $this->bUseCache = C::Get('sys.cache.use');
     $this->sCacheType = C::Get('sys.cache.type');
     $this->sCachePrefix = $this->GetCachePrefix();
     $aCacheTypes = (array) C::Get('sys.cache.backends');
     // Доступные механизмы кеширования
     $this->aCacheTypesAvailable = array_map('strtolower', array_keys($aCacheTypes));
     // Механизмы принудительного кеширования
     $this->aCacheTypesForce = (array) C::Get('sys.cache.force');
     if ($this->aCacheTypesForce === true) {
         // Разрешены все
         $this->aCacheTypesForce = $this->aCacheTypesAvailable;
     } else {
         // Разрешены только те, которые есть в списке доступных
         $this->aCacheTypesForce = array_intersect(array_map('strtolower', $this->aCacheTypesForce), $this->aCacheTypesAvailable);
     }
     // По умолчанию кеширование данных полностью отключено
     $this->nCacheMode = self::CACHE_MODE_NONE;
     if ($this->_backendIsAvailable($this->sCacheType)) {
         if ($this->bUseCache) {
             // Включено автокеширование
             $this->nCacheMode = $this->nCacheMode | self::CACHE_MODE_AUTO | self::CACHE_MODE_REQUEST;
         } else {
             // Включено кеширование по запросу
             $this->nCacheMode = $this->nCacheMode | self::CACHE_MODE_REQUEST;
         }
         // Инициализация механизма кеширования по умолчанию
         $this->_backendInit($this->sCacheType);
     }
     if ($this->aCacheTypesForce) {
         // Разрешено принудительное кеширование
         $this->nCacheMode = $this->nCacheMode | self::CACHE_MODE_FORCE;
     }
     if ($this->nCacheMode != self::CACHE_MODE_NONE) {
         // Дабы не засорять место протухшим кешем, удаляем его в случайном порядке, например 1 из 50 раз
         if (rand(1, $this->nRandClearOld) == 33) {
             $this->Clean(Zend_Cache::CLEANING_MODE_OLD);
         }
     }
     $sCheckFile = C::Get('sys.cache.dir') . self::CHECK_FILENAME;
     if (F::File_CheckDir(C::Get('sys.cache.dir'), true)) {
         // If the control file is not present, then we need to clear cache and create
         if (!F::File_Exists($sCheckFile)) {
             $this->Clean();
         }
     }
     return $this->nCacheMode;
 }
コード例 #5
0
ファイル: Uploader.class.php プロジェクト: AntiqS/altocms
 /**
  * @param int  $iUserId
  * @param bool $bAutoMake
  *
  * @return string
  */
 public function GetUserFileDir($iUserId, $bAutoMake = true)
 {
     $sResult = $this->GetUserFilesUploadDir($iUserId) . date('Y/m/d/');
     if ($bAutoMake) {
         F::File_CheckDir($sResult, $bAutoMake);
     }
     return $sResult;
 }
コード例 #6
0
ファイル: Loader.class.php プロジェクト: Azany/altocms
 /**
  * Check required dirs
  */
 protected static function _checkRequiredDirs()
 {
     $sDir = Config::Get('path.dir.app');
     if (!$sDir) {
         die('Application directory not defined');
     } elseif (!F::File_CheckDir($sDir, false)) {
         die('Application directory "' . F::File_LocalDir(Config::Get('path.dir.app')) . '" is not exist');
     }
     $sDir = Config::Get('path.tmp.dir');
     if (!$sDir) {
         die('Directory for temporary files not defined');
     } elseif (!F::File_CheckDir($sDir, true)) {
         die('Directory for temporary files "' . $sDir . '" does not exist');
     } elseif (!is_writeable($sDir)) {
         die('Directory for temporary files "' . F::File_LocalDir($sDir) . '" is not writeable');
     }
     $sDir = Config::Get('path.runtime.dir');
     if (!$sDir) {
         die('Directory for runtime files not defined');
     } elseif (!F::File_CheckDir($sDir, true)) {
         die('Directory for runtime files "' . $sDir . '" does not exist');
     } elseif (!is_writeable($sDir)) {
         die('Directory for runtime files "' . F::File_LocalDir($sDir) . '" is not writeable');
     }
 }
コード例 #7
0
ファイル: function.php プロジェクト: AntiqS/altocms
/**
 * Создаёт каталог по полному пути
 *
 * @param string $sBasePath
 * @param string $sNewDir
 */
function func_mkdir($sBasePath, $sNewDir)
{
    $sDirToCheck = rtrim($sBasePath, '/') . '/' . $sNewDir;
    return F::File_CheckDir($sDirToCheck);
}
コード例 #8
0
 public static function IsAvailable()
 {
     return F::File_CheckDir(Config::Get('sys.cache.dir'), true);
 }