public function initTheme() { $result = false; if (strlen($this->mTheme)) { global $gEnv; import('com.solarix.ampoliros.core.Ampoliros'); $amp = Ampoliros::instance('Ampoliros'); if ($this->mTheme == 'default') { $this->mTheme = $gEnv['hui']['theme']['default']; } if ($this->mTheme != 'userdefined') { if (file_exists(CONFIG_PATH . $this->mTheme . '.huitheme')) { $this->mThemeFile = CONFIG_PATH . $this->mTheme . '.huitheme'; } else { $this->mTheme = $gEnv['hui']['theme']['default']; $this->mThemeFile = CONFIG_PATH . $gEnv['hui']['theme']['default'] . '.huitheme'; } OpenLibrary('configman.library'); $cfg_file = new ConfigFile($this->mThemeFile); if ($cfg_file->opened()) { $this->mIconsSetName = $cfg_file->Value('THEME.ICONSSET'); $this->mColorsSetName = $cfg_file->Value('THEME.COLORSSET'); $this->mStyleName = $cfg_file->Value('THEME.STYLE'); } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('ampoliros.huithemes_library.huitheme_class.inittheme', 'Unable to open theme configuration file ' . $this->mThemeFile, LOGGER_ERROR); } } else { $this->mIconsSetName = $this->mUserSettings['iconsset']; $this->mColorsSetName = $this->mUserSettings['colorsset']; $this->mStyleName = $this->mUserSettings['stylename']; } $this->mIconsSetBase = CGI_URL . 'icons/' . $this->mIconsSetName . '/'; $this->mIconsBase = CGI_URL . 'icons/'; $this->mIconsSetDir = CGI_PATH . 'icons/' . $this->mIconsSetName . '/'; $this->mStyleBase = CGI_URL . 'styles/'; $this->mStyleDir = CGI_PATH . 'styles/' . $this->mStyleName . '/'; $hui_colors = new HuiColorsSet($this->mrAmpDb, $this->mColorsSetName); $hui_icons = new HuiIconsSet($this->mrAmpDb, $this->mIconsSetName); $hui_style = new HuiStyle($this->mrAmpDb, $this->mStyleName); if ($amp->getState() != Ampoliros::STATE_SETUP) { $cached_iconsset = new CachedItem($this->mrAmpDb, 'ampoliros', 'huiiconsset-' . $this->mIconsSetName); $cached_colorsset = new CachedItem($this->mrAmpDb, 'ampoliros', 'huicolorsset-' . $this->mColorsSetName); $cached_style = new CachedItem($this->mrAmpDb, 'ampoliros', 'huistyle-' . $this->mStyleName); $this->mIconsSet = unserialize($cached_iconsset->Retrieve()); $this->mColorsSet = unserialize($cached_colorsset->Retrieve()); $this->mStyle = unserialize($cached_style->Retrieve()); } if (!$this->mIconsSet or !$this->mColorsSet or !$this->mStyle) { if ($gEnv['hui']['theme']['default'] == $this->mTheme) { $this->mColorsSet = $hui_colors->GetColorsSet(); $this->mIconsSet = $hui_icons->GetIconsSet(); $this->mStyle = $hui_style->GetStyle(); } else { OpenLibrary('configman.library'); $def_cfg_file = new ConfigFile(CONFIG_PATH . $gEnv['hui']['theme']['default'] . '.huitheme'); if ($def_cfg_file->Opened()) { $def_icons_set_name = $def_cfg_file->Value('THEME.ICONSSET'); $def_colors_set_name = $def_cfg_file->Value('THEME.COLORSSET'); $def_style_name = $def_cfg_file->Value('THEME.STYLE'); } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('ampoliros.huithemes_library.huitheme_class.inittheme', 'Unable to open default theme configuration file ' . CONFIG_PATH . $gEnv['hui']['theme']['default'] . '.huitheme', LOGGER_ERROR); } $hui_def_colors = new HuiColorsSet($this->mrAmpDb, $def_colors_set_name); $hui_def_icons = new HuiIconsSet($this->mrAmpDb, $def_icons_set_name); $hui_def_style = new HuiStyle($this->mrAmpDb, $def_style_name); $this->mColorsSet = $this->DefOpts($hui_def_colors->GetColorsSet(), $hui_colors->GetColorsSet()); $this->mIconsSet = $this->DefOpts($hui_def_icons->GetIconsSet(), $hui_icons->GetIconsSet()); $this->mStyle = $this->DefOpts($hui_def_style->GetStyle(), $hui_style->GetStyle()); } while (list($style_name, $style_item) = each($this->mStyle)) { $this->mStyle[$style_name] = $this->mStyleBase . $style_item['base'] . '/' . $style_item['value']; } if ($amp->getState() != Ampoliros::STATE_SETUP) { $cached_iconsset->Store(serialize($this->mIconsSet)); $cached_colorsset->Store(serialize($this->mColorsSet)); $cached_style->Store(serialize($this->mStyle)); } } } return $result; }