コード例 #1
0
ファイル: Topic.class.php プロジェクト: Azany/altocms
 /**
  * Returns tags array from topic
  *
  * @param object|int $xTopic
  *
  * @return array
  */
 protected function _getTagsFromTopic($xTopic)
 {
     if (is_object($xTopic)) {
         $aTopicTags = F::Str2Array($xTopic->getTags());
     } else {
         $aTopicTags = array();
         $iTopicId = intval($xTopic);
         $aTopics = $this->GetTopicsByArrayId(array($iTopicId));
         if ($aTopics) {
             $oTopic = reset($aTopics);
             $aTopicTags = F::Str2Array($oTopic->getTags());
         }
     }
     return $aTopicTags;
 }
コード例 #2
0
ファイル: HookMain.class.php プロジェクト: AntiqS/altocms
 /**
  * Обработка хука инициализации экшенов
  */
 public function InitAction()
 {
     // * Проверяем наличие директории install
     if (is_dir(rtrim(Config::Get('path.root.dir'), '/') . '/install') && (!isset($_SERVER['HTTP_APP_ENV']) || $_SERVER['HTTP_APP_ENV'] != 'test')) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('install_directory_exists'));
         R::Action('error');
     }
     // * Проверка на закрытый режим
     $oUserCurrent = E::ModuleUser()->GetUserCurrent();
     if (!$oUserCurrent && Config::Get('general.close.mode')) {
         $aEnabledActions = F::Str2Array(Config::Get('general.close.actions'));
         if (!in_array(R::GetAction(), $aEnabledActions)) {
             return R::Action('login');
         }
     }
     return null;
 }
コード例 #3
0
ファイル: Viewer.class.php プロジェクト: anp135/altocms
 /**
  * Initialization of skin
  *
  */
 protected function _initSkin()
 {
     $this->sViewSkin = $this->GetConfigSkin();
     // Load skin's config
     $aConfig = array();
     Config::ResetLevel(Config::LEVEL_SKIN);
     $aSkinConfigPaths['sSkinConfigCommonPath'] = Config::Get('path.smarty.template') . '/settings/config/';
     $aSkinConfigPaths['sSkinConfigAppPath'] = Config::Get('path.dir.app') . F::File_LocalPath($aSkinConfigPaths['sSkinConfigCommonPath'], Config::Get('path.dir.common'));
     // Может загружаться основной конфиг скина, так и внешние секции конфига,
     // которые задаются ключом 'config_load'
     // (обычно это 'classes', 'assets', 'jevix', 'widgets', 'menu')
     $aConfigNames = array('config') + F::Str2Array(Config::Get('config_load'));
     // Config section that are loaded for the current skin
     $aSkinConfigNames = array();
     // ** Old skin version compatibility
     $oSkin = E::ModuleSkin()->GetSkin($this->sViewSkin);
     if (!$oSkin || !$oSkin->GetCompatible() || $oSkin->SkinCompatible('1.1', '<')) {
         // 'head.default' may be used in skin config
         C::Set('head.default', C::Get('assets.default'));
     }
     // Load configs from paths
     foreach ($aConfigNames as $sConfigName) {
         foreach ($aSkinConfigPaths as $sPath) {
             $sFile = $sPath . $sConfigName . '.php';
             if (F::File_Exists($sFile)) {
                 $aSubConfig = F::IncludeFile($sFile, false, true);
                 if ($sConfigName != 'config' && !isset($aSubConfig[$sConfigName])) {
                     $aSubConfig = array($sConfigName => $aSubConfig);
                 } elseif ($sConfigName == 'config' && isset($aSubConfig['head'])) {
                     // ** Old skin version compatibility
                     $aSubConfig['assets'] = $aSubConfig['head'];
                     unset($aSubConfig['head']);
                 }
                 // загружаем конфиг, что позволяет сразу использовать значения
                 // в остальных конфигах скина (assets и кастомном config.php) через Config::Get()
                 Config::Load($aSubConfig, false, null, null, $sFile);
                 if ($sConfigName != 'config' && !isset($aSkinConfigNames[$sConfigName])) {
                     $aSkinConfigNames[$sConfigName] = $sFile;
                 }
             }
         }
     }
     if (!$oSkin || !$oSkin->GetCompatible() || $oSkin->SkinCompatible('1.1', '<')) {
         // 'head.default' may be used in skin config
         C::Set('head.default', false);
     }
     Config::ResetLevel(Config::LEVEL_SKIN_CUSTOM);
     $aStorageConfig = Config::ReadStorageConfig(null, true);
     // Reload sections changed by user
     if ($aSkinConfigNames) {
         foreach (array_keys($aSkinConfigNames) as $sConfigName) {
             if (isset($aStorageConfig[$sConfigName])) {
                 if (empty($aConfig)) {
                     $aConfig[$sConfigName] = $aStorageConfig[$sConfigName];
                 } else {
                     $aConfig = F::Array_MergeCombo($aConfig, array($sConfigName => $aStorageConfig[$sConfigName]));
                 }
             }
         }
     }
     // Checks skin's config from users settings
     $sUserConfigKey = 'skin.' . $this->sViewSkin . '.config';
     $aUserConfig = Config::Get($sUserConfigKey);
     if ($aUserConfig) {
         if (!$aConfig) {
             $aConfig = $aUserConfig;
         } else {
             $aConfig = F::Array_MergeCombo($aConfig, $aUserConfig);
         }
     }
     if ($aConfig) {
         Config::Load($aConfig, false, null, null, $sUserConfigKey);
     }
     // Check skin theme and set one in config if it was changed
     if ($this->GetConfigTheme() != Config::Get('view.theme')) {
         Config::Set('view.theme', $this->GetConfigTheme());
     }
     // Load lang files for skin
     E::ModuleLang()->LoadLangFileTemplate(E::ModuleLang()->GetLang());
     // Load template variables from config
     if (($aVars = Config::Get('view.assign')) && is_array($aVars)) {
         $this->Assign($aVars);
     }
 }
