]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
V 0.1.8 Chapter
authorHamatoma <author@hamatoma.de>
Sat, 20 Apr 2024 15:51:27 +0000 (17:51 +0200)
committerHamatoma <author@hamatoma.de>
Sat, 20 Apr 2024 15:51:27 +0000 (17:51 +0200)
Added
- TextProcessor
- Modul Chapter
- ModuleGaDeKuSeeder.php, SPropertyAudioSeeder.php

19 files changed:
CHANGELOG.md
app/Helpers/TextProcessor.php [new file with mode: 0644]
app/Http/Controllers/ChapterController.php [new file with mode: 0644]
app/Models/Chapter.php [new file with mode: 0644]
composer.lock
database/migrations/2024_04_19_184315_create_chapters_table.php [new file with mode: 0644]
database/seeders/ChapterSeeder.php [new file with mode: 0644]
database/seeders/ModuleGaDeKuSeeder.php [new file with mode: 0644]
database/seeders/SPropertyAudioSeeder.php [new file with mode: 0644]
lang/de_DE.json
missing.seeders
public/css/gadeku.css
resources/lang/sources/gadeku.de.json
resources/views/chapter/create.blade.php [new file with mode: 0644]
resources/views/chapter/edit.blade.php [new file with mode: 0644]
resources/views/chapter/index.blade.php [new file with mode: 0644]
resources/views/chapter/show.blade.php [new file with mode: 0644]
resources/views/chapter/showpretty.blade.php [new file with mode: 0644]
routes/web.php

index 60d33d6e193dfe2f6457da0b0472a462801580dc..f422fdfc7cdb69e79cdd08549b648a69c9542168 100644 (file)
@@ -1,3 +1,11 @@
+# V 0.1.8 Chapter
+
+## Added
+- TextProcessor
+- Modul Chapter
+- ModuleGaDeKuSeeder.php, SPropertyAudioSeeder.php
+
+
 # V 0.1.7 Übersetzungen in Words
 
 ## Added:
