| Conditions | 29 |
| Paths | > 20000 |
| Total Lines | 183 |
| Code Lines | 128 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 220 | function show_header_form($validation_errors) |
||
| 221 | { |
||
| 222 | global $setup_tpl; |
||
| 223 | |||
| 224 | $GLOBALS['egw_setup']->html->show_header($GLOBALS['egw_info']['setup']['HeaderFormMSG'], False, 'header'); |
||
| 225 | |||
| 226 | if(empty($_REQUEST['ConfigLang'])) |
||
| 227 | { |
||
| 228 | $setup_tpl->set_var('lang_select','<tr><td colspan="2"><form action="manageheader.php" method="post">Please Select your language '.setup_html::lang_select(True,'en')."</form></td></tr>"); |
||
| 229 | } |
||
| 230 | |||
| 231 | $setup_tpl->set_var('pagemsg',$GLOBALS['egw_info']['setup']['PageMSG']); |
||
| 232 | |||
| 233 | // checking required PHP version |
||
| 234 | if ((float) PHP_VERSION < $GLOBALS['egw_setup']->required_php_version) |
||
| 235 | { |
||
| 236 | $GLOBALS['egw_setup']->html->show_header($GLOBALS['egw_info']['setup']['header_msg'],True); |
||
| 237 | $GLOBALS['egw_setup']->html->show_alert_msg('Error', |
||
| 238 | lang('You are using PHP version %1. EGroupware now requires %2 or later, recommended is PHP %3.', |
||
| 239 | PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,$GLOBALS['egw_setup']->recommended_php_version)); |
||
| 240 | $GLOBALS['egw_setup']->html->show_footer(); |
||
| 241 | exit; |
||
| 242 | } |
||
| 243 | $detected = null; |
||
| 244 | $supported_db = $GLOBALS['egw_setup']->header->check_db_support($detected); |
||
| 245 | |||
| 246 | if (!count($supported_db)) |
||
| 247 | { |
||
| 248 | echo '<p align="center" class="msg"><b>' |
||
| 249 | . lang('Did not find any valid DB support!') |
||
| 250 | . "<br />\n" |
||
| 251 | . lang('Try to configure your php to support one of the above mentioned DBMS, or install EGroupware by hand.') |
||
| 252 | . '</b></p>'; |
||
| 253 | $GLOBALS['egw_setup']->html->show_footer(); |
||
| 254 | exit; |
||
| 255 | } |
||
| 256 | $js_default_db_ports = 'var default_db_ports = new Array();'."\n"; |
||
| 257 | foreach($GLOBALS['egw_setup']->header->default_db_ports as $db => $port) |
||
| 258 | { |
||
| 259 | $js_default_db_ports .= ' default_db_ports["'.$db.'"]="'.$port.'";'."\n"; |
||
| 260 | } |
||
| 261 | $setup_tpl->set_var('js_default_db_ports',$js_default_db_ports); |
||
| 262 | |||
| 263 | if ($validation_errors) $setup_tpl->set_var('detected','<ul><li>'.implode("</li>\n<li>",$validation_errors)."</li>\n</ul>\n"); |
||
| 264 | |||
| 265 | if ($_POST['adddomain']) |
||
| 266 | { |
||
| 267 | $GLOBALS['egw_domain'][lang('new')] = $GLOBALS['egw_setup']->header->domain_defaults( |
||
| 268 | $GLOBALS['egw_info']['server']['header_admin_user'], |
||
| 269 | $GLOBALS['egw_info']['server']['header_admin_password'],$supported_db); |
||
| 270 | } |
||
| 271 | // show the non-domain settings |
||
| 272 | //echo "<pre>".print_r($GLOBALS['egw_info']['server'],true)."</pre>\n"; |
||
| 273 | foreach($GLOBALS['egw_info']['server'] as $name => $value) |
||
| 274 | { |
||
| 275 | switch($name) |
||
| 276 | { |
||
| 277 | case 'db_persistent': |
||
| 278 | if ($GLOBALS['egw_info']['server'][$name] && is_array($GLOBALS['egw_domain'])) |
||
| 279 | { |
||
| 280 | $GLOBALS['egw_info']['server'][$name] = $GLOBALS['egw_setup']->header->check_db_persistent($GLOBALS['egw_domain']); |
||
| 281 | } |
||
| 282 | // fall through |
||
| 283 | case 'show_domain_selectbox': |
||
| 284 | case 'mcrypt_enabled': |
||
| 285 | $setup_tpl->set_var($name.($GLOBALS['egw_info']['server'][$name] ? '_yes' : '_no'),' selected="selected"'); |
||
| 286 | break; |
||
| 287 | default: |
||
| 288 | if (!is_array($value)) $setup_tpl->set_var($name,htmlspecialchars($value)); |
||
| 289 | break; |
||
| 290 | } |
||
| 291 | } |
||
| 292 | $supported_session_handler = array( |
||
| 293 | 'egw_session_files' => lang('PHP session handler enabled in php.ini'), |
||
| 294 | ); |
||
| 295 | if ($GLOBALS['egw_info']['server']['session_handler'] && !isset($supported_session_handler[$GLOBALS['egw_info']['server']['session_handler']])) |
||
| 296 | { |
||
| 297 | $supported_session_handler[$GLOBALS['egw_info']['server']['session_handler']] = lang("Custom handler: %1",$GLOBALS['egw_info']['server']['session_handler']); |
||
| 298 | } |
||
| 299 | $options = array(); |
||
| 300 | foreach($supported_session_handler as $type => $label) |
||
| 301 | { |
||
| 302 | $options[] = '<option ' . ($type == $GLOBALS['egw_info']['server']['session_handler'] ? |
||
| 303 | 'selected="selected" ' : '') . 'value="' . $type . '">' . $label . '</option>'; |
||
| 304 | } |
||
| 305 | $setup_tpl->set_var('session_options',implode("\n",$options)); |
||
| 306 | |||
| 307 | // showing the settings of all domains |
||
| 308 | foreach($GLOBALS['egw_domain'] as $domain => $data) |
||
| 309 | { |
||
| 310 | $setup_tpl->set_var('db_domain',htmlspecialchars($domain)); |
||
| 311 | foreach($data as $name => $value) |
||
| 312 | { |
||
| 313 | if ($name == 'db_port' && !$value) // Set default here if the admin didn't set a port yet |
||
| 314 | { |
||
| 315 | $value = $GLOBALS['egw_setup']->header->default_db_ports[$data['db_type']]; |
||
| 316 | } |
||
| 317 | $setup_tpl->set_var($name,htmlspecialchars($value)); |
||
| 318 | } |
||
| 319 | $dbtype_options = ''; |
||
| 320 | foreach($supported_db as $db) |
||
| 321 | { |
||
| 322 | $dbtype_options .= '<option ' . ($db == $data['db_type'] ? 'selected="selected" ' : ''). |
||
| 323 | 'value="' . $db . '">' . $GLOBALS['egw_setup']->header->db_fullnames[$db] . "</option>\n"; |
||
| 324 | } |
||
| 325 | $setup_tpl->set_var('dbtype_options',$dbtype_options); |
||
| 326 | |||
| 327 | $setup_tpl->parse('domains','domain',True); |
||
| 328 | } |
||
| 329 | if(is_writeable('../header.inc.php') || !file_exists('../header.inc.php') && is_writeable('../')) |
||
| 330 | { |
||
| 331 | $setup_tpl->set_var('actions',lang('%1, %2 or %3 the configuration file.', |
||
| 332 | '<input type="submit" name="action[write]" value="'.htmlspecialchars(lang('Write')).'" />', |
||
| 333 | '<input type="submit" name="action[download]" value="'.htmlspecialchars(lang('Download')).'" />', |
||
| 334 | '<input type="submit" name="action[view]" value="'.htmlspecialchars(lang('View')).'" />')); |
||
| 335 | } |
||
| 336 | else |
||
| 337 | { |
||
| 338 | $setup_tpl->set_var('actions',lang('Cannot create the header.inc.php due to file permission restrictions.<br /> Instead you can %1 or %2 the file.', |
||
| 339 | '<input type="submit" name="action[download]" value="'.htmlspecialchars(lang('Download')).'" />', |
||
| 340 | '<input type="submit" name="action[view]" value="'.htmlspecialchars(lang('View')).'" />')); |
||
| 341 | } |
||
| 342 | // set domain and password for the continue button |
||
| 343 | @reset($GLOBALS['egw_domain']); |
||
| 344 | $firstDomain = @key($GLOBALS['egw_domain']); |
||
| 345 | |||
| 346 | $setup_tpl->set_var(array( |
||
| 347 | 'FormDomain' => $firstDomain, |
||
| 348 | 'FormUser' => $GLOBALS['egw_domain'][$firstDomain]['config_user'], |
||
| 349 | 'FormPW' => $GLOBALS['egw_domain'][$firstDomain]['config_passwd'] |
||
| 350 | )); |
||
| 351 | |||
| 352 | $setup_tpl->set_var(array( |
||
| 353 | 'lang_analysis' => $validation_errors ? lang('Validation errors') : '', |
||
| 354 | 'lang_settings' => lang('Settings'), |
||
| 355 | 'lang_domain' => lang('Database instance (EGw domain)'), |
||
| 356 | 'lang_delete' => lang('Delete'), |
||
| 357 | 'lang_adddomain' => lang('Add new database instance (EGw domain)'), |
||
| 358 | 'lang_serverroot' => lang('Server Root'), |
||
| 359 | 'lang_serverroot_descr'=> lang('Path (not URL!) to your EGroupware installation.'), |
||
| 360 | 'lang_adminuser' => lang('Header username'), |
||
| 361 | 'lang_adminuser_descr' => lang('Admin user for header manager'), |
||
| 362 | 'lang_adminpass' => lang('Header password'), |
||
| 363 | 'lang_adminpass_descr' => lang('Admin password to header manager').'.', |
||
| 364 | 'lang_leave_empty' => lang('Leave empty to keep current.'), |
||
| 365 | 'lang_setup_acl' => lang('Limit access'), |
||
| 366 | 'lang_setup_acl_descr' => lang('Limit access to setup to the following addresses, networks or hostnames (e.g. 127.0.0.1,10.1.1,myhost.dnydns.org)'), |
||
| 367 | 'lang_dbhost' => lang('DB Host'), |
||
| 368 | 'lang_dbhostdescr' => lang('Hostname/IP of database server').'<br />'. |
||
| 369 | lang('Postgres: Leave it empty to use the prefered unix domain sockets instead of a tcp/ip connection').'<br />'. |
||
| 370 | lang('ODBC / MaxDB: DSN (data source name) to use'), |
||
| 371 | 'lang_dbport' => lang('DB Port'), |
||
| 372 | 'lang_dbportdescr' => lang('TCP port number of database server'), |
||
| 373 | 'lang_dbname' => lang('DB Name'), |
||
| 374 | 'lang_dbnamedescr' => lang('Name of database'), |
||
| 375 | 'lang_dbuser' => lang('DB User'), |
||
| 376 | 'lang_dbuserdescr' => lang('Name of db user EGroupware uses to connect'), |
||
| 377 | 'lang_dbpass' => lang('DB Password'), |
||
| 378 | 'lang_dbpassdescr' => lang('Password of db user'), |
||
| 379 | 'lang_dbtype' => lang('DB Type'), |
||
| 380 | 'lang_whichdb' => lang('Which database type do you want to use with EGroupware?'), |
||
| 381 | 'lang_configuser' => lang('Configuration User'), |
||
| 382 | 'lang_configuser_descr'=> lang('Loginname needed for domain configuration'), |
||
| 383 | 'lang_configpass' => lang('Configuration Password'), |
||
| 384 | 'lang_passforconfig' => lang('Password needed for domain configuration.'), |
||
| 385 | 'lang_persist' => lang('Persistent connections'), |
||
| 386 | 'lang_persistdescr' => lang('Do you want persistent connections (higher performance, but consumes more resources)'), |
||
| 387 | 'lang_session' => lang('Sessions Handler'), |
||
| 388 | 'lang_session_descr' => lang('Session handler class used.'), |
||
| 389 | 'lang_enablemcrypt' => lang('Enable MCrypt'), |
||
| 390 | 'lang_mcrypt_warning' => lang('Not all mcrypt algorithms and modes work with EGroupware. If you experience problems try switching it off.'), |
||
| 391 | 'lang_mcryptiv' => lang('MCrypt initialization vector'), |
||
| 392 | 'lang_mcryptivdescr' => lang('This should be around 30 bytes in length.<br />Note: The default has been randomly generated.'), |
||
| 393 | 'lang_domselect' => lang('Domain select box on login'), |
||
| 394 | 'lang_domselect_descr' => lang('Alternatively domains can be accessed by logging in with <i>username@domain</i>.'), |
||
| 395 | 'lang_finaldescr' => lang('After retrieving the file, put it into place as the header.inc.php. Then, click "continue".'), |
||
| 396 | 'lang_continue' => lang('Continue'), |
||
| 397 | 'lang_Yes' => lang('Yes'), |
||
| 398 | 'lang_No' => lang('No') |
||
| 399 | )); |
||
| 400 | $setup_tpl->pfp('out','manageheader'); |
||
| 401 | |||
| 402 | $GLOBALS['egw_setup']->html->show_footer(); |
||
| 403 | } |
||
| 404 |