コード例 #4
0
ファイル: Viewer.class.php プロジェクト: ZeoNish/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();
 }
コード例 #5
0
ファイル: ActionAdmin.class.php プロジェクト: ZeoNish/altocms
 /**
  * Deletes user
  *
  * @return bool
  */
 protected function _eventUsersCmdDelete()
 {
     E::ModuleSecurity()->ValidateSendForm();
     $aUsersId = F::Str2Array(F::GetRequest('adm_user_list'), ',', true);
     $bResult = true;
     foreach ($aUsersId as $iUserId) {
         if ($iUserId == $this->oUserCurrent->GetId()) {
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.cannot_del_self'), null, true);
             $bResult = false;
             break;
         } elseif ($oUser = E::ModuleUser()->GetUserById($iUserId)) {
             if ($oUser->IsAdministrator()) {
                 E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.cannot_del_admin'), null, true);
                 $bResult = false;
                 break;
             } elseif (!F::GetRequest('adm_user_del_confirm') && !F::GetRequest('adm_bulk_confirm')) {
                 E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.cannot_del_confirm'), null, true);
                 $bResult = false;
                 break;
             } else {
                 E::ModuleAdmin()->DelUser($oUser->GetId());
                 E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('action.admin.user_deleted', array('user' => $oUser->getLogin())), null, true);
             }
         } else {
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.user_not_found'), null, true);
             $bResult = false;
             break;
         }
     }
     return $bResult;
 }
コード例 #6
0
ファイル: Lang.class.php プロジェクト: AntiqS/altocms
 /**
  * Получить алиасы языка по умолчанию
  *
  * @return array
  */
 public function GetDefaultLangAliases()
 {
     return F::Str2Array(Config::Get('lang.aliases.' . $this->GetDefaultLang()));
 }