diff --git a/app/Helpers/TextProcessor.php b/app/Helpers/TextProcessor.php
new file mode 100644 (file)
index 0000000..e6ff8bb
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace App\Helpers;
+
+class TextProcessor
+{
+    public static function markupToHtml(string $text): string
+    {
+        $rc = '';
+        $pos = 0;
+        while (true) {
+            if (($end = strpos($text, "\r\n\r\n", $pos)) !== false) {
+                $text2 = substr($text, $pos, $end);
+                $rc .= self::sentenceToHtml($text2);
+                $pos = $end + 4;
+            } else {
+                $text2 = substr($text, $pos);
+                if (!empty(trim($text2))) {
+                    $rc .= self::sentenceToHtml($text2);
+                }
+                break;
+            }
+        }
+        return $rc;
+    }
+    public static function sentenceToHtml(string $text): string
+    {
+        $text2 = preg_replace_callback(
+            '/%trans\((.*?)(\|.*?)?\)%/',
+            function ($hit) {
+                $text = $hit[1];
+                $info = count($hit) == 2 ? $text : substr($hit[2], 1);
+                $rc = "<b data-toggle=\"tooltip\" data-placement=\"top\" title=\"$info\">$text</b>";
+                return $rc;
+            },
+            $text
+        );
+        $rc = "<p>$text2</p>\n";
+        return $rc;
+    }
+    public static function starToTrans(string $text): string
+    {
+        $rc = preg_replace('/\*(\w[^*]+\w)\*/', '%trans($1)%', $text);
+        return $rc;
+    }
+}
diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php
new file mode 100644 (file)
index 0000000..6138b74
--- /dev/null
@@ -0,0 +1,235 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Helpers\FileHelper;
+use App\Models\File;
+use App\Models\Module;
+use App\Helpers\Helper;
+use App\Models\Chapter;
+use App\Helpers\DbHelper;
+use App\Models\SProperty;
+use App\Helpers\Pagination;
+use App\Helpers\ViewHelper;
+use Illuminate\Http\Request;
+use App\Helpers\TextProcessor;
+use App\Helpers\ContextLaraKnife;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Route;
+use Illuminate\Support\Facades\Validator;
+
+class ChapterController extends Controller
+{
+    /**
+     * Show the form for creating a new resource.
+     */
+    public function create(Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/chapter-index');
+        } else {
+            $fields = $request->all();
+            if (count($fields) === 0) {
+                $records = DB::select('select max(`order`) as maxorder from chapters');
+                $order = intval(($records[0]->maxorder + 10) / 10) * 10;
+                $fields = [
+                    'order' => $order,
+                    'title' => '',
+                    'info' => '',
+                    'contents' => ''
+                ];
+            }
+            $context = new ContextLaraKnife($request, $fields);
+            $rc = view('chapter.create', [
+                'context' => $context,
+            ]);
+        }
+        return $rc;
+    }
+    /**
+     * Show the form for editing the specified resource.
+     */
+    public function edit(Chapter $chapter, Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/chapter-index');
+        } else {
+            $fields = $request->all();
+            if (count($fields) === 0) {
+                $file = $chapter->audio_id == null ? '' : File::find($chapter->audio_id)->filename;
+                $fields = [
+                    'order' => '',
+                    'title' => '',
+                    'info' => '',
+                    'contents' => '',
+                    'file' => $file
+                ];
+            }
+            $context = new ContextLaraKnife($request, $fields, $chapter);
+            $rc = view('chapter.edit', [
+                'context' => $context,
+            ]);
+        }
+        return $rc;
+    }
+    /**
+     * Remove the specified resource from storage.
+     */
+    public function destroy(Chapter $chapter, Request $request)
+    {
+        if ($request->btnSubmit === 'btnDelete') {
+            $chapter->delete();
+        }
+        return redirect('/chapter-index');
+    }
+    /**
+     * Display the database records of the resource.
+     */
+    public function index(Request $request)
+    {
+        if ($request->btnSubmit === 'btnNew') {
+            return redirect('/chapter-create');
+        } else {
+            $sql = 'SELECT t0.*'
+                . ' FROM chapters t0'
+            ;
+            $parameters = [];
+            $fields = $request->all();
+            if (count($fields) == 0) {
+                $fields = [
+                    'order' => '',
+                    'title' => '',
+                    'info' => '',
+                    'contents' => '',
+                    '_sortParams' => 'order:asc;id:asc'
+                ];
+            } else {
+                $conditions = [];
+                ViewHelper::addConditionPattern($conditions, $parameters, 'title,info,contents', 'text');
+                $sql = DbHelper::addConditions($sql, $conditions);
+            }
+            $sql = DbHelper::addOrderBy($sql, $fields['_sortParams']);
+            $pagination = new Pagination($sql, $parameters, $fields);
+            $records = $pagination->records;
+            $context = new ContextLaraKnife($request, $fields);
+            return view('chapter.index', [
+                'context' => $context,
+                'records' => $records,
+                'pagination' => $pagination
+            ]);
+        }
+    }
+    /**
+     * Returns the validation rules.
+     * @return array<string, string> The validation rules.
+     */
+    private function rules(bool $isCreate = false): array
+    {
+        $rc = [
+            'order' => 'required',
+            'title' => 'required',
+            'info' => '',
+            'contents' => 'required'
+        ];
+        return $rc;
+    }
+    public static function routes()
+    {
+        Route::get('/chapter-index', [ChapterController::class, 'index'])->middleware('auth');
+        Route::post('/chapter-index', [ChapterController::class, 'index'])->middleware('auth');
+        Route::get('/chapter-create', [ChapterController::class, 'create'])->middleware('auth');
+        Route::put('/chapter-store', [ChapterController::class, 'store'])->middleware('auth');
+        Route::post('/chapter-edit/{chapter}', [ChapterController::class, 'edit'])->middleware('auth');
+        Route::get('/chapter-edit/{chapter}', [ChapterController::class, 'edit'])->middleware('auth');
+        Route::post('/chapter-update/{chapter}', [ChapterController::class, 'update'])->middleware('auth');
+        Route::get('/chapter-show/{chapter}/delete', [ChapterController::class, 'show'])->middleware('auth');
+        Route::delete('/chapter-show/{chapter}/delete', [ChapterController::class, 'destroy'])->middleware('auth');
+        Route::get('/chapter-showpretty/{chapter}', [ChapterController::class, 'showPretty'])->middleware('auth');
+        Route::post('/chapter-showpretty/{chapter}', [ChapterController::class, 'showPretty'])->middleware('auth');
+    }
+    /**
+     * Display the specified resource.
+     */
+    public function show(Chapter $chapter, Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/chapter-index')->middleware('auth');
+        } else {
+            $context = new ContextLaraKnife($request, null, $chapter);
+            $rc = view('chapter.show', [
+                'context' => $context,
+                'mode' => 'delete'
+            ]);
+        }
+        return $rc;
+    }
+
+    public function showPretty(Chapter $chapter, Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/chapter-index')->middleware('auth');
+        } else {
+            $text = TextProcessor::markupToHtml($chapter->contents);
+            $link = $chapter->audio_id == null ? null : File::relativeFileLink($chapter->audio_id);
+            $context = new ContextLaraKnife($request, ['text' => $text, 'link' => $link], $chapter);
+            $rc = view('chapter.showpretty', [
+                'context' => $context,
+                'mode' => 'delete'
+            ]);
+        }
+        return $rc;
+
+    }
+    /**
+     * Store a newly created resource in storage.
+     */
+    public function store(Request $request)
+    {
+        $rc = null;
+        if ($request->btnSubmit === 'btnStore') {
+            $fields = $request->all();
+            $validator = Validator::make($fields, $this->rules(true));
+            if ($validator->fails()) {
+                $rc = back()->withErrors($validator)->withInput();
+            } else {
+                $validated = $validator->validated();
+                $validated['info'] = strip_tags($validated['info']);
+                $validated['contents'] = TextProcessor::starToTrans($validated['contents']);
+                Chapter::create($validated);
+            }
+        }
+        if ($rc == null) {
+            $rc = redirect('/chapter-index');
+        }
+        return $rc;
+    }
+    /**
+     * Update the specified resource in storage.
+     */
+    public function update(Chapter $chapter, Request $request)
+    {
+        $rc = null;
+        if ($request->btnSubmit === 'btnStore') {
+            $fields = $request->all();
+            $validator = Validator::make($fields, $this->rules(false));
+            if ($validator->fails()) {
+                $rc = back()->withErrors($validator)->withInput();
+            } else {
+                $validated = $validator->validated();
+                $validated['info'] = strip_tags($validated['info']);
+                $validated['contents'] = strip_tags($validated['contents']);
+                if (empty($chapter->audio_id) && $request->file('file') != null) {
+                    $filename = FileHelper::textToFilename($chapter->title);
+                    $moduleId = Module::idOfModule('chapter');
+                    $fileId = File::storeFile($request, $chapter->title, 1103, 1091, 'audio file of chapter', $filename, $moduleId , $chapter->id);
+                    $validated['audio_id'] = $fileId;
+                }
+                $chapter->update($validated);
+            }
+        }
+        if ($rc == null) {
+            $rc = redirect('/chapter-index');
+        }
+        return $rc;
+    }
+}
diff --git a/app/Models/Chapter.php b/app/Models/Chapter.php
new file mode 100644 (file)
index 0000000..cd8f508
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\DB;
+use Hamatoma\Laraknife\ViewHelpers;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+
+class Chapter extends Model
+{
+    use HasFactory;
+    protected $table = 'chapters';
+    protected $fillable = [
+        'order',
+        'title',
+        'info',
+        'contents',
+        'audio_id'
+    ];
+}
index 6c22dbffc506d55b263d039bfde2f3f6388ad15f..daa434ea843f9ce038f0add06756a5719d98f445 100644 (file)
             "dist": {
                 "type": "path",
                 "url": "../laraknife",
-                "reference": "0578f3c7527bb061c7671f3d9f9ffe2db04688f9"
+                "reference": "ffcc3fc697cf5ca157890c042061fa5f4f884aa2"
             },
             "require-dev": {
                 "phpunit/phpunit": "11.0.x-dev"
         },
         {
             "name": "laravel/framework",
-            "version": "v11.3.1",
+            "version": "v11.4.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/framework.git",
-                "reference": "3b87d0767e9cbddec46480d883010ba720e50dea"
+                "reference": "c1dc67c28811dc5be524a30b18f29ce62126716a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/framework/zipball/3b87d0767e9cbddec46480d883010ba720e50dea",
-                "reference": "3b87d0767e9cbddec46480d883010ba720e50dea",
+                "url": "https://api.github.com/repos/laravel/framework/zipball/c1dc67c28811dc5be524a30b18f29ce62126716a",
+                "reference": "c1dc67c28811dc5be524a30b18f29ce62126716a",
                 "shasum": ""
             },
             "require": {
                 "fruitcake/php-cors": "^1.3",
                 "guzzlehttp/guzzle": "^7.8",
                 "guzzlehttp/uri-template": "^1.0",
-                "laravel/prompts": "^0.1.15",
+                "laravel/prompts": "^0.1.18",
                 "laravel/serializable-closure": "^1.3",
                 "league/commonmark": "^2.2.1",
                 "league/flysystem": "^3.8.0",
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2024-04-10T15:13:49+00:00"
+            "time": "2024-04-16T14:38:51+00:00"
         },
         {
             "name": "laravel/prompts",
-            "version": "v0.1.18",
+            "version": "v0.1.19",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/prompts.git",
-                "reference": "3b5e6b03f1f1175574b5a32331d99c9819da9848"
+                "reference": "0ab75ac3434d9f610c5691758a6146a3d1940c18"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/prompts/zipball/3b5e6b03f1f1175574b5a32331d99c9819da9848",
-                "reference": "3b5e6b03f1f1175574b5a32331d99c9819da9848",
+                "url": "https://api.github.com/repos/laravel/prompts/zipball/0ab75ac3434d9f610c5691758a6146a3d1940c18",
+                "reference": "0ab75ac3434d9f610c5691758a6146a3d1940c18",
                 "shasum": ""
             },
             "require": {
             ],
             "support": {
                 "issues": "https://github.com/laravel/prompts/issues",
-                "source": "https://github.com/laravel/prompts/tree/v0.1.18"
+                "source": "https://github.com/laravel/prompts/tree/v0.1.19"
             },
