Changeset 3491:9aba899e5494 for admin/langs.php
- Timestamp:
- 01/02/17 17:03:59 (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/langs.php
r3036 r3491 31 31 } catch (Exception $e) {} 32 32 33 # Language installation function 34 $lang_install = function($file) 35 { 36 $zip = new fileUnzip($file); 37 $zip->getList(false,'#(^|/)(__MACOSX|\.svn|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 38 39 if (!preg_match('/^[a-z]{2,3}(-[a-z]{2})?$/',$zip->getRootDir())) { 40 throw new Exception(__('Invalid language zip file.')); 41 } 42 43 if ($zip->isEmpty() || !$zip->hasFile($zip->getRootDir().'/main.po')) { 44 throw new Exception(__('The zip file does not appear to be a valid Dotclear language pack.')); 45 } 46 47 48 $target = dirname($file); 49 $destination = $target.'/'.$zip->getRootDir(); 50 $res = 1; 51 52 if (is_dir($destination)) { 53 if (!files::deltree($destination)) { 54 throw new Exception(__('An error occurred during language upgrade.')); 55 } 56 $res = 2; 57 } 58 59 $zip->unzipAll($target); 60 return $res; 61 }; 62 33 63 # Delete a language pack 34 64 if ($is_writable && !empty($_POST['delete']) && !empty($_POST['locale_id'])) … … 81 111 82 112 try { 83 $ret_code = dc_lang_install($dest);113 $ret_code = $lang_install($dest); 84 114 } catch (Exception $e) { 85 115 @unlink($dest); … … 117 147 118 148 try { 119 $ret_code = dc_lang_install($dest);149 $ret_code = $lang_install($dest); 120 150 } catch (Exception $e) { 121 151 @unlink($dest); … … 266 296 dcPage::helpBlock('core_langs'); 267 297 dcPage::close(); 268 269 # Language installation function270 function dc_lang_install($file)271 {272 $zip = new fileUnzip($file);273 $zip->getList(false,'#(^|/)(__MACOSX|\.svn|\.DS_Store|\.directory|Thumbs\.db)(/|$)#');274 275 if (!preg_match('/^[a-z]{2,3}(-[a-z]{2})?$/',$zip->getRootDir())) {276 throw new Exception(__('Invalid language zip file.'));277 }278 279 if ($zip->isEmpty() || !$zip->hasFile($zip->getRootDir().'/main.po')) {280 throw new Exception(__('The zip file does not appear to be a valid Dotclear language pack.'));281 }282 283 284 $target = dirname($file);285 $destination = $target.'/'.$zip->getRootDir();286 $res = 1;287 288 if (is_dir($destination)) {289 if (!files::deltree($destination)) {290 throw new Exception(__('An error occurred during language upgrade.'));291 }292 $res = 2;293 }294 295 $zip->unzipAll($target);296 return $res;297 }
Note: See TracChangeset
for help on using the changeset viewer.