コード例 #1
0
ファイル: Func.php プロジェクト: AntiqS/altocms
 /**
  * Получить список плагинов
  *
  * @param bool $bAll     - все плагины (иначе - только активные)
  * @param bool $bIdOnly  - только Id плагинов (иначе - вся строка с информацией о плагине)
  *
  * @return array
  */
 public static function GetPluginsList($bAll = false, $bIdOnly = true)
 {
     $sPluginsDatFile = static::GetPluginsDatFile();
     if (isset(self::$_aPluginList[$sPluginsDatFile][$bAll])) {
         $aPlugins = self::$_aPluginList[$sPluginsDatFile][$bAll];
     } else {
         $sCommonPluginsDir = static::GetPluginsDir();
         $aPlugins = array();
         $aPluginsRaw = array();
         if ($bAll) {
             $aFiles = glob($sCommonPluginsDir . '{*,*/*}/plugin.xml', GLOB_BRACE);
             if ($aFiles) {
                 foreach ($aFiles as $sXmlFile) {
                     $aPluginInfo = array();
                     $sXmlText = F::File_GetContents($sXmlFile);
                     $sDirName = dirname(F::File_LocalPath($sXmlFile, $sCommonPluginsDir));
                     if (preg_match('/\\<id\\>([\\w\\.\\/]+)\\<\\/id\\>/', $sXmlText, $aMatches)) {
                         $aPluginInfo['id'] = $aMatches[1];
                     } else {
                         $aPluginInfo['id'] = $sDirName;
                     }
                     $aPluginInfo['dirname'] = $sDirName;
                     $aPluginInfo['path'] = dirname($sXmlFile) . '/';
                     $aPluginInfo['manifest'] = $sXmlFile;
                     $aPlugins[$aPluginInfo['id']] = $aPluginInfo;
                 }
             }
         } else {
             if (is_file($sPluginsDatFile) && ($aPluginsRaw = @file($sPluginsDatFile))) {
                 $aPluginsRaw = array_map('trim', $aPluginsRaw);
                 $aPluginsRaw = array_unique($aPluginsRaw);
             }
             if ($aPluginsRaw) {
                 foreach ($aPluginsRaw as $sPluginStr) {
                     if (($n = strpos($sPluginStr, ';')) !== false) {
                         if ($n === 0) {
                             continue;
                         }
                         $sPluginStr = trim(substr($sPluginStr, 0, $n));
                     }
                     if ($sPluginStr) {
                         $aPluginInfo = str_word_count($sPluginStr, 1, '0..9/_');
                         $aPluginInfo['id'] = $aPluginInfo[0];
                         if (empty($aPluginInfo[1])) {
                             $aPluginInfo['dirname'] = $aPluginInfo[0];
                         } else {
                             $aPluginInfo['dirname'] = $aPluginInfo[1];
                         }
                         $sXmlFile = $sCommonPluginsDir . '/' . $aPluginInfo['dirname'] . '/plugin.xml';
                         if (is_file($sXmlFile)) {
                             $aPluginInfo['path'] = dirname($sXmlFile) . '/';
                             $aPluginInfo['manifest'] = $sXmlFile;
                             $aPlugins[$aPluginInfo['id']] = $aPluginInfo;
                         }
                     }
                 }
             }
         }
         $aPlugins = self::ExcludeByEnabledMask($aPlugins);
         self::$_aPluginList[$sPluginsDatFile][$bAll] = $aPlugins;
     }
     if ($bIdOnly) {
         $aPlugins = array_keys($aPlugins);
     }
     return $aPlugins;
 }
コード例 #2
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);
     }
 }
