Skip to content

Commit

Permalink
fixes lonnieezell#255 MB: Modify the index and index_alt views genera…
Browse files Browse the repository at this point in the history
…ted by the Module Builder to use the record->FIELD_NAME rather than a dynamically generate list
  • Loading branch information
Sean Downey committed Nov 19, 2011
1 parent 85a6b0b commit c1ce328
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 24 deletions.
Expand Up @@ -84,20 +84,37 @@
<tbody>
<?php
foreach ($records as $record) : ?>
<?php $record = (array)$record;?>
<tr>
<?php
foreach($record as $field => $value)
{
if($field != "'.$primary_key_field.'") {
?>
<td><?php echo ($field == \'deleted\') ? (($value > 0) ? lang(\''.$module_name_lower.'_true\') : lang(\''.$module_name_lower.'_false\')) : $value; ?></td>
<tr>';
for($counter=1; $field_total >= $counter; $counter++)
{
// only build on fields that have data entered.

<?php
}
//Due to the requiredif rule if the first field is set the the others must be

if (set_value("view_field_name$counter") == NULL || set_value("view_field_name$counter") == $primary_key_field)
{
continue; // move onto next iteration of the loop
}
?>
<td><?php echo anchor(SITE_AREA .\'/'.$controller_name.'/'.$module_name_lower.'/edit/\'. $record[\''.$primary_key_field.'\'], lang(\''.$module_name_lower.'_edit\'), \'class="ajaxify"\'); ?></td>
$view .= '
<td><?php echo $record->'.$module_name_lower.'_'.set_value("view_field_name$counter").'?></td>';
}
if ($use_soft_deletes == 'true')
{
$view .= '
<td><?php echo $record->deleted > 0 ? lang(\''.$module_name_lower.'_true\') : lang(\''.$module_name_lower.'_false\')?></td>';
}
if ($use_created == 'true')
{
$view .= '
<td><?php echo $record->'.set_value("created_field").'?></td>';
}
if ($use_modified == 'true')
{
$view .= '
<td><?php echo $record->'.set_value("modified_field").'?></td>';
}
$view .= '
<td><?php echo anchor(SITE_AREA .\'/'.$controller_name.'/'.$module_name_lower.'/edit/\'. $record->'.$primary_key_field.', lang(\''.$module_name_lower.'_edit\'), \'class="ajaxify"\'); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
Expand Up @@ -29,19 +29,9 @@
<tbody>
<?php foreach (\$records as \$record) : ?>
<?php \$record = (array)\$record;?>
<tr>
<?php foreach(\$record as \$field => \$value) : ?>
<?php if (\$field != '{$primary_key_field}') : ?>
<td><?php echo (\$field == 'deleted') ? ((\$value > 0) ? lang('{$module_name_lower}_true') : lang('{$module_name_lower}_false')) : \$value; ?></td>
<?php endif; ?>
<?php endforeach; ?>
<td>
<?php echo anchor(SITE_AREA .'/{$controller_name}/{$module_name_lower}/edit/'. \$record[\$primary_key_field], lang('{$module_name_lower}_edit'), '') ?>
</td>
{table_records}
<td><?php echo anchor(SITE_AREA .'/{$controller_name}/{$module_name_lower}/edit/'. \$record->{$primary_key_field}, lang('{$module_name_lower}_edit'), '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down Expand Up @@ -79,7 +69,40 @@
<th>Modified</th>';
}

$table_records = '';
for($counter=1; $field_total >= $counter; $counter++)
{
// only build on fields that have data entered.

//Due to the requiredif rule if the first field is set the the others must be

if (set_value("view_field_name$counter") == NULL || set_value("view_field_name$counter") == $primary_key_field)
{
continue; // move onto next iteration of the loop
}
$table_records .= '
<td><?php echo $record->'.$module_name_lower.'_'.set_value("view_field_name$counter").'?></td>';
}
if ($use_soft_deletes == 'true')
{
$table_records .= '
<td><?php echo $record->deleted > 0 ? lang(\''.$module_name_lower.'_true\') : lang(\''.$module_name_lower.'_false\')?></td>';
}
if ($use_created == 'true')
{
$table_records .= '
<td><?php echo $record->'.set_value("created_field").'?></td>';
}
if ($use_modified == 'true')
{
$table_records .= '
<td><?php echo $record->'.set_value("modified_field").'?></td>';
}



$view = str_replace('{table_header}', $headers, $view);
$view = str_replace('{table_records}', $table_records, $view);

echo $view;

Expand Down

0 comments on commit c1ce328

Please sign in to comment.