]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
V 0.2.2 MediaWiki Page
authorHamatoma <author@hamatoma.de>
Sat, 27 Apr 2024 19:05:41 +0000 (21:05 +0200)
committerHamatoma <author@hamatoma.de>
Sat, 27 Apr 2024 19:05:41 +0000 (21:05 +0200)
- MediaWiki: eigene Implementierung
- Modul Page: eigene Implementierung

19 files changed:
CHANGELOG.md
app/Helpers/MediaWiki.php [changed from symlink to file mode: 0644]
app/Helpers/MediaWikiBase.php [new symlink]
app/Helpers/dummy.html [deleted file]
app/Http/Controllers/PageController.php [changed from symlink to file mode: 0644]
app/Models/Page.php [changed from symlink to file mode: 0644]
composer.lock
database/migrations/2024_04_21_092103_create_pages_table.php [changed from symlink to file mode: 0644]
database/seeders/PageSeeder.php [changed from symlink to file mode: 0644]
resources/views/page [deleted symlink]
resources/views/page/create.blade.php [new file with mode: 0644]
resources/views/page/edit.blade.php [new file with mode: 0644]
resources/views/page/index.blade.php [new file with mode: 0644]
resources/views/page/show.blade.php [new file with mode: 0644]
resources/views/page/showcol1.blade.php [new file with mode: 0644]
resources/views/page/showcol2.blade.php [new file with mode: 0644]
resources/views/page/showcol3.blade.php [new file with mode: 0644]
resources/views/page/showcol4.blade.php [new file with mode: 0644]
resources/views/page/unknown.blade.php [new file with mode: 0644]

index 2c4ef2bbf48111905ba44e169e61a96fc2c40f19..cd74f7108db887027e0c4a20884d7bfac6e8e853 100644 (file)
@@ -1,3 +1,9 @@
+# V 0.2.2 MediaWiki Page
+
+## Added
+- MediaWiki: eigene Implementierung
+- Modul Page: eigene Implementierung
+
 # V 0.2.1 Modul Page
 
 ## Added
