Commit 2bba3b15 by Siti Aisah

add allowed tags for page

parent f7100683
...@@ -80,8 +80,8 @@ class PageController extends Controller ...@@ -80,8 +80,8 @@ class PageController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
// dd($request); // dd($request);
$request['content'] = $request->content; $request['content'] = strip_tags($request->content, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']);
$request['title'] = $request->title; $request['title'] = strip_tags($request->title, ['b', 'i', 'u']);
$request->validate([ $request->validate([
'title' => 'required', 'title' => 'required',
'content' => 'required|min:3', 'content' => 'required|min:3',
...@@ -119,13 +119,13 @@ class PageController extends Controller ...@@ -119,13 +119,13 @@ class PageController extends Controller
private function createEn($data, $page) private function createEn($data, $page)
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['title'], ['b', 'i', 'u']));
if (strip_tags($data['content']) == null) { if ($data['content'] == null) {
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataEn['page_id'] = $page->id; $dataEn['page_id'] = $page->id;
$dataEn['title'] = $title; $dataEn['title'] = $title;
...@@ -137,13 +137,13 @@ class PageController extends Controller ...@@ -137,13 +137,13 @@ class PageController extends Controller
private function createDe($data, $page) private function createDe($data, $page)
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETDE, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['title'], ['b', 'i', 'u']));
if (strip_tags($data['content']) == null) { if ($data['content'] == null) {
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataDe['page_id'] = $page->id; $dataDe['page_id'] = $page->id;
$dataDe['title'] = $title; $dataDe['title'] = $title;
...@@ -155,13 +155,13 @@ class PageController extends Controller ...@@ -155,13 +155,13 @@ class PageController extends Controller
private function createSa($data, $page) private function createSa($data, $page)
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETSA, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['title'], ['b', 'i', 'u']));
if (strip_tags($data['content']) == null) { if ($data['content'] == null) {
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataSa['page_id'] = $page->id; $dataSa['page_id'] = $page->id;
$dataSa['title'] = $title; $dataSa['title'] = $title;
...@@ -173,13 +173,13 @@ class PageController extends Controller ...@@ -173,13 +173,13 @@ class PageController extends Controller
private function createZh($data, $page) private function createZh($data, $page)
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETZH, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['title'], ['b', 'i', 'u']));
if (strip_tags($data['content']) == null) { if ($data['content'] == null) {
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataZh['page_id'] = $page->id; $dataZh['page_id'] = $page->id;
$dataZh['title'] = $title; $dataZh['title'] = $title;
...@@ -246,16 +246,16 @@ class PageController extends Controller ...@@ -246,16 +246,16 @@ class PageController extends Controller
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
// dd($request); // dd($request);
$request['content'] = $request->content; $request['content'] = strip_tags($request->content, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']);
$request['content_en'] = $request->content_en; $request['content_en'] = strip_tags($request->content_en, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']);
$request['content_de'] = $request->content_de; $request['content_de'] = strip_tags($request->content_de, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']);
$request['content_sa'] = $request->content_sa; $request['content_sa'] = strip_tags($request->content_sa, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']);
$request['content_zh'] = $request->content_zh; $request['content_zh'] = strip_tags($request->content_zh, ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']);
$request['title'] = $request->title; $request['title'] = strip_tags($request->title, ['b', 'i', 'u']);
$request['title_en'] = $request->title_en; $request['title_en'] = strip_tags($request->title_en, ['b', 'i', 'u']);
$request['title_de'] = $request->title_de; $request['title_de'] = strip_tags($request->title_de, ['b', 'i', 'u']);
$request['title_sa'] = $request->title_sa; $request['title_sa'] = strip_tags($request->title_sa, ['b', 'i', 'u']);
$request['title_zh'] = $request->title_zh; $request['title_zh'] = strip_tags($request->title_zh, ['b', 'i', 'u']);
$request->validate([ $request->validate([
// 'title' => 'required', // 'title' => 'required',
...@@ -307,13 +307,13 @@ class PageController extends Controller ...@@ -307,13 +307,13 @@ class PageController extends Controller
$dataEn['content'] = $data['content_en']; $dataEn['content'] = $data['content_en'];
} }
else{ else{
if (strip_tags($data['content']) == null) { if ($data['content'] == null) {
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['title'], ['b', 'i', 'u']));
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataEn['title'] = $title; $dataEn['title'] = $title;
$dataEn['content'] = $content; $dataEn['content'] = $content;
...@@ -329,12 +329,12 @@ class PageController extends Controller ...@@ -329,12 +329,12 @@ class PageController extends Controller
$dataDe['content'] = $data['content_de']; $dataDe['content'] = $data['content_de'];
} }
else{ else{
if(strip_tags($data['content'])==null){ if($data['content']==null){
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETDE, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['title'], ['b', 'i', 'u']));
$content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataDe['title'] = $title; $dataDe['title'] = $title;
$dataDe['content'] = $content; $dataDe['content'] = $content;
...@@ -350,13 +350,13 @@ class PageController extends Controller ...@@ -350,13 +350,13 @@ class PageController extends Controller
$dataSa['content'] = $data['content_sa']; $dataSa['content'] = $data['content_sa'];
} }
else{ else{
if(strip_tags($data['content'])==null){ if($data['content']==null){
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETSA, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['title'], ['b', 'i', 'u']));
$content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataSa['title'] = $title; $dataSa['title'] = $title;
$dataSa['content'] = $content; $dataSa['content'] = $content;
...@@ -372,13 +372,13 @@ class PageController extends Controller ...@@ -372,13 +372,13 @@ class PageController extends Controller
$dataZh['content'] = $data['content_zh']; $dataZh['content'] = $data['content_zh'];
} }
else{ else{
if(strip_tags($data['content'])==null){ if($data['content']==null){
$data['content'] = 'kosong'; $data['content'] = 'kosong';
} }
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETZH, $data['title']); $title = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['title'], ['b', 'i', 'u']));
$content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['content'])); $content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['content'], ['a', 'br', 'p', 'b', 'i', 'u', 'ul', 'li', 'ol', 'img']));
$dataZh['title'] = $title; $dataZh['title'] = $title;
$dataZh['content'] = $content; $dataZh['content'] = $content;
......
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