/** * Plugin for Smarty * Display widget group * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_wgroup_show($aParams, $oSmartyTemplate) { if (isset($aParams['name'])) { if (!isset($aParams['group'])) { $aParams['group'] = $aParams['name']; } elseif (!isset($aParams['widget'])) { $aParams['widget'] = $aParams['name']; } } if (!isset($aParams['group'])) { $sError = 'Parameter "group" does not define in {wgroup_show ...} function'; if ($oSmartyTemplate->template_resource) { $sError .= ' (template: ' . $oSmartyTemplate->template_resource . ')'; } trigger_error($sError, E_USER_WARNING); return null; } $sWidgetGroup = $aParams['group']; $aWidgets = E::ModuleViewer()->GetWidgets(); $sResult = ''; if (isset($aWidgets[$sWidgetGroup])) { if (!function_exists('smarty_function_widget')) { F::IncludeFile('function.widget.php'); } foreach ($aWidgets[$sWidgetGroup] as $oWidget) { $sResult .= smarty_function_widget(array('object' => $oWidget), $oSmartyTemplate); } } return $sResult; }
/** * Create a typographer and load its configuration */ protected function _createTextParser() { $sParser = C::Get('module.text.parser'); $sClassName = 'TextParser' . $sParser; $sFileName = './parser/' . $sClassName . '.class.php'; F::IncludeFile($sFileName); $this->oTextParser = new $sClassName(); }
/** * Plugin for Smarty * Eval widget groups * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_wgroup($aParams, $oSmartyTemplate) { if (isset($aParams['name'])) { if (!isset($aParams['group'])) { $aParams['group'] = $aParams['name']; } elseif (!isset($aParams['widget'])) { $aParams['widget'] = $aParams['name']; } } if (!isset($aParams['group']) && !isset($aParams['name'])) { $sError = 'Parameter "group" does not define in {wgroup ...} function'; if ($oSmartyTemplate->template_resource) { $sError .= ' (template: ' . $oSmartyTemplate->template_resource . ')'; } trigger_error($sError, E_USER_WARNING); return null; } $sWidgetGroup = $aParams['group']; $aWidgetParams = isset($aParams['params']) ? $aParams['params'] : $aParams; // group parameter required if (!$sWidgetGroup) { return null; } if (isset($aParams['command'])) { $sWidgetCommand = $aParams['command']; } else { $sWidgetCommand = 'show'; } if ($sWidgetCommand == 'show') { if (!function_exists('smarty_function_wgroup_show')) { F::IncludeFile('function.wgroup_show.php'); } unset($aWidgetParams['group']); if (isset($aWidgetParams['command'])) { unset($aWidgetParams['command']); } return smarty_function_wgroup_show(array('group' => $sWidgetGroup, 'params' => $aWidgetParams), $oSmartyTemplate); } elseif ($sWidgetCommand == 'add') { if (!isset($aWidgetParams['widget'])) { trigger_error('Parameter "widget" does not define in {wgroup ...} function', E_USER_WARNING); return null; } if (!function_exists('smarty_function_wgroup_add')) { F::IncludeFile('function.wgroup_add.php'); } $sWidgetName = $aWidgetParams['widget']; unset($aWidgetParams['group']); unset($aWidgetParams['widget']); if (isset($aWidgetParams['command'])) { unset($aWidgetParams['command']); } return smarty_function_wgroup_add(array('group' => $sWidgetGroup, 'widget' => $sWidgetName, 'params' => $aWidgetParams), $oSmartyTemplate); } return ''; }
/** * Plugin for Smarty * Display widget group * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_wgroup_show($aParams, $oSmartyTemplate) { static $aStack = array(); if (empty($aParams['group']) && empty($aParams['name'])) { $sError = 'Parameter "group" does not define in {wgroup_show ...} function'; if ($oSmartyTemplate->template_resource) { $sError .= ' (template: ' . $oSmartyTemplate->template_resource . ')'; } F::SysWarning($sError); return null; } if (empty($aParams['group']) && !empty($aParams['name'])) { $aParams['group'] = $aParams['name']; unset($aParams['name']); } $sWidgetGroup = $aParams['group']; $aWidgetParams = isset($aParams['params']) ? array_merge($aParams['params'], $aParams) : $aParams; if (isset($aStack[$sWidgetGroup])) { // wgroup nested in self $sError = 'Template function {wgroup group="' . $sWidgetGroup . '" nested in self '; if ($oSmartyTemplate->template_resource) { $sError .= ' (template: ' . $oSmartyTemplate->template_resource . ')'; } F::SysWarning($sError); return null; } // add group into the stack $aStack[$sWidgetGroup] = $aWidgetParams; $aWidgets = E::ModuleViewer()->GetWidgets(); $sResult = ''; if (isset($aWidgets[$sWidgetGroup])) { if (!function_exists('smarty_function_widget')) { F::IncludeFile('function.widget.php'); } foreach ($aWidgets[$sWidgetGroup] as $oWidget) { $sResult .= smarty_function_widget(array_merge($aWidgetParams, array('widget' => $oWidget)), $oSmartyTemplate); } } // Pop element off the stack array_pop($aStack); return $sResult; }
/** * @param string $sFile * @param string $sCheckClassname * * @return bool|mixed */ protected static function _includeFile($sFile, $sCheckClassname = null) { if (class_exists('F', false)) { $xResult = F::IncludeFile($sFile); } else { $xResult = (include_once $sFile); } if ($sCheckClassname) { return class_exists($sCheckClassname, false); } return $xResult; }
/** * Инициализация модуля */ public function Init() { F::IncludeFile(Plugin::GetPath('ls') . 'libs/external/LiveImage/Image.php'); $this->aParamsDefault = array('watermark_use' => false, 'round_corner' => false); }
protected function _getSkinFromConfig($sSkin) { $sSkinTheme = null; if (F::File_Exists($sFile = Config::Get('path.skins.dir') . $sSkin . '/settings/config/config.php')) { $aSkinConfig = F::IncludeFile($sFile, false, true); if (isset($aSkinConfig['view']) && isset($aSkinConfig['view']['theme'])) { $sSkinTheme = $aSkinConfig['view']['theme']; } elseif (isset($aSkinConfig['view.theme'])) { $sSkinTheme = $aSkinConfig['view.theme']; } } return $sSkinTheme; }
/** * Плагин для Smarty * Подключает обработчик блоков шаблона (LS-compatible) * * @param array $aParams * @param Smarty_Internal_Template $oSmarty * * @return string */ function smarty_insert_block($aParams, &$oSmarty) { if (!isset($aParams['block'])) { trigger_error('Parameter "block" not define in {insert name="block" ...}', E_USER_WARNING); return null; } $aParams['name'] = $aParams['block']; if (!function_exists('smarty_function_widget')) { F::IncludeFile(Config::Get('path.smarty.plug') . 'function.widget.php'); } return smarty_function_widget($aParams, $oSmarty); /* $oEngine = Engine::getInstance(); $sWidget = ucfirst(basename($aParams['block'])); $sDelegatedClass = $oEngine->Plugin_GetDelegate('widget', $sWidget); if ($sDelegatedClass == $sWidget) { // Пробуем получить делегата по старинке, для совместимости с LS // * LS-compatible * // $sDelegatedClass = $oEngine->Plugin_GetDelegate('block', $sWidget); } // Если делегатов нет, то определаем класс виджета if ($sDelegatedClass == $sWidget) { // если указан плагин, то ищем там if (isset($aParams['params']) && isset($aParams['params']['plugin'])) { $sPlugin = $aParams['params']['plugin']; } else { $sPlugin = ''; } // Проверяем наличие класса виджета штатными средствами $sWidgetClass = E::Widget_FileClassExists($sWidget, $sPlugin, true); if (!$sWidgetClass) { if ($sPlugin) { // Если класс виджета не найден, то пытаемся по старинке задать класс "LS-блока" $sWidgetClass = 'Plugin' . ucfirst($aParams['params']['plugin']) . '_Block' . $sWidget; } else { // Если класс виджета не найден, то пытаемся по старинке задать класс "LS-блока" $sWidgetClass = 'Block' . $sWidget; } // Проверяем делигирование найденного класса $sWidgetClass = E::Plugin_GetDelegate('block', $sWidgetClass); } // Проверяем делигирование найденного класса $sWidgetClass = $oEngine->Plugin_GetDelegate('widget', $sWidgetClass); } else { $sWidgetClass = $sDelegatedClass; } $sTemplate = $oEngine->Plugin_GetDelegate('template', 'widgets/widget.' . $aParams['block'] . '.tpl'); if (!F::File_Exists($sTemplate)) { //$sTemplate = ''; // * LS-compatible * // $sLsTemplate = $oEngine->Plugin_GetDelegate('template', 'blocks/block.' . $aParams['block'] . '.tpl'); if (F::File_Exists($sLsTemplate)) { $sTemplate = $sLsTemplate; } } // * параметры $aWidgetParams = array(); if (isset($aParams['params'])) { $aWidgetParams = $aParams['params']; } // * Подключаем необходимый обработчик $oWidgetHandler = new $sWidgetClass($aWidgetParams); // * Запускаем обработчик $sResult = $oWidgetHandler->Exec(); // Если обработчик ничего не вернул, то рендерим шаблон if (!$sResult && $sTemplate) $sResult = $oSmarty->fetch($sTemplate); return $sResult; */ }
/** * @param string $sType * @param bool $bClear * * @return ITextParser */ public static function newTextParser($sType = 'default', $bClear = true) { $sParser = C::Get('module.text.parser'); $sClassName = 'TextParser' . $sParser; $sFileName = './parser/' . $sClassName . '.class.php'; F::IncludeFile($sFileName); /** @var ITextParser $oTextParser */ $oTextParser = new $sClassName(); $oTextParser->loadConfig($sType, $bClear); return $oTextParser; }
define('ALTO_DEBUG_PROFILE', 1); define('ALTO_DEBUG_FILES', 2); if (is_file(__DIR__ . '/config.defines.php')) { include __DIR__ . '/config.defines.php'; } defined('DEBUG') || define('DEBUG', 0); // load basic config with paths $config = (include __DIR__ . '/config.php'); if (!$config) { die('Fatal error: Cannot load file "' . __DIR__ . '/config.php"'); } // load system functions $sFuncFile = $config['path']['dir']['engine'] . 'include/Func.php'; if (!is_file($sFuncFile) || !(include $sFuncFile)) { die('Fatal error: Cannot load file "' . $sFuncFile . '"'); } // load Storage class F::IncludeFile($config['path']['dir']['engine'] . '/classes/core/Storage.class.php'); if (!isset($config['url']['request'])) { $config['url']['request'] = F::ParseUrl(); } // load Config class F::IncludeFile($config['path']['dir']['engine'] . '/classes/core/Config.class.php'); if (!defined('ALTO_NO_LOADER')) { // load Loder class F::IncludeFile($config['path']['dir']['engine'] . '/classes/core/Loader.class.php'); Loader::Init($config); } // load Application class F::IncludeFile($config['path']['dir']['engine'] . '/classes/core/Application.class.php'); // EOF
/** * 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); } }
/*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- * Based on * LiveStreet Engine Social Networking by Mzhelskiy Maxim * Site: www.livestreet.ru * E-mail: rus.engine@gmail.com *---------------------------------------------------------------------------- */ F::IncludeFile('Storage.class.php'); F::IncludeFile('DataArray.class.php'); /** * Управление простым конфигом в виде массива * * @package engine.lib * @since 1.0 * * @method static Config getInstance */ class Config extends Storage { const LEVEL_MAIN = 0; const LEVEL_APP = 1; const LEVEL_CUSTOM = 2; const LEVEL_ACTION = 3; const LEVEL_SKIN = 4;
/** * 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); } }
<?php F::IncludeFile(LS_DKCACHE_PATH . 'Zend/Cache.php'); F::IncludeFile(LS_DKCACHE_PATH . 'Zend/Cache/Backend/Interface.php'); interface ICacheBackend { /** * @return bool */ public static function IsAvailable(); /** * @param $sName * * @return mixed */ public function Load($sName); /** * @param $data * @param $sName * @param $aTags * @param $nTimeLife * * @return mixed */ public function Save($data, $sName, $aTags = array(), $nTimeLife = false); /** * @param $sName * * @return mixed */ public function Remove($sName);
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ F::IncludeFile('Action.class.php'); F::IncludeFile('ActionPlugin.class.php'); /** * Класс роутинга * Инициализирует ядро, определяет какой экшен запустить согласно URL'у и запускает его * * @package engine * @since 1.0 */ class Router extends LsObject { const BACKWARD_COOKIE = 'route_backward'; /** * Конфигурация роутинга, получается из конфига * * @var array */ protected $aConfigRoute = array(); /** * Текущий экшен *
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ F::IncludeFile('./ICacheBackend.php'); F::IncludeFile(LS_DKCACHE_PATH . 'Zend/Cache/Backend/Memcached.php'); /** * Class CacheBackendMemcached * * Кеш на основе Memcached */ class CacheBackendMemcached extends Dklab_Cache_Backend_TagEmuWrapper implements ICacheBackend { public static function IsAvailable() { return extension_loaded('memcache'); } public static function Init($sFuncStats) { if (!self::IsAvailable()) { return false; } $aConfigMem = C::Get('memcache'); $oCache = new Dklab_Cache_Backend_MemcachedMultiload($aConfigMem); return new self(new Dklab_Cache_Backend_Profiler($oCache, $sFuncStats));
/** * Plugin for Smarty * Eval widgets * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_widget($aParams, $oSmartyTemplate) { if (!isset($aParams['name']) && !isset($aParams['object']) && !isset($aParams['group']) && !isset($aParams['id'])) { $sError = 'Parameter "name" or "object" or "id" not define in {widget ...} function'; if ($oSmartyTemplate->template_resource) { $sError .= ' (template: ' . $oSmartyTemplate->template_resource . ')'; } trigger_error($sError, E_USER_WARNING); return; } if (isset($aParams['group'])) { if (!function_exists('smarty_function_wgroup')) { F::IncludeFile('function.wgroup.php'); } return smarty_function_wgroup($aParams, $oSmartyTemplate); } /** @var ModuleWidget_EntityWidget $oWidget */ $oWidget = null; $sWidgetType = ''; $sWidgetName = ''; $aWidgetParams = array(); if (isset($aParams['name'])) { $sWidgetName = $aParams['name']; $sWidgetType = 'exec'; $aWidgetParams = isset($aParams['params']) ? $aParams['params'] : array(); foreach ($aParams as $sKey => $xValue) { if ($sKey != 'name' && $sKey != 'params') { $aWidgetParams[$sKey] = $xValue; } } } elseif (isset($aParams['id'])) { $aWidgets = $oSmartyTemplate->getTemplateVars('aWidgets'); if (is_array($aWidgets) && isset($aWidgets['_all_'][$aParams['id']])) { $oWidget = $aWidgets['_all_'][$aParams['id']]; } } else { $oWidget = $aParams['object']; } if ($oWidget) { $sWidgetName = $oWidget->GetName(); $sWidgetTemplate = $oWidget->GetTemplate(); $aWidgetParams = $oWidget->getParams(); $sWidgetType = $oWidget->getType(); } $sResult = ''; $aSavedVars = array('aWidgetParams' => $oSmartyTemplate->getTemplateVars('aWidgetParams'), 'oWidget' => $oSmartyTemplate->getTemplateVars('oWidget')); $oSmartyTemplate->assign('aWidgetParams', $aWidgetParams); $oSmartyTemplate->assign('oWidget', $oWidget); if ($sWidgetType == 'exec') { if (!function_exists('smarty_function_widget_exec')) { F::IncludeFile('function.widget_exec.php'); } $sResult = smarty_function_widget_exec(array('name' => $sWidgetName, 'params' => $aWidgetParams, 'widget' => $oWidget), $oSmartyTemplate); } elseif ($sWidgetType == 'block') { // * LS-compatible * // if (!function_exists('smarty_function_widget_exec')) { F::IncludeFile('function.widget_exec.php'); } $sResult = smarty_function_widget_exec(array('name' => $sWidgetName, 'params' => $aWidgetParams, 'widget' => $oWidget), $oSmartyTemplate); } elseif ($sWidgetType == 'template') { if (!function_exists('smarty_function_widget_template')) { F::IncludeFile('function.widget_template.php'); } $sResult = smarty_function_widget_template(array('name' => !empty($sWidgetTemplate) ? $sWidgetTemplate : $sWidgetName, 'params' => $aWidgetParams, 'widget' => $oWidget), $oSmartyTemplate); } $oSmartyTemplate->assign($aSavedVars); return $sResult; }
/** * Активация плагина * * @param string $sPluginId - код плагина * * @return bool */ public function Activate($sPluginId) { $aConditions = array('<' => 'lt', 'lt' => 'lt', '<=' => 'le', 'le' => 'le', '>' => 'gt', 'gt' => 'gt', '>=' => 'ge', 'ge' => 'ge', '==' => 'eq', '=' => 'eq', 'eq' => 'eq', '!=' => 'ne', '<>' => 'ne', 'ne' => 'ne'); // получаем список неактивированных плагинов $aPlugins = $this->GetPluginsList(false); if (!isset($aPlugins[$sPluginId])) { return false; } $sPluginDir = $aPlugins[$sPluginId]->getDirname(); if (!$sPluginDir) { $sPluginDir = $sPluginId; } $sPluginName = F::StrCamelize($sPluginId); $sClassName = "Plugin{$sPluginName}"; $sPluginClassFile = F::File_NormPath("{$this->sPluginsCommonDir}{$sPluginDir}/Plugin{$sPluginName}.class.php"); F::IncludeFile($sPluginClassFile); if (class_exists($sClassName, false)) { /** @var Plugin $oPlugin */ $oPlugin = new $sClassName(); /** @var ModulePlugin_EntityPlugin $oPluginEntity */ $oPluginEntity = $oPlugin->GetPluginEntity(); // Проверяем совместимость с версией Alto if (!$oPluginEntity->EngineCompatible()) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_activation_version_error', array('version' => $oPluginEntity->RequiredAltoVersion())), E::ModuleLang()->Get('error'), true); return false; } // * Проверяем системные требования if ($oPluginEntity->RequiredPhpVersion()) { // Версия PHP if (!version_compare(PHP_VERSION, $oPluginEntity->RequiredPhpVersion(), '>=')) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_activation_error_php', array('version' => $oPluginEntity->RequiredPhpVersion())), E::ModuleLang()->Get('error'), true); return false; } } // * Проверяем наличие require-плагинов if ($aRequiredPlugins = $oPluginEntity->RequiredPlugins()) { $aActivePlugins = array_keys($this->GetActivePlugins()); $iError = 0; foreach ($aRequiredPlugins as $oReqPlugin) { // * Есть ли требуемый активный плагин if (!in_array((string) $oReqPlugin, $aActivePlugins)) { $iError++; E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_activation_requires_error', array('plugin' => ucfirst($oReqPlugin))), E::ModuleLang()->Get('error'), true); } else { if (isset($oReqPlugin['name'])) { $sReqPluginName = (string) $oReqPlugin['name']; } else { $sReqPluginName = ucfirst($oReqPlugin); } if (isset($oReqPlugin['version'])) { $sReqVersion = $oReqPlugin['version']; if (isset($oReqPlugin['condition']) && array_key_exists((string) $oReqPlugin['condition'], $aConditions)) { $sReqCondition = $aConditions[(string) $oReqPlugin['condition']]; } else { $sReqCondition = 'eq'; } $sClassName = "Plugin{$oReqPlugin}"; /** @var ModulePlugin_EntityPlugin $oReqPluginInstance */ $oReqPluginInstance = new $sClassName(); // Получаем версию требуемого плагина $sReqPluginVersion = $oReqPluginInstance->GetVersion(); if (!$sReqPluginVersion) { $iError++; E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_havenot_getversion_method', array('plugin' => $sReqPluginName)), E::ModuleLang()->Get('error'), true); } else { // * Если требуемый плагин возвращает версию, то проверяем ее if (!version_compare($sReqPluginVersion, $sReqVersion, $sReqCondition)) { $sTextKey = 'action.admin.plugin_activation_reqversion_error_' . $sReqCondition; $iError++; E::ModuleMessage()->AddError(E::ModuleLang()->Get($sTextKey, array('plugin' => $sReqPluginName, 'version' => $sReqVersion)), E::ModuleLang()->Get('error'), true); } } } } } if ($iError) { return false; } } // * Проверяем, не вступает ли данный плагин в конфликт с уже активированными // * (по поводу объявленных делегатов) $aPluginDelegates = $oPlugin->GetDelegates(); $iError = 0; foreach ($this->aDelegates as $sGroup => $aReplaceList) { $iCount = 0; if (isset($aPluginDelegates[$sGroup]) && is_array($aPluginDelegates[$sGroup]) && ($iCount = sizeof($aOverlap = array_intersect_key($aReplaceList, $aPluginDelegates[$sGroup])))) { $iError += $iCount; foreach ($aOverlap as $sResource => $aConflict) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_activation_overlap', array('resource' => $sResource, 'delegate' => $aConflict['delegate'], 'plugin' => $aConflict['sign'])), E::ModuleLang()->Get('error'), true); } } if ($iCount) { return false; } } $bResult = $oPlugin->Activate(); if ($bResult && ($sVersion = $oPlugin->GetVersion())) { $oPlugin->WriteStorageVersion($sVersion); $oPlugin->WriteStorageDate(); } } else { // * Исполняемый файл плагина не найден E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_file_not_found', array('file' => $sPluginClassFile)), E::ModuleLang()->Get('error'), true); return false; } if ($bResult) { // Запрещаем кеширование E::ModuleCache()->SetDesabled(true); // Надо обязательно очистить кеш здесь E::ModuleCache()->Clean(); E::ModuleViewer()->ClearAll(); // Переопределяем список активированных пользователем плагинов if (!$this->_addActivePlugins($oPluginEntity)) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.plugin_write_error', array('file' => F::GetPluginsDatFile())), E::ModuleLang()->Get('error'), true); $bResult = false; } } return $bResult; }
/** * Инициализация бэкенда кеширования * * @param string $sCacheType * * @return string|null * * @throws Exception */ protected function _backendInit($sCacheType) { if (is_string($sCacheType)) { $sCacheType = strtolower($sCacheType); } elseif ($sCacheType === true || is_null($sCacheType)) { $sCacheType = $this->sCacheType; } if ($sCacheType) { if (!isset($this->aBackends[$sCacheType])) { if (!in_array($sCacheType, $this->aCacheTypesAvailable)) { // Unknown cache type throw new Exception('Wrong type of caching: ' . $this->sCacheType); } else { $aCacheTypes = (array) C::Get('sys.cache.backends'); $sClass = 'CacheBackend' . $aCacheTypes[$sCacheType]; $sFile = './backend/' . $sClass . '.class.php'; if (!F::IncludeFile($sFile)) { throw new Exception('Cannot include cache backend file: ' . basename($sFile)); } elseif (!class_exists($sClass, false)) { throw new Exception('Cannot load cache backend class: ' . $sClass); } else { if (!$sClass::IsAvailable() || !($oBackendCache = $sClass::Init(array($this, 'CalcStats')))) { throw new Exception('Cannot use cache type: ' . $sCacheType); } else { $this->aBackends[$sCacheType] = $oBackendCache; //* LS-compatible *// if ($sCacheType == $this->sCacheType) { $this->oBackendCache = $oBackendCache; } //$oBackendCache = null; return $sCacheType; } } } } else { return $sCacheType; } } return null; }
/** * @param string $sPluginId * @param bool $bActive * * @return Plugin|null */ protected function _getPluginById($sPluginId, $bActive) { $oPlugin = null; $oPluginEntity = $this->_getPluginEntityById($sPluginId, $bActive); if ($oPluginEntity) { $sClassName = $oPluginEntity->GetPluginClass(); $sPluginClassFile = $oPluginEntity->GetPluginClassFile(); if ($sClassName && $sPluginClassFile) { F::IncludeFile($sPluginClassFile); if (class_exists($sClassName, false)) { /** @var Plugin $oPlugin */ $oPlugin = new $sClassName($oPluginEntity); } } } return $oPlugin; }
* Based on * LiveStreet Engine Social Networking by Mzhelskiy Maxim * Site: www.livestreet.ru * E-mail: rus.engine@gmail.com *---------------------------------------------------------------------------- */ F::IncludeFile('../abstract/Plugin.class.php'); F::IncludeFile('../abstract/Hook.class.php'); F::IncludeFile('../abstract/Module.class.php'); F::IncludeFile('Decorator.class.php'); F::IncludeFile('../abstract/Entity.class.php'); F::IncludeFile('../abstract/Mapper.class.php'); F::IncludeFile('../abstract/ModuleORM.class.php'); F::IncludeFile('../abstract/EntityORM.class.php'); F::IncludeFile('../abstract/MapperORM.class.php'); F::IncludeFile('ManyToManyRelation.class.php'); /** * Основной класс движка. Ядро. * * Производит инициализацию плагинов, модулей, хуков. * Через этот класс происходит выполнение методов всех модулей, * которые вызываются так: * <pre> * E::ModuleName()->Method(); * </pre> * Также отвечает за автозагрузку остальных классов движка. * * * @method static ModuleAcl ModuleAcl() * @method static ModuleAdmin ModuleAdmin() * @method static ModuleBlog ModuleBlog()
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- * Based on * LiveStreet Engine Social Networking by Mzhelskiy Maxim * Site: www.livestreet.ru * E-mail: rus.engine@gmail.com *---------------------------------------------------------------------------- */ F::IncludeFile(__DIR__ . '/LangArray.class.php'); /** * Модуль поддержки языковых файлов * * @package engine.modules * @since 1.0 */ class ModuleLang extends Module { const LANG_PATTERN = '%%lang%%'; /** * Текущий язык ресурса * * @var string */ protected $sCurrentLang;
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ F::IncludeFile('./ICacheBackend.php'); /** * Class CacheBackendFile * * Кеш в памяти * * Рекомендуется для хранения небольших объемов данных, к которым возможно частое обращение * в течение обработки одного запроса. Может привести к увеличению требуемой памяти, но самый быстрый * из всех видов кеша * * Категорически НЕЛЬЗЯ использовать, как кеш всего приложения!!! */ class CacheBackendTmp extends Dklab_Cache_Backend_Profiler implements ICacheBackend { protected static $aStore = array(); public static function IsAvailable() { return true; } public static function init($sFuncStats) {
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); F::IncludeFile('../abstract/LsObject.class.php'); F::IncludeFile('Router.class.php'); /** * Application class of CMS * * @package engine * @since 1.1 */ class Application extends LsObject { protected static $oInstance; protected $aParams = array(); public function __construct() { } public function __destruct() { $this->Done(); } /**