parent
79a56c20ba
commit
74f33560d8
@ -1,27 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
|
||||
// including the global dokeos file |
||||
require_once '../inc/global.inc.php'; |
||||
require_once 'sub_language.class.php'; |
||||
/* |
||||
* search a term and return description from a glossary |
||||
*/ |
||||
global $charset; |
||||
$new_language = Security::remove_XSS($_POST['new_language']); |
||||
$language_variable = Security::remove_XSS($_POST['variable_language']); |
||||
$file_language = Security::remove_XSS($_POST['file_language']); |
||||
$id_language = Security::remove_XSS($_POST['id']); |
||||
$sub_language_id = Security::remove_XSS($_POST['sublanguage_id']); |
||||
|
||||
$all_data_of_language=SubLanguageManager::get_all_information_of_sub_language($id_language,$sub_language_id); |
||||
$dokeos_path_folder=api_get_path('SYS_LANG_PATH').$all_data_of_language['dokeos_folder'].'/'.$file_language; |
||||
$all_file_of_directory=SubLanguageManager::get_all_language_variable_in_file($dokeos_path_folder); |
||||
SubLanguageManager::add_file_in_language_directory ($dokeos_path_folder); |
||||
|
||||
//update variable language |
||||
$all_file_of_directory[$language_variable]="\"".mb_convert_encoding($new_language,$charset,'UTF-8')."\";"; |
||||
|
||||
foreach ($all_file_of_directory as $key_value=>$value_info) { |
||||
SubLanguageManager::write_data_in_file ($dokeos_path_folder,$value_info,$key_value); |
||||
} |
@ -1,297 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
/** |
||||
================================================================================== |
||||
@author Isaac flores paz <florespaz_isaac@hotmail.com> - Added 9 july of 2009 |
||||
================================================================================== |
||||
*/ |
||||
/* |
||||
============================================================================== |
||||
INIT SECTION |
||||
============================================================================== |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = 'admin'; |
||||
$cidReset = true; |
||||
require_once '../inc/global.inc.php'; |
||||
require_once 'sub_language.class.php'; |
||||
$this_section=SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_script(); |
||||
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery |
||||
$htmlHeadXtra[] ='<script type="text/javascript"> |
||||
$(document).ready(function() { |
||||
|
||||
$("#sl_original_file").change(function () { |
||||
|
||||
current_action=$("#Loadlanguage").attr("action"); |
||||
current_action=current_action.split("original_file"); |
||||
current_action=current_action[0]; |
||||
current_action=current_action+"original_file="+$(this).attr("value") |
||||
$("#Loadlanguage").attr("action",current_action); |
||||
// |
||||
current_action=$("#Searchlanguage").attr("action"); |
||||
current_action=current_action.split("original_file"); |
||||
current_action=current_action[0]; |
||||
current_action=current_action+"original_file="+$(this).attr("value") |
||||
$("#Searchlanguage").attr("action",current_action); |
||||
}); |
||||
|
||||
$(window).load(function () { |
||||
/*current_action=$("#Loadlanguage").attr("action"); |
||||
current_action=current_action+"&original_file="+$("#sl_original_file").attr("value") |
||||
$("#Loadlanguage").attr("action",current_action);*/ |
||||
}); |
||||
|
||||
$("#sl_original_file option[@value='.Security::remove_XSS($_REQUEST['original_file']).']").attr("selected","selected"); |
||||
|
||||
$(".save").click(function() { |
||||
button_name=$(this).attr("name"); |
||||
button_name=button_name.split("_"); |
||||
button_name=button_name[1]; |
||||
is_id=$("#id_hidden_original_file").attr("value"); |
||||
is_sublanguage_id=$("#id_hidden_sublanguage").attr("value"); |
||||
is_variable_language="$"+button_name; |
||||
is_new_language=$("#txtid_"+button_name).attr("value"); |
||||
if (is_new_language=="undefined") { |
||||
is_new_language="_"; |
||||
} |
||||
is_file_language="'.Security::remove_XSS($_REQUEST['original_file']).'"; |
||||
if (is_new_language.length>0 && is_new_language!="_") { |
||||
$.ajax({ |
||||
contentType: "application/x-www-form-urlencoded", |
||||
beforeSend: function(objeto) { |
||||
$("#div_message_information_id").html("<div class=\"normal-message\"><img src=\'../inc/lib/javascript/indicator.gif\' /></div>"); |
||||
|
||||
}, |
||||
type: "POST", |
||||
url: "../admin/add_by_ajax_sub_language.inc.php", |
||||
data: "new_language="+is_new_language+"&variable_language="+is_variable_language+"&file_language="+is_file_language+"&id="+is_id+"&sublanguage_id="+is_sublanguage_id, |
||||
success: function(datos) { |
||||
$("#div_message_information_id").html("<div class=\"confirmation-message\">'.get_lang('TheNewWordHasBeenAdded').'</div>"); |
||||
|
||||
} }); |
||||
} else { |
||||
$("#div_message_information_id").html("<div class=\"error-message\">'.get_lang('FormHasErrorsPleaseComplete').'</div>"); |
||||
} |
||||
|
||||
|
||||
}); |
||||
|
||||
}); |
||||
</script>'; |
||||
/* |
||||
============================================================================== |
||||
MAIN CODE |
||||
============================================================================== |
||||
*/ |
||||
// setting the name of the tool |
||||
$tool_name = get_lang('CreateSubLanguage'); |
||||
|
||||
// setting breadcrumbs |
||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('PlatformLanguages')); |
||||
|
||||
require_once api_get_path(LIBRARY_PATH).'text.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; |
||||
|
||||
if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
||||
$language_name=SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
||||
$all_data_of_language=SubLanguageManager::get_all_information_of_language($_GET['id']); |
||||
$my_language=$language_name; |
||||
if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
||||
$parent_id=intval($_GET['id']); |
||||
$language_id_exist=true; |
||||
} else { |
||||
$language_id_exist=false; |
||||
} |
||||
} else { |
||||
$language_name=''; |
||||
$language_id_exist=false; |
||||
} |
||||
|
||||
$language_name=get_lang('RegisterTermsOfSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
||||
|
||||
// including the header file (which includes the banner itself) |
||||
|
||||
|
||||
$dokeos_path_folder=api_get_path('SYS_LANG_PATH').$all_data_of_language['dokeos_folder']; |
||||
//get file name example : forum.inc.php,gradebook.inc.php |
||||
|
||||
if (!is_dir($dokeos_path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
Display :: display_header($language_name); |
||||
|
||||
$all_file_of_directory=SubLanguageManager::get_all_data_of_dokeos_folder ($dokeos_path_folder); |
||||
$load_array_in_select=array(); |
||||
sort($all_file_of_directory); |
||||
foreach ($all_file_of_directory as $value_all_file_of_directory) { |
||||
$load_array_in_select[$value_all_file_of_directory]=$value_all_file_of_directory; |
||||
} |
||||
|
||||
$request_file=''; |
||||
|
||||
if (isset($_POST['original_file']) && $_POST['original_file']!='') { |
||||
$request_file=Security::remove_XSS($_POST['original_file']); |
||||
} |
||||
if (isset($_GET['original_file']) && $_GET['original_file']!='') { |
||||
$request_file=Security::remove_XSS($_GET['original_file']); |
||||
} |
||||
|
||||
/*$form = new FormValidator('Loadlanguage', 'post', 'register_sub_language.php?id='.Security::remove_XSS($_GET['id']).'&original_file='.$request_file); |
||||
$class='plus'; |
||||
$form->addElement('hidden','id_hidden_original_file',Security::remove_XSS($_REQUEST['id']),array('id'=>'id_hidden_original_file')); |
||||
$select_level = array (); |
||||
$radios_results_enabled[] = FormValidator :: createElement ('select', 'original_file', get_lang('File'),$load_array_in_select,array('id'=>'sl_original_file')); |
||||
$radios_results_enabled[] = FormValidator :: createElement ('style_submit_button', 'SubmitLoadLanguage', get_lang('LoadLanguageFile'), 'class="'.$class.'"'); |
||||
$radios_results_enabled[] = FormValidator :: createElement ('text', 'txt_search_word'); |
||||
$radios_results_enabled[] = FormValidator :: createElement ('style_submit_button', 'SubmitSearchLanguage', get_lang('Search'), 'class="search"'); |
||||
$form->addGroup($radios_results_enabled);*/ |
||||
echo '<div class="actions-message" >'; |
||||
echo $language_name; |
||||
echo '</div>'; |
||||
echo '<br/>'; |
||||
/*echo '<div class="actions">'; |
||||
$form->display(); |
||||
echo '</div>';*/ |
||||
|
||||
$html.='<div style="float:left" class="actions" >'; |
||||
$html.='<form style="float:left" id="Loadlanguage" name="Loadlanguage" method="post" action="register_sub_language.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']).'&original_file='.$request_file.'" >'; |
||||
$html.='<input type="hidden" name="id_hidden_original_file" id="id_hidden_original_file" value="'.Security::remove_XSS($_REQUEST['id']).'" />'; |
||||
$html.='<input type="hidden" name="id_hidden_sublanguage" id="id_hidden_sublanguage" value="'.Security::remove_XSS($_REQUEST['sub_language_id']).'" />'; |
||||
$html.='<select id="sl_original_file" name="original_file">'; |
||||
//$html.='<option value="0">'.get_lang('SelectAChoice').'</option>'; |
||||
foreach ($load_array_in_select as $index_radios_results_enabled=>$value_radios_results_enabled) { |
||||
$html.='<option value="'.$value_radios_results_enabled.'">'.$value_radios_results_enabled.'</option>'; |
||||
} |
||||
$html.='</select>'; |
||||
$html.='<button class="plus" name="SubmitLoadLanguage" type="submit">'.get_lang('LoadLanguageFile').'</button>'; |
||||
$html.='</form>'; |
||||
$html.='</div>'; |
||||
|
||||
$html.='<div style="float:left" class="actions">'; |
||||
$html.='<form style="float:left" id="Searchlanguage" name="Searchlanguage" method="post" action="register_sub_language.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']).'&original_file='.$request_file.'" >'; |
||||
$html.=' '.get_lang('OriginalName').' : '; |
||||
$html.='<input name="txt_search_word" type="text" size="30" id="txt_search_word" value="" />'; |
||||
$html.='<button name="SubmitSearchLanguage" class="search" type="submit">'.get_lang('Search').'</button>'; |
||||
$html.='</form>'; |
||||
$html.='</div>'; |
||||
|
||||
echo $html; |
||||
|
||||
echo '<br/>'; |
||||
echo '<br/>'; |
||||
echo '<br/>'; |
||||
//id |
||||
echo '<div id="div_message_information_id"> </div>'; |
||||
echo '<div class="actions-message"><strong>'; |
||||
echo get_lang('AddTermsOfThisSubLanguage'); |
||||
echo '</strong></div>'; |
||||
echo '<br/>'; |
||||
|
||||
//allow see data in sortetable |
||||
if ($_REQUEST['original_file']) { |
||||
|
||||
if (isset($_REQUEST['txt_search_word']) && strlen(trim($_REQUEST['txt_search_word']))==0) { |
||||
unset($list_info); |
||||
$search_data=false; |
||||
} else { |
||||
$search_data=true; |
||||
} |
||||
if($search_data===true) { |
||||
$parent_id=intval($_REQUEST['id']); |
||||
$sub_language_id=intval($_REQUEST['sub_language_id']); |
||||
$get_all_info_of_sub_language=SubLanguageManager::get_all_information_of_sub_language ($parent_id,$sub_language_id); |
||||
$dokeos_path_file=api_get_path('SYS_LANG_PATH').$all_data_of_language['dokeos_folder'].'/'.$request_file; |
||||
|
||||
$dokeos_english_path_file=api_get_path('SYS_LANG_PATH').'english/'.$request_file; |
||||
$dokeos_sub_language_path_file=api_get_path('SYS_LANG_PATH').$get_all_info_of_sub_language['dokeos_folder'].'/'.$request_file; |
||||
if (file_exists($dokeos_sub_language_path_file)) { |
||||
$sub_language_exist=true; |
||||
} else { |
||||
$sub_language_exist=false; |
||||
} |
||||
|
||||
$all_language_variable=SubLanguageManager::get_all_language_variable_in_file ($dokeos_path_file); |
||||
$all_english_language_variable=SubLanguageManager::get_all_language_variable_in_file($dokeos_english_path_file); |
||||
if ($sub_language_exist===true) { |
||||
$get_all_sub_language_variable=SubLanguageManager::get_all_language_variable_in_file($dokeos_sub_language_path_file); |
||||
} |
||||
$i=0; |
||||
foreach ($all_language_variable as $index_language_variable =>$value_language_variable) { |
||||
$use_field_name=substr($index_language_variable,1); |
||||
|
||||
if ($sub_language_exist===true) { |
||||
foreach ($get_all_sub_language_variable as $index_get_all_sub_language_variable =>$value_get_all_sub_language_variable) { |
||||
if ($index_get_all_sub_language_variable==$index_language_variable) { |
||||
$value_sub_language=$value_get_all_sub_language_variable; |
||||
break; |
||||
} else { |
||||
$value_sub_language=''; |
||||
} |
||||
} |
||||
} |
||||
$value_sub_language=strlen($value_sub_language)>0 ? $value_sub_language : ''; |
||||
|
||||
$obj_text='<textarea tabindex="1" rows="4" cols="40" name="txt_'.$use_field_name.'" id="txtid_'.$use_field_name.'" >'.substr($value_sub_language,1,(strlen($value_sub_language)-3)).'</textarea>'; |
||||
|
||||
$obj_button='<button class="save" type="button" name="btn_'.$use_field_name.'" id="btnid_'.$use_field_name.'" />'.get_lang('Save').'</button>'; |
||||
|
||||
$new_element_html=='<input type="hidden" name="code_language_id" id="code_language_id" value="'.Security::remove_XSS($_GET['id']).'" />'; |
||||
|
||||
if ($i==0) { |
||||
$obj_button=$obj_button.$new_element_html; |
||||
} else { |
||||
$obj_button=$obj_button; |
||||
} |
||||
foreach ($all_english_language_variable as $index_english_language_variable =>$value_english_language_variable) { |
||||
if ($index_english_language_variable==$index_language_variable) { |
||||
$add_english_language_in_array=$value_english_language_variable; |
||||
break; |
||||
} |
||||
} |
||||
//FIRST OPTION substr($index_language_variable,1,strlen($index_language_variable)), |
||||
$list_info[]=array($index_language_variable,substr($add_english_language_in_array,1,(strlen($add_english_language_in_array)-3)),substr($value_language_variable,1,(strlen($value_language_variable)-3)),$obj_text,$obj_button); |
||||
$i++; |
||||
} |
||||
} |
||||
if (isset($_REQUEST['txt_search_word']) && strlen(trim($_REQUEST['txt_search_word']))>0) { |
||||
foreach ($list_info as $index_list_info=>$value_list_info) { |
||||
$search='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
||||
if (preg_match($search,$value_list_info[2])===0) { |
||||
unset($list_info[$index_list_info]); |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
||||
$parameters=array('id'=>Security::remove_XSS($_GET['id']),'original_file'=>$request_file,'sub_language_id'=>Security::remove_XSS($_GET['sub_language_id'])); |
||||
if (isset($_REQUEST['txt_search_word']) && strlen($_REQUEST['txt_search_word'])>0) { |
||||
$parameters['txt_search_word']=Security::remove_XSS($_REQUEST['txt_search_word']); |
||||
} |
||||
|
||||
$table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info'); |
||||
$table->set_additional_parameters($parameters); |
||||
//$table->set_header(0, ''); |
||||
$table->set_header(0, get_lang('LanguageVariable')); |
||||
$table->set_header(1, get_lang('EnglishName')); |
||||
$table->set_header(2, get_lang('OriginalName')); |
||||
$table->set_header(3, get_lang('SubLanguage'),false); |
||||
$table->set_header(4, get_lang('Edit'),false); |
||||
/*$form_actions = array (); |
||||
$form_actions['addsublanguage'] = get_lang('AddSubLanguage'); |
||||
$table->set_form_actions($form_actions);*/ |
||||
|
||||
$table->display(); |
||||
|
||||
/* |
||||
============================================================================== |
||||
FOOTER |
||||
============================================================================== |
||||
*/ |
||||
|
||||
Display :: display_footer(); |
||||
?> |
@ -0,0 +1,285 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
/* |
||||
============================================================================== |
||||
INIT SECTION |
||||
============================================================================== |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file = 'admin'; |
||||
$cidReset = true; |
||||
require_once '../inc/global.inc.php'; |
||||
require_once 'sub_language.class.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'array.lib.php'; |
||||
$this_section=SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_script(); |
||||
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery |
||||
$htmlHeadXtra[] ='<script type="text/javascript"> |
||||
$(document).ready(function() { |
||||
|
||||
$(".save").click(function() { |
||||
button_name=$(this).attr("name"); |
||||
button_array=button_name.split("|"); |
||||
button_name=button_array[1]; |
||||
file_id=button_array[2]; |
||||
is_variable_language="$"+button_name; |
||||
|
||||
is_new_language=$("#txtid_"+button_name).attr("value"); |
||||
if (is_new_language=="undefined") { |
||||
is_new_language="_"; |
||||
} |
||||
|
||||
if (is_new_language.length>0 && is_new_language!="_" && file_id!="" && button_name!="") { |
||||
$.ajax({ |
||||
contentType: "application/x-www-form-urlencoded", |
||||
beforeSend: function(objeto) { |
||||
$("#div_message_information_id").html("<div class=\"normal-message\"><img src=\'../inc/lib/javascript/indicator.gif\' /></div>"); |
||||
|
||||
}, |
||||
type: "POST", |
||||
url: "../admin/sub_language_ajax.inc.php", |
||||
data: "new_language="+is_new_language+"&variable_language="+is_variable_language+"&file_id="+file_id+"&id="+'.intval($_REQUEST['id']).'+"&sub="+'.intval($_REQUEST['sub_language_id']).', |
||||
success: function(datos) { |
||||
$("#div_message_information_id").html("<div class=\"confirmation-message\">'.get_lang('TheNewWordHasBeenAdded').'</div>"); |
||||
|
||||
} }); |
||||
} else { |
||||
$("#div_message_information_id").html("<div class=\"error-message\">'.get_lang('FormHasErrorsPleaseComplete').'</div>"); |
||||
} |
||||
}); |
||||
}); |
||||
</script>'; |
||||
/* |
||||
============================================================================== |
||||
MAIN CODE |
||||
============================================================================== |
||||
*/ |
||||
// setting the name of the tool |
||||
$tool_name = get_lang('CreateSubLanguage'); |
||||
// setting breadcrumbs |
||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('PlatformLanguages')); |
||||
|
||||
require_once api_get_path(LIBRARY_PATH).'text.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; |
||||
|
||||
if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
||||
$language_name=SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
||||
$all_data_of_language=SubLanguageManager::get_all_information_of_language($_GET['id']); |
||||
$my_language=$language_name; |
||||
if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
||||
$parent_id=intval($_GET['id']); |
||||
$language_id_exist=true; |
||||
} else { |
||||
$language_id_exist=false; |
||||
} |
||||
} else { |
||||
$language_name=''; |
||||
$language_id_exist=false; |
||||
} |
||||
|
||||
$language_name=get_lang('RegisterTermsOfSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
||||
$dokeos_path_folder=api_get_path('SYS_LANG_PATH').$all_data_of_language['dokeos_folder']; |
||||
// |
||||
if (!is_dir($dokeos_path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
Display :: display_header($language_name); |
||||
|
||||
echo '<div class="actions-message" >'; |
||||
echo $language_name; |
||||
echo '</div>'; |
||||
echo '<br />'; |
||||
|
||||
$html.='<div style="float:left" class="actions">'; |
||||
$html.='<form style="float:left" id="Searchlanguage" name="Searchlanguage" method="post" action="sub_language.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']).'">'; |
||||
$html.=' '.get_lang('OriginalName').' : '; |
||||
$html.='<input name="txt_search_word" type="text" size="50" id="txt_search_word" value="'.Security::remove_XSS($_REQUEST['txt_search_word']).'" />'; |
||||
$html.=" ".'<button name="SubmitSearchLanguage" class="search" type="submit">'.get_lang('Search').'</button>'; |
||||
$html.='</form>'; |
||||
$html.='</div>'; |
||||
echo $html; |
||||
echo '<br /><br /><br /><br />'; |
||||
echo '<div id="div_message_information_id"> </div>'; |
||||
|
||||
/** |
||||
* Search a term in the language |
||||
* @param string the term to search |
||||
* @param bool the search will include the variable definition of the term |
||||
* @param bool the search will include the english language variables |
||||
* @param bool the search will include the parent language variables of the sub language |
||||
* @param bool the search will include the sub language variables |
||||
* @author Julio Montoya |
||||
* |
||||
*/ |
||||
function search_language_term($term, $search_in_variable = true , $search_in_english = true, $search_in_parent = true, $search_in_sub_language= true) { |
||||
//These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
||||
/* |
||||
These 4 arrays are set in global.inc.php with the condition that will be load from sub_language.php or sub_language_ajax.inc.php |
||||
$english_language_array |
||||
$parent_language_array |
||||
$sub_language_array |
||||
$language_files_to_load |
||||
*/ |
||||
//echo '<pre>'; |
||||
// array with the list of files to load i.e trad4fall, notification, etc set in global.inc.php |
||||
|
||||
global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
||||
$language_files_to_load_keys = array_flip($language_files_to_load); |
||||
$array_to_search = $parent_language_array; |
||||
$list_info = array(); |
||||
//echo '<pre>'; |
||||
//print_r($language_files_to_load); |
||||
$term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
||||
//@todo optimize this foreach |
||||
foreach ($language_files_to_load as $lang_file) { |
||||
//searching in parent language of the sub language |
||||
if ($search_in_parent) { |
||||
$variables = $parent_language_array[$lang_file]; |
||||
foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
||||
//arrays are avoided |
||||
if (is_array($parent_variable_value)) { |
||||
continue; |
||||
} |
||||
$founded = false; |
||||
// searching the item in the parent tool |
||||
if (preg_match($term,$parent_variable_value)!==0) { |
||||
$founded = true; |
||||
} |
||||
if ($founded) { |
||||
//loading variable from the english array |
||||
$sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
||||
//loading variable from the english array |
||||
$english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
||||
|
||||
//config buttons |
||||
if (strlen($english_name_variable)>1500) { |
||||
$size =20; |
||||
} else { |
||||
$size =4; |
||||
} |
||||
$obj_text='<textarea rows="'.$size.'" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
||||
$obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
||||
|
||||
$list_info[]=array($lang_file.'.inc.php', |
||||
$parent_name_variable, |
||||
$english_name_variable, |
||||
$parent_variable_value,$obj_text,$obj_button); |
||||
} |
||||
} |
||||
} |
||||
|
||||
//search in english |
||||
if ($search_in_english || $search_in_variable) { |
||||
$variables = $english_language_array[$lang_file]; |
||||
foreach ($variables as $name_variable =>$variable_value) { |
||||
if (is_array($variable_value)) { |
||||
continue; |
||||
} |
||||
if (is_array($variable_value)) |
||||
echo $lang_file; |
||||
$founded = false; |
||||
if ($search_in_english && $search_in_variable) { |
||||
// searching the item in the parent tool |
||||
if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
||||
$founded = true; |
||||
} |
||||
} else { |
||||
if ($search_in_english) { |
||||
if (preg_match($term,$variable_value)!==0) { |
||||
$founded = true; |
||||
} |
||||
} else { |
||||
if (preg_match($term,$name_variable)!==0) { |
||||
$founded = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($founded) { |
||||
//loading variable from the english array |
||||
$sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
||||
$parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
||||
//config buttons |
||||
$obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
||||
$obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
||||
|
||||
//loading variable from the english array |
||||
$english_name_variable = $english_language_array[$lang_file][$name_variable]; |
||||
|
||||
$list_info[]=array($lang_file.'.inc.php', |
||||
$name_variable, |
||||
$english_name_variable, |
||||
$parent_variable_value,$obj_text,$obj_button); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
//search in sub language |
||||
if ($search_in_sub_language) { |
||||
$variables = $sub_language_array[$lang_file]; |
||||
foreach ($variables as $name_variable =>$variable_value) { |
||||
if (is_array($parent_variable_value)) { |
||||
continue; |
||||
} |
||||
|
||||
$founded = false; |
||||
// searching the item in the parent tool |
||||
if (preg_match($term,$variable_value)!==0) { |
||||
$founded = true; |
||||
} |
||||
if ($founded) { |
||||
//loading variable from the english array |
||||
$sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
||||
$parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
||||
//config buttons |
||||
$obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
||||
$obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
||||
|
||||
//loading variable from the english array |
||||
$english_name_variable = $english_language_array[$lang_file][$name_variable]; |
||||
$list_info[]=array($lang_file.'.inc.php', |
||||
$name_variable, |
||||
$english_name_variable, |
||||
$parent_variable_value,$obj_text,$obj_button); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$list_info = array_unique_dimensional($list_info); |
||||
return $list_info; |
||||
} |
||||
|
||||
//allow see data in sortetable |
||||
if (isset($_REQUEST['txt_search_word']) && strlen(trim($_REQUEST['txt_search_word']))!=0) { |
||||
$list_info = search_language_term($_REQUEST['txt_search_word'],true, true, true,true); |
||||
} |
||||
//var_dump($list_info); |
||||
$parameters=array('id'=>intval($_GET['id']),'sub_language_id'=>intval($_GET['sub_language_id'])); |
||||
if (isset($_REQUEST['txt_search_word']) && strlen($_REQUEST['txt_search_word'])>0) { |
||||
$parameters['txt_search_word']=Security::remove_XSS($_REQUEST['txt_search_word']); |
||||
} |
||||
|
||||
$table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info'); |
||||
$table->set_additional_parameters($parameters); |
||||
//$table->set_header(0, ''); |
||||
$table->set_header(0, get_lang('LanguageFile')); |
||||
$table->set_header(1, get_lang('LanguageVariable')); |
||||
$table->set_header(2, get_lang('EnglishName')); |
||||
$table->set_header(3, get_lang('OriginalName')); |
||||
$table->set_header(4, get_lang('SubLanguage'),false); |
||||
$table->set_header(5, get_lang('Edit'),false); |
||||
$table->display(); |
||||
|
||||
/* |
||||
============================================================================== |
||||
FOOTER |
||||
============================================================================== |
||||
*/ |
||||
|
||||
Display :: display_footer(); |
||||
?> |
@ -0,0 +1,30 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
// including the global dokeos file |
||||
require_once '../inc/global.inc.php'; |
||||
require_once 'sub_language.class.php'; |
||||
/* |
||||
* search a term and return description from a glossary |
||||
*/ |
||||
global $charset; |
||||
|
||||
$new_language = Security::remove_XSS($_REQUEST['new_language']); |
||||
$language_variable = Security::remove_XSS($_REQUEST['variable_language']); |
||||
$file_id = Security::remove_XSS($_REQUEST['file_id']); |
||||
|
||||
if (isset($new_language) && isset($language_variable) && isset($file_id)) { |
||||
$file_language = $language_files_to_load[$file_id].'.inc.php'; |
||||
$id_language = intval($_REQUEST['id']); |
||||
$sub_language_id = intval($_REQUEST['sub']); |
||||
$all_data_of_language=SubLanguageManager::get_all_information_of_sub_language($id_language,$sub_language_id); |
||||
$dokeos_path_folder=api_get_path('SYS_LANG_PATH').$all_data_of_language['dokeos_folder'].'/'.$file_language; |
||||
$all_file_of_directory=SubLanguageManager::get_all_language_variable_in_file($dokeos_path_folder); |
||||
SubLanguageManager::add_file_in_language_directory ($dokeos_path_folder); |
||||
|
||||
//update variable language |
||||
$all_file_of_directory[$language_variable]="\"".mb_convert_encoding($new_language,$charset,'UTF-8')."\";"; |
||||
|
||||
foreach ($all_file_of_directory as $key_value=>$value_info) { |
||||
SubLanguageManager::write_data_in_file ($dokeos_path_folder,$value_info,$key_value); |
||||
} |
||||
} |
Loading…
Reference in new issue