From: Vincent Vanwaelscappel Date: Mon, 15 Apr 2024 15:46:37 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=10dfa466adf105b22443d16c153c0dc49d79a1f3;p=fluidbook-toolbox.git . --- diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index fb9a953c9..53aff1c9e 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -3,7 +3,6 @@ namespace App\Fluidbook\Compiler; use App\Fields\FluidbookFont; -use App\Fluidbook\PDF; use App\Fluidbook\SEO\Page; use App\Fluidbook\SocialImage; use App\Http\Controllers\Admin\Operations\Tools\Favicon; @@ -51,6 +50,8 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError use Cache; use Search; use Accessibility; + use Tabs; + use PDF; /** @var Lock */ protected $lock; @@ -84,7 +85,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError 'js/libs/jquery/jquery.scrollto.min.js', ], 'aria' => ['js/libs/aria/radio.js',], - 'bluebird' => ['js/libs/bluebird.min.js'], + //'bluebird' => ['js/libs/bluebird.min.js'], 'noaccents' => ['js/libs/noaccents.js'], 'screenfull' => ['js/libs/screenfull.min.js'], 'storage' => ['js/libs/storage.js',], @@ -183,6 +184,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError 'android' => array('webintent')); public $pluginCSS = []; public $pluginJs = []; + protected $customJs = []; public $htmlmultimedia = []; public $cssX = []; public $cssY = []; @@ -323,6 +325,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError $this->dir = $this->getFluidbook()->getFinalPath($theme, $scormVariant); $this->vdir = new VirtualDirectory($this->dir); + $this->vdir->setLogger($this); $this->vdir->setErrorListener($this); $this->wdir = $this->getFluidbook()->getAssetDir(); @@ -506,17 +509,8 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError $this->config->vectorPages = array_diff(ArrayUtil::parseRange($this->config->vectorPages), $this->config->rasterizePages); $this->numerotation = $this->config->numerotation = explode(',', $this->getFluidbook()->page_numbers); - $hideOnPages = ArrayUtil::parseRange($this->config->tabsHideOnPages); - $this->config->tabsDisabledOnPages = ArrayUtil::parseRange($this->config->tabsDisabledOnPages); + $this->initTabsConfig(); - if ($this->config->tabsHideOnCover) { - $hideOnPages[] = 0; - $hideOnPages[] = 1; - } - if ($this->config->tabsHideOnLastPage) { - $hideOnPages[] = count($this->pages); - } - $this->config->tabsHideOnPages = $hideOnPages; $this->config->triggersLinks = []; $this->config->hasContentLock = false; } @@ -561,8 +555,8 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError // We need to be able to reference both navOrder and navOrderH so convert both to arrays // We also make sure there are no empty items in the arrays (see: http://php.net/manual/en/function.array-filter.php#111091) - $this->config->navOrder = array_filter(array_map('trim', explode(',', $this->config->navOrder)), 'strlen'); - $this->config->navOrderH = array_filter(array_map('trim', explode(',', $this->config->navOrderH)), 'strlen'); + $this->config->navOrder = array_values(array_filter(array_map('trim', explode(',', $this->config->navOrder)), 'strlen')); + $this->config->navOrderH = array_values(array_filter(array_map('trim', explode(',', $this->config->navOrderH)), 'strlen')); $this->config->standalone = $this->standalone; if ($this->config->phonegap) { @@ -764,8 +758,10 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError } $this->writeJs(); $this->log('Js written'); + //$this->vdir->setUpdateMode($this->getFluidbook()->region !== 'UE'); $this->vdir->sync(true, $this); - `chmod -R 775 $this->dir`; + + \Cubist\Backpack\Jobs\CommandLine::dispatch("chmod -R 775 $this->dir"); $this->log('Files Synced'); // $f=rtrim(str_replace('/html5/', '/compiletime/', $this->dir)); // touch($f); @@ -980,6 +976,9 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError } $script = '' . "\n"; + foreach ($this->customJs as $c) { + $script .= "\t" . '' . "\n"; + } foreach ($this->jsLibs as $jsLib => $files) { $script .= "\t" . '' . "\n"; } @@ -1251,26 +1250,11 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError return $variables; } - protected function writePDF() - { - if (!$this->fluidbookSettings->print && !$this->fluidbookSettings->pdf) { - return; - } - - $res = PDF::compilePDF($this->getFluidbook()); - if (!$this->config->pdfName) { - $this->config->pdfName = 'document.pdf'; - } - $this->config->pdfName = Text::removeAccents($this->config->pdfName); - if (mb_strtolower(substr($this->config->pdfName, -4)) !== '.pdf') { - $this->config->pdfName .= '.pdf'; - } - if ($res !== false) { - $this->vdir->copy($res, 'data/' . $this->config->pdfName); - } - $this->log('PDF written'); - return ''; + protected function replaceVariables($str) + { + $replace = ['%title%' => $this->config->title]; + return strtr($str, $replace); } protected function addFilesInfos($key, $file) @@ -1493,6 +1477,12 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError $this->config->content_lock = $this->content_lock; } + public function addPDFJSPageRenderer() + { + $this->vdir->copyDirectory(resource_path('pdfjs/dist-min'), 'pdfjs'); + $this->customJs[] = 'pdfjs/build/pdf.js'; + } + public function addPDFJS($force = false) { if ($this->_addedPDFJS) {