]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6300 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Sep 2023 17:38:39 +0000 (19:38 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Sep 2023 17:38:39 +0000 (19:38 +0200)
app/Elearning/QuizCompiler.php
app/Models/Quiz.php
app/Models/QuizTheme.php

index 8d37a472dfd25c8657dfc6bf8759caeee7b5c0ac..afa4f758badd59d299c991bf6c07f7788ea6cb19 100644 (file)
@@ -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':
index 65833567753cf9cffd9fdcc74108dcdff8710de3..866f5680619f117aa2c075b193217eb5601f4280 100644 (file)
@@ -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']]]);
index 1e49f0822b476c81b057cb6e4dde1b8f9abc6397..4eb7040ef5e5944f960e8ce7fb4f15557468df17 100644 (file)
@@ -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);