diff options
Diffstat (limited to 'h-source/Application/Controllers/BaseController.php')
-rw-r--r-- | h-source/Application/Controllers/BaseController.php | 82 |
1 files changed, 65 insertions, 17 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); |