Commit b7afdec4 authored by tbrehm's avatar tbrehm

Added language file editor.

parent a6efc78e
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checking permissions for the module
if(!stristr($_SESSION['s']['user']['modules'],'admin')) {
header('Location: ../index.php');
exit;
}
//* This is only allowed for administrators
if(!$app->auth->is_admin()) die('only allowed for administrators.');
$app->uses('tpl');
$app->tpl->newTemplate('form.tpl.htm');
$app->tpl->setInclude('content_tpl', 'templates/language_add.htm');
//* reading languages
$language_option = '';
$error = '';
$msg = '';
$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'],0,2):'en';
$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/');
while ($file = readdir ($handle)) {
if ($file != '.' && $file != '..') {
$tmp_lng = substr($file,0,-4);
if($tmp_lng !='') {
$selected = ($tmp_lng == $selected_language)?'SELECTED':'';
$language_option .= "<option value='$tmp_lng' $selected>$tmp_lng</option>";
if(isset($_POST['lng_new']) && $_POST['lng_new'] == $tmp_lng) $error = 'Language exists already.';
}
}
}
$app->tpl->setVar('language_option',$language_option);
$app->tpl->setVar('error',$error);
if(isset($_POST['lng_new']) && strlen($_POST['lng_new']) == 2 && $error == '') {
$lng_new = $_POST['lng_new'];
if(!preg_match("/^[a-z]{2}$/i", $lng_new)) die('unallowed characters in language name.');
//* Make a copy of every language file
$bgcolor = '#FFFFFF';
$language_files_list = array();
$handle = @opendir(ISPC_WEB_PATH);
while ($file = @readdir ($handle)) {
if ($file != '.' && $file != '..') {
if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) {
$handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang');
while ($lang_file = @readdir ($handle2)) {
if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == $selected_language) {
$new_lang_file = $lng_new.substr($lang_file,2);
//echo ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file.' ## '.ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file;
copy(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file,ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file);
$msg = 'Added new language '.$lng_new;
}
}
}
}
}
}
$app->tpl->setVar('msg',$msg);
//* load language file
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_add.lng';
include($lng_file);
$app->tpl->setVar($wb);
$app->tpl_defaults();
$app->tpl->pparse();
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checking permissions for the module
if(!stristr($_SESSION['s']['user']['modules'],'admin')) {
header('Location: ../index.php');
exit;
}
//* This is only allowed for administrators
if(!$app->auth->is_admin()) die('only allowed for administrators.');
$app->uses('tpl');
$app->tpl->newTemplate('form.tpl.htm');
$app->tpl->setInclude('content_tpl', 'templates/language_edit.htm');
$lang = $_REQUEST['lang'];
$module = $_REQUEST['module'];
$lang_file = $_REQUEST['lang_file'];
if(!preg_match("/^[a-z]+$/i", $lang)) die('unallowed characters in language name.');
if(!preg_match("/^[a-z_]+$/i", $module)) die('unallowed characters in module name.');
if(!preg_match("/^[a-z\._]+$/i", $lang_file)) die('unallowed characters in language file name.');
$msg = '';
//* Save data
if(isset($_POST['records']) && is_array($_POST['records'])) {
$file_content = "<?php\n";
foreach($_POST['records'] as $key => $val) {
$val = stripslashes($val);
$val = str_replace("'",'',$val);
$val = str_replace('"','',$val);
$file_content .= '$wb['."'$key'".'] = '."'$val';\n";
$msg = 'File saved.';
}
$file_content .= "?>\n";
file_put_contents(ISPC_WEB_PATH."/$module/lib/lang/$lang_file" ,$file_content);
}
$app->tpl->setVar(array('module' => $module,'lang_file' => $lang_file, 'lang' => $lang, 'msg' => $msg));
include(ISPC_WEB_PATH."/$module/lib/lang/$lang_file");
$keyword_list = array();
if(isset($wb) && is_array($wb)) {
foreach($wb as $key => $val) {
$keyword_list[] = array('key' => $key, 'val' => $val);
}
$app->tpl->setLoop('records', $keyword_list);
unset($wb);
}
//* load language file
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_edit.lng';
include($lng_file);
$app->tpl->setVar($wb);
$app->tpl_defaults();
$app->tpl->pparse();
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checking permissions for the module
if(!stristr($_SESSION['s']['user']['modules'],'admin')) {
header('Location: ../index.php');
exit;
}
//* This is only allowed for administrators
if(!$app->auth->is_admin()) die('only allowed for administrators.');
$app->uses('tpl');
$app->tpl->newTemplate('form.tpl.htm');
$app->tpl->setInclude('content_tpl', 'templates/language_list.htm');
//* reading languages
$language_option = '';
$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'],0,2):'en';
$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/');
while ($file = readdir ($handle)) {
if ($file != '.' && $file != '..') {
$tmp_lng = substr($file,0,-4);
if($tmp_lng !='') {
$selected = ($tmp_lng == $selected_language)?'SELECTED':'';
$language_option .= "<option value='$tmp_lng' $selected>$tmp_lng</option>";
}
}
}
$app->tpl->setVar('language_option',$language_option);
// $app->tpl->setLoop('records', $language_list);
//* list all language files of the selected language
$bgcolor = '#FFFFFF';
$language_files_list = array();
$handle = @opendir(ISPC_WEB_PATH);
while ($file = @readdir ($handle)) {
if ($file != '.' && $file != '..') {
if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) {
$handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang');
while ($lang_file = @readdir ($handle2)) {
if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == $selected_language) {
$bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
$language_files_list[] = array( 'module' => $file,
'lang_file' => $lang_file,
'bgcolor' => $bgcolor,
'lang' => $selected_language);
}
}
}
}
}
$app->tpl->setLoop('records', $language_files_list);
//* load language file
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_list.lng';
include($lng_file);
$app->tpl->setVar($wb);
$app->tpl_defaults();
$app->tpl->pparse();
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Add new language';
$wb["language_select_txt"] = 'Select language basis';
$wb["language_new_txt"] = 'New language';
$wb['btn_save_txt'] = 'Create new language file set';
$wb['btn_cancel_txt'] = 'Back';
?>
\ No newline at end of file
<?php
$wb['list_head_txt'] = 'Language file editor';
$wb['language_select_txt'] = 'Select language';
$wb['module_txt'] = 'Module';
$wb['lang_file_txt'] = 'Language file';
$wb['btn_save_txt'] = 'Save';
$wb['btn_cancel_txt'] = 'Back';
?>
<?php
$wb["list_head_txt"] = 'Language file editor';
$wb["language_select_txt"] = 'Select language';
$wb["module_txt"] = 'Module';
$wb["lang_file_txt"] = 'Language file';
?>
\ No newline at end of file
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<p class="frmText11">
<tmpl_var name="language_select_txt">: <select name="lng_select">{tmpl_var name='language_option'}</select>
<tmpl_var name="language_new_txt">: <input type="text" name="lng_new" value="" class="text" size="2" maxlength="2" />
</p>
<tmpl_if name="msg">
<p class="msg" ><tmpl_var name="msg"></p>
</tmpl_if>
<tmpl_if name="error">
<p class="error" ><tmpl_var name="error"></p>
</tmpl_if>
<input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_add.php');"><div class="buttonEnding"></div>
<input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php');"><div class="buttonEnding"></div>
\ No newline at end of file
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="tblHead"><tmpl_var name="key_txt"></td>
<td class="tblHead"><tmpl_var name="value_txt"></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tmpl_loop name="records">
<tr bgcolor="{tmpl_var name="bgcolor"}">
<td class="frmText11">{tmpl_var name="key"}</td>
<td class="frmText11"><input name="records[{tmpl_var name="key"}]" type="text" class="text" value="{tmpl_var name='val'}" size="50" maxlength="255"></td>
</tr>
</tmpl_loop>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tmpl_if name="msg">
<tr>
<td class="msg" colspan="2"><tmpl_var name="msg"></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</tmpl_if>
<tr>
<td>&nbsp;</td>
<td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_edit.php');"><div class="buttonEnding"></div>
<input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php?lng_select={tmpl_var name='lang'}');"><div class="buttonEnding"></div>
</td>
</tr>
</table>
<input type="hidden" name="lang" value="{tmpl_var name='lang'}">
<input type="hidden" name="lang_file" value="{tmpl_var name='lang_file'}">
<input type="hidden" name="module" value="{tmpl_var name='module'}">
\ No newline at end of file
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<p class="frmText11"><tmpl_var name="language_select_txt">: <select name="lng_select" onChange="submitForm('pageForm','admin/language_list.php');">{tmpl_var name='language_option'}</select></p>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="tblHead"><tmpl_var name="module_txt"></td>
<td class="tblHead"><tmpl_var name="lang_file_txt"></td>
</tr>
<tmpl_loop name="records">
<tr bgcolor="{tmpl_var name="bgcolor"}">
<td class="frmText11"><a href="#" onClick="loadContent('admin/language_edit.php?module={tmpl_var name="module"}&lang_file={tmpl_var name="lang_file"}&lang={tmpl_var name="lang"}');" class="frmText11">{tmpl_var name="module"}</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('admin/language_edit.php?module={tmpl_var name="module"}&lang_file={tmpl_var name="lang_file"}&lang={tmpl_var name="lang"}');" class="frmText11">{tmpl_var name="lang_file"}</a></td>
</tr>
</tmpl_loop>
<tr>
<td colspan="2" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
</tr>
</table>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment