/** * Append one row on final of datasource with the count of defined columns. */ public function appendColumnCount() { if (!$this->getEnabledColumnCount()) { return $this; } $columns = $this->getColumnFieldCounts(); $arrayAppend = array(); $float = new Fields\FloatType(); for ($this->rewind(); $this->valid(); $this->next()) { foreach ($this->current() as $keyIdentification => $valueField) { if (isset($columns[$keyIdentification]) || in_array($keyIdentification, $columns)) { if (isset($columns[$keyIdentification]) && is_array($columns[$keyIdentification]) && !isset($columns[$keyIdentification]['callback'])) { $label = isset($columns[$keyIdentification]['label']) ? $columns[$keyIdentification]['label'] : $valueField; $prefix = isset($columns[$keyIdentification]['prefix']) ? $columns[$keyIdentification]['prefix'] : ''; $suffix = isset($columns[$keyIdentification]['suffix']) ? $columns[$keyIdentification]['suffix'] : ''; $arrayAppend[$keyIdentification] = sprintf('%s %s %s', $prefix, $label, $suffix); } elseif (isset($columns[$keyIdentification]['callback']) && is_callable($columns[$keyIdentification]['callback'])) { $valueField = $columns[$keyIdentification]['callback']($valueField); } if (is_numeric($valueField)) { $arrayAppend[$keyIdentification] = isset($arrayAppend[$keyIdentification]) ? $arrayAppend[$keyIdentification] + $valueField : $valueField; if (is_float($valueField)) { $arrayAppend[$keyIdentification] = $float->format($arrayAppend[$keyIdentification]); } } } } } $this->append($arrayAppend); return $this; }
public function format($value) { $value = parent::format($value); return empty($value) ? null : "<c r=\"cellAddress\"><v>{$value}</v></c>"; }