dir = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'greydragon/'; self::loadConfig($ver); } private function getDefaults() { return array( "p_version" => array("value" => "", "quotes" => QUOTES_NONE), // General Settings "p_logo_path" => array("value" => null, "quotes" => QUOTES_NONE), "p_header" => array("value" => null, "quotes" => QUOTES_LAZY), "p_footer" => array("value" => null, "quotes" => QUOTES_LAZY), "p_colorpack" => array("value" => "greydragon", "quotes" => QUOTES_NONE), "p_favicon_ico" => array("value" => null, "quotes" => QUOTES_NONE), "p_favicon_png" => array("value" => "", "quotes" => QUOTES_NONE), "p_favicon_gif" => array("value" => "", "quotes" => QUOTES_NONE), "p_favicon_apple" => array("value" => "", "quotes" => QUOTES_NONE), "p_favicon_noshine" => array("value" => "off", "quotes" => QUOTES_NONE), // Advanced Options - General "p_main_menu" => array("value" => "closed", "quotes" => QUOTES_NONE), // static, closed, opened, top, header-bottom, header-top, disabled "p_animated_menu" => array("value" => "off", "quotes" => QUOTES_NONE), "p_main_menu_close" => array("value" => "off", "quotes" => QUOTES_NONE), "p_lowertext" => array("value" => "off", "quotes" => QUOTES_NONE), "p_credits" => array("value" => "off", "quotes" => QUOTES_NONE), "p_nogenerator" => array("value" => "off", "quotes" => QUOTES_NONE), "p_hideabout" => array("value" => "off", "quotes" => QUOTES_NONE), "p_adminemail" => array("value" => "off", "quotes" => QUOTES_NONE), "p_nocounter" => array("value" => "off", "quotes" => QUOTES_NONE), // Advanced Options - Photo Page "p_pict_tab_mode" => array("value" => "txt-tab-open", "quotes" => QUOTES_NONE), "p_pict_tab_default" => array("value" => "desc", "quotes" => QUOTES_NONE), "p_pict_tab_anim" => array("value" => "off", "quotes" => QUOTES_NONE), "p_pict_tab_exif" => array("value" => "on", "quotes" => QUOTES_NONE), // Advanced Options - Root Page "p_rootpage" => array("value" => "off", "quotes" => QUOTES_NONE), "p_rootpage_desc" => array("value" => null, "quotes" => QUOTES_SAFE | QUOTES_LAZY), "p_rootpage_link" => array("value" => "off", "quotes" => QUOTES_NONE), "p_rootpage_src" => array("value" => "slider", "quotes" => QUOTES_NONE), "p_rootpage_size" => array("value" => "M", "quotes" => QUOTES_NONE), "p_rootpage_id" => array("value" => 1, "quotes" => QUOTES_NONE), "p_rootpage_mode" => array("value" => "fade", "quotes" => QUOTES_NONE), "p_rootpage_delay" => array("value" => 10, "quotes" => QUOTES_NONE), "p_rootpage_elastic" => array("value" => "off", "quotes" => QUOTES_NONE), "p_rootpage_navarr" => array("value" => "off", "quotes" => QUOTES_NONE), "p_rootpage_navctr" => array("value" => "off", "quotes" => QUOTES_NONE), 'p_customcss' => array("value" => null, "quotes" => (QUOTES_LAZY | QUOTES_SINGLE)), 'p_debug' => array("value" => "off", "quotes" => FALSE) ); } private function loadConfig($ver = '') { global $conf, $pwg_loaded_plugins; $this->themeConfigMin = unserialize($conf['greydragon']); $this->themeConfigMin["version"] = $ver; $this->themeConfigMin["hasUserTags"] = isset($pwg_loaded_plugins['user_tags']); $this->themeConfig = $this->validateDefault($this->themeConfigMin); } private function validateDefault($config) { // Check version, perform update if necessary if (!isset($config["p_version"]) || ($this->themeConfigMin["version"] !== $config["p_version"])): if (isset($config["p_favicon_path"])): $config["p_favicon_ico"] = $config["p_favicon_path"]; unset($config["p_favicon_path"]); endif; endif; $theme_default_settings = $this->getDefaults(); foreach ($theme_default_settings as $key => $value): if (isset($value["value"])): if (array_key_exists($key, $config)): else: $config[$key] = $value["value"]; endif; endif; endforeach; // Populate some system settings $url_root = get_root_url(); $config['U_SITE_ADMIN'] = $url_root . 'admin.php?page='; return $config; } public function initEvents() { } public function loadCSS() { } public function getConfig($isFull = TRUE) { if ($isFull): return $this->themeConfig; else: $config = $this->themeConfigMin; $config['p_version'] = GDTHEME_VERSION; return $config; endif; } public function setSetting($name, $value) { $this->themeConfig[$name] = $value; } public function saveSettingFromPOST($name) { $theme_default_settings = $this->getDefaults(); $isFound = FALSE; $isStored = FALSE; if (array_key_exists($name, $theme_default_settings)): $setting = $theme_default_settings[$name]; $default = $setting["value"]; $quotes = $setting["quotes"]; if (isset($_POST[$name]) and !empty($_POST[$name])): $isFound = TRUE; $value = $_POST[$name]; if ($value != $default): $isStored = TRUE; if ($quotes): if (($quotes & QUOTES_LAZY) == QUOTES_LAZY): $value = str_replace('\"', '"', $value); $value = str_replace("\'", "'", $value); endif; if (($quotes & QUOTES_SINGLE) == QUOTES_SINGLE): $value = str_replace("'", '"', $value); endif; if (($quotes & QUOTES_SAFE) == QUOTES_SAFE): $value = str_replace("'", ''', $value); $value = str_replace('"', '"', $value); endif; $value = str_replace("\'", "';", $value); endif; endif; endif; if ($isFound): $this->themeConfig[$name] = $value; if ($isStored): $this->themeConfigMin[$name] = $value; endif; endif; endif; // Config cleanup if ((!$isStored) && (array_key_exists($name, $this->themeConfigMin))): unset($this->themeConfigMin[$name]); endif; if ((!$isFound) && (array_key_exists($name, $this->themeConfig))): unset($this->themeConfig[$name]); endif; } public function saveSettingsFromPost(){ $theme_default_settings = $this->getDefaults(); if ((isset($_POST["p_reset"])) && ($_POST["p_reset"] == "on")): // Reset theme settings $config = array(); conf_update_param('greydragon', pwg_db_real_escape_string(serialize($config))); load_conf_from_db(); $this->loadConfig(); else: foreach ($theme_default_settings as $key => $value): $this->saveSettingFromPOST($key); endforeach; endif; } public function hasSettingFromPost($name) { return (isset($_POST[$name])); } public function getSettingFromPost($name) { if (isset($_POST[$name])): return $_POST[$name]; else: return FALSE; endif; } public function hasOption($name, $isGlobal = FALSE) { global $conf; if ($isGlobal): return (array_key_exists($name, $conf) && isset($conf[$name]) && ($conf[$name])); else: return (array_key_exists($name, $this->themeConfig)); endif; } public function deleteOption($name, $isGlobal = FALSE) { global $conf; if ($isGlobal): if (array_key_exists($name, $conf) && isset($conf[$name])): unset($conf[$name]); endif; else: if (array_key_exists($name, $this->themeConfig)): unset($this->themeConfig[$name]); endif; endif; } public function getOption($name, $isGlobal = FALSE) { global $conf; if ($isGlobal): if (array_key_exists($name, $conf)): return $conf[$name]; else: return FALSE; endif; else: if (array_key_exists($name, $this->themeConfig)): return $this->themeConfig[$name]; else: return FALSE; endif; endif; } public function hasCustomFavicon() { return ($this->hasOption("p_logo_path")); } public function update($old_version, $new_version) { $this->prepareCustomCSS(); } public function uninstall() { // delete configuration $this->deleteCustomCSS(); conf_delete_param('greydragon'); } public function prepareHomePage($prefix, $pageId) { $r_desc = $this->getOption('p_rootpage_desc'); $r_link = $this->getOption('p_rootpage_link'); $r_scr = $this->getOption('p_rootpage_src'); $r_size = $this->getOption('p_rootpage_size'); $r_mode = $this->getOption('p_rootpage_mode'); $r_id = $this->getOption('p_rootpage_id'); $r_delay = $this->getOption('p_rootpage_delay'); $r_elastic = ($this->getOption('p_rootpage_elastic') == "on")? 'true' : 'false'; $r_navarr = ($this->getOption('p_rootpage_navarr') == "on")? 'true' : 'false'; $r_navctr = ($this->getOption('p_rootpage_navctr') == "on")? 'true' : 'false'; $content = '