2009-03-20 11:42:45 +01:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
|
|
|
* http://ldapsaisie.labs.libre-entreprise.org
|
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2011-04-08 14:28:55 +02:00
|
|
|
error_reporting(E_ERROR);
|
|
|
|
|
2009-04-20 12:02:01 +02:00
|
|
|
require_once('../core.php');
|
2009-03-20 11:42:45 +01:00
|
|
|
require_once('../conf/config.inc.php');
|
2009-04-20 12:02:01 +02:00
|
|
|
|
2013-07-09 19:12:55 +02:00
|
|
|
$withoutselectlist=False;
|
|
|
|
$copyoriginalvalue=False;
|
2013-07-10 19:30:57 +02:00
|
|
|
$additionalfileformat=False;
|
2013-11-27 18:17:24 +01:00
|
|
|
$translations=array();
|
2010-11-18 16:23:32 +01:00
|
|
|
if ($argc > 1) {
|
|
|
|
for ($i=1;$i<$argc;$i++) {
|
|
|
|
if (is_file($argv[$i])) {
|
|
|
|
@include($argv[$i]);
|
2013-11-27 18:17:24 +01:00
|
|
|
foreach($GLOBALS['LSlang'] as $msg => $trans) {
|
|
|
|
$translations[$msg]=$trans;
|
|
|
|
}
|
2010-11-18 16:23:32 +01:00
|
|
|
}
|
2013-07-09 19:12:55 +02:00
|
|
|
elseif($argv[$i]=='--without-select-list') {
|
|
|
|
$withoutselectlist=True;
|
|
|
|
}
|
|
|
|
elseif($argv[$i]=='--copy-original-value') {
|
|
|
|
$copyoriginalvalue=True;
|
|
|
|
}
|
2013-07-10 19:30:57 +02:00
|
|
|
elseif($argv[$i]=='--additional-file-format') {
|
|
|
|
$additionalfileformat=True;
|
|
|
|
}
|
2013-07-09 19:12:55 +02:00
|
|
|
elseif($argv[$i]=='-h') {
|
|
|
|
echo "Usage : ".$argv[0]." [file1] [file2] [-h] [options]\n";
|
|
|
|
echo " --without-select-list Don't add possibles values of select list\n";
|
|
|
|
echo " --copy-original-value Copy original value as translated value when no translated value exists\n";
|
2013-07-10 19:30:57 +02:00
|
|
|
echo " --additional-file-format Additional file format output\n";
|
2013-07-09 19:12:55 +02:00
|
|
|
exit(0);
|
|
|
|
}
|
2010-11-18 16:23:32 +01:00
|
|
|
}
|
2009-04-20 12:02:01 +02:00
|
|
|
}
|
2009-03-20 11:42:45 +01:00
|
|
|
|
|
|
|
$data=array();
|
|
|
|
|
|
|
|
function add($msg) {
|
2015-08-21 12:10:23 +02:00
|
|
|
if ($msg!='' && _($msg) == "$msg") {
|
2013-11-27 18:17:24 +01:00
|
|
|
global $data, $translations;
|
|
|
|
$data[$msg]=$translations[$msg];
|
2009-03-20 11:42:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-10 10:15:33 +02:00
|
|
|
// Change directory
|
|
|
|
chdir('../');
|
|
|
|
|
|
|
|
// Initialize session
|
|
|
|
LSsession :: initialize();
|
|
|
|
|
2009-03-20 11:42:45 +01:00
|
|
|
// LDAP Servers
|
|
|
|
foreach($GLOBALS['LSconfig']['ldap_servers'] as $conf) {
|
|
|
|
add($conf['name']);
|
|
|
|
add($conf['subDnLabel']);
|
|
|
|
add($conf['recoverPassword']['recoveryHashMail']['subject']);
|
|
|
|
add($conf['recoverPassword']['recoveryHashMail']['msg']);
|
|
|
|
add($conf['recoverPassword']['newPasswordMail']['subject']);
|
|
|
|
add($conf['recoverPassword']['newPasswordMail']['msg']);
|
|
|
|
if (is_array($conf['subDn'])) {
|
|
|
|
foreach($conf['subDn'] as $name => $cf) {
|
|
|
|
if ($name!='LSobject') {
|
|
|
|
add($name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LSobject
|
2015-08-10 10:15:33 +02:00
|
|
|
if (loadDir(LS_OBJECTS_DIR) && loadDir(LS_LOCAL_DIR.LS_OBJECTS_DIR)) {
|
2009-03-20 11:42:45 +01:00
|
|
|
foreach($GLOBALS['LSobjects'] as $name => $conf) {
|
|
|
|
add($conf['label']);
|
|
|
|
|
|
|
|
// LSrelation
|
|
|
|
if (is_array($conf['LSrelation'])) {
|
|
|
|
foreach($conf['LSrelation'] as $rel) {
|
|
|
|
add($rel['label']);
|
|
|
|
add($rel['emptyText']);
|
|
|
|
}
|
|
|
|
}
|
2011-03-25 18:05:26 +01:00
|
|
|
// Custom Actions
|
|
|
|
if (is_array($conf['customActions'])) {
|
|
|
|
foreach($conf['customActions'] as $act) {
|
|
|
|
add($act['label']);
|
|
|
|
add($act['question_format']);
|
|
|
|
add($act['onSuccessMsgFormat']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-20 11:42:45 +01:00
|
|
|
// LSform
|
|
|
|
if (is_array($conf['LSform']['layout'])) {
|
|
|
|
foreach($conf['LSform']['layout'] as $lay) {
|
|
|
|
add($lay['label']);
|
|
|
|
}
|
|
|
|
}
|
2010-11-17 19:11:49 +01:00
|
|
|
if (is_array($conf['LSform']['dataEntryForm'])) {
|
|
|
|
foreach($conf['LSform']['dataEntryForm'] as $def) {
|
|
|
|
add($def['label']);
|
|
|
|
}
|
|
|
|
}
|
2010-02-19 14:38:08 +01:00
|
|
|
// LSsearch
|
|
|
|
if (is_array($conf['LSsearch']['predefinedFilters'])) {
|
|
|
|
foreach($conf['LSsearch']['predefinedFilters'] as $lay) {
|
|
|
|
add($lay);
|
|
|
|
}
|
|
|
|
}
|
2014-06-17 16:08:41 +02:00
|
|
|
if (is_array($conf['LSsearch']['extraDisplayedColumns'])) {
|
|
|
|
foreach($conf['LSsearch']['extraDisplayedColumns'] as $cid => $cconf) {
|
|
|
|
add($cconf['label']);
|
|
|
|
}
|
|
|
|
}
|
2014-10-08 17:24:30 +02:00
|
|
|
if (is_array($conf['LSsearch']['customActions'])) {
|
|
|
|
foreach($conf['LSsearch']['customActions'] as $act) {
|
|
|
|
add($act['label']);
|
|
|
|
add($act['question_format']);
|
|
|
|
add($act['onSuccessMsgFormat']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-19 14:38:08 +01:00
|
|
|
|
2009-03-20 11:42:45 +01:00
|
|
|
|
|
|
|
if(is_array($conf['attrs'])) {
|
|
|
|
foreach($conf['attrs'] as $attr) {
|
|
|
|
add($attr['label']);
|
|
|
|
add($attr['help_info']);
|
2014-11-28 12:31:25 +01:00
|
|
|
add($attr['no_value_label']);
|
2009-03-20 11:42:45 +01:00
|
|
|
add($attr['html_options']['mail']['subject']);
|
|
|
|
add($attr['html_options']['mail']['msg']);
|
|
|
|
|
2009-12-31 14:43:59 +01:00
|
|
|
// LSattr_html_select_list
|
2015-07-25 18:23:06 +02:00
|
|
|
if (($attr['html_type']=='select_list' || $attr['html_type']=='select_box') && is_array($attr['html_options']['possible_values']) && !$withoutselectlist) {
|
2009-12-31 14:43:59 +01:00
|
|
|
foreach($attr['html_options']['possible_values'] as $pkey => $pname) {
|
2015-07-25 18:23:06 +02:00
|
|
|
if (is_array($pname)) {
|
|
|
|
add($pname['label']);
|
|
|
|
if (is_array($pname['possible_values'])) {
|
|
|
|
foreach($pname['possible_values'] as $pk => $pn) {
|
|
|
|
if ($pk == 'OTHER_OBJECT') continue;
|
|
|
|
add($pn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($pkey != 'OTHER_OBJECT') {
|
2009-12-31 14:43:59 +01:00
|
|
|
add($pname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-24 15:47:40 +01:00
|
|
|
|
|
|
|
// LSattr_html_valueWithUnit
|
|
|
|
if ($attr['html_type']=='valueWithUnit' && is_array($attr['html_options']['units'])) {
|
|
|
|
foreach($attr['html_options']['units'] as $pname) {
|
|
|
|
add($pname);
|
|
|
|
}
|
|
|
|
}
|
2009-12-31 14:43:59 +01:00
|
|
|
|
2009-03-20 11:42:45 +01:00
|
|
|
// Check data
|
|
|
|
if (is_array($attr['check_data'])) {
|
|
|
|
foreach($attr['check_data'] as $check) {
|
|
|
|
add($check['msg']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// validation
|
|
|
|
if (is_array($attr['validation'])) {
|
|
|
|
foreach($attr['validation'] as $valid) {
|
|
|
|
add($valid['msg']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-30 16:40:26 +02:00
|
|
|
/*
|
|
|
|
* Manage template file
|
|
|
|
*/
|
|
|
|
|
|
|
|
function parse_template_file($file) {
|
|
|
|
foreach(file($file) as $line) {
|
|
|
|
if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) {
|
|
|
|
foreach($matches[1] as $t)
|
|
|
|
add($t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function find_and_parse_template_file($dir) {
|
|
|
|
if (is_dir($dir)) {
|
|
|
|
if ($dh = opendir($dir)) {
|
|
|
|
while (($file = readdir($dh)) !== false) {
|
|
|
|
if ($file=='.' || $file=='..') continue;
|
|
|
|
if (is_dir($dir.'/'.$file)) {
|
|
|
|
find_and_parse_template_file($dir.'/'.$file);
|
|
|
|
}
|
|
|
|
elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) {
|
|
|
|
parse_template_file($dir.'/'.$file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-10 10:15:33 +02:00
|
|
|
find_and_parse_template_file(LS_TEMPLATES_DIR);
|
|
|
|
find_and_parse_template_file(LS_LOCAL_DIR.LS_TEMPLATES_DIR);
|
2015-07-30 16:40:26 +02:00
|
|
|
|
2015-08-21 12:10:44 +02:00
|
|
|
/*
|
|
|
|
* Manage addons files
|
|
|
|
*/
|
|
|
|
|
|
|
|
function parse_addon_file($file) {
|
|
|
|
foreach(file($file) as $line) {
|
|
|
|
$offset=0;
|
|
|
|
while ($pos = strpos($line,'_(',$offset)) {
|
|
|
|
$quote='';
|
|
|
|
$res='';
|
|
|
|
for ($i=$pos+2;$i<strlen($line);$i++) {
|
|
|
|
if ($line[$i]=='\\') {
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
elseif (empty($quote) && ($line[$i]==' ' || $line[$i]=="\t")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
elseif (empty($quote) && ($line[$i]=='"' || $line[$i]=="'")) {
|
|
|
|
$quote=$line[$i];
|
|
|
|
}
|
|
|
|
elseif (!empty($quote) && $line[$i]==$quote) {
|
|
|
|
$offset=$i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$res.=$line[$i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($res)) add($res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function find_and_parse_addon_file($dir) {
|
|
|
|
if (is_dir($dir)) {
|
|
|
|
if ($dh = opendir($dir)) {
|
|
|
|
while (($file = readdir($dh)) !== false) {
|
|
|
|
if (preg_match('/^LSaddons\.(.+)\.php$/',$file)) {
|
|
|
|
parse_addon_file($dir.'/'.$file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
find_and_parse_addon_file(LS_ADDONS_DIR);
|
|
|
|
find_and_parse_addon_file(LS_LOCAL_DIR.LS_ADDONS_DIR);
|
|
|
|
|
2015-07-30 16:40:26 +02:00
|
|
|
|
2009-03-20 11:42:45 +01:00
|
|
|
ksort($data);
|
|
|
|
|
2013-07-10 19:30:57 +02:00
|
|
|
echo "<?php\n\n";
|
|
|
|
|
|
|
|
if (!$additionalfileformat) print "\$GLOBALS['LSlang'] = array (\n";
|
2009-03-20 11:42:45 +01:00
|
|
|
|
|
|
|
foreach($data as $key => $val) {
|
2013-07-09 19:12:55 +02:00
|
|
|
if ($copyoriginalvalue && $val=="") {
|
|
|
|
$val=$key;
|
|
|
|
}
|
2013-07-10 19:30:57 +02:00
|
|
|
if ($additionalfileformat) {
|
|
|
|
print "\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "\n\"$key\" =>\n \"$val\",\n";
|
|
|
|
}
|
2009-03-20 11:42:45 +01:00
|
|
|
}
|
|
|
|
|
2013-07-10 19:30:57 +02:00
|
|
|
if (!$additionalfileformat) echo "\n);\n";
|
2009-03-20 11:42:45 +01:00
|
|
|
|
|
|
|
?>
|