forked from ZwiiCMS-Team/ZwiiCMS
Jquery entités
This commit is contained in:
parent
c8ea16040e
commit
a5bd94fe6e
@ -68,31 +68,32 @@ class helper
|
|||||||
/**
|
/**
|
||||||
* Fonction pour assurer la traduction des messages
|
* Fonction pour assurer la traduction des messages
|
||||||
*/
|
*/
|
||||||
public static function googleTranslate($to, $text){
|
public static function googleTranslate($to, $text)
|
||||||
|
{
|
||||||
if (!file_exists('site/i18n/' . $to . '.json')) {
|
if (!file_exists('site/i18n/' . $to . '.json')) {
|
||||||
file_put_contents ('site/i18n/' . $to . '.json', json_encode([]));
|
file_put_contents('site/i18n/' . $to . '.json', json_encode([]));
|
||||||
}
|
}
|
||||||
if (!empty($text)) {
|
if (!empty($text)) {
|
||||||
//Lecture des données en ligne
|
//Lecture des données en ligne
|
||||||
$data = json_decode(file_get_contents('site/i18n/' . $to . '.json'), true);
|
$data = json_decode(file_get_contents('site/i18n/' . $to . '.json'), true);
|
||||||
// Mode traduction
|
// Mode traduction
|
||||||
if ($to !== 'fr_FR') {
|
if ($to !== 'fr_FR') {
|
||||||
$arrayjson = json_decode(file_get_contents('https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl=' . $to . '&q=' . rawurlencode($text)),true);
|
$arrayjson = json_decode(file_get_contents('https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl=' . $to . '&q=' . rawurlencode($text)), true);
|
||||||
$response = $arrayjson[0][0];
|
$response = $arrayjson[0][0];
|
||||||
// Captation
|
// Captation
|
||||||
if ($data !== '') {
|
if ($data !== '') {
|
||||||
if (array_key_exists($text, $data) ) {
|
if (array_key_exists($text, $data)) {
|
||||||
$data[$text] = $response;
|
$data[$text] = $response;
|
||||||
} else {
|
} else {
|
||||||
$data = array_merge($data,[$text => $response]);
|
$data = array_merge($data, [$text => $response]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Mode alimentation des chaines
|
// Mode alimentation des chaines
|
||||||
} else {
|
} else {
|
||||||
// Créer la variable
|
// Créer la variable
|
||||||
$data = array_merge($data,[$text => '']);
|
$data = array_merge($data, [$text => '']);
|
||||||
}
|
}
|
||||||
file_put_contents ('site/i18n/' . $to . '.json', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX);
|
file_put_contents('site/i18n/' . $to . '.json', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,11 +448,13 @@ class helper
|
|||||||
break;
|
break;
|
||||||
case self::FILTER_ID:
|
case self::FILTER_ID:
|
||||||
$text = mb_strtolower($text, 'UTF-8');
|
$text = mb_strtolower($text, 'UTF-8');
|
||||||
$text = strip_tags(str_replace(
|
$text = strip_tags(
|
||||||
|
str_replace(
|
||||||
explode(',', 'á,à,â,ä,ã,å,ç,é,è,ê,ë,í,ì,î,ï,ñ,ó,ò,ô,ö,õ,ú,ù,û,ü,ý,ÿ,\',", '),
|
explode(',', 'á,à,â,ä,ã,å,ç,é,è,ê,ë,í,ì,î,ï,ñ,ó,ò,ô,ö,õ,ú,ù,û,ü,ý,ÿ,\',", '),
|
||||||
explode(',', 'a,a,a,a,a,a,c,e,e,e,e,i,i,i,i,n,o,o,o,o,o,u,u,u,u,y,y,-,-,-'),
|
explode(',', 'a,a,a,a,a,a,c,e,e,e,e,i,i,i,i,n,o,o,o,o,o,u,u,u,u,y,y,-,-,-'),
|
||||||
$text
|
$text
|
||||||
));
|
)
|
||||||
|
);
|
||||||
$text = preg_replace('/([^a-z0-9-])/', '', $text);
|
$text = preg_replace('/([^a-z0-9-])/', '', $text);
|
||||||
// Supprime les emoji
|
// Supprime les emoji
|
||||||
$text = preg_replace('/[[:^print:]]/', '', $text);
|
$text = preg_replace('/[[:^print:]]/', '', $text);
|
||||||
@ -539,6 +542,10 @@ class helper
|
|||||||
$css = preg_replace(['(( )+{)', '({( )+)'], '{', $css);
|
$css = preg_replace(['(( )+{)', '({( )+)'], '{', $css);
|
||||||
$css = preg_replace(['(( )+})', '(}( )+)', '(;( )*})'], '}', $css);
|
$css = preg_replace(['(( )+})', '(}( )+)', '(;( )*})'], '}', $css);
|
||||||
$css = preg_replace(['(;( )+)', '(( )+;)'], ';', $css);
|
$css = preg_replace(['(;( )+)', '(( )+;)'], ';', $css);
|
||||||
|
// Convertir les codes entités
|
||||||
|
$css = htmlspecialchars_decode($css);
|
||||||
|
// Supprime les balises HTML
|
||||||
|
$css = strip_tags($css);
|
||||||
// Retourne le css minifié
|
// Retourne le css minifié
|
||||||
return $css;
|
return $css;
|
||||||
}
|
}
|
||||||
|
@ -1044,6 +1044,7 @@ class layout extends common
|
|||||||
$inlineScript = implode($this->core->output['inlineScript']);
|
$inlineScript = implode($this->core->output['inlineScript']);
|
||||||
}
|
}
|
||||||
echo '<script defer>' . helper::minifyJs($coreScript . $this->core->output['script'] . htmlspecialchars_decode($inlineScript)) . '</script>';
|
echo '<script defer>' . helper::minifyJs($coreScript . $this->core->output['script'] . htmlspecialchars_decode($inlineScript)) . '</script>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1070,7 +1071,7 @@ class layout extends common
|
|||||||
if ($this->core->output['inlineStyle']) {
|
if ($this->core->output['inlineStyle']) {
|
||||||
foreach ($this->core->output['inlineStyle'] as $style) {
|
foreach ($this->core->output['inlineStyle'] as $style) {
|
||||||
if ($style) {
|
if ($style) {
|
||||||
echo '<style type="text/css">' . helper::minifyCss(htmlspecialchars_decode($style)) . '</style>';
|
echo '<style type="text/css">' . helper::minifyCss($style) . '</style>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user