Skip to content

Commit

Permalink
Removing altrow from the bake default templates.
Browse files Browse the repository at this point in the history
Refs #306
  • Loading branch information
markstory committed Jun 22, 2011
1 parent edda41e commit f547032
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 33 deletions.
11 changes: 3 additions & 8 deletions lib/Cake/Console/Templates/default/views/index.ctp
Expand Up @@ -28,13 +28,8 @@
<?php
echo "<?php
\$i = 0;
foreach (\${$pluralVar} as \${$singularVar}):
\$class = null;
if (\$i++ % 2 == 0) {
\$class = ' class=\"altrow\"';
}
?>\n";
echo "\t<tr<?php echo \$class;?>>\n";
foreach (\${$pluralVar} as \${$singularVar}): ?>\n";
echo "\t<tr>\n";
foreach ($fields as $field) {
$isKey = false;
if (!empty($associations['belongsTo'])) {
Expand Down Expand Up @@ -92,4 +87,4 @@
}
?>
</ul>
</div>
</div>
44 changes: 19 additions & 25 deletions lib/Cake/Console/Templates/default/views/view.ctp
Expand Up @@ -18,23 +18,23 @@
?>
<div class="<?php echo $pluralVar;?> view">
<h2><?php echo "<?php echo __('{$singularHumanName}');?>";?></h2>
<dl><?php echo "<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
<dl>
<?php
foreach ($fields as $field) {
$isKey = false;
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php echo __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$this->Html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
echo "\t\t<dt><?php echo __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
echo "\t\t<dd>\n\t\t\t<?php echo \$this->Html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
break;
}
}
}
if ($isKey !== true) {
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php echo __('" . Inflector::humanize($field) . "'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo h(\${$singularVar}['{$modelClass}']['{$field}']); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
echo "\t\t<dt><?php echo __('" . Inflector::humanize($field) . "'); ?></dt>\n";
echo "\t\t<dd>\n\t\t\t<?php echo h(\${$singularVar}['{$modelClass}']['{$field}']); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
}
}
?>
Expand Down Expand Up @@ -68,11 +68,11 @@ if (!empty($associations['hasOne'])) :
<div class="related">
<h3><?php echo "<?php echo __('Related " . Inflector::humanize($details['controller']) . "');?>";?></h3>
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
<dl>
<?php
foreach ($details['fields'] as $field) {
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php echo __('" . Inflector::humanize($field) . "');?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
echo "\t\t<dt><?php echo __('" . Inflector::humanize($field) . "');?></dt>\n";
echo "\t\t<dd>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
}
?>
</dl>
Expand Down Expand Up @@ -113,24 +113,18 @@ foreach ($relations as $alias => $details):
<?php
echo "\t<?php
\$i = 0;
foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}):
\$class = null;
if (\$i++ % 2 == 0) {
\$class = ' class=\"altrow\"';
foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}): ?>\n";
echo "\t\t<tr>\n";
foreach ($details['fields'] as $field) {
echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field}'];?></td>\n";
}
?>\n";
echo "\t\t<tr<?php echo \$class;?>>\n";

foreach ($details['fields'] as $field) {
echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field}'];?></td>\n";
}

echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";
echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";

echo "\t<?php endforeach; ?>\n";
?>
Expand All @@ -142,4 +136,4 @@ echo "\t<?php endforeach; ?>\n";
</ul>
</div>
</div>
<?php endforeach;?>
<?php endforeach;?>

0 comments on commit f547032

Please sign in to comment.