Skip to content

Commit

Permalink
fixing a few bugs and adding a way to manage what fields show or not
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jun 11, 2010
1 parent c8a580f commit 295e56f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions extensions/data/views/helpers/csv.php
Expand Up @@ -29,7 +29,11 @@ function output($rows = null, $params = array(), $generated = true){
if (!empty($rows)){
foreach($params['needed'][key($params['needed'])] as $head){
if (!in_array($head, $this->ignore)){
$parts[] = Inflector::humanize(str_replace('_id', ' #', $head));
if($head == 'id'){
$parts[] = __(Inflector::humanize(key($params['needed'])), true).' #';
continue;
}
$parts[] = __(Inflector::humanize(str_replace('_id', ' #', $head)), true);
}
}

Expand All @@ -40,7 +44,10 @@ function output($rows = null, $params = array(), $generated = true){

foreach($array[key($params['needed'])] as $field => $value){
if (!in_array($field, $this->ignore)){
if (strpos($field, '_id') && in_array($field, $params['needed'][key($params['needed'])])){
if($field == 'id'){
$parts[] = str_pad($value, 5, 0, STR_PAD_LEFT);
}
else if (strpos($field, '_id') && in_array($field, $params['needed'][key($params['needed'])])){
$parts[] = $array[Inflector::camelize(str_replace('_id', '' , $field))][ClassRegistry::init(Inflector::camelize(str_replace('_id', '' , $field)))->displayField];
}

Expand Down

0 comments on commit 295e56f

Please sign in to comment.