array("value" => null, "quotes" => QUOTES_NONE), "p_favicon_path" => array("value" => null, "quotes" => QUOTES_NONE), "p_apple_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" => null, "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_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_default" => array("value" => "desc", "quotes" => QUOTES_NONE), "p_pict_tab_anim" => array("value" => "off", "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_src" => array("value" => "slider", "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; $this->themeConfigMin = unserialize($conf['greydragon']); $this->themeConfigMin["version"] = $ver; $this->themeConfig = $this->validateDefault($this->themeConfigMin); } private function validateDefault($config) { $theme_default_settings = $this->getDefaults(); foreach ($theme_default_settings as $key => $value): if ($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() { // add_event_handler('get_admin_plugin_menu_links', array(&$this, 'pluginAdminMenu') ); } public function loadCSS() { // parent::loadCSS(); // GPCCore::addUI('gpcCSS'); } public function getConfig($isFull = TRUE) { if ($isFull): return $this->themeConfig; else: return $this->themeConfigMin; 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 conf_update_param('greydragon', pwg_db_real_escape_string(serialize(array()))); 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 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 prepareHomePage($prefix, $pageId) { $r_desc = $this->getOption('p_rootpage_desc'); $r_scr = $this->getOption('p_rootpage_src'); $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 = '
'; if ($r_desc): $content .= '
' . $r_desc . '
'; endif; $content .= '
'; if ($r_scr == "photo"): $content .= '[photo id=' . $r_id . ' size=M html=yes link=no]'; elseif ($r_scr == "random"): $content .= '[random album=' . $r_id . ' size=M html=yes link=no]'; else: $content .= '[slider album=' . $r_id . ' nb_images=10 random=yes size=M speed=' . $r_delay . ' title=no effect=' . $r_mode . ' arrows=' . $r_navarr . ' control=' . $r_navctr . ' elastic=' . $r_elastic . ']'; endif; $content .= '
'; // $query = 'UPDATE ' . $prefix . 'additionalpages ' . 'SET content = "' . pwg_db_real_escape_string($content) . '" ' . ' , standalone = FALSE ' . 'WHERE (id = ' . $pageId . ') AND (content <> "' . pwg_db_real_escape_string($content) . '");'; pwg_query($query); return (pwg_db_changes() > 0); } public function getHeader() { $content = ""; if ($this->hasOption('p_logo_path')): $content .= ''; endif; if ($this->hasOption('p_header')): $content .= '' . $this->getOption('p_header') . ''; elseif ($this->hasOption('page_banner', TRUE)): $content .= '' . $this->getOption('page_banner', TRUE) . ''; endif; return $content; } public function getHead($content) { if ($favicon_name = $this->getOption('p_favicon_path')): $search = '##'; $replacement = ''; $content = preg_replace($search, $replacement, $content); endif; if ($this->getOption('p_nogenerator') == "on"): $search = '##'; $replacement = ''; $content = preg_replace($search, $replacement, $content); endif; return $content; } } ?>