Commit 1d9d6d40 by Triyah Fatmawati

Allow strip tags tabel

parent 23cf8977
......@@ -72,13 +72,11 @@ class CategoryController extends Controller
*/
public function store(Request $request)
{
// dd($request);
$request['name'] = strip_tags($request->name);
$request->validate([
'name' => 'required'
], [
'name.required' => 'Kategori wajib diisi',
// 'name.regex' => 'Kategori tidak valid! Kategori hanya berupa angka dan huruf',
// 'name.max' => 'Kategori terlalu panjang'
]);
$data = $request->except('_token');
......@@ -98,7 +96,7 @@ class CategoryController extends Controller
private function createEn($data, $category)
{
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGET, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['name']));
$dataEn['category_id'] = $category->id;
$dataEn['name'] = $name;
......@@ -109,7 +107,7 @@ class CategoryController extends Controller
private function createDe($data, $category)
{
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGETDE, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['name']));
$dataDe['category_id'] = $category->id;
$dataDe['name'] = $name;
......@@ -120,7 +118,7 @@ class CategoryController extends Controller
private function createSa($data, $category)
{
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGETSA, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['name']));
$dataSa['category_id'] = $category->id;
$dataSa['name'] = $name;
......@@ -131,7 +129,7 @@ class CategoryController extends Controller
private function createZh($data, $category)
{
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGETZH, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['name']));
$dataZh['category_id'] = $category->id;
$dataZh['name'] = $name;
......@@ -179,7 +177,6 @@ class CategoryController extends Controller
'data' => $data,
'manual' => $manual,
];
// dd($data);
return view('webprofile.backend.categories.edit_per_bahasa', $data)->withTitle(trans('feature.edit_category'));
}
......@@ -193,15 +190,13 @@ class CategoryController extends Controller
*/
public function update(Request $request, $id)
{
// dd($request);
$request['name'] = strip_tags($request->name);
$request->validate([
'name' => 'required',
], [
'name.required' => 'Kategori wajib diisi',
// 'name.regex' => 'Kategori tidak valid! Kategori hanya berupa angka dan huruf',
// 'name.max' => 'Kategori terlalu panjang',
]);
// dd($request);
$data = $request->except(['_token', 'manual', 'id', 'name_en', 'name_de', 'name_sa', 'name_zh']);
// // $dataEn = $request->except(['_token', 'id', 'name_de']);
$dataEn = $request->except(['_token','id', 'manual']);
......@@ -211,20 +206,19 @@ class CategoryController extends Controller
// $dataEn['name_sa'] = htmlspecialchars($request->name_sa);
// $dataEn['name_zh'] = htmlspecialchars($request->name_zh);
// // $dataDe = $request->except(['_token', 'id', 'name', 'name_en']);
// // dd($request, $dataEn);
array_key_exists('is_active', $data) ? $data['is_active'] = 1 : $data['is_active'] = 0;
$category = $this->repo->findId($id, ['rEn', 'rDe', 'rSa', 'rZh']);
// $edit = $this->repo->update($data, $category);
// dd($dataEn, $category, $request->manual);
$this->updateEn($dataEn, $category, $request->manual);
$this->updateDe($dataEn, $category, $request->manual);
$this->updateSa($dataEn, $category, $request->manual);
$this->updateZh($dataEn, $category, $request->manual);
$this->repo->update($data, $category);
// dd($data, $category, $request->manual);
return redirect()->route('category.index');
}
......@@ -240,24 +234,20 @@ class CategoryController extends Controller
// $this->repoEn->store($dataEn);
// }
// dd($data, $category, $manual);
// dd($data, $category, $manual);
if($manual==1){
$dataEn['name'] = $data['name_en'];
$dataEn['name'] = strip_tags($data['name_en']);
}
else{
if (strip_tags($data['name']) == null) {
if ($data['name'] == null) {
$data['name'] = 'kosong';
}
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGET, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['name']));
$dataEn['name'] = $name;
// dd($dataEn);
}
// dd($category);
$this->repoEn->update($dataEn, $category);
}
......@@ -275,15 +265,15 @@ class CategoryController extends Controller
// }
if($manual==1){
$dataDe['name'] = $data['name_de'];
$dataDe['name'] = strip_tags($data['name_de']);
}
else{
if (strip_tags($data['name']) == null) {
if ($data['name'] == null) {
$data['name'] = 'kosong';
}
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGETDE, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['name']));
$dataDe['name'] = $name;
}
$this->repoDe->update($dataDe, $category);
......@@ -303,15 +293,15 @@ class CategoryController extends Controller
// }
if($manual==1){
$dataSa['name'] = $data['name_sa'];
$dataSa['name'] = strip_tags($data['name_sa']);
}
else{
if (strip_tags($data['name']) == null) {
if ($data['name'] == null) {
$data['name'] = 'kosong';
}
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGETSA, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['name']));
$dataSa['name'] = $name;
}
$this->repoSa->update($dataSa, $category);
......@@ -331,15 +321,15 @@ class CategoryController extends Controller
// }
if($manual==1){
$dataZh['name'] = $data['name_zh'];
$dataZh['name'] = strip_tags($data['name_zh']);
}
else{
if (strip_tags($data['name']) == null) {
if ($data['name'] == null) {
$data['name'] = 'kosong';
}
$trans = new GoogleTranslate();
$name = $trans->translate($this->SOURCE, $this->TARGETZH, $data['name']);
$name = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['name']));
$dataZh['name'] = $name;
}
$this->repoZh->update($dataZh, $category);
......
......@@ -79,7 +79,6 @@ class PageController extends Controller
*/
public function store(Request $request)
{
// dd($request);
$request['content'] = strip_tags($request->content, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
$request['title'] = strip_tags($request->title);
$request->validate([
......@@ -88,11 +87,8 @@ class PageController extends Controller
'keys' => 'max:100'
], [
'title.required' => 'Judul wajib diisi',
// 'title.regex' => 'Judul tidak valid! Judul hanya berupa angka dan huruf',
// 'title.max' => 'Judul terlalu panjang',
'content.required' => 'Konten wajib diisi',
'content.min' => 'Konten terlalu singkat',
// 'keys.regex' => 'Keyword tidak valid! Keyword hanya berupa angka dan huruf',
'keys.max' => 'Keyword terlalu panjang'
]);
......@@ -245,7 +241,6 @@ class PageController extends Controller
*/
public function update(Request $request, $id)
{
// dd($request);
$request['content'] = strip_tags($request->content, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
$request['content_en'] = strip_tags($request->content_en, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
$request['content_de'] = strip_tags($request->content_de, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
......@@ -255,19 +250,14 @@ class PageController extends Controller
$request['title_en'] = strip_tags($request->title_en);
$request['title_de'] = strip_tags($request->title_de);
$request['title_sa'] = strip_tags($request->title_sa);
$request['title_zh'] = strip_tags($request->title_zh);
$request['title_zh'] = strip_tags($request->title_zh);
$request->validate([
// 'title' => 'required',
'content' => 'required|min:3',
'keys' => 'max:100'
], [
'title.required' => 'Judul wajib diisi',
// 'title.regex' => 'Judul tidak valid! Judul hanya berupa angka dan huruf',
// 'title.max' => 'Judul terlalu panjang',
'content.required' => 'Konten wajib diisi',
'content.min' => 'Konten terlalu singkat',
// 'keys.regex' => 'Keyword tidak valid! Keyword hanya berupa angka dan huruf',
'keys.max' => 'Keyword terlalu panjang'
]);
......@@ -284,10 +274,10 @@ class PageController extends Controller
// $dataEn['title_zh'] = htmlspecialchars($request->title_zh);
// $dataEn['content'] = htmlspecialchars($request->content);
// $dataEn['content_en'] = htmlspecialchars($request->content_en);
// $dataEn['content_de'] = htmlspecialchars($request->content_de);
// $dataEn['content_sa'] = htmlspecialchars($request->content_sa);
// $dataEn['content_de'] = htmlspecialchars($request->content_de);
// $dataEn['content_sa'] = htmlspecialchars($request->content_sa);
// $dataEn['content_zh'] = htmlspecialchars($request->content_zh);
$page = $this->repo->findId($id, ['rEn', 'rDe', 'rSa', 'rZh']);
// $edit = $this->repo->update($data, $page);
......@@ -303,8 +293,8 @@ class PageController extends Controller
public function updateEn($data, $page, $manual)
{
if ($manual==1){
$dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en'];
$dataEn['title'] = strip_tags($data['title_en']);
$dataEn['content'] = strip_tags($data['content_en'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
}
else{
if ($data['content'] == null) {
......@@ -325,8 +315,8 @@ class PageController extends Controller
public function updateDe($data, $page, $manual)
{
if($manual==1){
$dataDe['title'] = $data['title_de'];
$dataDe['content'] = $data['content_de'];
$dataDe['title'] = strip_tags($data['title_de']);
$dataDe['content'] = strip_tags($data['content_de'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
}
else{
if($data['content']==null){
......@@ -346,8 +336,8 @@ class PageController extends Controller
public function updateSa($data, $page, $manual)
{
if($manual==1){
$dataSa['title'] = $data['title_sa'];
$dataSa['content'] = $data['content_sa'];
$dataSa['title'] = strip_tags($data['title_sa']);
$dataSa['content'] = strip_tags($data['content_sa'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
}
else{
if($data['content']==null){
......@@ -361,15 +351,15 @@ class PageController extends Controller
$dataSa['title'] = $title;
$dataSa['content'] = $content;
}
$this->repoSa->update($dataSa, $page);
}
public function updateZh($data, $page, $manual)
{
if($manual==1){
$dataZh['title'] = $data['title_zh'];
$dataZh['content'] = $data['content_zh'];
$dataZh['title'] = strip_tags($data['title_zh']);
$dataZh['content'] = strip_tags($data['content_zh'],['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img', 'table', 'td', 'th', 'tr', 'iframe']);
}
else{
if($data['content']==null){
......
......@@ -60,7 +60,6 @@ class UserController extends Controller
*/
public function store(UserRequest $request)
{
// dd($request);
$request->validate([
'password' => 'required|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$/|min:8|confirmed',
], [
......
......@@ -15,7 +15,7 @@
@section('breadcrumbs')
<li><a href="{{ url('home') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.create_post')</li>
<li class="active">@lang('feature.edit_post')</li>
@stop
@section('content')
......@@ -61,13 +61,13 @@
</div>
</div>
{{-- <div class="tabs">
{{-- <div class="tabs">
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#inggris" role="tab" data-toggle="tab" aria-expanded="true">Inggris</a></li>
<li class=""><a href="#jerman" role="tab" data-toggle="tab" aria-expanded="false">Jerman</a></li>
<li class=""><a href="#arab" role="tab" data-toggle="tab" aria-expanded="false">Arab</a></li>
<li class=""><a href="#cina" role="tab" data-toggle="tab" aria-expanded="false">Cina</a></li>
</ul>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="inggris">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
......@@ -295,7 +295,7 @@
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
$(document).ready(function() {
$('#content').summernote({
height: 350
......
......@@ -15,7 +15,7 @@
@section('breadcrumbs')
<li><a href="{{ url('home') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.create_post')</li>
<li class="active">@lang('feature.edit_post')</li>
@stop
@section('content')
......@@ -60,13 +60,13 @@
</div>
</div>
</div>
<div class="tabs">
<div class="tabs">
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#inggris" role="tab" data-toggle="tab" aria-expanded="true">Inggris</a></li>
<li class=""><a href="#jerman" role="tab" data-toggle="tab" aria-expanded="false">Jerman</a></li>
<li class=""><a href="#arab" role="tab" data-toggle="tab" aria-expanded="false">Arab</a></li>
<li class=""><a href="#cina" role="tab" data-toggle="tab" aria-expanded="false">Cina</a></li>
</ul>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="inggris">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
......@@ -294,7 +294,7 @@
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
$(document).ready(function() {
$('#content').summernote({
height: 350
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment