diff --git a/Console/Templates/boost3/actions/controller_actions.ctp b/Console/Templates/boost3/actions/controller_actions.ctp new file mode 100644 index 0000000..cb948a9 --- /dev/null +++ b/Console/Templates/boost3/actions/controller_actions.ctp @@ -0,0 +1,179 @@ +/** + * index method + * + * @return void + */ + public function index() { + $this->->recursive = 0; + $this->set('', $this->Paginator->paginate()); + } + +/** + * view method + * + * @param string $id + * @return void + */ + public function view($id = null) { + $this->->id = $id; + if (!$this->->exists()) { + throw new NotFoundException(__('Invalid %s', __(''))); + } + $this->set('', $this->->read(null, $id)); + } + + +/** + * add method + * + * @return void + */ + public function add() { + if ($this->request->is('post')) { + $this->->create(); + if ($this->->save($this->request->data)) { + + $this->Session->setFlash( + __('The %s has been saved', __('')), + 'alert', + array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' + ) + ); + $this->redirect(array('action' => 'index')); + + $this->flash(__('%s saved.', __('')), array('action' => 'index')); + + } else { + + $this->Session->setFlash( + __('The %s could not be saved. Please, try again.', __('')), + 'alert', + array( + 'plugin' => 'BoostCake', + 'class' => 'alert-error' + ) + ); + + } + } +{$assoc} as $associationName => $relation): + if (!empty($associationName)): + $otherModelName = $this->_modelName($associationName); + $otherPluralName = $this->_pluralName($associationName); + echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; + $compact[] = "'{$otherPluralName}'"; + endif; + endforeach; + endforeach; + if (!empty($compact)): + echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; + endif; +?> + } + + +/** + * edit method + * + * @param string $id + * @return void + */ + public function edit($id = null) { + $this->->id = $id; + if (!$this->->exists()) { + throw new NotFoundException(__('Invalid %s', __(''))); + } + if ($this->request->is('post') || $this->request->is('put')) { + if ($this->->save($this->request->data)) { + + $this->Session->setFlash( + __('The %s has been saved', __('')), + 'alert', + array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' + ) + ); + $this->redirect(array('action' => 'index')); + + $this->flash(__('The %s has been saved.', __('')), array('action' => 'index')); + + } else { + + $this->Session->setFlash( + __('The %s could not be saved. Please, try again.', __('')), + 'alert', + array( + 'plugin' => 'BoostCake', + 'class' => 'alert-error' + ) + ); + + } + } else { + $this->request->data = $this->->read(null, $id); + } +{$assoc} as $associationName => $relation): + if (!empty($associationName)): + $otherModelName = $this->_modelName($associationName); + $otherPluralName = $this->_pluralName($associationName); + echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; + $compact[] = "'{$otherPluralName}'"; + endif; + endforeach; + endforeach; + if (!empty($compact)): + echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; + endif; + ?> + } + +/** + * delete method + * + * @param string $id + * @return void + */ + public function delete($id = null) { + if (!$this->request->is('post')) { + throw new MethodNotAllowedException(); + } + $this->->id = $id; + if (!$this->->exists()) { + throw new NotFoundException(__('Invalid %s', __(''))); + } + if ($this->->delete()) { + + $this->Session->setFlash( + __('The %s deleted', __('')), + 'alert', + array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' + ) + ); + $this->redirect(array('action' => 'index')); + + $this->flash(__('%s deleted', __('')), array('action' => 'index')); + + } + + $this->Session->setFlash( + __('The %s was not deleted', __('')), + 'alert', + array( + 'plugin' => 'BoostCake', + 'class' => 'alert-error' + ) + ); + + $this->flash(__('%s was not deleted', __('')), array('action' => 'index')); + + $this->redirect(array('action' => 'index')); + } diff --git a/Console/Templates/boost3/classes/controller.ctp b/Console/Templates/boost3/classes/controller.ctp new file mode 100644 index 0000000..789754e --- /dev/null +++ b/Console/Templates/boost3/classes/controller.ctp @@ -0,0 +1,67 @@ + +/** + * Controller + * + + */ +class Controller extends AppController { + + +/** + * Scaffold + * + * @var mixed + */ + public $scaffold; + + + +} diff --git a/Console/Templates/boost3/views/form.ctp b/Console/Templates/boost3/views/form.ctp new file mode 100644 index 0000000..8df2735 --- /dev/null +++ b/Console/Templates/boost3/views/form.ctp @@ -0,0 +1,82 @@ +
+
+ Form->create('{$modelClass}', array( + 'class' => 'form-horizontal', + 'inputDefaults' => array( + 'label' => array( + 'class' => 'col-md-3 control-label', + ), + 'div' => array( + 'class' => 'form-group', + ), + 'wrapInput' => array( + 'class' => 'col-md-9' + ), + 'class' => 'form-control' + ) + )); + ?>"; ?> +
+ "; ?> + Form->hidden('{$field}');\n"; + } else { + if ($this->templateVars['schema'][$field]['null'] == false) { + $required = ", array(\n\t\t\t\t\t'required' => 'required',\n\t\t\t\t\t'afterInput' => '' . __('Required') . ' ')\n\t\t\t\t"; + } else { + $required = null; + } + echo "\t\t\t\techo \$this->Form->input('{$field}'{$required});\n"; + } + } + } + echo $id; + unset($id); + if (!empty($associations['hasAndBelongsToMany'])) { + foreach ($associations['hasAndBelongsToMany'] as $assocName => $assocData) { + echo "\t\t\t\techo \$this->Form->input('{$assocName}');\n"; + } + } + echo "\t\t\t\t?>\n"; + echo "\t\t\t\tForm->submit(__('Submit'));?>\n"; + ?> +
+ Form->end();?>\n"; + ?> +
+ +
+
+
+

