/** */ protected function tplCfg($path, $task = null) { $file = explode('.', $path); $files = array(); if (strstr($file[0], 'cms:')) { $file[0] = str_replace('cms:', null, $file[0]); $file = SPFactory::mainframe()->path(implode('.', $file)); $path = SPLoader::dirPath($file, 'root', true); $this->_tCfg = SPLoader::loadIniFile("{$path}.config", true, false, false, true); $files[] = SPLoader::iniStorage(); } else { $this->_tCfg = SPLoader::loadIniFile("usr.templates.{$path}.config"); $files[] = SPLoader::iniStorage(); $path = SPLoader::dirPath('usr.templates.' . $path, 'front', true); } if (!$task) { $task = $this->_task == 'add' || $this->_task == 'submit' ? 'edit' : $this->template; } if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'ini')) { $taskCfg = SPLoader::loadIniFile("{$path}.{$this->templateType}.{$task}", true, false, false, true); $files[] = SPLoader::iniStorage(); foreach ($taskCfg as $section => $keys) { if (isset($this->_tCfg[$section])) { $this->_tCfg[$section] = array_merge($this->_tCfg[$section], $keys); } else { $this->_tCfg[$section] = $keys; } } } if (count($files)) { foreach ($files as $i => $file) { $files[$i] = array('file' => str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $file), 'checksum' => md5_file($file)); } SPFactory::registry()->set('template_config', $files); } if (SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')) { $config = json_decode(SPFs::read(SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')), true); $settings = array(); foreach ($config as $section => $setting) { $settings[str_replace('-', '.', $section)] = $setting; } if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')) { $subConfig = json_decode(SPFs::read(SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')), true); if (count($subConfig)) { foreach ($subConfig as $section => $subSettings) { foreach ($subSettings as $k => $v) { $settings[str_replace('-', '.', $section)][$k] = $v; } } } } if (isset($settings['general'])) { foreach ($settings['general'] as $k => $v) { $this->_tCfg['general'][$k] = $v; } } $task = SPRequest::task() == 'entry.add' ? 'entry.edit' : SPRequest::task(); if (isset($settings[$task])) { foreach ($settings[$task] as $k => $v) { $this->_tCfg['general'][$k] = $v; } } } Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_tCfg)); SPFactory::registry()->set('current_template', $path); }