示例#1
0
 public function render()
 {
     $this->_collection = $this->_obj->getCollection();
     $this->_collection->setBoundaryBatch(-1);
     // set relevant uri adapter and get some identifiers
     /* @var $_uriAdapter t41\View\ViewUri\AbstractAdapter */
     if (!($this->_uriAdapter = ViewUri::getUriAdapter()) instanceof ViewUri\Adapter\GetAdapter) {
         $this->_uriAdapter = new ViewUri\Adapter\GetAdapter();
     }
     $this->_uriAdapter->setEnvData($this->_uriAdapter->getIdentifier('offset'), 0);
     $this->_obj->query($this->_uriAdapter);
     $row = '';
     $sep = str_replace('\\t', "\t", ",");
     // print out result rows
     foreach ($this->_obj->getCollection()->getMembers(ObjectModel::DATA) as $this->_do) {
         $p = null;
         foreach ($this->_obj->getColumns() as $key => $column) {
             if ($p) {
                 $p .= $sep;
             }
             if ($column instanceof Element\IdentifierElement) {
                 $value = $this->_do->getUri()->getIdentifier();
             } else {
                 if ($column instanceof Element\MetaElement) {
                     $value = $column->getDisplayValue($this->_do);
                 } else {
                     $property = $this->_do->getProperty($column->getParameter('property'));
                     $column->setValue($property->getValue());
                     if ($column->getParameter('recursion')) {
                         foreach ($column->getParameter('recursion') as $recursion) {
                             if ($property instanceof AbstractProperty) {
                                 $property = $property->getValue(ObjectModel::DATA);
                             }
                             if ($property instanceof ObjectModel || $property instanceof DataObject) {
                                 $property = $property->getProperty($recursion);
                             }
                         }
                     }
                     if ($property instanceof Property\MediaProperty) {
                         $value = '';
                     } else {
                         if ($property instanceof Property\CurrencyProperty) {
                             $value = $property->getValue();
                             // value formatting must not be converted
                         } else {
                             $value = $property instanceof Property\AbstractProperty ? $property->getDisplayValue() : null;
                         }
                     }
                 }
             }
             $fv = str_replace('\\r\\n', ', ', stripslashes($value));
             $p .= "\"" . str_replace('"', '""', $fv) . "\"";
         }
         $row .= $p . "\r\n";
         // preserve memory!
         $this->_do->reclaimMemory();
     }
     return $this->_drawHeaderRow() . $row;
 }
示例#2
0
 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;
 }