From e4bdee6ae724577e2e34ed1e70d02b53d539eea2 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Sun, 28 Apr 2024 12:45:59 +0200 Subject: [PATCH] V 0.2.4 Page - PageController: - Mehrspaltendarstellung - Trennung Layout Frontend/Backend - edit: neu: reference_id --- CHANGELOG.md | 10 +++ app/Http/Controllers/PageController.php | 64 ++++++++++++------- app/Models/Page.php | 2 +- composer.lock | 41 ++++++------ .../2024_04_21_092103_create_pages_table.php | 2 +- lang/de_DE.json | 5 +- resources/views/layouts/backend.blade.php | 55 +++++++++++++++- .../{gadeku.blade.php => frontend.blade.php} | 2 +- resources/views/page/edit.blade.php | 4 +- resources/views/page/index.blade.php | 2 + ...showcol1.blade.php => show-col1.blade.php} | 8 +-- ...showcol2.blade.php => show-col2.blade.php} | 12 ++-- resources/views/page/show-col3.blade.php | 27 ++++++++ resources/views/page/show-col4.blade.php | 30 +++++++++ resources/views/page/showcol3.blade.php | 25 -------- resources/views/page/showcol4.blade.php | 28 -------- resources/views/page/text-col2.blade.php | 26 ++++++++ 17 files changed, 234 insertions(+), 109 deletions(-) mode change 120000 => 100644 resources/views/layouts/backend.blade.php rename resources/views/layouts/{gadeku.blade.php => frontend.blade.php} (98%) rename resources/views/page/{showcol1.blade.php => show-col1.blade.php} (70%) rename resources/views/page/{showcol2.blade.php => show-col2.blade.php} (64%) create mode 100644 resources/views/page/show-col3.blade.php create mode 100644 resources/views/page/show-col4.blade.php delete mode 100644 resources/views/page/showcol3.blade.php delete mode 100644 resources/views/page/showcol4.blade.php create mode 100644 resources/views/page/text-col2.blade.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a7039d..9babd71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ +# V 0.2.4 Page + +## Changed +- PageController: + - Mehrspaltendarstellung + - Trennung Layout Frontend/Backend + - edit: neu: reference_id + # V 0.2.3 MediaWiki +## Changed + - Mediawiki: Korrekturen bei %date()% und %dateTime()%, %color()% umbenannt in %mark()% # V 0.2.2 MediaWiki Page diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index 5b507af..4a60822 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -22,7 +22,7 @@ use Illuminate\Support\Facades\Validator; class PageController extends Controller { - private function asPreview(Page &$page, ?string $contents = null): string + private function asHtml(Page &$page, ?string $contents = null): string { $contents ??= $page->contents; $type = $page->markup_scope; @@ -111,7 +111,7 @@ class PageController extends Controller $optionsPagetype = SProperty::optionsByScope('pagetype', $page->pagetype_scope, ''); $optionsMarkup = SProperty::optionsByScope('markup', $page->markup_scope, ''); $optionsLanguage = SProperty::optionsByScope('localization', $page->language_scope, ''); - $preview = $this->asPreview($page); + $preview = $this->asHtml($page); $fields = $request->btnSubmit !== 'btnPreview' ? null : ['preview' => $preview]; $context = new ContextLaraKnife($request, $fields, $page); $rc = view('page.edit', [ @@ -255,12 +255,38 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id if ($request->btnSubmit === 'btnCancel') { $rc = redirect('/page-index')->middleware('auth'); } else { - $text = $this->asPreview($page); - $link = $page->audio_id == null ? null : File::relativeFileLink($page->audio_id); - $context = new ContextLaraKnife($request, ['text' => $text, 'link' => $link], $page); - $rc = view('page.showcol1', [ - 'context' => $context, - ]); + $textRaw = $page->contents; + $view = 'page.show-col1'; + $audio = $page->audio_id == null ? null : File::relativeFileLink($page->audio_id); + $params = ['audio' => $audio]; + if ($page->pagetype_scope != 2031/* chapter */) { + $columns = 1 + substr_count($textRaw, "\n---- %col%"); + if ($columns <= 1) { + $params["text1"] = $this->asHtml($page); + } else { + $wiki = new MediaWiki(); + $parts = explode("\n---- %col%", $textRaw, 4); + for ($no = 1; $no <= $columns; $no++) { + $params["text$no"] = $wiki->toHtml($parts[$no - 1]); + } + $view = "page.show-col$columns"; + } + } else { + /* Chapter: */ + $text1 = $this->asHtml($page); + $params['text1'] = $text1; + $text2 = null; + $lang = SProperty::idOfLocalization(auth()->user()->localization); + if (($page2 = Page::where(['reference_id' => $page->id, 'language_scope' => $lang])->first()) != null) { + $text2 = $this->asHtml($page2); + } + if ($text2 != null) { + $params['text2'] = $text2; + $view = 'page.text-col2'; + } + } + $context = new ContextLaraKnife($request, $params, $page); + $rc = view($view, ['context' => $context]); } return $rc; } @@ -273,20 +299,7 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id 'context' => $context, ]); } else { - $params = []; - $columns = $page->columns; - if ($columns <= 1) { - $params['text'] = $this->asPreview($page); - } else { - $cols = explode('----', $page->contents); - for ($no = 1; $no <= $columns; $no++) { - $params["text$no"] = $this->asPreview($page, $cols[$no - 1]); - } - } - $context = new ContextLaraKnife($request, $params, $page); - $rc = view("page.showcol$columns", [ - 'context' => $context, - ]); + $rc = $this->showPretty($page, $request); } return $rc; } @@ -338,8 +351,13 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id */ public function update(Page $page, Request $request, array &$fields) { - $validator = Validator::make($fields, $this->rules(false)); + $rules = $this->rules(false); + if ($fields['reference_id'] != null){ + $rules['reference_id'] = 'exists:pages,id'; + } + $validator = Validator::make($fields, $rules); if ($validator->fails()) { + $errors = $validator->errors(); $rc = back()->withErrors($validator)->withInput(); } else { $validated = $validator->validated(); diff --git a/app/Models/Page.php b/app/Models/Page.php index f747dfa..39cdb7e 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -23,7 +23,7 @@ class Page extends Model 'order', 'columns', 'audio_id', - 'cacheof_id', + 'reference_id', 'owner_id' ]; } diff --git a/composer.lock b/composer.lock index 82125d2..de67f3b 100644 --- a/composer.lock +++ b/composer.lock @@ -8,25 +8,25 @@ "packages": [ { "name": "brick/math", - "version": "0.11.0", + "version": "0.12.1", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" + "reference": "f510c0a40911935b77b86859eb5223d58d660df1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", + "reference": "f510c0a40911935b77b86859eb5223d58d660df1", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "5.0.0" + "phpunit/phpunit": "^10.1", + "vimeo/psalm": "5.16.0" }, "type": "library", "autoload": { @@ -46,12 +46,17 @@ "arithmetic", "bigdecimal", "bignum", + "bignumber", "brick", - "math" + "decimal", + "integer", + "math", + "mathematics", + "rational" ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.11.0" + "source": "https://github.com/brick/math/tree/0.12.1" }, "funding": [ { @@ -59,7 +64,7 @@ "type": "github" } ], - "time": "2023-01-15T23:15:59+00:00" + "time": "2023-11-29T23:19:16+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -1051,7 +1056,7 @@ "dist": { "type": "path", "url": "../laraknife", - "reference": "1947415cf873aba097bffffacc911a0c50c554bb" + "reference": "b903164d1c0f98b70657238210a55b05769cff3c" }, "require-dev": { "phpunit/phpunit": "11.0.x-dev" @@ -3126,20 +3131,20 @@ }, { "name": "ramsey/uuid", - "version": "4.7.5", + "version": "4.7.6", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e" + "reference": "91039bc1faa45ba123c4328958e620d382ec7088" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e", - "reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/91039bc1faa45ba123c4328958e620d382ec7088", + "reference": "91039bc1faa45ba123c4328958e620d382ec7088", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" @@ -3202,7 +3207,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.7.5" + "source": "https://github.com/ramsey/uuid/tree/4.7.6" }, "funding": [ { @@ -3214,7 +3219,7 @@ "type": "tidelift" } ], - "time": "2023-11-08T05:53:05+00:00" + "time": "2024-04-27T21:32:50+00:00" }, { "name": "spatie/laravel-permission", diff --git a/database/migrations/2024_04_21_092103_create_pages_table.php b/database/migrations/2024_04_21_092103_create_pages_table.php index bfd2c13..3e361ca 100644 --- a/database/migrations/2024_04_21_092103_create_pages_table.php +++ b/database/migrations/2024_04_21_092103_create_pages_table.php @@ -24,7 +24,7 @@ return new class extends Migration $table->integer('language_scope'); $table->integer('columns')->default(1); $table->foreignId('audio_id')->nullable()->references('id')->on('files'); - $table->foreignId('cacheof_id')->nullable()->references('id')->on('pages'); + $table->foreignId('reference_id')->nullable()->references('id')->on('pages'); $table->foreignId('owner_id')->references('id')->on('users'); }); } diff --git a/lang/de_DE.json b/lang/de_DE.json index 7f38a41..c64904d 100644 --- a/lang/de_DE.json +++ b/lang/de_DE.json @@ -20,6 +20,7 @@ "Change of a Menu Item": "\u00c4ndern einer Men\u00fceintrags", "Change of a Note": "\u00c4ndern einer Notiz", "Change of a Noun": "\u00c4nderung eines Nomens", + "Change of a Page": "\u00c4ndern einer Seite", "Change of a Phrase": "\u00c4nderung eines Satzes", "Change of a Role": "\u00c4ndern einer Rolle", "Change of a Scoped Property": "\u00c4ndern einer bereichsbasierten Eigenschaft", @@ -29,6 +30,7 @@ "Change of an User": "\u00c4ndern eines Benutzers", "Chapter": "Kapitel", "Chapters": "Kapitel", + "Columns": "Spalten", "Confirmation": "Best\u00e4tigung", "Contents": "Inhalt", "Creation of a Chapter": "Neues Kapitel", @@ -36,7 +38,7 @@ "Creation of a File": "Hochladen einer Datei", "Creation of a Menu Item": "Erstellen eine Men\u00fceintrags", "Creation of a Note": "Erstellen einer Notiz", - "Creation of a Page": "Neue Seite", + "Creation of a Page": "Erstellen einer Seite", "Creation of a Role": "Erstellen eine Rolle", "Creation of a Scoped Property": "Erzeugen einer bereichsbasierten Eigenschaft", "Creation of a Term": "Erstellen eines Termins", @@ -109,6 +111,7 @@ "Preview": "Vorschau", "Privacy": "Datenschutz", "Properties": "Eigenschaften", + "Reference": "Referenz", "Remain signed in": "Angemeldet bleiben", "Repetition": "Wiederholung", "Role": "Rolle", diff --git a/resources/views/layouts/backend.blade.php b/resources/views/layouts/backend.blade.php deleted file mode 120000 index 64b957d..0000000 --- a/resources/views/layouts/backend.blade.php +++ /dev/null @@ -1 +0,0 @@ -gadeku.blade.php \ No newline at end of file diff --git a/resources/views/layouts/backend.blade.php b/resources/views/layouts/backend.blade.php new file mode 100644 index 0000000..77546c2 --- /dev/null +++ b/resources/views/layouts/backend.blade.php @@ -0,0 +1,54 @@ + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + @vite(['resources/sass/app.scss', 'resources/js/app.js']) + + + + + + +
+ +
+ @yield('content') + + + diff --git a/resources/views/layouts/gadeku.blade.php b/resources/views/layouts/frontend.blade.php similarity index 98% rename from resources/views/layouts/gadeku.blade.php rename to resources/views/layouts/frontend.blade.php index 77546c2..e79dee2 100644 --- a/resources/views/layouts/gadeku.blade.php +++ b/resources/views/layouts/frontend.blade.php @@ -15,7 +15,7 @@ - +