Classes

File phpboost/theme/ThemeConfiguration.class.php

File phpboost/theme/ThemeConfiguration.class.php

  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 
<?php
/**
 * @package     PHPBoost
 * @subpackage  Theme
 * @copyright   &copy; 2005-2019 PHPBoost
 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
 * @author      Kevin MASSY <reidlos@phpboost.com>
 * @version     PHPBoost 5.2 - last update: 2014 12 22
 * @since       PHPBoost 3.0 - 2011 04 10
*/

class ThemeConfiguration
{
    private $name;
    private $author_name;
    private $author_mail;
    private $author_link;
    private $version;
    private $description = '';
    private $date;
    private $compatibility;
    private $require_copyright = false;
    private $html_version = '1.0 Strict';
    private $css_version = 2.1;
    private $columns_disabled = null;
    private $main_color = '';
    private $variable_width;
    private $width;
    private $pictures;
    private $repository;

    public function __construct($config_ini_file, $desc_ini_file)
    {
        $this->load_configuration($config_ini_file);
        $this->load_description($desc_ini_file);
    }

    public function get_name()
    {
        return $this->name;
    }

    public function get_author_name()
    {
        return $this->author_name;
    }

    public function get_author_mail()
    {
        return $this->author_mail;
    }

    public function get_author_link()
    {
        return $this->author_link;
    }

    public function get_version()
    {
        return $this->version;
    }

    public function get_description()
    {
        return $this->description;
    }

    public function get_compatibility()
    {
        return $this->compatibility;
    }

    public function get_require_copyright()
    {
        return $this->require_copyright;
    }

    public function get_html_version()
    {
        return $this->html_version;
    }

    public function get_css_version()
    {
        return $this->css_version;
    }

    public function get_columns_disabled()
    {
        return $this->columns_disabled;
    }

    public function get_main_color()
    {
        return $this->main_color;
    }

    public function get_variable_width()
    {
        return $this->variable_width;
    }

    public function get_width()
    {
        return $this->width;
    }

    public function get_pictures()
    {
        return $this->pictures;
    }

    public function get_first_picture()
    {
        if (isset($this->pictures[0]))
        {
            return $this->pictures[0];
        }
        return '';
    }

    public function get_repository()
    {
        return $this->repository;
    }

    private function load_configuration($config_ini_file)
    {
        $config = @parse_ini_file($config_ini_file);

        if ($config === false)
        {
            throw new IOException('Load ini file "'. $config_ini_file .'" failed');
        }

        $this->check_parse_ini_file($config, $config_ini_file);

        $this->author_name = $config['author'];
        $this->author_mail = $config['author_mail'];
        $this->author_link = $config['author_link'];
        $this->version = $config['version'];
        $this->date = isset($config['date']) ? $config['date'] : '';
        $this->compatibility = $config['compatibility'];
        $this->require_copyright = (bool)$config['require_copyright'];
        $this->html_version = isset($config['html_version']) ? $config['html_version'] : '';
        $this->css_version = isset($config['css_version']) ? $config['css_version'] : '';
        $this->columns_disabled = isset($config['columns_disabled']) ? $this->parse_columns_disabled_array($config['columns_disabled']) : new ColumnsDisabled();
        $this->variable_width = (bool)$config['variable_width'];
        $this->width = isset($config['width']) ? $config['width'] : '';
        $this->pictures = isset($config['pictures']) ? $this->parse_pictures_array($config['pictures']) : array();
        $this->repository = !empty($config['repository']) ? $config['repository'] : Updates::PHPBOOST_OFFICIAL_REPOSITORY;

    }

    private function load_description($desc_ini_file)
    {
        $desc = @parse_ini_file($desc_ini_file);
        $this->check_parse_ini_file($desc, $desc_ini_file);
        $this->name = $desc['name'];
        $this->description = $desc['desc'];
        $this->main_color = $desc['main_color'];
    }

    private function parse_pictures_array($pictures)
    {
        return explode(',', $pictures);
    }

    private function parse_columns_disabled_array($columns_disabled)
    {
        $columns_disabled_array = explode(',', $columns_disabled);
        $columns_disabled_class = new ColumnsDisabled();
        $columns_disabled_class->set_columns_disabled($columns_disabled_array);

        return $columns_disabled_class;
    }

    private function check_parse_ini_file($parse_result, $ini_file)
    {
        if ($parse_result === false)
        {
            throw new Exception('Parse ini file "' . $ini_file . '" failed');
        }
    }
}
?>
Annonces