]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6248 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Sep 2023 08:35:57 +0000 (10:35 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Sep 2023 08:35:57 +0000 (10:35 +0200)
16 files changed:
app/Fields/FluidbookTranslatedString.php
app/Http/Controllers/Admin/ElearningTranslateCrudController.php [new file with mode: 0644]
app/Http/Controllers/Admin/FluidbookTranslateCrudController.php
app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php [new file with mode: 0644]
app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php [new file with mode: 0644]
app/Http/Controllers/Admin/Operations/FluidbookTranslate/ExcelExportOperation.php [deleted file]
app/Http/Controllers/Admin/Operations/FluidbookTranslate/ExcelImportOperation.php [deleted file]
app/Http/Controllers/Admin/TranslateCrudController.php [new file with mode: 0644]
app/Models/Base/ToolboxContentTranslate.php
app/Models/ElearningTranslate.php
app/Models/FluidbookTranslate.php
resources/views/content_translate/excel_export.blade.php [new file with mode: 0644]
resources/views/content_translate/excel_import.blade.php [new file with mode: 0644]
resources/views/fluidbook_translate/excel_export.blade.php [deleted file]
resources/views/fluidbook_translate/excel_import.blade.php [deleted file]
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php

index d93de4317926d2ce9808cb352006f6c83904b3a5..3082627b9acadc53b290f198949a6c7f25fb918d 100644 (file)
@@ -23,6 +23,9 @@ class FluidbookTranslatedString extends SelectFromArray
         return self::$__options;
     }
 