"; ?>

+
+ +
    + +
  • Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?>
  • + +
  • Html->link(__('List %s', __('" . $pluralHumanName . "')), array('action' => 'index'));?>"; ?>
  • + $data) { + foreach ($data as $alias => $details) { + if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { + echo "\t\t\t
  • Html->link(__('List %s', __('" . Inflector::humanize($details['controller']) . "')), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; + echo "\t\t\t
  • Html->link(__('New %s', __('" . Inflector::humanize(Inflector::underscore($alias)) . "')), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + $done[] = $details['controller']; + } + } + } + ?> +
+
+
+
\ No newline at end of file diff --git a/Console/Templates/boost3/views/index.ctp b/Console/Templates/boost3/views/index.ctp new file mode 100644 index 0000000..48765d1 --- /dev/null +++ b/Console/Templates/boost3/views/index.ctp @@ -0,0 +1,78 @@ +
+
+

"; ?>

+ +

+ Paginator->counter(array('format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')));?>\n"; ?> +

+ Paginator->pagination(array( + 'ul' => 'pagination pagination-lg' + )); ?>\n"; ?> + + + + + + + + \n"; + echo "\t\t\t\n"; + 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\t\t\n"; + break; + } + } + } + if ($isKey !== true) { + echo "\t\t\t\t\n"; + } + } + + echo "\t\t\t\t\n"; + echo "\t\t\t\n"; + + echo "\t\t\n"; + ?> +
Paginator->sort('{$field}');?>"; ?>"; ?>
\n\t\t\t\t\tHtml->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t\t \n"; + + echo "\t\t\t\t\tHtml->link('', array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('escape' => false, 'class' => 'btn btn-success')); ?>\n"; + echo "\t\t\t\t\tHtml->link('', array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('escape' => false, 'class' => 'btn btn-info')); ?>\n"; + echo "\t\t\t\t\tForm->postLink('', array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('escape' => false, 'class' => 'btn btn-danger'), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; + echo "\t\t\t\t
+ + Paginator->pagination(array( + 'ul' => 'pagination pagination-lg' + )); ?>\n"; ?> +
+
+
+
+

"; ?>

+
+ + +
    +
  • Html->link(__('New %s', __('" . $singularHumanName . "')), array('action' => 'add')); ?>"; ?>
  • + $data) { + foreach ($data as $alias => $details) { + if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { + echo "\t\t\t
  • Html->link(__('List %s', __('" . Inflector::humanize($details['controller']) . "')), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; + echo "\t\t\t
  • Html->link(__('New %s', __('" . Inflector::humanize(Inflector::underscore($alias)) . "')), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + $done[] = $details['controller']; + } + } + } + ?> +
+
+
+ +
\ No newline at end of file diff --git a/Console/Templates/boost3/views/view.ctp b/Console/Templates/boost3/views/view.ctp new file mode 100644 index 0000000..4101bb2 --- /dev/null +++ b/Console/Templates/boost3/views/view.ctp @@ -0,0 +1,137 @@ +
+
+

"; ?>

+
+ $details) { + if ($field === $details['foreignKey']) { + $isKey = true; + echo "\t\t\t
\n"; + echo "\t\t\t
\n\t\t\t\tHtml->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t\t \n\t\t\t
\n"; + break; + } + } + } + if ($isKey !== true) { + echo "\t\t\t
\n"; + echo "\t\t\t
\n\t\t\t\t\n\t\t\t\t \n\t\t\t
\n"; + } + } + ?> +
+
+ +
+
+
+

"; ?>

+
+ + +
    + Html->link(__('Edit %s', __('" . $singularHumanName . "')), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n"; + echo "\t\t\t
  • Form->postLink(__('Delete %s', __('" . $singularHumanName . "')), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
  • \n"; + echo "\t\t\t
  • Html->link(__('List %s', __('" . $pluralHumanName . "')), array('action' => 'index')); ?>
  • \n"; + echo "\t\t\t
  • Html->link(__('New %s', __('" . $singularHumanName . "')), array('action' => 'add')); ?>
  • \n"; + + $done = array(); + foreach ($associations as $type => $data) { + foreach ($data as $alias => $details) { + if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { + echo "\t\t\t
  • Html->link(__('List %s', __('" . Inflector::humanize($details['controller']) . "')), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; + echo "\t\t\t
  • Html->link(__('New %s', __('" . Inflector::humanize(Inflector::underscore($alias)) . "')), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + $done[] = $details['controller']; + } + } + } + ?> +
+
+
+ + +
+ + $details): + ?> +
+
+

"; ?>

+ \n"; ?> +
+ \n"; + echo "\t\t\t
\n\t\t\t\t\n\t\t\t\t \n\t\t\t
\n"; + } + ?> +
+ \n"; ?> +
+
+ +
+
+ + $details): + $otherSingularVar = Inflector::variable($alias); + $otherPluralHumanName = Inflector::humanize($details['controller']); + ?> +
+
+

"; ?>

+ \n"; ?> + + + \n"; + } + ?> + + + \n"; + echo "\t\t\t\n"; + foreach ($details['fields'] as $field) { + echo "\t\t\t\t\n"; + } + + echo "\t\t\t\t\n"; + echo "\t\t\t\n"; + + echo "\t\t\n"; + ?> +
"; ?>
\n"; + echo "\t\t\t\t\tHtml->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; + echo "\t\t\t\t\tHtml->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; + echo "\t\t\t\t\tForm->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\t
+ \n\n"; ?> +
+
+ +
+
+