From 31a40cfc446c9586f89a4aa69ef76d76d469e5a4 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Mon, 16 Jul 2018 13:24:18 +0200 Subject: Bake : setup and create empty CustomTheme --- app-from-scratch.sh | 19 +++ fai_gestion/composer.json | 8 +- fai_gestion/composer.lock | 2 +- fai_gestion/config/bootstrap_cli.php | 2 + fai_gestion/plugins/CustomTheme/.gitignore | 3 + fai_gestion/plugins/CustomTheme/README.md | 11 ++ fai_gestion/plugins/CustomTheme/composer.json | 23 ++++ fai_gestion/plugins/CustomTheme/config/routes.php | 12 ++ fai_gestion/plugins/CustomTheme/phpunit.xml.dist | 36 ++++++ .../CustomTheme/src/Controller/AppController.php | 10 ++ fai_gestion/plugins/CustomTheme/src/Plugin.php | 12 ++ .../src/Template/Bake/Controller/controller.twig | 57 +++++++++ .../src/Template/Bake/Element/Controller/add.twig | 46 +++++++ .../src/Template/Bake/Element/Controller/edit.twig | 49 ++++++++ .../Template/Bake/Element/Controller/index.twig | 33 +++++ .../src/Template/Bake/Element/form.twig | 80 ++++++++++++ .../src/Template/Bake/Model/entity.twig | 61 +++++++++ .../CustomTheme/src/Template/Bake/Model/table.twig | 138 +++++++++++++++++++++ .../src/Template/Bake/Template/index.twig | 90 ++++++++++++++ .../src/Template/Bake/Template/view.twig | 137 ++++++++++++++++++++ .../plugins/CustomTheme/tests/bootstrap.php | 30 +++++ fai_gestion/plugins/CustomTheme/webroot/empty | 0 fai_gestion/plugins/empty | 0 23 files changed, 855 insertions(+), 4 deletions(-) create mode 100644 fai_gestion/plugins/CustomTheme/.gitignore create mode 100644 fai_gestion/plugins/CustomTheme/README.md create mode 100644 fai_gestion/plugins/CustomTheme/composer.json create mode 100644 fai_gestion/plugins/CustomTheme/config/routes.php create mode 100644 fai_gestion/plugins/CustomTheme/phpunit.xml.dist create mode 100644 fai_gestion/plugins/CustomTheme/src/Controller/AppController.php create mode 100644 fai_gestion/plugins/CustomTheme/src/Plugin.php create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Controller/controller.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/entity.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/table.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig create mode 100644 fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig create mode 100644 fai_gestion/plugins/CustomTheme/tests/bootstrap.php create mode 100644 fai_gestion/plugins/CustomTheme/webroot/empty delete mode 100644 fai_gestion/plugins/empty diff --git a/app-from-scratch.sh b/app-from-scratch.sh index 9d6ed70..9fcdf90 100644 --- a/app-from-scratch.sh +++ b/app-from-scratch.sh @@ -208,3 +208,22 @@ cat ~/chd_gestion/schema/enum-tables-data-mysql.sql | sudo mariadb fai_gestion # - ALTER TABLE equipements CHANGE ipmgmt_id ip_management VARCHAR(39) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; # - import PROCEDURE refresh_network_elt(IN root INT) # - TODO : work on fai_gestion_exports permissions +# - TODO : dump everything cleanly then git + +# bake initial setup +cd ~/chd_gestion/fai_gestion/ +composer.phar require --dev cakephp/bake:~1.0 +yes | cake bake plugin CustomTheme +v=vendor/cakephp/bake/src/Template/Bake +p=plugins/CustomTheme/src/Template/Bake +mkdir -p $p/{Controller,Element/Controller,Model,Template} +cp -a $v/Controller/controller.twig $p/Controller/ +cp -a $v/Element/form.twig $p/Element/ +cp -a $v/Element/Controller/{add,edit,index}.twig $p/Element/Controller +cp -a $v/Model/{entity,table}.twig $p/Model/ +cp -a $v/Template/{index,view}.twig $p/Template/ +editor config/bootstrap.php config/bootstrap_cli.php +# load the plugin only in cli mode +git checkout -- config/bootstrap.php +git add ../app-from-scratch.sh composer.json composer.lock config/bootstrap_cli.php plugins/ +git commit -m "Bake : setup and create empty CustomTheme" diff --git a/fai_gestion/composer.json b/fai_gestion/composer.json index 7787c9a..d370f55 100644 --- a/fai_gestion/composer.json +++ b/fai_gestion/composer.json @@ -13,7 +13,7 @@ "mobiledetect/mobiledetectlib": "2.*" }, "require-dev": { - "cakephp/bake": "^1.1", + "cakephp/bake": "~1.0", "cakephp/cakephp-codesniffer": "^3.0", "cakephp/debug_kit": "^3.15.0", "psy/psysh": "@stable" @@ -25,13 +25,15 @@ }, "autoload": { "psr-4": { - "App\\": "src/" + "App\\": "src/", + "CustomTheme\\": "./plugins/CustomTheme/src/" } }, "autoload-dev": { "psr-4": { "App\\Test\\": "tests/", - "Cake\\Test\\": "vendor/cakephp/cakephp/tests/" + "Cake\\Test\\": "vendor/cakephp/cakephp/tests/", + "CustomTheme\\Test\\": "./plugins/CustomTheme/tests/" } }, "scripts": { diff --git a/fai_gestion/composer.lock b/fai_gestion/composer.lock index 21c6029..b1a1098 100644 --- a/fai_gestion/composer.lock +++ b/fai_gestion/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "226c85de8ca341def4f0f5329bb17fb3", + "content-hash": "bdfe56ce06a95062ff683ed4dad28676", "packages": [ { "name": "aura/intl", diff --git a/fai_gestion/config/bootstrap_cli.php b/fai_gestion/config/bootstrap_cli.php index 287683a..43b569a 100644 --- a/fai_gestion/config/bootstrap_cli.php +++ b/fai_gestion/config/bootstrap_cli.php @@ -28,3 +28,5 @@ use Cake\Core\Plugin; // Set logs to different files so they don't have permission conflicts. Configure::write('Log.debug.file', 'cli-debug'); Configure::write('Log.error.file', 'cli-error'); + +Plugin::load('CustomTheme', ['bootstrap' => false, 'routes' => true]); diff --git a/fai_gestion/plugins/CustomTheme/.gitignore b/fai_gestion/plugins/CustomTheme/.gitignore new file mode 100644 index 0000000..bc959c5 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/.gitignore @@ -0,0 +1,3 @@ +/composer.lock +/phpunit.xml +/vendor diff --git a/fai_gestion/plugins/CustomTheme/README.md b/fai_gestion/plugins/CustomTheme/README.md new file mode 100644 index 0000000..4ccb8e2 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/README.md @@ -0,0 +1,11 @@ +# CustomTheme plugin for CakePHP + +## Installation + +You can install this plugin into your CakePHP application using [composer](http://getcomposer.org). + +The recommended way to install composer packages is: + +``` +composer require your-name-here/CustomTheme +``` diff --git a/fai_gestion/plugins/CustomTheme/composer.json b/fai_gestion/plugins/CustomTheme/composer.json new file mode 100644 index 0000000..ddbb4a3 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/composer.json @@ -0,0 +1,23 @@ +{ + "name": "your-name-here/CustomTheme", + "description": "CustomTheme plugin for CakePHP", + "type": "cakephp-plugin", + "license": "MIT", + "require": { + "cakephp/cakephp": "^3.5" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.14|^6.0" + }, + "autoload": { + "psr-4": { + "CustomTheme\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "CustomTheme\\Test\\": "tests/", + "Cake\\Test\\": "vendor/cakephp/cakephp/tests/" + } + } +} diff --git a/fai_gestion/plugins/CustomTheme/config/routes.php b/fai_gestion/plugins/CustomTheme/config/routes.php new file mode 100644 index 0000000..62cbd6c --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/config/routes.php @@ -0,0 +1,12 @@ + '/custom-theme'], + function (RouteBuilder $routes) { + $routes->fallbacks(DashedRoute::class); + } +); diff --git a/fai_gestion/plugins/CustomTheme/phpunit.xml.dist b/fai_gestion/plugins/CustomTheme/phpunit.xml.dist new file mode 100644 index 0000000..399f43d --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/phpunit.xml.dist @@ -0,0 +1,36 @@ + + + + + + + + + + + tests/TestCase/ + + + + + + + + + + + + + + + src/ + + + + diff --git a/fai_gestion/plugins/CustomTheme/src/Controller/AppController.php b/fai_gestion/plugins/CustomTheme/src/Controller/AppController.php new file mode 100644 index 0000000..80729f4 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Controller/AppController.php @@ -0,0 +1,10 @@ +{{ currentModelName }}->newEntity(); + if ($this->request->is('post')) { + ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $this->request->getData()); + if ($this->{{ currentModelName }}->save(${{ singularName }})) { + $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); + + return $this->redirect(['action' => 'index']); + } + $this->Flash->error(__('The {{ singularHumanName|lower }} could not be saved. Please, try again.')); + } +{% set associations = Bake.aliasExtractor(modelObj, 'BelongsTo') %} +{% set associations = associations|merge(Bake.aliasExtractor(modelObj, 'BelongsToMany')) %} + +{%- for assoc in associations %} + {%- set otherName = Bake.getAssociatedTableAlias(modelObj, assoc) %} + {%- set otherPlural = otherName|variable %} + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', ['limit' => 200]); + {{- "\n" }} + {%- set compact = compact|merge(["'#{otherPlural}'"]) %} +{% endfor %} + $this->set(compact({{ compact|join(', ')|raw }})); + } diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig new file mode 100644 index 0000000..d06cb9c --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig @@ -0,0 +1,49 @@ +{# +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} +{% set belongsTo = Bake.aliasExtractor(modelObj, 'BelongsTo') %} +{% set belongsToMany = Bake.aliasExtractor(modelObj, 'belongsToMany') %} +{% set compact = ["'#{singularName}'"] %} + + /** + * Edit method + * + * @param string|null $id {{ singularHumanName }} id. + * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise. + * @throws \Cake\Network\Exception\NotFoundException When record not found. + */ + public function edit($id = null) + { + ${{ singularName }} = $this->{{ currentModelName }}->get($id, [ + 'contain' => [{{ Bake.stringifyList(belongsToMany, {'indent': false})|raw }}] + ]); + if ($this->request->is(['patch', 'post', 'put'])) { + ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $this->request->getData()); + if ($this->{{ currentModelName }}->save(${{ singularName }})) { + $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); + + return $this->redirect(['action' => 'index']); + } + $this->Flash->error(__('The {{ singularHumanName|lower }} could not be saved. Please, try again.')); + } +{% for assoc in belongsTo|merge(belongsToMany) %} + {%- set otherName = Bake.getAssociatedTableAlias(modelObj, assoc) %} + {%- set otherPlural = otherName|variable %} + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', ['limit' => 200]); + {{- "\n" }} + {%- set compact = compact|merge(["'#{otherPlural}'"]) %} +{% endfor %} + $this->set(compact({{ compact|join(', ')|raw }})); + } diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig new file mode 100644 index 0000000..181e830 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig @@ -0,0 +1,33 @@ +{# +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} + + /** + * Index method + * + * @return \Cake\Http\Response|void + */ + public function index() + { +{% set belongsTo = Bake.aliasExtractor(modelObj, 'BelongsTo') %} +{% if belongsTo %} + $this->paginate = [ + 'contain' => [{{ Bake.stringifyList(belongsTo, {'indent': false})|raw }}] + ]; +{% endif %} + ${{ pluralName }} = $this->paginate($this->{{ currentModelName }}); + + $this->set(compact('{{ pluralName }}')); + } diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig new file mode 100644 index 0000000..b2d9e50 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig @@ -0,0 +1,80 @@ +{# +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} +{% set fields = Bake.filterFields(fields, schema, modelObject) %} + +
+ Form->create(${{ singularVar }}) ?> +
+ + Form->control('{{ field }}', ['options' => ${{ keyFields[field] }}, 'empty' => true]); + {{- "\n" }} + {%- else %} + echo $this->Form->control('{{ field }}', ['options' => ${{ keyFields[field] }}]); + {{- "\n" }} + {%- endif %} + {%- elseif field not in ['created', 'modified', 'updated'] %} + {%- set fieldData = Bake.columnData(field, schema) %} + {%- if fieldData.type in ['date', 'datetime', 'time'] and fieldData.null %} + echo $this->Form->control('{{ field }}', ['empty' => true]); + {{- "\n" }} + {%- else %} + echo $this->Form->control('{{ field }}'); + {{- "\n" }} + {%- endif %} + {%- endif %} +{%- endfor %} + +{%- if associations.BelongsToMany %} + {%- for assocName, assocData in associations.BelongsToMany %} + echo $this->Form->control('{{ assocData.property }}._ids', ['options' => ${{ assocData.variable }}]); + {{- "\n" }} + {%- endfor %} +{% endif %} + ?> +
+ Form->button(__('Submit')) ?> + Form->end() ?> +
diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/entity.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/entity.twig new file mode 100644 index 0000000..e09794a --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/entity.twig @@ -0,0 +1,61 @@ +{# +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} +{% set propertyHintMap = DocBlock.buildEntityPropertyHintTypeMap(propertySchema ?: []) %} +{% set associationHintMap = DocBlock.buildEntityAssociationHintTypeMap(propertySchema ?: []) %} +{% set annotations = DocBlock.propertyHints(propertyHintMap) %} + +{%- if associationHintMap %} + {%- set annotations = annotations|merge(['']) %} + {%- set annotations = annotations|merge(DocBlock.propertyHints(associationHintMap)) %} +{% endif %} + +{%- set accessible = Bake.getFieldAccessibility(fields, primaryKey) %} +setTable('{{ table }}'); +{% endif %} + +{%- if displayField %} + $this->setDisplayField('{{ displayField }}'); +{% endif %} + +{%- if primaryKey %} + {%- if primaryKey is iterable and primaryKey|length > 1 %} + $this->setPrimaryKey([{{ Bake.stringifyList(primaryKey, {'indent': false})|raw }}]); + {{- "\n" }} + {%- else %} + $this->setPrimaryKey('{{ primaryKey|as_array|first }}'); + {{- "\n" }} + {%- endif %} +{% endif %} + +{%- if behaviors %} + +{% endif %} + +{%- for behavior, behaviorData in behaviors %} + $this->addBehavior('{{ behavior }}'{{ (behaviorData ? (", [" ~ Bake.stringifyList(behaviorData, {'indent': 3, 'quotes': false})|raw ~ ']') : '')|raw }}); +{% endfor %} + +{%- if associations.belongsTo or associations.hasMany or associations.belongsToMany %} + +{% endif %} + +{%- for type, assocs in associations %} + {%- for assoc in assocs %} + {%- set assocData = [] %} + {%- for key, val in assoc if key is not same as('alias') %} + {%- set assocData = assocData|merge({(key): val}) %} + {%- endfor %} + $this->{{ type }}('{{ assoc.alias }}', [{{ Bake.stringifyList(assocData, {'indent': 3})|raw }}]); + {{- "\n" }} + {%- endfor %} +{% endfor %} + } +{{- "\n" }} + +{%- if validation %} + + /** + * Default validation rules. + * + * @param \Cake\Validation\Validator $validator Validator instance. + * @return \Cake\Validation\Validator + */ + public function validationDefault(Validator $validator) + { +{% for field, rules in validation %} +{% set validationMethods = Bake.getValidationMethods(field, rules) %} +{% if validationMethods %} + $validator +{% for validationMethod in validationMethods %} +{% if loop.last %} +{% set validationMethod = validationMethod ~ ';' %} +{% endif %} + {{ validationMethod|raw }} +{% endfor %} + +{% endif %} +{% endfor %} + return $validator; + } +{% endif %} + +{%- if rulesChecker %} + + /** + * Returns a rules checker object that will be used for validating + * application integrity. + * + * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. + * @return \Cake\ORM\RulesChecker + */ + public function buildRules(RulesChecker $rules) + { +{% for field, rule in rulesChecker %} + $rules->add($rules->{{ rule.name }}(['{{ field }}']{{ (rule.extra is defined and rule.extra ? (", '#{rule.extra}'") : '')|raw }})); +{% endfor %} + + return $rules; + } +{% endif %} + +{%- if connection is not same as('default') %} + + /** + * Returns the database connection name to use by default. + * + * @return string + */ + public static function defaultConnectionName() + { + return '{{ connection }}'; + } +{% endif %} +} diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig new file mode 100644 index 0000000..79050ef --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig @@ -0,0 +1,90 @@ +{# +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} + +{% set fields = Bake.filterFields(fields, schema, modelObject, indexColumns, ['binary', 'text']) %} + +
+

+ + + +{% for field in fields %} + +{% endfor %} + + + + + + +{% for field in fields %} +{% set isKey = false %} +{% if associations.BelongsTo %} +{% for alias, details in associations.BelongsTo if field == details.foreignKey %} +{% set isKey = true %} + +{% endfor %} +{% endif %} +{% if isKey is not same as(true) %} +{% set columnData = Bake.columnData(field, schema) %} +{% if columnData.type not in ['integer', 'float', 'decimal', 'biginteger', 'smallinteger', 'tinyinteger'] %} + +{% else %} + +{% endif %} +{% endif %} +{% endfor %} +{% set pk = '$' ~ singularVar ~ '->' ~ primaryKey[0] %} + + + + +
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 }}) ?> + Html->link(__('View'), ['action' => 'view', {{ pk|raw }}]) ?> + Html->link(__('Edit'), ['action' => 'edit', {{ pk|raw }}]) ?> + Form->postLink(__('Delete'), ['action' => 'delete', {{ pk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }})]) ?> +
+
+
    + Paginator->first('<< ' . __('first')) ?> + Paginator->prev('< ' . __('previous')) ?> + Paginator->numbers() ?> + Paginator->next(__('next') . ' >') ?> + Paginator->last(__('last') . ' >>') ?> +
