From d9799b6b2b4b7e66de31f7a6564135eafa5e81dd Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Sun, 12 May 2024 13:18:03 +0200 Subject: [PATCH] V 0.3.3 Aufgaben mittels Note/Task, Email bei Note, Farben - neu: TaskHelper - TextProcessor: neu compressSnakeText() - Note: neues Registerblatt "Aufgabe" - neues Farbschema Orange --- CHANGELOG.md | 9 ++ app/Helpers/TaskHelper.php | 22 +++ app/Helpers/TextProcessor.php | 6 + app/Helpers/ViewHelperLocal.php | 12 +- app/Http/Controllers/PageController.php | 91 ++++++------- app/Http/Controllers/TaskController.php | 125 ++++++++++++++++++ app/Mail/NoteNotification.php | 1 + composer.lock | 2 +- lang/de_DE.json | 9 +- public/css/gadeku.css | 110 ++++++++++++++- resources/lang/sources/gadeku.de.json | 3 + resources/views/layouts/backend.blade.php | 2 +- resources/views/layouts/frontend.blade.php | 2 +- .../views/mails/note-notification.blade.php | 1 + resources/views/page/index.blade.php | 4 +- resources/views/task/create.blade.php | 20 +++ resources/views/task/edit_snake.blade.php | 26 ++++ 17 files changed, 385 insertions(+), 60 deletions(-) create mode 100644 app/Helpers/TaskHelper.php create mode 100644 app/Http/Controllers/TaskController.php create mode 120000 app/Mail/NoteNotification.php create mode 120000 resources/views/mails/note-notification.blade.php create mode 100644 resources/views/task/create.blade.php create mode 100644 resources/views/task/edit_snake.blade.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 230badf..0d4da28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# V 0.3.3 Aufgaben mittels Note/Task, Email bei Note, Farben + +## Added +- neu: TaskHelper +- TextProcessor: neu compressSnakeText() +- Note: neues Registerblatt "Aufgabe" +- neues Farbschema Orange + + # V 0.3.2 Phrase Word ## Added diff --git a/app/Helpers/TaskHelper.php b/app/Helpers/TaskHelper.php new file mode 100644 index 0000000..2c21cbc --- /dev/null +++ b/app/Helpers/TaskHelper.php @@ -0,0 +1,22 @@ +"; + break; + default: + break; + } + return $rc; + } + public function buildButtonTask() + { + + } +} \ No newline at end of file diff --git a/app/Helpers/TextProcessor.php b/app/Helpers/TextProcessor.php index f7478a5..fe634ec 100644 --- a/app/Helpers/TextProcessor.php +++ b/app/Helpers/TextProcessor.php @@ -3,6 +3,12 @@ namespace App\Helpers; class TextProcessor { + public static function compressSnakeText(?string $text): string + { + $text = preg_replace('/[,.\s]+/', '', $text ?? ''); + $text = strtolower($text); + return $text; + } public static function expandStarItems(string $text): string { $rc = preg_replace( diff --git a/app/Helpers/ViewHelperLocal.php b/app/Helpers/ViewHelperLocal.php index 676a97d..14a95ea 100644 --- a/app/Helpers/ViewHelperLocal.php +++ b/app/Helpers/ViewHelperLocal.php @@ -27,11 +27,19 @@ class ViewHelperLocal $rc = null; switch ($name) { case 'note-edit': - $rc = new NavigationTabs([ + $list = [ "Properties;/note-edit/$referenceId", "Documents;/note-index_documents/$referenceId", "Shift;/note-edit_shift/$referenceId", - ], $indexActive); + ]; + if (strpos($options, 'task=1302') !== false){ + $match = null; + if (preg_match('/ref-page=(\d+)/', $options, $match)){ + $pageId = $match[1]; + array_push($list, "Task;/task-edit_snake/$referenceId/$pageId"); + } + } + $rc = new NavigationTabs($list, $indexActive); break; case 'word-edit': $header = StringHelper::toCapital($options); diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index ab56936..fc0dfbf 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -25,21 +25,8 @@ class PageController extends Controller private function asHtml(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 = '

' . str_replace('/\r?\n/', "

\n

", $contents) . "