-            "time": "2024-04-04T17:41:50+00:00"
+            "time": "2024-04-16T14:20:35+00:00"
         },
         {
             "name": "laravel/serializable-closure",
         },
         {
             "name": "spatie/laravel-permission",
-            "version": "6.4.0",
+            "version": "6.7.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/spatie/laravel-permission.git",
-                "reference": "05cce017fe3ac78f60a3fce78c07fe6e8e6e6e52"
+                "reference": "17607924aa0aa89bc0153c2ce45ed7c55083367b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/05cce017fe3ac78f60a3fce78c07fe6e8e6e6e52",
-                "reference": "05cce017fe3ac78f60a3fce78c07fe6e8e6e6e52",
+                "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/17607924aa0aa89bc0153c2ce45ed7c55083367b",
+                "reference": "17607924aa0aa89bc0153c2ce45ed7c55083367b",
                 "shasum": ""
             },
             "require": {
             ],
             "support": {
                 "issues": "https://github.com/spatie/laravel-permission/issues",
-                "source": "https://github.com/spatie/laravel-permission/tree/6.4.0"
+                "source": "https://github.com/spatie/laravel-permission/tree/6.7.0"
             },
             "funding": [
                 {
                     "type": "github"
                 }
             ],
-            "time": "2024-02-28T08:11:20+00:00"
+            "time": "2024-04-19T12:35:28+00:00"
         },
         {
             "name": "symfony/clock",
         },
         {
             "name": "phpunit/phpunit",
-            "version": "10.5.17",
+            "version": "10.5.19",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "c1f736a473d21957ead7e94fcc029f571895abf5"
+                "reference": "c726f0de022368f6ed103e452a765d3304a996a4"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1f736a473d21957ead7e94fcc029f571895abf5",
-                "reference": "c1f736a473d21957ead7e94fcc029f571895abf5",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c726f0de022368f6ed103e452a765d3304a996a4",
+                "reference": "c726f0de022368f6ed103e452a765d3304a996a4",
                 "shasum": ""
             },
             "require": {
             "support": {
                 "issues": "https://github.com/sebastianbergmann/phpunit/issues",
                 "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
-                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.17"
+                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.19"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-04-05T04:39:01+00:00"
+            "time": "2024-04-17T14:06:18+00:00"
         },
         {
             "name": "sebastian/cli-parser",
         },
         {
             "name": "spatie/ignition",
-            "version": "1.13.1",
+            "version": "1.13.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/spatie/ignition.git",
-                "reference": "889bf1dfa59e161590f677728b47bf4a6893983b"
+                "reference": "952798e239d9969e4e694b124c2cc222798dbb28"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/spatie/ignition/zipball/889bf1dfa59e161590f677728b47bf4a6893983b",
-                "reference": "889bf1dfa59e161590f677728b47bf4a6893983b",
+                "url": "https://api.github.com/repos/spatie/ignition/zipball/952798e239d9969e4e694b124c2cc222798dbb28",
+                "reference": "952798e239d9969e4e694b124c2cc222798dbb28",
                 "shasum": ""
             },
             "require": {
                     "type": "github"
                 }
             ],