コード例 #7
0
ファイル: Loader.class.php プロジェクト: Azany/altocms
 /**
  * @param array $aConfig
  */
 public static function Init($aConfig)
 {
     // Регистрация автозагрузчика классов
     spl_autoload_register('Loader::Autoload');
     Config::Load($aConfig);
     $sConfigDir = Config::Get('path.dir.config');
     // Load main config
     Config::LoadFromFile($sConfigDir . '/config.php', false);
     // Load additional config files if defined
     $aConfigLoad = F::Str2Array(Config::Get('config_load'));
     if ($aConfigLoad) {
         self::_loadConfigSections($sConfigDir, $aConfigLoad);
     }
     // Includes all *.php files from {path.root.engine}/include/
     $sIncludeDir = Config::Get('path.dir.engine') . '/include/';
     self::_includeAllFiles($sIncludeDir);
     // Load main config level (modules, local & plugins)
     self::_loadConfigFiles($sConfigDir, Config::LEVEL_MAIN);
     // Define app config dir
     $sAppConfigDir = Config::Get('path.dir.app') . '/config/';
     // Ups config level
     Config::ResetLevel(Config::LEVEL_APP);
     // Load application config level (modules, local & plugins)
     self::_loadConfigFiles($sAppConfigDir, Config::LEVEL_APP);
     // Load additional config files (the set could be changed in this point)
     $aConfigLoad = F::Str2Array(Config::Get('config_load'));
     if ($aConfigLoad) {
         self::_loadConfigSections($sAppConfigDir, $aConfigLoad, Config::LEVEL_APP);
     }
     // Load include files of plugins
     self::_loadIncludeFiles(Config::LEVEL_MAIN);
     self::_loadIncludeFiles(Config::LEVEL_APP);
     self::_checkRequiredDirs();
     $aSeekDirClasses = array(Config::Get('path.dir.app'), Config::Get('path.dir.common'), Config::Get('path.dir.engine'));
     Config::Set('path.root.seek', $aSeekDirClasses);
     if (is_null(Config::Get('path.root.subdir'))) {
         if (isset($_SERVER['DOCUMENT_ROOT'])) {
             $sPathSubdir = '/' . F::File_LocalPath(ALTO_DIR, $_SERVER['DOCUMENT_ROOT']);
         } elseif ($iOffset = Config::Get('path.offset_request_url')) {
             $aParts = array_slice(explode('/', F::File_NormPath(ALTO_DIR)), -$iOffset);
             $sPathSubdir = '/' . implode('/', $aParts);
         } else {
             $sPathSubdir = '';
         }
         Config::Set('path.root.subdir', $sPathSubdir);
     }
     // Подгружаем конфиг из файлового кеша, если он есть
     Config::ResetLevel(Config::LEVEL_CUSTOM);
     $aConfig = Config::ReadCustomConfig(null, true);
     if ($aConfig) {
         Config::Load($aConfig, false, null, null, 'custom');
     }
     // Задаем локаль по умолчанию
     F::IncludeLib('UserLocale/UserLocale.class.php');
     // Устанавливаем признак того, является ли сайт многоязычным
     $aLangsAllow = (array) Config::Get('lang.allow');
     if (sizeof($aLangsAllow) > 1) {
         UserLocale::initLocales($aLangsAllow);
         Config::Set('lang.multilang', true);
     } else {
         Config::Set('lang.multilang', false);
     }
     UserLocale::setLocale(Config::Get('lang.current'), array('local' => Config::Get('i18n.locale'), 'timezone' => Config::Get('i18n.timezone')));
     Config::Set('i18n', UserLocale::getLocale());
     F::IncludeFile(Config::Get('path.dir.engine') . '/classes/core/Engine.class.php');
 }
