Subversion Repositories ALCASAR

Rev

Rev 3037 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3037 Rev 3287
Line 52... Line 52...
52
     * @var array
52
     * @var array
53
     */
53
     */
54
    private $_templates = array();
54
    private $_templates = array();
55
 
55
 
56
    /**
56
    /**
57
     * configured bootstrap template
-
 
58
     *
-
 
59
     * @var string
-
 
60
     */
-
 
61
    private $_bootstrap_template;
-
 
62
 
-
 
63
    /**
-
 
64
     * all available bootstrap templates
-
 
65
     *
-
 
66
     * @var array
-
 
67
     */
-
 
68
    private $_bootstrap_templates = array();
-
 
69
 
-
 
70
    /**
-
 
71
     * all available languages
57
     * all available languages
72
     *
58
     *
73
     * @var array
59
     * @var array
74
     */
60
     */
75
    private $_languages = array();
61
    private $_languages = array();
Line 92... Line 78...
92
     * check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini
78
     * check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini
93
     * @param string $indexname
79
     * @param string $indexname
94
     */
80
     */
95
    public function __construct($indexname="dynamic")
81
    public function __construct($indexname="dynamic")
96
    {
82
    {
-
 
83
        if ($indexname !== "bootstrap") {
-
 
84
            $indexname = "dynamic";
-
 
85
        }
97
        $this->_indexname = $indexname;
86
        $this->_indexname = $indexname;
98
        parent::__construct();
87
        parent::__construct();
99
        $this->_getTemplateList();
88
        $this->_getTemplateList();
100
        $this->_getLanguageList();
89
        $this->_getLanguageList();
101
    }
90
    }
Line 106... Line 95...
106
     *
95
     *
107
     * @return void
96
     * @return void
108
     */
97
     */
109
    private function _checkTemplateLanguage()
98
    private function _checkTemplateLanguage()
110
    {
99
    {
-
 
100
        switch ($this->_indexname) {
-
 
101
        case 'dynamic':
111
        if (!defined("PSI_DEFAULT_TEMPLATE") || (($this->_template = strtolower(trim(PSI_DEFAULT_TEMPLATE))) == "") || !file_exists(PSI_APP_ROOT.'/templates/'.$this->_template.".css")) {
102
            if (!defined("PSI_DEFAULT_TEMPLATE") || (($this->_template = strtolower(trim(PSI_DEFAULT_TEMPLATE))) == "") || !file_exists(PSI_APP_ROOT.'/templates/dynamic/'.$this->_template.".css")) {
112
            $this->_template = 'phpsysinfo';
103
                $this->_template = 'phpsysinfo';
113
        }
104
            }
-
 
105
            break;
-
 
106
        case 'bootstrap':
114
        if (!defined("PSI_DEFAULT_BOOTSTRAP_TEMPLATE") || (($this->_bootstrap_template = strtolower(trim(PSI_DEFAULT_BOOTSTRAP_TEMPLATE))) == "") || !file_exists(PSI_APP_ROOT.'/templates/'.$this->_bootstrap_template."_bootstrap.css")) {
107
            if (!defined("PSI_DEFAULT_BOOTSTRAP_TEMPLATE") || (($this->_template = strtolower(trim(PSI_DEFAULT_BOOTSTRAP_TEMPLATE))) == "") || !file_exists(PSI_APP_ROOT.'/templates/bootstrap/'.$this->_template.".css")) {
115
            $this->_bootstrap_template = 'phpsysinfo';
108
                $this->_template = 'phpsysinfo';
-
 
109
            }
-
 
110
            break;
-
 
111
        default:
-
 
112
            $this->_template = '';
116
        }
113
        }
117
        $this->_pick_template = !defined("PSI_SHOW_PICKLIST_TEMPLATE") || (PSI_SHOW_PICKLIST_TEMPLATE !== false);
114
        $this->_pick_template = !defined("PSI_SHOW_PICKLIST_TEMPLATE") || (PSI_SHOW_PICKLIST_TEMPLATE !== false);
118
 
115
 
119
        if (!defined("PSI_DEFAULT_LANG") || (($this->_language = strtolower(trim(PSI_DEFAULT_LANG))) == "") || !file_exists(PSI_APP_ROOT.'/language/'.$this->_language.".xml")) {
116
        if (!defined("PSI_DEFAULT_LANG") || (($this->_language = strtolower(trim(PSI_DEFAULT_LANG))) == "") || !file_exists(PSI_APP_ROOT.'/language/'.$this->_language.".xml")) {
120
            $this->_language = 'en';
117
            $this->_language = 'en';
Line 127... Line 124...
127
     *
124
     *
128
     * @return void
125
     * @return void
129
     */
126
     */
130
    private function _getTemplateList()
127
    private function _getTemplateList()
131
    {
128
    {
132
        $dirlist = CommonFunctions::gdc(PSI_APP_ROOT.'/templates/');
129
        $dirlist = CommonFunctions::gdc(PSI_APP_ROOT.'/templates/'.$this->_indexname.'/');
133
        sort($dirlist);
130
        sort($dirlist);
134
        foreach ($dirlist as $file) {
131
        foreach ($dirlist as $file) {
135
            $tpl_ext = substr($file, strlen($file) - 4);
132
            $tpl_ext = substr($file, strlen($file) - 4);
136
            $tpl_name = substr($file, 0, strlen($file) - 4);
133
            $tpl_name = substr($file, 0, strlen($file) - 4);
137
            if ($tpl_ext === ".css") {
134
            if ($tpl_ext === ".css") {
138
                if (preg_match("/(\S+)_bootstrap$/", $tpl_name, $ar_buf)) {
-
 
139
                    array_push($this->_bootstrap_templates, $ar_buf[1]);
-
 
140
                } else {
-
 
141
                    array_push($this->_templates, $tpl_name);
135
                array_push($this->_templates, $tpl_name);
142
                }
-
 
143
            }
136
            }
144
        }
137
        }
145
    }
138
    }
146
 
139
 
147
    /**
140
    /**
Line 169... Line 162...
169
     */
162
     */
170
    public function run()
163
    public function run()
171
    {
164
    {
172
        $this->_checkTemplateLanguage();
165
        $this->_checkTemplateLanguage();
173
 
166
 
174
        $tpl = new Template("/templates/html/index_".$this->_indexname.".html");
167
        $tpl = new Template("/templates/index_".$this->_indexname.".html");
175
 
168
 
176
        $tpl->set("template", $this->_template);
169
        $tpl->set("template", $this->_template);
177
        $tpl->set("templates", $this->_templates);
170
        $tpl->set("templates", $this->_templates);
178
        $tpl->set("bootstraptemplate", $this->_bootstrap_template);
-
 
179
        $tpl->set("bootstraptemplates", $this->_bootstrap_templates);
-
 
180
        $tpl->set("picktemplate", $this->_pick_template);
171
        $tpl->set("picktemplate", $this->_pick_template);
181
        $tpl->set("language", $this->_language);
172
        $tpl->set("language", $this->_language);
182
        $tpl->set("languages", $this->_languages);
173
        $tpl->set("languages", $this->_languages);
183
        $tpl->set("picklanguage", $this->_pick_language);
174
        $tpl->set("picklanguage", $this->_pick_language);
184
        $tpl->set("showCPUListExpanded", defined('PSI_SHOW_CPULIST_EXPANDED') ? (PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false') : 'true');
175
        $tpl->set("showCPUListExpanded", defined('PSI_SHOW_CPULIST_EXPANDED') ? (PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false') : 'true');