Deleted: Core class code for system translations to a new pr and removed from this branch
Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
@@ -82,7 +82,6 @@ class LanguageCore extends ObjectModel
|
||||
'errors' => '_ERRORS',
|
||||
'admin' => '_LANGADM',
|
||||
'pdf' => '_LANGPDF',
|
||||
'class' => '_LANGCLASS',
|
||||
'tabs' => 'tabs',
|
||||
);
|
||||
|
||||
@@ -276,7 +275,7 @@ class LanguageCore extends ObjectModel
|
||||
$mPath_to = _PS_MAIL_DIR_.(string)$iso_to.'/';
|
||||
}
|
||||
|
||||
$lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php', 'class.php', 'tabs.php');
|
||||
$lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php', 'tabs.php');
|
||||
|
||||
// Added natives mails files
|
||||
$mFiles = array(
|
||||
|
||||
@@ -1122,25 +1122,6 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
|
||||
return ((is_array($_FIELDS) && array_key_exists($key, $_FIELDS)) ? ($htmlentities ? htmlentities($_FIELDS[$key], ENT_QUOTES, 'utf-8') : $_FIELDS[$key]) : $field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a translation for this core class.
|
||||
* Strings translated via Localization > Translations > Core class translations.
|
||||
*
|
||||
* @param string $string String to translate (must be a literal for the scanner)
|
||||
* @param string $class Class context (defaults to calling class)
|
||||
* @return string
|
||||
*/
|
||||
public static function l($string, $class = null)
|
||||
{
|
||||
if (!$class) {
|
||||
$class = get_called_class();
|
||||
if (substr($class, -4) === 'Core') {
|
||||
$class = substr($class, 0, -4);
|
||||
}
|
||||
}
|
||||
return Translate::getClassTranslation($string, $class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.0.1 Use validateController() instead
|
||||
* @param bool $htmlentities
|
||||
|
||||
@@ -275,42 +275,6 @@ class TranslateCore
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a translation for a core class (used via ObjectModel::l())
|
||||
*
|
||||
* @param string $string String to translate
|
||||
* @param string $class Class name (e.g. 'Order', 'HotelBookingDetail')
|
||||
* @param bool $addslashes
|
||||
* @param bool $htmlentities
|
||||
* @return string
|
||||
*/
|
||||
public static function getClassTranslation($string, $class = '', $addslashes = false, $htmlentities = false)
|
||||
{
|
||||
global $_LANGCLASS;
|
||||
|
||||
$iso = Context::getContext()->language->iso_code;
|
||||
if (empty($iso)) {
|
||||
$iso = Language::getIsoById((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
}
|
||||
|
||||
$file = _PS_TRANSLATIONS_DIR_.$iso.'/class.php';
|
||||
if (!isset($_LANGCLASS) && file_exists($file)) {
|
||||
include_once($file);
|
||||
}
|
||||
|
||||
$string = preg_replace("/\\\*'/", "\'", $string);
|
||||
$key = md5($string);
|
||||
|
||||
$str = (isset($_LANGCLASS) && is_array($_LANGCLASS) && array_key_exists($class.$key, $_LANGCLASS))
|
||||
? $_LANGCLASS[$class.$key]
|
||||
: $string;
|
||||
|
||||
if ($addslashes) {
|
||||
return addslashes($str);
|
||||
}
|
||||
return $htmlentities ? htmlspecialchars(stripslashes($str), ENT_QUOTES, 'utf-8') : stripslashes($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if string use a specif syntax for sprintf and replace arguments if use it
|
||||
*
|
||||
@@ -427,12 +391,6 @@ class TranslateCore
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?(\s*pdf=\'true\')?\s*\}/U';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'class':
|
||||
// Parsing core class files for self::l() calls only
|
||||
// ClassName::l() is intentionally excluded to avoid matching Mail::l() and similar
|
||||
$regex = '/(?:self)::l\((\')'._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_array($regex)) {
|
||||
|
||||
@@ -333,10 +333,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$to_insert = $GLOBALS['_LANGPDF'];
|
||||
break;
|
||||
|
||||
case 'class':
|
||||
$to_insert = $GLOBALS['_LANGCLASS'];
|
||||
break;
|
||||
|
||||
}
|
||||
foreach ($to_insert as $key => $value) {
|
||||
if (in_array($key, $keysToUpdate)) {
|
||||
@@ -1233,20 +1229,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$directories['php'] = Translate::listFiles(_PS_CLASS_DIR_, array(), 'php');
|
||||
break;
|
||||
|
||||
case 'class':
|
||||
$directories['php'] = Translate::listFiles(_PS_CLASS_DIR_, array(), 'php');
|
||||
$directories['php'] = array_merge($directories['php'], Translate::listFiles(_PS_OVERRIDE_DIR_.'classes/', array(), 'php'));
|
||||
// Remove classes/pdf/ and classes/helper/ — those subdirs have dedicated translation
|
||||
// types (pdf and back) that write to pdf.php and admin.php respectively.
|
||||
// self::l() there resolves to HTMLTemplate::l() / Helper::l(), not ObjectModel::l().
|
||||
foreach (array_keys($directories['php']) as $dir) {
|
||||
if (strpos($dir, DIRECTORY_SEPARATOR.'pdf'.DIRECTORY_SEPARATOR) !== false
|
||||
|| strpos($dir, DIRECTORY_SEPARATOR.'helper'.DIRECTORY_SEPARATOR) !== false) {
|
||||
unset($directories['php'][$dir]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pdf':
|
||||
$tpl_theme = Tools::file_exists_cache(_PS_THEME_SELECTED_DIR_.'pdf/') ? scandir(_PS_THEME_SELECTED_DIR_.'pdf/') : array();
|
||||
$directories = array(
|
||||
@@ -1335,12 +1317,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
'dir' => _PS_TRANSLATIONS_DIR_.$this->lang_selected->iso_code.'/',
|
||||
'file' => 'pdf.php'
|
||||
),
|
||||
'class' => array(
|
||||
'name' => $this->l('Core class translations'),
|
||||
'var' => '_LANGCLASS',
|
||||
'dir' => _PS_TRANSLATIONS_DIR_.$this->lang_selected->iso_code.'/',
|
||||
'file' => 'class.php'
|
||||
),
|
||||
'mails' => array(
|
||||
'name' => $this->l('Email templates translations'),
|
||||
'var' => '_LANGMAIL',
|
||||
@@ -1498,7 +1474,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
|
||||
}
|
||||
} elseif (Tools::isSubmit('submitTranslationsBack') || Tools::isSubmit('submitTranslationsErrors') || Tools::isSubmit('submitTranslationsFields') || Tools::isSubmit('submitTranslationsFront') || Tools::isSubmit('submitTranslationsClass')) {
|
||||
} elseif (Tools::isSubmit('submitTranslationsBack') || Tools::isSubmit('submitTranslationsErrors') || Tools::isSubmit('submitTranslationsFields') || Tools::isSubmit('submitTranslationsFront')) {
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
$this->writeTranslationFile();
|
||||
} else {
|
||||
@@ -1836,65 +1812,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
/**
|
||||
* This method generate the form for back translations
|
||||
*/
|
||||
public function initFormClass()
|
||||
{
|
||||
$name_var = $this->translations_informations[$this->type_selected]['var'];
|
||||
$GLOBALS[$name_var] = $this->fileExists();
|
||||
$missing_translations = array();
|
||||
$missing_translations_found = array();
|
||||
$tabs_array = array();
|
||||
|
||||
$files_per_directory = $this->getFileToParseByTypeTranslation();
|
||||
|
||||
foreach ($files_per_directory['php'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/^(.*)\.php$/', $file) && Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, Translate::$ignore_folder)) {
|
||||
$prefix_key = basename($file, '.php');
|
||||
|
||||
$content = file_get_contents($file_path);
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, 'php');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
if (isset($GLOBALS[$name_var][$prefix_key.md5($key)])) {
|
||||
$tabs_array[$prefix_key][$key]['trad'] = stripslashes(html_entity_decode($GLOBALS[$name_var][$prefix_key.md5($key)], ENT_COMPAT, 'UTF-8'));
|
||||
} else {
|
||||
if (!isset($tabs_array[$prefix_key][$key]['trad'])) {
|
||||
$tabs_array[$prefix_key][$key]['trad'] = '';
|
||||
if (!isset($missing_translations[$prefix_key])) {
|
||||
$missing_translations[$prefix_key] = 1;
|
||||
$missing_translations_found[$prefix_key] = array();
|
||||
$missing_translations_found[$prefix_key][] = $key;
|
||||
} elseif (!in_array($key, $missing_translations_found[$prefix_key])) {
|
||||
$missing_translations[$prefix_key]++;
|
||||
$missing_translations_found[$prefix_key][] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($tabs_array as $array) {
|
||||
$count += count($array);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars = array_merge($this->tpl_view_vars, array(
|
||||
'count' => $count,
|
||||
'cancel_url' => $this->context->link->getAdminLink('AdminTranslations'),
|
||||
'limit_warning' => $this->displayLimitPostWarning($count),
|
||||
'mod_security_warning' => Tools::apacheModExists('mod_security'),
|
||||
'tabsArray' => $tabs_array,
|
||||
'missing_translations' => $missing_translations
|
||||
));
|
||||
|
||||
$this->initToolbar();
|
||||
$this->base_tpl_view = 'translation_form.tpl';
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
public function initFormBack()
|
||||
{
|
||||
$name_var = $this->translations_informations[$this->type_selected]['var'];
|
||||
|
||||
Reference in New Issue
Block a user