From 7acbe50d5b7bd3130a37c080190e30b54a6b0723 Mon Sep 17 00:00:00 2001 From: Miklos Marton Date: Sun, 13 Sep 2015 09:27:33 +0200 Subject: [PATCH 1/2] Fixed indentation in the generated view's. --- src/Template/Bake/Element/form.ctp | 37 ++++---- src/Template/Bake/Template/index.ctp | 25 +++--- src/Template/Bake/Template/view.ctp | 122 ++++++++++++++------------- 3 files changed, 96 insertions(+), 88 deletions(-) diff --git a/src/Template/Bake/Element/form.ctp b/src/Template/Bake/Element/form.ctp index 8dc64e15..9e4ef6bf 100644 --- a/src/Template/Bake/Element/form.ctp +++ b/src/Template/Bake/Element/form.ctp @@ -12,25 +12,26 @@ $this->extend('../Layout/TwitterBootstrap/dashboard'); $this->start('tb_actions'); ?> <% if (strpos($action, 'add') === false): %> -
  • Form->postLink( - __('Delete'), - ['action' => 'delete', $<%= $singularVar - %>-><%= $primaryKey[0] %>], - ['confirm' => __('Are you sure you want to delete # {0}?', $<%= $singularVar %>-><%= $primaryKey[0] %>)] + __('Delete'), + ['action' => 'delete', $<%= $singularVar + %>-><%= $primaryKey[0] %>], + ['confirm' => __('Are you sure you want to delete # {0}?', $<%= $singularVar %>-><%= $primaryKey[0] %>)] ) - ?>
  • + ?> + <% endif; %> -
  • Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?>
  • +
  • Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?>
  • <% $done = []; foreach ($associations as $type => $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { %> -
  • Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) %>
  • -
  • Html->link(__('New <%= $this->_singularHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) %>
  • - <% +
  • Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) %>
  • +
  • Html->link(__('New <%= $this->_singularHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) %>
  • +<% $done[] = $details['controller']; } } @@ -42,7 +43,7 @@ foreach ($associations as $type => $data) {
    {0}', ['<%= $singularHumanName %>']) ?> $data) { if (isset($keyFields[$field])) { %> echo $this->Form->input('<%= $field %>', ['options' => $<%= $keyFields[$field] %>]); - <% +<% continue; } if (!in_array($field, ['created', 'modified', 'updated'])) { %> echo $this->Form->input('<%= $field %>'); - <% +<% } } if (!empty($associations['BelongsToMany'])) { foreach ($associations['BelongsToMany'] as $assocName => $assocData) { %> echo $this->Form->input('<%= $assocData['property'] %>._ids', ['options' => $<%= $assocData['variable'] %>]); - <% +<% } } %> ?>
    -Form->button(__('Submit')) ?> +<% +if (strpos($action, 'add') === false) + $submitButtonTitle = '__("Save")'; +else + $submitButtonTitle = '__("Add")'; +%> +Form->button(<% echo $submitButtonTitle;%>); ?> Form->end() ?> \ No newline at end of file diff --git a/src/Template/Bake/Template/index.ctp b/src/Template/Bake/Template/index.ctp index 40c59007..477961f0 100644 --- a/src/Template/Bake/Template/index.ctp +++ b/src/Template/Bake/Template/index.ctp @@ -6,16 +6,16 @@ use Cake\Utility\Inflector; $this->extend('../Layout/TwitterBootstrap/dashboard'); $this->start('tb_actions'); ?> -
  • Html->link(__('New <%= $singularHumanName %>'), ['action' => 'add']); ?>
  • +
  • Html->link(__('New <%= $singularHumanName %>'), ['action' => 'add']); ?>
  • <% $done = []; foreach ($associations as $type => $data): foreach ($data as $alias => $details): if ($details['controller'] != $this->name && !in_array($details['controller'], $done)): %> -
  • Html->link(__('List <%= Inflector::humanize($details["controller"]) %>'), ['controller' => '<%= $details["controller"] %>', 'action' => 'index']); ?>
  • -
  • Html->link(__('New <%= Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) %>'), ['controller' => ' <%= $details["controller"] %>', 'action' => 'add']); ?>
  • - <% +
  • Html->link(__('List <%= Inflector::humanize($details["controller"]) %>'), ['controller' => '<%= $details["controller"] %>', 'action' => 'index']); ?>
  • +
  • Html->link(__('New <%= Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) %>'), ['controller' => ' <%= $details["controller"] %>', 'action' => 'add']); ?>
  • +<% $done[] = $details['controller']; endif; endforeach; @@ -34,16 +34,16 @@ $fields = collection($fields) - <% foreach ($fields as $field): %> +<% foreach ($fields as $field): %> - <% endforeach; %> +<% endforeach; %> as $<%= $singularVar %>): ?> - <% +<% foreach ($fields as $field) { $isKey = false; if (!empty($associations['BelongsTo'])) { @@ -52,9 +52,9 @@ $fields = collection($fields) $isKey = true; %> - <% + ->has('<%= $details['property'] %>') ? $this->Html->link($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>, ['controller' => '<%= $details['controller'] %>', 'action' => 'view', $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['primaryKey'][0] %>]) : '' ?> + +<% break; } } @@ -63,11 +63,11 @@ $fields = collection($fields) if (!in_array($schema->columnType($field), ['integer', 'biginteger', 'decimal', 'float'])) { %> - <% +<% } else { %> - <% +<% } } } @@ -80,7 +80,6 @@ $fields = collection($fields) Form->postLink('', ['action' => 'delete', <%= $pk %>], ['confirm' => __('Are you sure you want to delete # {0}?', <%= $pk %>), 'title' => __('Delete'), 'class' => 'btn btn-default glyphicon glyphicon-trash']) ?> -
    Paginator->sort('<%= $field %>'); ?>
    - ->has('<%= $details['property'] %>') ? $this->Html->link($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>, ['controller' => '<%= $details['controller'] %>', 'action' => 'view', $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['primaryKey'][0] %>]) : '' ?> - -><%= $field %>) ?>Number->format($<%= $singularVar %>-><%= $field %>) ?>
    diff --git a/src/Template/Bake/Template/view.ctp b/src/Template/Bake/Template/view.ctp index 447ee243..f6dbaa11 100644 --- a/src/Template/Bake/Template/view.ctp +++ b/src/Template/Bake/Template/view.ctp @@ -43,19 +43,19 @@ $pk = "\$$singularVar->{$primaryKey[0]}"; $this->extend('../Layout/TwitterBootstrap/dashboard'); $this->start('tb_actions'); ?> -
  • Html->link(__('Edit <%= $singularHumanName %>'), ['action' => 'edit', <%= $pk %>]) ?>
  • -
  • Form->postLink(__('Delete <%= $singularHumanName %>'), ['action' => 'delete', <%= $pk %>], ['confirm' => __('Are you sure you want to delete # {0}?', <%= $pk %>)]) ?>
  • -
  • Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?>
  • -
  • Html->link(__('New <%= $singularHumanName %>'), ['action' => 'add']) ?>
  • +
  • Html->link(__('Edit <%= $singularHumanName %>'), ['action' => 'edit', <%= $pk %>]) ?>
  • +
  • Form->postLink(__('Delete <%= $singularHumanName %>'), ['action' => 'delete', <%= $pk %>], ['confirm' => __('Are you sure you want to delete # {0}?', <%= $pk %>)]) ?>
  • +
  • Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?>
  • +
  • Html->link(__('New <%= $singularHumanName %>'), ['action' => 'add']) ?>
  • <% $done = []; foreach ($associations as $type => $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { %> -
  • Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) ?>
  • -
  • Html->link(__('New <%= Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) ?>
  • - <% +
  • Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) ?>
  • +
  • Html->link(__('New <%= Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) ?>
  • +<% $done[] = $details['controller']; } } @@ -66,57 +66,59 @@ foreach ($associations as $type => $data) {

    -><%= $displayField %>) ?>

    - <% if ($groupedFields['string']) : %> +<% if ($groupedFields['string']) : %>
    - <% foreach ($groupedFields['string'] as $field) : %> - <% +<% foreach ($groupedFields['string'] as $field) : %> +<% if (isset($associationFields[$field])) : $details = $associationFields[$field]; %>
    ') ?>
    -

    ->has('<%= $details['property'] %>') ? $this->Html->link($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>, ['controller' => '<%= $details['controller'] %>', 'action' => 'view', $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['primaryKey'][0] %>]) : '' ?>

    - <% else : %> +

    ->has('<%= $details['property'] %>') ? $this->Html->link($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>, ['controller' => '<%= $details['controller'] %>', 'action' => 'view', $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['primaryKey'][0] %>]) : '' ?>

    +<% else : %>
    ') ?>
    -

    -><%= $field %>) ?>

    - <% endif; %> - <% endforeach; %> +

    -><%= $field %>) ?>

    +<% endif; %> +<% endforeach; %>
    - <% endif; %> - <% if ($groupedFields['number']) : %> +<% endif; %> +<% if ($groupedFields['number']) : %>
    - <% foreach ($groupedFields['number'] as $field) : %> +<% foreach ($groupedFields['number'] as $field) : %>
    ') ?>
    -

    Number->format($<%= $singularVar %>-><%= $field %>) ?>

    - <% endforeach; %> +

    Number->format($<%= $singularVar %>-><%= $field %>) ?>

    +<% endforeach; %>
    - <% endif; %> - <% if ($groupedFields['date']) : %> +<% endif; %> +<% if ($groupedFields['date']) : %>
    - <% foreach ($groupedFields['date'] as $field) : %> +<% foreach ($groupedFields['date'] as $field) : %>
    <%= "<%= __('" . Inflector::humanize($field) . "') %>" %>
    -

    -><%= $field %>) ?>

    - <% endforeach; %> +

    -><%= $field %>) ?>

    +<% endforeach; %>
    - <% endif; %> - <% if ($groupedFields['boolean']) : %> +<% endif; %> +<% if ($groupedFields['boolean']) : %>
    - <% foreach ($groupedFields['boolean'] as $field) : %> +<% foreach ($groupedFields['boolean'] as $field) : %>
    ') ?>
    -

    -><%= $field %> ? __('Yes') : __('No'); ?>

    - <% endforeach; %> +

    -><%= $field %> ? __('Yes') : __('No'); ?>

    +<% endforeach; %>
    - <% endif; %> +<% endif; %>
    <% if ($groupedFields['text']) : %> - <% foreach ($groupedFields['text'] as $field) : %> +<% foreach ($groupedFields['text'] as $field) : %>
    -
    -
    ') ?>
    - Text->autoParagraph(h($<%= $singularVar %>-><%= $field %>)); ?> -
    -
    - <% endforeach; %> -<% endif; %> +
    +
    ') ?>
    + Text->autoParagraph(h($<%= $singularVar %>-><%= $field %>)); ?> +
    + +<% +endforeach; +endif; +%> <% $relations = $associations['HasMany'] + $associations['BelongsToMany']; foreach ($relations as $alias => $details): @@ -124,31 +126,31 @@ foreach ($relations as $alias => $details): $otherPluralHumanName = Inflector::humanize($details['controller']); %> -<% +<% endforeach; -endif; +endif; %> <% $relations = $associations['HasMany'] + $associations['BelongsToMany'];