From 436c8dffcfc7f3d3e67ae4c258d8be317cb6ddfa Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Wed, 21 Dec 2005 00:57:46 +0000 Subject: [PATCH] . --- admin/langimport.php | 62 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/admin/langimport.php b/admin/langimport.php index 62546f6b6af..321c31ee9ad 100755 --- a/admin/langimport.php +++ b/admin/langimport.php @@ -12,8 +12,9 @@ include('../config.php'); $mode = optional_param('mode',0,PARAM_INT); //phase - $pack = optional_param('pack',PARAM_ALPHAEXT); //pack to install - $displaylang = optional_param('displaylang',PARAM_ALPHA); //display language + $pack = optional_param('pack','',PARAM_ALPHAEXT); //pack to install + $displaylang = optional_param('displaylang','',PARAM_ALPHA); //display language + $uninstalllang = optional_param('uninstalllang','',PARAM_ALPHA); require_login(); if (!isadmin()) { @@ -32,7 +33,7 @@ print_simple_box_start('center','100%'); echo '
'; - echo '
'; + echo ''; echo ''; echo ''; print_heading(get_string('confirm').' '.$displaylang,2); @@ -58,7 +59,9 @@ fclose($file); ///recursively remove the whole directory since unzip does not overwrites anything - remove_dir($destination.$pack.'/'); + if (file_exists($destination.$pack)){ + @remove_dir($destination.$pack.'/'); + } //unpack the zip if (unzip_file($langpack, $destination, false)){ print_heading(get_string('success')); @@ -71,14 +74,47 @@ } fclose($file); @unlink ($langpack); //remove the zip file - echo '
'; + echo '
'; echo ''; echo '
'; } } break; + case 4: + if (!optional_param('confirm')){ + echo $uninstalllang; + print_simple_box_start('center','100%'); + echo '
'; + echo '
'; + echo ''; + echo ''; + print_heading(get_string('confirm').' '.get_string('uninstall').$uninstalllang,2); + echo ''; + echo ' '; + echo '
'; + echo '
'; + print_simple_box_end(); + } + else { + $dest1 = $CFG->dataroot.'/lang/'.$uninstalllang; + $dest2 = $CFG->dirroot.'/lang/'.$uninstalllang; + if (file_exists($dest1)){ + @remove_dir($dest1); + } + if (file_exists($dest2)){ + @remove_dir($dest2); + } + //delete the direcotries + echo '
'; + print_string('langpackremoved'); + echo '
'; + echo ''; + echo '
'; + } + break; + default: //display choice mode $source = 'http://download.moodle.org/lang/list.txt'; @@ -108,19 +144,20 @@ echo get_string('availablelangs'); echo ''; echo ''; + echo '
'; $installedlangs = get_list_of_languages(); ///THIS FUNCTION NEEDS TO BE CHANGED /// display nstalled Components here - echo ''; - foreach ($installedlangs as $ilang){ - echo ''; + foreach ($installedlangs as $clang =>$ilang){ + echo ''; } echo ''; - - echo ''; + echo ''; + echo '
'; /// display to be installed Components here - echo '
'; + echo ''; echo ''; echo ''; echo ''; //availabe langs table @@ -150,7 +187,6 @@ echo '
'; //close available langs table echo ''; - echo ''; print_simple_box_end(); @@ -164,7 +200,7 @@ //this is for site that can't perform fopen function get_local_list_of_languages(){ global $CFG; - $source = $CFG->wwwroot.'/blah.txt'; + $source = $CFG->wwwroot.'/lib/languages.txt'; $availablelangs = array(); if ($fp = fopen($source, 'r')){ while(!feof ($fp)) {