+

Paginator->counter(['format' => __('Page {{ '{{' }}page{{ '}}' }} of {{ '{{' }}pages{{ '}}' }}, showing {{ '{{' }}current{{ '}}' }} record(s) out of {{ '{{' }}count{{ '}}' }} total')]) ?>

+
+
diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig new file mode 100644 index 0000000..200a2f8 --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig @@ -0,0 +1,137 @@ +{# +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} + +{% set associations = {'BelongsTo': [], 'HasOne': [], 'HasMany': [], 'BelongsToMany': []}|merge(associations) %} +{% set fieldsData = Bake.getViewFieldsData(fields, schema, associations) %} +{% set associationFields = fieldsData.associationFields %} +{% set groupedFields = fieldsData.groupedFields %} +{% set pK = '$' ~ singularVar ~ '->' ~ primaryKey[0] %} + +
+

{{ displayField }}) ?>

+ +{% if groupedFields['string'] %} +{% for field in groupedFields['string'] %} +{% if associationFields[field] %} +{% set details = associationFields[field] %} + + + + +{% else %} + + + + +{% endif %} +{% endfor %} +{% endif %} +{% if associations.HasOne %} +{% for alias, details in associations.HasOne %} + + + + +{% endfor %} +{% endif %} +{% if groupedFields.number %} +{% for field in groupedFields.number %} + + + + +{% endfor %} +{% endif %} +{% if groupedFields.date %} +{% for field in groupedFields.date %} + + + + +{% endfor %} +{% endif %} +{% if groupedFields.boolean %} +{% for field in groupedFields.boolean %} + + + + +{% endfor %} +{% endif %} +
has('{{ details.property }}') ? $this->Html->link(${{ singularVar }}->{{ details.property }}->{{ details.displayField }}, ['controller' => '{{ details.controller }}', 'action' => 'view', ${{ singularVar }}->{{ details.property }}->{{ details.primaryKey[0] }}]) : '' ?>
{{ field }}) ?>
has('{{ details.property }}') ? $this->Html->link(${{ singularVar }}->{{ details.property }}->{{ details.displayField }}, ['controller' => '{{ details.controller }}', 'action' => 'view', ${{ singularVar }}->{{ details.property }}->{{ details.primaryKey[0] }}]) : '' ?>
Number->format(${{ singularVar }}->{{ field }}) ?>
{{ field }}) ?>
{{ field }} ? __('Yes') : __('No'); ?>
+{% if groupedFields.text %} +{% for field in groupedFields.text %} +
+

+ Text->autoParagraph(h(${{ singularVar }}->{{ field }})); ?> +
+{% endfor %} +{% endif %} +{% set relations = associations.BelongsToMany|merge(associations.HasMany) %} +{% for alias, details in relations %} +{% set otherSingularVar = alias|variable %} +{% set otherPluralHumanName = details.controller|underscore|humanize %} + +{% endfor %} +
diff --git a/fai_gestion/plugins/CustomTheme/tests/bootstrap.php b/fai_gestion/plugins/CustomTheme/tests/bootstrap.php new file mode 100644 index 0000000..644321d --- /dev/null +++ b/fai_gestion/plugins/CustomTheme/tests/bootstrap.php @@ -0,0 +1,30 @@ +