From 01d85c1a5ba36a90acbd2df5241766c5408a9a6d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 26 Sep 2023 19:38:39 +0200 Subject: [PATCH] wip #6300 @0.5 --- app/Elearning/QuizCompiler.php | 20 +++++++++++++------- app/Models/Quiz.php | 2 +- app/Models/QuizTheme.php | 2 ++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/Elearning/QuizCompiler.php b/app/Elearning/QuizCompiler.php index 8d37a472d..afa4f758b 100644 --- a/app/Elearning/QuizCompiler.php +++ b/app/Elearning/QuizCompiler.php @@ -18,6 +18,8 @@ use Cubist\Util\Data; use Cubist\Util\Files\Files; use Cubist\Util\Files\VirtualDirectory; use Cubist\Util\Graphics\Color; +use Cubist\Util\Text; +use Illuminate\Translation\Translator; use Psy\Output\Theme; use RyanChandler\Blade\Blade; use function PHPUnit\Framework\matches; @@ -85,8 +87,12 @@ class QuizCompiler extends Base $l10n = $this->data->l10n; $blade = new Blade($this->_resourcesPath() . '/views', $this->_resourcesPath() . '/cache/' . md5(rand(100000, 10000000)) . '/'); - $html = $blade->make('index', ['data' => $this->data, 'quiz' => $this->quiz, 'theme' => $this->theme, '__' => function ($str) use ($l10n) { - return $l10n[$str] ?? $str; + $html = $blade->make('index', ['data' => $this->data, 'quiz' => $this->quiz, 'theme' => $this->theme, '__' => function ($str, $replace = [], $locale = null) use ($l10n) { + $str = $l10n[$str] ?? $str; + if (!$replace) { + return $str; + } + return Text::l10nReplacements($str, $replace); }])->render(); $vdir->file_put_contents('index.html', $html); @@ -115,7 +121,7 @@ class QuizCompiler extends Base foreach ($this->theme->getFields() as $f) { if ($f instanceof \Cubist\Backpack\Magic\Fields\Files) { $path = $themePageData->getImageFile($f->getName()); - if(!$path){ + if (!$path) { continue; } $spl = new \SplFileInfo($path); @@ -205,8 +211,8 @@ class QuizCompiler extends Base protected function _font($f) { - if(!$f){ - $f='SourceSans'; + if (!$f) { + $f = 'SourceSans'; } $font = FluidbookFont::getAvailableFonts()[$f]; if ($font['font_kit']) { @@ -268,8 +274,8 @@ class QuizCompiler extends Base protected function _resourcesPath() { - if(!$this->quiz->dev_version){ - $this->quiz->dev_version='stable'; + if (!$this->quiz->dev_version) { + $this->quiz->dev_version = 'dev'; } switch ($this->quiz->dev_version) { case 'stable': diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 658335677..866f56806 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -190,7 +190,7 @@ class Quiz extends ToolboxModel $this->addField('section_intro', FormSection::class, __('Introduction')); $this->addField('intro_enable', Checkbox::class, __('Activer l\'écran d\'introduction'), ['default' => 1]); $this->addField('intro_title', Text::class, __('Titre d\'introduction'), ['when' => ['intro_enable' => ['1']]]); - $this->addField('intro_text', Textarea::class, __('Titre d\'introduction'), ['when' => ['intro_enable' => ['1']]]); + $this->addField('intro_text', Textarea::class, __('Texte d\'introduction'), ['when' => ['intro_enable' => ['1']]]); $this->addField('intro_button', Text::class, __('Texte du bouton d\'introduction'), ['when' => ['intro_enable' => ['1']]]); $this->addField('', FormSeparator::class); $this->addField('intro_custom_mobile', Checkbox::class, __('Personnaliser les textes sur Mobile'), ['when' => ['intro_enable' => ['1']]]); diff --git a/app/Models/QuizTheme.php b/app/Models/QuizTheme.php index 1e49f0822..4eb7040ef 100644 --- a/app/Models/QuizTheme.php +++ b/app/Models/QuizTheme.php @@ -179,6 +179,8 @@ class QuizTheme extends ToolboxModel $theme->nokColor = \Cubist\Util\Graphics\Color::colorToCSS($quiz->nokColor); $theme->backgroundColor = '#ffffff'; + $theme->owner = 5; + $logo = new \SplFileInfo($quiz->getFirstMediaPath($quiz->logo)); $tmp = Files::tempnam() . '.' . $logo->getExtension(); copy($logo, $tmp); -- 2.39.5