using functions moved to setup_translation class and modernising setup_html

This commit is contained in:
Ralf Becker 2010-07-29 08:29:54 +00:00
parent b71035b529
commit d02badfed5
3 changed files with 302 additions and 333 deletions

View File

@ -1,26 +1,26 @@
<?php
/**************************************************************************\
* eGroupWare - Setup *
* http://www.egroupware.org *
* -------------------------------------------- *
* This file written by Tony Puglisi (Angles) <angles@aminvestments.com> *
* and Miles Lott<milosch@groupwhere.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/**
* eGroupWare Setup
*
* @link http://www.egroupware.org
* @package setup
* @author Tony Puglisi (Angles) <angles@aminvestments.com>
* @author Miles Lott <milos@groupwhere.org>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* Some static helper functions to generate html stuff in setup
*/
class setup_html
{
/**
* generate header.inc.php file output - NOT a generic html header function
*
*/
function generate_header()
static function generate_header()
{
// PHP will automatically replace any dots in incoming
// variable names with underscores.
@ -94,7 +94,7 @@
return $GLOBALS['header_template']->parse('out','header');
}
function setup_tpl_dir($app_name='setup')
static function setup_tpl_dir($app_name='setup')
{
/* hack to get tpl dir */
if (is_dir(EGW_SERVER_ROOT))
@ -111,7 +111,7 @@
return $tpl_root;
}
function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='')
static function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='')
{
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
header('Content-type: text/html; charset='.$GLOBALS['egw_setup']->system_charset);
@ -180,20 +180,20 @@
/* $setup_tpl->set_var('T_head',''); */
}
function show_footer()
static function show_footer()
{
$GLOBALS['setup_tpl']->pparse('out','T_footer');
unset($GLOBALS['setup_tpl']);
}
function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
static function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
{
$GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word);
$GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg);
$GLOBALS['setup_tpl']->pparse('out','T_alert_msg');
}
function make_frm_btn_simple($pre_frm_blurb='',$frm_method='post',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
static function make_frm_btn_simple($pre_frm_blurb='',$frm_method='post',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
{
/* a simple form has simple components */
$simple_form = $pre_frm_blurb ."\n"
@ -204,7 +204,7 @@
return $simple_form;
}
function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
static function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
{
/* a simple href link has simple components */
$simple_link = $pre_link_blurb
@ -213,7 +213,7 @@
return $simple_link;
}
function login_form()
static function login_form()
{
/* begin use TEMPLATE login_main.tpl */
$GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['egw_info']['setup']['ConfigLoginMSG']);
@ -226,7 +226,7 @@
$GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password'));
$GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain'));
$GLOBALS['setup_tpl']->set_var('lang_select',lang_select());
$GLOBALS['setup_tpl']->set_var('lang_select',self::lang_select());
if ($GLOBALS['egw_info']['setup']['stage']['header'] == '10')
{
@ -278,7 +278,36 @@
$GLOBALS['setup_tpl']->pparse('out','T_login_main');
}
function get_template_list()
static function lang_select($onChange=False,$ConfigLang='')
{
if (!$ConfigLang)
{
$ConfigLang = setup::get_lang();
}
$select = '<select name="ConfigLang"'.($onChange ? ' onchange="this.form.submit();"' : '').'>' . "\n";
$languages = setup_translation::get_supported_langs();
foreach($languages as $data)
{
if($data['available'] && !empty($data['lang']))
{
$short = substr($data['lang'],0,2);
if ($short == $ConfigLang || $data['lang'] == $ConfigLang || empty($ConfigLang) && $short == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2))
{
$selected = ' selected';
}
else
{
$selected = '';
}
$select .= '<option value="' . $data['lang'] . '"' . $selected . '>' . $data['descr'] . '</option>' . "\n";
}
}
$select .= '</select>' . "\n";
return $select;
}
static function get_template_list()
{
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
@ -304,7 +333,7 @@
return $list;
}
function list_themes()
static function list_themes()
{
$dh = dir(EGW_SERVER_ROOT . '/phpgwapi/themes');
while ($file = $dh->read())
@ -319,4 +348,3 @@
return $list;
}
}
?>

View File

@ -75,65 +75,6 @@ function lang($key,$vars=null)
return $GLOBALS['egw_setup']->translation->translate("$key", $vars);
}
/**
* returns array of languages we support, with enabled set to True if the lang file exists
*/
function get_langs()
{
$f = fopen('./lang/languages','rb');
while($line = fgets($f,200))
{
list($x,$y) = explode("\t",$line);
$languages[$x]['lang'] = trim($x);
$languages[$x]['descr'] = trim($y);
$languages[$x]['available'] = False;
}
fclose($f);
$d = dir('./lang');
while($file=$d->read())
{
if(preg_match('/^(php|e)gw_([-a-z]+).lang$/i',$file,$matches))
{
$languages[$matches[2]]['available'] = True;
}
}
$d->close();
//print_r($languages);
return $languages;
}
function lang_select($onChange=False,$ConfigLang='')
{
if (!$ConfigLang)
{
$ConfigLang = setup::get_lang();
}
$select = '<select name="ConfigLang"'.($onChange ? ' onchange="this.form.submit();"' : '').'>' . "\n";
$languages = get_langs();
usort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);'));
foreach($languages as $data)
{
if($data['available'] && !empty($data['lang']))
{
$short = substr($data['lang'],0,2);
if ($short == $ConfigLang || $data['lang'] == $ConfigLang || empty($ConfigLang) && $short == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2))
{
$selected = ' selected';
}
else
{
$selected = '';
}
$select .= '<option value="' . $data['lang'] . '"' . $selected . '>' . $data['descr'] . '</option>' . "\n";
}
}
$select .= '</select>' . "\n";
return $select;
}
if(file_exists(EGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'))
{
include(EGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'); /* To set the current core version */

View File

@ -480,7 +480,7 @@ switch($GLOBALS['egw_info']['setup']['stage']['lang'])
break;
case 10:
$langs_list = array();
$languages = get_langs();
$languages = setup_translation::get_supported_langs();
foreach ($GLOBALS['egw_info']['setup']['installed_langs'] as $key => $value)
{
$langs_list[] = isset($languages[$key]) ? $languages[$key]['descr'] : $value;