-            "time": "2024-03-29T14:03:47+00:00"
+            "time": "2024-04-16T08:49:17+00:00"
         },
         {
             "name": "spatie/laravel-ignition",
-            "version": "2.5.1",
+            "version": "2.5.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/spatie/laravel-ignition.git",
-                "reference": "0c864b3cbd66ce67a2096c5f743e07ce8f1d6ab9"
+                "reference": "c93fcadcc4629775c839ac9a90916f07a660266f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/0c864b3cbd66ce67a2096c5f743e07ce8f1d6ab9",
-                "reference": "0c864b3cbd66ce67a2096c5f743e07ce8f1d6ab9",
+                "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/c93fcadcc4629775c839ac9a90916f07a660266f",
+                "reference": "c93fcadcc4629775c839ac9a90916f07a660266f",
                 "shasum": ""
             },
             "require": {
                 "illuminate/support": "^10.0|^11.0",
                 "php": "^8.1",
                 "spatie/flare-client-php": "^1.3.5",
-                "spatie/ignition": "^1.13",
+                "spatie/ignition": "^1.13.2",
                 "symfony/console": "^6.2.3|^7.0",
                 "symfony/var-dumper": "^6.2.3|^7.0"
             },
                     "type": "github"
                 }
             ],
-            "time": "2024-04-02T06:30:22+00:00"
+            "time": "2024-04-16T08:57:16+00:00"
         },
         {
             "name": "symfony/yaml",
diff --git a/database/migrations/2024_04_19_184315_create_chapters_table.php b/database/migrations/2024_04_19_184315_create_chapters_table.php
new file mode 100644 (file)
index 0000000..c4b79f0
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('chapters', function (Blueprint $table) {
+            $table->id();
+            $table->timestamps();
+            $table->integer('order');
+            $table->string('title');
+            $table->text('info');
+            $table->text('contents');
+            $table->foreignId('audio_id')->nullable()->references('id')->on('files');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('chapters');
+    }
+};
diff --git a/database/seeders/ChapterSeeder.php b/database/seeders/ChapterSeeder.php
new file mode 100644 (file)
index 0000000..6587974
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+
+class ChapterSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        DB::table('menuitems')->insert([
+            'name' => 'chapters',
+            'label' => 'Chapters',
+            'icon' => 'bi bi-book',
+            'section' => 'main',
+            'link' => '/chapter-index'
+        ]);
+    }
+}
diff --git a/database/seeders/ModuleGaDeKuSeeder.php b/database/seeders/ModuleGaDeKuSeeder.php
new file mode 100644 (file)
index 0000000..5c9402f
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Module;
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+
+class ModuleGaDeKuSeeder extends Seeder
+{
+   private function exists(string $name): bool {
+      $rc = Module::where(['name' => $name])->first() != null;
+      return $rc;
+   }
+   private function insert(string $name, string $table=null){
+    if (! $this->exists($name)){
+        $table ??= strtolower($name) . 's';
+        DB::table('modules')->insert([
+            'name' => $name,
+            'tablename' => $table
+        ]);
+    }
+   }
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        /*
+        $this->insert('SProperty');
+        $this->insert('Role');
+        $this->insert('User');
+        $this->insert('Note');
+        $this->insert('Menuitem');
+        $this->insert('File');
+        $this->insert('Module');
+        */
+        $this->insert('Word');
+        $this->insert('Verb');
+        $this->insert('Nomen');
+        $this->insert('Phrase');
+        $this->insert('Chapter');
+    }
+}
diff --git a/database/seeders/SPropertyAudioSeeder.php b/database/seeders/SPropertyAudioSeeder.php
new file mode 100644 (file)
index 0000000..04fec59
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+
+class SPropertyAudioSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        DB::table('sproperties')->insert([
+            'id' => 1103, 'scope' => 'filegroup', 'name' => 'Audio file', 'order' => '30', 'shortname' => 'AUDIO'
+        ]);
+        DB::table('sproperties')->insert([
+            'id' => 1104, 'scope' => 'filegroup', 'name' => 'Video file', 'order' => '40', 'shortname' => 'VIDEO'
+        ]);
+        DB::table('sproperties')->insert([
+            'id' => 1105, 'scope' => 'filegroup', 'name' => 'Image file', 'order' => '50', 'shortname' => 'IMG'
+        ]);
+        DB::table('sproperties')->insert([
+            'id' => 1106, 'scope' => 'filegroup', 'name' => 'Document file', 'order' => '60', 'shortname' => 'DOC'
+        ]);
+    }
+}
index 9ce4bbc89e013bfa4a0f9f69744d50960f1917fe..db6a9eec56d1a33e0e33d3dbd81a871502042644 100644 (file)
@@ -15,6 +15,7 @@
     "Category": "Kategorie",
     "Change": "\u00c4ndern",
     "Change Password of an User": "Passwort eines Benutzers \u00e4ndern",
