/** * Decorates the data into a locale overview * @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 all the values of the remaining rows of the table * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $data = $cell->getValue(); $value = ''; if (!$this->meta->isValidData($data)) { $cell->setValue($value); return; } if (isset($data->dataLocale) && $data->dataLocale != $this->currentLocale) { $row->appendToClass(self::STYLE_UNLOCALIZED); } $ids = $this->localizedModel->getLocalizedIds($data->id); foreach ($this->locales as $locale) { if (array_key_exists($locale, $ids)) { $localeString = '<strong>' . $locale . '</strong>'; } else { $localeString = $locale; } if ($this->action !== null) { $anchor = new Anchor($localeString, $this->action . '/' . $data->id . '/' . $locale); $localeString = $anchor->getHtml(); } $value .= ($value == '' ? '' : ' ') . $localeString; } $cell->setValue($value); }
/** * Decorates the cell with a order handle for the category * @param zibo\library\html\table\Cell $cell * @param zibo\library\html\table\Row $row * @param integer $rowNumber * @param array $remainingValues * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $data = $cell->getValue(); $row->setId('data_' . $data->id); $cell->appendToClass('action'); $image = new Image(self::IMAGE_HANDLE); $image->appendToClass('handle'); $cell->setValue($image->getHtml()); }
/** * Gets the HTML of this table * @return string */ public function getHtml() { $html = '<table' . $this->getIdHtml() . $this->getClassHtml() . $this->getAttributesHtml() . '>' . "\n"; if ($this->header) { $html .= "\t" . $this->header->getHtml() . "\n"; } foreach ($this->rows as $row) { $html .= "\t" . $row->getHtml() . "\n"; } $html .= '</table>' . "\n"; return $html; }
/** * Decorates the cell * @param zibo\library\html\table\Cell $cell Cell of the value 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 containing the values of the remaining rows of the table * @return null */ public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues) { $field = $cell->getValue(); if (!$field instanceof ModelField) { return; } $row->setId('field_' . $field->getName()); $cell->appendToClass('action'); $image = new Image(self::IMAGE_HANDLE); $image->appendToClass('handle'); $cell->setValue($image->getHtml()); }
/** * Adds the header row to the table based on the header decorators * @return null */ protected function addHeader() { if (!$this->hasHeaderDecorators) { return; } $row = new Row(); $row->appendToClass(self::STYLE_HEADER); foreach ($this->columnDecorators as $columnDecorator) { $cell = new HeaderCell(); $headerDecorator = $columnDecorator->getHeaderDecorator(); if ($headerDecorator) { $headerDecorator->decorate($cell, $row, 0, array()); } $row->addCell($cell); } parent::setHeader($row); }
/** * Adds a data row to the export * @param zibo\library\html\table\Row $row Data row * @return null */ public function addExportDataRow(Row $row, $isGroupRow) { $cells = $row->getCells(); foreach ($cells as $cell) { $value = $cell->getValue(); $cell->setValue(nl2br($value)); } if ($isGroupRow) { $row->appendToClass('group'); } else { if ($this->zebraIndex) { $row->appendToClass('even'); $this->zebraIndex = 0; } else { $row->appendToClass('odd'); $this->zebraIndex = 1; } } $this->rows[] = $row; }