From 75095b0329236ea0e2522a633f4a2be733d6869b Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sat, 8 Oct 2011 09:09:05 +0000 Subject: improved the way text can be written inside modules of the website --- .../Application/Controllers/BaseController.php | 82 +++++++++++++++++----- .../Application/Controllers/GenericController.php | 21 +++++- .../Application/Controllers/HomeController.php | 13 +--- h-source/Application/Views/form.php | 2 +- h-source/Application/Views/page.php | 2 +- h-source/Public/Css/main.css | 6 ++ h-source/tables.sql | 3 +- 7 files changed, 98 insertions(+), 31 deletions(-) diff --git a/h-source/Application/Controllers/BaseController.php b/h-source/Application/Controllers/BaseController.php index 0954d2f..13bbb66 100644 --- a/h-source/Application/Controllers/BaseController.php +++ b/h-source/Application/Controllers/BaseController.php @@ -29,7 +29,9 @@ class BaseController extends Controller protected $isadmin = false; protected $querySanitized = true; protected $token = 'token'; - protected $_updating; + protected $_updating = 'no'; + + protected $_configXml = null; protected $_topMenuClasses = array( "home" => null, @@ -106,13 +108,66 @@ class BaseController extends Controller //check it they are updating the website $updating = $this->m['ParamsModel']->select('updating')->where(array('id_par'=>1))->toList('updating')->send(); - $data['updating_flag'] = $updating[0]; - $this->_updating = $data['updating_flag']; - + + $data['updating_flag'] = 'no'; + if (count($updating)>0) + { + $data['updating_flag'] = $updating[0]; + $this->_updating = $data['updating_flag']; + } + + //get the configuration xml + $xmlRes = $this->m['ParamsModel']->select('boxes_xml')->where(array('id_par'=>1))->toList('boxes_xml')->send(); + if (count($xmlRes)>0) + { + $configXml = htmlspecialchars_decode($xmlRes[0],ENT_QUOTES); + if (@simplexml_load_string($configXml)) + { + $this->_configXml = simplexml_load_string($configXml); + } + } + $this->append($data); - } - + + //get the right box from the configuration xml + protected function getBox($xmlPath,$xmlString = null) + { + if (!isset($xmlString)) + { + $xmlString = $this->_configXml; + } + + if (is_array($xmlPath)) + { + if (isset($xmlString)) + { + $tempXml = $xmlString->{$xmlPath[0]}; + if (count($xmlPath) === 1) + { + if (isset($tempXml->{$this->lang})) + { + return $tempXml->{$this->lang}->asXml(); + } + else if (isset($tempXml->{"en"})) + { + return $tempXml->{"en"}->asXml(); + } + else + { + return null; + } + } + else + { + array_shift($xmlPath); + return $this->getBox($xmlPath,$tempXml); + } + } + } + return null; + } + protected function right($lang = 'en') { $hard = new HardwareModel(); @@ -123,21 +178,14 @@ class BaseController extends Controller $data['numbLogged'] = count($logged); - // get the right column container - $this->m['BoxesModel']->setWhereQueryClause(array('title'=>'right_bottom')); - $boxes = $this->m['BoxesModel']->getAll('boxes'); - - if (count($boxes) > 0) + //render the boxes inside the right column + $data['htmlRightBox'] = null; + $xml = $this->getBox(array('right_column')); + if ($xml) { - $xml = htmlspecialchars_decode($boxes[0]['boxes']['message'],ENT_QUOTES); - $box_news = new BoxParser($xml); $data['htmlRightBox'] = $box_news->render(); } - else - { - $data['htmlRightBox'] = null; - } $data['language_links'] = $this->buildLanguageLinks($this->lang); diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index a2c5bdf..f1f1d70 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -129,6 +129,8 @@ class GenericController extends BaseController $data['submitName'] = "insertAction"; $data['hiddenInput'] = null; + + $data['tracksHelpLabel'] = $this->getEntryLabel('it_tracks_users'); $data['values'] = $this->m['HardwareModel']->getFormValues('insert','sanitizeHtml'); $this->append($data); @@ -288,7 +290,9 @@ class GenericController extends BaseController // echo $this->m['HardwareModel']->fields; $data['values'] = $this->m['HardwareModel']->getFormValues('update','sanitizeHtml'); $data['hiddenInput'] = "\n"; - + + $data['tracksHelpLabel'] = $this->getEntryLabel('it_tracks_users'); + $this->append($data); if (!isset($_POST['from_client'])) @@ -322,6 +326,19 @@ class GenericController extends BaseController } } +// get the help label for the "it_tracks_users" entry + protected function getEntryLabel($entryName) + { + $tracksHelpLabel = null; + $xml = $this->getBox(array('devices',$this->controller,'form',$entryName)); + if ($xml) + { + $box_news = new BoxParser($xml); + $tracksHelpLabel = $box_news->render(); + } + return $tracksHelpLabel; + } + //get the preview of the description entry protected function getPreview() { @@ -531,6 +548,8 @@ class GenericController extends BaseController $data['tree'] = $this->getSpecHardLink() . " » ".$data['ne_name'].""; $data['isDeleted'] = $this->m['HardwareModel']->isDeleted($clean['id_hard']); $data['isApproved'] = strcmp($data['table'][0]['hardware']['approved'],'yes') === 0 ? true : false; + + $data['tracksHelpLabel'] = $this->getEntryLabel('it_tracks_users'); $this->passWhoAskedForDeletion($clean['id_hard']); } diff --git a/h-source/Application/Controllers/HomeController.php b/h-source/Application/Controllers/HomeController.php index 5eff4d9..96479f3 100644 --- a/h-source/Application/Controllers/HomeController.php +++ b/h-source/Application/Controllers/HomeController.php @@ -37,20 +37,13 @@ class HomeController extends BaseController public function index($lang = 'en') { // get the news container - $this->m['BoxesModel']->setWhereQueryClause(array('title'=>'home_news')); - $boxes = $this->m['BoxesModel']->getAll('boxes'); - - if (count($boxes) > 0) + $data['htmlNewsBox'] = null; + $xml = $this->getBox(array('top_news')); + if ($xml) { - $xml = htmlspecialchars_decode($boxes[0]['boxes']['message'],ENT_QUOTES); - $box_news = new BoxParser($xml); $data['htmlNewsBox'] = $box_news->render(); } - else - { - $data['htmlNewsBox'] = null; - } $this->append($data); $this->cleverLoad('left'); diff --git a/h-source/Application/Views/form.php b/h-source/Application/Views/form.php index 5568cfd..5d04566 100644 --- a/h-source/Application/Views/form.php +++ b/h-source/Application/Views/form.php @@ -115,7 +115,7 @@ controller,'printers') === 0 ) { ?>
- +
diff --git a/h-source/Application/Views/page.php b/h-source/Application/Views/page.php index 727431c..6b7e539 100644 --- a/h-source/Application/Views/page.php +++ b/h-source/Application/Views/page.php @@ -116,7 +116,7 @@ controller,'printers') === 0 ) { ?>
-
+
diff --git a/h-source/Public/Css/main.css b/h-source/Public/Css/main.css index b911536..5afe645 100644 --- a/h-source/Public/Css/main.css +++ b/h-source/Public/Css/main.css @@ -1995,6 +1995,12 @@ div#description_tabs_content { clear:left; } + +.box_module_label a +{ + color:#FF4500; +} + /* Start - temporarily added due to transformation of help pages 2011-05-29 joeko diff --git a/h-source/tables.sql b/h-source/tables.sql index 65da6bc..7269ee1 100644 --- a/h-source/tables.sql +++ b/h-source/tables.sql @@ -209,7 +209,8 @@ create table deletion ( create table params ( id_par INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - updating char(4) not null default 'no' + updating char(4) not null default 'no', + boxes_xml text CHARACTER SET utf8 not null )engine=innodb; insert into params (updating) values ('no'); -- cgit v1.2.3