コード例 #8
0
ファイル: Loader.class.php プロジェクト: AntiqS/altocms
 /**
  * @param string $sConfigDir
  * @param int    $nConfigLevel
  */
 protected static function _loadConfigFiles($sConfigDir, $nConfigLevel)
 {
     // * Загружаем конфиги модулей вида /config/modules/[module_name]/config.php
     $sDirConfig = $sConfigDir . '/modules/';
     $aFiles = glob($sDirConfig . '*/config.php');
     if ($aFiles) {
         foreach ($aFiles as $sConfigFile) {
             $sDirModule = basename(dirname($sConfigFile));
             $aConfig = F::IncludeFile($sConfigFile, true, true);
             if (!empty($aConfig) && is_array($aConfig)) {
                 $sKey = 'module.' . $sDirModule;
                 Config::Load(array($sKey => $aConfig), false, null, $nConfigLevel, $sConfigFile);
             }
         }
     }
     /*
      * Подгружаем файлы локального конфига
      */
     $sConfigFile = $sConfigDir . '/config.local.php';
     if (F::File_Exists($sConfigFile)) {
         if ($aConfig = F::IncludeFile($sConfigFile, true, true)) {
             Config::Set($aConfig, false, null, $nConfigLevel, $sConfigFile);
         }
     }
     $aConfigSections = F::Str2Array(Config::Get('config_load'));
     /*
      * Загружает конфиг-файлы плагинов вида /plugins/[plugin_name]/config/*.php
      * и include-файлы вида /plugins/[plugin_name]/include/*.php
      */
     $sPluginsDir = F::GetPluginsDir($nConfigLevel == Config::LEVEL_APP);
     if ($aPluginsList = F::GetPluginsList(false, false)) {
         foreach ($aPluginsList as $sPlugin => $aPluginInfo) {
             // Paths to dirs of plugins
             Config::Set('path.dir.plugin.' . $aPluginInfo['id'], $aPluginInfo['path']);
             // Загружаем все конфиг-файлы плагина
             $aConfigFiles = glob($sPluginsDir . '/' . $aPluginInfo['dirname'] . '/config/*.php');
             if ($aConfigFiles) {
                 // move config.php to begin of array
                 if (sizeof($aConfigFiles) > 1) {
                     $sConfigFile = $sPluginsDir . '/' . $aPluginInfo['dirname'] . '/config/config.php';
                     $iIndex = array_search($sConfigFile, $aConfigFiles);
                     if ($iIndex) {
                         $aConfigFiles = array_merge(array_splice($aConfigFiles, $iIndex, 1), $aConfigFiles);
                     }
                 }
                 foreach ($aConfigFiles as $sConfigFile) {
                     $aConfig = F::IncludeFile($sConfigFile, true, true);
                     if (!empty($aConfig) && is_array($aConfig)) {
                         $sSectionName = pathinfo($sConfigFile, PATHINFO_FILENAME);
                         if (in_array($sSectionName, $aConfigSections)) {
                             // e.g "classes.php"
                             $aConfigRoot = $aConfig;
                             if (!isset($aConfigRoot[$sSectionName])) {
                                 $aConfigRoot = array($sSectionName => $aConfigRoot);
                             }
                             $aConfig = array();
                         } elseif (isset($aConfig[Config::KEY_ROOT])) {
                             $aConfigRoot = $aConfig[Config::KEY_ROOT];
                             unset($aConfig[Config::KEY_ROOT]);
                         } else {
                             $aConfigRoot = array();
                         }
                         if (!empty($aConfigRoot)) {
                             Config::Set($aConfigRoot, false, null, $nConfigLevel, $sConfigFile);
                         }
                         if (!empty($aConfig)) {
                             // Если конфиг этого плагина пуст, то загружаем массив целиком
                             $sKey = 'plugin.' . $sPlugin;
                             if (!Config::isExist($sKey)) {
                                 Config::Set($sKey, $aConfig, null, $nConfigLevel, $sConfigFile);
                             } else {
                                 // Если уже существуют привязанные к плагину ключи,
                                 // то сливаем старые и новое значения ассоциативно-комбинированно
                                 /** @see AltoFunc_Array::MergeCombo() */
                                 Config::Set($sKey, F::Array_MergeCombo(Config::Get($sKey), $aConfig), null, $nConfigLevel, $sConfigFile);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #9
0
ファイル: Img.class.php プロジェクト: hard990/altocms
 /**
  * Returns driver name by key
  *
  * @return string
  */
 public function GetDriver()
 {
     $sResult = '';
     $aDrivers = F::Str2Array(Config::Get('module.image.libs'));
     if ($aDrivers) {
         foreach ($aDrivers as $sDriver) {
             if (isset($this->aDrivers[$sDriver])) {
                 $sDriver = $this->aDrivers[$sDriver];
             }
             if (isset($this->aAvailableDrivers[$sDriver])) {
                 $sResult = $sDriver;
                 break;
             }
         }
     }
     if (!$sResult) {
         $sResult = $this->sDefaultDriver;
     }
     if (!isset($this->aInitDrivers[$sResult])) {
         $this->InitDriver($sResult);
         $this->aInitDrivers[$sResult] = true;
     }
     return $sResult;
 }