]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
V 0.4.2 Modul Export, Refaktorierung Seeders
authorHamatoma <author@hamatoma.de>
Sat, 8 Jun 2024 17:27:31 +0000 (19:27 +0200)
committerHamatoma <author@hamatoma.de>
Sat, 8 Jun 2024 17:27:31 +0000 (19:27 +0200)
- neu Modul Export
- PageController: neu: export()

21 files changed:
CHANGELOG.md
app/Http/Controllers/ExportController.php [new symlink]
app/Http/Controllers/PageController.php
composer.lock
database/seeders/ChapterSeeder.php [deleted file]
database/seeders/ExportSeeder.php [new file with mode: 0644]
database/seeders/MenuitemGaDeKuSeeder.php [deleted file]
database/seeders/ModuleGaDeKuSeeder.php [deleted file]
database/seeders/NounSeeder.php [deleted file]
database/seeders/PageSeeder.php
database/seeders/RoleGaDeKuSeeder.php [deleted file]
database/seeders/RoleLocalSeeder.php [new file with mode: 0644]
database/seeders/SPropertyAudioSeeder.php [deleted file]
database/seeders/TermSeeder.php [new symlink]
database/seeders/WordSeeder.php
database/seeders/seeders [deleted symlink]
lang/de_DE.json
public/export [new symlink]
resources/views/export [new symlink]
resources/views/page/index.blade.php
routes/web.php

index ef9017ab0157664438379a4b7ade8dc95ec5aab8..2a5e90e4030570a86a47fbb66acc77887c410174 100644 (file)
@@ -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 (symlink)
index 0000000..898e528
--- /dev/null
@@ -0,0 +1 @@
+../../../vendor/hamatoma/laraknife/templates/Http/Controllers/ExportController.php
\ No newline at end of file
index f024ab5a04f4261b3b66e48d7c92d5ed2a73d712..384060725c73eec6e5b319bdc52e5d7f29e68e64 100644 (file)
@@ -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");
                 }
             }
index ba1c03f71cdb1f1ac73da50209679223f0aee47d..fc4b471115cc5ff5d8c9dcf984f60cb9927d2465 100644 (file)
             "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 (file)
index 6587974..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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/ExportSeeder.php b/database/seeders/ExportSeeder.php
new file mode 100644 (file)
index 0000000..95464c1
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Module;
+use App\Models\Menuitem;
+use App\Models\SProperty;
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+
+class ExportSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        Menuitem::insertIfNotExists('exports', 'bi bi-file-earmark-arrow-down');
+    }
+}
diff --git a/database/seeders/MenuitemGaDeKuSeeder.php b/database/seeders/MenuitemGaDeKuSeeder.php
deleted file mode 100644 (file)
index 0b12b2d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace Database\Seeders;
-
-use Illuminate\Database\Console\Seeds\WithoutModelEvents;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Database\Seeder;
-
-class MenuitemGaDeKuSeeder extends Seeder
-{
-    /**
-     * Run the database seeds.
-     */
-    public function run(): void
-    {
-        DB::table('menuitems')->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 (file)
index 5c9402f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?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/NounSeeder.php b/database/seeders/NounSeeder.php
deleted file mode 100644 (file)
index 885dd92..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace Database\Seeders;
-
-use Illuminate\Database\Seeder;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Database\Console\Seeds\WithoutModelEvents;
-
-class NounSeeder extends Seeder
-{
-    /**
-     * Run the database seeds.
-     */
-    public function run(): void
-    {
-        DB::table('sproperties')->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'
-        ]);
-    }
-}
index 61fc0e8a10060136b03f47fc671b176dab5d752c..97c2085bbc9e181c70f188c41a03af08f5c19546 100644 (file)
@@ -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 (file)
index 4978a99..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace Database\Seeders;
-
-use Illuminate\Database\Seeder;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Database\Console\Seeds\WithoutModelEvents;
-
-class RoleGaDeKuSeeder extends Seeder
-{
-    /**
-     * Run the database seeds.
-     */
-    public function run(): void
-    {
-        DB::table('roles')->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 (file)
index 0000000..95a6a2d
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Role;
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+
+class RoleLocalSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        Role::insertIfNotExists('Tutor', 30);
+        Role::insertIfNotExists('Student', 40);
+    }
+}
diff --git a/database/seeders/SPropertyAudioSeeder.php b/database/seeders/SPropertyAudioSeeder.php
deleted file mode 100644 (file)
index 04fec59..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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'
-        ]);
-    }
-}
diff --git a/database/seeders/TermSeeder.php b/database/seeders/TermSeeder.php
new file mode 120000 (symlink)
index 0000000..2b06965
--- /dev/null
@@ -0,0 +1 @@
+../../vendor/hamatoma/laraknife/templates/database/seeders/TermSeeder.php
\ No newline at end of file
index 484d5215ef3042f1773780eed90e136c3ea61643..ed7e542c00ae477dbd172be6a988c07024e8b13c 100644 (file)
@@ -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 (symlink)
index d617996..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../vendor/hamatoma/laraknife/templates/database/seeders/
\ No newline at end of file
index b4036f512357b4fae4ce29fa2defdc5ccb58bf38..541cd2ecc3f41bc9a847c0888333a1d3f411632f 100644 (file)
@@ -5,10 +5,13 @@
     "<Not verified>": "<Nicht verifiziert>",
     "<Please select>": "<Bitte w\u00e4hlen>",
     "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",
     "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",
     "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",
     "Localization": "Lokalisierung",
     "Logout": "Abmelden",
     "Manager": "Verwalter",
+    "Mandator": "Mandant",
+    "Mandators": "Mandanten",
     "Markup": "Sprachtyp",
     "Member": "Mitglied",
     "Members": "Mitglieder",
     "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",
     "Reference": "Referenz",
     "Remain signed in": "Angemeldet bleiben",
     "Repetition": "Wiederholung",
+    "Responsibility": "Verantwortung",
     "Responsibility changed": "Verantwortung ge\u00e4ndert",
     "Role": "Rolle",
     "Roles": "Rollen",
     "Status": "Status",
     "Store": "Speichern",
     "Store Menu": "Men\u00fc speichern",
+    "Sum": "Summe",
     "Superlative": "Superlativ",
     "Task": "Aufgabe",
     "Term": "Termin",
     "Title": "Titel",
     "To": "Bis",
     "Total": "Gesamt",
+    "Transaction": "Transaktion",
+    "Transactions": "Transaktionen",
     "Translation": "\u00dcbersetzung",
+    "Type": "Typ",
     "Up": "Auf",
     "Usage": "Verwendung",
     "User": "Benutzer",
     "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 (symlink)
index 0000000..42ade0f
--- /dev/null
@@ -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 (symlink)
index 0000000..69ab3c7
--- /dev/null
@@ -0,0 +1 @@
+../../vendor/hamatoma/laraknife/resources/views/export/
\ No newline at end of file
index cc4a6bc153917c2148f6e170cf1d792e248e86c9..0c4d12a55a53110fac9ed34831d4849fba3c994e 100644 (file)
@@ -12,7 +12,8 @@
       <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.buttons.button-position position="first" name="btnNew" label="New" width1="0" width2="6"/>
+      <x-laraknife.buttons.button-position position="last" name="btnExport" label="Export" width1="0" width2="6"/>
       <x-laraknife.panels.sortable-table :context="$context" :pagination="$pagination">
         <thead>
           <tr>
index 72b0a737af115fbe0c5438f2bf9ced736491b21c..3caccbe77c4a594c8b2087f70b20925dd74a07b8 100644 (file)
@@ -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();