array(1), 'create_input_box' => array(1,3), 'create_check_box' => array(1,3), 'create_select_box' => array(1,4), 'create_text_area' => array(1,5), 'create_notify' => array(1,5), 'create_password_box' => array(1,3) ); var $files = array( 'config.tpl' => 'config', 'hook_admin.inc.php' => 'file_admin', 'hook_preferences.inc.php' => 'file_preferences', 'hook_sidebox_menu.inc.php' => 'file', 'hook_acl_manager.inc.php' => 'acl_manager' ); var $public_functions = array( 'index' => True ); function solangfile() { $this->db = $GLOBALS['phpgw']->db; } function fetch_keys($app,$arr) { if (!is_array($arr)) { return; } foreach($arr as $key => $val) { $this->plist[$key] = $app; } } function config_file($app,$fname) { //echo "
solangfile::config_file(app='$app',fname='$fname')
\n"; $lines = file($fname); if ($app != 'setup') { $app = 'admin'; } foreach($lines as $n => $line) { while (ereg('\{lang_([^}]+)\}(.*)',$line,$found)) { $lang = str_replace('_',' ',$found[1]); $this->plist[$lang] = $app; $line = $found[2]; } } } function special_file($app,$fname,$langs_in) { //echo "solangfile::special_file(app='$app',fname='$fname',langs_in='$langs_in')
\n"; switch ($langs_in) { case 'config': $this->config_file($app,$fname); return; case 'file_admin': case 'file_preferences': $app = substr($langs_in,5); break; case 'phpgwapi': $app = 'common'; break; } if (!function_exists('display_sidebox')) { function display_sidebox($appname,$menu_title,$file) // hook_sidebox_menu { unset($file['_NewLine_']); $GLOBALS['file'] += $file; } function display_section($appname,$file,$file2='') // hook_preferences, hook_admin { if (is_array($file2)) { $file = $file2; } $GLOBALS['file'] += $file; } } $GLOBALS['file'] = array(); unset($GLOBALS['acl_manager']); include($fname); if (isset($GLOBALS['acl_manager'])) // hook_acl_manager { foreach($GLOBALS['acl_manager'] as $app => $data) { foreach ($data as $item => $arr) { foreach ($arr as $key => $val) { switch ($key) { case 'name': $this->plist[$val] = $app; break; case 'rights': foreach($val as $lang => $right) { $this->plist[$lang] = $app; } break; } } } } } if (count($GLOBALS['file'])) // hook_{admin|preferences|sidebox_menu} { foreach ($GLOBALS['file'] as $lang => $link) { $this->plist[$lang] = $app; } } } function parse_php_app($app,$fd) { $reg_expr = '('.implode('|',array_keys($this->functions)).")[ \t]*\([ \t]*(.*)$"; define('SEP',filesystem_separator()); $d=dir($fd); while ($fn=$d->read()) { if (@is_dir($fd.$fn.SEP)) { if (($fn!='.')&&($fn!='..')&&($fn!='CVS')) { $this->parse_php_app($app,$fd.$fn.SEP); } } elseif (is_readable($fd.$fn)) { if (isset($this->files[$fn])) { $this->special_file($app,$fd.$fn,$this->files[$fn]); } if (strpos($fn,'.php') === False) { continue; } $lines = file($fd.$fn); foreach($lines as $n => $line) { //echo "line='$line', lines[1+$n]='".$lines[1+$n]."'solangfile::load_app('$app','$userlang') converting from charset('$userlang')='$from' to '$to'
\n"; if (file_exists($fn)) { if ($fp = @fopen($fn,'rb')) { while ($data = fgets($fp,8000)) { list($message_id,$app_name,$null,$content) = explode("\t",$data); if(!$message_id) { continue; } //echo 'solangfile::write_file('$app_name',,'$userlang') converting from '$from' to charset('$userlang')='$to'
\n"; $fn = PHPGW_SERVER_ROOT . SEP . $app_name . SEP . ($app_name == 'setup' ? 'lang' : 'setup') . SEP . 'phpgw_' . $userlang . '.lang'; if (file_exists($fn)) { $backup = $fn . '.old'; @unlink($backup); @rename($fn,$backup); } $fp = fopen($fn,'wb'); while(list($mess_id,$data) = @each($langarray)) { $data['content'] = $GLOBALS['phpgw']->translation->convert(trim($data['content']),$from,$to); fwrite($fp,$mess_id . "\t" . $data['app_name'] . "\t" . $userlang . "\t" . $data['content'] . "\n"); } fclose($fp); if ($which == 'source') { $this->src_file = $fn; } else { $this->tgt_file = $fn; } return $fn; } function loaddb($app_name,$userlangs) { if (!is_array($userlangs)) { $userlangs = array($userslangs => $userlangs); } $GLOBALS['phpgw']->translation->install_langs($userlangs,'addmissing',$app_name); return lang('done'); } } ?>