deleted file mode 120000 (symlink)
index d83989f3ff3180c0f0975d6ce8357aab5c1b260c..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../../vendor/hamatoma/laraknife/resources/helpers/MediaWiki.php
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..f43f448352cb37a47e1a197a9b12009951d4f4f7
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+namespace App\Helpers;
+
+// Macros:
+
+class MediaWiki extends MediaWikiBase
+{
+    public static function expandStarItems(string $text): string
+    {
+        $rc = preg_replace(
+            [
+                '/\*(\w[^*]+\w)\*/',
+                '/\*<(.+?)>\*/',
+                '/\*-(\w[^*]+\w)-\*/',
+                '/\*\+(\w[^*]+\w)\+\*/'
+            ],
+            [
+                '%trans($1)%',
+                '%field($1)%',
+                '%del($1)%',
+                '%add($1)%'
+            ],
+            $text
+        );
+        return $rc;
+    }
+    function specialMacrosToHtml(string $body): string
+    {
+        $pos = 0;
+        // .............................1...1..2...23....3
+        $body = preg_replace_callback('/%(\w+)\((.*?)(\|.*?)?\)%/', function ($matches) {
+            switch ($matches[1]) {
+                case 'date':
+                    $rc = date('%Y.%m.%d');
+                    break;
+                case 'dateTime':
+                    $rc = date('%Y.%m.%d %H:%M');
+                    break;
+                case 'trans':
+                    $text = $matches[2];
+                    $info = count($matches) > 3 ? $text : substr($matches[3], 1);
+                    $rc = "<i><b data-toggle=\"tooltip\" data-placement=\"top\" title=\"$info\">$text</b></i>";
+                    break;
+                case 'color':
+                    $rc = '<span class="lkn-text-' . substr($matches[3], 1) .'">' . $matches[2] . '</span>';
+                    break;
+                case 'add':
+                    $rc = '<ins class="lkn-ins">' . (count($matches) == 4 ? ($matches[2] . $matches[3]) : $matches[2]) . '</ins>';
+                    break;
+                case 'del':
+                    $rc = '<del class="lkn-del">' . (count($matches) == 4 ? ($matches[2] . $matches[3]) : $matches[2]) . '</del>';
+                    break;
+                case 'field':
+                    $name = $matches[2];
+                    $value = '';
+                    $size = 8;
+                    if (count($matches) > 3){
+                        $parts = explode('|', substr($matches[3], 1));
+                        $value = $parts[0];
+                        if (count($parts) > 1){
+                            $size = $parts[1];
+                        }
+                    }
+                    $rc = "<input class=\"lkn-field\" name=\"$name\" value=\"$value\" size=\"$size\">";
+                    break;
+                default:
+                    $rc = $matches[0];
+                    break;
+            }
+            return $rc;
+        }, $body);
+        return $body;
+    }
+}
diff --git a/app/Helpers/MediaWikiBase.php b/app/Helpers/MediaWikiBase.php
new file mode 120000 (symlink)
index 0000000..5887466
--- /dev/null
@@ -0,0 +1 @@
+../../vendor/hamatoma/laraknife/resources/helpers/MediaWikiBase.php
\ No newline at end of file
diff --git a/app/Helpers/dummy.html b/app/Helpers/dummy.html
deleted file mode 100644 (file)
index 793860b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-
-<body>
-</body>
-
-</html>
\ No newline at end of file
deleted file mode 120000 (symlink)
index eefdef549cd8c7d6ff70d1b5c753fc727d04fb2c..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../vendor/hamatoma/laraknife/templates/Http/Controllers/PageController.php
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..5b507af6ac6f7c0d6c0a3ab6139554a479234f25
--- /dev/null
@@ -0,0 +1,356 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\File;
+use App\Models\Page;
+use App\Models\Module;
+use App\Helpers\Helper;
+use App\Helpers\DbHelper;
+use App\Models\SProperty;
+use App\Helpers\MediaWiki;
+use App\Helpers\FileHelper;
+use App\Helpers\Pagination;
+use App\Helpers\ViewHelper;
+use Illuminate\Http\Request;
+use App\Helpers\StringHelper;
+use App\Helpers\TextProcessor;
+use App\Helpers\ContextLaraKnife;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Route;
+use Illuminate\Support\Facades\Validator;
+
+class PageController extends Controller
+{
+    private function asPreview(Page &$page, ?string $contents = null): string
+    {
+        $contents ??= $page->contents;
+        $type = $page->markup_scope;
+        switch ($type) {
+            case 1122: // mediawiki
+                $wiki = new MediaWiki();
+                $text = $wiki->toHtml($contents);
+                break;
+            case 1223: // html
+                $text = $contents;
+                break;
+            default:
+            case 1121: // plain text
+                $text = '<p>' . str_replace('/\r?\n/', "</p>\n<p>", $contents) . "</p>";
+                break;
+        }
+        return $text;
+    }
+    /**
+     * Show the form for creating a new resource.
+     */
+    public function create(Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/page-index');
+        } else {
+            $fields = $request->all();
+            if (count($fields) === 0) {
+                $fields = [
+                    'title' => '',
+                    'name' => '',
+                    'contents' => '',
+                    'info' => '',
+                    'pagetype_scope' => '',
+                    'markup_scope' => '1122',
+                    'language_scope' => SProperty::idOfLocalization(auth()->user()->localization),
+                    'order' => '0',
+                    'columns' => '1',
+                    'audio_id' => '',
+                ];
+            }
+            $optionsPagetype = SProperty::optionsByScope('pagetype', $fields['pagetype_scope'], '-');
+            $optionsMarkup = SProperty::optionsByScope('markup', $fields['markup_scope'], '-');
+            $optionsLanguage = SProperty::optionsByScope('localization', $fields['language_scope'], '-');
+            $context = new ContextLaraKnife($request, $fields);
+            $rc = view('page.create', [
+                'context' => $context,
+                'optionsPagetype' => $optionsPagetype,
+                'optionsMarkup' => $optionsMarkup,
+                'optionsLanguage' => $optionsLanguage,
+            ]);
+        }
+        return $rc;
+    }
+    /**
+     * Show the form for editing the specified resource.
+     */
+    public function edit(Page $page, Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/page-index');
+        } else {
+            $fields = $request->all();
+            if (count($fields) === 0) {
+                $fields = [
+                    'title' => $page->title,
+                    'name' => $page->title,
+                    'columns' => $page->columns,
+                    'contents' => $page->contents,
+                    'info' => $page->info,
+                    'pagetype_scope' => $page->pagetype_scope,
+                    'markup_scope' => $page->markup_scope,
+                    'language_scope' => $page->language_scope,
+                    'order' => $page->order ?? '0',
+                    'audio_id' => $page->audio_id
+                ];
+            } else {
+                $fields['pagetype_scope'] = $page->pagetype_scope;
+                $fields['markup_scope'] = $page->markup_scope;
+                $fields['language_scope'] = $page->language_scope;
+            }
+            $fields['contents'] = MediaWiki::expandStarItems($fields['contents']);
+            if ($request->btnSubmit === 'btnStore') {
+                $this->update($page, $request, $fields);
+            }
+            $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);
+            $fields = $request->btnSubmit !== 'btnPreview' ? null : ['preview' => $preview];
+            $context = new ContextLaraKnife($request, $fields, $page);
+            $rc = view('page.edit', [
+                'context' => $context,
+                'optionsPagetype' => $optionsPagetype,
+                'optionsMarkup' => $optionsMarkup,
+                'optionsLanguage' => $optionsLanguage,
+            ]);
+        }
+        return $rc;
+    }
+    /**
+     * Remove the specified resource from storage.
+     */
+    public function destroy(Page $page, Request $request)
+    {
+        if ($request->btnSubmit === 'btnDelete') {
+            $page->delete();
+        }
+        return redirect('/page-index');
+    }
+    /**
+     * Display the database records of the resource.
+     */
+    public function index(Request $request)
+    {
+        if ($request->btnSubmit === 'btnNew') {
+            return redirect('/page-create');
+        } else {
+            $sql = "
+SELECT t0.*,
+  t1.name as pagetype,
+  t2.name as markup,
+  t3.shortname as language,
+  t4.name as owner
+FROM pages t0
+LEFT JOIN sproperties t1 ON t1.id=t0.pagetype_scope
+LEFT JOIN sproperties t2 ON t2.id=t0.markup_scope
+LEFT JOIN sproperties t3 ON t3.id=t0.language_scope
+LEFT JOIN sproperties t4 ON t4.id=t0.owner_id
+";
+            $parameters = [];
+            $fields = $request->all();
+            if (count($fields) == 0) {
+                $fields = [
+                    'pagetype' => '',
+                    'markup' => '',
+                    'title' => '',
+                    'contents' => '',
+                    'owner' => '',
+                    '_sortParams' => 'title:asc;id:asc'
+                ];
+            } else {
+                $conditions = [];
+                ViewHelper::addConditionComparism($conditions, $parameters, 'pagetype_scope', 'pagetype');
+                ViewHelper::addConditionComparism($conditions, $parameters, 'markup_scope', 'markup');
+                ViewHelper::addConditionComparism($conditions, $parameters, 'language_scope', 'language');
+                ViewHelper::addConditionComparism($conditions, $parameters, 'owner_id', 'owner');
+                ViewHelper::addConditionPattern($conditions, $parameters, 'name,title,info', 'title');
+                ViewHelper::addConditionPattern($conditions, $parameters, 'info,contents', 'contents');
+                $sql = DbHelper::addConditions($sql, $conditions);
+            }
+            $sql = DbHelper::addOrderBy($sql, $fields['_sortParams']);
+            $pagination = new Pagination($sql, $parameters, $fields);
+            $records = $pagination->records;
+            $optionsPagetype = SProperty::optionsByScope('pagetype', $fields['pagetype'], 'all');
+            $optionsMarkup = SProperty::optionsByScope('markup', $fields['markup'], 'all');
+            $optionsLanguage = SProperty::optionsByScope('localization', $fields['markup'], 'all');
+            $optionsOwner = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['owner']);
+            $context = new ContextLaraKnife($request, $fields);
+            return view('page.index', [
+                'context' => $context,
+                'records' => $records,
+                'optionsPagetype' => $optionsPagetype,
+                'optionsMarkup' => $optionsMarkup,
+                'optionsLanguage' => $optionsLanguage,
+                'optionsOwner' => $optionsOwner,
+                'pagination' => $pagination
+            ]);
+        }
+    }
+    /**
+     * Returns the validation rules.
+     * @return array<string, string> The validation rules.
+     */
+    private function rules(bool $isCreate = false): array
+    {
+        $rc = [
+            'title' => 'required',
+            'name' => 'required',
+            'contents' => 'required',
+            'info' => '',
+            'order' => 'integer|min:0|max:9999',
+            'columns' => 'integer|min:1|max:4'
+        ];
+        if ($isCreate) {
+            $rc['markup_scope'] = 'required';
+            $rc['pagetype_scope'] = 'required';
+            $rc['language_scope'] = 'required';
+        }
+        return $rc;
+    }
+    public static function routes()
+    {
+        Route::get('/page-index', [PageController::class, 'index'])->middleware('auth');
+        Route::post('/page-index', [PageController::class, 'index'])->middleware('auth');
+        Route::get('/page-create', [PageController::class, 'create'])->middleware('auth');
+        Route::put('/page-store', [PageController::class, 'store'])->middleware('auth');
+        Route::post('/page-edit/{page}', [PageController::class, 'edit'])->middleware('auth');
+        Route::get('/page-edit/{page}', [PageController::class, 'edit'])->middleware('auth');
+        Route::get('/page-show/{page}/delete', [PageController::class, 'show'])->middleware('auth');
+        Route::delete('/page-show/{page}/delete', [PageController::class, 'destroy'])->middleware('auth');
+        Route::get('/page-showpretty/{page}', [PageController::class, 'showPretty'])->middleware('auth');
+        Route::post('/page-showpretty/{page}', [PageController::class, 'showPretty'])->middleware('auth');
+        Route::get('/page-showmenu/{title}', [PageController::class, 'showMenu'])->middleware('auth');
+        Route::get('/page-showhelp/{title}', [PageController::class, 'showHelp'])->middleware('auth');
+        Route::get('/page-showbyname/{name}/{pageType}', [PageController::class, 'showByName'])->middleware('auth');
+    }
+    /**
+     * Display the specified resource.
+     */
+    public function show(Page $page, Request $request)
+    {
+        if ($request->btnSubmit === 'btnCancel') {
+            $rc = redirect('/page-index')->middleware('auth');
+        } else {
+            $optionsPagetype = SProperty::optionsByScope('pagetype', $page->pagetype_scope, '');
+            $optionsMarkup = SProperty::optionsByScope('markup', $page->markup_scope, '');
+            $context = new ContextLaraKnife($request, null, $page);
+            $rc = view('page.show', [
+                'context' => $context,
+                'optionsPagetype' => $optionsPagetype,
+                'optionsMarkup' => $optionsMarkup,
+                'mode' => 'delete'
+            ]);
+        }
+        return $rc;
+    }
+    public function showPretty(Page $page, Request $request)
+    {
+        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,
+            ]);
+        }
+        return $rc;
+    }
+    public function showByName(string $name, int $pageType, Request $request)
+    {
+        $page = Page::where(['name' => $name, 'pagetype_scope' => $pageType])->first();
+        if ($page == null) {
+            $context = new ContextLaraKnife($request, ['text' => "invalid reference: $name $pageType"]);
+            $rc = $rc = view('page.unknown', [
+                '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,
+            ]);
+        }
+        return $rc;
+    }
+    public function showHelp(string $title, Request $request)
+    {
+        $rc = $this->showByName($title, 1142, $request);
+        return $rc;
+    }
+
+    public function showMenu(string $title, Request $request)
+    {
+        $rc = $this->showByName($title, 1141, $request);
+        return $rc;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     */
+    public function store(Request $request)
+    {
+        $rc = null;
+        if ($request->btnSubmit === 'btnStore') {
+            $fields = $request->all();
+            ViewHelper::addFieldIfMissing($fields, 'order', '0');
+            ViewHelper::addFieldIfMissing($fields, 'owner_id', auth()->id());
+            $fields['name'] = StringHelper::textToUrl(empty($fields['name']) ? $fields['title'] : $fields['name']);
+            $lang = auth()->user()->localization;
+            $lang2 = SProperty::byScopeAndName('localization', $lang, 'shortname');
+            ViewHelper::addFieldIfMissing($fields, 'language_scope', $lang2);
+            $validator = Validator::make($fields, $this->rules(true));
+            if ($validator->fails()) {
+                $errors = $validator->errors();
+                $rc = back()->withErrors($validator)->withInput();
+            } else {
+                $validated = $validator->validated();
+                $validated['info'] = strip_tags($validated['info']);
+                $validated['owner_id'] = $fields['owner_id'];
+                $validated['contents'] = MediaWiki::expandStarItems($validated['contents']);
+                Page::create($validated);
+            }
+        }
+        if ($rc == null) {
+            $rc = redirect('/page-index');
+        }
+        return $rc;
+    }
+    /**
+     * Update the specified resource in storage.
+     */
+    public function update(Page $page, Request $request, array &$fields)
+    {
+        $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']);
+            if (empty($page->audio_id) && $request->file('file') != null) {
+                $filename = FileHelper::textToFilename($page->title);
+                $moduleId = Module::idOfModule('Page');
+                $fileId = File::storeFile($request, $page->title, 1103, 1091, 'audio file of page', $filename, $moduleId, $page->id);
+                $validated['audio_id'] = $fileId;
+            }
+            $page->update($validated);
+        }
+    }
+}
deleted file mode 120000 (symlink)
index 765f5964ddc7b4f2e4a4f290d1aea05c795074a9..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../../vendor/hamatoma/laraknife/templates/Models/Page.php
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..f747dfa71d543c010795157805d9d38aaf855d5b
--- /dev/null
@@ -0,0 +1,29 @@
+<?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 Page extends Model
+{
+    use HasFactory;
+    protected $table = 'pages';
+    protected $fillable = [
+        'name',
+        'title',
+        'contents',
+        'info',
+        'pagetype_scope',
+        'markup_scope',
+        'language_scope',
+        'order',
+        'columns',
+        'audio_id',
+        'cacheof_id',
+        'owner_id'
+    ];
+}
index 74f088baf95cda8babc09d242fbcc587a819757e..82125d244bdc4fd9f61de9ee37cb70c3fe407249 100644 (file)
             "dist": {
                 "type": "path",
                 "url": "../laraknife",
-                "reference": "da72a7038fb52b0a6aeeb7c75b89094d5b5c705c"
+                "reference": "1947415cf873aba097bffffacc911a0c50c554bb"
             },
             "require-dev": {
                 "phpunit/phpunit": "11.0.x-dev"
         },
         {
             "name": "spatie/ignition",
-            "version": "1.13.2",
+            "version": "1.14.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/spatie/ignition.git",
-                "reference": "952798e239d9969e4e694b124c2cc222798dbb28"
+                "reference": "80385994caed328f6f9c9952926932e65b9b774c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/spatie/ignition/zipball/952798e239d9969e4e694b124c2cc222798dbb28",
-                "reference": "952798e239d9969e4e694b124c2cc222798dbb28",
+                "url": "https://api.github.com/repos/spatie/ignition/zipball/80385994caed328f6f9c9952926932e65b9b774c",
+                "reference": "80385994caed328f6f9c9952926932e65b9b774c",
                 "shasum": ""
             },
             "require": {
                     "type": "github"
                 }
             ],
