aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Application/Controllers')
-rw-r--r--h-source/Application/Controllers/BaseController.php82
-rw-r--r--h-source/Application/Controllers/GenericController.php21
-rw-r--r--h-source/Application/Controllers/HomeController.php13
3 files changed, 88 insertions, 28 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'] = "<input type='hidden' name='id_hard' value='".$clean['id_hard']."'>\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() . " &raquo; <span class='last_tree_element'>".$data['ne_name']."</span>";
$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');