/** * @param AbstractColumn $column * @return string */ public function getFormattedValue(AbstractColumn $column) { $row = $this->getRowData(); $value = $row[$column->getUniqueId()]; $routeKey = !is_null($this->getRouteKey()) ? $this->getRouteKey() : $column->getUniqueId(); $params = $this->getRouteParams(); $params[$routeKey] = $value; $url = (string) $this->getViewRenderer()->url($this->getRoute(), $params); return sprintf('<a href="%s">%s</a>', $url, $value); }
public function getFormattedValue(AbstractColumn $column) { $row = $this->getRowData(); $value = $row[$column->getUniqueId()]; $prefix = $this->getPrefix(); if (is_array($value)) { $thumb = $value[0]; if (isset($value[1])) { $original = $value[1]; } else { $original = $thumb; } } else { $thumb = $value; $original = $value; } $linkAttributes = []; foreach ($this->getLinkAttributes() as $key => $value) { $linkAttributes[] = $key . '="' . $value . '"'; } $attributes = []; foreach ($this->getAttributes() as $key => $value) { $attributes[] = $key . '="' . $value . '"'; } return '<a href="' . $prefix . $original . '" ' . implode(' ', $linkAttributes) . '><img src="' . $prefix . $thumb . '" ' . implode(' ', $attributes) . ' /></a>'; }
public function testIsDisplayedException() { /* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ $action = $this->getMockForAbstractClass('ZfcDatagrid\\Column\\Action\\AbstractAction'); $this->setExpectedException('InvalidArgumentException'); $action->addShowOnValue($this->column, '23', 'UNknownFilter'); $action->isDisplayed([$this->column->getUniqueId() => '32']); }
public function testIsApplyAndOperatorNoDisplay() { /* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */ $style = $this->getMockForAbstractClass('Zf2datatable\\Column\\Style\\AbstractStyle'); $style->setByValueOperator('AND'); $style->addByValue($this->column, '23', Filter::EQUAL); $style->addByValue($this->column, '23', Filter::NOT_EQUAL); $this->assertFalse($style->isApply(array($this->column->getUniqueId() => '23'))); }
/** * The value should be in bytes * * @see \ZfcDatagrid\Column\Formatter\AbstractFormatter::getFormattedValue() */ public function getFormattedValue(AbstractColumn $column) { $row = $this->getRowData(); $value = $row[$column->getUniqueId()]; if ('' == $value) { return $value; } $index = 0; while ($value >= 1024 && $index < count(self::$prefixes)) { $value = $value / 1024; $index++; } return sprintf('%1.2f %sB', $value, self::$prefixes[$index]); }
public function testIsDisplayedByColumn() { /* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ $action = $this->getMockForAbstractClass('ZfcDatagrid\\Column\\Action\\AbstractAction'); $columnCompare = clone $this->column; $columnCompare->setUniqueId('columnCompare'); $action->addShowOnValue($this->column, $columnCompare, Filter::GREATER_EQUAL); $this->assertEquals([['column' => $this->column, 'value' => $columnCompare, 'comparison' => Filter::GREATER_EQUAL]], $action->getShowOnValues()); $this->assertTrue($action->hasShowOnValues()); // Test lower value $row = [$this->column->getUniqueId() => 5, $columnCompare->getUniqueId() => 15]; $this->assertFalse($action->isDisplayed($row)); // Test greater value $row = [$this->column->getUniqueId() => 15, $columnCompare->getUniqueId() => 10]; $this->assertTrue($action->isDisplayed($row)); // Test row without compared column $row = [$this->column->getUniqueId() => 15]; $this->assertTrue($action->isDisplayed($row)); }
public function testStyleByColumn() { /* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */ $style = $this->getMockForAbstractClass('ZfcDatagrid\\Column\\Style\\AbstractStyle'); $columnCompare = clone $this->column; $columnCompare->setUniqueId('columnCompare'); $style->addByValue($this->column, $columnCompare, Filter::GREATER_EQUAL); $this->assertEquals([['column' => $this->column, 'value' => $columnCompare, 'operator' => Filter::GREATER_EQUAL]], $style->getByValues()); $this->assertTrue($style->hasByValues()); // Test lower value $row = [$this->column->getUniqueId() => 5, $columnCompare->getUniqueId() => 15]; $this->assertFalse($style->isApply($row)); // Test greater value $row = [$this->column->getUniqueId() => 15, $columnCompare->getUniqueId() => 10]; $this->assertTrue($style->isApply($row)); // Test row without compared column $row = [$this->column->getUniqueId() => 15]; $this->assertTrue($style->isApply($row)); }
public function getFormattedValue(AbstractColumn $column) { $row = $this->getRowData(); return '<a href="mailto:' . $row[$column->getUniqueId()] . '">' . $row[$column->getUniqueId()] . '</a>'; }
/** * This is needed public for rowClickAction... * * @param AbstractColumn $col * @return string */ protected function getLinkReplaced(AbstractColumn $col) { $row = $this->getRowData(); $link = $this->getLink(); if ($link == '') { return $row[$col->getUniqueId()]; } // Replace placeholders if (strpos($link, self::ROW_ID_PLACEHOLDER) !== false) { $id = ''; if (isset($row['idConcated'])) { $id = $row['idConcated']; } $link = str_replace(self::ROW_ID_PLACEHOLDER, rawurlencode($id), $link); } foreach ($this->getLinkColumnPlaceholders() as $col) { $link = str_replace(':' . $col->getUniqueId() . ':', rawurlencode($row[$col->getUniqueId()]), $link); } return $link; }
/** * Get the column row value placeholder * $action->setLink('/myLink/something/id/'.$action->getRowIdPlaceholder().'/something/'.$action->getColumnRowPlaceholder($myCol)); * * @param AbstractColumn $col * @return string */ public function getColumnValuePlaceholder(AbstractColumn $col) { $this->linkColumnPlaceholders[] = $col; return ':' . $col->getUniqueId() . ':'; }