/** * Allows the element to pre-process a rows data before and join mergeing of rows * occurs. Used in calc element to do cals on actual row rather than merged row * * @param string $element_data elements data for the current row * @param object $row current row's data * * @since 3.0.5 * * @return string formatted value */ public function preFormatFormJoins($element_data, $row) { $params = $this->getParams(); $format = trim($params->get('calc_format_string')); /** * $$$ hugh - the 'calculated value' bit is for legacy data that was created * before we started storing a value when row is saved */ if ($params->get('calc_on_save_only', 0)) { if ($format != '') { $element_data = sprintf($format, $element_data); } return parent::preFormatFormJoins($element_data, $row); } else { $element = $this->getElement(); $cal = $params->get('calc_calculation', ''); $listModel = $this->getlistModel(); $formModel = $this->getFormModel(); $data = JArrayHelper::fromObject($row); $data['rowid'] = $data['__pk_val']; $data['fabrik'] = $formModel->getId(); /** * $$$ hugh - trying to standardize on $data so scripts know where data is, * need $d here for backward compat */ $d = $data; $res = $listModel->parseMessageForRowHolder($cal, $data, true); $res = @eval($res); FabrikWorker::logEval($res, 'Caught exception on eval in ' . $element->name . '::renderListData() : %s'); if ($format != '') { $res = sprintf($format, $res); } // $$$ hugh - need to set _raw, might be needed if (say) calc is being used as 'use_as_row_class' // See comments in formatData() in table model, we might could move this to a renderRawListData() method. $raw_name = $this->getFullName(false, true, false) . '_raw'; $row->{$raw_name} = str_replace(GROUPSPLITTER, ',', $res); return parent::preFormatFormJoins($res, $row); } }