From 759f536ae8a94ec5cce173fd00855aa39f0dbf3a Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Thu, 19 May 2011 22:10:52 +0000 Subject: h-source:added preview button for the description entry and for the wiki pages --- .../Application/Controllers/GenericController.php | 23 ++++++++++++++++++-- .../Application/Controllers/WikiController.php | 25 ++++++++++++++++------ 2 files changed, 39 insertions(+), 9 deletions(-) (limited to 'h-source/Application/Controllers') diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index 31271b9..9cbaeee 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -63,6 +63,8 @@ class GenericController extends BaseController $this->shift(2); $clean['token'] = sanitizeAlphanum($token); + + $data['descriptionPreview'] = null; //contains the HTML of the preview of the description entry $data['notice'] = null; $data['submission_response'] = 'error'; @@ -114,7 +116,9 @@ class GenericController extends BaseController } } } - + + $data['descriptionPreview'] = $this->getPreview(); + $data['notice'] = $this->m['HardwareModel']->notice; $data['submitName'] = "insertAction"; @@ -143,7 +147,7 @@ class GenericController extends BaseController $this->redirect("users/login/".$this->lang."?redirect=".$this->controller."/catalogue/".$this->lang,0); } } - + public function del($lang = 'en', $token = '') { header('Content-type: text/html; charset=UTF-8'); @@ -210,6 +214,8 @@ class GenericController extends BaseController $this->shift(2); $clean['token'] = sanitizeAlphanum($token); + + $data['descriptionPreview'] = null; //contains the HTML of the preview of the description entry $data['notice'] = null; $data['submission_response'] = 'error'; @@ -264,6 +270,8 @@ class GenericController extends BaseController } } } + + $data['descriptionPreview'] = $this->getPreview(); $data['notice'] = $this->m['HardwareModel']->notice; @@ -306,6 +314,17 @@ class GenericController extends BaseController } } + //get the preview of the description entry + protected function getPreview() + { + if (isset($_POST['previewAction'])) + { + $this->m['HardwareModel']->result = false; + return $this->request->post('description','','sanitizeHtml'); + } + return null; + } + protected function checkVendorId($interface) { if (strcmp($this->m['HardwareModel']->type,'notebook') === 0) return true; diff --git a/h-source/Application/Controllers/WikiController.php b/h-source/Application/Controllers/WikiController.php index 0e05ffd..9815055 100644 --- a/h-source/Application/Controllers/WikiController.php +++ b/h-source/Application/Controllers/WikiController.php @@ -40,6 +40,8 @@ class WikiController extends BaseController public function insert($lang = 'en') { $this->shift(1); + + $data['pagePreview'] = null; $data['title'] = 'insert a wiki page - '.Website::$generalName; @@ -64,6 +66,8 @@ class WikiController extends BaseController die(); } } + + $data['pagePreview'] = $this->getPreview(); $data['notice'] = $this->m['WikiModel']->notice; @@ -87,6 +91,8 @@ class WikiController extends BaseController { $this->shift(1); + $data['pagePreview'] = null; + $data['title'] = 'update a wiki page - '.Website::$generalName; $this->m['WikiModel']->setFields('title,page','sanitizeAll'); @@ -125,6 +131,8 @@ class WikiController extends BaseController } } + $data['pagePreview'] = $this->getPreview(); + $data['notice'] = $this->m['WikiModel']->notice; $data['id_wiki'] = $clean['id_wiki']; @@ -151,13 +159,16 @@ class WikiController extends BaseController } } -// protected function viewRedirect($titleClean) -// { -// if ($this->m['WikiModel']->queryResult) -// { -// $this->redirect($this->controller.'/page/'.$this->lang.'/'.$titleClean); -// } -// } + //get the preview of the description entry + protected function getPreview() + { + if (isset($_POST['previewAction'])) + { + $this->m['WikiModel']->result = false; + return $this->request->post('page','','sanitizeHtml'); + } + return null; + } public function page($lang = 'en', $title_clean = null) { -- cgit v1.2.3