+    "Change of a Chapter": "\u00c4nderung eines Kapitels",
     "Change of a File": "\u00c4ndern einer Datei",
     "Change of a Menu Item": "\u00c4ndern einer Men\u00fceintrags",
     "Change of a Note": "\u00c4ndern einer Notiz",
     "Change of a Verb": "\u00c4nderung eines Verbs",
     "Change of a Word": "\u00c4nderung eines Wortes",
     "Change of an User": "\u00c4ndern eines Benutzers",
+    "Chapter": "Kapitel",
+    "Chapters": "Kapitel",
     "Confirmation": "Best\u00e4tigung",
+    "Contents": "Inhalt",
+    "Creation of a Chapter": "Neues Kapitel",
     "Creation of a Document": "Hochladen eines Dokuments",
     "Creation of a File": "Hochladen einer Datei",
     "Creation of a Menu Item": "Erstellen eine Men\u00fceintrags",
@@ -53,6 +58,7 @@
     "Duration": "Dauer",
     "Email": "Email",
     "English (Britisch)": "Englisch (GB)",
+    "Exchange of a File": "Austausch einer Datei",
     "File": "Datei",
     "Filegroup": "Gruppe",
     "Filename": "Dateiname",
index 5c7ba4b94a1a280d8d50ef4e7d2628585f7a1cf3..3da93a6a87d1d4ec560f26eec3da4aba92f216c9 100644 (file)
@@ -1,3 +1,3 @@
 # Enter the module names separated by " ".
 # Example: MISSING="User Role Menuitem"
