/** * 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); }
/** * Constructs a new localize view * @param $meta * @param $id * @param $action * @param $field * @return null */ public function __construct(ModelMeta $meta, $data, $action = null) { parent::__construct(self::TEMPLATE); $localizedModel = $meta->getLocalizedModel(); $localizedFields = $meta->getLocalizedFields(); $currentLocale = LocalizeController::getLocale(); $allLocales = I18n::getInstance()->getAllLocales(); unset($allLocales[$currentLocale]); $locales = array(); foreach ($allLocales as $locale) { $locale = $locale->getCode(); $localizedId = $localizedModel->getLocalizedId($data->id, $locale); if ($localizedId === null) { $locales[$locale] = null; continue; } $localesData = clone $data; $localizedData = $localizedModel->findById($localizedId); foreach ($localizedFields as $fieldName => $localizedField) { $localesData->{$fieldName} = $localizedData->{$fieldName}; } $localesData->localizedLabel = $meta->formatData($localesData); $locales[$locale] = $localesData; } $this->set('locales', $locales); $this->set('action', $action); }
/** * Gets the HTML for the image of the data * @param mixed $data * @return string */ private function getImageHtml($data) { $modelTable = $this->meta->getModelTable(); if (!$modelTable->hasDataFormat(DataFormatter::FORMAT_IMAGE)) { return ''; } $image = $this->meta->formatData($data, DataFormatter::FORMAT_IMAGE); if ($image) { $image = new Image($image); } else { $image = new Image($this->defaultImage); } $image->setThumbnailer('crop', 50, 50); $image->appendToClass(self::STYLE_IMAGE); return $image->getHtml(); }