From 6e0c7e87065418085ed150ea39242737ad9b6db6 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Thu, 27 Dec 2018 17:38:05 +0100 Subject: [PATCH] Feedback in V3 --- .env | 18 +- .idea/workspace.xml | 829 +++++++++--------- .../Controllers/CMSFeedbackController.php | 82 ++ app/Http/Controllers/DraftController.php | 6 + app/Models/Feedback.php | 74 ++ app/Models/Page.php | 13 + app/Services/HTMLHelper.php | 64 ++ app/helpers.php | 8 + config/app.php | 6 + .../2018_12_22_171112_create_page_table.php | 92 ++ public/js/custom.js | 2 +- resources/views/booking/index.blade.php | 2 + resources/views/cms/feedback/detail.blade.php | 179 ++++ resources/views/cms/feedback/index.blade.php | 106 +++ resources/views/drafts/index.blade.php | 100 ++- resources/views/layouts/application.blade.php | 24 +- .../layouts/includes/layout-sidenav.blade.php | 12 +- .../views/travel/program/detail.blade.php | 4 +- routes/web.php | 11 + 19 files changed, 1141 insertions(+), 491 deletions(-) create mode 100755 app/Http/Controllers/CMSFeedbackController.php create mode 100644 app/Models/Feedback.php create mode 100644 app/Models/Page.php create mode 100644 database/migrations/2018_12_22_171112_create_page_table.php create mode 100755 resources/views/cms/feedback/detail.blade.php create mode 100755 resources/views/cms/feedback/index.blade.php diff --git a/.env b/.env index 15e171f..4a0065b 100755 --- a/.env +++ b/.env @@ -5,14 +5,26 @@ APP_DEBUG=true APP_URL=http://crm-stern-tours.local APP_OLD_URL = http://cms-stern-tours.local +#APP_URL_V2=https://v2.stern-tours.de +APP_URL_V2=http://v2-sterntours.local + +#APP_URL_STERN=https://www.sterntours.de +APP_URL_STERN=http://sterntours.local + LOG_CHANNEL=stack DB_CONNECTION=mysql -DB_HOST=192.168.1.7 +DB_HOST=localhost DB_PORT=3306 DB_DATABASE=cmssso_db1 -DB_USERNAME=cmssso_1 -DB_PASSWORD=ZXk8Udm8 +DB_USERNAME=root +DB_PASSWORD=KT32vQ7 +# on neptune +#DB_HOST=192.168.1.7 +#DB_PORT=3306 +#DB_DATABASE=cmssso_db1 +#DB_USERNAME=cmssso_1 +#DB_PASSWORD=ZXk8Udm8 DB_CONNECTION_STERN=mysql diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7381de9..9837e73 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,52 +2,22 @@ - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - + + - - - - - - + - - - - + @@ -75,47 +45,53 @@ - - - + + + + - + - + + - - + + + + - + - - + + + - - + + + - - - + + + - - - - + + + + @@ -124,46 +100,35 @@ - + - - + + - - + - - - - - - + + - + - + - - - - - - - - - - - + + + + + @@ -176,6 +141,8 @@ datepicker url translations + draft + version @@ -192,9 +159,6 @@ @@ -252,6 +225,7 @@ + @@ -363,8 +337,8 @@ - @@ -432,6 +406,11 @@ + + + + + @@ -457,33 +436,39 @@ - + - - - - - - - - + - - + + + + + + + + + + + + + + + + + - - @@ -496,14 +481,15 @@ - + - + + @@ -512,13 +498,6 @@ - - - - - - - @@ -526,14 +505,6 @@ - - - - - - - - @@ -565,11 +536,11 @@ + + + - - - @@ -636,17 +607,26 @@ + + + + + + + + + - - + - + @@ -687,232 +667,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -920,27 +674,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -948,13 +681,6 @@ - - - - - - - @@ -962,48 +688,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1011,10 +695,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/Http/Controllers/CMSFeedbackController.php b/app/Http/Controllers/CMSFeedbackController.php new file mode 100755 index 0000000..c6832cc --- /dev/null +++ b/app/Http/Controllers/CMSFeedbackController.php @@ -0,0 +1,82 @@ + Feedback::all(),//Feedback::where('lvl', 1)->get(), + ]; + return view('cms.feedback.index', $data); + + } + + public function detail($id) + { + if($id == "new") { + $feedback = new Feedback(); + $id = 'new'; + + }else{ + $feedback = Feedback::findOrFail($id); + $id = $feedback->id; + } + $data = [ + 'feedback' => $feedback, + 'id' => $id, + ]; + return view('cms.feedback.detail', $data); + + } + + + public function store($id) + { + $data = Input::all(); + if($id == "new") { + $feedback = new Feedback(); + }else{ + $feedback = Feedback::findOrFail($id); + } + + $feedback->title = $data['title']; + $feedback->status = isset($data['status']) ? true : false; + $feedback->slug = $data['slug']; + $feedback->date = $data['date']; + $feedback->content = $data['content']; + $feedback->description = $data['description']; + $feedback->pagetitle = $data['pagetitle']; + $feedback->keywords = $data['keywords']; + + //parent + $feedback->save(); + + \Session()->flash('alert-save', '1'); + return redirect(route('cms_feedback_detail', [$feedback->id])); + + } + + +} diff --git a/app/Http/Controllers/DraftController.php b/app/Http/Controllers/DraftController.php index 10f6fa4..84c4731 100755 --- a/app/Http/Controllers/DraftController.php +++ b/app/Http/Controllers/DraftController.php @@ -120,6 +120,12 @@ class DraftController extends Controller foreach ($draft->draft_items as $draft_item){ $draft_item->delete(); } + + foreach ($draft->travel_program_drafts as $travel_program_draft){ + $travel_program_draft->delete(); + } + + $draft->delete(); \Session()->flash('alert-save', '1'); return redirect(route('drafts')); diff --git a/app/Models/Feedback.php b/app/Models/Feedback.php new file mode 100644 index 0000000..0e92d22 --- /dev/null +++ b/app/Models/Feedback.php @@ -0,0 +1,74 @@ +where('model', 'feedback'); + $query->orderBy('lvl', 'ASC'); + $query->orderBy('date', 'DESC'); + + }); + } + + public function parent() + { + return $this->belongsTo('App\Models\Feedback', 'owner'); + } + + public function getParent() + { + if ($this->lvl == 2) { + $this->parent(); + } + return false; + } + + + public function setContentAttribute($value) + { + if (!$value) { + $this->attributes['content'] = $value; + } else { + $this->attributes['content'] = HTMLHelper::filterHTML($value, ['src' => ['removeHost']], true); + } + } + + + + public function getParentsArray(){ + //lvl 0 + return Page::where('model', 'feedback')->where('lvl', 1)->get()->pluck('title', 'id'); + + } + //$feedbacks = Feedback::where('lvl', 1)->get(); + public function getDateRow() + { + return$this->attributes['date']; + } + + public function getDateAttribute() + { + return isset($this->attributes['date']) ? Carbon::parse($this->attributes['date'])->format("d.m.Y") : ''; + } + + public function setDateAttribute($value) + { + if (!$value) { + $this->attributes['date'] = null; + } else { + $this->attributes['date'] = (new Carbon($value))->format('Y-m-d'); + + } + } +} diff --git a/app/Models/Page.php b/app/Models/Page.php new file mode 100644 index 0000000..d2900e6 --- /dev/null +++ b/app/Models/Page.php @@ -0,0 +1,13 @@ +id; + } + if($empty){ + $ret .= '\n'; + } + foreach ($options as $id => $name){ + $attr = ($id === $setId) ? 'selected="selected"' : ''; + $ret .= '\n'; + } + return $ret; + } + + + public static function filterHTML($html, $arg = [], $save = false){ + + $dom = new \DOMDocument('1.0', 'UTF-8'); + //@$dom->loadHTML(); + + @$dom->loadHTML( mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); + + if(isset($arg['src'])){ + + if(in_array('addHost', $arg['src'])){ + $images = $dom->getElementsByTagName('img'); + foreach ($images as $image) { + + $src = $image->getAttribute('src'); + $host = config('app.url_stern'); + if(strpos($src, $host) === false){ + $src = $host."/".ltrim($src, '/'); + } + $image->setAttribute('src', $src); + } + } + + if(in_array('removeHost', $arg['src'])){ + $images = $dom->getElementsByTagName('img'); + foreach ($images as $image) { + $src = $image->getAttribute('src'); + $host = config('app.url_stern'); + if(strpos($src, $host) !== false){ + $src = str_replace($host, '', $src); + } + $image->setAttribute('src', $src); + } + } + } + $html = $dom->saveHTML(); + + $html = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\s*~i', '', $html); + + if($save){ + return mb_convert_encoding($html, "UTF-8", "HTML-ENTITIES"); + } + + + return $html; + } + /* public static function getIndustrySectorsWithoutParents($id = false, $sameId = false, $all = true){ $values = IndustrySector::where('parent_id', null)->get(); diff --git a/app/helpers.php b/app/helpers.php index f57e38d..f66a158 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -6,3 +6,11 @@ if (! function_exists('make_old_url')) { return config('app.old_url').$path; } } + + +if (! function_exists('make_v2_url')) { + function make_v2_url($path) + { + return config('app.url_v2').$path; + } +} diff --git a/config/app.php b/config/app.php index d99820a..4c2c742 100755 --- a/config/app.php +++ b/config/app.php @@ -56,6 +56,12 @@ return [ 'old_url' => env('APP_OLD_URL', 'http://cms-stern-tours.local'), + 'url_v2' => env('APP_URL_V2', 'https://v2.stern-tours.de'), + + 'url_stern' => env('APP_URL_STERN', 'https://www.sterntours.de'), + + + /* |-------------------------------------------------------------------------- | Application Timezone diff --git a/database/migrations/2018_12_22_171112_create_page_table.php b/database/migrations/2018_12_22_171112_create_page_table.php new file mode 100644 index 0000000..13363d5 --- /dev/null +++ b/database/migrations/2018_12_22_171112_create_page_table.php @@ -0,0 +1,92 @@ +increments('id'); + $table->integer('owner')->nullable()->default(0); + $table->string('model', 20)->nullable(); + $table->integer('owner_second'); + $table->integer('catalog_id')->nullable(); + $table->integer('catalog_index')->nullable()->default(0); + $table->string('slug', 255)->nullable(); + $table->integer('travel_program')->nullable(); + $table->integer('status')->nullable()->default(1); + $table->integer('show_in_navi')->nullable()->default(1); + $table->integer('order')->nullable()->default(0); + $table->string('title', 255)->nullable(); + $table->string('pagetitle', 255)->nullable(); + $table->text('description')->nullable(); + $table->text('keywords')->nullable(); + $table->text('content')->nullable(); + $table->text('content_new')->nullable(); + $table->string('buma_destination', 255)->nullable(); + $table->integer('OLD_CatalogID')->nullable(); + $table->integer('OLD_OwnerID')->nullable(); + $table->integer('buma_gjr')->nullable(); + $table->dateTime('date'); + $table->tinyInteger('price-tags')->default(0); + $table->text('text_right')->nullable(); + $table->string('keyword', 255)->nullable(); + $table->string('canonical_url', 511)->nullable(); + $table->integer('country_id')->nullable(); + $table->string('template', 80)->nullable(); + $table->integer('lft')->nullable(); + $table->integer('rgt')->nullable(); + $table->integer('lvl')->nullable(); + $table->integer('tree_root')->nullable(); + $table->integer('parent_id')->nullable(); + $table->string('real_url_path', 200)->nullable(); + $table->text('box_body')->nullable(); + $table->string('box_image_url', 200)->nullable(); + $table->string('box_star', 255)->nullable(); + $table->string('box_discount', 255)->nullable(); + $table->longText('cms_settings')->nullable(); + $table->integer('fewo_lodging')->nullable(); + + $table->unique('keyword', 'keyword'); + $table->unique('real_url_path', 'UNIQ_140AB620E2652A2A'); + $table->unique('fewo_lodging', 'UNIQ_140AB6209629C357'); + $table->index('tree_root', 'IDX_140AB620A977936C'); + $table->index('parent_id', 'IDX_140AB620727ACA70'); + + $table->foreign('parent_id', 'FK_140AB620727ACA70')->references('id')->on('page')->onDelete('CASCADE +')->onUpdate('RESTRICT'); + $table->foreign('fewo_lodging', 'FK_140AB6209629C357')->references('id')->on('fewo_lodging')->onDelete('SET NULL +')->onUpdate('RESTRICT'); + $table->foreign('tree_root', 'FK_140AB620A977936C')->references('id')->on('page')->onDelete('CASCADE +')->onUpdate('RESTRICT'); + $table->foreign('country_id', 'FK_page_travel_country')->references('id')->on('travel_country')->onDelete('SET NULL +')->onUpdate('RESTRICT'); + + }); + + + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('page'); + } +} diff --git a/public/js/custom.js b/public/js/custom.js index cfd4ccd..70db6ea 100644 --- a/public/js/custom.js +++ b/public/js/custom.js @@ -50,7 +50,7 @@ jQuery(document).ready(function() { $(function() { $('.datepicker-base').datepicker({ - orientation: 'auto right', + orientation: 'auto left', calendarWeeks: true, todayBtn: 'linked', daysOfWeekDisabled: '1', diff --git a/resources/views/booking/index.blade.php b/resources/views/booking/index.blade.php index 5c1cb46..7e20544 100755 --- a/resources/views/booking/index.blade.php +++ b/resources/views/booking/index.blade.php @@ -40,4 +40,6 @@ }); + + @endsection \ No newline at end of file diff --git a/resources/views/cms/feedback/detail.blade.php b/resources/views/cms/feedback/detail.blade.php new file mode 100755 index 0000000..4957556 --- /dev/null +++ b/resources/views/cms/feedback/detail.blade.php @@ -0,0 +1,179 @@ +@extends('layouts.layout-2') + +@section('content') + +

