source: trunk/phpgwapi/inc/class.setup_html.inc.php @ 2

Revision 2, 10.6 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Setup                                                       *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  * This file written by Tony Puglisi (Angles) <angles@aminvestments.com>    *
7  *  and Miles Lott<milosch@groupwhere.org>                                  *
8  * --------------------------------------------                             *
9  *  This program is free software; you can redistribute it and/or modify it *
10  *  under the terms of the GNU General Public License as published by the   *
11  *  Free Software Foundation; either version 2 of the License, or (at your  *
12  *  option) any later version.                                              *
13  \**************************************************************************/
14
15
16        class setup_html
17        {
18                /*!
19                @function generate_header
20                @abstract generate header.inc.php file output - NOT a generic html header function
21                */
22                function generate_header()
23                {
24                        // PHP will automatically replace any dots in incoming
25                        // variable names with underscores.
26
27                        $GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
28                        $GLOBALS['header_template']->set_block('header','domain','domain');
29                        $var = Array();
30
31                        $deletedomain = get_var('deletedomain',Array('POST'));
32                        $domains = get_var('domains',Array('POST'));
33                        @reset($domains);
34                        while($domains && list($k,$v) = @each($domains))
35                        {
36                                if(isset($deletedomain[$k]))
37                                {
38                                        continue;
39                                }
40                                $variableName = str_replace('.','_',$k);
41                                $dom = get_var('setting_'.$variableName,Array('POST'));
42                                $GLOBALS['header_template']->set_var('DB_DOMAIN',$v);
43                                while(list($x,$y) = @each($dom))
44                                {
45                                        if(strtoupper($x) == 'CONFIG_PASS')
46                                        {
47                                                $GLOBALS['header_template']->set_var(strtoupper($x),md5($y));
48                                        }
49                                        else
50                                        {
51                                                $GLOBALS['header_template']->set_var(strtoupper($x),$y);
52                                        }
53                                }
54                                /* Admin did not type a new password, so use the old one from the hidden field,
55                                 * which is already md5 encoded.
56                                 */
57                                if($dom['config_password'] && !$dom['config_pass'])
58                                {
59                                        /* Real == hidden */
60                                        $GLOBALS['header_template']->set_var('CONFIG_PASS',$dom['config_password']);
61                                }
62                                /* If the admin didn't select a db_port, set to the default */
63                                if(!$dom['db_port'])
64                                {
65                                        $GLOBALS['header_template']->set_var('DB_PORT',$GLOBALS['default_db_ports'][$dom['db_type']]);
66                                }
67                                $GLOBALS['header_template']->parse('domains','domain',True);
68                        }
69
70                        $GLOBALS['header_template']->set_var('domain','');
71
72                        $setting = get_var('setting',Array('POST'));
73                       
74                        if ($setting['use_prefix_organization'] != 'True')
75                                $setting['use_prefix_organization'] = 'False';
76                       
77                        while($setting && list($k,$v) = @each($setting))
78                        {
79                                if(strtoupper($k) == 'HEADER_ADMIN_PASSWORD')
80                                {
81                                        $var[strtoupper($k)] = md5($v);
82                                }
83                                else
84                                {
85                                        $var[strtoupper($k)] = $v;
86                                }
87                        }
88                       
89                        /* Admin did not type a new header password, so use the old one from the hidden field,
90                         * which is already md5 encoded.
91                         */
92                        if($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD']))
93                        {
94                                /* Real == hidden */
95                                $var['HEADER_ADMIN_PASSWORD'] = $var['HEADER_ADMIN_PASS'];
96                        }
97                        $GLOBALS['header_template']->set_var($var);
98                        return $GLOBALS['header_template']->parse('out','header');
99                }
100
101                function setup_tpl_dir($app_name='setup')
102                {
103                        /* hack to get tpl dir */
104                        if (is_dir(PHPGW_SERVER_ROOT))
105                        {
106                                $srv_root = PHPGW_SERVER_ROOT . SEP . "$app_name" . SEP;
107                        }
108                        else
109                        {
110                                $srv_root = '';
111                        }
112
113                        $tpl_typical = 'templates' . SEP . 'default';
114                        $tpl_root = "$srv_root" ."$tpl_typical";
115                        return $tpl_root;
116                }
117
118                function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='')
119                {
120                        // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
121                        header('Content-type: text/html; charset='.lang('charset'));
122
123                        $GLOBALS['setup_tpl']->set_var('charset',lang('charset'));
124                        $style = array(
125                                'th_bg'         => '#486591',
126                                'th_text'       => '#FFFFFF',
127                                'row_on'        => '#DDDDDD',
128                                'row_off'       => '#EEEEEE',
129                                'banner_bg'     => '#4865F1',
130                                'msg'           => '#FF0000',
131                        );
132                        $GLOBALS['setup_tpl']->set_var($style);
133                        if ($nologoutbutton)
134                        {
135                                $GLOBALS['setup_tpl']->set_block('T_head','loged_in');
136                                $GLOBALS['setup_tpl']->set_var('loged_in','');
137                        }
138                        else
139                        {
140                                $btn_logout = '<a href="index.php?FormLogout=' . $logoutfrom . '" class="link">' . lang('Logout').'</a>';
141                                $check_install = '<a class="textsidebox" href="check_install.php">'.lang('Check installation').'</a>';
142                        }
143
144                        $GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup'));
145                        $GLOBALS['setup_tpl']->set_var('page_title',$title);
146                        if ($configdomain == '')
147                        {
148                                $GLOBALS['setup_tpl']->set_var('configdomain','');
149                        }
150                        else
151                        {
152                                $GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': ' . $configdomain);
153                        }
154
155                        if(basename($_SERVER['SCRIPT_FILENAME']) != 'index.php')
156                        {
157                                $index_btn = '<a href="index.php" class="link">' . lang('Setup Main Menu') . '</a>';
158                                $index_img = '<img src="../phpgwapi/templates/idots/images/orange-ball.png" alt="ball" />';
159                        }
160
161                        $GLOBALS['setup_tpl']->set_var('lang_version',lang('version'));
162                        $GLOBALS['setup_tpl']->set_var('pgw_ver',@$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
163                        $GLOBALS['setup_tpl']->set_var(array(
164                                'logoutbutton'  => $btn_logout,
165                                'indexbutton'   => $index_btn,
166                                'indeximg'      => $index_img,
167                                'check_install' => $check_install,
168                                'main_menu'     => lang('Setup Main Menu'),
169                                'user_login'    => lang('Back to user login')
170                        ));
171                        $GLOBALS['setup_tpl']->pparse('out','T_head');
172                        /* $setup_tpl->set_var('T_head',''); */
173                }
174
175                function show_footer()
176                {
177                        $GLOBALS['setup_tpl']->pparse('out','T_footer');
178                        unset($GLOBALS['setup_tpl']);
179                }
180
181                function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
182                {
183                        $GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word);
184                        $GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg);
185                        $GLOBALS['setup_tpl']->pparse('out','T_alert_msg');
186                }
187
188                function make_frm_btn_simple($pre_frm_blurb='',$frm_method='POST',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
189                {
190                        /* a simple form has simple components */
191                        $simple_form = $pre_frm_blurb  ."\n"
192                                . '<form method="' . $frm_method . '" action="' . $frm_action  . '">' . "\n"
193                                . '<input type="'  . $input_type . '" value="'  . $input_value . '">' . "\n"
194                                . '</form>' . "\n"
195                                . $post_frm_blurb . "\n";
196                        return $simple_form;
197                }
198
199                function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
200                {
201                        /* a simple href link has simple components */
202                        $simple_link = $pre_link_blurb
203                                . '<a href="' . $href_link . '">' . $href_text . '</a> '
204                                . $post_link_blurb . "\n";
205                        return $simple_link;
206                }
207
208                function login_form()
209                {
210                        /* begin use TEMPLATE login_main.tpl */
211                        $GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG']);
212                        $GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',@$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG']);
213                        $GLOBALS['setup_tpl']->set_var('lang_header_username',lang('Header Username'));
214                        $GLOBALS['setup_tpl']->set_var('lang_header_password',lang('Header Password'));
215                        $GLOBALS['setup_tpl']->set_var('lang_header_login',lang('Header Admin Login'));
216                        $GLOBALS['setup_tpl']->set_var('lang_config_login',lang('Setup/Config Admin Login'));
217                        $GLOBALS['setup_tpl']->set_var('lang_config_username',lang('Config Username'));
218                        $GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password'));
219                        $GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain'));
220
221                        $GLOBALS['setup_tpl']->set_var('lang_select',lang_select());
222
223                        if ($GLOBALS['phpgw_info']['setup']['stage']['header'] == '10')
224                        {
225                                /*
226                                 Begin use SUB-TEMPLATE login_stage_header,
227                                 fills V_login_stage_header used inside of login_main.tpl
228                                */
229                                if (count($GLOBALS['phpgw_domain']) > 1)
230                                {
231                                        foreach($GLOBALS['phpgw_domain'] as $domain => $data)
232                                        {
233                                                $domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['phpgw_info']['setup']['LastDomain'] ? ' SELECTED' : '').">$domain</option>\n";
234                                        }
235                                        $GLOBALS['setup_tpl']->set_var('domains',$domains);
236
237                                        // use BLOCK B_multi_domain inside of login_stage_header
238                                        $GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain');
239                                        // in this case, the single domain block needs to be nothing
240                                        $GLOBALS['setup_tpl']->set_var('V_single_domain','');
241                                }
242                                else
243                                {
244                                        reset($GLOBALS['phpgw_domain']);
245                                        $default_domain = each($GLOBALS['phpgw_domain']);
246                                        $GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain[0]);
247
248                                        /* Use BLOCK B_single_domain inside of login_stage_header */
249                                        $GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain');
250                                        /* in this case, the multi domain block needs to be nothing */
251                                        $GLOBALS['setup_tpl']->set_var('V_multi_domain','');
252                                }
253                                /*
254                                 End use SUB-TEMPLATE login_stage_header
255                                 put all this into V_login_stage_header for use inside login_main
256                                */
257                                $GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header');
258                        }
259                        else
260                        {
261                                /* begin SKIP SUB-TEMPLATE login_stage_header */
262                                $GLOBALS['setup_tpl']->set_var('V_multi_domain','');
263                                $GLOBALS['setup_tpl']->set_var('V_single_domain','');
264                                $GLOBALS['setup_tpl']->set_var('V_login_stage_header','');
265                        }
266                        /*
267                         end use TEMPLATE login_main.tpl
268                         now out the login_main template
269                        */
270                        $GLOBALS['setup_tpl']->pparse('out','T_login_main');
271                }
272
273                function get_template_list()
274                {
275                        $d = dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates');
276
277                        while($entry = $d->read())
278                        {
279                                if ($entry != 'CVS' && $entry != '.' && $entry != '..')
280                                {
281                                        $list[$entry]['name'] = $entry;
282                                        $f = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
283                                        if (file_exists ($f))
284                                        {
285                                                include($f);
286                                                $list[$entry]['title'] = 'Use ' . $GLOBALS['phpgw_info']['template'][$entry]['title'] . 'interface';
287                                        }
288                                        else
289                                        {
290                                                $list[$entry]['title'] = $entry;
291                                        }
292                                }
293                        }
294                        $d->close();
295                        reset ($list);
296                        return $list;
297                }
298
299                function list_themes()
300                {
301                        $dh = dir(PHPGW_SERVER_ROOT . '/phpgwapi/themes');
302                        while ($file = $dh->read())
303                        {
304                                if (eregi("\.theme$", $file))
305                                {
306                                        $list[] = substr($file,0,strpos($file,'.'));
307                                }
308                        }
309                        $dh->close();
310                        reset ($list);
311                        return $list;
312                }
313        }
314?>
Note: See TracBrowser for help on using the repository browser.