// replaced api by www in Language class and AdminTranslationsController
// better error message when suhosin or max_input_vars exceeded in Translations forms // cleanning/comments code in email translations functions
This commit is contained in:
+17
-3
@@ -30,8 +30,22 @@
|
||||
|
||||
<h2>{l s='Language'} : {$lang} - {$translation_type}</h2>
|
||||
{l s='Errors to translate'} : <b>{$count}</b>
|
||||
{$limit_warning}
|
||||
{if !$suoshin_exceeded}
|
||||
{if $post_limit_exceeded}
|
||||
<div class="warn">
|
||||
{if $limit_warning['error_type'] == 'suhosin'}
|
||||
{l s='Warning, your hosting provider is using the suhosin patch for PHP, which limits the maximum number of fields to post in a form:'}
|
||||
|
||||
<b>{$limit_warning['post.max_vars']}</b>{l s='for suhosin.post.max_vars.'}<br/>
|
||||
<b>{$limit_warning['request.max_vars']}</b> {l s='for suhosin.request.max_vars.'}<br/>
|
||||
{l s='Please ask your hosting provider to increase the suhosin post and request limit to'}
|
||||
{else}
|
||||
{l s='Warning, your PHP configuration limits the maximum number of fields to post in a form:'}<br/>
|
||||
<b>{$limit_warning['max_input_vars']}</b> {l s='for max_input_vars.'}<br/>
|
||||
{l s='Please ask your hosting provider to increase the this limit to'}
|
||||
{/if}
|
||||
<u><b>{$limit_warning['needed_limit']}</b></u> {l s='at least.'} {l s='or edit the translation file manually.'}
|
||||
</div>
|
||||
{else}
|
||||
<form method="post" id="{$table}_form" action="{$url_submit}" class="form">
|
||||
{*{$auto_translate}$*}
|
||||
<input type="hidden" name="lang" value="{$lang}" />
|
||||
@@ -48,4 +62,4 @@
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
{/block}
|
||||
{/block}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
{l s='Expressions to translate'} : <b>{$count}</b>.
|
||||
<div class="hint" style="display:block;">{l s='Click on the titles to open fieldsets'}.</div><br /><br />
|
||||
<p>{l s='total missing expresssions:'} {$missing_translations|array_sum} </p>
|
||||
{if $post_limit_exceeded == true}
|
||||
{if $post_limit_exceeded}
|
||||
<div class="warn">
|
||||
{if $limit_warning['error_type'] == 'suhosin'}
|
||||
{l s='Warning, your hosting provider is using the suhosin patch for PHP, which limits the maximum number of fields to post in a form:'}
|
||||
|
||||
+17
-2
@@ -31,8 +31,23 @@
|
||||
{$tinyMCE}
|
||||
|
||||
<h2>{l s='Language'} : {$lang} - {$translation_type}</h2>
|
||||
{if $post_limit_exceeded}
|
||||
<div class="warn">
|
||||
{if $limit_warning['error_type'] == 'suhosin'}
|
||||
{l s='Warning, your hosting provider is using the suhosin patch for PHP, which limits the maximum number of fields to post in a form:'}
|
||||
|
||||
<b>{$limit_warning['post.max_vars']}</b>{l s='for suhosin.post.max_vars.'}<br/>
|
||||
<b>{$limit_warning['request.max_vars']}</b> {l s='for suhosin.request.max_vars.'}<br/>
|
||||
{l s='Please ask your hosting provider to increase the suhosin post and request limit to'}
|
||||
{else}
|
||||
{l s='Warning, your PHP configuration limits the maximum number of fields to post in a form:'}<br/>
|
||||
<b>{$limit_warning['max_input_vars']}</b> {l s='for max_input_vars.'}<br/>
|
||||
{l s='Please ask your hosting provider to increase the this limit to'}
|
||||
{/if}
|
||||
<u><b>{$limit_warning['needed_limit']}</b></u> {l s='at least.'} {l s='or edit the translation file manually.'}
|
||||
</div>
|
||||
{else}
|
||||
<div class="hint" style="display:block;">{l s='Click on the titles to open fieldsets'}.</div><br />
|
||||
{if !$suoshin_exceeded}
|
||||
<form method="post" id="{$table}_form" action="{$url_submit}" class="form">
|
||||
{$toggle_button}
|
||||
<input type="hidden" name="lang" value="{$lang}" />
|
||||
@@ -62,4 +77,4 @@
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
{/block}
|
||||
{/block}
|
||||
|
||||
@@ -634,13 +634,13 @@ class LanguageCore extends ObjectModel
|
||||
return true;
|
||||
else
|
||||
{
|
||||
if (@fsockopen('api.prestashop.com', 80))
|
||||
if (@fsockopen('www.prestashop.com', 80))
|
||||
{
|
||||
$lang = new Language();
|
||||
$lang->iso_code = $iso_code;
|
||||
$lang->active = true;
|
||||
|
||||
if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code)))
|
||||
if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code)))
|
||||
{
|
||||
if (isset($lang_pack->name)
|
||||
&& isset($lang_pack->version)
|
||||
@@ -653,7 +653,7 @@ class LanguageCore extends ObjectModel
|
||||
|
||||
if ($lang_pack)
|
||||
{
|
||||
$flag = Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
if ($flag != null && !preg_match('/<body>/', $flag))
|
||||
{
|
||||
$file = fopen(dirname(__FILE__).'/../img/l/'.$insert_id.'.jpg', 'w');
|
||||
|
||||
@@ -498,7 +498,7 @@ class AdminLanguagesControllerCore extends AdminController
|
||||
$this->status = 'error';
|
||||
$this->errors[] = '[TECHNICAL ERROR] ps_version not set or empty';
|
||||
}
|
||||
if (@fsockopen('api.prestashop.com', 80))
|
||||
if (@fsockopen('www.prestashop.com', 80))
|
||||
{
|
||||
// Get all iso code available
|
||||
$lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']);
|
||||
|
||||
@@ -29,7 +29,7 @@ define ('TEXTAREA_SIZED', 70);
|
||||
|
||||
class AdminTranslationsControllerCore extends AdminController
|
||||
{
|
||||
protected $link_lang_pack = 'http://api.prestashop.com/download/lang_packs/get_each_language_pack.php';
|
||||
protected $link_lang_pack = 'http://www.prestashop.com/download/lang_packs/get_each_language_pack.php';
|
||||
protected $total_expression = 0;
|
||||
protected $all_iso_lang = array();
|
||||
protected $modules_translations = array();
|
||||
@@ -62,7 +62,16 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
public function initContent()
|
||||
{
|
||||
if ($type = Tools::getValue('type'))
|
||||
$this->content .= $this->{'initForm'.ucfirst($type)}(Tools::strtolower(Tools::getValue('lang')));
|
||||
{
|
||||
$method_name = 'initForm'.$type;
|
||||
if (method_exists($this, $method_name))
|
||||
$this->content .= $this->{$method_name}(Tools::strtolower(Tools::getValue('lang')));
|
||||
else
|
||||
{
|
||||
$this->errors[] = sprintf(Tools::displayError('"%s" does not exists. Maybe you typed the url manually.'), $type);
|
||||
$this->content .= $this->initMain();
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->content .= $this->initMain();
|
||||
|
||||
@@ -316,7 +325,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
if (Validate::isLangIsoCode($arr_import_lang[0]))
|
||||
{
|
||||
if ($content = Tools::file_get_contents(
|
||||
'http://api.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.$arr_import_lang[0].'.gzip', false,
|
||||
'http://www.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.$arr_import_lang[0].'.gzip', false,
|
||||
@stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5)))))
|
||||
{
|
||||
$file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip';
|
||||
@@ -1120,14 +1129,17 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
continue;
|
||||
preg_match_all('/Tools::displayError\(\''._PS_TRANS_PATTERN_.'\'(, (true|false))?\)/U', fread(fopen($fn, 'r'), filesize($fn)), $matches);
|
||||
foreach ($matches[1] as $key)
|
||||
{
|
||||
$stringToTranslate[$key] = (key_exists(md5($key), $_ERRORS)) ? html_entity_decode($_ERRORS[md5($key)], ENT_COMPAT, 'UTF-8') : '';
|
||||
$this->total_expression++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tpl_view_vars = array(
|
||||
'lang' => Tools::strtoupper($lang),
|
||||
'translation_type' => $this->l('Error translations'),
|
||||
'count' => count($stringToTranslate),
|
||||
'limit_warning' => $this->displayLimitPostWarning($count),
|
||||
'count' => $this->total_expression,
|
||||
'limit_warning' => $this->displayLimitPostWarning($this->total_expression),
|
||||
'post_limit_exceeded' => $this->post_limit_exceed,
|
||||
'url_submit' => self::$currentIndex.'&submitTranslationsErrors=1&token='.$this->token,
|
||||
'auto_translate' => '',
|
||||
@@ -1244,11 +1256,15 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$type = substr($email_file, strripos($email_file, '.') + 1);
|
||||
if (!isset($arr_return['files'][$email_name]))
|
||||
$arr_return['files'][$email_name] = array();
|
||||
// $email_file is from scandir ($dir), so we already know that file exists
|
||||
$arr_return['files'][$email_name][$type]['en'] = $this->getMailContent($dir, $email_file, 'en');
|
||||
|
||||
// check if the file exists in the language to translate
|
||||
if (file_exists($dir.$lang.'/'.$email_file))
|
||||
{
|
||||
$arr_return['files'][$email_name][$type][$lang] = $this->getMailContent($dir, $email_file, $lang);
|
||||
$this->total_expression++;
|
||||
}
|
||||
else
|
||||
$arr_return['files'][$email_name][$type][$lang] = '';
|
||||
|
||||
@@ -1259,6 +1275,9 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// @todo : allow to translate when english is missing
|
||||
$this->warnings[] = sprintf(Tools::displayError('mail directory exists for %1$s but not for english in %s'), $lang, str_replace(_PS_ROOT_DIR_, '', $dir));
|
||||
return $arr_return;
|
||||
}
|
||||
|
||||
@@ -1490,6 +1509,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
foreach ($modules_has_mails as $module_name => $module_path)
|
||||
{
|
||||
$module_mails[$module_name] = $this->getMailFiles($module_path.'/mails/', $lang, 'module_mail');
|
||||
// @todo : all subjects (for core and modules name) are currently saved in mails/$lang/lang.php instead of module directory
|
||||
$module_mails[$module_name]['subject'] = $core_mails['subject'];
|
||||
$module_mails[$module_name]['display'] = $this->displayMailContent($module_mails[$module_name], $subject_mail, $obj_lang, Tools::strtolower($module_name), sprintf($this->l('E-mails for %s module'), '<em>'.$module_name.'</em>'), $module_name);
|
||||
}
|
||||
@@ -1541,6 +1561,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$this->tpl_view_vars = array(
|
||||
'lang' => Tools::strtoupper($lang),
|
||||
'translation_type' => $this->l('E-mail template translations'),
|
||||
'limit_warning' => $this->displayLimitPostWarning($this->total_expression),
|
||||
'post_limit_exceeded' => $this->post_limit_exceed,
|
||||
'url_submit' => self::$currentIndex.'&submitTranslationsMails=1&token='.$this->token,
|
||||
'toggle_button' => $this->displayToggleButton(),
|
||||
@@ -1595,10 +1616,11 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
if (Tools::file_exists_cache($directory.'/lang.php'))
|
||||
{
|
||||
// we need to include this even if already included
|
||||
// we need to include this even if already included (no include once)
|
||||
include($directory.'/lang.php');
|
||||
foreach ($_LANGMAIL as $key => $subject)
|
||||
{
|
||||
$this->total_expression++;
|
||||
$subject = str_replace('\n', ' ', $subject);
|
||||
$subject = str_replace("\\'", "\'", $subject);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user