+ Feedback verwalten +

+ + {!! Form::open(['url' => route('cms_feedback_detail', [$id]), 'class' => 'form-horizontal']) !!} + + + +
+
+
+
+ + {{ Form::text('title', $feedback->title, array('placeholder'=>__('Title'), 'class'=>'form-control', 'id'=>'feedback_title', 'required'=>true)) }} +
+
+ + + +
+
+
+ +
+ + {{ Form::text('slug', $feedback->slug, array('placeholder'=>__('slug'), 'class'=>'form-control', 'id'=>'feedback_slug', 'required'=>true)) }} +
+
+ + {{ Form::text('date', $feedback->date, array('placeholder'=>__('Reisezeitraum'), 'class'=>'form-control datepicker-base', 'id'=>'feedback_date')) }} +
+ +
+ +
+
+ + {{ Form::textarea('content', HTMLHelper::filterHTML($feedback->content, ['src' => ['addHost']]) , ['class' => 'form-control summernote']) }} +
+
+ + +
+
+ + {{ Form::text('pagetitle', $feedback->pagetitle, array('placeholder'=>__('pagetitle'), 'class'=>'form-control', 'id'=>'feedback_pagetitle')) }} +
+
+ + {{ Form::text('description', $feedback->description, array('placeholder'=>__('description'), 'class'=>'form-control', 'id'=>'feedback_description')) }} +
+
+ + {{ Form::text('keywords', $feedback->keywords, array('placeholder'=>__('keywords'), 'class'=>'form-control', 'id'=>'feedback_keywords')) }} +
+
+ +
+
+ + +
+   + {{ __('back') }} + {{ __('zurück ins v2 Programm') }} +
+ + {!! Form::close() !!} + + {{-- + + + + + + + + + --}} + + +@endsection \ No newline at end of file diff --git a/resources/views/cms/feedback/index.blade.php b/resources/views/cms/feedback/index.blade.php new file mode 100755 index 0000000..3f87607 --- /dev/null +++ b/resources/views/cms/feedback/index.blade.php @@ -0,0 +1,106 @@ +@extends('layouts.layout-2') + +@section('content') + +

+ {{ __('Feedback') }} +

+ +
+
+ + + + + + + + + {{-- + + --}} + + + + @foreach($feedbacks as $value) + + + + + + + + {{-- + + --}} + + + @endforeach + +
 {{__('Name')}}{{__('Parent')}}{{__('Date')}}{{__('sichtbar')}}
+ + + + {{ $value->title }}@if($value->parent) {{ $value->parent->title }} @endif{{ $value->date }} + @if($value->status) + + @else + + @endif + + +
+
+ +
+
+ +
+ + + +@endsection \ No newline at end of file diff --git a/resources/views/drafts/index.blade.php b/resources/views/drafts/index.blade.php index 0d6be11..716731a 100755 --- a/resources/views/drafts/index.blade.php +++ b/resources/views/drafts/index.blade.php @@ -17,61 +17,59 @@
+