+    /**
+     * @throws \JsonException
+     */
     protected function _getOptions()
     {
         $locale = 'en';
diff --git a/app/Http/Controllers/Admin/ElearningTranslateCrudController.php b/app/Http/Controllers/Admin/ElearningTranslateCrudController.php
new file mode 100644 (file)
index 0000000..78c1833
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+class ElearningTranslateCrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagicController
+{
+    use \Cubist\Backpack\Magic\Operations\CreateOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\CloneEditOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\BulkPublishOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
+       use \App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelExportOperation;
+       use \App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelImportOperation;
+
+
+
+    /*
+       __('traduction')
+       __('traductions')
+       */
+
+    protected $_modelNamespace = 'App\Models\ElearningTranslate';
+    protected $_routeURL = 'elearning-translate';
+    protected $_singular = 'traduction';
+    protected $_plural = 'traductions';
+    protected $_oneInstance= true;
+}
index 27f72e800c44f97d8add76a5c755d3381f281ac9..dd14e8d59f00c209e7aa32d5ef6db2c2373910f7 100644 (file)
@@ -12,9 +12,9 @@ class FluidbookTranslateCrudController extends \Cubist\Backpack\Magic\Controller
        use \Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
        use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
        use \Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
-       use \App\Http\Controllers\Admin\Operations\FluidbookTranslate\ExcelExportOperation;
-       use \App\Http\Controllers\Admin\Operations\FluidbookTranslate\ExcelImportOperation;
-       
+       use \App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelExportOperation;
+       use \App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelImportOperation;
+
 
 
     /*
diff --git a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php
new file mode 100644 (file)
index 0000000..66697c4
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+
+namespace App\Http\Controllers\Admin\Operations\ContentTranslate;
+
+use App\Models\FluidbookTranslate;
+use Cubist\Util\Files\Files;
+use Illuminate\Support\Facades\Route;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Protection;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+
+// __('!! Traduction de l\'interface fluidbook')
+trait ExcelExportOperation
+{
+    protected function setupExcelExportRoutes($segment, $routeName, $controller)
+    {
+
+        Route::match(['get'], $segment . '/excel/export/{locale}', $controller . '@excelExport');
+    }
+
+    protected function excelExport($locale)
+    {
+        $class = get_class($this);
+
+        $alldata = json_decode($class::find(1)->getRawOriginal('content_translatable'), true);
+
+        $t = $class::find(1);
+        if ($locale === 'en') {
+            $ref = 'fr';
+        } else {
+            $ref = 'en';
+        }
+
+        $tref = $this->_getTranslations($alldata, $ref);
+        $tr = $this->_getTranslations($alldata, $locale);
+
+        $xls = new Spreadsheet();
+
+        $worksheet = $xls->getActiveSheet();
+        $worksheet->setTitle($locale);
+
+        $worksheet->getProtection()->setSheet(true);
+        $xls->getDefaultStyle()->getProtection()->setLocked(false);
+
+        $worksheet->setCellValueByColumnAndRow(1, 1, 'ID');
+        $worksheet->setCellValueByColumnAndRow(2, 1, 'Reference string');
+        $worksheet->setCellValueByColumnAndRow(3, 1, 'Reference translation');
+        $worksheet->setCellValueByColumnAndRow(4, 1, 'Translation');
+        for ($i = 2; $i <= 4; $i++) {
+            $style = $worksheet->getStyleByColumnAndRow($i, 1);
+            $style->getAlignment()->setWrapText(true);
+            $style->getFont()->setBold(true);
+            $style->getProtection()->setLocked(Protection::PROTECTION_PROTECTED);
+        }
+
+        $row = 2;
+        foreach ($tref as $k => $v) {
+            $str = base64_decode(explode('t_', $k)[1]);
+            $worksheet->setCellValueByColumnAndRow(1, $row, $k);
+            $worksheet->setCellValueByColumnAndRow(2, $row, $str);
+            $worksheet->setCellValueByColumnAndRow(3, $row, $v);
+
+            for ($i = 1; $i <= 3; $i++) {
+                $style = $worksheet->getStyleByColumnAndRow($i, $row);
+                $style->getProtection()->setLocked(Protection::PROTECTION_PROTECTED);
+            }
+            for ($i = 2; $i <= 4; $i++) {
+                $style = $worksheet->getStyleByColumnAndRow($i, $row);
+                $style->getAlignment()->setWrapText(true);
+            }
+            $worksheet->setCellValueByColumnAndRow(4, $row, $tr[$k] ?? '');
+            $row++;
+        }
+
+        $width = 100;
+        $worksheet->getColumnDimensionByColumn(1)->setVisible(false);
+        $worksheet->getColumnDimensionByColumn(2)->setWidth($width);
+        $worksheet->getColumnDimensionByColumn(3)->setWidth($width);
+        $worksheet->getColumnDimensionByColumn(4)->setWidth($width);
+
+        $writer = new Xlsx($xls);
+        $tmp = Files::tempnam();
+        $writer->save($tmp);
+
+        return response()->download($tmp, $class::getName() . '_translate_' . $locale . '.xlsx')->deleteFileAfterSend();
+    }
+
+    protected function _getTranslations($alldata, $locale)
+    {
+        if (isset($alldata[$locale])) {
+            $data = $alldata[$locale];
+        } else {
+            $e = explode('_', $locale);
+            if (isset($alldata[$e[0]])) {
+                $data = $alldata[$e[0]];
+            } else {
+                $data = $alldata['en'];
+            }
+        }
+        $res = [];
+        foreach ($data as $k => $v) {
+            if ($k === 'k') {
+                continue;
+            }
+            $res[$k] = $v;
+        }
+        return $res;
+    }
+}
diff --git a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php
new file mode 100644 (file)
index 0000000..0f37129
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Http\Controllers\Admin\Operations\ContentTranslate;
+
+use App\Models\FluidbookTranslate;
+use App\Models\Quiz;
+use App\Models\QuizTranslation;
+use Cubist\Util\Files\Files;
+use Illuminate\Support\Facades\Route;
+use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
+use PhpOffice\PhpSpreadsheet\RichText\RichText;
+use Prologue\Alerts\Facades\Alert;
+// __('!! Traduction de l\'interface fluidbook')
+trait ExcelImportOperation
+{
+    protected function setupExcelImportRoutes($segment, $routeName, $controller)
+    {
+        Route::match(['post'], $segment . '/excel/import/{locale}', $controller . '@excelImport');
+    }
+
+    /**
+     * @throws \JsonException
+     */
+    protected function excelImport($locale)
+    {
+        $file = $_FILES['file'];
+
+        if ($file['error']) {
+            Alert::warning('No file were imported')->flash();
+            return;
+        }
+
+        $reader = new Xlsx();
+        $xls = $reader->load($file['tmp_name']);
+        $sheet = $xls->getActiveSheet();
+
+        $existingTranslation = FluidbookTranslate::getFluidbookTranslation($locale);
+
+
+        $translations = [];
+        $count = 0;
+        $updated = 0;
+        foreach ($sheet->getRowIterator(2) as $row) {
+            $ri = $row->getRowIndex();
+            $k = $sheet->getCellByColumnAndRow(1, $ri)->getValue();
+            if (!FluidbookTranslate::isKey($k)) {
+                continue;
+            }
+
+            $v = $sheet->getCellByColumnAndRow(4, $ri)->getValue();
+            if($v instanceof RichText){
+                $v=$v->getPlainText();
+            }
+
+            if (!isset($existingTranslation[$k]['translation']) || $v != $existingTranslation[$k]['translation']) {
+                $translations[$k] = $v;
+                $updated++;
+            }
+            $count++;
+        }
+
+
+        if (!$count) {
+            Alert::warning('No translation were find')->flash();
+        } elseif (!$updated) {
+            Alert::warning('No translation were updated')->flash();
+        } else {
+            FluidbookTranslate::updateFluidbookTranslation($locale, $translations);
+            Alert::success('<b>' . $updated . ' translations</b> were updated (' . $count . ' total)')->flash();
+        }
+        return redirect($this->crud->route . '/1/edit/?locale=' . $locale);
+    }
+}
diff --git a/app/Http/Controllers/Admin/Operations/FluidbookTranslate/ExcelExportOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookTranslate/ExcelExportOperation.php
deleted file mode 100644 (file)
index 8b67bbb..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Admin\Operations\FluidbookTranslate;
-
-use App\Models\FluidbookTranslate;
-use Cubist\Util\Files\Files;
-use Illuminate\Support\Facades\Route;
-use PhpOffice\PhpSpreadsheet\Spreadsheet;
-use PhpOffice\PhpSpreadsheet\Style\Protection;
-use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-// __('!! Traduction de l\'interface fluidbook')
-trait ExcelExportOperation
-{
-    protected function setupExcelExportRoutes($segment, $routeName, $controller)
-    {
-
-        Route::match(['get'], $segment . '/excel/export/{locale}', $controller . '@excelExport');
-    }
-
-    protected function excelExport($locale)
-    {
-        $alldata = json_decode(FluidbookTranslate::find(1)->getRawOriginal('content_translatable'), true);
-
-        $t = FluidbookTranslate::find(1);
-        if ($locale === 'en') {
-            $ref = 'fr';
-        } else {
-            $ref = 'en';
-        }
-
-        $tref = $this->_getTranslations($alldata, $ref);
-        $tr = $this->_getTranslations($alldata, $locale);
-
-        $xls = new Spreadsheet();
-
-        $worksheet = $xls->getActiveSheet();
-        $worksheet->setTitle($locale);
-
-        $worksheet->getProtection()->setSheet(true);
-        $xls->getDefaultStyle()->getProtection()->setLocked(false);
-
-        $worksheet->setCellValueByColumnAndRow(1, 1, 'ID');
-        $worksheet->setCellValueByColumnAndRow(2, 1, 'Reference string');
-        $worksheet->setCellValueByColumnAndRow(3, 1, 'Reference translation');
-        $worksheet->setCellValueByColumnAndRow(4, 1, 'Translation');
-        for ($i = 2; $i <= 4; $i++) {
-            $style = $worksheet->getStyleByColumnAndRow($i, 1);
-            $style->getAlignment()->setWrapText(true);
-            $style->getFont()->setBold(true);
-            $style->getProtection()->setLocked(Protection::PROTECTION_PROTECTED);
-        }
-
-        $row = 2;
-        foreach ($tref as $k => $v) {
-            $str = base64_decode(explode('t_', $k)[1]);
-            $worksheet->setCellValueByColumnAndRow(1, $row, $k);
-            $worksheet->setCellValueByColumnAndRow(2, $row, $str);
-            $worksheet->setCellValueByColumnAndRow(3, $row, $v);
-
-            for ($i = 1; $i <= 3; $i++) {
-                $style = $worksheet->getStyleByColumnAndRow($i, $row);
-                $style->getProtection()->setLocked(Protection::PROTECTION_PROTECTED);
-            }
-            for ($i = 2; $i <= 4; $i++) {
-                $style = $worksheet->getStyleByColumnAndRow($i, $row);
-                $style->getAlignment()->setWrapText(true);
-            }
-            $worksheet->setCellValueByColumnAndRow(4, $row, $tr[$k] ?? '');
-            $row++;
-        }
-
-        $width = 100;
-        $worksheet->getColumnDimensionByColumn(1)->setVisible(false);
-        $worksheet->getColumnDimensionByColumn(2)->setWidth($width);
-        $worksheet->getColumnDimensionByColumn(3)->setWidth($width);
-        $worksheet->getColumnDimensionByColumn(4)->setWidth($width);
-
-        $writer = new Xlsx($xls);
-        $tmp = Files::tempnam();
-        $writer->save($tmp);
-
-        return response()->download($tmp, 'fluidbook_translate_' . $locale . '.xlsx')->deleteFileAfterSend();
-    }
-
-    protected function _getTranslations($alldata, $locale)
-    {
-        if (isset($alldata[$locale])) {
-            $data = $alldata[$locale];
-        } else {
-            $e = explode('_', $locale);
-            if (isset($alldata[$e[0]])) {
-                $data = $alldata[$e[0]];
-            } else {
-                $data = $alldata['en'];
-            }
-        }
-        $res = [];
-        foreach ($data as $k => $v) {
-            if ($k === 'k') {
-                continue;
-            }
-            $res[$k] = $v;
-        }
-        return $res;
-    }
-}
diff --git a/app/Http/Controllers/Admin/Operations/FluidbookTranslate/ExcelImportOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookTranslate/ExcelImportOperation.php
deleted file mode 100644 (file)
index 62fdbcf..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Admin\Operations\FluidbookTranslate;
-
-use App\Models\FluidbookTranslate;
-use App\Models\Quiz;
-use App\Models\QuizTranslation;
-use Cubist\Util\Files\Files;
-use Illuminate\Support\Facades\Route;
-use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
-use PhpOffice\PhpSpreadsheet\RichText\RichText;
-use Prologue\Alerts\Facades\Alert;
-// __('!! Traduction de l\'interface fluidbook')
-trait ExcelImportOperation
-{
-    protected function setupExcelImportRoutes($segment, $routeName, $controller)
-    {
-        Route::match(['post'], $segment . '/excel/import/{locale}', $controller . '@excelImport');
-    }
-
-    /**
-     * @throws \JsonException
-     */
-    protected function excelImport($locale)
-    {
-        $file = $_FILES['file'];
-
-        if ($file['error']) {
-            Alert::warning('No file were imported')->flash();
-            return;
-        }
-
-        $reader = new Xlsx();
-        $xls = $reader->load($file['tmp_name']);
-        $sheet = $xls->getActiveSheet();
-
-        $existingTranslation = FluidbookTranslate::getFluidbookTranslation($locale);
-
-
-        $translations = [];
-        $count = 0;
-        $updated = 0;
-        foreach ($sheet->getRowIterator(2) as $row) {
-            $ri = $row->getRowIndex();
-            $k = $sheet->getCellByColumnAndRow(1, $ri)->getValue();
-            if (!FluidbookTranslate::isKey($k)) {
-                continue;
-            }
-
-            $v = $sheet->getCellByColumnAndRow(4, $ri)->getValue();
-            if($v instanceof RichText){
-                $v=$v->getPlainText();
-            }
-
-            if (!isset($existingTranslation[$k]['translation']) || $v != $existingTranslation[$k]['translation']) {
-                $translations[$k] = $v;
-                $updated++;
-            }
-            $count++;
-        }
-
-
-        if (!$count) {
-            Alert::warning('No translation were find')->flash();
-        } elseif (!$updated) {
-            Alert::warning('No translation were updated')->flash();
-        } else {
-            FluidbookTranslate::updateFluidbookTranslation($locale, $translations);
-            Alert::success('<b>' . $updated . ' translations</b> were updated (' . $count . ' total)')->flash();
-        }
-        return redirect($this->crud->route . '/1/edit/?locale=' . $locale);
-    }
-}
diff --git a/app/Http/Controllers/Admin/TranslateCrudController.php b/app/Http/Controllers/Admin/TranslateCrudController.php
new file mode 100644 (file)
index 0000000..9764a9c
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+class TranslateCrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagicController
+{
+    use \Cubist\Backpack\Magic\Operations\CreateOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\CloneEditOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\BulkPublishOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
+       use \Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
+       
+
+
+    /*
+       __('traduction')
+       __('traductions')
+       */
+
+    protected $_modelNamespace = 'App\Models\Base\ToolboxContentTranslate';
+    protected $_routeURL = 'translate';
+    protected $_singular = 'traduction';
+    protected $_plural = 'traductions';
+    protected $_oneInstance= true;
+}
index 70495f79f39cac2ed1f8067461ae85742b3faff7..96cbaebd403c7e3f9f5cbbf4d7c7f73894850784 100644 (file)
@@ -2,9 +2,11 @@
 
 namespace App\Models\Base;
 
