/** * @param mixed $name name of the property to change * @param mixed $value new value for the property * @return void */ public function __set($name, $value) { if (isset($this->_cache['subs'][$name]) && !$this->_cache['subs'][$name]['dynamic']) { trigger_error('Property ' . $name . ' is not a parameter', E_USER_ERROR); } elseif (isset($this->_cache['params'][$name])) { if (is_scalar($value) || $value instanceof \DateTime) { if (!isset($this->_params[$name])) { $this->_params[$name] = ParameterFactory::factory($this->_cache['params'][$name]); } $this->_params[$name]->set($value); } elseif (is_array($value)) { // recreate param to reset other keys and keep scalar value if existent $v = isset($this->_params[$name]) && is_scalar($this->_params[$name]->value()) ? $this->_params[$name]->value() : null; $this->_params[$name] = ParameterFactory::factory($this->_cache['params'][$name]); $this->_params[$name]->value($v); // proceed array if ($this->_params[$name] instanceof ParameterArrayType) { foreach ($value as $key => $v) { $this->_params[$name][$key] = $v; } } else { foreach ($value as $key => $v) { $this->_params[$name]->{$key} = $v; } } } else { trigger_error("Invalid value for property " . $name, E_USER_ERROR); } } else { trigger_error("Property " . $name . " does not exist", E_USER_ERROR); } }
/** * @param mixed|null $value sets the value of this parameter if $value is not null * @return mixed|null */ public function value($value = null) { if ($this->hasChilds()) { if ($value === null) { $r = array(); foreach ($this->_subparams as $name => $param) { $v = $param->get(); if ($v !== null) { $r[$name] = $v; } } if (count($r) > 0) { return $r; } else { return null; } } else { if (is_array($value)) { $this->_subparams = array(); foreach ($value as $key => $v) { if (array_key_exists($key, $this->_cache['subparams'])) { if (!isset($this->_subparams[$key])) { $this->_subparams[$key] = ParameterFactory::factory($this->_cache['subparams'][$key]); } $this->_subparams[$key]->value($v); } else { trigger_error("Property " . $key . " does not exist", E_USER_ERROR); } } } else { trigger_error("Can not set value of Parameter with subparameters", E_USER_ERROR); } } } else { if ($value !== null) { if (is_scalar($value) || $value instanceof \DateTime) { if ($this->_strict) { trigger_error("Can not set a scalar value to a Parameter which is in all operations an Array.", E_USER_ERROR); } else { $this->_value = $value; } } else { trigger_error("Property value must be scalar.", E_USER_ERROR); } } return $this->_value; } }
* * * ************************************************************************************************************************* */ require 'minify.php'; ob_start('minify_output'); include_once 'directory.php'; $action = $_GET['action']; if ($action === 'getReportParameters') { $report = ReportFactory::makeReport($_GET['reportID']); // get parameters Parameter::$ajax_parmValues = array(); foreach ($report->getParameters() as $parm) { $parm->form(); } } else { if ($action === 'getChildParameters') { $parm = ParameterFactory::makeParam($_GET['reportID'], $_GET['parentReportParameterID']); $parm->ajaxGetChildParameters(); } else { if ($action === 'getChildUpdate') { $parm = ParameterFactory::makeParam($_GET['reportID'], $_GET['reportParameterID']); $parm->ajaxGetChildUpdate(); } else { echo _("Action {$action} not set up!"); } } } ob_end_flush(); ?>
public function getParameters() { // set database to reporting database name Config::init(); $objects = array(); foreach ($this->db->selectDB(Config::$database->name)->query("SELECT reportParameterID\n FROM ReportParameterMap\n WHERE reportID = '{$this->id}'\n ORDER BY 1")->fetchRows(MYSQLI_ASSOC) as $row) { $objects[] = ParameterFactory::makeParam($this->id, $row['reportParameterID']); } $objects[] = new CheckSummaryOnlyParameter($this->id); return $objects; }
public function getChildren() { Config::init(); $objects = array(); foreach ($this->db->selectDB(Config::$database->name)->query("SELECT reportParameterID\n FROM ReportParameterMap\n WHERE parentReportParameterID = '{$this->id}' ORDER BY 1")->fetchRows(MYSQLI_ASSOC) as $row) { $objects[] = ParameterFactory::makeParam($this->reportID, $row['reportParameterID']); } return $objects; }