}
/**
+ * @param $version string
+ * @param $fluidbook FluidbookPublication
+ * @param $theme FluidbookTheme
+ * @param $path string
+ * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|object
* @throws \Exception
*/
public function preview($version, $fluidbook, $theme, $path = 'index.html')
$nointerface = !!request('nointerface', false);
$shortLoading = !!request('shortLoading', false);
- $dest = $fluidbook->getFinalPath($theme, $version);
+ $isScorm = $version === 'scorm';
+
+ $dest = $fluidbook->getFinalPath($theme, $isScorm);
if ($path === 'index.html') {
- $compiler = new FluidbookCompiler($fluidbook, version: $version, theme: $theme);
+ $compiler = new FluidbookCompiler($fluidbook, $isScorm, theme: $theme);
$compiler->handle();
}
- return XSendFileController::sendfile($dest . '/' . $path);
+
+ $relayPath = $dest . '/' . $path;
+ if (!file_exists($relayPath)) {
+ throw new \Exception($relayPath . ' not found');
+ }
+ return XSendFileController::sendfile($relayPath);
}
/**
$text = str_replace(array_keys($replace), array_values($replace), $text);
$text = Text::cleanUTF8($text, '');
- $voiceInfos = $data['voice'] ? !$this->fluidbookSettings->audiodescriptionVoice;
+ $voiceInfos = $data['voice'] ?: $this->fluidbookSettings->audiodescriptionVoice;
if ($voiceInfos) {
- $hash = hash('sha256', $voiceInfos . '_^_' . $text);
- $fname = $hash . '.mp3';
- $dir = WS_BOOKS . '/audiodescription/';
- if (!file_exists($dir)) {
- mkdir($dir, 0777, true);
- }
-
- $file = $dir . $fname;
+ $e = explode(':', $voiceInfos);
- if ($this->book_id === '18860' && file_exists($file)) {
- unlink($file);
+ if (count($e) === 1) {
+ $engine = 'azuretts';
+ $voice = $voiceInfos;
+ } else {
+ $engine = $e[0];
+ $voice = $e[1];
}
- if (!file_exists($file) || filesize($file) === 0) {
- $e = explode(':', $voiceInfos);s
+ $hash = hash('sha256', $engine . ':' . $voice . '_^_' . $text);
+ $fname = $hash . '.mp3';
+ $dir = Files::mkdir(protected_path('audiodescription'));
- if (count($e) === 1) {
- $engine = 'azuretts';
- $voice = $voiceInfos;
- } else {
- $engine = $e[0];
- $voice = $e[1];
- }
+ $file = $dir . $fname;
+ if (!file_exists($file) || filesize($file) === 0) {
if ($engine == 'festival') {
$tmp = Files::tempnam() . '.wav';
$tmptext = Files::tempnam() . '.txt';
$this->accessibleTexts[$page] = $text;
}
-
if (count($this->accessibleTexts) > 0) {
$this->config->accessibleTexts = $this->accessibleTexts;
}
$this->addOwnerField();
- $this->addField('type', SelectFromArray::class, __('Type'), ['column' => true, 'options' => ['export' => __('Export'), 'scorm_multilang' => __('SCORM multilingue')]]);
- $this->addField('locale_switch', Checkbox::class, __('Permettre le changement de langue'), ['when' => ['type' => 'scorm_multilang'], 'default' => true]);
+ $this->addField('type', SelectFromArray::class, __('Type'), ['column' => true, 'options' => ['export' => __('Export'), 'export_multilang' => __('Export multilingue'), 'scorm_multilang' => __('SCORM multilingue')]]);
+ $this->addField('locale_switch', Checkbox::class, __('Permettre le changement de langue'), ['when' => ['type' => ['scorm_multilang', 'export_multilang']], 'default' => true]);
$this->addField('version', FluidbookExportVersion::class, __('Version'), ['when' => ['type' => 'export']]);
$this->addField('publications', BunchOfFieldsMultiple::class, __('Publications'), ['bunch' => CollectionPublication::class, 'edit_label' => '%fluidbook > %dir']);
$this->addField('override_settings', BunchOfFieldsMultiple::class, __('Redéfinir les paramètres lors de l\'export'), ['bunch' => Fluidbook_Setting::class]);
public function getFinalPath($theme = null, $scormVariant = false)
{
$dir = $this->id;
- if (null !== $theme || ($theme instanceof FluidbookTheme && $theme->id != $this->theme)) {
- $dir .= '-';
- if (is_string($theme) || is_numeric($theme)) {
- $dir .= $theme;
- } else if ($theme instanceof FluidbookTheme) {
- $dir .= $theme->id;
- }
+
+ if (null !== $theme) {
+ $themeId = $theme instanceof FluidbookTheme ? $theme->id : $theme;
+ } else {
+ $themeId = null;
+ }
+
+ if (null !== $theme && ($themeId != $this->theme)) {
+ $dir .= '-' . $themeId;
}
return protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online'));
}