-use App\Models\ElearningTranslate;
-use App\Models\FluidbookTranslate;
+use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelExportOperation;
+use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelImportOperation;
+use Cubist\Backpack\Facades\App;
 use Cubist\Backpack\Magic\Models\Translate;
+use Cubist\Util\PHP;
 use Illuminate\Support\Facades\Cache;
 
 class ToolboxContentTranslate extends Translate
@@ -12,12 +14,30 @@ class ToolboxContentTranslate extends Translate
 
     protected static $_allTranslations = null;
 
-    protected static $_name = 'content';
+    protected static string $_name = 'content';
+
+    protected $_operations = [ExcelExportOperation::class, ExcelImportOperation::class];
+
+    public function __construct(array $attributes = [])
+    {
+        PHP::neverStop();
+
+        $this->_availableLocales = \Cubist\Locale\Locale::getList(App::getLocale());
+        $this->addEditAction('content_translate.excel_export');
+        $this->addEditAction('content_translate.excel_import');
+
+        parent::__construct($attributes);
+    }
+
+    public static function getName()
+    {
+        return static::$_name;
+    }
 
 
     protected function _getLanguageFile($locale)
     {
-        return self::getLanguageFile($locale);
+        return static::getLanguageFile($locale);
     }
 
     public static function getLanguageFile($locale)
