Exemplo n.º 1
0
 public function getValue(DataObject $do)
 {
     $property = $do->getProperty($this->getParameter('property'));
     if ($property instanceof CollectionProperty) {
         $subParts = explode('.', $this->getParameter('action'));
         $collection = $property->getValue();
         return $collection->{$subParts[0]}(isset($subParts[1]) ? $subParts[1] : null);
     } else {
         if ($property instanceof AbstractProperty) {
             return $property->getValue();
         } else {
             return $this->_value;
             //parent::getValue();
         }
     }
 }
Exemplo n.º 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;
 }