public function __construct()
 {
     parent::__construct();
     self::$tpl_regexp = '/\\{l s=\'' . _PS_TRANS_PATTERN_ . '\'( mod=\'.+\')?( js=1)?\\}/U';
     // added ? after spaces because some peoples forget them. see PSCFI-2501
     self::$php_regexp = '/->l\\(\'' . _PS_TRANS_PATTERN_ . '\'(, ?\'(.+)\')?(, ?(.+))?\\)/U';
 }
 public function __construct()
 {
     parent::__construct();
     self::$tpl_regexp = '/\\{l s=\'' . _PS_TRANS_PATTERN_ . '\'( mod=\'.+\')?( js=1)?\\}/U';
     self::$php_regexp = '/->l\\(\'' . _PS_TRANS_PATTERN_ . '\'(, \'(.+)\')?(, (.+))?\\)/U';
 }
 public function submitImportLang()
 {
     global $currentIndex;
     if (!isset($_FILES['file']['tmp_name']) or !$_FILES['file']['tmp_name']) {
         $this->_errors[] = Tools::displayError('No file selected');
     } else {
         include_once PS_ADMIN_DIR . '/../tools/pear/PEAR.php';
         include_once PS_ADMIN_DIR . '/../tools/tar/Archive_Tar.php';
         $gz = new Archive_Tar($_FILES['file']['tmp_name'], true);
         $iso_code = str_replace('.gzip', '', $_FILES['file']['name']);
         if (Validate::isLangIsoCode($iso_code)) {
             $files_list = $gz->listContent();
             $uniqid = uniqid();
             $sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
             if ($gz->extract($sandbox, false)) {
                 foreach ($files_list as $file2check) {
                     //don't validate index.php, will be overwrite when extract in translation directory
                     if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php') {
                         continue;
                     }
                     if (preg_match('@^[0-9a-z-_/\\\\]+\\.php$@i', $file2check['filename'])) {
                         if (!AdminTranslations::checkTranslationFile(file_get_contents($sandbox . $file2check['filename']))) {
                             $this->_errors[] = sprintf(Tools::displayError('Validation failed for: %s'), $file2check['filename']);
                         }
                     } elseif (is_file($sandbox . $file2check['filename']) && !preg_match('@^[0-9a-z-_/\\\\]+\\.(html|tpl|txt)$@i', $file2check['filename'])) {
                         $this->_errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']);
                     }
                 }
                 Tools::deleteDirectory($sandbox, true);
             }
             if (count($this->_errors)) {
                 return false;
             }
             if ($gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
                 $this->checkAndAddMailsFiles($iso_code, $files_list);
                 if (Validate::isLanguageFileName($_FILES['file']['name'])) {
                     if (!Language::checkAndAddLanguage($iso_code)) {
                         $conf = 20;
                     }
                 }
                 Tools::redirectAdmin($currentIndex . '&conf=' . (isset($conf) ? $conf : '15') . '&token=' . $this->token);
             } else {
                 $this->_errors[] = Tools::displayError('Archive cannot be extracted.');
             }
         } else {
             $this->_errors[] = Tools::displayError('Iso code invalid');
         }
     }
 }