';
if (!empty($sublanguage_folder_error)) {
Display::display_warning_message($sublanguage_folder_error);
}
echo '
';
/**
* Search a term in the language
* @param string $term the term to search
* @param bool $search_in_variable the search will include the variable definition of the term
* @param bool $search_in_english the search will include the english language variables
* @param bool $search_in_parent the search will include the parent language variables of the sub language
* @param bool $search_in_sub_language 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
*/
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();
$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='';
$obj_button=''.get_lang('Save').'';
$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 = null;
if (isset($sub_language_array[$lang_file][$name_variable])) {
$sub_language_name_variable = $sub_language_array[$lang_file][$name_variable];
}
$parent_variable_value = null;
if (isset($parent_language_array[$lang_file][$name_variable])) {
$parent_variable_value = $parent_language_array[$lang_file][$name_variable];
}
//config buttons
$obj_text='';
$obj_button=''.get_lang('Save').'';
//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='';
$obj_button=''.get_lang('Save').'';
//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 sort table
$list_info = array();
if (isset($_REQUEST['txt_search_word'])) {
//@todo fix to accept a char with 1 char
if (strlen(trim($_REQUEST['txt_search_word']))>2) {
$list_info = search_language_term(
$_REQUEST['txt_search_word'],
true,
true,
true,
true
);
}
}
$parameters = array(
'id' => intval($_GET['id']),
'sub_language_id' => intval($_GET['sub_language_id']),
'txt_search_word' => $txt_search_word
);
$table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info');
$table->set_additional_parameters($parameters);
$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();
Display :: display_footer();