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);
 }
 /**
  * Constructs a new model diagram object
  * @param zibo\library\orm\model\meta\ModelMeta $meta The meta of the model
  * @return null
  */
 public function __construct(ModelMeta $meta)
 {
     $this->id = $meta->getName();
     $this->meta = $meta;
     $this->fieldPoints = array();
     $this->setPadding(5, 5, 5, 5);
     $this->setBackgroundColor(new Color(255, 255, 255));
     $this->setFrontColor(new Color(15, 15, 15));
 }
 /**
  * Calculates the dimension of the diagram object
  * @return null
  */
 private function calculateDimension()
 {
     $maxLength = strlen($this->meta->getName());
     $fields = $this->meta->getFields();
     foreach ($fields as $fieldName => $field) {
         $fieldNameLength = strlen($fieldName . $this->getFieldType($field)) + 4;
         if ($fieldNameLength > $maxLength) {
             $maxLength = $fieldNameLength;
         }
     }
     $width = $maxLength * self::CHARACTER_WIDTH + $this->paddingLeft + $this->paddingRight;
     $height = (count($fields) + 2) * ($this->paddingTop + self::CHARACTER_HEIGHT) + $this->paddingTop + $this->paddingBottom;
     $this->dimension = new Dimension($width, $height);
 }
 /**
  * Sets the log subview to the view if necessairy
  * @param zibo\library\orm\model\meta\ModelMeta $meta Meta of the model
  * @param mixed $data Data object of the form
  * @return null
  */
 protected function setLogSubview(ModelMeta $meta, $data)
 {
     if (!$meta->isLogged()) {
         return;
     }
     if (!$data || empty($data->id)) {
         return;
     }
     $logView = new LogView($meta->getName(), $data->id);
     $this->setSubView('log', $logView);
 }
Esempio n. 5
0
 /**
  * Gets the name of this model
  * @return string
  */
 public function getName()
 {
     return $this->meta->getName();
 }