Skip to content
Snippets Groups Projects
Commit fc4a61a4 authored by Tim Steiner's avatar Tim Steiner
Browse files

Update to the CollectionTable view helper

parent a537b352
No related branches found
No related tags found
No related merge requests found
<?php
class App_View_Helper_CollectionTable extends Zend_View_Helper_Abstract
{
public function collectionTable(Unl_Model_Collection $collection, array $columns, array $searchUrlParameters = array(), array $rowUrlSpec = array())
public function collectionTable(Unl_Model_Collection $collection,
array $columns,
array $searchUrlParameters = null,
array $rowUrlSpec = null,
array $formatOptions = null)
{
if (!is_array($searchUrlParameters)) {
$searchUrlParameters = array();
}
if (!is_array($rowUrlSpec)) {
$rowUrlSpec = array();
}
if (!is_array($formatOptions)) {
$formatOptions = array();
}
$output = '';
$output .= "<table>\n";
......@@ -27,7 +42,7 @@ class App_View_Helper_CollectionTable extends Zend_View_Helper_Abstract
if ($url) {
$output .= '<a href="' . $url . '">';
}
$output .= $row->{'get' . $field}();
$output .= $this->_applyFormatting($row->{'get' . $field}(), $formatOptions[$field]);
if ($url) {
$output .= '</a>';
}
......@@ -52,4 +67,22 @@ class App_View_Helper_CollectionTable extends Zend_View_Helper_Abstract
}
return call_user_func_array('sprintf', $params);
}
protected function _applyFormatting($data, $options)
{
if (!is_array($options)) {
if (is_array($data)) {
$data = implode(', ', $data);
}
return $data;
}
if ($options['type'] == 'Zend_Date' && $data instanceof Zend_Date) {
$data = $data->toString($options['format']);
}
return $data;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment