/** * Draw table header */ protected function _drawHeaderRow() { $row = ""; $sep = str_replace('\\t', "\t", ","); $add_character = "\r\n"; $add_character = str_replace('\\r', "\r", $add_character); $add_character = str_replace('\\n', "\n", $add_character); $add_character = str_replace('\\t', "\t", $add_character); foreach ($this->_obj->getColumns() as $colonne) { if ($row) { $row .= $sep; } $row .= '"' . str_replace("\"", "\\\"", $colonne->getTitle()) . '"'; } $row .= $add_character; //$row = preg_replace("\015(\012)?", "\012", $row); return $row; }
protected function _contentRendering() { $i = 0; $p = ''; $aliases = $this->_obj->getAliases(); // print out rows foreach ($this->_obj->getCollection()->getMembers(ObjectModel::DATA) as $this->_key => $this->_do) { $css = $i % 2 == 0 ? 'odd' : 'even'; // \Zend_Debug::dump($this->_do->getProperty('marche')->getValue(ObjectModel::MODEL)); die; // @todo handle objects coming from different backends $p .= sprintf('<tr data-member="%s" data-alias="%s" class="%s">', $this->_key, $this->_do->getUri() ? $aliases[$this->_do->getUri()->getIdentifier()] : null, $css); $i++; if ($this->_obj->getParameter('selectable') === true) { // make list items selectable $p .= sprintf('<td><input type="checkbox" name="t41_selection[]" value="%s"/></td>', $this->_do->getUri()->getIdentifier()); } $altDec = (array) $this->_obj->getParameter('decorators'); foreach ($this->_obj->getColumns() as $column) { if ($column instanceof Element\IdentifierElement) { $p .= sprintf('<td>%s</td>', $this->_do->getUri()->getIdentifier()); continue; } if ($column instanceof Element\MetaElement) { $attrib = $column->getParameter('type') == 'currency' ? ' class="cellcurrency"' : null; $p .= "<td{$attrib}>" . $column->getDisplayValue($this->_do) . '</td>'; continue; } $property = $this->_do->getProperty($column->getParameter('property')); if (!$property) { $p .= '<td>??</td>'; continue; } $column->setValue($property->getValue()); /* if a decorator has been declared for property/element, use it */ if (isset($altDec[$column->getId()])) { $column->setDecorator($altDec[$column->getId()]); $deco = Decorator::factory($column); $p .= sprintf('<td>%s</td>', $deco->render()); continue; } $attrib = sprintf(' class="tb-%s', $column->getId()); $attrib .= $property instanceof Property\CurrencyProperty ? ' cellcurrency"' : '"'; if ($column->getParameter('recursion')) { $parts = $column->getParameter('recursion'); foreach ($parts as $rkey => $recursion) { if ($property instanceof ArrayProperty) { // property won't be a property here ! $property = $property->getValue(); $property = $property[$recursion]; if ($property instanceof BaseObject && isset($parts[$rkey + 1])) { $property = $property->{$parts[$rkey + 1]}; } break; } // property is an object property if ($property instanceof AbstractProperty && $property->getValue()) { $property = $property->getValue(ObjectModel::DATA)->getProperty($recursion); } if ($property instanceof ObjectModel || $property instanceof DataObject) { $property = $property->getProperty($recursion); } else { if ($property instanceof ObjectUri) { $property = ObjectModel::factory($property)->getProperty($recursion); } } } } if ($property instanceof Property\MediaProperty) { $column->setValue($property->getDisplayValue()); $deco = Decorator::factory($column); $value = $deco->render(); } else { $value = $property instanceof Property\AbstractProperty ? $property->getDisplayValue() : $property; } //$p .= "<td$attrib>" . $this->_escape($value) . '</td>'; $p .= "<td{$attrib}>" . $value . '</td>'; } $p .= '<td class="tb-actions">'; foreach ($this->_obj->getEvents('row') as $button) { $button->setParameter('uri', $this->_do->getUri()); $p .= $this->_renderButton($button, $aliases[$this->_do->getUri()->getIdentifier()]); } $p .= '</td></tr>' . "\n"; } return $p; }