-            "time": "2024-04-16T08:49:17+00:00"
+            "time": "2024-04-26T08:45:51+00:00"
         },
         {
             "name": "spatie/laravel-ignition",
deleted file mode 120000 (symlink)
index 558b3d77fc947e4d91c44cabea7827babf4a137b..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../../vendor/hamatoma/laraknife/templates/database/migrations/2024_04_21_092103_create_pages_table.php
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..bfd2c13ed95ba664712254638bb1a938c4b79021
--- /dev/null
@@ -0,0 +1,39 @@
+<?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('pages', function (Blueprint $table) {
+            $table->id();
+            $table->timestamps();
+            $table->string('title');
+            $table->string('name', 32);
+            $table->text('contents');
+            $table->text('info')->nullable();
+            $table->integer('pagetype_scope');
+            $table->integer('markup_scope');
+            $table->integer('order')->nullable();
+            $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('owner_id')->references('id')->on('users');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('pages');
+    }
+};
deleted file mode 120000 (symlink)
index edbe88b5c9ffaa8b44e16e76ebbb1cdda8cf2703..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../../vendor/hamatoma/laraknife/templates/database/seeders/PageSeeder.php
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..61fc0e8a10060136b03f47fc671b176dab5d752c
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Module;
+use App\Models\Menuitem;
+use App\Models\SProperty;
+use Illuminate\Database\Seeder;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+
+class PageSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        Menuitem::insertIfNotExists('pages', 'bi bi-journals');
+        Module::insertIfNotExists('Page');
+        SProperty::insertIfNotExists(1121, 'markup', 'plain text', 10, 'PT');
+        SProperty::insertIfNotExists(1122, 'markup', 'mediawiki', 20, 'MW');
+        SProperty::insertIfNotExists(1123, 'markup', 'HTML', 30, 'HL');
+
+        SProperty::insertIfNotExists(1141, 'pagetype', 'menu', 10, 'MN');
+        SProperty::insertIfNotExists(1142, 'pagetype', 'help', 20, 'HP');
+    }
+}
+
diff --git a/resources/views/page b/resources/views/page
deleted file mode 120000 (symlink)
index fa5b2fb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../vendor/hamatoma/laraknife/resources/views/page/
\ No newline at end of file
diff --git a/resources/views/page/create.blade.php b/resources/views/page/create.blade.php
new file mode 100644 (file)
index 0000000..ca8ab2e
--- /dev/null
@@ -0,0 +1,24 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-create" action="/page-store" method="POST">
+        @csrf
+        @method('PUT')
+        <x-laraknife.panels.create title="{{ __('Creation of a Page') }}">
+            <x-laraknife.forms.combobox position="first" name="pagetype_scope" label="Pagetype" :options="$optionsPagetype"
+                width2="4" />
+            <x-laraknife.forms.combobox position="last" name="markup_scope" label="Markup" :options="$optionsMarkup" width2="4" />
+            <x-laraknife.forms.string position="first" name="title" label="Title"
+                value="{{ $context->valueOf('title') }}" width2="4" />
+            <x-laraknife.forms.string position="last" name="name" label="Name (URL)"
+                value="{{ $context->valueOf('name') }}" width2="4" />
+                <x-laraknife.forms.combobox position="first" name="language_scope" label="Language" :options="$optionsLanguage" width2="4" />
+                <x-laraknife.forms.string position="last" name="column" label="Columns"
+                value="{{ $context->valueOf('columns') }}" width2="4" />
+            <x-laraknife.forms.text position="alone" name="contents" label="Contents"
+                value="{{ $context->valueOf('contents') }}" width2="10" rows="10" />
+            <x-laraknife.forms.text position="alone" name="info" label="Info" value="{{ $context->valueOf('info') }}"
+                width2="10" rows="2" />
+        </x-laraknife.panels.create>
+    </form>
+@endsection
diff --git a/resources/views/page/edit.blade.php b/resources/views/page/edit.blade.php
new file mode 100644 (file)
index 0000000..5014df3
--- /dev/null
@@ -0,0 +1,36 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-edit" action="/page-edit/{{ $context->model->id }}" method="POST">
+        @csrf
+        <x-laraknife.panels.edit title="{{ __('Change of a Page') }}">
+            <x-laraknife.forms.combobox position="first" name="pagetype_scope" label="Pagetype" :options="$optionsPagetype" width2="4"
+                attribute="readonly" />
+            <x-laraknife.forms.combobox position="last" name="markup_scope" label="Markup" :options="$optionsMarkup" width2="4"
+                attribute="readonly" />
+            <x-laraknife.forms.string type="number" position="first" name="columns" label="Columns"
+                value="{{ $context->valueOf('columns') }}" width2="4" />
+            <x-laraknife.forms.string type="number" position="last" name="order" label="Order"
+                value="{{ $context->valueOf('order') }}" width2="4" />
+            <x-laraknife.forms.combobox position="alone" name="language_scope" label="Language" :options="$optionsLanguage"
+                width2="4" attribute="readonly" />
+            <x-laraknife.forms.string position="first" name="title" label="Title"
+                value="{{ $context->valueOf('title') }}" width2="4" />
+            <x-laraknife.forms.string position="last" name="name" label="Name (URL)"
+                value="{{ $context->valueOf('name') }}" width2="4" />
+            <x-laraknife.forms.text position="alone" name="contents" label="Contents"
+                value="{{ $context->valueOf('contents') }}" width2="10" rows="10" />
+            <x-laraknife.forms.text position="alone" name="info" label="Info" value="{{ $context->valueOf('info') }}"
+                width2="10" rows="2" />
+            <x-laraknife.forms.file-protected position="first" name="file" fieldId="{{ $context->model->audio_id }}"
+                label="Audio" width2="4" />
+            <x-laraknife.buttons.button position="last" name="btnPreview" label="Preview" />
+        </x-laraknife.panels.edit>
+        @if (!empty($context->valueOf('preview')))
+            <x-laraknife.panels.noform title="{{ __('Preview') }}">
+                <div class="lkn-text">{!! $context->valueOf('preview') !!}
+                </div>
+            </x-laraknife.panels.noform>
+        @endif
+    </form>
+@endsection
diff --git a/resources/views/page/index.blade.php b/resources/views/page/index.blade.php
new file mode 100644 (file)
index 0000000..61318f2
--- /dev/null
@@ -0,0 +1,44 @@
+@extends('layouts.backend')
+
+@section('content')
+<form id="page-index" action="/page-index" method="POST">
+    @csrf
+    <x-laraknife.panels.index title="{{ __('Pages') }}">
+      <x-laraknife.panels.filter legend="{{ $pagination->legendText() }}">
+      <x-laraknife.forms.combobox position="first" name="pagetype" label="Pagetype" :options="$optionsPagetype" class="lkn-autoupdate" width2="4" />
+      <x-laraknife.forms.combobox position="last" name="markup" label="Markup" :options="$optionsMarkup" class="lkn-autoupdate" width2="4" />
+      <x-laraknife.forms.combobox position="first" name="language" label="Language" :options="$optionsLanguage" class="lkn-autoupdate" width2="4" />
+      <x-laraknife.forms.combobox position="last" name="owner" label="Owner" :options="$optionsOwner" class="lkn-autoupdate" width2="4" />
+      <x-laraknife.forms.string position="first" name="title" label="Title" value="{{ $context->valueOf('title') }}" width2="4" />
+      <x-laraknife.forms.string position="last" name="contents" label="Contents" value="{{ $context->valueOf('contents') }}" width2="4" />
+      </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="title">{{__('Title')}}</th>
+            <th sortId="pagetype">{{__('Pagetype')}}</th>
+            <th sortId="markup">{{__('Markup')}}</th>
+            <th sortId="language">{{__('Language')}}</th>
+            <th sortId="owner">{{__('Owner')}}</th>
+            <th></th>
+          </tr>
+        </thead>
+        <tbody>
+@foreach ($records as $page)
+        <tr>
+            <td><x-laraknife.icons.change-record module="page" no="{{ $page->id }}" /></td>
+              <td><a href="/page-showpretty/{{ $page->id }}">{{$page->title}}</a></td>
+              <td> {{ __($page->pagetype) }}</td>
+              <td> {{ __($page->markup) }}</td>
+              <td> {{ __($page->language) }}</td>
+              <td>{{$page->owner}}</td>
+            <td><x-laraknife.icons.delete-record module="page" no="{{ $page->id }}" /></td>
+        </tr>
+@endforeach
+      </tbody>
+    </x-laraknife.panels.sortable-table>
+  </x-laraknife.panels.index>
+</form>
+@endsection
diff --git a/resources/views/page/show.blade.php b/resources/views/page/show.blade.php
new file mode 100644 (file)
index 0000000..16e9096
--- /dev/null
@@ -0,0 +1,17 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-show" action="/page-show/{{ $context->model->id }}/{{ $mode }}" method="POST">
+        @csrf
+        @if($mode === 'delete')
+        @method('DELETE')
+        @endif
+        <x-laraknife.panels.show title="{{ __($mode !== 'delete' ? 'An Page' : 'Deletion of an Page') }}" mode="{{$mode}}">
+            <x-laraknife.forms.combobox position="first" name="pagetype_scope" label="Pagetype" :options="$optionsPagetype" width2="4" attribute="readonly"/>
+            <x-laraknife.forms.combobox position="last" name="markup_scope" label="Markup" :options="$optionsMarkup" width2="4" attribute="readonly"/>
+            <x-laraknife.forms.string position="alone" name="title" label="Title" value="{{ $context->valueOf('title') }}" width2="10" attribute="readonly" />
+            <x-laraknife.forms.text position="alone" name="contents" label="Contents" value="{{ $context->valueOf('contents') }}" width2="10" attribute="readonly" rows="5" />
+            <x-laraknife.forms.text position="alone" name="info" label="Info" value="{{ $context->valueOf('info') }}" width2="10" attribute="readonly" rows="2" />
+        </x-laraknife.panels.show>
+    </form>
+@endsection
diff --git a/resources/views/page/showcol1.blade.php b/resources/views/page/showcol1.blade.php
new file mode 100644 (file)
index 0000000..f853209
--- /dev/null
@@ -0,0 +1,17 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-show" action="/page-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
diff --git a/resources/views/page/showcol2.blade.php b/resources/views/page/showcol2.blade.php
new file mode 100644 (file)
index 0000000..5cae863
--- /dev/null
@@ -0,0 +1,22 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-show" action="/page-show/{{ $context->model->id }}" method="POST">
+        @csrf
+        <x-laraknife.panels.noform-text title="{{ $context->valueof('title') }}">
+            <div class="row">
+                <div class="col-md-6">
+                {!! $context->valueOf('text1') !!}
+                </div>
+                <div class="col-md-6">
+                {!! $context->valueOf('text2') !!}
+                </div>
+            </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
diff --git a/resources/views/page/showcol3.blade.php b/resources/views/page/showcol3.blade.php
new file mode 100644 (file)
index 0000000..ad334e3
--- /dev/null
@@ -0,0 +1,25 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-show" action="/page-show/{{ $context->model->id }}" method="POST">
+        @csrf
+        <x-laraknife.panels.noform-text title="{{ $context->valueof('title') }}">
+            <div class="row">
+                <div class="col-md-4">
+                {!! $context->valueOf('text1') !!}
+                </div>
+                <div class="col-md-4">
+                {!! $context->valueOf('text2') !!}
+                </div>
+               <div class="col-md-4">
+                {!! $context->valueOf('text3') !!}
+                </div>
+            </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
diff --git a/resources/views/page/showcol4.blade.php b/resources/views/page/showcol4.blade.php
new file mode 100644 (file)
index 0000000..6c1ccef
--- /dev/null
@@ -0,0 +1,28 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-show" action="/page-show/{{ $context->model->id }}" method="POST">
+        @csrf
+        <x-laraknife.panels.noform-text title="{{ $context->valueof('title') }}">
+            <div class="row">
+                <div class="col-md-3">
+                {!! $context->valueOf('text1') !!}
+                </div>
+                <div class="col-md-3">
+                {!! $context->valueOf('text2') !!}
+                </div>
+               <div class="col-md-3">
+                {!! $context->valueOf('text3') !!}
+                </div>
+               <div class="col-md-3">
+                {!! $context->valueOf('text4') !!}
+                </div>
+            </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
diff --git a/resources/views/page/unknown.blade.php b/resources/views/page/unknown.blade.php
new file mode 100644 (file)
index 0000000..a9ad8eb
--- /dev/null
@@ -0,0 +1,10 @@
+@extends('layouts.backend')
+
+@section('content')
+    <form id="page-unknown" action="/page-index" method="POST">
+        @csrf
+        <x-laraknife.panels.noform-text title="{{ __('Unknown page request') }}">
+            <x-laraknife.forms.const-text text=" {{ $context->valueOf('text') }}" />
+        </x-laraknife.panels.noform-text>
+    </form>
+@endsection