source: branches/2.3/phpgwapi/inc/class.setup_html.inc.php @ 3540

Revision 3540, 11.3 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1344 - Informar na tela de login dados de identificação.

  • 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="templates/default/images/orange-ball.png" alt="ball" />';                               
159                        }
160
161                        $GLOBALS['setup_tpl']->set_var('lang_version',lang('version'));
162                        if(!is_file(dirname( __FILE__ ) . '/../../infodist/ultima-revisao-svn.php'))
163                            {
164                                $GLOBALS['setup_tpl']->set_var('pgw_ver',@$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
165                            }
166                        else
167                            {
168                                $aux = '';
169                                include_once(dirname( __FILE__ ) . '/../../infodist/ultima-revisao-svn.php');
170                                if(isset($ultima_revisao))
171                                    {
172                                        $aux =  '<br>' . $ultima_revisao;
173                                    }
174                                $GLOBALS['setup_tpl']->set_var('pgw_ver',@$GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] . $aux);
175                            }
176                       
177                        $GLOBALS['setup_tpl']->set_var(array(
178                                'logoutbutton'  => $btn_logout,
179                                'indexbutton'   => $index_btn,
180                                'indeximg'      => $index_img,
181                                'check_install' => $check_install,
182                                'main_menu'     => lang('Setup Main Menu'),
183                                'user_login'    => lang('Back to user login')
184                        ));
185                        $GLOBALS['setup_tpl']->pparse('out','T_head');
186                        /* $setup_tpl->set_var('T_head',''); */
187                }
188
189                function show_footer()
190                {
191                        $GLOBALS['setup_tpl']->pparse('out','T_footer');
192                        unset($GLOBALS['setup_tpl']);
193                }
194
195                function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
196                {
197                        $GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word);
198                        $GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg);
199                        $GLOBALS['setup_tpl']->pparse('out','T_alert_msg');
200                }
201
202                function make_frm_btn_simple($pre_frm_blurb='',$frm_method='POST',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
203                {
204                        /* a simple form has simple components */
205                        $simple_form = $pre_frm_blurb  ."\n"
206                                . '<form method="' . $frm_method . '" action="' . $frm_action  . '">' . "\n"
207                                . '<input type="'  . $input_type . '" value="'  . $input_value . '">' . "\n"
208                                . '</form>' . "\n"
209                                . $post_frm_blurb . "\n";
210                        return $simple_form;
211                }
212
213                function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
214                {
215                        /* a simple href link has simple components */
216                        $simple_link = $pre_link_blurb
217                                . '<a href="' . $href_link . '">' . $href_text . '</a> '
218                                . $post_link_blurb . "\n";
219                        return $simple_link;
220                }
221
222                function login_form()
223                {
224                        /* begin use TEMPLATE login_main.tpl */
225                        $GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG']);
226                        $GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',@$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG']);
227                        $GLOBALS['setup_tpl']->set_var('lang_header_username',lang('Header Username'));
228                        $GLOBALS['setup_tpl']->set_var('lang_header_password',lang('Header Password'));
229                        $GLOBALS['setup_tpl']->set_var('lang_header_login',lang('Header Admin Login'));
230                        $GLOBALS['setup_tpl']->set_var('lang_config_login',lang('Setup/Config Admin Login'));
231                        $GLOBALS['setup_tpl']->set_var('lang_config_username',lang('Config Username'));
232                        $GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password'));
233                        $GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain'));
234
235                        $GLOBALS['setup_tpl']->set_var('lang_select',lang_select());
236
237                        if ($GLOBALS['phpgw_info']['setup']['stage']['header'] == '10')
238                        {
239                                /*
240                                 Begin use SUB-TEMPLATE login_stage_header,
241                                 fills V_login_stage_header used inside of login_main.tpl
242                                */
243                                if (count($GLOBALS['phpgw_domain']) > 1)
244                                {
245                                        foreach($GLOBALS['phpgw_domain'] as $domain => $data)
246                                        {
247                                                $domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['phpgw_info']['setup']['LastDomain'] ? ' SELECTED' : '').">$domain</option>\n";
248                                        }
249                                        $GLOBALS['setup_tpl']->set_var('domains',$domains);
250
251                                        // use BLOCK B_multi_domain inside of login_stage_header
252                                        $GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain');
253                                        // in this case, the single domain block needs to be nothing
254                                        $GLOBALS['setup_tpl']->set_var('V_single_domain','');
255                                }
256                                else
257                                {
258                                        reset($GLOBALS['phpgw_domain']);
259                                        $default_domain = each($GLOBALS['phpgw_domain']);
260                                        $GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain[0]);
261
262                                        /* Use BLOCK B_single_domain inside of login_stage_header */
263                                        $GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain');
264                                        /* in this case, the multi domain block needs to be nothing */
265                                        $GLOBALS['setup_tpl']->set_var('V_multi_domain','');
266                                }
267                                /*
268                                 End use SUB-TEMPLATE login_stage_header
269                                 put all this into V_login_stage_header for use inside login_main
270                                */
271                                $GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header');
272                        }
273                        else
274                        {
275                                /* begin SKIP SUB-TEMPLATE login_stage_header */
276                                $GLOBALS['setup_tpl']->set_var('V_multi_domain','');
277                                $GLOBALS['setup_tpl']->set_var('V_single_domain','');
278                                $GLOBALS['setup_tpl']->set_var('V_login_stage_header','');
279                        }
280                        /*
281                         end use TEMPLATE login_main.tpl
282                         now out the login_main template
283                        */
284                        $GLOBALS['setup_tpl']->pparse('out','T_login_main');
285                }
286
287                function get_template_list()
288                {
289                        $d = dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates');
290
291                        while($entry = $d->read())
292                        {
293                                if ($entry != 'CVS' && $entry != '.' && $entry != '..')
294                                {
295                                        $list[$entry]['name'] = $entry;
296                                        $f = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
297                                        if (file_exists ($f))
298                                        {
299                                                include($f);
300                                                $list[$entry]['title'] = 'Use ' . $GLOBALS['phpgw_info']['template'][$entry]['title'] . 'interface';
301                                        }
302                                        else
303                                        {
304                                                $list[$entry]['title'] = $entry;
305                                        }
306                                }
307                        }
308                        $d->close();
309                        reset ($list);
310                        return $list;
311                }
312
313                function list_themes()
314                {
315                        $dh = dir(PHPGW_SERVER_ROOT . '/phpgwapi/themes');
316                        while ($file = $dh->read())
317                        {
318                                if (eregi("\.theme$", $file))
319                                {
320                                        $list[] = substr($file,0,strpos($file,'.'));
321                                }
322                        }
323                        $dh->close();
324                        reset ($list);
325                        return $list;
326                }
327        }
328?>
Note: See TracBrowser for help on using the repository browser.