From ee8584a2d5adb5ab9725550034a56f2d9573daef Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Wed, 12 Sep 2018 17:30:42 +0200 Subject: [PATCH] new static page links --- .../Settings/LicenseController.php | 14 ++++-- .../Controllers/Settings/PageController.php | 11 +++-- app/Models/License.php | 12 ++--- app/Models/Page.php | 30 ++++++------ resources/lang/en/exceptions.php | 7 +++ resources/lang/en/resources.php | 49 +++++++++---------- .../views/frontend/pages/index.blade.php | 13 ++++- resources/views/layouts/app.blade.php | 9 ++-- .../views/settings/license/edit.blade.php | 4 +- resources/views/settings/page/edit.blade.php | 23 +++++++-- 10 files changed, 110 insertions(+), 62 deletions(-) diff --git a/app/Http/Controllers/Settings/LicenseController.php b/app/Http/Controllers/Settings/LicenseController.php index 501a81b..a82141b 100644 --- a/app/Http/Controllers/Settings/LicenseController.php +++ b/app/Http/Controllers/Settings/LicenseController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; use Illuminate\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; +use App\Exceptions\GeneralException; class LicenseController extends Controller { @@ -51,8 +52,15 @@ class LicenseController extends Controller $license = License::findOrFail($id); $input = $request->all(); - $license->update($input); - session()->flash('flash_message', 'You have updated the license!'); - return redirect()->route('settings.license'); + if ($license->update($input)) { + // event(new PageUpdated($page)); + return redirect() + ->route('settings.license') + ->with('flash_message', 'You have updated the license!'); + } + throw new GeneralException(trans('exceptions.backend.licenses.update_error')); + // $license->update($input); + // session()->flash('flash_message', 'You have updated the license!'); + // return redirect()->route('settings.license'); } } diff --git a/app/Http/Controllers/Settings/PageController.php b/app/Http/Controllers/Settings/PageController.php index 6c931c8..bf67cb9 100644 --- a/app/Http/Controllers/Settings/PageController.php +++ b/app/Http/Controllers/Settings/PageController.php @@ -11,6 +11,7 @@ use Illuminate\View\View; use Illuminate\Http\RedirectResponse; use App\Exceptions\GeneralException; use App\Events\Pages\PageUpdated; +use Illuminate\Support\Facades\DB; class PageController extends Controller { @@ -69,8 +70,12 @@ class PageController extends Controller */ public function edit(Page $page) { - return view('settings.page.edit') - ->withPage($page); + $languages = DB::table('languages') + ->where('active', true) + ->pluck('part2_t', 'part2_t'); + + return view('settings.page.edit', compact('page', 'languages')); + // ->withPage($page); } /** @@ -85,7 +90,7 @@ class PageController extends Controller // $this->pages->update($page, $request->except(['_method', '_token'])); $input = $request->except(['_method', '_token']); // Making extra fields - $input['page_slug'] = str_slug($input['title']); + //$input['page_slug'] = str_slug($input['title']); $input['status'] = isset($input['status']) ? 1 : 0; $input['updated_by'] = \Auth::user()->id; diff --git a/app/Models/License.php b/app/Models/License.php index c19b206..55d2906 100644 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -10,17 +10,17 @@ class License extends Model public $timestamps = false; protected $fillable = [ - 'active', - 'desc_text', - 'desc_text', - 'desc_text', + 'name_long', 'language', 'link_licence', 'link_logo', + 'desc_text', + 'desc_markup', + 'comment_internal', 'mime_type', - 'name_long', - 'pod_allowed', 'sort_order', + 'active', + 'pod_allowed' ]; public function datasets() diff --git a/app/Models/Page.php b/app/Models/Page.php index 6869eab..7d53c08 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -2,14 +2,14 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; -use App\Models\User; use App\Models\ModelTrait; +use App\Models\User; +use Illuminate\Database\Eloquent\Model; class Page extends Model { use ModelTrait; - /** + /** * The database table used by the model. * * @var string @@ -32,12 +32,14 @@ class Page extends Model 'created_by' => 1, ]; + //You can specify default eager loaded relationships using the $with property on the model. + //https://stackoverflow.com/questions/25674143/laravel-whenever-i-return-a-model-always-return-a-relationship-with-it protected $with = ['owner']; public function __construct(array $attributes = []) { parent::__construct($attributes); - $this->table = 'pages';//config('module.pages.table'); + $this->table = 'pages'; //config('module.pages.table'); } public function owner() @@ -45,41 +47,41 @@ class Page extends Model return $this->belongsTo(User::class, 'created_by'); } - /** + /** * @return string */ public function getActionButtonsAttribute() { return '
- '.$this->getEditButtonAttribute('page', 'settings.page.edit').' - '.$this->getViewButtonAttribute().' - '.$this->getDeleteButtonAttribute('page', 'settings.page.destroy').' + ' . $this->getEditButtonAttribute('page', 'settings.page.edit') . ' + ' . $this->getViewButtonAttribute() . '
'; + // '.$this->getDeleteButtonAttribute('page', 'settings.page.destroy').' } - /** + /** * @return string */ public function getViewButtonAttribute() { return ' + ' . route('frontend.pages.show', $this->page_slug) . ' " class="btn btn-flat btn-default"> '; } - /** + /** * @return string */ public function getStatusLabelAttribute() { if ($this->isActive()) { - return "'; + return "'; } - return "'; + return "'; } - + /** * @return bool */ diff --git a/resources/lang/en/exceptions.php b/resources/lang/en/exceptions.php index b8fd4b0..80a6172 100644 --- a/resources/lang/en/exceptions.php +++ b/resources/lang/en/exceptions.php @@ -22,6 +22,13 @@ return [ 'not_found' => 'That Page does not exist.', 'update_error' => 'There was a problem updating this Page. Please try again.', ], + 'licenses' => [ + 'already_exists' => 'That License already exists. Please choose a different name.', + 'create_error' => 'There was a problem creating this License. Please try again.', + 'delete_error' => 'There was a problem deleting this License. Please try again.', + 'not_found' => 'That License does not exist.', + 'update_error' => 'There was a problem updating this License. Please try again.', + ], ], 'frontend' => [], ]; diff --git a/resources/lang/en/resources.php b/resources/lang/en/resources.php index e7ae8f5..d8d6ce0 100644 --- a/resources/lang/en/resources.php +++ b/resources/lang/en/resources.php @@ -1,46 +1,45 @@ 'Laravel Internationalization example.', + 'msg' => 'Laravel Internationalization example.', - 'home_index_label' => 'Home', - 'home_index_pagetitle' => 'Home', - 'home_index_title' => 'Publication Server of XYZ University', - 'home_index_welcome' => 'The library offers to publish electronically generated and + 'home_index_label' => 'Home', + 'home_index_pagetitle' => 'Home', + 'home_index_title' => 'Publication Server of XYZ University', + 'home_index_welcome' => 'The library offers to publish electronically generated and qualified documents on its online publication system. This service is for university members only and free of charge. After publication, the texts are available worldwide on the Internet and will be archived permanently by the library. The documents are indexed and made accessible in library catalogues and Web search engines.', - 'home_index_instructions' => 'If you want to search for documents of the university, please + 'home_index_instructions' => 'If you want to search for documents of the university, please choose the menu "Search" where you will find several search options. If you want to publish a document, please select the menu "Publish"; here you can submit your document to the publication server in just a few steps.', - 'home_index_imprint_pagetitle' => 'Imprint', - 'home_index_imprint_title' => 'Legal notice according to § 5 E-Commerce-Gesetz (Austria)', - 'help_content_imprint' => Illuminate\Support\Facades\File::get(resource_path() . '/lang/en/imprint.en.txt'), + 'home_index_imprint_pagetitle' => 'Imprint', + 'home_index_imprint_title' => 'Legal notice according to § 5 E-Commerce-Gesetz (Austria)', + 'help_content_imprint' => Illuminate\Support\Facades\File::get(resource_path() . '/lang/en/imprint.en.txt'), - 'home_index_contact_pagetitle' => 'Contact', - 'home_index_contact_title' => 'Contact us...', + 'home_index_contact_pagetitle' => 'Contact', + 'home_index_contact_title' => 'Contact us...', - 'home_about_pagetitle' => 'About Us', - 'home_about_title' => 'About us...', - 'home_about_content' => 'RDR (Research Data Repository) is an interdisciplinary digital data repository for the archival and publication of research data resulting from completed scientific studies and projects. RDR focuses on disciplines who do not have a tradition of data sharing thus ensuring better availability, sustainable preservation and (independent) publication capacity of their research data.', + 'home_about_pagetitle' => 'About Us', + 'home_about_title' => 'About us...', + 'home_about_content' => 'RDR (Research Data Repository) is an interdisciplinary digital data repository for the archival and publication of research data resulting from completed scientific studies and projects. RDR focuses on disciplines who do not have a tradition of data sharing thus ensuring better availability, sustainable preservation and (independent) publication capacity of their research data.', - 'home_news_pagetitle' => 'News', + 'home_news_pagetitle' => 'News', + 'solrsearch_title_simple' => 'Search', + 'solrsearch_title_advanced' => 'Advanced Search', + 'solrsearch_title_alldocs' => 'All datasets', + 'solrsearch_searchaction' => 'Search', + 'solrsearch_title_latest' => 'Latest Documents', - 'solrsearch_title_simple' => 'Search', - 'solrsearch_title_advanced' => 'Advanced Search', - 'solrsearch_title_alldocs' => 'All datasets', - 'solrsearch_searchaction' => 'Search', - 'solrsearch_title_latest' => 'Latest Documents', + 'rss_icon' => 'subscribe to RSS feed', + 'rss_title' => 'subscribe to RSS feed', - 'rss_icon' =>'subscribe to RSS feed', - 'rss_title' => 'subscribe to RSS feed', - - 'default_auth_index' => 'Login', - 'auth_pagetitle' => 'User Login', + 'default_auth_index' => 'Login', + 'auth_pagetitle' => 'User Login', ]; diff --git a/resources/views/frontend/pages/index.blade.php b/resources/views/frontend/pages/index.blade.php index 8d94ee3..a4dab32 100644 --- a/resources/views/frontend/pages/index.blade.php +++ b/resources/views/frontend/pages/index.blade.php @@ -1,5 +1,16 @@ @extends('layouts.app') @section('content') - {!! $page->description !!} +
+

+ {!! $page->title !!} +

+ +
+

+ {!! $page->description !!} +

+
+
+ @endsection \ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 1e58136..68aa9f2 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -56,7 +56,8 @@

About RDR

@@ -66,10 +67,10 @@