Dotclear


Ignore:
Timestamp:
01/02/17 17:03:59 (9 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Switch from functions to closures (PHP 5.3+), fix available favorites order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/langs.php

    r3036 r3491  
    3131} catch (Exception $e) {} 
    3232 
     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 
    3363# Delete a language pack 
    3464if ($is_writable && !empty($_POST['delete']) && !empty($_POST['locale_id'])) 
     
    81111 
    82112          try { 
    83                $ret_code = dc_lang_install($dest); 
     113               $ret_code = $lang_install($dest); 
    84114          } catch (Exception $e) { 
    85115               @unlink($dest); 
     
    117147 
    118148          try { 
    119                $ret_code = dc_lang_install($dest); 
     149               $ret_code = $lang_install($dest); 
    120150          } catch (Exception $e) { 
    121151               @unlink($dest); 
     
    266296dcPage::helpBlock('core_langs'); 
    267297dcPage::close(); 
    268  
    269 # Language installation function 
    270 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.

Sites map