コード例 #3
0
ファイル: Viewer.class.php プロジェクト: ZeoNish/altocms
 /**
  * Initialization of skin
  *
  */
 protected function _initSkin()
 {
     $this->sViewSkin = $this->GetConfigSkin();
     // Load skin's config
     $aConfig = array();
     if (F::File_Exists($sFile = Config::Get('path.smarty.template') . '/settings/config/config.php')) {
         $aConfig = F::IncludeFile($sFile, FALSE, TRUE);
     }
     if (F::File_Exists($sFile = Config::Get('path.smarty.template') . '/settings/config/menu.php')) {
         $aConfig = F::Array_MergeCombo($aConfig, F::IncludeFile($sFile, false, true));
     }
     //        $aConfigLoad = F::Str2Array(Config::Get('config_load'));
     //        if ($aConfigLoad) {
     //            foreach ($aConfigLoad as $sConfigName) {
     //                if (F::File_Exists($sFile = Config::Get('path.smarty.template') . "/settings/config/$sConfigName.php")) {
     //                    $aConfig = array_merge($aConfig, F::IncludeFile($sFile, false, true));
     //                }
     //            }
     //        }
     // Checks skin's config in app dir
     $sFile = Config::Get('path.dir.app') . F::File_LocalPath($sFile, Config::Get('path.dir.common'));
     if (F::File_Exists($sFile)) {
         $aConfig = F::Array_MergeCombo($aConfig, F::IncludeFile($sFile, false, true));
     }
     // Checks skin's config from users settings
     $aUserConfig = Config::Get('skin.' . $this->sViewSkin . '.config');
     if ($aUserConfig) {
         if (!$aConfig) {
             $aConfig = $aUserConfig;
         } else {
             $aConfig = F::Array_MergeCombo($aConfig, $aUserConfig);
         }
     }
     Config::ResetLevel(Config::LEVEL_SKIN);
     if ($aConfig) {
         Config::Load($aConfig, false, null, null, 'skin');
     }
     // 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());
     // Skip skin widgets for local viewer
     if (!$this->bLocal) {
         // * Load skin widgets
         if (F::File_Exists($sFile = Config::Get('path.smarty.template') . '/settings/config/widgets.php')) {
             $aSkinWidgets = F::IncludeFile($sFile, false, true);
             if (isset($aSkinWidgets['widgets']) && is_array($aSkinWidgets['widgets']) && count($aSkinWidgets['widgets'])) {
                 $aWidgets = array_merge(Config::Get('widgets'), $aSkinWidgets['widgets']);
                 Config::Set('widgets', $aWidgets);
             }
         }
     }
     // Load template variables from config
     if (($aVars = Config::Get('view.assign')) && is_array($aVars)) {
         $this->Assign($aVars);
     }
 }
コード例 #4
0
ファイル: ViewerAsset.class.php プロジェクト: AntiqS/altocms
 public function AssetFileDir2Url($sAssetFile)
 {
     $sFilePath = F::File_LocalPath($sAssetFile, F::File_GetAssetDir());
     return F::File_GetAssetUrl() . $sFilePath;
 }
コード例 #5
0
ファイル: Lang.class.php プロジェクト: AntiqS/altocms
 /**
  * Загружает языковой файл текущего шаблона
  *
  * @param string $sLangName    Язык для загрузки
  */
 public function LoadLangFileTemplate($sLangName = null, $sLangFor = null)
 {
     $aLangPaths = array(Config::Get('path.smarty.template') . '/settings/language/');
     $aLangPaths[] = Config::Get('path.dir.app') . F::File_LocalPath($aLangPaths[0], Config::Get('path.dir.common'));
     $this->_loadFiles($aLangPaths, $sLangName, null, $sLangFor);
 }
コード例 #6
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');
 }
コード例 #7
0
 /**
  * Создание ресурса из одиночного файла
  *
  * @param string $sAsset
  * @param array  $aFileParams
  *
  * @return bool
  */
 public function MakeSingle($sAsset, $aFileParams)
 {
     $sFile = $aFileParams['file'];
     if (isset($aFileParams['dir_from'])) {
         $sLocalPath = F::File_LocalPath(dirname($sFile), $aFileParams['dir_from']);
         $sDir = $aFileParams['dir_from'];
     } else {
         $sLocalPath = '';
         $sDir = dirname($sFile);
     }
     if ($aFileParams['merge']) {
         $sSubdir = $this->_makeSubdir($sAsset . $sDir);
     } else {
         $sSubdir = $this->_makeSubdir($sDir);
     }
     if ($sLocalPath) {
         $sSubdir .= '/' . $sLocalPath;
     }
     $sDestination = F::File_GetAssetDir() . $sSubdir . '/' . basename($sFile);
     $aFileParams['asset_file'] = $sDestination;
     if (!$this->CheckDestination($sDestination)) {
         if ($sDestination = $this->PrepareFile($sFile, $sDestination)) {
             $this->AddLink($aFileParams['info']['extension'], E::ModuleViewerAsset()->AssetFileDir2Url($sDestination), $aFileParams);
         } else {
             F::SysWarning('Can not prepare asset file "' . $sFile . '"');
             return false;
         }
     } else {
         $this->AddLink($aFileParams['info']['extension'], E::ModuleViewerAsset()->AssetFileDir2Url($sDestination), $aFileParams);
     }
     return true;
 }