public function __construct() { parent::__construct(); $lang = new \MY_Lang(); $lang->load('template_manager'); $this->templateName = $this->db->get('settings')->row()->site_template; $this->templateModel = TemplateManager::getInstance()->getCurentTemplate(); \CMSFactory\Events::create()->setListener([new DemodataMigrationsControl(), 'run'], TemplateManager::EVENT_DEMODATA_INSTALLED); }
/** * * @param string $componentName * @param string $methodName * @param ... arguments */ function callComponentMethod($componentName, $methodName) { $component = \template_manager\classes\TemplateManager::getInstance()->getCurentTemplate()->getComponent($componentName); if (!$component) { return false; } $arguments = func_get_args(); array_shift($arguments); array_shift($arguments); return call_user_func(array($component, $methodName), $arguments); }
/** * Функція існує суто для сумісності із старими версіями * @deprecated since version 4.6 * @param string $name * @param string $value * @return string|boolean */ function siteInfoAdditionalManipulations($name) { if (FALSE !== strpos($name, '_path')) { $name = str_replace('_path', '', $name); } if (FALSE !== strpos($name, '_url')) { $name = str_replace('_url', '', $name); } $siteinfo = new SiteInfo(); $value = $siteinfo->getSiteInfo($name); switch ($name) { case 'siteinfo_favicon': case 'siteinfo_logo': // із врахуванням активного шаблону if (is_array($value)) { $settings = CI::$APP->cms_base->get_settings(); if (key_exists($settings['site_template'], $value)) { $fileName = $value[$settings['site_template']]; if (SHOP_INSTALLED) { $colorScheme = CI::$APP->load->module('template_manager')->getComponent('TColorScheme')->getColorSheme(); return "/templates/{$settings['site_template']}/css/{$colorScheme}/{$fileName}"; } else { return "/templates/{$settings['site_template']}/images/{$fileName}"; } } elseif (count($value) > 0) { reset($value); $key = key($value); if (SHOP_INSTALLED) { $colorScheme = CI::$APP->load->module('template_manager')->getComponent('TColorScheme')->getColorSheme(); $template = \template_manager\classes\TemplateManager::getInstance()->getCurentTemplate(); return "/templates/" . $template->name . "/css/{$colorScheme}/" . $value[$key]; } else { return "/templates/{$settings['site_template']}/images/{$fileName}"; } } return ''; } elseif (is_string($value)) { return empty($value) ? '' : CI::$APP->siteinfo->imagesPath . $value; } } return false; }
/** * * @param int $type 1 - only from template, 2 - only core components, 3 - all (default 3) * @return array */ public function getComponents($type = self::COMPONENTS_ALL) { $tm = \template_manager\classes\TemplateManager::getInstance(); $this->loadDataFromXml(); foreach ($this->xmlData['components'] as $componentName) { if (!isset($this->componentsInstances[$componentName])) { require_once $this->templatePath . "components/{$componentName}/{$componentName}" . EXT; $this->componentsInstances[$componentName] = new $componentName(); } } $tm->loadDefaultComponents(array_keys($this->componentsInstances)); if ($type == self::COMPONENTS_CORE) { return $tm->defaultComponents; } if ($type == self::COMPONENTS_TEMPLATE) { return $this->componentsInstances; } // template components has higher priority $componentsToReturn = $this->componentsInstances; foreach ($tm->defaultComponents as $name => $component) { if (!key_exists($name, $this->componentsInstances)) { $componentsToReturn[$name] = $component; } } return $componentsToReturn; }
/** * Install template by name * @throws \Exception */ public function install() { try { // license agreement acception if ($_POST['accept_license_agreement'] != 1) { throw new \Exception(lang('Templates are the intellectual property, so if you <br /> want to install it, you must accept the license agreement.', 'template_manager')); } if (!isset($_POST['template_name'])) { throw new \Exception(lang('Error - template not specified', 'template_manager')); } TemplateManager::getInstance()->setTemplate(new Template($_POST['template_name'])); $this->lib_admin->log(lang('Template was successfully installed.', 'template_manager') . ' - ' . $_POST['template_name']); showMessage(lang('Template was successfully installed.', 'template_manager')); if (MAINSITE) { $xmlShopId = $this->load->module('mainsaas')->getShopId(); $code = "ga('send', 'event', 'Clients-change-design', '" . $xmlShopId . "');"; jsCode($code); } } catch (\Exception $e) { showMessage($e->getMessage(), '', 'r'); exit; } }