diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index bc3cbe1ad..a50bb3c4a 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -937,7 +937,6 @@ class AdminTranslationsControllerCore extends AdminController $this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = html_entity_decode($GLOBALS[$name_var][$default_key], ENT_COMPAT, 'UTF-8'); else { - //d(array($module_key, $default_key, $key, $GLOBALS[$name_var])); $this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = ''; $this->missing_translations++; } @@ -1471,12 +1470,10 @@ class AdminTranslationsControllerCore extends AdminController $array_subjects = array(); if (($subjects = Tools::getValue('subject')) && is_array($subjects)) { - $array_subjects['core_and_modules'] = array('translations'=>array(), 'path'=>$arr_mail_path['core_mail'].'lang.php'); - + $array_subjects['core_and_modules'] = array('translations' => array(), 'path' => $arr_mail_path['core_mail'].'lang.php'); foreach ($subjects as $subject_translation) $array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation); } - if (!empty($array_subjects)) foreach ($array_subjects as $infos) $this->writeSubjectTranslationFile($infos['translations'], $infos['path']); @@ -2149,32 +2146,37 @@ class AdminTranslationsControllerCore extends AdminController
'; if (!empty($mails['files'])) { + $topic_already_displayed = array(); foreach ($mails['files'] as $mail_name => $mail_files) { if (array_key_exists('html', $mail_files) || array_key_exists('txt', $mail_files)) { if (array_key_exists($mail_name, $all_subject_mail)) { - $subject_mail = $all_subject_mail[$mail_name]; - $value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : ''; - $str_return .= ' -
- -
- '.$subject_mail.'
'; - if (isset($value_subject_mail['trad']) && $value_subject_mail['trad']) - $str_return .= ''; - else - $str_return .= ''; + foreach ($all_subject_mail[$mail_name] as $subject_mail) + { + $subject_key = 'subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']'; + if (in_array($subject_key, $topic_already_displayed)) + continue; + $topic_already_displayed[] = $subject_key; + $value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : ''; + $str_return .= ' +
+ +
+ '.$subject_mail.'
'; + if (isset($value_subject_mail['trad']) && $value_subject_mail['trad']) + $str_return .= ''; + else + $str_return .= ''; - if (isset($value_subject_mail['use_sprintf']) && $value_subject_mail['use_sprintf']) - { - $str_return .= ' - '.$value_subject_mail['use_sprintf'].' - '; - } + if (isset($value_subject_mail['use_sprintf']) && $value_subject_mail['use_sprintf']) + $str_return .= ' + '.$value_subject_mail['use_sprintf'].' + '; $str_return .= '
-
'; +
'; + } } else { @@ -2196,12 +2198,11 @@ class AdminTranslationsControllerCore extends AdminController } } else - { - $str_return .= ' -

'.$this->l('There was a problem getting the mail files.').'
' - .sprintf($this->l('English language files must exist in %s folder'), ''.$mails['directory'].'en') - .'

'; - } + $str_return .= '

+ '.$this->l('There was a problem getting the mail files.').'
+ '.sprintf($this->l('English language files must exist in %s folder'), ''.preg_replace('@/[a-z]{2}(/?)$@', '/en$1', $mails['directory']).'').' +

'; + $str_return .= '
@@ -2412,21 +2413,27 @@ class AdminTranslationsControllerCore extends AdminController $content = file_get_contents($dir.'/'.$file); $content = str_replace("\n", ' ', $content); + // Subject must match with a template, therefor we first grep the Mail::Send() function then the Mail::l() inside. if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab)) for ($i = 0; isset($tab[1][$i]); $i++) { $tab2 = explode(',', $tab[1][$i]); - if (is_array($tab2)) - if ($tab2 && isset($tab2[1])) - { - $tab2[1] = trim(str_replace('\'', '', $tab2[1])); - if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'/s', $tab2[2], $matches)) - $subject_mail[$tab2[1]] = $matches[1]; - } + if (is_array($tab2) && isset($tab2[1])) + { + $template = trim(str_replace('\'', '', $tab2[1])); + foreach ($tab2 as $tab3) + if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'\)/Us', $tab3.')', $matches)) + { + if (!isset($subject_mail[$template])) + $subject_mail[$template] = array(); + if (!in_array($matches[1], $subject_mail[$template])) + $subject_mail[$template][] = $matches[1]; + } + } } if (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file)) - $subject_mail = $this->getSubjectMail($dir, $file, $subject_mail); + $subject_mail = $this->getSubjectMail($dir, $file, $subject_mail); return $subject_mail; } diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index f32311554..d5a136ae3 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -180,14 +180,8 @@ class ContactControllerCore extends FrontController $id_product = (int)Tools::getValue('id_product'); - if (isset($ct) && Validate::isLoadedObject($ct)) - { - if ($ct->id_order) - $id_order = $ct->id_order; - $subject = sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token); - } - else - $subject = Mail::l('Your message has been correctly sent'); + if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) + $id_order = $ct->id_order; if ($id_order) { @@ -203,14 +197,18 @@ class ContactControllerCore extends FrontController $var_list['{product_name}'] = $product->name[Context::getContext()->language->id]; } + + + + if (empty($contact->email)) - Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, null, null, $fileAttachment); + Mail::Send($this->context->language->id, 'contact_form', ((isset($ct) && Validate::isLoadedObject($ct)) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent')), $var_list, $from, null, null, null, $fileAttachment); else { if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]', $var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment) || - !Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, $contact->email, $contact->name, $fileAttachment)) + !Mail::Send($this->context->language->id, 'contact_form', ((isset($ct) && Validate::isLoadedObject($ct)) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent')), $var_list, $from, null, $contact->email, $contact->name, $fileAttachment)) $this->errors[] = Tools::displayError('An error occurred while sending the message.'); } }