Esempio n. 1
0
 /**
  * Decorates the data in the cell
  * @param zibo\library\html\table\Cell $cell Cell to decorate
  * @param zibo\library\html\table\Row $row Row containing the cell
  * @param int $rowNumber Number of the current row
  * @param array $remainingValues Array with the values of the remaining rows of the table
  * @return null
  */
 public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues)
 {
     $data = $cell->getValue();
     if (!$this->meta->isValidData($data)) {
         $cell->setValue('');
     }
     $title = $this->meta->formatData($data, DataFormatter::FORMAT_TITLE);
     $teaser = '';
     if ($this->hasTeaserFormat) {
         $teaser = $this->meta->formatData($data, DataFormatter::FORMAT_TEASER);
     }
     $value = $this->getImageHtml($data);
     if ($this->action) {
         if (!$title) {
             $title = $this->meta->getName() . ' ' . $data->id;
         }
         $anchor = new Anchor($title, $this->action . $data->id);
         $value .= $anchor->getHtml();
     } else {
         $value .= $title;
     }
     if ($teaser) {
         $value .= '<div class="info">' . $teaser . '</div>';
     }
     $cell->setValue($value);
 }
Esempio n. 2
0
 /**
  * Decorates the data
  * @param mixed $data
  * @return string
  */
 public function decorate($data)
 {
     if (!$this->meta->isValidData($data)) {
         return '';
     }
     return $this->meta->formatData($data, DataFormatter::FORMAT_TITLE);
 }
 /**
  * Decorates the data in the cell
  * @param zibo\library\html\table\Cell $cell Cell to decorate
  * @param zibo\library\html\table\Row $row Row containing the cell
  * @param int $rowNumber Number of the current row
  * @param array $remainingValues Array with the values of the remaining rows of the table
  * @return null
  */
 public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues)
 {
     $data = $cell->getValue();
     if (!$this->meta->isValidData($data)) {
         $cell->setValue('');
     }
     $value = $this->meta->formatData($data, $this->format);
     $cell->setValue($value);
 }
Esempio n. 4
0
 /**
  * Gets the primary key of data
  * @param mixed $data Primary key or a data object
  * @return integer The primary key of the data
  * @throws zibo\library\orm\exception\ModelException when no primary key could be retrieved from the data
  */
 protected function getPrimaryKey($data)
 {
     if (is_numeric($data)) {
         return $data;
     }
     $this->meta->isValidData($data);
     if (!empty($data->id)) {
         return $data->id;
     }
     throw new ModelException('No primary key found in the provided data');
 }