From 940e6e912b856fda875bee871f876a968fcae9f4 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Thu, 25 Apr 2024 18:32:19 +0200 Subject: [PATCH] V 0.2.1 Modul Page Added - Modul Page, ersetzt Article Deleted - Modul Article, wird durch Page ersetzt --- CHANGELOG.md | 9 + app/Helpers/dummy.html | 6 + app/Http/Controllers/ArticleController.php | 288 ------------------ app/Http/Controllers/PageController.php | 1 + app/Http/Controllers/WordController.php | 3 +- app/Models/Article.php | 24 -- app/Models/Page.php | 1 + composer.lock | 67 ++-- ...024_04_21_092103_create_articles_table.php | 34 --- .../2024_04_21_092103_create_pages_table.php | 1 + database/seeders/MenuitemArticleSeeder.php | 20 -- database/seeders/PageLocalSeeder.php | 22 ++ database/seeders/PageSeeder.php | 1 + database/seeders/SPropertyArticleSeeder.php | 26 -- lang/de_DE.json | 16 +- missing.seeders | 2 +- resources/lang/sources/gadeku.de.json | 7 - resources/views/article/create.blade.php | 19 -- resources/views/article/edit.blade.php | 27 -- resources/views/article/index.blade.php | 39 --- resources/views/article/show.blade.php | 17 -- resources/views/article/showpretty.blade.php | 17 -- resources/views/layouts/gadeku.blade.php | 5 +- resources/views/page | 1 + routes/web.php | 4 +- 25 files changed, 93 insertions(+), 564 deletions(-) delete mode 100644 app/Http/Controllers/ArticleController.php create mode 120000 app/Http/Controllers/PageController.php delete mode 100644 app/Models/Article.php create mode 120000 app/Models/Page.php delete mode 100644 database/migrations/2024_04_21_092103_create_articles_table.php create mode 120000 database/migrations/2024_04_21_092103_create_pages_table.php delete mode 100644 database/seeders/MenuitemArticleSeeder.php create mode 100644 database/seeders/PageLocalSeeder.php create mode 120000 database/seeders/PageSeeder.php delete mode 100644 database/seeders/SPropertyArticleSeeder.php delete mode 100644 resources/views/article/create.blade.php delete mode 100644 resources/views/article/edit.blade.php delete mode 100644 resources/views/article/index.blade.php delete mode 100644 resources/views/article/show.blade.php delete mode 100644 resources/views/article/showpretty.blade.php create mode 120000 resources/views/page diff --git a/CHANGELOG.md b/CHANGELOG.md index 77e2e0a..2c4ef2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# V 0.2.1 Modul Page + +## Added +- Modul Page, ersetzt Article + +## Deleted +- Modul Article, wird durch Page ersetzt + + # V 0.2.0 Module Article ## Added diff --git a/app/Helpers/dummy.html b/app/Helpers/dummy.html index e69de29..793860b 100644 --- a/app/Helpers/dummy.html +++ b/app/Helpers/dummy.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/Http/Controllers/ArticleController.php b/app/Http/Controllers/ArticleController.php deleted file mode 100644 index 6f02c0b..0000000 --- a/app/Http/Controllers/ArticleController.php +++ /dev/null @@ -1,288 +0,0 @@ -markup_scope; - switch ($type) { - case 1122: // mediawiki - $wiki = new MediaWiki(); - $text = $wiki->ToHtml($article->contents); - break; - case 1223: // html - $text = $article->contents; - break; - default: - case 1121: // plain text - $text = '

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

\n

", $article->contents) . "