-MISSING=""
+MISSING="ChapterSeeder SPropertyAudioSeeder ModuleGaDeKuSeeder"
index 97bbb85edd9df3f8bf65a7bb740ceafb4f93cd3d..74154d5bfe85cd67ad112ae8ff224adcf91ef83f 100644 (file)
@@ -15,3 +15,9 @@ input, button {
     background-color: #333;
     border-color: #CCC;
 }
+.translation {
+    visibility: hidden;
+}
+.translation:hover {
+    visibility: visible;
+}
\ No newline at end of file
index eee27ca8dde04c1ea8b5241f46c117dfe4ddb76e..973335d80266cc510d180d84b3bc0bb71ec773c3 100644 (file)
@@ -2,10 +2,15 @@
 "!comment": "Bitte alphabetisch sortiert eintragen!",
 "<Not verified>": "<Nicht verifiziert>",
 "Adjective": "Adjektiv",
+"Change of a Chapter": "Änderung eines Kapitels",
 "Change of a Noun": "Änderung eines Nomens",
 "Change of a Phrase": "Änderung eines Satzes",
 "Change of a Verb": "Änderung eines Verbs",
 "Change of a Word": "Änderung eines Wortes",
+"Chapter": "Kapitel",
+"Chapters": "Kapitel",
+"Contents": "Inhalt",
+"Creation of a Chapter": "Neues Kapitel",
 "Creation of a Verb": "Neues Verb",
 "Deletion of a Noun": "Löschen eines Nomens",
 "Deletion of a Verb": "Löschen eines Verbs",
