From: vincent@cubedesigners.com Date: Tue, 30 Jun 2020 11:12:32 +0000 (+0000) Subject: wip #3747 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c3e529474fe617798a1fc056130b4adc88609686;p=cubeextranet.git wip #3747 @1 --- diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index c6a78da36..7b35ccecc 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -461,8 +461,8 @@ class wsBookParametres extends wsParametres $this->fields['product_tweet'] = array('type' => 'textarea', 'default' => '%short%', 'editable' => true, 'label' => __("Contenu Partage court"), 'hint' => __('Contenu du partagé sur les partages courts')); $this->forms['product_zoom'] = ['label' => __('Zooms produits'), 'fieldsnames' => array_merge(["product_zoom_references", '|', 'product_zoom_buttons_order'], $f, ['|', 'product_share_enabled', 'product_share_link', 'product_email_title', 'product_email_body', 'product_tweet'])]; - $this->fields['audiodescriptionTexts'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Contenus textuels pour l\'audiodescription'), 'fileFilter' => $seoFilter]; - $this->fields['audiodescriptionVoice'] = ['type' => 'combo', 'datas' => wsDroits::getTTSVoices(), 'editable' => true, 'default' => true, 'label' => __('Voix pour l\'audiodescription')]; + $this->fields['audiodescriptionTexts'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Contenus textuels pour l\'audiodescription ou les lecteurs d\'écran'), 'fileFilter' => $seoFilter]; + $this->fields['audiodescriptionVoice'] = ['type' => 'combo', 'datas' => wsDroits::getTTSVoices(), 'editable' => true, 'default' => '', 'label' => __('Voix pour l\'audiodescription')]; $this->forms['accessibility'] = ['label' => __('Accessibilité'), 'fieldsnames' => ['audiodescriptionTexts', 'audiodescriptionVoice'] ]; @@ -709,8 +709,5 @@ class wsBookParametres extends wsParametres $this->forms['downloads'] = array('label' => __('Versions disponibles au téléchargement'), 'fieldsnames' => $fields); - - } - } diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 73dc8b0d8..b67d73196 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -703,7 +703,7 @@ class wsHTML5Compiler protected function writeAccessibility() { - if ($this->book->parametres->audiodescriptionTexts == '' || $this->book->parametres->audiodescriptionVoice == '') { + if (!$this->book->parametres->audiodescriptionTexts) { return; } $file = $this->wdir . '/' . $this->book->parametres->audiodescriptionTexts; @@ -731,39 +731,41 @@ class wsHTML5Compiler $text = str_replace(array_keys($replace), array_values($replace), $text); - $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text); - $fname = $hash . '.mp3'; - $dir = WS_BOOKS . '/audiodescription/'; - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } + if( $this->book->parametres->audiodescriptionVoice) { + $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text); + $fname = $hash . '.mp3'; + $dir = WS_BOOKS . '/audiodescription/'; + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + } - $file = $dir . $fname; - if (!file_exists($file)) { - $e = explode(':', $this->book->parametres->audiodescriptionVoice); + $file = $dir . $fname; + if (!file_exists($file)) { + $e = explode(':', $this->book->parametres->audiodescriptionVoice); - $engine = $e[0]; - $voice = $e[1]; + $engine = $e[0]; + $voice = $e[1]; - if ($engine == 'festival') { - $tmp = CubeIT_Files::tempnam() . '.wav'; - $tmptext = CubeIT_Files::tempnam() . '.txt'; + if ($engine == 'festival') { + $tmp = CubeIT_Files::tempnam() . '.wav'; + $tmptext = CubeIT_Files::tempnam() . '.txt'; - file_put_contents($tmptext, $text); - $cmd = "text2wave -o $tmp $tmptext -eval \"($voice)\""; - `$cmd`; + file_put_contents($tmptext, $text); + $cmd = "text2wave -o $tmp $tmptext -eval \"($voice)\""; + `$cmd`; - `lame $tmp $file`; - unlink($tmp); - unlink($tmptext); - } else if ($engine == 'readspeaker') { - $e = explode('/', $voice); - $this->_readSpeaker($text, $e[1], $e[0], $file); + `lame $tmp $file`; + unlink($tmp); + unlink($tmptext); + } else if ($engine == 'readspeaker') { + $e = explode('/', $voice); + $this->_readSpeaker($text, $e[1], $e[0], $file); + } } - } - $this->config->audiodescription[$page] = $fname; - $this->vdir->copy($file, 'data/audiodescription/' . $fname); + $this->config->audiodescription[$page] = $fname; + $this->vdir->copy($file, 'data/audiodescription/' . $fname); + } } }