"; - break; - } - return $text; - } - /** - * Show the form for creating a new resource. - */ - public function create(Request $request) - { - if ($request->btnSubmit === 'btnCancel') { - $rc = redirect('/article-index'); - } else { - $fields = $request->all(); - if (count($fields) === 0) { - $fields = [ - 'title' => '', - 'contents' => '', - 'info' => '', - 'articletype_scope' => '', - 'markup_scope' => '1122', - 'order' => '0', - 'audio_id' => '' - ]; - } - $optionsArticletype = SProperty::optionsByScope('articletype', $fields['articletype_scope'], '-'); - $optionsMarkup = SProperty::optionsByScope('markup', $fields['markup_scope'], '-'); - $context = new ContextLaraKnife($request, $fields); - $rc = view('article.create', [ - 'context' => $context, - 'optionsArticletype' => $optionsArticletype, - 'optionsMarkup' => $optionsMarkup, - ]); - } - return $rc; - } - /** - * Show the form for editing the specified resource. - */ - public function edit(Article $article, Request $request) - { - if ($request->btnSubmit === 'btnCancel') { - $rc = redirect('/article-index'); - } elseif ($request->btnSubmit === 'btnStore') { - $rc = $this->update($article, $request); - } else { - $fields = $request->all(); - if (count($fields) === 0) { - $fields = [ - 'title' => $article->title, - 'contents' => $article->contents, - 'info' => $article->info, - 'articletype_scope' => $article->articletype_scope, - 'markup_scope' => $article->markup_scope, - 'order' => $article->order ?? '0', - 'audio_id' => $article->audio_id - ]; - } else { - $fields['articletype_scope'] = $article->articletype_scope; - $fields['markup_scope'] = $article->markup_scope; - } - $optionsArticletype = SProperty::optionsByScope('articletype', $article->articletype_scope, ''); - $optionsMarkup = SProperty::optionsByScope('markup', $article->markup_scope, ''); - $fields = $request->btnSubmit !== 'btnPreview' ? null : ['preview' => $this->asPreview($article)]; - $context = new ContextLaraKnife($request, $fields, $article); - $rc = view('article.edit', [ - 'context' => $context, - 'optionsArticletype' => $optionsArticletype, - 'optionsMarkup' => $optionsMarkup, - ]); - } - return $rc; - } - /** - * Remove the specified resource from storage. - */ - public function destroy(Article $article, Request $request) - { - if ($request->btnSubmit === 'btnDelete') { - $article->delete(); - } - return redirect('/article-index'); - } - /** - * Display the database records of the resource. - */ - public function index(Request $request) - { - if ($request->btnSubmit === 'btnNew') { - return redirect('/article-create'); - } else { - $sql = " -SELECT t0.*, - t1.name as articletype_scope, - t2.name as markup_scope, - t3.name as audio_id -FROM articles t0 -LEFT JOIN sproperties t1 ON t1.id=t0.articletype_scope -LEFT JOIN sproperties t2 ON t2.id=t0.markup_scope -LEFT JOIN sproperties t3 ON t3.id=t0.audio_id -"; - $parameters = []; - $fields = $request->all(); - if (count($fields) == 0) { - $fields = [ - 'articletype' => '', - 'markup' => '', - 'text' => '', - '_sortParams' => 'title:asc;id:asc' - ]; - } else { - $conditions = []; - ViewHelper::addConditionComparism($conditions, $parameters, 'articletype_scope', 'articletype'); - ViewHelper::addConditionComparism($conditions, $parameters, 'markup_scope', 'markup'); - ViewHelper::addConditionPattern($conditions, $parameters, 'title,info,contents', 'text'); - $sql = DbHelper::addConditions($sql, $conditions); - } - $sql = DbHelper::addOrderBy($sql, $fields['_sortParams']); - $pagination = new Pagination($sql, $parameters, $fields); - $records = $pagination->records; - $optionsArticletype = SProperty::optionsByScope('articletype', $fields['articletype'], 'all'); - $optionsMarkup = SProperty::optionsByScope('markup', $fields['markup'], 'all'); - $context = new ContextLaraKnife($request, $fields); - return view('article.index', [ - 'context' => $context, - 'records' => $records, - 'optionsArticletype' => $optionsArticletype, - 'optionsMarkup' => $optionsMarkup, - 'pagination' => $pagination - ]); - } - } - /** - * Returns the validation rules. - * @return array The validation rules. - */ - private function rules(bool $isCreate = false): array - { - $rc = [ - 'title' => 'required', - 'contents' => 'required', - 'info' => '', - 'order' => 'integer|min:0|max:9999' - ]; - if ($isCreate) { - $rc['markup_scope'] = 'required'; - $rc['articletype_scope'] = 'required'; - } - return $rc; - } - public static function routes() - { - Route::get('/article-index', [ArticleController::class, 'index'])->middleware('auth'); - Route::post('/article-index', [ArticleController::class, 'index'])->middleware('auth'); - Route::get('/article-create', [ArticleController::class, 'create'])->middleware('auth'); - Route::put('/article-store', [ArticleController::class, 'store'])->middleware('auth'); - Route::post('/article-edit/{article}', [ArticleController::class, 'edit'])->middleware('auth'); - Route::get('/article-edit/{article}', [ArticleController::class, 'edit'])->middleware('auth'); - Route::post('/article-update/{article}', [ArticleController::class, 'update'])->middleware('auth'); - Route::get('/article-show/{article}/delete', [ArticleController::class, 'show'])->middleware('auth'); - Route::delete('/article-show/{article}/delete', [ArticleController::class, 'destroy'])->middleware('auth'); - Route::get('/article-showpretty/{article}', [ArticleController::class, 'showPretty'])->middleware('auth'); - Route::post('/article-showpretty/{article}', [ArticleController::class, 'showPretty'])->middleware('auth'); - } - /** - * Display the specified resource. - */ - public function show(Article $article, Request $request) - { - if ($request->btnSubmit === 'btnCancel') { - $rc = redirect('/article-index')->middleware('auth'); - } else { - $optionsArticletype = SProperty::optionsByScope('articletype', $article->articletype_scope, ''); - $optionsMarkup = SProperty::optionsByScope('markup', $article->markup_scope, ''); - $context = new ContextLaraKnife($request, null, $article); - $rc = view('article.show', [ - 'context' => $context, - 'optionsArticletype' => $optionsArticletype, - 'optionsMarkup' => $optionsMarkup, - 'mode' => 'delete' - ]); - } - return $rc; - } - public function showPretty(Article $article, Request $request) - { - if ($request->btnSubmit === 'btnCancel') { - $rc = redirect('/article-index')->middleware('auth'); - } else { - $text = $this->asPreview($article); - $link = $article->audio_id == null ? null : File::relativeFileLink($article->audio_id); - $context = new ContextLaraKnife($request, ['text' => $text, 'link' => $link], $article); - $rc = view('article.showpretty', [ - 'context' => $context, - 'mode' => 'delete' - ]); - } - return $rc; - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - $rc = null; - if ($request->btnSubmit === 'btnStore') { - $fields = $request->all(); - $validator = Validator::make($fields, $this->rules(true)); - if ($validator->fails()) { - $rc = back()->withErrors($validator)->withInput(); - } else { - $validated = $validator->validated(); - $validated['info'] = strip_tags($validated['info']); - $validated['contents'] = TextProcessor::expandStarItems(strip_tags($validated['contents'])); - Article::create($validated); - } - } - if ($rc == null) { - $rc = redirect('/article-index'); - } - return $rc; - } - /** - * Update the specified resource in storage. - */ - public function update(Article $article, Request $request) - { - $rc = null; - if ($request->btnSubmit === 'btnStore') { - $fields = $request->all(); - $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($article->audio_id) && $request->file('file') != null) { - $filename = FileHelper::textToFilename($article->title); - $moduleId = Module::idOfModule('Article'); - $fileId = File::storeFile($request, $article->title, 1103, 1091, 'audio file of article', $filename, $moduleId, $article->id); - $validated['audio_id'] = $fileId; - } - $article->update($validated); - } - } - if ($rc == null) { - $rc = redirect("/article-edit/$article->id"); - } - return $rc; - } -} diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php new file mode 120000 index 0000000..eefdef5 --- /dev/null +++ b/app/Http/Controllers/PageController.php @@ -0,0 +1 @@ +../../../vendor/hamatoma/laraknife/templates/Http/Controllers/PageController.php \ No newline at end of file diff --git a/app/Http/Controllers/WordController.php b/app/Http/Controllers/WordController.php index 15b5402..18bd4b9 100644 --- a/app/Http/Controllers/WordController.php +++ b/app/Http/Controllers/WordController.php @@ -73,8 +73,7 @@ class WordController extends Controller 'word' => $word->word, 'usage' => $phrase->phrase, 'wordtype_scope' => $phrase->wordtype_scope, - 'language' => $request->language, - 'language' => SProperty::idOfLocalization(), + 'language' => SProperty::idOfLocalization(auth()->user()->localization), 'lastLanguage' => '', 'translation' => '' ]; diff --git a/app/Models/Article.php b/app/Models/Article.php deleted file mode 100644 index 2cd86c8..0000000 --- a/app/Models/Article.php +++ /dev/null @@ -1,24 +0,0 @@ -id(); - $table->timestamps(); - $table->string('title'); - $table->text('contents'); - $table->text('info')->nullable(); - $table->integer('articletype_scope'); - $table->integer('markup_scope'); - $table->integer('order')->nullable(); - $table->foreignId('audio_id')->nullable()->references('id')->on('files'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('articles'); - } -}; diff --git a/database/migrations/2024_04_21_092103_create_pages_table.php b/database/migrations/2024_04_21_092103_create_pages_table.php new file mode 120000 index 0000000..558b3d7 --- /dev/null +++ b/database/migrations/2024_04_21_092103_create_pages_table.php @@ -0,0 +1 @@ +../../vendor/hamatoma/laraknife/templates/database/migrations/2024_04_21_092103_create_pages_table.php \ No newline at end of file diff --git a/database/seeders/MenuitemArticleSeeder.php b/database/seeders/MenuitemArticleSeeder.php deleted file mode 100644 index 4680a8d..0000000 --- a/database/seeders/MenuitemArticleSeeder.php +++ /dev/null @@ -1,20 +0,0 @@ -": "", "Adjective": "Adjektiv", -"Article": "Artikel", -"Articles": "Artikel", -"articletype": "Artikeltyp", -"Articletype": "Artikeltyp", -"Change of an Article": "Änderung eines Artikels", "Change of a Chapter": "Änderung eines Kapitels", "Change of a Noun": "Änderung eines Nomens", "Change of a Phrase": "Änderung eines Satzes", @@ -17,10 +12,8 @@ "Chapters": "Kapitel", "cloze text": "Lückentext", "Contents": "Inhalt", -"Creation of an Article": "Neuer Artikel", "Creation of a Chapter": "Neues Kapitel", "Creation of a Verb": "Neues Verb", -"Deletion of an Article": "Löschen eines Artikels", "Deletion of a Noun": "Löschen eines Nomens", "Deletion of a Verb": "Löschen eines Verbs", "Deletion of a Word": "Löschen eines Wortes", diff --git a/resources/views/article/create.blade.php b/resources/views/article/create.blade.php deleted file mode 100644 index 87a8715..0000000 --- a/resources/views/article/create.blade.php +++ /dev/null @@ -1,19 +0,0 @@ -@extends('layouts.backend') - -@section('content') -
- @csrf - @method('PUT') - - - - - - - -
-@endsection diff --git a/resources/views/article/edit.blade.php b/resources/views/article/edit.blade.php deleted file mode 100644 index 20e34a1..0000000 --- a/resources/views/article/edit.blade.php +++ /dev/null @@ -1,27 +0,0 @@ -@extends('layouts.backend') - -@section('content') -
- @csrf - - - - - - - - - - @if(! empty($context->valueOf('preview'))) -
{!! $context->valueOf('preview') !!} -
- @endif -
-
-@endsection diff --git a/resources/views/article/index.blade.php b/resources/views/article/index.blade.php deleted file mode 100644 index 7395645..0000000 --- a/resources/views/article/index.blade.php +++ /dev/null @@ -1,39 +0,0 @@ -@extends('layouts.backend') - -@section('content') -
- @csrf - - - - - - - - - - - - {{__('Title')}} - {{__('Articletype')}} - {{__('Markup')}} - {{__('Order')}} - - - - -@foreach ($records as $article) - - - {{$article->title}} - {{ __($article->articletype_scope) }} - {{ __($article->markup_scope) }} - {{$article->order}} - - -@endforeach - - - -
-@endsection diff --git a/resources/views/article/show.blade.php b/resources/views/article/show.blade.php deleted file mode 100644 index 7010ef0..0000000 --- a/resources/views/article/show.blade.php +++ /dev/null @@ -1,17 +0,0 @@ -@extends('layouts.backend') - -@section('content') -
- @csrf - @if($mode === 'delete') - @method('DELETE') - @endif - - - - - - - -
-@endsection diff --git a/resources/views/article/showpretty.blade.php b/resources/views/article/showpretty.blade.php deleted file mode 100644 index 7506e3c..0000000 --- a/resources/views/article/showpretty.blade.php +++ /dev/null @@ -1,17 +0,0 @@ -@extends('layouts.backend') - -@section('content') -
- @csrf - -
- {!! $context->valueOf('text') !!} -
-
- @if ($context->valueof('link') != null) -
- -
- @endif -
-@endsection diff --git a/resources/views/layouts/gadeku.blade.php b/resources/views/layouts/gadeku.blade.php index 09624b6..77546c2 100644 --- a/resources/views/layouts/gadeku.blade.php +++ b/resources/views/layouts/gadeku.blade.php @@ -25,7 +25,10 @@