diff --git a/resources/views/chapter/create.blade.php b/resources/views/chapter/create.blade.php
new file mode 100644 (file)
index 0000000..b4ae9ea
--- /dev/null
@@ -0,0 +1,17 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="chapter-create" action="/chapter-store" method="POST">
+        @csrf
+        @method('PUT')
+        <x-laraknife.panels.create title="{{ __('Creation of a Chapter') }}">
+            <input type="hidden" name="order" value="{{$context->valueOf('order')}}">
+            <x-laraknife.forms.string position="alone" name="title" label="Title" value="{{ $context->valueOf('title') }}"
+                width2="10" />
+            <x-laraknife.forms.text position="alone" name="info" label="Info" value="{{ $context->valueOf('info') }}"
+                width2="10" rows="2" />
+            <x-laraknife.forms.text position="alone" name="contents" label="Contents"
+                value="{{ $context->valueOf('contents') }}" width2="10" rows="10" />
+        </x-laraknife.panels.create>
+    </form>
+@endsection
diff --git a/resources/views/chapter/edit.blade.php b/resources/views/chapter/edit.blade.php
new file mode 100644 (file)
index 0000000..4e425ba
--- /dev/null
@@ -0,0 +1,20 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="chapter-edit" enctype="multipart/form-data" action="/chapter-update/{{ $context->model->id }}" method="POST">
+        @csrf
+        <x-laraknife.panels.edit title="{{ __('Change of a Chapter') }}">
+            <x-laraknife.forms.string position="first" name="order" label="Order" value="{{ $context->valueOf('order') }}"
+                width2="4" />
+            <x-laraknife.forms.string position="last" name="title" label="Title" value="{{ $context->valueOf('title') }}"
+                width2="4" />
+            <x-laraknife.forms.text position="alone" name="info" label="Info" value="{{ $context->valueOf('info') }}"
+                width2="10" rows="2" />
+            <x-laraknife.forms.text position="alone" name="contents" label="Contents"
+                value="{{ $context->valueOf('contents') }}" width2="10" rows="10" />
+            <x-laraknife.forms.file-protected position="alone" name="file" fieldId="{{ $context->model->audio_id }}"
+                value="{{ $context->valueOf('file') }}" label="Audio" width2="10" />
+
+        </x-laraknife.panels.edit>
+    </form>
+@endsection
diff --git a/resources/views/chapter/index.blade.php b/resources/views/chapter/index.blade.php
new file mode 100644 (file)
index 0000000..a1d353c
--- /dev/null
@@ -0,0 +1,35 @@
+@extends('layouts.backend')
+
+@section('content')
+<form id="chapter-index" action="/chapter-index" method="POST">
+    @csrf
+    <x-laraknife.panels.index title="{{ __('Chapters') }}">
+      <x-laraknife.panels.filter legend="{{ $pagination->legendText() }}">
+      <x-laraknife.forms.string position="alone" name="text" label="Text" value="{{ $context->valueOf('text') }}" width2="10" />
+      </x-laraknife.panels.filter>
+      <x-laraknife.panels.index-button buttonType="new"/>
+      <x-laraknife.panels.sortable-table :context="$context" :pagination="$pagination">
+        <thead>
+          <tr>
+            <th></th>
+            <th sortId="order">{{__('Order')}}</th>
+            <th sortId="title">{{__('Title')}}</th>
+            <th sortId="info">{{__('Info')}}</th>
+            <th></th>
+          </tr>
+        </thead>
+        <tbody>
+@foreach ($records as $chapter)
+        <tr>
+            <td><x-laraknife.icons.change-record module="chapter" no="{{ $chapter->id }}" /></td>
+              <td>{{$chapter->order}}</td>
+              <td><a href="/chapter-showpretty/{{ $chapter->id }}">{{$chapter->title}}</a></td>
+              <td>{{$chapter->info}}</td>
+            <td><x-laraknife.icons.delete-record module="chapter" no="{{ $chapter->id }}" /></td>
+        </tr>
+@endforeach
+      </tbody>
+    </x-laraknife.panels.sortable-table>
+  </x-laraknife.panels.index>
+</form>
+@endsection
diff --git a/resources/views/chapter/show.blade.php b/resources/views/chapter/show.blade.php
new file mode 100644 (file)
index 0000000..ae060a4
--- /dev/null
@@ -0,0 +1,17 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="chapter-show" action="/chapter-show/{{ $context->model->id }}/{{ $mode }}" method="POST">
+        @csrf
+        @if($mode === 'delete')
+        @method('DELETE')
+        @endif
+        <x-laraknife.panels.show title="{{ __($mode !== 'delete' ? 'A Chapter' : 'Deletion of a Chapter') }}" mode="{{$mode}}">
+            <x-laraknife.forms.string position="first" name="id" label="Id" value="{{ $context->model->id }}" width2="4" attribute="readonly" />
+            <x-laraknife.forms.text position="alone" name="info" label="Info" value="{{ $context->valueOf('info') }}" width2="4" attribute="readonly" rows="2" />
+            <x-laraknife.forms.text position="alone" name="contents" label="Contents" value="{{ $context->valueOf('contents') }}" width2="4" attribute="readonly" rows="2" />
+            <x-laraknife.forms.string position="alone" name="title" label="Title" value="{{ $context->valueOf('title') }}" width2="4" attribute="readonly" />
+            <x-laraknife.string position="alone" name="order" label="Order" value="{{ $context->valueOf('order') }}" width2="4" attribute="readonly" />
+        </x-laraknife.panels.show>
+    </form>
+@endsection
diff --git a/resources/views/chapter/showpretty.blade.php b/resources/views/chapter/showpretty.blade.php
new file mode 100644 (file)
index 0000000..15c8853
--- /dev/null
@@ -0,0 +1,17 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="chapter-show" action="/chapter-show/{{ $context->model->id }}" method="POST">
+        @csrf
+        <x-laraknife.panels.noform-text title="{{ $context->valueof('title') }}">
+            <div class="row">
+                {!! $context->valueOf('text') !!}
+            </div>
+        </x-laraknife.panels.noform-text>
+        @if ($context->valueof('link') != null)
+            <div class="row">
+                <x-laraknife.forms.audio width1="5" width2="2" fileLink="{{ $context->valueof('link') }}" />
+            </div>
+        @endif
+    </form>
+@endsection
index 1d9b99a110d7e1ad2509092d7b40be886717e59f..5662c04131f9098e10ce3e6b2b8d52fbb5dc1a14 100644 (file)
@@ -12,6 +12,7 @@ use App\Http\Controllers\WordController;
 use App\Http\Controllers\PhraseController;
 use App\Http\Controllers\ReviewController;
 use App\Http\Controllers\MenuitemController;
+use App\Http\Controllers\ChapterController;
 use App\Http\Controllers\SPropertyController;
 
 Route::get('/', function () {
@@ -32,3 +33,5 @@ VerbController::routes();
 
 PhraseController::routes();
 ReviewController::routes();
+
+ChapterController::routes();