/** * Decorates a cell which contains an Advertisement object * @param zibo\library\html\table\Cell $cell * @param zibo\library\html\table\Row $row * @param int $rowNumber * @param array $remainingValues * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $advertisement = $cell->getValue(); if (!$advertisement instanceof AdvertisementData) { return; } $cell->appendToClass('advertisement'); try { $image = new Image($advertisement->image); $image->appendToClass('data'); $image->setThumbnailer('crop', 50, 50); $value = $image->getHtml(); } catch (Exception $e) { $value = 'Could not load image: ' . $e->getMessage(); } $anchor = new Anchor($advertisement->name, $this->action . $advertisement->id); $value .= $anchor->getHtml(); if (!$advertisement->clicks) { $advertisement->clicks = '0'; } $translateParams = array('from' => $this->locale->formatDate($advertisement->dateStart), 'till' => $this->locale->formatDate($advertisement->dateStop), 'clicks' => $advertisement->clicks); $value .= '<div class="info">'; $value .= $advertisement->website . '<br />'; $value .= $this->translator->translate(self::TRANSLATION_DISPLAY, $translateParams) . '<br />'; $value .= $this->translator->translate(self::TRANSLATION_CLICKS, $translateParams); $value .= '</div>'; $cell->setValue($value); }
/** * Performs the actual decorating on the provided value. * @param mixed $value The value to decorate * @return mixed The decorated value */ protected function decorateValue($value) { if (!$value) { return self::DEFAULT_VALUE; } try { $value = $this->locale->formatDate($value, $this->format); } catch (Exception $e) { $value = self::DEFAULT_VALUE; } return $value; }
/** * 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(); $title = '#' . $data->id . ': ' . $data->getJobClassName(); $anchor = new Anchor($title, $this->action . $data->id); $translationVars = array('queue' => $data->queue, 'date' => $this->locale->formatDate($data->dateAdded, 'j F Y H:i:s')); if ($data->dateScheduled) { $translationKey = self::TRANSLATION_INFO_SCHEDULED; $translationVars['scheduled'] = $this->locale->formatDate($data->dateScheduled, 'j F Y H:i:s'); } else { $translationKey = self::TRANSLATION_INFO; } $value = $anchor->getHtml(); $value .= '<div class="info">' . $this->translator->translate($translationKey, $translationVars) . '</div>'; $cell->setValue($value); }