parent
aeb4a4bc76
commit
d9b16acc68
@ -0,0 +1,26 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
|
||||
// including the global dokeos file |
||||
require_once '../inc/global.inc.php'; |
||||
require_once 'admin.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']); |
||||
|
||||
$all_data_of_language=AdminManager::get_all_information_of_sub_language($_POST['id']); |
||||
$dokeos_path_folder=api_get_path('SYS_LANG_PATH').$all_data_of_language['dokeos_folder'].'/'.$file_language; |
||||
$all_file_of_directory=AdminManager::get_all_language_variable_in_file($dokeos_path_folder); |
||||
AdminManager::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) { |
||||
AdminManager::write_data_in_file ($dokeos_path_folder,$value_info,$key_value); |
||||
} |
@ -0,0 +1,163 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
/** |
||||
============================================================================== |
||||
@author Isaac flores - Added 9 july of 2009 |
||||
============================================================================== |
||||
*/ |
||||
/* |
||||
============================================================================== |
||||
Class AdminManager |
||||
============================================================================== |
||||
*/ |
||||
class AdminManager { |
||||
|
||||
function __construct() { |
||||
} |
||||
/** |
||||
* Get all data of dokeos folder (forum.inc.php,gradebook.inc.php,notebook.inc.php) |
||||
* @param String The dokeos path folder (/var/www/my_dokeos/main/lang/spanish) |
||||
* @return Array All file of dokeos folder |
||||
*/ |
||||
public static function get_all_data_of_dokeos_folder ($dokeos_path_folder) { |
||||
$content_dir=array(); |
||||
if (is_dir($dokeos_path_folder)) { |
||||
if ($dh = opendir($dokeos_path_folder)) { |
||||
while (($file = readdir($dh)) !== false && $file != '.' && $file != '..') { |
||||
if ($file{0}<>'.') { |
||||
$content_dir[]=$file; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
closedir($dh); |
||||
return $content_dir; |
||||
} |
||||
} |
||||
/** |
||||
* Get all information of sub-language |
||||
* @param Integer The parent id(Language father id) |
||||
* @return Array All information about sub-language |
||||
*/ |
||||
public static function get_all_information_of_sub_language ($parent_id) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql='SELECT * FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'"'; |
||||
$rs=Database::query($sql,__FILE__,__LINE__); |
||||
$all_information=array(); |
||||
while ($row=Database::fetch_array($rs,'ASSOC')) { |
||||
$all_information=$row; |
||||
} |
||||
return $all_information; |
||||
} |
||||
/** |
||||
* Get all information of language |
||||
* @param Integer The parent id(Language father id) |
||||
* @return Array All information about language |
||||
*/ |
||||
public static function get_all_information_of_language ($parent_id) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql='SELECT * FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($parent_id).'"'; |
||||
$rs=Database::query($sql,__FILE__,__LINE__); |
||||
$all_information=array(); |
||||
while ($row=Database::fetch_array($rs,'ASSOC')) { |
||||
$all_information=$row; |
||||
} |
||||
return $all_information; |
||||
} |
||||
/** |
||||
* Get all information of dokeos file |
||||
* @param String The dokeos path file (/var/www/my_dokeos/main/lang/spanish/gradebook.inc.php) |
||||
* @return Array Contains all information of dokeos file |
||||
*/ |
||||
public static function get_all_language_variable_in_file ($dokeos_path_file) { |
||||
$info_file=file($dokeos_path_file); |
||||
foreach ($info_file as $line) { |
||||
if (substr($line,0,1)!='$') { continue; } |
||||
list($var,$val) = split('=',$line,2); |
||||
$var = trim($var); $val = trim($val); |
||||
$res_list[$var] = $val; |
||||
} |
||||
return $res_list; |
||||
} |
||||
|
||||
/** |
||||
* Add file in sub-language directory and add header(tag php) |
||||
* @param String The dokeos path file (/var/www/my_dokeos/main/lang/spanish/gradebook.inc.php) |
||||
* @return void() |
||||
*/ |
||||
public static function add_file_in_language_directory ($dokeos_path_file) { |
||||
file_put_contents($dokeos_path_file,'<?php'.PHP_EOL); |
||||
} |
||||
/** |
||||
* Write in file of sub-language |
||||
* @param String The path file (/var/www/my_dokeos/main/lang/spanish/gradebook.inc.php) |
||||
* @param String The new sub-language |
||||
* @param String The language variable |
||||
* @return void() |
||||
*/ |
||||
public static function write_data_in_file ($path_file,$new_sub_language,$variable_sub_language) { |
||||
$new_data=$variable_sub_language.'='.$new_sub_language; |
||||
$g_open_file = fopen($path_file, "a"); |
||||
if (fwrite($g_open_file, $new_data.PHP_EOL) === false) { |
||||
//not allow to write |
||||
} |
||||
fclose($g_open_file); |
||||
} |
||||
/** |
||||
* Add directory for sub-language |
||||
* @param String The sub-language path directory ( /var/www/my_dokeos/main/lang/spanish_corporate ) |
||||
* @return boolean |
||||
*/ |
||||
public static function add_directory_of_sub_language($path_sub_language) { |
||||
$rs=@mkdir($path_sub_language,0777); |
||||
if ($rs) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
/** |
||||
* Delete sub-language |
||||
* @param Integer The parent id |
||||
* @return void() |
||||
*/ |
||||
public static function removed_sub_language ($parent_id) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql='DELETE FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'"'; |
||||
$rs=Database::query($sql,__FILE__,__LINE__); |
||||
} |
||||
/** |
||||
* check if language exist by id |
||||
*/ |
||||
public static function check_if_exist_language_by_id ($language_id) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql='SELECT count(*) as count FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($language_id).'"'; |
||||
$rs=Database::query($sql,__FILE__,__LINE__); |
||||
if (Database::num_rows($rs)>0) { |
||||
if (Database::result($rs,0,'count') ==1) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} else { |
||||
return false;; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Get name of language by id |
||||
*/ |
||||
function get_name_of_language_by_id ($language_id) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql='SELECT original_name FROM '.$tbl_admin_languages.' WHERE id="'.Database::escape_string($language_id).'"'; |
||||
$rs=Database::query($sql,__FILE__,__LINE__); |
||||
if (Database::num_rows($rs)>0) { |
||||
return Database::result($rs,0,'original_name'); |
||||
} else { |
||||
return ''; |
||||
} |
||||
|
||||
} |
||||
} |
||||
?> |
@ -0,0 +1,280 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
/** |
||||
============================================================================== |
||||
@author Isaac flores - 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 'admin.class.php'; |
||||
$this_section=SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_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'; |
||||
|
||||
/*declare functions*/ |
||||
/** |
||||
* Add sub-language |
||||
*/ |
||||
function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql='INSERT INTO '.$tbl_admin_languages.'(original_name,english_name,isocode,dokeos_folder,available,parent_id) VALUES ("'.api_htmlentities($original_name).'","'.$english_name.'","'.$isocode.'","'.$english_name.'","'.$sublanguage_available.'","'.$parent_id.'")'; |
||||
Database::query($sql,__FILE__,__LINE__); |
||||
} |
||||
/** |
||||
* check if language exist |
||||
*/ |
||||
function check_if_language_exist ($original_name,$english_name,$isocode,$sublanguage_available) { |
||||
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
||||
$sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string(api_htmlentities($original_name)).'" '; |
||||
$sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
||||
$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" '; |
||||
$rs_original_name=Database::query($sql_original_name,__FILE__,__LINE__); |
||||
$rs_english_name=Database::query($sql_english_name,__FILE__,__LINE__); |
||||
$rs_isocode=Database::query($sql_isocode,__FILE__,__LINE__); |
||||
$count_original_name=Database::result($rs_original_name,0,'count_original_name'); |
||||
$count_english_name=Database::result($rs_english_name,0,'count_english_name'); |
||||
$count_isocode=Database::result($rs_isocode,0,'count_isocode'); |
||||
$has_error=false; |
||||
$message_information=array(); |
||||
|
||||
if ($count_original_name==1) { |
||||
$has_error=true; |
||||
$message_information['original_name']=true; |
||||
} |
||||
if ($count_english_name==1) { |
||||
$has_error=true; |
||||
$message_information['english_name']=true; |
||||
} |
||||
if ($count_isocode==1) { |
||||
$has_error=true; |
||||
$message_information['isocode']=true; |
||||
} |
||||
if ($has_error===true) { |
||||
$message_information['execute_add']=false; |
||||
} |
||||
if ($has_error===false) { |
||||
$message_information['execute_add']=true; |
||||
} |
||||
|
||||
return $message_information; |
||||
} |
||||
|
||||
/** |
||||
* get name of language by id |
||||
*/ |
||||
function get_name_of_language_by_id ($language_id) { |
||||
return AdminManager::get_name_of_language_by_id($language_id); |
||||
} |
||||
/** |
||||
* check if language exist by id |
||||
*/ |
||||
function check_if_exist_language_by_id ($language_id) { |
||||
return AdminManager::check_if_exist_language_by_id($language_id); |
||||
} |
||||
/** |
||||
* check if is parent of sub-language |
||||
*/ |
||||
function ckeck_if_is_parent_of_sub_language ($parent_id) { |
||||
$sql='SELECT count(*) AS count FROM language WHERE parent_id="'.Database::escape_string($parent_id).'"'; |
||||
$rs=Database::query($sql,__FILE__,__LINE__); |
||||
if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
/** |
||||
* Get all information of sub-language |
||||
*/ |
||||
function allow_get_all_information_of_sub_language ($parent_id) { |
||||
return AdminManager::get_all_information_of_sub_language($parent_id); |
||||
} |
||||
/** |
||||
* Delete sub-language |
||||
*/ |
||||
function removed_sub_language ($parent_id) { |
||||
AdminManager::removed_sub_language($parent_id); |
||||
} |
||||
/** |
||||
* Add directory for sub-language |
||||
*/ |
||||
function add_directory_of_sub_language ($path_sub_language) { |
||||
return AdminManager::add_directory_of_sub_language($path_sub_language); |
||||
} |
||||
/** |
||||
* Remove directory of sub-language |
||||
*/ |
||||
function remove_directory_of_sub_language ($path) { |
||||
$content=AdminManager::get_all_data_of_dokeos_folder($path); |
||||
|
||||
if (count($content)>0) { |
||||
foreach ($content as $value_content) { |
||||
$path_file=$path.'/'.$value_content; |
||||
unlink($path_file); |
||||
} |
||||
$rs=@rmdir($path); |
||||
if ($rs===true) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} else { |
||||
$rs=@rmdir($path); |
||||
if ($rs===true) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
} |
||||
/*end declare functions*/ |
||||
|
||||
//add register |
||||
if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
||||
$language_name=get_name_of_language_by_id($_GET['id']); |
||||
if (check_if_exist_language_by_id ($_GET['id'])===true) { |
||||
$parent_id=$_GET['id']; |
||||
$language_id_exist=true; |
||||
} else { |
||||
$language_id_exist=false; |
||||
} |
||||
|
||||
} else { |
||||
$language_name=''; |
||||
$language_id_exist=false; |
||||
} |
||||
|
||||
//removed and register |
||||
|
||||
if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
||||
if (check_if_exist_language_by_id($_GET['id'])===true) { |
||||
$get_all_information=allow_get_all_information_of_sub_language ($_GET['id']); |
||||
$original_name=$get_all_information['original_name']; |
||||
$english_name=$get_all_information['english_name']; |
||||
$isocode=$get_all_information['isocode']; |
||||
|
||||
} |
||||
} |
||||
|
||||
$language_name=get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
||||
|
||||
if (ckeck_if_is_parent_of_sub_language ($parent_id)===true ) { |
||||
$language_name=get_lang('DeleteSubLanguageForLanguage'); |
||||
} |
||||
|
||||
Display :: display_header($language_name); |
||||
|
||||
if (isset($_POST['SubmitAddNewLanguage'])) { |
||||
$original_name=$_POST['original_name']; |
||||
$english_name=$_POST['english_name']; |
||||
$isocode=$_POST['isocode']; |
||||
$english_name=str_replace(' ','_',$english_name); |
||||
$isocode=str_replace(' ','_',$isocode); |
||||
|
||||
$sublanguage_available=$_POST['sub_language_is_visible']; |
||||
$check_information=array(); |
||||
$check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available); |
||||
foreach ($check_information as $index_information => $value_information) { |
||||
$allow_insert_info=false; |
||||
if ($index_information=='original_name') { |
||||
Display::display_error_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')'); |
||||
} |
||||
if ($index_information=='english_name') { |
||||
Display::display_error_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')'); |
||||
} |
||||
if ($index_information=='isocode') { |
||||
Display::display_error_message(get_lang('AlreadyExists').' "'.get_lang('Isocode').'" '.'('.$isocode.')'); |
||||
} |
||||
if ($index_information=='execute_add' && $value_information===true) { |
||||
$allow_insert_info=true; |
||||
} |
||||
|
||||
} |
||||
|
||||
if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) { |
||||
if ($allow_insert_info===true && $language_id_exist===true) { |
||||
$english_name=str_replace(' ','_',$english_name); |
||||
$isocode=str_replace(' ','_',$isocode); |
||||
$str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('Isocode').' : '.$isocode; |
||||
$path=api_get_path('SYS_LANG_PATH').$english_name; |
||||
add_directory_of_sub_language ($path); |
||||
add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id); |
||||
|
||||
Display::display_confirmation_message(get_lang('TheNewSubLanguageHasBeenAdd').$str_info); |
||||
} else { |
||||
if ($language_id_exist===false) { |
||||
Display::display_error_message(get_lang('LanguageParentNotExist')); |
||||
} |
||||
} |
||||
} else { |
||||
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); |
||||
} |
||||
} |
||||
if (isset($_POST['SubmitAddDeleteLanguage'])) { |
||||
$path=api_get_path('SYS_LANG_PATH').$english_name; |
||||
if (is_dir($path)) { |
||||
$rs=remove_directory_of_sub_language($path); |
||||
if ($rs===true) { |
||||
removed_sub_language($parent_id); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
if (ckeck_if_is_parent_of_sub_language ($parent_id)===false ) { |
||||
$text=$language_name; |
||||
$form = new FormValidator('addsublanguage', 'post', 'new_sub_language.php?id='.Security::remove_XSS($_GET['id'])); |
||||
$class='add'; |
||||
$form->addElement('header', '', $text); |
||||
$form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"'); |
||||
$form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required'); |
||||
$form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"'); |
||||
$form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required'); |
||||
$form->addElement('text', 'isocode', get_lang('Isocode'),'class="input_titles"'); |
||||
$form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required'); |
||||
$form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility')); |
||||
$form->addElement('style_submit_button', 'SubmitAddNewLanguage', get_lang('CreateSubLanguage'), 'class="'.$class.'"'); |
||||
$form->display(); |
||||
} else { |
||||
$text=$language_name; |
||||
$form = new FormValidator('deletesublanguage', 'post', 'new_sub_language.php?id='.Security::remove_XSS($_GET['id'])); |
||||
$class='save'; |
||||
$form->addElement('header', '', $text); |
||||
$form->addElement('static', '', get_lang('OriginalName'),$original_name); |
||||
$form->addElement('static', '', get_lang('EnglishName'),$english_name); |
||||
$form->addElement('static', '', get_lang('Isocode'),$isocode); |
||||
$form->addElement('style_submit_button', 'SubmitAddDeleteLanguage', get_lang('DeleteSubLanguage'), 'class="'.$class.'"'); |
||||
$form->display(); |
||||
} |
||||
|
||||
/* |
||||
============================================================================== |
||||
FOOTER |
||||
============================================================================== |
||||
*/ |
||||
Display :: display_footer(); |
||||
?> |
@ -0,0 +1,278 @@ |
||||
<?php |
||||
/* For licensing terms, see /dokeos_license.txt */ |
||||
/** |
||||
============================================================================== |
||||
@author Isaac flores - 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 'admin.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+"&original_file="+$(this).attr("value") |
||||
$("#Loadlanguage").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_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, |
||||
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'; |
||||
|
||||
/*declare functions*/ |
||||
/** |
||||
* Get name of language by id |
||||
*/ |
||||
function get_name_of_language_by_id ($language_id) { |
||||
return AdminManager::get_name_of_language_by_id($language_id); |
||||
} |
||||
function check_if_exist_language_by_id ($language_id) { |
||||
return AdminManager::check_if_exist_language_by_id($language_id); |
||||
} |
||||
/*end declare functions*/ |
||||
|
||||
|
||||
if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
||||
$language_name=get_name_of_language_by_id($_GET['id']); |
||||
$all_data_of_language=AdminManager::get_all_information_of_language($_GET['id']); |
||||
$my_language=$language_name; |
||||
if (check_if_exist_language_by_id ($_GET['id'])===true) { |
||||
$parent_id=$_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) |
||||
|
||||
//ADD ALL SUB LANGUAGE |
||||
if (isset($_POST['action']) && $_POST['action']=='addsublanguage') { |
||||
/*$all_data_of_sub_language=AdminManager::get_all_information_of_sub_language($_POST['code_language_id']); |
||||
$dokeos_sub_language_path_folder=api_get_path('SYS_LANG_PATH').$all_data_of_sub_language['dokeos_folder'].'/'.Security::remove_XSS($_REQUEST['original_file']); |
||||
$all_file_of_directory=AdminManager::get_all_language_variable_in_file($dokeos_sub_language_path_folder); |
||||
//AdminManager::add_file_in_language_directory ($dokeos_path_folder); |
||||
|
||||
foreach ($_POST['id'] as $index_post_id =>$value_post_id) { |
||||
foreach ($_POST as $index_post_txt =>$value_post_txt) { |
||||
if (is_string($index_post_txt) && strlen($index_post_txt)>4) { |
||||
if ($value_post_id==substr($index_post_txt,4,strlen($index_post_txt))) { |
||||
$new_language=$value_post_txt; |
||||
$index_variable_of_sub_language='$'.$index_post_txt; |
||||
$all_file_of_directory[$index_variable_of_sub_language]="\"".$new_language."\";"; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
*/ |
||||
//var_dump($all_file_of_directory); |
||||
//update variable language |
||||
|
||||
|
||||
|
||||
/*foreach ($all_file_of_directory as $key_value=>$value_info) { |
||||
AdminManager::write_data_in_file ($dokeos_path_folder,$value_info,$key_value); |
||||
}*/ |
||||
} |
||||
//END ALL SUB LANGUAGE |
||||
|
||||
$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=AdminManager::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='add'; |
||||
$form->addElement('header', '', $language_name); |
||||
$form->addElement('select', 'original_file', get_lang('File'),$load_array_in_select,array('id'=>'sl_original_file')); |
||||
$form->addElement('hidden','id_hidden_original_file',Security::remove_XSS($_REQUEST['id']),array('id'=>'id_hidden_original_file')); |
||||
$form->addElement('style_submit_button', 'SubmitLoadLanguage', get_lang('LoadLanguageFile'), 'class="'.$class.'"'); |
||||
$form->display(); |
||||
echo '<br/>'; |
||||
|
||||
//id |
||||
echo '<div id="div_message_information_id"> </div>'; |
||||
echo '<div class="actions"><strong>'; |
||||
echo get_lang('AddTermsOfThisSubLanguage'); |
||||
echo '</strong></div>'; |
||||
|
||||
|
||||
//allow see data in sortetable |
||||
if ($_REQUEST['original_file']) { |
||||
|
||||
$parent_id=Security::remove_XSS($_REQUEST['id']); |
||||
$get_all_info_of_sub_language=AdminManager::get_all_information_of_sub_language ($parent_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=AdminManager::get_all_language_variable_in_file ($dokeos_path_file); |
||||
$all_english_language_variable=AdminManager::get_all_language_variable_in_file($dokeos_english_path_file); |
||||
if ($sub_language_exist===true) { |
||||
$get_all_sub_language_variable=AdminManager::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='<input name="txt_'.$use_field_name.'" id="txtid_'.$use_field_name.'" value="'.substr($value_sub_language,1,(strlen($value_sub_language)-3)).'">'; |
||||
|
||||
$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++; |
||||
} |
||||
} |
||||
|
||||
|
||||
$parameters=array('id'=>Security::remove_XSS($_GET['id']),'original_file'=>$request_file); |
||||
$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')); |
||||
$table->set_header(4, get_lang('Register')); |
||||
/*$form_actions = array (); |
||||
$form_actions['addsublanguage'] = get_lang('AddSubLanguage'); |
||||
$table->set_form_actions($form_actions);*/ |
||||
|
||||
$table->display(); |
||||
|
||||
/* |
||||
============================================================================== |
||||
FOOTER |
||||
============================================================================== |
||||
*/ |
||||
|
||||
Display :: display_footer(); |
||||
?> |
Loading…
Reference in new issue