@@ -59,12 +79,12 @@ class ToolboxContentTranslate extends Translate
 
             });
         }
-        return self::$_allTranslations;
+        return static::$_allTranslations;
     }
 
     public static function getCompiledTranslations()
     {
-        $raw = self::getAllTranslations();
+        $raw = static::getAllTranslations();
         $res = [];
         foreach ($raw as $code => $data) {
             $res[$code] = [];
@@ -97,13 +117,11 @@ class ToolboxContentTranslate extends Translate
     /**
      * @param string $locale
      * @return array[]|null
-     * @throws \JsonException
      */
-    public static function getTranslation($locale)
+    public static function getLocaleTranslations($locale)
     {
-        $all = static::getAllTranslations();
-        $res = $all[$locale] ?? null;
-        return $res;
+        $all = static::getAllTranslations(false);
+        return $all[$locale] ?? [];
     }
 
 }
index 6a5655aabd6ef860a0fbb2ada00a58870d57cbf4..6abe4c46509c07e2cfa8cd4323a2c32eb89addb8 100644 (file)
@@ -3,8 +3,8 @@
 
 namespace App\Models;
 
-use App\Http\Controllers\Admin\Operations\FluidbookTranslate\ExcelExportOperation;
-use App\Http\Controllers\Admin\Operations\FluidbookTranslate\ExcelImportOperation;
+use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelExportOperation;
+use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelImportOperation;
 use App\Models\Base\ToolboxContentTranslate;
 use App\Models\Traits\QuizBranches;
 use Cubist\Backpack\Facades\App;
@@ -17,7 +17,7 @@ class ElearningTranslate extends ToolboxContentTranslate
     use QuizBranches;
 
     protected $table = 'elearning_translate';
-    protected static $_name='elearning';
+    protected static string $_name='elearning';
 
     protected $_enableRevisions = false;
 
@@ -29,17 +29,6 @@ class ElearningTranslate extends ToolboxContentTranslate
     protected $_operations = [ExcelExportOperation::class, ExcelImportOperation::class];
 
 
-    public function __construct(array $attributes = [])
-    {
-        PHP::neverStop();
-
-        $this->_availableLocales = \Cubist\Locale\Locale::getList(App::getLocale());
-        $this->addEditAction('elearning_translate.excel_export');
-        $this->addEditAction('elearning_translate.excel_import');
-
-        parent::__construct($attributes);
-    }
-
     public function getPaths()
     {
         $res = [];
index ea8bde0f7505ba804294af0e9705a7d74abeb131..34df1d4e5884577c7d967998a0959b3c4a34f97a 100644 (file)
@@ -4,8 +4,8 @@
 namespace App\Models;
 
 use App\Fields\NSISLocale;
-use App\Http\Controllers\Admin\Operations\FluidbookTranslate\ExcelExportOperation;
-use App\Http\Controllers\Admin\Operations\FluidbookTranslate\ExcelImportOperation;
+use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelExportOperation;
+use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelImportOperation;
 use App\Models\Base\ToolboxContentTranslate;
 use App\Models\Traits\FluidbookPlayerBranches;
 use Cubist\Backpack\Facades\App;
@@ -19,7 +19,7 @@ class FluidbookTranslate extends ToolboxContentTranslate
     use FluidbookPlayerBranches;
 
     protected $table = 'fluidbook_translate';
-    protected static $_name = 'elearning';
+    protected static string $_name = 'elearning';
 
     protected static $_allTranslations = null;
 
@@ -30,20 +30,6 @@ class FluidbookTranslate extends ToolboxContentTranslate
         'plural' => 'traductions',
         'oneinstance' => true];
 
-    protected $_operations = [ExcelExportOperation::class, ExcelImportOperation::class];
-
-
-    public function __construct(array $attributes = [])
-    {
-        PHP::neverStop();
-
-        $this->_availableLocales = \Cubist\Locale\Locale::getList(App::getLocale());
-        $this->addEditAction('fluidbook_translate.excel_export');
-        $this->addEditAction('fluidbook_translate.excel_import');
-
-        parent::__construct($attributes);
-    }
-
     public function setFields()
     {
         $this->addField(['name' => 'nsis', 'type' => NSISLocale::class, 'label' => __('Langue de l\'installeur') . ' (' . __('Version offline windows') . ')', 'translatable' => true, 'default' => 'English']);
@@ -67,7 +53,7 @@ class FluidbookTranslate extends ToolboxContentTranslate
     {
         return static::getAllTranslations($force);
     }
-    
+
     /**
      * @param string $locale
      * @return array[]|null
@@ -75,7 +61,7 @@ class FluidbookTranslate extends ToolboxContentTranslate
      */
     public static function getFluidbookTranslation($locale)
     {
-        return static::getTranslation($locale);
+        return static::getLocaleTranslations($locale);
     }
 
 }
diff --git a/resources/views/content_translate/excel_export.blade.php b/resources/views/content_translate/excel_export.blade.php
new file mode 100644 (file)
index 0000000..5fef725
--- /dev/null
@@ -0,0 +1,5 @@
+{{-- __('!! Traduction des fluidbooks') --}}
+<a href="{{$crud->route}}/excel/export/{{request()->get('locale',app()->getLocale())}}"
+   class="btn btn-outline-notice"><span
+        class="la la-file-excel"></span> {{__('Export Excel')}}</a>
+
diff --git a/resources/views/content_translate/excel_import.blade.php b/resources/views/content_translate/excel_import.blade.php
new file mode 100644 (file)
index 0000000..e0fee16
--- /dev/null
@@ -0,0 +1,29 @@
+{{-- __('!! Traduction des fluidbooks') --}}
+@push("after_form")
+<form method="post" style="visibility: hidden;width: 0;height: 0;" enctype="multipart/form-data" action="{{$crud->route}}/excel/import/{{request()->get('locale',app()->getLocale())}}"
+      style="visibility:hidden;height:1px;position:absolute;top:0;" id="uploadimportform">
+    @csrf
+    <input type="file" name="file" id="uploadimport"
+           accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
+</form>
+@endpush
+
+<button class="btn btn-outline-notice" id="uploadimportbutton"><span
+        class="la la-file-excel"></span> {{__('Import Excel')}}</button>
+
+@push('after_scripts')
+    <script>
+        (function ($) {
+            $(function () {
+                $(document).on('click', "#uploadimportbutton", function () {
+                    $("#uploadimport").click();
+                    return false;
+                });
+
+                $(document).on('change', '#uploadimportform', function () {
+                    $("#uploadimportform").submit();
+                })
+            });
+        })(jQuery);
+    </script>
+@endpush
diff --git a/resources/views/fluidbook_translate/excel_export.blade.php b/resources/views/fluidbook_translate/excel_export.blade.php
deleted file mode 100644 (file)
index 5fef725..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{{-- __('!! Traduction des fluidbooks') --}}
-<a href="{{$crud->route}}/excel/export/{{request()->get('locale',app()->getLocale())}}"
-   class="btn btn-outline-notice"><span
-        class="la la-file-excel"></span> {{__('Export Excel')}}</a>
-
diff --git a/resources/views/fluidbook_translate/excel_import.blade.php b/resources/views/fluidbook_translate/excel_import.blade.php
deleted file mode 100644 (file)
index e0fee16..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-{{-- __('!! Traduction des fluidbooks') --}}
-@push("after_form")
-<form method="post" style="visibility: hidden;width: 0;height: 0;" enctype="multipart/form-data" action="{{$crud->route}}/excel/import/{{request()->get('locale',app()->getLocale())}}"
-      style="visibility:hidden;height:1px;position:absolute;top:0;" id="uploadimportform">
-    @csrf
-    <input type="file" name="file" id="uploadimport"
-           accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
-</form>
-@endpush
-
-<button class="btn btn-outline-notice" id="uploadimportbutton"><span
-        class="la la-file-excel"></span> {{__('Import Excel')}}</button>
-
-@push('after_scripts')
-    <script>
-        (function ($) {
-            $(function () {
-                $(document).on('click', "#uploadimportbutton", function () {
-                    $("#uploadimport").click();
-                    return false;
-                });
-
-                $(document).on('change', '#uploadimportform', function () {
-                    $("#uploadimportform").submit();
-                })
-            });
-        })(jQuery);
-    </script>
-@endpush
index c588e3fffff372e375fd2b7ac1de93b21b3e0799..b94f683a7f5d75ab43308ced415ae660aefcd03e 100644 (file)
                 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('quiz-theme') }}"><i
                             class="la la-palette nav-icon"></i> {{__('Thèmes')}}</a></li>
             @endcan
-            @can('quiztranslation:read')
-                <li class="nav-item"><a class="nav-link" href="{{ backpack_url('quiztranslation') }}"><i
-                            class="la la-language nav-icon"></i> {{__('Traductions')}}</a></li>
-            @endcan
+
             <li class="nav-divider"></li>
             @can('elearning-media:read')
                 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('elearning-media') }}"><i
                 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('elearning-package') }}"><i
                             class="la la-cubes nav-icon"></i> {{__('Package')}}</a></li>
             @endcan
-
+            @can('quiztranslation:read')
+                <li class="nav-item"><a class="nav-link" href="{{ backpack_url('elearning-translate') }}"><i
+                            class="la la-language nav-icon"></i> {{__('Traductions')}}</a></li>
+            @endcan
         </ul>
     </li>
 @endcanany