From 46261e5eeb39080f47a122699f9f3ed953ce5db5 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 28 Jul 2021 15:40:56 +0000 Subject: [PATCH] wip #4623 @0.25 --- inc/ws/Controlleur/class.ws.url.php | 120 +------------------- inc/ws/DAO/class.ws.dao.lang.php | 103 ++++++++--------- inc/ws/Metier/class.ws.lang.php | 2 - inc/ws/Metier/class.ws.theme.parametres.php | 8 +- 4 files changed, 50 insertions(+), 183 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 06f9ae6cc..2699a68b9 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -691,84 +691,7 @@ class wsUrl global $core; commonDroits::min(5); - - if (count($args) < 2) { - $args[1] = 'fr'; - } - - $allLangs = cubeLang::getCodes($core->user->lang); - $allLangs['es-pr'] = 'Espagnol, Porto Rico'; - $allLangs['es-mx'] = 'Espagnol, Mexique'; - $existingLangs = array(); - - $dao = new wsDAOLang($core->con); - $langs = $dao->selectAll(); - foreach ($langs as $lang) { - if (!isset($allLangs[$lang->lang_id])) { - continue; - } - $existingLangs[$lang->lang_id] = $allLangs[$lang->lang_id]; - - unset($allLangs[$lang->lang_id]); - } - - $langs = array(__('Langues configurées') => array_flip($existingLangs), __('Autres langues') => array_flip($allLangs)); - - $res = commonPage::barre(); - $res .= commonPage::tMain(null, false); - - $res .= commonPage::bh(); - $res .= '
'; - $res .= ''; - $res .= ''; - $res .= '
' . __('Sélectionnez la langue à configurer') . ' : ' . form::combo('lang', $langs, $args[1]) . '
'; - $res .= '
'; - $res .= commonPage::bf(); - - $res .= '
'; - $res .= self::formLang($args[1]); - $res .= '
'; - $res .= commonPage::bMain(true); - - return $res; - } - - public static function formLang($lang_id) - { - commonDroits::min(5); - global $core; - $dao = new wsDAOLang($core->con); - $lang = $dao->selectById($lang_id); - - $res = commonPage::bh(); - $res .= ''; - $res .= ''; - $res .= '
' . __('Exporter au format Excel') . ''; - $res .= ' | ' . __('Exporter toutes les langues au format Excel') . ''; - $res .= '
'; - $res .= commonPage::bf(); - - $res .= '
'; - - $res .= commonPage::bh(); - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __('Police de caractères') . ' : ' . form::hidden('lang', $lang_id) . form::combo('font', self::getFonts(), $lang->font) . '
' . __('Jeux de caractères') . ' : ' . form::combo('charset', self::getCharsets(), $lang->charset) . '
' . __("Langue de l'installeur") . ' : ' . form::combo('nsis', self::getNSISLangs(), $lang->nsis) . '
' . $core->typo->Ajouter('Valider') . '
'; - $res .= commonPage::bf(); - - $res .= commonPage::bh(); - $res .= cubeLang::translationForm(self::getTranslationSources(), $lang_id, null, 'liste', array(), '' . $core->typo->Ajouter(__('Enregistrer')) . '', $lang->traductions); - $res .= commonPage::bf(); - $res .= '
'; - return $res; - } - - public static function getTranslationSources() - { - return array(__('Version HTML5') => WS_COMPILE_ASSETS . '/player/local', __('Version HTML5 GIT') => WS_COMPILE_ASSETS . '/player/branches', __('Compilateur HTML5') => ROOT . '/inc/ws/Util/html5', __('Application') => WS_COMPILE_ASSETS . '/_html5app'); + header('Location: https://toolbox.fluidbook.com/fluidbook-translate/1/edit'); } public static function exportLangAsExcel($args) @@ -871,47 +794,6 @@ class wsUrl return $lang_name; } - public static function getFonts() - { - $formats = array('ttf', 'otf', 'TTF', 'OTF'); - - $dr = opendir(FONT_PATH); - $fonts = array('Arial (police système)' => "system"); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..' || !in_array(files::getExtension($file), $formats)) { - continue; - } - $fonts[$file] = $file; - } - return $fonts; - } - - protected static function getCharsets() - { - $sets = cubeFlexFontAsset::getSets(); - $res = array(); - foreach ($sets as $k => $v) { - $res[$k] = $k; - } - return $res; - } - - protected static function getNSISLangs() - { - $res = array(); - $dir = WS_FILES . '/nsislangs'; - $dr = opendir($dir); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..') { - continue; - } - $e = explode('.', $file); - $res[$e[0]] = $e[0]; - } - - ksort($res); - return $res; - } public static function editor($args) { diff --git a/inc/ws/DAO/class.ws.dao.lang.php b/inc/ws/DAO/class.ws.dao.lang.php index d83c3c2e9..e408b045c 100644 --- a/inc/ws/DAO/class.ws.dao.lang.php +++ b/inc/ws/DAO/class.ws.dao.lang.php @@ -1,61 +1,48 @@ lang_id = mb_strtolower($r->lang_id); - $lang->font = $r->font; - $lang->charset = $r->charset; - - if ($r->nsis == '') { - $r->nsis = 'English'; - } - $lang->nsis = $r->nsis; - - if ($r->traductions == '') { - $lang->traductions = array(); - } else { - $lang->traductions = json_decode($r->traductions, true); - } - - $lang->traductions = wsLang::checkTranslations($lang->traductions); - return $lang; - } - - public function selectById($lang_id) { - $r = $this->con->select('SELECT * FROM langues WHERE lang_id=\'' . $this->con->escape($lang_id) . '\''); - return $this->singleton($r); - } - - public function selectAll() { - $r = $this->con->select('SELECT * FROM langues'); - return $this->factory($r); - } - - public function sauve($data) { - $c = $this->con->openCursor('langues'); - $c->lang_id = $data['lang_id']; - $c->font = $data['font']; - $c->charset = $data['charset']; - $c->nsis = $data['nsis']; - $traductions = array(); - foreach ($data['traductions'] as $msgid => $text) { - if (substr($msgid, 0, 4) == 'B64_') { - $msgid = base64_decode(substr($msgid, 4)); - } - $traductions[$msgid] = $text; - } - - $c->traductions = json_encode($traductions); - $r = $this->con->select('SELECT * FROM langues WHERE lang_id=\'' . $this->con->escape($c->lang_id) . '\''); - if (!$r->count()) { - $c->insert(); - } else { - $c->update('WHERE lang_id=\'' . $this->con->escape($c->lang_id) . '\''); - } - - return $this->selectById($c->lang_id); - } - +class wsDAOLang extends commonDAO +{ + + protected function singleton($r) + { + $lang = new wsLang(); + $lang->lang_id = $r['id']; + $lang->nsis = $r['nsis'] ?? 'English'; + $lang->traductions = $r['translations']; + + return $lang; + } + + public function selectById($lang_id) + { + + $res = $this->selectAll(); + return $res[$lang_id]; + } + + public function selectAll() + { + $res = []; + + $r = $this->con->select('SELECT * FROM fluidbook_toolbox.fluidbook_translate WHERE id=1'); + + $nsis = json_decode($r->nsis, true); + $contents = json_decode($r->content_translatable, true); + foreach ($contents as $id => $content) { + $code = $id; + if (stristr($code, '_')) { + $e = explode('_', $code); + $code = $e[0] . '-' . mb_strtolower($e[1]); + } + $translations = []; + foreach ($contents[$id] as $k => $v) { + $e = explode('t_', $k); + if (count($e) > 1) { + $translations[base64_decode($e[1])] = $v; + } + } + $res[$code] = $this->singleton(['id' => $code, 'nsis' => $nsis[$id], 'translations' => $translations]); + } + return $res; + } } \ No newline at end of file diff --git a/inc/ws/Metier/class.ws.lang.php b/inc/ws/Metier/class.ws.lang.php index cdc427ffb..3e6e0afb3 100644 --- a/inc/ws/Metier/class.ws.lang.php +++ b/inc/ws/Metier/class.ws.lang.php @@ -67,8 +67,6 @@ class wsLang extends cubeMetier { 'functionality dont work when in fullscreen mode' => 63, "you don't have any bookmark" => 64); protected $lang_id; - protected $font; - protected $charset; protected $traductions; protected $nsis; diff --git a/inc/ws/Metier/class.ws.theme.parametres.php b/inc/ws/Metier/class.ws.theme.parametres.php index 2e865d146..996a6a8b2 100644 --- a/inc/ws/Metier/class.ws.theme.parametres.php +++ b/inc/ws/Metier/class.ws.theme.parametres.php @@ -69,7 +69,7 @@ class wsThemeParametres extends wsParametres 'label' => __("Couleur des icônes")); $this->forms['icones'] = array('label' => __('Personnalisation des icônes'), - 'fieldsnames' => array('iconSet','couleurI')); + 'fieldsnames' => array('iconSet', 'couleurI')); /* Book */ $this->fields['interfaceFont'] = ['type' => 'combo', 'default' => 'OpenSans', 'datas' => wsBookParametres::$fonts, 'editable' => true, 'label' => __('Police de l\'interface')]; @@ -105,8 +105,8 @@ class wsThemeParametres extends wsParametres 'label' => __("Couleur de l'étoile activée")); $this->forms['book'] = array('label' => __('Personnalisation de la publication'), - 'fieldsnames' => array('interfaceFont', 'interfaceFontUppercase', '|', 'shadeAlpha', - '|', 'bookShadeColor', + 'fieldsnames' => array('interfaceFont', 'interfaceFontUppercase', '|', 'shadeAlpha', + '|', 'bookShadeColor', '|', 'usePageEdges', '|', 'displayPageNumber', 'colorPageNumber', '|', 'linksColor', 'videoBackgroundColor', '|', 'tooltipBackColor', 'tooltipTextColor', 'tooltipTextSize', @@ -166,7 +166,7 @@ class wsThemeParametres extends wsParametres ); $this->forms['menubar'] = array('label' => __('Personnalisation de la barre de menu'), - 'fieldsnames' => array('menuHeight', '|', 'menuColor', 'menuImage', '|', 'invertMenuPosition', '|', 'afterSearch')); + 'fieldsnames' => array('menuHeight', '|', 'menuColor', 'menuImage', '|', 'invertMenuPosition', '|', 'afterSearch')); /* Menu bar logo */ $imageFilter = new stdClass(); -- 2.39.5