Skip to content

Commit

Permalink
adding some code to do settings for the modules, it uses json for set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
dogmatic69 committed Jan 22, 2010
1 parent d96d4d3 commit 62a8d36
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion extensions/libs/views/helpers/infinitas.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
*
*/
class InfinitasHelper extends AppHelper{
var $_json_errors = array(
JSON_ERROR_NONE => 'No error',
JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
JSON_ERROR_SYNTAX => 'Syntax error',
);

function loadModules($position = null){
if (!$position) {
$this->errors[] = 'No position selected to load modules';
Expand All @@ -28,7 +35,7 @@ function loadModules($position = null){

if (!empty($module['Module']['module'])) {
$View = ClassRegistry::getObject('view');
$moduleOut .= $View->element('modules/'.$module['Module']['module']);
$moduleOut .= $View->element('modules/'.$module['Module']['module'], array('config' => $this->_moduleConfig($module['Module'])));
}
else if (!empty($module['Module']['content'])) {
$moduleOut .= $module['Module']['content'];
Expand All @@ -50,5 +57,20 @@ function loadModules($position = null){

return $out;
}

function _moduleConfig($config = ''){
if (empty($config['config'])) {
return array();
}

$json = json_decode($config['config'], true);

if (!$json) {
$this->errors[] = 'module ('.$config['name'].'): '.$this->_json_errors[json_last_error()];
return array();
}

return $json;
}
}
?>

0 comments on commit 62a8d36

Please sign in to comment.