"; - break; - } - return $text; + $rc = ViewHelper::asHtml($contents, $page->markup_scope); + return $rc; } /** * Show the form for creating a new resource. @@ -115,7 +102,7 @@ class PageController extends Controller $optionsMarkup = SProperty::optionsByScope('markup', $page->markup_scope, ''); $optionsLanguage = SProperty::optionsByScope('localization', $page->language_scope, ''); $fields = $request->btnSubmit !== 'btnPreview' ? null : ['preview' => $this->asHtml($page)]; - if ($page->audio_id != null){ + if ($page->audio_id != null) { $file = File::find($page->audio_id); $fields['audio'] = $file->filename; } @@ -265,39 +252,47 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id $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]); + switch ($page->pagetype_scope) { + + case 2035/* snaketext */: + $text = TextProcessor::compressSnakeText($page->contents); + $params['text1'] = $this->asHtml($page, $text); + break; + case 2031/* chapter */ : + /* 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); } - $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.translation-col2'; - } + if ($text2 != null) { + $params['text2'] = $text2; + $view = 'page.translation-col2'; + } + break; + default: + $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"; + } + break; } - if ($page->previous_id != null){ + if ($page->previous_id != null) { $params['prev'] = "/page-showpretty/$page->previous_id"; } - if ($page->next_id != null){ + if ($page->next_id != null) { $params['next'] = "/page-showpretty/$page->next_id"; } - if ($page->up_id != null){ + if ($page->up_id != null) { $params['up'] = "/page-showpretty/$page->up_id"; } $context = new ContextLaraKnife($request, $params, $page); @@ -367,19 +362,19 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id public function update(Page $page, Request $request, array &$fields) { $rules = $this->rules(false); - if ($fields['order'] == null){ + if ($fields['order'] == null) { $fields['order'] = 0; } - if ($fields['reference_id'] != null){ + if ($fields['reference_id'] != null) { $rules['reference_id'] = 'exists:pages,id'; } - if ($fields['previous_id'] != null){ + if ($fields['previous_id'] != null) { $rules['previous_id'] = 'exists:pages,id'; } - if ($fields['up_id'] != null){ + if ($fields['up_id'] != null) { $rules['up_id'] = 'exists:pages,id'; } - if ($fields['next_id'] != null){ + if ($fields['next_id'] != null) { $rules['next_id'] = 'exists:pages,id'; } $validator = Validator::make($fields, $rules); diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php new file mode 100644 index 0000000..b1dc546 --- /dev/null +++ b/app/Http/Controllers/TaskController.php @@ -0,0 +1,125 @@ +noteId = $noteId; + $rc->pageId = $pageId; + return $rc; + } + public function create(Request $request) + { + $rc = null; + if ($request->btnSubmit === 'btnCancel') { + $rc = redirect('/note-index'); + } else { + $fields = $request->all(); + $pageId = array_key_exists('page_id', $fields) ? $fields['page_id'] : null; + if (count($fields) <= 1) { + $fields = [ + 'title' => '', + 'body' => '', + 'category_scope' => '1054', + 'visibility_scope' => '1091', + 'owner_id' => strval(auth()->id()), + 'task' => '' + ]; + } + if ($pageId != null) { + $page = Page::find(intval($pageId)); + if ($page != null) { + $fields['title'] = __('Task') . ": $page->title"; + $fields['options'] = "ref-page=$page->id"; + } + } + if ($request->btnSubmit === 'btnStore') { + $validator = Validator::make($fields, ['title' => 'required', 'task' => 'required']); + if ($validator->fails()) { + $rc = back()->withErrors($validator)->withInput(); + } else { + $fields['notestatus_scope'] = 1011; + $fields['options'] .= "\ntask=" . $fields['task']; + $fields['owner_id'] = auth()->id(); + $task = Note::create($fields); + $rc = redirect("/note-edit/$task->id"); + } + } + if ($rc == null) { + $optionsVisibility = SProperty::optionsByScope('visibility', $fields['visibility_scope']); + $optionsTask = SProperty::optionsByScope('task', $fields['task'], '-'); + $optionsCategory = SProperty::optionsByScope('category', $fields['category_scope']); + $context = new ContextLaraKnife($request, $fields); + $rc = view('task.create', [ + 'context' => $context, + 'optionsVisibility' => $optionsVisibility, + 'optionsTask' => $optionsTask, + 'optionsCategory' => $optionsCategory, + ]); + } + } + return $rc; + } + public function editSnake(Note $note, Page $page, Request $request) + { + if ($request->btnSubmit === 'btnCancel') { + $rc = redirect('/page-index'); + } else { + $fields = $request->all(); + if (count($fields) <= 1) { + $fields['snaketext'] = TextProcessor::compressSnakeText($page->body); + $fields['solution'] = $note->body != null && $note->body !== '' ? $note->body : $fields['snaketext']; + if ($page != null && $note != null) { + $fields['pageId'] = $page->id; + } + } + if ($request->btnSubmit === 'btnStore') { + $note->update(['body' => $fields['solution']]); + } + $navigationTabInfo = ViewHelperLocal::getNavigationTabInfo('note-edit', 3, $note->id, $note->options); + $context = new ContextLaraKnife($request, $fields, $note); + $context->model2 = $page; + $rc = view('task.edit_snake', [ + 'context' => $context, + 'navTabsInfo' => $navigationTabInfo + ]); + } + return $rc; + + } + + public static function routes() + { + Route::get('/task-create', [TaskController::class, 'create'])->middleware('auth'); + Route::post('/task-create', [TaskController::class, 'create'])->middleware('auth'); + Route::get('/task-edit_snake/{note}/{page}', [TaskController::class, 'editSnake'])->middleware('auth'); + Route::post('/task-edit_snake/{note}/{page}', [TaskController::class, 'editSnake'])->middleware('auth'); + } + +} + diff --git a/app/Mail/NoteNotification.php b/app/Mail/NoteNotification.php new file mode 120000 index 0000000..55a14c6 --- /dev/null +++ b/app/Mail/NoteNotification.php @@ -0,0 +1 @@ +../../vendor/hamatoma/laraknife/resources/mail/NoteNotification.php \ No newline at end of file diff --git a/composer.lock b/composer.lock index ec2ed47..c55e14d 100644 --- a/composer.lock +++ b/composer.lock @@ -1056,7 +1056,7 @@ "dist": { "type": "path", "url": "../laraknife", - "reference": "51702fba5a786ac71dd1628e7aee3aae747d6003" + "reference": "25dda6c582df04ebf4ed061d2311d3612001e5fb" }, "require-dev": { "phpunit/phpunit": "11.0.x-dev" diff --git a/lang/de_DE.json b/lang/de_DE.json index 70e0066..fe32dfb 100644 --- a/lang/de_DE.json +++ b/lang/de_DE.json @@ -44,6 +44,7 @@ "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 Task": "Erstellen einer Aufgabe", "Creation of a Term": "Erstellen eines Termins", "Creation of a Word": "Neues Wort", "Creation of an User": "Erstellen eines Benutzers", @@ -79,7 +80,6 @@ "Groups": "Gruppen", "Hello": "Hallo", "Id": "Id", - "Imperfect": "Imperfekt", "Imprint": "Impressum", "Info": "Info", "Insert Position": "Einf\u00fcgeposition", @@ -112,6 +112,7 @@ "Participle": "Partizip", "Password": "Passwort", "Password forgotten?": "Passwort vergessen?", + "Past tense": "Pr\u00e4teritum", "Phrase": "Satz", "Phrases": "S\u00e4tze", "Please use the following link and change your password:": "Bitte benutze den folgenden Verweis und \u00e4ndere dein Passwort", @@ -134,12 +135,15 @@ "Shift": "Verschiebung", "Shortname": "Kurzname", "Size (MByte)": "Gr\u00f6\u00dfe (MByte)", + "Snaketext": "Schlangentext", + "Solution": "L\u00f6sung", "Someone has requested a password reset.": "Jemand hat das Zur\u00fccksetzen des Passworts angefordert.", "Start Menu": "Startmen\u00fc", "Status": "Status", "Store": "Speichern", "Store Menu": "Men\u00fc speichern", "Superlative": "Superlativ", + "Task": "Aufgabe", "Term": "Termin", "Terms": "Termine", "Text": "Text", @@ -170,7 +174,9 @@ "active": "aktiv", "chapter": "Kapitel", "closed": "geschlossen", + "cloze": "L\u00fcckentext", "cloze text": "L\u00fcckentext", + "description": "Beschreibung", "feminine": "Femininum", "free text": "Freier Text", "grammar rules": "Grammatikregeln", @@ -191,5 +197,6 @@ "section": "Bereich", "snaketext": "Schlangentext", "standard": "Standard", + "task": "Aufgabe", "work": "Arbeit" } \ No newline at end of file diff --git a/public/css/gadeku.css b/public/css/gadeku.css index f271512..4e3de34 100644 --- a/public/css/gadeku.css +++ b/public/css/gadeku.css @@ -25,14 +25,114 @@ input, button { padding: 0.25rem; color: white; text-align: center; - background-color: blue; - border-bottom: solid 0.1rem blue; + background-color: #fdaf40; + border-bottom: solid 0.1rem #ffac03;; border-radius: 0.25rem; } .lkn-text h2, .lkn-text h3{ /* color: rgb(213, 78, 29); */ - color: blue; - border-bottom: solid 0.1rem blue; + color: #fdaf40; + border-bottom: solid 0.1rem #fdaf40; +} .lkn-text h4, .lkn-text h5{ + color: #d86d0c; +} +#lkn-header { background-color: #4cb2be; color: white;} +.lkn-text-frame-background{ background-color: #fdaf40 !important } +.lkn-noform-frame, +.lkn-standard-panel, +.lkn-edit-panel, +.lkn-create-panel, +.lkn-show-panel, +.lkn-panel, +.lkn-nav-tab-panel, +#main-content li.lkn-nav-item-active, +.lkn-filter, +.lkn-fieldset, +.lkn-form-table, +.lkn-filter, +.lkn-fieldset, +.lkn-form-table, +.lkn-text-frame, +.lkn-header-frame, +.lkn-pagination-block +{ + background-color: #fdaf4030; +} +.lkn-page-item.active .lkn-page-link { + background-color: #ffac03; + border-color: #ffac03; +} +.lkn-field-error { + color: red; +} +a.lnk-overview-cell, +a:visited.lkn-overview-cell, +a:link.lkn-overview-cell, +a:active.lkn-overview-cell { + border: 1px solid #ffac03; + color: #ffac03;; + box-shadow: 0 0 5px 0 #ffac03; +} +a.lkn-overview-cell, +a:visited.lkn-overview-cell, +a:link.lkn-overview-cell, +a:active.lkn-overview-cell { + background-color: #EEE; + color: #ffac03; +} +#main-content .nav-item { + background-color: #EEE; +} +.lkn-text-info { + color: #ffac03; +} +.lkn-text-info2 { + color: green; +} +.lkn-text-info3 { color: blue; -} \ No newline at end of file +} +.lkn-text-info4 { + color: cyan; +} +.lkn-text-error { + color: red; + background-color: yellow; +} +.lkn-text-warning { + color: green; + background-color: yellow; +} +.lkn-text-important { + color: red; +} +.lkn-text-tagged { + background-color: rgba(255, 166, 0, 0.418); +} +.lkn-text-tagged2 { + background-color: yellow; +} +.lkn-header-frame h1, .text-header-frame h2, .text-header-frame h3 { + color: whitesmoke; + background-color: #fdaf40; +} +.lkn-ins { + background-color: lightblue; +} +.lkn-del { + background-color: rgba(255, 166, 0, 0.418); +} +button.bg-primary { + background-color: #fdaf40 !important; +} +a, a:active.nav-item, a:link.nav-item, a:visited.nav-item, a:any-link.nav-item { color: #fdaf40; } +.bi { + color: #fdaf40 !important; +} +nav a:active, nav a:link, nav a:visited, nav a:any-link { + color: white; +} +.page-link { color: black !important; background-color: #fdaf4030;; } +.page-link.active, .active > .page-link { background-color: #fdaf40; } +.page-item { color: black; background-color: #EEE; } \ No newline at end of file diff --git a/resources/lang/sources/gadeku.de.json b/resources/lang/sources/gadeku.de.json index 80cbedd..1ef2458 100644 --- a/resources/lang/sources/gadeku.de.json +++ b/resources/lang/sources/gadeku.de.json @@ -9,6 +9,7 @@ "chapter": "Kapitel", "Chapter": "Kapitel", "Chapters": "Kapitel", +"cloze": "Lückentext", "cloze text": "Lückentext", "Comparative": "Komparativ", "Contents": "Inhalt", @@ -30,6 +31,8 @@ "Phrases": "Sätze", "Preposition": "Präposition", "snaketext": "Schlangentext", +"Snaketext": "Schlangentext", +"Solution": "Lösung", "Superlative": "Superlativ", "Translation": "Übersetzung", "Verb": "Verb", diff --git a/resources/views/layouts/backend.blade.php b/resources/views/layouts/backend.blade.php index fb80772..a674e59 100644 --- a/resources/views/layouts/backend.blade.php +++ b/resources/views/layouts/backend.blade.php @@ -26,7 +26,7 @@
-