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;
use Cache;
use Search;
use Accessibility;
- use Tabs;
- use PDF;
/** @var Lock */
protected $lock;
'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',],
'android' => array('webintent'));
public $pluginCSS = [];
public $pluginJs = [];
- protected $customJs = [];
public $htmlmultimedia = [];
public $cssX = [];
public $cssY = [];
$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();
$this->config->vectorPages = array_diff(ArrayUtil::parseRange($this->config->vectorPages), $this->config->rasterizePages);
$this->numerotation = $this->config->numerotation = explode(',', $this->getFluidbook()->page_numbers);
- $this->initTabsConfig();
+ $hideOnPages = ArrayUtil::parseRange($this->config->tabsHideOnPages);
+ $this->config->tabsDisabledOnPages = ArrayUtil::parseRange($this->config->tabsDisabledOnPages);
+ 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;
}
// 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_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->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->standalone = $this->standalone;
if ($this->config->phonegap) {
if ($error) {
FluidbookHealthIssues::addIssue($this->book_id, FluidbookHealthIssues::TYPE_CHAPTER_PAGE_NOT_EXIST, ['chapter' => $chapter['label'], 'page' => $chapter['page']]);
}
+
}
}
}
$this->writeJs();
$this->log('Js written');
- //$this->vdir->setUpdateMode($this->getFluidbook()->region !== 'UE');
$this->vdir->sync(true, $this);
-
- \Cubist\Backpack\Jobs\CommandLine::dispatch("chmod -R 775 $this->dir");
+ `chmod -R 775 $this->dir`;
$this->log('Files Synced');
// $f=rtrim(str_replace('/html5/', '/compiletime/', $this->dir));
// touch($f);
}
$script = '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . 'data/datas.js' . $jstime . '"></script>' . "\n";
- foreach ($this->customJs as $c) {
- $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $c . $jstime . '"></script>' . "\n";
- }
foreach ($this->jsLibs as $jsLib => $files) {
$script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . 'data/' . $jsLib . '.js' . $jstime . '"></script>' . "\n";
}
return $variables;
}
-
- protected function replaceVariables($str)
+ protected function writePDF()
{
- $replace = ['%title%' => $this->config->title];
- return strtr($str, $replace);
+ 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 addFilesInfos($key, $file)
$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) {
$this->_addedPDFJS = true;
+
if ($renderer === 'pdfjs') {
$resource = resource_path('pdfjs/dist-min');
} else if ($renderer === 'pdfjs-legacy') {
$this->lessVariables['z'] = $this->z;
$this->lessVariables['book-page-width'] = $w;
+
$this->lessVariables['book-page-correct-width'] = $w;
$this->lessVariables['book-page-correct-height'] = $h;
+
$this->log('CSS 2');
$this->lessVariables['book-page-height'] = $h;
$this->lessVariables['book-page-ratio'] = floatval($w) / floatval($h);
if (isset($fontCapHeight) && isset($fontHeight) && is_numeric($fontCapHeight) && is_numeric($fontHeight)) {
$capHeight = $fontCapHeight / $fontHeight;
}
- $font = ['family' => $hash, 'capHeight' => $capHeight, 'ascender' => $ascender / $fontHeight, 'descender' => $descender / $fontHeight];
+ $font = ['family' => $hash, 'capHeight' => $capHeight, 'ascender' => $fontHeight > 0 ? $ascender / $fontHeight : 1, 'descender' => $fontHeight > 0 ? $descender / $fontHeight : 1];
$this->cssfont[$hash] = $font;
}
return $this->cssfont[$hash];
$form->addField('containername', Text::class, __('Nom du container'), ['prefix' => '/docker/']);
$form->addField('domain', Text::class, __('Nom du domaine ou sous-domaine'), ['placeholder' => 'containername.dev.cubedesigners.com']);
$form->addField('env', SelectFromArrayMultiple::class, __('Environnements'), ['default' => json_encode(['production', 'dev']), 'options' => ['production' => 'production', 'dev' => 'dev', 'staging' => 'staging', 'preprod' => 'preprod']]);
-
- $form->addField('laravel', Checkbox::class, __('Installer Laravel'), ['default' => true]);
- $form->addField('public', Checkbox::class, __('Racine dans le dossier "public"'), ['default' => true]);
+ $form->addField('laravel', SelectFromArray::class, __('Installer Laravel'), ['options' => ['0' => __('Non'), '5' => 'Laraval Backpack 5', '6' => 'Laravel Backpack 6'], 'default' => '5']);
+ $form->addField('public', Checkbox::class, __('Racine dans le dossier "public"'), ['default' => true, 'when' => ['laravel' => '0']]);
$form->addField('phpversion', SelectFromArray::class, __('Version de PHP'), ["options" =>
['none' => '-',
'5.6' => '5.6',
'7.4' => '7.4',
'8.2' => '8.2',
'8.3' => '8.3',
- ], 'value' => '8.3']);
- $form->addField('mysql', Checkbox::class, __('Serveur Mariadb') . ' (MySQL)', ['default' => true]);
- $form->addField('redis', Checkbox::class, __('Serveur Redis'), ['default' => true]);
+ ], 'value' => '8.3', 'when' => ['laravel' => 0]]);
+ $form->addField('mysql', Checkbox::class, __('Serveur Mariadb') . ' (MySQL)', ['default' => true, 'when' => ['laravel' => '0']]);
+ $form->addField('redis', Checkbox::class, __('Serveur Redis'), ['default' => true, 'when' => ['laravel' => '0']]);
$form->addField('matomo', Checkbox::class, __('Serveur Matomo'), ['default' => false]);
$form->addField('elasticsearch', Checkbox::class, __('Serveur ElasticSearch'), ['default' => false]);
-
return view('tools.form', ['form' => $form]);
}
$subDomain = '';
}
- $laravel = $request->get('laravel', true);
+ $laravel = $request->get('laravel', 5);
+ $phpversion = $request->get('phpversion', '8.3');
+ $mysql = $request->get('mysql', true);
+ $redis = $request->get('redis', true);
+ if ($laravel > 0) {
+ $phpversion = '8.3';
+ $redis = $mysql = true;
+ }
$variables = [
'$user' => $name,
$additionalEnv = [];
$compose = ['base'];
- $variables['$phpversion'] = $request->get('phpversion', '8.3');
+ $variables['$phpversion'] = $phpversion;
if ($variables['$phpversion'] !== 'none') {
$compose[] = 'php';
if (version_compare($variables['$phpversion'], '5.6', '<=')) {
}
$fixRights[] = 'chown 0:0 ./config/cron/crontab';
}
- if ($laravel || $request->get('mysql', true)) {
+ if ($mysql) {
$compose[] = 'mysql';
$fixRights[] = 'chown -R 999:999 ./database/data';
$additionalEnv['DB_USERNAME'] = 'root';
$additionalEnv['DB_PASSWORD'] = '$dbpassword';
}
- if ($laravel || $request->get('redis', true)) {
+ if ($redis) {
$compose[] = 'redis';
$fixRights[] = 'chown -R 999:999 ./redis';
$additionalEnv['CACHE_DRIVER'] = 'redis';
$fixRights[] = 'chmod -R 777 ./esdata';
}
- if ($request->get('laravel', true)) {
+ if ($laravel) {
$laravelSource = resource_path('tools/dockerwebcontainer/laravel');
+ $cmsbackVersion = 'dev-backpack' . $laravel;
+ if ($laravel == 5) {
+ $cmsbackVersion = 'dev-master';
+ $frameworkVersion = '10.0';
+ } else if ($laravel == 6) {
+ $frameworkVersion = '11.0';
+ }
+
$envPath = $www . '/.env';
$projectEnv = Dotenv::parse(file_get_contents($envPath));
- `rm -rf $www;composer create-project laravel/laravel $www`;
+ `rm -rf $www;composer create-project laravel/laravel:^$frameworkVersion.0 $www`;
$composerFile = $www . '/composer.json';
$composer = json_decode(file_get_contents($composerFile));
$composer->name = str_replace('-', '/', $name);
$composer->license = 'Proprietary';
$composer->keywords = [$name];
$composer->description = $name . ' project';
- $composer->require->{"cubist/cms-back"} = 'dev-backpack6';
+ $composer->require->{"cubist/cms-back"} = $cmsbackVersion;
$composer->repositories = [
['type' => 'composer', 'url' => "https://composer.cubedesigners.com/"],
['type' => 'composer', 'url' => "https://repo.backpackforlaravel.com/"]
Env::arrayToEnvFile($envPath . '.' . $env, $laravelEnv);
unlink($envPath);
unlink($envPath . '.example');
- copy($laravelSource . '/AppServiceProvider.php', $www . '/Providers/AppServiceProvider.php');
+ copy($laravelSource . '/AppServiceProvider.php', $www . '/app/Providers/AppServiceProvider.php');
}
$variables['$fixrights'] = implode("\n", $fixRights);