mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
some changes to lang pack management
This commit is contained in:
parent
ac00b9977d
commit
1a71d8074c
2 changed files with 276 additions and 98 deletions
|
@ -54,6 +54,15 @@
|
||||||
'', '', true, $button);
|
'', '', true, $button);
|
||||||
|
|
||||||
if (!$mode) {
|
if (!$mode) {
|
||||||
|
print_simple_box_start('center','80%');
|
||||||
|
echo '<table align="center" width="100%"><tr><td width="50%" align="center">';
|
||||||
|
print_string('managelang','admin');
|
||||||
|
echo '</td><td align="center" width="50%">';
|
||||||
|
print_string('editlang','admin');
|
||||||
|
echo '</td></tr><tr><td>';
|
||||||
|
print_string('lang16notify','admin');
|
||||||
|
echo '<p /><a href="langimport.php">'.get_string('langimport','admin').'</a>';
|
||||||
|
echo '</td><td>';
|
||||||
$currlang = current_language();
|
$currlang = current_language();
|
||||||
$langs = get_list_of_languages();
|
$langs = get_list_of_languages();
|
||||||
echo "<table align=\"center\"><tr><td align=\"right\">";
|
echo "<table align=\"center\"><tr><td align=\"right\">";
|
||||||
|
@ -62,11 +71,13 @@
|
||||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
echo popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||||
echo '</td></tr><tr><td colspan="2">';
|
echo '</td></tr><tr><td colspan="2">';
|
||||||
$options["lang"] = $currentlang;
|
$options["lang"] = $currentlang;
|
||||||
print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
//print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||||
echo "</td></tr></table>";
|
echo "</td></tr></table>";
|
||||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||||
print_heading("<a href=\"lang.php?mode=compare\">$streditstrings</a>");
|
print_heading("<a href=\"lang.php?mode=compare\">$streditstrings</a>");
|
||||||
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
|
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
|
||||||
|
echo '</td></tr></table>';
|
||||||
|
print_simple_box_end();
|
||||||
print_footer();
|
print_footer();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
///This file only manages the installation of 1.6 lang packs.
|
///This file only manages the installation of 1.6 lang packs.
|
||||||
///in downloads.moodle.org, they are store in separate directory
|
///in downloads.moodle.org, they are store in separate directory /lang16
|
||||||
///in local server, they are stored in $CFG->dataroot/lang
|
///in local server, they are stored in $CFG->dataroot/lang
|
||||||
///This helps to avoid confusion.
|
///This helps to avoid confusion.
|
||||||
|
|
||||||
|
|
||||||
/*********************************************
|
|
||||||
* Problem with directory permisssion *
|
|
||||||
* /temp, /lang *
|
|
||||||
*********************************************/
|
|
||||||
|
|
||||||
include('../config.php');
|
include('../config.php');
|
||||||
$mode = optional_param('mode',0,PARAM_INT); //phase
|
$mode = optional_param('mode',0,PARAM_INT); //phase
|
||||||
$pack = optional_param('pack','',PARAM_NOTAGS); //pack to install
|
$pack = optional_param('pack','',PARAM_NOTAGS); //pack to install
|
||||||
$displaylang = optional_param('displaylang','',PARAM_ALPHA); //display language
|
$displaylang = $pack;
|
||||||
$uninstalllang = optional_param('uninstalllang','',PARAM_NOTAGS);
|
$uninstalllang = optional_param('uninstalllang','',PARAM_NOTAGS);
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
|
@ -21,74 +15,108 @@
|
||||||
error('You must be an admin');
|
error('You must be an admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$site = get_site()) {
|
||||||
|
error("Site not defined!");
|
||||||
|
}
|
||||||
|
|
||||||
$strlang = get_string('langimport','admin');
|
$strlang = get_string('langimport','admin');
|
||||||
|
|
||||||
print_header($strlang, $strlang, $strlang);
|
$stradministration = get_string("administration");
|
||||||
|
$strconfiguration = get_string("configuration");
|
||||||
|
$strlanguage = get_string("language");
|
||||||
|
$strthislanguage = get_string("thislanguage");
|
||||||
|
$title = $strlang;
|
||||||
|
|
||||||
|
print_header("$site->shortname: $title", "$site->fullname",
|
||||||
|
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||||
|
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||||
|
"<a href=\"lang.php\">$strlanguage</a> -> $strlang",
|
||||||
|
'', '', true, '');
|
||||||
|
|
||||||
print_heading('');
|
print_heading('');
|
||||||
|
|
||||||
switch ($mode){
|
switch ($mode){
|
||||||
|
|
||||||
case 2: //mode 2 confirmation
|
case 2: ///installation of selected language pack
|
||||||
|
|
||||||
if (confirm_sesskey()){
|
if (confirm_sesskey()){
|
||||||
print_simple_box_start('center','100%');
|
if (optional_param('confirm')){
|
||||||
echo '<div align="center">';
|
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||||
echo '<form name="langform" action="langimport.php?mode=3" method="POST">';
|
@mkdir ($CFG->dataroot.'/lang/');
|
||||||
echo '<input name="pack" type="hidden" value="'.$pack.'" />';
|
$source = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||||
echo '<input name="displaylang" type="hidden" value="'.$displaylang.'" />';
|
$langpack = $CFG->dataroot.'/temp/'.$pack.'.zip';
|
||||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
$destination = $CFG->dataroot.'/lang/';
|
||||||
print_heading(get_string('confirminstall','admin',$displaylang),2);
|
if ($contents = file_get_contents($source)) { // Grab whole page
|
||||||
echo '<input type="submit" value="'.get_string('ok').'"/>';
|
if ($file = fopen($langpack, 'w')) { // Make local copy
|
||||||
echo ' <input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
|
if (!fwrite($file, $contents)){ //copy zip to temp folder..
|
||||||
echo '</form>';
|
error ('could not copy file');
|
||||||
echo '</div>';
|
}
|
||||||
print_simple_box_end();
|
fclose($file);
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: //mode 3 process (copy, unzip, write md5 file, cleanup)
|
|
||||||
|
|
||||||
if (confirm_sesskey()){
|
|
||||||
@mkdir ($CFG->dataroot.'/temp/');
|
|
||||||
@mkdir ($CFG->dataroot.'/lang/');
|
|
||||||
$source = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
|
||||||
$langpack = $CFG->dataroot.'/temp/'.$pack.'.zip';
|
|
||||||
$destination = $CFG->dataroot.'/lang/';
|
|
||||||
if ($contents = file_get_contents($source)) { // Grab whole page
|
|
||||||
if ($file = fopen($langpack, 'w')) { // Make local copy
|
|
||||||
if (!fwrite($file, $contents)){ //copy zip to temp folder..
|
|
||||||
error ('could not copy file');
|
|
||||||
}
|
|
||||||
fclose($file);
|
|
||||||
|
|
||||||
///recursively remove the whole directory since unzip does not overwrites anything
|
///recursively remove the whole directory since unzip does not overwrites anything
|
||||||
if (file_exists($destination.$pack)){
|
if (file_exists($destination.$pack)){
|
||||||
@remove_dir($destination.$pack.'/');
|
@remove_dir($destination.$pack.'/');
|
||||||
|
}
|
||||||
|
//unpack the zip
|
||||||
|
if (unzip_file($langpack, $destination, false)){
|
||||||
|
print_heading(get_string('langimportsuccess','admin'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error('language installation failed');
|
||||||
|
}
|
||||||
|
//now, we update the md5key of the lang pack, this is used to check version
|
||||||
|
$md5file = $CFG->dataroot.'/lang/'.$pack.'/'.$pack.'.md5';
|
||||||
|
if ($file = fopen($md5file, 'w')){
|
||||||
|
fwrite($file, md5($contents)); //manually generate md5 from zip
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
@unlink ($langpack); //bye bye zip file, come back when you get a little better
|
||||||
|
echo '<div align="center"><form action="langimport.php" method="POST">';
|
||||||
|
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||||
|
echo '</form></div>';
|
||||||
}
|
}
|
||||||
//unpack the zip
|
}
|
||||||
if (unzip_file($langpack, $destination, false)){
|
}
|
||||||
print_heading(get_string('langimportsuccess','admin'));
|
else { //print confirm box, no confirmation yet
|
||||||
}
|
if (confirm_sesskey()){
|
||||||
else {
|
print_simple_box_start('center','100%');
|
||||||
error('language installation failed');
|
echo '<div align="center">';
|
||||||
}
|
echo '<form name="langform" action="langimport.php?mode=2" method="POST">';
|
||||||
//now, we update the md5key of the lang pack, this is used to check version
|
echo '<input name="pack" type="hidden" value="'.$pack.'" />';
|
||||||
$md5file = $CFG->dataroot.'/lang/'.$pack.'/'.$pack.'.md5';
|
echo '<input name="displaylang" type="hidden" value="'.$displaylang.'" />';
|
||||||
if ($file = fopen($md5file, 'w')){
|
echo '<input name="confirm" type="hidden" value="1" />';
|
||||||
fwrite($file, md5($contents)); //we should not pass md5 value from moodle.org, because some sites can't fopen,, and the value will not be obtainable
|
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||||
}
|
print_heading(get_string('confirminstall','admin',$displaylang),2);
|
||||||
fclose($file);
|
echo '<input type="submit" value="'.get_string('ok').'"/>';
|
||||||
@unlink ($langpack); //remove the zip file
|
echo ' <input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
|
||||||
echo '<div align="center"><form action="langimport.php" method="POST">';
|
echo '</form>';
|
||||||
echo '<input type="submit" value="'.get_string('ok').'" />';
|
echo '</div>';
|
||||||
echo '</form></div>';
|
print_simple_box_end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
|
||||||
|
case 3: //change site language
|
||||||
|
|
||||||
|
if (confirm_sesskey){
|
||||||
|
$langconfig = get_record('config','name','lang');
|
||||||
|
$sitelang = required_param('sitelangconfig',PARAM_NOTAGS);
|
||||||
|
$langconfig->value = $sitelang;
|
||||||
|
if (update_record('config',$langconfig)){
|
||||||
|
echo '<div align="center">';
|
||||||
|
notify (get_string('sitelangchanged','admin'));
|
||||||
|
echo '<form action="langimport.php" method="POST">';
|
||||||
|
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||||
|
echo '</form></div>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error ('can not update site language');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 4: //delete a directory(ies) containing a lang pack completely
|
||||||
|
|
||||||
if (!optional_param('confirm') && confirm_sesskey()){
|
if (!optional_param('confirm') && confirm_sesskey()){
|
||||||
print_simple_box_start('center','100%');
|
print_simple_box_start('center','100%');
|
||||||
|
@ -123,21 +151,129 @@
|
||||||
echo '<input type="submit" value="'.get_string('ok').'" />';
|
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||||
echo '</form></div>';
|
echo '</form></div>';
|
||||||
}
|
}
|
||||||
else {
|
else { //nothing deleted, possibly due to permission error
|
||||||
error ('An error has occured, language pack is not completely uninstalled');
|
error ('An error has occurred, language pack is not completely uninstalled, please check file permission');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 5: //1 click update for all updatable language packs
|
||||||
|
|
||||||
|
//0th pull a list from download.moodle.org,
|
||||||
|
//key = langname, value = md5
|
||||||
|
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||||
|
$md5array = array();
|
||||||
|
$update = 0; //any packs updated?
|
||||||
|
$alllangs = array_keys(get_list_of_languages());
|
||||||
|
$lang16 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
|
||||||
|
$packs = array(); //all the packs that needs updating
|
||||||
|
|
||||||
|
if ($fp = fopen($source, 'r')){ /// attempt to get the list from Moodle.org.
|
||||||
|
while(!feof ($fp)) {
|
||||||
|
$availablelangs[] = split(',', fgets($fp,1024));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error('can not fopen!');
|
||||||
|
}
|
||||||
|
//and build an associative array
|
||||||
|
foreach ($availablelangs as $alang){
|
||||||
|
$md5array[$alang[0]] = $alang[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
//first build a list of all the language packs,
|
||||||
|
|
||||||
|
//filtering out non-16 packs
|
||||||
|
foreach ($alllangs as $clang){
|
||||||
|
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||||
|
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||||
|
|
||||||
|
if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
|
||||||
|
$lang16[] = $clang;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//then filter out packs that have the same md5 key
|
||||||
|
foreach ($lang16 as $clang){
|
||||||
|
if (!is_installed_lang($clang, $md5array[$clang])){
|
||||||
|
$packs[] = $clang;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@mkdir ($CFG->dataroot.'/temp/');
|
||||||
|
@mkdir ($CFG->dataroot.'/lang/');
|
||||||
|
foreach ($packs as $pack){ //for each of the remaining in the list, we
|
||||||
|
|
||||||
|
//1. delete old director(ies)
|
||||||
|
|
||||||
|
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||||
|
$dest2 = $CFG->dirroot.'/lang/'.$pack;
|
||||||
|
$rm1 = false;
|
||||||
|
$rm2 = false;
|
||||||
|
if (file_exists($dest1)){
|
||||||
|
$rm1 = remove_dir($dest1);
|
||||||
|
}
|
||||||
|
if (file_exists($dest2)){
|
||||||
|
$rm2 = remove_dir($dest2);
|
||||||
|
}
|
||||||
|
if (!($rm1 || $rm2)){
|
||||||
|
error ('could not delete old directory, update failed');
|
||||||
|
}
|
||||||
|
|
||||||
|
//2. copy & unzip into new
|
||||||
|
|
||||||
|
$source = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||||
|
$langpack = $CFG->dataroot.'/temp/'.$pack.'.zip';
|
||||||
|
$destination = $CFG->dataroot.'/lang/';
|
||||||
|
if ($contents = file_get_contents($source)) { // Grab whole page
|
||||||
|
if ($file = fopen($langpack, 'w')) { // Make local copy
|
||||||
|
if (!fwrite($file, $contents)){ //copy zip to temp folder..
|
||||||
|
error ('could not copy file');
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
|
||||||
|
//unpack the zip
|
||||||
|
if (!unzip_file($langpack, $destination, false)){
|
||||||
|
error('language installation failed - can not unzip language pack');
|
||||||
|
}
|
||||||
|
//now, we update the md5key of the lang pack, this is used to check version
|
||||||
|
$md5file = $CFG->dataroot.'/lang/'.$pack.'/'.$pack.'.md5';
|
||||||
|
if ($file = fopen($md5file, 'w')){
|
||||||
|
fwrite($file, md5($contents));
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
@unlink ($langpack); //remove the zip file
|
||||||
|
echo '<div align="center">';
|
||||||
|
notify(print_string('langpackupdated','admin',$pack));
|
||||||
|
$updated = 1;
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div align="center"><form action="langimport.php" method="POST">';
|
||||||
|
if ($updated){
|
||||||
|
notify(print_string('langupdatecomplete','admin'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
notify(print_string('nolangupdateneeded','admin'));
|
||||||
|
}
|
||||||
|
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||||
|
echo '</form></div>';
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default: //display choice mode
|
default: //display choice mode
|
||||||
|
|
||||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||||
$remote = 0; //flag for reading from remote or local
|
$remote = 0; //flag for reading from remote or local
|
||||||
|
|
||||||
if ($fp = fopen($source, 'r')){ /// attempt to get the list from Moodle.org.
|
if ($fp = fopen($source, 'r')){ /// attempt to get the list from Moodle.org.
|
||||||
while(!feof ($fp)) {
|
while(!feof ($fp)) {
|
||||||
$availablelangs[] = split(',', fgets($fp,1024));
|
$availablelangs[] = split(',', fgets($fp,1024));
|
||||||
}
|
}
|
||||||
$remote = 1;
|
$remote = 1; //can read from download.moodle.org
|
||||||
}
|
}
|
||||||
else { /// fopen failed, we find local copy of list.
|
else { /// fopen failed, we find local copy of list.
|
||||||
$availablelangs = get_local_list_of_languages();
|
$availablelangs = get_local_list_of_languages();
|
||||||
|
@ -146,7 +282,7 @@
|
||||||
if (!$remote){
|
if (!$remote){
|
||||||
print_simple_box_start('center','60%');
|
print_simple_box_start('center','60%');
|
||||||
echo '<div align="center">';
|
echo '<div align="center">';
|
||||||
print_string('remotelangnotavailable');
|
print_string('remotelangnotavailable','admin',$CFG->dataroot.'/lang/');
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
print_simple_box_end();
|
print_simple_box_end();
|
||||||
}
|
}
|
||||||
|
@ -157,52 +293,83 @@
|
||||||
echo '</td><td align="center">';
|
echo '</td><td align="center">';
|
||||||
echo get_string('availablelangs','admin');
|
echo get_string('availablelangs','admin');
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
echo '<tr><td align="right" valign="top">';
|
echo '<tr><td align="center" valign="top">';
|
||||||
echo '<form name="uninstallform" action="langimport.php?mode=4" method="POST">';
|
echo '<form name="uninstallform" action="langimport.php?mode=4" method="POST">';
|
||||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||||
$installedlangs = get_list_of_languages(); ///THIS FUNCTION NEEDS TO BE CHANGED
|
$installedlangs = get_list_of_languages();
|
||||||
/// display nstalled Components here
|
|
||||||
|
/// display installed langs here
|
||||||
|
|
||||||
echo '<select name="uninstalllang" size="15">';
|
echo '<select name="uninstalllang" size="15">';
|
||||||
foreach ($installedlangs as $clang =>$ilang){
|
foreach ($installedlangs as $clang =>$ilang){
|
||||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||||
}
|
}
|
||||||
echo '</select>';
|
echo '</select>';
|
||||||
echo '<input type="submit" value="'.get_string('uninstall','admin').'" />';
|
echo '<br /><input type="submit" value="'.get_string('uninstall','admin').'" />';
|
||||||
echo '</form></td><td align="center">';
|
echo '</form>';
|
||||||
|
echo '<form name="updateform" action="langimport.php?mode=5" method="POST">';
|
||||||
/// display to be installed Components here
|
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||||
//echo '<form name="langform" action="langimport.php?mode=2" method="POST">';
|
echo '</form>';
|
||||||
//echo '<input name="pack" type="hidden" value="" />';
|
echo '<p />';
|
||||||
//echo '<input name="displaylang" type="hidden" value="" />';
|
|
||||||
echo '<table>'; //availabe langs table
|
/// Display option to change site language
|
||||||
|
|
||||||
$empty = 1; //something to pring
|
print_string('changesitelang','admin');
|
||||||
/// if this language pack is not already installed, then we allow installation
|
$sitelanguage = get_record('config','name','lang');
|
||||||
|
echo '<form name="changelangform" action="langimport.php?mode=3" method="POST">';
|
||||||
///PROBLEM is can't FOPEN, then can't obtain newest MD5 to check against
|
echo '<select name="sitelangconfig">';
|
||||||
///Don't know if the version is current
|
|
||||||
|
foreach ($installedlangs as $clang =>$ilang){
|
||||||
foreach ($availablelangs as $alang){
|
if ($clang == $sitelanguage->value){
|
||||||
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
echo '<option value="'.$clang.'" selected="selected">'.$ilang.'</option>';
|
||||||
echo '<form method="POST" action="langimport.php?mode=2&pack='.$alang[0].'&displaylang='.$alang[2].'">';
|
}
|
||||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
else {
|
||||||
if ($remote){
|
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||||
echo '<tr><td>'.$alang[2].' '.$alang[0].'</td><td><input type="submit" value="'.get_string('install','admin').'"></td></tr>';
|
|
||||||
}
|
|
||||||
else { //print list in local format, and instruction to install
|
|
||||||
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang/'.$alang[0].'.zip">'.get_string('download').'</a>';
|
|
||||||
}
|
|
||||||
$empty = 0;
|
|
||||||
echo '</form>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo '</select>';
|
||||||
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||||
|
echo '<input type="submit" value="'.get_string('change','admin').'" />';
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
|
/// display to be installed langs here
|
||||||
|
|
||||||
|
echo '</td><td align="center" valign="top">';
|
||||||
|
echo '<table><tr><td valign="top" align="center">'; //availabe langs table
|
||||||
|
$empty = 1; //something to pring
|
||||||
|
|
||||||
|
/// if this language pack is not already installed, then we allow installation
|
||||||
|
|
||||||
|
echo '<form name="installform" method="POST" action="langimport.php?mode=2">';
|
||||||
|
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||||
|
if ($remote){
|
||||||
|
echo '<select name="pack" size="15">';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($availablelangs as $alang){
|
||||||
|
if ($remote){
|
||||||
|
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
||||||
|
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$alang[0].')</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { //print list in local format, and instruction to install
|
||||||
|
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang16/'.$alang[0].'.zip">'.get_string('download','admin').'</a>';
|
||||||
|
}
|
||||||
|
$empty = 0;
|
||||||
|
}
|
||||||
|
if ($remote){
|
||||||
|
echo '</select>';
|
||||||
|
echo '<br/ ><input type="submit" value="'.get_string('install','admin').'">';
|
||||||
|
}
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
if ($empty){
|
if ($empty){
|
||||||
echo '<tr><td align="center">';
|
echo '<tr><td align="center">';
|
||||||
print_string('nolanguagetodownload');
|
print_string('nolanguagetodownload');
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>'; //close available langs table
|
echo '</td><tr></table>'; //close available langs table
|
||||||
echo '<form>';
|
echo '<form>';
|
||||||
echo '</td></tr></table>';
|
echo '</td></tr></table>';
|
||||||
print_simple_box_end();
|
print_simple_box_end();
|
||||||
|
@ -217,7 +384,7 @@
|
||||||
//this is for site that can't perform fopen
|
//this is for site that can't perform fopen
|
||||||
function get_local_list_of_languages(){
|
function get_local_list_of_languages(){
|
||||||
global $CFG;
|
global $CFG;
|
||||||
$source = $CFG->wwwroot.'/lib/languages.txt';
|
$source = $CFG->wwwroot.'/lib/languages.md5';
|
||||||
$availablelangs = array();
|
$availablelangs = array();
|
||||||
if ($fp = fopen($source, 'r')){
|
if ($fp = fopen($source, 'r')){
|
||||||
while(!feof ($fp)) {
|
while(!feof ($fp)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue