Ignore:
Timestamp:
Jan 23, 2015, 7:53:13 PM (9 years ago)
Author:
SergeD
Message:

version 1.1.20 - please refer to change log for more details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/greydragon/include/greydragon.class.php

    r30783 r30900  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 define('GDTHEME_VERSION', '1.1.19');
     5define('GDTHEME_VERSION', '1.1.20');
    66
    77define("QUOTES_NONE",   FALSE);
     
    3636
    3737    return array(
     38      "p_version"          => array("value" => "",       "quotes" => QUOTES_NONE),
     39
    3840      // General Settings
    3941      "p_logo_path"        => array("value" => null,     "quotes" => QUOTES_NONE),
    40       "p_favicon_path"     => array("value" => null,     "quotes" => QUOTES_NONE),
    41       "p_apple_path"       => array("value" => null,     "quotes" => QUOTES_NONE),
    4242      "p_header"           => array("value" => null,     "quotes" => QUOTES_LAZY),
    4343      "p_footer"           => array("value" => null,     "quotes" => QUOTES_LAZY),
    4444      "p_colorpack"        => array("value" => null,     "quotes" => QUOTES_NONE),
     45
     46      "p_favicon_ico"      => array("value" => null,     "quotes" => QUOTES_NONE),
     47      "p_favicon_png"      => array("value" => null,     "quotes" => QUOTES_NONE),
     48      "p_favicon_gif"      => array("value" => null,     "quotes" => QUOTES_NONE),
     49      "p_favicon_apple"    => array("value" => null,     "quotes" => QUOTES_NONE),
     50      "p_favicon_noshine"  => array("value" => "off",    "quotes" => QUOTES_NONE),
    4551   
    4652      // Advanced Options - General
     
    8086  private function loadConfig($ver = '') {
    8187    global $conf, $pwg_loaded_plugins;
     88
    8289    $this->themeConfigMin = unserialize($conf['greydragon']);
    8390    $this->themeConfigMin["version"] = $ver;
     
    8895
    8996  private function validateDefault($config) {
     97
     98    // Check version, perform update if necessary
     99    if (!isset($config["p_version"]) || ($this->themeConfigMin["version"] !== $config["p_version"])):
     100
     101      if (isset($config["p_favicon_path"])):
     102        $config["p_favicon_ico"] = $config["p_favicon_path"];
     103        unset($config["p_favicon_path"]);
     104      endif;
     105    endif;
     106
    90107    $theme_default_settings = $this->getDefaults();
    91108
    92109    foreach ($theme_default_settings as $key => $value):
    93       if ($value["value"]):
     110      if (isset($value["value"])):
    94111        if (array_key_exists($key, $config)):
    95112        else:
     
    100117
    101118    // Populate some system settings
    102 
    103119    $url_root = get_root_url();
    104120    $config['U_SITE_ADMIN'] = $url_root . 'admin.php?page=';
     
    120136      return $this->themeConfig;
    121137    else:
    122       return $this->themeConfigMin;
     138      $config = $this->themeConfigMin;
     139      $config['p_version'] = GDTHEME_VERSION;
     140      return $config;
    123141    endif;
    124142  }
     
    187205    if ((isset($_POST["p_reset"])) && ($_POST["p_reset"] == "on")):
    188206      // Reset theme settings
    189       conf_update_param('greydragon', pwg_db_real_escape_string(serialize(array())));
     207      $config = array();
     208      conf_update_param('greydragon', pwg_db_real_escape_string(serialize($config)));
    190209      load_conf_from_db();
    191210      $this->loadConfig();
     
    216235    else:
    217236      return (array_key_exists($name, $this->themeConfig));
     237    endif;
     238  }
     239
     240  public function deleteOption($name, $isGlobal = FALSE) {
     241    global $conf;
     242
     243    if ($isGlobal):
     244      if (array_key_exists($name, $conf) && isset($conf[$name])):
     245        unset($conf[$name]);
     246      endif;
     247    else:
     248      if (array_key_exists($name, $this->themeConfig)):
     249        unset($this->themeConfig[$name]);
     250      endif;
    218251    endif;
    219252  }
     
    235268      endif;
    236269    endif;
     270  }
     271
     272  public function hasCustomFavicon() {
     273    return ($this->hasOption("p_logo_path"));
     274  }
     275
     276  public function update($old_version, $new_version) {
     277    $this->prepareCustomCSS();
     278  }
     279
     280  public function uninstall() {
     281    // delete configuration
     282    $this->deleteCustomCSS();
     283
     284    conf_delete_param('greydragon');
    237285  }
    238286
     
    290338  }
    291339
    292   public function getHeader() {
    293     $content = "";
     340  public function getURLRoot() {
    294341    $root_base = get_root_url();
    295342    if ($root_base):
     
    297344      $root_base = '/';
    298345    endif;
     346    return $root_base;
     347  }
     348
     349  public function getHeader() {
     350    global $conf;
     351
     352    $content = "";
     353    $root_base = $this->getURLRoot();
    299354
    300355    if ($this->hasOption('p_logo_path')):
     
    302357    endif;
    303358    if ($this->hasOption('p_header')):
    304       $content .= '<a title="Home" id="g-header-text" href="' . $root_base . '">' . $this->getOption('p_header') . '</a>';
     359      $p_header = $this->getOption('p_header');
    305360    elseif ($this->hasOption('page_banner', TRUE)):
    306       $content .= '<a title="Home" id="g-header-text" href="' . $root_base . '">' . $this->getOption('page_banner', TRUE) . '</a>';
    307     endif;                                                                                                             
     361      $p_header = $this->getOption('page_banner', TRUE);
     362    else:
     363      $p_header = "";
     364    endif;
     365    $p_header = trim(str_replace('%gallery_title%', $conf['gallery_title'], $p_header));
     366    if (strlen($p_header) > 0):
     367      $content .= '<a title="Home" id="g-header-text" href="{$U_HOME}">' . $p_header . '</a>';
     368    endif;
    308369
    309370    return $content;
Note: See TracChangeset for help on using the changeset viewer.