From ae3028b3ebd0ef0113eb066294fa21bf3cfd8a4b Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Sat, 8 Jun 2024 19:27:31 +0200 Subject: [PATCH] V 0.4.2 Modul Export, Refaktorierung Seeders - neu Modul Export - PageController: neu: export() --- CHANGELOG.md | 6 +++ app/Http/Controllers/ExportController.php | 1 + app/Http/Controllers/PageController.php | 33 ++++++++++++++++- composer.lock | 2 +- database/seeders/ChapterSeeder.php | 24 ------------ database/seeders/ExportSeeder.php | 21 +++++++++++ database/seeders/MenuitemGaDeKuSeeder.php | 39 -------------------- database/seeders/ModuleGaDeKuSeeder.php | 45 ----------------------- database/seeders/NounSeeder.php | 26 ------------- database/seeders/PageSeeder.php | 1 + database/seeders/RoleGaDeKuSeeder.php | 25 ------------- database/seeders/RoleLocalSeeder.php | 20 ++++++++++ database/seeders/SPropertyAudioSeeder.php | 29 --------------- database/seeders/TermSeeder.php | 1 + database/seeders/WordSeeder.php | 10 ++++- database/seeders/seeders | 1 - lang/de_DE.json | 22 +++++++++++ public/export | 1 + resources/views/export | 1 + resources/views/page/index.blade.php | 3 +- routes/web.php | 2 + 21 files changed, 119 insertions(+), 194 deletions(-) create mode 120000 app/Http/Controllers/ExportController.php delete mode 100644 database/seeders/ChapterSeeder.php create mode 100644 database/seeders/ExportSeeder.php delete mode 100644 database/seeders/MenuitemGaDeKuSeeder.php delete mode 100644 database/seeders/ModuleGaDeKuSeeder.php delete mode 100644 database/seeders/NounSeeder.php delete mode 100644 database/seeders/RoleGaDeKuSeeder.php create mode 100644 database/seeders/RoleLocalSeeder.php delete mode 100644 database/seeders/SPropertyAudioSeeder.php create mode 120000 database/seeders/TermSeeder.php delete mode 120000 database/seeders/seeders create mode 120000 public/export create mode 120000 resources/views/export diff --git a/CHANGELOG.md b/CHANGELOG.md index ef9017a..2a5e90e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# V 0.4.2 Modul Export, Refaktorierung Seeders + +## Added +- neu Modul Export +- PageController: neu: export() + # V 0.4.1 Mandator Account Transaction ## Added diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php new file mode 120000 index 0000000..898e528 --- /dev/null +++ b/app/Http/Controllers/ExportController.php @@ -0,0 +1 @@ +../../../vendor/hamatoma/laraknife/templates/Http/Controllers/ExportController.php \ No newline at end of file diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index f024ab5..3840607 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -64,6 +64,32 @@ class PageController extends Controller } return $rc; } + public function export(array &$records) + { + $fn = FileHelper::buildExportName('page-export', '.txt'); + $sep = '~' . StringHelper::randomString(StringHelper::$charSetAlphaNumeric, 3) . '%'; + $count = count($records); + $contents = "!Meta LaraKnife-Export +separator=$sep +records=$count + "; + $recordNo = 0; + foreach ($records as &$record) { + $recordNo++; + $contents .= "action=insert +table=pages +primary=page$recordNo +title=$record->title +name=$record->name +contents=<< +$record->contents +$sep +"; + } + file_put_contents($fn, $contents); + $rc = redirect('/exported'); + return $rc; + } /** * Show the form for editing the specified resource. */ @@ -170,6 +196,9 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id $sql = DbHelper::addOrderBy($sql, $fields['_sortParams']); $pagination = new Pagination($sql, $parameters, $fields); $records = $pagination->records; + if ($request->btnSubmit === 'btnExport') { + $rc = $this->export($records); + } $optionsPagetype = SProperty::optionsByScope('pagetype', $fields['pagetype'], 'all'); $optionsMarkup = SProperty::optionsByScope('markup', $fields['markup'], 'all'); $optionsLanguage = SProperty::optionsByScope('localization', $fields['markup'], 'all'); @@ -254,7 +283,7 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id $params = ['audio' => $audio]; switch ($page->pagetype_scope) { - case 2035/* snaketext */: + case 2035/* snaketext */ : $text = TextProcessor::compressSnakeText($page->contents); $params['text1'] = $this->asHtml($page, $text); break; @@ -349,7 +378,7 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id $validated['owner_id'] = $fields['owner_id']; $validated['contents'] = MediaWiki::expandStarItems($validated['contents']); $page = Page::create($validated); - if ($page != null){ + if ($page != null) { $rc = redirect("/page-edit/$page->id"); } } diff --git a/composer.lock b/composer.lock index ba1c03f..fc4b471 100644 --- a/composer.lock +++ b/composer.lock @@ -1056,7 +1056,7 @@ "dist": { "type": "path", "url": "../laraknife", - "reference": "f593c3b28cae789a0cd9d443282ec3994d37d25a" + "reference": "5571c586612a4a51475ac95ef30ac1bf91b8d115" }, "require-dev": { "phpunit/phpunit": "11.0.x-dev" diff --git a/database/seeders/ChapterSeeder.php b/database/seeders/ChapterSeeder.php deleted file mode 100644 index 6587974..0000000 --- a/database/seeders/ChapterSeeder.php +++ /dev/null @@ -1,24 +0,0 @@ -insert([ - 'name' => 'chapters', - 'label' => 'Chapters', - 'icon' => 'bi bi-book', - 'section' => 'main', - 'link' => '/chapter-index' - ]); - } -} diff --git a/database/seeders/ExportSeeder.php b/database/seeders/ExportSeeder.php new file mode 100644 index 0000000..95464c1 --- /dev/null +++ b/database/seeders/ExportSeeder.php @@ -0,0 +1,21 @@ +insert([ - 'name' => 'words', - 'label' => 'Words', - 'icon' => 'bi bi-file-earmark-word', - 'section' => 'main', - 'link' => '/word-index' - ]); - DB::table('menuitems')->insert([ - 'name' => 'nouns', - 'label' => 'Nouns', - 'icon' => 'bi bi-file-image', - 'section' => 'main', - 'link' => '/noun-index' - ]); - DB::table('menuitems')->insert([ - 'name' => 'verbs', - 'label' => 'Verbs', - 'icon' => 'bi bi-file-image', - 'section' => 'main', - 'link' => '/verb-index' - ]); - } -} - diff --git a/database/seeders/ModuleGaDeKuSeeder.php b/database/seeders/ModuleGaDeKuSeeder.php deleted file mode 100644 index 5c9402f..0000000 --- a/database/seeders/ModuleGaDeKuSeeder.php +++ /dev/null @@ -1,45 +0,0 @@ - $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/NounSeeder.php b/database/seeders/NounSeeder.php deleted file mode 100644 index 885dd92..0000000 --- a/database/seeders/NounSeeder.php +++ /dev/null @@ -1,26 +0,0 @@ -insert([ - 'id' => 2021, 'scope' => 'genus', 'name' => 'masculine', 'order' => '10', 'shortname' => 'm' - ]); - DB::table('sproperties')->insert([ - 'id' => 2022, 'scope' => 'genus', 'name' => 'feminine', 'order' => '20', 'shortname' => 'f' - ]); - DB::table('sproperties')->insert([ - 'id' => 2023, 'scope' => 'genus', 'name' => 'neuter', 'order' => '30', 'shortname' => 'n' - ]); - } -} diff --git a/database/seeders/PageSeeder.php b/database/seeders/PageSeeder.php index 61fc0e8..97c2085 100644 --- a/database/seeders/PageSeeder.php +++ b/database/seeders/PageSeeder.php @@ -17,6 +17,7 @@ class PageSeeder extends Seeder { 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'); diff --git a/database/seeders/RoleGaDeKuSeeder.php b/database/seeders/RoleGaDeKuSeeder.php deleted file mode 100644 index 4978a99..0000000 --- a/database/seeders/RoleGaDeKuSeeder.php +++ /dev/null @@ -1,25 +0,0 @@ -insert([ - 'name' => 'Tutor', - 'priority' => '30' - ]); - DB::table('roles')->insert([ - 'name' => 'Student', - 'priority' => '40' - ]); - } -} diff --git a/database/seeders/RoleLocalSeeder.php b/database/seeders/RoleLocalSeeder.php new file mode 100644 index 0000000..95a6a2d --- /dev/null +++ b/database/seeders/RoleLocalSeeder.php @@ -0,0 +1,20 @@ +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' - ]); - } -} diff --git a/database/seeders/TermSeeder.php b/database/seeders/TermSeeder.php new file mode 120000 index 0000000..2b06965 --- /dev/null +++ b/database/seeders/TermSeeder.php @@ -0,0 +1 @@ +../../vendor/hamatoma/laraknife/templates/database/seeders/TermSeeder.php \ No newline at end of file diff --git a/database/seeders/WordSeeder.php b/database/seeders/WordSeeder.php index 484d521..ed7e542 100644 --- a/database/seeders/WordSeeder.php +++ b/database/seeders/WordSeeder.php @@ -2,6 +2,8 @@ namespace Database\Seeders; +use App\Models\Module; +use App\Models\Menuitem; use App\Models\SProperty; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; @@ -14,7 +16,9 @@ class WordSeeder extends Seeder */ public function run(): void { - // int $id, string $scope, string $name, int $order, string $shortname + Menuitem::insertIfNotExists('words', 'bi bi-file-earmark-word'); + Module::insertIfNotExists('Word'); + SProperty::insertIfNotExists(2001, 'wordtype', 'Noun', '10', 'N'); SProperty::insertIfNotExists(2002, 'wordtype', 'Verb', '20', 'V'); SProperty::insertIfNotExists(2003, 'wordtype', 'Adjective', '30', 'ADJ'); @@ -25,5 +29,9 @@ class WordSeeder extends Seeder SProperty::insertIfNotExists(2008, 'wordtype', 'Conjunction', '80', 'CON'); SProperty::insertIfNotExists(2009, 'wordtype', 'Interjection', '90', 'INT'); SProperty::insertIfNotExists(2010, 'wordtype', 'Numeral', '100', 'NUM'); + + SProperty::insertIfNotExists(2021, 'genus', 'masculine', '10', 'm'); + SProperty::insertIfNotExists(2022, 'genus', 'feminine', '20', 'f'); + SProperty::insertIfNotExists(2022, 'genus', 'neuter', '30', 'n'); } } diff --git a/database/seeders/seeders b/database/seeders/seeders deleted file mode 120000 index d617996..0000000 --- a/database/seeders/seeders +++ /dev/null @@ -1 +0,0 @@ -../../vendor/hamatoma/laraknife/templates/database/seeders/ \ No newline at end of file diff --git a/lang/de_DE.json b/lang/de_DE.json index b4036f5..541cd2e 100644 --- a/lang/de_DE.json +++ b/lang/de_DE.json @@ -5,10 +5,13 @@ "": "", "": "", "A Scoped Property": "Eine bereichsbasierte Eigenschaft", + "Account": "Konto", + "Accounts": "Konten", "Action": "Aktion", "Adjective": "Adjektiv", "Administrator": "Administrator", "All": "Alle", + "Amount": "Betrag", "Assign Roles": "Rollen zuordnen", "Back": "Zur\u00fcck", "Body": "Info", @@ -18,6 +21,7 @@ "Change Password of an User": "Passwort eines Benutzers \u00e4ndern", "Change of a File": "\u00c4ndern einer Datei", "Change of a Group": "\u00c4ndern einer Gruppe", + "Change of a Mandator": "\u00c4ndern eines Mandanten", "Change of a Menu Item": "\u00c4ndern einer Men\u00fceintrags", "Change of a Note": "\u00c4ndern einer Notiz", "Change of a Noun": "\u00c4nderung eines Nomens", @@ -26,8 +30,10 @@ "Change of a Role": "\u00c4ndern einer Rolle", "Change of a Scoped Property": "\u00c4ndern einer bereichsbasierten Eigenschaft", "Change of a Term": "\u00c4ndern eines Termins", + "Change of a Transaction": "\u00c4ndern einer Transaktion", "Change of a Verb": "\u00c4nderung eines Verbs", "Change of a Word": "\u00c4nderung eines Wortes", + "Change of an Account": "\u00c4ndern eines Kontos", "Change of an User": "\u00c4ndern eines Benutzers", "Chapter": "Kapitel", "Chapters": "Kapitel", @@ -39,6 +45,7 @@ "Creation of a Document": "Hochladen eines Dokuments", "Creation of a File": "Hochladen einer Datei", "Creation of a Group": "Erstellen einer Gruppe", + "Creation of a Mandator": "Erstellen eine Mandanten", "Creation of a Menu Item": "Erstellen eine Men\u00fceintrags", "Creation of a Note": "Erstellen einer Notiz", "Creation of a Page": "Erstellen einer Seite", @@ -46,12 +53,15 @@ "Creation of a Scoped Property": "Erzeugen einer bereichsbasierten Eigenschaft", "Creation of a Task": "Erstellen einer Aufgabe", "Creation of a Term": "Erstellen eines Termins", + "Creation of a Transaction": "Erstellen einer Transaktion", "Creation of a Word": "Neues Wort", + "Creation of an Account": "Erstellen eines Kontos", "Creation of an User": "Erstellen eines Benutzers", "Date": "Datum", "Delete": "L\u00f6schen", "Deletion of a Document": "L\u00f6schen eines Dokuments", "Deletion of a Group": "L\u00f6schen einer Gruppe", + "Deletion of a Mandator": "L\u00f6schen eines Mandanten", "Deletion of a Menu Item": "L\u00f6schen eines Men\u00fceintrags", "Deletion of a Note": "L\u00f6schen einer Notiz", "Deletion of a Page": "L\u00f6schen einer Seite", @@ -66,6 +76,7 @@ "Email": "Email", "English (Britisch)": "Englisch (GB)", "Exchange of a File": "Austausch einer Datei", + "Exported Files": "Exportierte Dateien", "File": "Datei", "Filegroup": "Gruppe", "Filename": "Dateiname", @@ -92,6 +103,8 @@ "Localization": "Lokalisierung", "Logout": "Abmelden", "Manager": "Verwalter", + "Mandator": "Mandant", + "Mandators": "Mandanten", "Markup": "Sprachtyp", "Member": "Mitglied", "Members": "Mitglieder", @@ -114,6 +127,7 @@ "Password": "Passwort", "Password forgotten?": "Passwort vergessen?", "Past tense": "Pr\u00e4teritum", + "Patterns": "Muster", "Phrase": "Satz", "Phrases": "S\u00e4tze", "Please use the following link and change your password:": "Bitte benutze den folgenden Verweis und \u00e4ndere dein Passwort", @@ -125,6 +139,7 @@ "Reference": "Referenz", "Remain signed in": "Angemeldet bleiben", "Repetition": "Wiederholung", + "Responsibility": "Verantwortung", "Responsibility changed": "Verantwortung ge\u00e4ndert", "Role": "Rolle", "Roles": "Rollen", @@ -144,6 +159,7 @@ "Status": "Status", "Store": "Speichern", "Store Menu": "Men\u00fc speichern", + "Sum": "Summe", "Superlative": "Superlativ", "Task": "Aufgabe", "Term": "Termin", @@ -157,7 +173,10 @@ "Title": "Titel", "To": "Bis", "Total": "Gesamt", + "Transaction": "Transaktion", + "Transactions": "Transaktionen", "Translation": "\u00dcbersetzung", + "Type": "Typ", "Up": "Auf", "Usage": "Verwendung", "User": "Benutzer", @@ -180,12 +199,15 @@ "cloze": "L\u00fcckentext", "cloze text": "L\u00fcckentext", "description": "Beschreibung", + "done": "erledigt", + "expense": "Ausgabe", "feminine": "Femininum", "free text": "Freier Text", "grammar rules": "Grammatikregeln", "help": "Hilfe", "icon": "Bildsymbol", "inactive": "nicht aktiv", + "income": "Einzahlung", "label": "Beschriftung", "link": "Verweis", "markdown simple": "einfache Markierungssprache", diff --git a/public/export b/public/export new file mode 120000 index 0000000..42ade0f --- /dev/null +++ b/public/export @@ -0,0 +1 @@ +../storage/app/public/export/ \ No newline at end of file diff --git a/resources/views/export b/resources/views/export new file mode 120000 index 0000000..69ab3c7 --- /dev/null +++ b/resources/views/export @@ -0,0 +1 @@ +../../vendor/hamatoma/laraknife/resources/views/export/ \ No newline at end of file diff --git a/resources/views/page/index.blade.php b/resources/views/page/index.blade.php index cc4a6bc..0c4d12a 100644 --- a/resources/views/page/index.blade.php +++ b/resources/views/page/index.blade.php @@ -12,7 +12,8 @@ - + + diff --git a/routes/web.php b/routes/web.php index 72b0a73..3caccbe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,6 +11,7 @@ use App\Http\Controllers\UserController; use App\Http\Controllers\VerbController; use App\Http\Controllers\WordController; use App\Http\Controllers\GroupController; +use App\Http\Controllers\ExportController; use App\Http\Controllers\PhraseController; use App\Http\Controllers\ReviewController; use App\Http\Controllers\AccountController; @@ -47,4 +48,5 @@ GroupController::routes(); MandatorController::routes(); AccountController::routes(); TransactionController::routes(); +ExportController::routes(); -- 2.39.5