diff options
Diffstat (limited to 'generator/before-bake')
20 files changed, 2036 insertions, 0 deletions
diff --git a/generator/before-bake/config/app.php b/generator/before-bake/config/app.php new file mode 100644 index 0000000..f8d0e1d --- /dev/null +++ b/generator/before-bake/config/app.php @@ -0,0 +1,321 @@ +<?php +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +return [ + /** + * Debug Level: + * + * Production Mode: + * false: No error messages, errors, or warnings shown. + * + * Development Mode: + * true: Errors and warnings shown. + */ + 'debug' => false, + + /** + * Configure basic information about the application. + * + * - namespace - The namespace to find app classes under. + * - encoding - The encoding used for HTML + database connections. + * - base - The base directory the app resides in. If false this + * will be auto detected. + * - dir - Name of app directory. + * - webroot - The webroot directory. + * - wwwRoot - The file path to webroot. + * - baseUrl - To configure CakePHP to *not* use mod_rewrite and to + * use CakePHP pretty URLs, remove these .htaccess + * files: + * /.htaccess + * /webroot/.htaccess + * And uncomment the baseUrl key below. + * - fullBaseUrl - A base URL to use for absolute links. + * - imageBaseUrl - Web path to the public images directory under webroot. + * - cssBaseUrl - Web path to the public css directory under webroot. + * - jsBaseUrl - Web path to the public js directory under webroot. + * - paths - Configure paths for non class based resources. Supports the + * `plugins`, `templates`, `locales` subkeys, which allow the definition of + * paths for plugins, view templates and locale files respectively. + */ + 'App' => [ + 'namespace' => 'App', + 'encoding' => 'UTF-8', + 'base' => false, + 'dir' => 'src', + 'webroot' => 'webroot', + 'wwwRoot' => WWW_ROOT, + // 'baseUrl' => env('SCRIPT_NAME'), + 'fullBaseUrl' => false, + 'imageBaseUrl' => 'img/', + 'cssBaseUrl' => 'css/', + 'jsBaseUrl' => 'js/', + 'paths' => [ + 'plugins' => [ROOT . DS . 'plugins' . DS], + 'templates' => [APP . 'Template' . DS], + 'locales' => [APP . 'Locale' . DS], + ], + ], + + /** + * Security and encryption configuration + * + * - salt - A random string used in security hashing methods. + * The salt value is also used as the encryption key. + * You should treat it as extremely sensitive data. + */ + 'Security' => [ + 'salt' => 'eb74ed8697b7bc31587f48bec13cdcc0460debf26cec73137e4c6d390a93de4d', + ], + + /** + * Apply timestamps with the last modified time to static assets (js, css, images). + * Will append a querystring parameter containing the time the file was modified. + * This is useful for busting browser caches. + * + * Set to true to apply timestamps when debug is true. Set to 'force' to always + * enable timestamping regardless of debug value. + */ + 'Asset' => [ + // 'timestamp' => true, + ], + + /** + * Configure the cache adapters. + */ + 'Cache' => [ + 'default' => [ + 'className' => 'File', + 'path' => CACHE, + ], + + /** + * Configure the cache used for general framework caching. + * Translation cache files are stored with this configuration. + */ + '_cake_core_' => [ + 'className' => 'File', + 'prefix' => 'myapp_cake_core_', + 'path' => CACHE . 'persistent/', + 'serialize' => true, + 'duration' => '+2 minutes', + ], + + /** + * Configure the cache for model and datasource caches. This cache + * configuration is used to store schema descriptions, and table listings + * in connections. + */ + '_cake_model_' => [ + 'className' => 'File', + 'prefix' => 'myapp_cake_model_', + 'path' => CACHE . 'models/', + 'serialize' => true, + 'duration' => '+2 minutes', + ], + ], + + /** + * Configure the Error and Exception handlers used by your application. + * + * By default errors are displayed using Debugger, when debug is true and logged + * by Cake\Log\Log when debug is false. + * + * In CLI environments exceptions will be printed to stderr with a backtrace. + * In web environments an HTML page will be displayed for the exception. + * With debug true, framework errors like Missing Controller will be displayed. + * When debug is false, framework errors will be coerced into generic HTTP errors. + * + * Options: + * + * - `errorLevel` - int - The level of errors you are interested in capturing. + * - `trace` - boolean - Whether or not backtraces should be included in + * logged errors/exceptions. + * - `log` - boolean - Whether or not you want exceptions logged. + * - `exceptionRenderer` - string - The class responsible for rendering + * uncaught exceptions. If you choose a custom class you should place + * the file for that class in src/Error. This class needs to implement a + * render method. + * - `skipLog` - array - List of exceptions to skip for logging. Exceptions that + * extend one of the listed exceptions will also be skipped for logging. + * E.g.: + * `'skipLog' => ['Cake\Network\Exception\NotFoundException', 'Cake\Network\Exception\UnauthorizedException']` + */ + 'Error' => [ + 'errorLevel' => E_ALL & ~E_DEPRECATED, + 'exceptionRenderer' => 'Cake\Error\ExceptionRenderer', + 'skipLog' => [], + 'log' => true, + 'trace' => true, + ], + + /** + * Email configuration. + * + * By defining transports separately from delivery profiles you can easily + * re-use transport configuration across multiple profiles. + * + * You can specify multiple configurations for production, development and + * testing. + * + * Each transport needs a `className`. Valid options are as follows: + * + * Mail - Send using PHP mail function + * Smtp - Send using SMTP + * Debug - Do not send the email, just return the result + * + * You can add custom transports (or override existing transports) by adding the + * appropriate file to src/Mailer/Transport. Transports should be named + * 'YourTransport.php', where 'Your' is the name of the transport. + */ + 'EmailTransport' => [ + 'default' => [ + 'className' => 'Mail', + // The following keys are used in SMTP transports + 'host' => 'localhost', + 'port' => 25, + 'timeout' => 30, + 'username' => 'user', + 'password' => 'secret', + 'client' => null, + 'tls' => null, + ], + ], + + /** + * Email delivery profiles + * + * Delivery profiles allow you to predefine various properties about email + * messages from your application and give the settings a name. This saves + * duplication across your application and makes maintenance and development + * easier. Each profile accepts a number of keys. See `Cake\Network\Email\Email` + * for more information. + */ + 'Email' => [ + 'default' => [ + 'transport' => 'default', + 'from' => 'you@localhost', + //'charset' => 'utf-8', + //'headerCharset' => 'utf-8', + ], + ], + + /** + * Connection information used by the ORM to connect + * to your application's datastores. + * Drivers include Mysql Postgres Sqlite Sqlserver + * See vendor\cakephp\cakephp\src\Database\Driver for complete list + */ + 'Datasources' => [ + 'default' => [ + 'className' => 'Cake\Database\Connection', + 'driver' => 'Cake\Database\Driver\Mysql', + 'persistent' => false, + 'host' => 'localhost', + 'username' => 'gestion', + 'password' => 'cha6fus0EiPh', + 'database' => 'gestion', + 'encoding' => 'utf8', + 'timezone' => 'UTC', + 'cacheMetadata' => true, + 'log' => false, + 'quoteIdentifiers' => false, + //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'], + ], + + /** + * The test connection is used during the test suite. + */ + 'test' => [ + 'className' => 'Cake\Database\Connection', + 'driver' => 'Cake\Database\Driver\Mysql', + 'persistent' => false, + 'host' => 'localhost', + 'username' => 'gestion_test', + 'password' => 'cha6fus0EiPh', + 'database' => 'gestion_test', + 'encoding' => 'utf8', + 'timezone' => 'UTC', + 'cacheMetadata' => true, + 'log' => false, + 'quoteIdentifiers' => false, + //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'], + ], + ], + + /** + * Configures logging options + */ + 'Log' => [ + 'debug' => [ + 'className' => 'Cake\Log\Engine\FileLog', + 'path' => LOGS, + 'file' => 'debug', + 'levels' => ['notice', 'info', 'debug'], + ], + 'error' => [ + 'className' => 'Cake\Log\Engine\FileLog', + 'path' => LOGS, + 'file' => 'error', + 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], + ], + ], + + /** + * Session configuration. + * + * Contains an array of settings to use for session configuration. The + * `defaults` key is used to define a default preset to use for sessions, any + * settings declared here will override the settings of the default config. + * + * ## Options + * + * - `cookie` - The name of the cookie to use. Defaults to 'CAKEPHP'. + * - `cookiePath` - The url path for which session cookie is set. Maps to the + * `session.cookie_path` php.ini config. Defaults to base path of app. + * - `timeout` - The time in minutes the session should be valid for. + * Pass 0 to disable checking timeout. + * Please note that php.ini's session.gc_maxlifetime must be equal to or greater + * than the largest Session['timeout'] in all served websites for it to have the + * desired effect. + * - `defaults` - The default configuration set to use as a basis for your session. + * There are four built-in options: php, cake, cache, database. + * - `handler` - Can be used to enable a custom session handler. Expects an + * array with at least the `engine` key, being the name of the Session engine + * class to use for managing the session. CakePHP bundles the `CacheSession` + * and `DatabaseSession` engines. + * - `ini` - An associative array of additional ini values to set. + * + * The built-in `defaults` options are: + * + * - 'php' - Uses settings defined in your php.ini. + * - 'cake' - Saves session files in CakePHP's /tmp directory. + * - 'database' - Uses CakePHP's database sessions. + * - 'cache' - Use the Cache class to save sessions. + * + * To define a custom session handler, save it at src/Network/Session/<name>.php. + * Make sure the class implements PHP's `SessionHandlerInterface` and set + * Session.handler to <name> + * + * To use database sessions, load the SQL file located at config/Schema/sessions.sql + */ + 'Session' => [ + 'defaults' => 'php', + ], +]; diff --git a/generator/before-bake/config/bake_extra.php b/generator/before-bake/config/bake_extra.php new file mode 100644 index 0000000..3ff3352 --- /dev/null +++ b/generator/before-bake/config/bake_extra.php @@ -0,0 +1,162 @@ +<?php +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +return [ + 'default' => [ 'actions' => [ 'index', 'view', 'add', 'edit'] ], + 'AdherentRoles' => [ 'actions' => [ 'index', 'add', 'delete' ] ], + 'AdherentRoleTypes' => [ 'actions' => [ '_empty' ] ], + 'AdherentStatuts' => [ 'actions' => [ '_empty' ] ], + 'AdherentTypes' => [ 'actions' => [ '_empty' ] ], + 'Civilites' => [ 'actions' => [ '_empty' ] ], + 'Periodicites' => [ 'actions' => [ '_empty' ] ], + 'Secteurs' => [ 'actions' => [ '_empty' ] ], + 'ServiceStatuts' => [ 'actions' => [ '_empty' ] ], + 'ServiceTypes' => [ 'actions' => [ '_empty' ] ], + 'EquipementModes' => [ 'actions' => [ '_empty' ] ], + 'EquipementModeles' => [ + 'title' => [ + 'glue' => ' ', + 'pieces' => ['constructeur', 'modele'], + ], + ], + 'Adherents' => [ + 'title' => [ + 'custom_code' => <<<'EOT' +"CHD" . $this->_properties['id'] . " - " . ( $this->_properties['raison']?($this->_properties['raison'] . " (" . $this->_properties['nom'] . ")" ):($this->_properties['nom'] . " " . $this->_properties['prenom']) ) +EOT + ], + 'filters' => [ + 'q' => [ + 'mode' => 'like', + 'before' => 'true', + 'after' => 'true', + 'columns' => ['id','nom','nom2','prenom','prenom2','raison','proprio','tel_mobile1','tel_mobile2'], + 'colspan' => 5, + 'hint' => 'Rechercher...', + ], + 'ville_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'Villes', + 'colspan' => 2, + 'hint' => 'Villes', + ], + ], + ], + 'Equipements' => [ + 'title' => [ + 'glue' => ' ', + 'pieces' => ['mac'], + ], + 'filters' => [ + 'q' => [ + 'mode' => 'like', + 'before' => 'true', + 'after' => 'true', + //'columns' => ['id', 'ipmgmt.ip4','ipmgmt.ip6', 'mac'], + 'columns' => ['mac'], + 'colspan' => 3, + 'hint' => 'Adresse MAC...', + ], + 'equipement_modele_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'EquipementModeles', + 'colspan' => 2, + 'hint' => 'Equipement Modeles', + ], + 'relais_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'Relais', + 'colspan' => 2, + 'hint' => 'Relais', + ], + ], + ], + 'Services' => [ + 'title' => [ + 'glue' => '-', + 'prefix' => 'SER', + 'pieces' => ['service_type_id', 'adherent_id', 'id'], + ], + 'filters' => [ + 'service_type_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'ServiceTypes', + 'colspan' => 3, + 'hint' => 'Service Type', + ], + 'service_statut_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'ServiceStatuts', + 'colspan' => 2, + 'hint' => 'Service Statut', + ], + 'relais_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'Relais', + 'colspan' => 2, + 'hint' => 'Relais', + ], + ], + ], + 'Ipmgmt' => [ + 'actions' => [ 'index', 'view' ], + 'title' => [ + 'glue' => ' ', + 'pieces' => ['ip4', 'ip6'], + ], + ], + 'Ippubliques' => [ + 'actions' => [ 'index', 'view' ], + 'title' => [ + 'glue' => ' ', + 'pieces' => ['ip4', 'ip6'], + ], + 'filters' => [ + 'q' => [ + 'mode' => 'like', + 'before' => 'true', + 'after' => 'false', + 'columns' => ['ip4','ip6'], + 'colspan' => 2, + 'hint' => 'Rechercher...', + ], + 'secteur_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'Secteurs', + 'colspan' => 1, + 'hint' => 'Secteurs', + ], + ], + ], +]; diff --git a/generator/before-bake/config/bootstrap_cli.php b/generator/before-bake/config/bootstrap_cli.php new file mode 100644 index 0000000..b27c7e5 --- /dev/null +++ b/generator/before-bake/config/bootstrap_cli.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 3.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +use Cake\Core\Configure; +use Cake\Core\Exception\MissingPluginException; +use Cake\Core\Plugin; +use Cake\Event\Event; +use Cake\Event\EventManager; +use Cake\Utility\Hash; + +/** + * Additional bootstrapping and configuration for CLI environments should + * be put here. + */ + +// 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'); + +try { + Plugin::load('Bake'); +} catch (MissingPluginException $e) { + // Do not halt if the plugin is missing +} + +EventManager::instance()->on('Bake.initialize', function (Event $event) { + // Initialize BakeExtraHelper with bake_extra.php config array + $view = $event->subject; + $extra = include(ROOT . DS . 'config' . DS . 'bake_extra.php'); + $view->loadHelper('CustomTheme.BakeExtra', $extra); +}); + +EventManager::instance()->on('Bake.beforeRender', function (Event $event) { + $view = $event->subject; + $isController = strpos($event->data[0], 'Bake/Controller/controller.ctp') !== false; + if ($isController) { + // Override controller's default action list with the configured one in bake_extra.php + $view->set('actions', $view->BakeExtra->getActions($view->get('name'))); + } +}); diff --git a/generator/before-bake/maj_default_pot.sh b/generator/before-bake/maj_default_pot.sh new file mode 100755 index 0000000..e87997e --- /dev/null +++ b/generator/before-bake/maj_default_pot.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> +# Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> +# +# This file is part of CHD Gestion. +# +# CHD Gestion is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CHD Gestion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +# +cd $(dirname $0) +bin/cake i18n extract --paths="./src" --output="./src/Locale" --merge=yes --extract-core=yes --exclude="Test,Vendor" --overwrite +ls -l ./src/Locale/default.pot diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Controller/controller.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Controller/controller.ctp new file mode 100644 index 0000000..76407ce --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Controller/controller.ctp @@ -0,0 +1,78 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * Controller bake template file + * + * Allows templating of Controllers generated from bake. + * + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +use Cake\Utility\Inflector; + +$defaultModel = $name; +%> +<?php +namespace <%= $namespace %>\Controller<%= $prefix %>; + +use <%= $namespace %>\Controller\AppController; + +/** + * <%= $name %> Controller + * + * @property \<%= $namespace %>\Model\Table\<%= $defaultModel %>Table $<%= $defaultModel %> +<% +foreach ($components as $component): + $classInfo = $this->Bake->classInfo($component, 'Controller/Component', 'Component'); +%> + * @property <%= $classInfo['fqn'] %> $<%= $classInfo['name'] %> +<% endforeach; %> + */ +class <%= $name %>Controller extends AppController +{ +<% if ($this->BakeExtra->hasFilters($currentModelName) ): %> + + public function initialize() + { + parent::initialize(); + if ($this->request->action === 'index') { + $this->loadComponent('Paginator', [ 'limit' => 15, 'order' => [ '<%=$currentModelName%>.id' => 'DESC' ] ]); + $this->loadComponent('Search.Prg'); + } + } +<% endif; %> +<% +echo $this->Bake->arrayProperty('helpers', $helpers, ['indent' => false]); +echo $this->Bake->arrayProperty('components', $components, ['indent' => false]); +foreach($actions as $action) { + echo $this->element('Controller/' . $action); +} +%> +} diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.ctp new file mode 100644 index 0000000..02d5dfb --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.ctp @@ -0,0 +1,45 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +%> + + /** + * _empty method + * Generated when no other actions requested + * Prevents bake all to make all $scaffoldActions when unwanted + * + * @return void + */ + public function _empty() + { + } diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.ctp new file mode 100644 index 0000000..be3860b --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.ctp @@ -0,0 +1,71 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +$compact = ["'" . $singularName . "'"]; +%> + + /** + * Add method + * + * @return void Redirects on successful add, renders view otherwise. + */ + public function add() + { + $<%= $singularName %> = $this-><%= $currentModelName %>->newEntity(); + if ($this->request->is('post')) { + $<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->data); + if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) { + $this->Flash->success(__('The <%= strtolower($singularHumanName) %> has been saved.')); + return $this->redirect(['action' => 'index']); + } else { + $this->Flash->error(__('The <%= strtolower($singularHumanName) %> could not be saved. Please, try again.')); + } + } +<% + $associations = array_merge( + $this->Bake->aliasExtractor($modelObj, 'BelongsTo'), + $this->Bake->aliasExtractor($modelObj, 'BelongsToMany') + ); + foreach ($associations as $assoc): + $association = $modelObj->association($assoc); + $otherName = $association->target()->alias(); + $otherPlural = $this->_variableName($otherName); +%> + $<%= $otherPlural %> = $this-><%= $currentModelName %>-><%= $otherName %>->find('list'); +<% + $compact[] = "'$otherPlural'"; + endforeach; +%> + $this->set(compact(<%= join(', ', $compact) %>)); + $this->set('_serialize', ['<%=$singularName%>']); + } diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.ctp new file mode 100644 index 0000000..b1b62f2 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.ctp @@ -0,0 +1,74 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +$belongsTo = $this->Bake->aliasExtractor($modelObj, 'BelongsTo'); +$belongsToMany = $this->Bake->aliasExtractor($modelObj, 'BelongsToMany'); +$compact = ["'" . $singularName . "'"]; +%> + + /** + * Edit method + * + * @param string|null $id <%= $singularHumanName %> id. + * @return void 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' => [<%= $this->Bake->stringifyList($belongsToMany, ['indent' => false]) %>] + ]); + if ($this->request->is(['patch', 'post', 'put'])) { + $<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->data); + if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) { + $this->Flash->success(__('The <%= strtolower($singularHumanName) %> has been saved.')); + return $this->redirect(['action' => 'index']); + } else { + $this->Flash->error(__('The <%= strtolower($singularHumanName) %> could not be saved. Please, try again.')); + } + } +<% + foreach (array_merge($belongsTo, $belongsToMany) as $assoc): + $association = $modelObj->association($assoc); + $otherName = $association->target()->alias(); + $otherPlural = $this->_variableName($otherName); +%> + $<%= $otherPlural %> = $this-><%= $currentModelName %>-><%= $otherName %>->find('list'); +<% + $compact[] = "'$otherPlural'"; + endforeach; +%> + $this->set(compact(<%= join(', ', $compact) %>)); + $this->set('_serialize', ['<%=$singularName%>']); + } diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.ctp new file mode 100644 index 0000000..1fa2e18 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.ctp @@ -0,0 +1,69 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +use Cake\Utility\Hash; +use Cake\Utility\Inflector; +%> + + /** + * Index method + * + * @return void + */ + public function index() + { +<% $belongsTo = $this->Bake->aliasExtractor($modelObj, 'BelongsTo'); %> +<% if ($belongsTo): %> + $this->paginate = [ + 'contain' => [<%= $this->Bake->stringifyList($belongsTo, ['indent' => false]) %>] + ]; +<% endif; %> +<% if (! $this->BakeExtra->hasFilters($currentModelName)): %> + $this->set('<%= $pluralName %>', $this->paginate($this-><%= $currentModelName %>)); +<% else: %> + $query = $this-><%= $currentModelName %> + ->find('search', $this-><%= $currentModelName %>->filterParams($this->request->query)); + $this->set('<%= $pluralName %>', $this->paginate($query)); + $this->set('_serialize', ['<%= $pluralName %>']); + +<% + $extraModels = Hash::extract($this->BakeExtra->getFilters($currentModelName), "{s}.model"); + foreach ( $extraModels as $m ): + $v = Inflector::variable($m); +%> + $this->loadModel('<%= $m %>'); + $this->set('<%= $v %>', $this-><%= $m %>->find('list')->toArray()); +<% endforeach; + endif; %> + } diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/form.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/form.ctp new file mode 100644 index 0000000..2273d86 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Element/form.ctp @@ -0,0 +1,126 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +use Cake\Utility\Inflector; + +$fields = collection($fields) + ->filter(function($field) use ($schema) { + return $schema->columnType($field) !== 'binary'; + }); +%> +<nav class="large-2 medium-3 columns" id="actions-sidebar"> + <ul class="side-nav"> + <li class="heading"><?= __('Actions') ?></li> +<% if (strpos($action, 'add') === false && $this->BakeExtra->hasAction("delete", $modelClass)): %> + <li><?= $this->Form->postLink( + __('Delete'), + ['action' => 'delete', $<%= $singularVar %>-><%= $primaryKey[0] %>], + ['confirm' => __('Are you sure you want to delete # {0}?', $<%= $singularVar %>-><%= $primaryKey[0] %>)] + ) + ?></li> +<% endif; + if ($this->BakeExtra->hasAction("index", $modelClass)): +%> + <li><?= $this->Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?></li> +<% + endif; + $done = []; + foreach ($associations as $type => $data) { + foreach ($data as $alias => $details) { + if ($details['controller'] !== $this->name && !in_array($details['controller'], $done)) { + if ( $this->BakeExtra->hasAction("index", $details['controller']) ): +%> + <li><?= $this->Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) %></li> +<% + endif; + if ( $this->BakeExtra->hasAction("add", $details['controller']) ): +%> + <li><?= $this->Html->link(__('New <%= $this->_singularHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) %></li> +<% + endif; + $done[] = $details['controller']; + } + } + } +%> + </ul> +</nav> +<div class="<%= $pluralVar %> form large-10 medium-9 columns content"> + <?= $this->Form->create($<%= $singularVar %>) ?> + <fieldset> + <legend><?= __('<%= Inflector::humanize($action) %> <%= $singularHumanName %>') ?></legend> + <?php +<% + foreach ($fields as $field) { + if (in_array($field, $primaryKey)) { + continue; + } + if (isset($keyFields[$field])) { + $fieldData = $schema->column($field); + if (!empty($fieldData['null'])) { +%> + echo $this->Form->input('<%= $field %>', ['options' => $<%= $keyFields[$field] %>, 'empty' => true]); +<% + } else { +%> + echo $this->Form->input('<%= $field %>', ['options' => $<%= $keyFields[$field] %>]); +<% + } + continue; + } + if (!in_array($field, ['created', 'modified', 'updated'])) { + $fieldData = $schema->column($field); + if (($fieldData['type'] === 'date') && (!empty($fieldData['null']))) { +%> + echo $this->Form->input('<%= $field %>', ['empty' => true, 'default' => '']); +<% + } else { +%> + 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'] %>]); +<% + } + } +%> + ?> + </fieldset> + <?= $this->Form->button(__('Submit')) ?> + <?= $this->Form->end() ?> +</div> diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Model/entity.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Model/entity.ctp new file mode 100644 index 0000000..5d1cb28 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Model/entity.ctp @@ -0,0 +1,127 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +use Cake\Utility\Inflector; +$title = $this->BakeExtra->getTitleOpts(Inflector::camelize($table)); + +$propertyHintMap = null; +if (!empty($propertySchema)) { + $propertyHintMap = $this->DocBlock->buildEntityPropertyHintTypeMap($propertySchema); +} + +$accessible = []; +if (!isset($fields) || $fields !== false) { + if (!empty($fields)) { + foreach ($fields as $field) { + $accessible[$field] = 'true'; + } + } elseif (!empty($primaryKey)) { + $accessible['*'] = 'true'; + foreach ($primaryKey as $field) { + $accessible[$field] = 'false'; + } + } +} +%> +<?php +namespace <%= $namespace %>\Model\Entity; + +use Cake\ORM\Entity; + +/** + * <%= $name %> Entity. +<% if ($propertyHintMap): %> + * +<% foreach ($propertyHintMap as $property => $type): %> +<% if ($type): %> + * @property <%= $type %> $<%= $property %> +<% else: %> + * @property $<%= $property %> +<% endif; %> +<% endforeach; %> +<% endif; %> + */ +class <%= $name %> extends Entity +{ +<% if (!empty($accessible)): %> + + /** + * Fields that can be mass assigned using newEntity() or patchEntity(). + * + * Note that when '*' is set to true, this allows all unspecified fields to + * be mass assigned. For security purposes, it is advised to set '*' to false + * (or remove it), and explicitly make individual fields accessible as needed. + * + * @var array + */ + protected $_accessible = [ +<% foreach ($accessible as $field => $value): %> + '<%= $field %>' => <%= $value %>, +<% endforeach; %> + ]; +<% endif %> +<% if (!empty($hidden)): %> + + /** + * Fields that are excluded from JSON an array versions of the entity. + * + * @var array + */ + protected $_hidden = [<%= $this->Bake->stringifyList($hidden) %>]; +<% endif %> +<% if (!empty($title)): %> + + /** + * Virtual field for pretty print in related table's views + * + * @return String + */ + protected function _getTitle() + { +<% if (array_key_exists('custom_code', $title)) { + echo "return " . $title['custom_code'] . ";\n"; + } else { + echo "return implode('" . $title['glue'] . "', array_filter([\n"; + if (array_key_exists('prefix', $title)) { + echo "\t\t\t'" . $title['prefix'] . "',\n"; + } + foreach ($title['pieces'] as $piece) { + echo "\t\t\t\$this->_properties['" . $piece . "'],\n"; + } + echo "], 'strlen'));\n"; + } +%> + } +<% endif; %> +} diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Model/table.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Model/table.ctp new file mode 100644 index 0000000..5d21755 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Model/table.ctp @@ -0,0 +1,258 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +use Cake\Utility\Inflector; +%> +<?php +namespace <%= $namespace %>\Model\Table; + +<% +$title = $this->BakeExtra->getTitleOpts($name); + +$uses = [ + "use $namespace\\Model\\Entity\\$entity;", + 'use Cake\ORM\Query;', + 'use Cake\ORM\RulesChecker;', + 'use Cake\ORM\Table;', + 'use Cake\Validation\Validator;' +]; +if ( $this->BakeExtra->hasFilters($name) ) { + $uses[] = 'use Search\Manager;'; + $behaviors['Search.Search'] = []; +} +sort($uses); +echo implode("\n", $uses); +%> + + +/** + * <%= $name %> Model + * +<% if ($associations): %> + * +<% foreach ($associations as $type => $assocs): %> +<% foreach ($assocs as $assoc): %> + * @property \Cake\ORM\Association\<%= Inflector::camelize($type) %> $<%= $assoc['alias'] %> +<% endforeach %> +<% endforeach; %> +<% endif; %> + */ +class <%= $name %>Table extends Table +{ + + /** + * Initialize method + * + * @param array $config The configuration for the Table. + * @return void + */ + public function initialize(array $config) + { + parent::initialize($config); + +<% if (!empty($table)): %> + $this->table('<%= $table %>'); +<% endif %> +<% + if (!empty($displayField) || !empty($title)): + if (!empty($title)): +%> + $this->displayField('title'); +<% else: %> + $this->displayField('<%= $displayField %>'); +<% endif; %> +<% endif; %> +<% if (!empty($primaryKey)): %> +<% if (count($primaryKey) > 1): %> + $this->primaryKey([<%= $this->Bake->stringifyList((array)$primaryKey, ['indent' => false]) %>]); +<% else: %> + $this->primaryKey('<%= current((array)$primaryKey) %>'); +<% endif %> +<% endif %> +<% if (!empty($behaviors)): %> + +<% endif; %> +<% foreach ($behaviors as $behavior => $behaviorData): %> + $this->addBehavior('<%= $behavior %>'<%= $behaviorData ? ", [" . implode(', ', $behaviorData) . ']' : '' %>); +<% endforeach %> +<% if (!empty($associations)): %> + +<% endif; %> +<% foreach ($associations as $type => $assocs): %> +<% foreach ($assocs as $assoc): + $alias = $assoc['alias']; + unset($assoc['alias']); +%> + $this-><%= $type %>('<%= $alias %>', [<%= $this->Bake->stringifyList($assoc, ['indent' => 3]) %>]); +<% endforeach %> +<% endforeach %> + } +<% if ( $this->BakeExtra->hasFilters($name) ): + $searchMethods = []; + foreach ( $this->BakeExtra->getFilters($name) as $k => $details ): + if ( $details['mode']==='value' ): + $searchMethods[] = "->" . $details['mode'] . "('$k', [ 'field' => \$this->aliasField('$k')])"; + else: + $fields = []; + foreach ( $details['columns'] as $col ): + $fields[] = "\$this->aliasField('$col')"; + endforeach; + $fields = implode(', ', $fields); + $searchMethods[] = "->" . $details['mode'] . "('$k', [\n" + . "\t\t\t\t'before' => " . $details['before'] . ",\n" + . "\t\t\t\t'after' => " . $details['after'] . ",\n" + . "\t\t\t\t'field' => [$fields]\n" + . "\t\t\t])"; + endif; + endforeach; +%> + /** + * Search plugin queries configuration + */ + public function searchConfiguration() + { + $search = new Manager($this); +<% if (!empty($searchMethods)): + $lastIndex = count($searchMethods) - 1; + $searchMethods[$lastIndex] .= ';'; +%> + $search +<% foreach ($searchMethods as $searchMethod): %> + <%= $searchMethod %> +<% endforeach; %> +<% endif; %> + return $search; + } +<% endif; %> +<% if (!empty($validation)): %> + + /** + * Default validation rules. + * + * @param \Cake\Validation\Validator $validator Validator instance. + * @return \Cake\Validation\Validator + */ + public function validationDefault(Validator $validator) + { +<% +foreach ($validation as $field => $rules): + $validationMethods = []; + foreach ($rules as $ruleName => $rule): + if ($rule['rule'] && !isset($rule['provider'])): + $validationMethods[] = sprintf( + "->add('%s', '%s', ['rule' => '%s'])", + $field, + $ruleName, + $rule['rule'] + ); + elseif ($rule['rule'] && isset($rule['provider'])): + $validationMethods[] = sprintf( + "->add('%s', '%s', ['rule' => '%s', 'provider' => '%s'])", + $field, + $ruleName, + $rule['rule'], + $rule['provider'] + ); + endif; + + if (isset($rule['allowEmpty'])): + if (is_string($rule['allowEmpty'])): + $validationMethods[] = sprintf( + "->allowEmpty('%s', '%s')", + $field, + $rule['allowEmpty'] + ); + elseif ($rule['allowEmpty']): + $validationMethods[] = sprintf( + "->allowEmpty('%s')", + $field + ); + else: + $validationMethods[] = sprintf( + "->requirePresence('%s', 'create')", + $field + ); + $validationMethods[] = sprintf( + "->notEmpty('%s')", + $field + ); + endif; + endif; + endforeach; + + if (!empty($validationMethods)): + $lastIndex = count($validationMethods) - 1; + $validationMethods[$lastIndex] .= ';'; + %> + $validator + <%- foreach ($validationMethods as $validationMethod): %> + <%= $validationMethod %> + <%- endforeach; %> + +<% + endif; +endforeach; +%> + return $validator; + } +<% endif %> +<% if (!empty($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) + { + <%- foreach ($rulesChecker as $field => $rule): %> + $rules->add($rules-><%= $rule['name'] %>(['<%= $field %>']<%= !empty($rule['extra']) ? ", '$rule[extra]'" : '' %>)); + <%- endforeach; %> + return $rules; + } +<% endif; %> +<% if ($connection !== 'default'): %> + + /** + * Returns the database connection name to use by default. + * + * @return string + */ + public static function defaultConnectionName() + { + return '<%= $connection %>'; + } +<% endif; %> +} diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Template/index.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Template/index.ctp new file mode 100644 index 0000000..112a40c --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Template/index.ctp @@ -0,0 +1,179 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +use Cake\Utility\Inflector; +use Cake\Utility\Hash; + +/* Enable for debug +echo "<!-- Instanciated vars :\n"; +print_r(compact('modelObject','modelClass','primaryKey','displayField','singularVar','pluralVar','singularHumanName','pluralHumanName','fields','keyFields','schema','fields','associations', 'extra', 'actions')); +echo "\n-->\n"; +*/ +$fields = collection($fields) + ->filter(function($field) use ($schema) { + return !in_array($schema->columnType($field), ['binary', 'text']) && $field != 'id'; + }) + ->take(7); +%> +<nav class="large-2 medium-3 columns" id="actions-sidebar"> + <ul class="side-nav"> + <li class="heading"><?= __('Actions') ?></li> + <li><?= $this->Html->link(__('New <%= $singularHumanName %>'), ['action' => 'add']) ?></li> +<% + $done = []; + foreach ($associations as $type => $data): + foreach ($data as $alias => $details): + if (!empty($details['navLink']) && $details['controller'] !== $this->name && !in_array($details['controller'], $done)): + if ($this->BakeExtra->hasAction("index", $details['controller'])): +%> + <li><?= $this->Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) ?></li> +<% + endif; + if ($this->BakeExtra->hasAction("add", $details['controller'])): +%> + <li><?= $this->Html->link(__('New <%= $this->_singularHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) ?></li> +<% + endif; + $done[] = $details['controller']; + endif; + endforeach; + endforeach; +%> + </ul> +</nav> +<div class="<%= $pluralVar %> index large-10 medium-9 columns content"> + <h3><?= __('<%= $pluralHumanName %>') ?></h3> + <table cellpadding="0" cellspacing="0"> +<% + if ( $this->BakeExtra->hasFilters($modelClass) ): +%> + <?= $this->Form->create(null) . "\n" ?> +<% + endif; +%> + <thead> +<% if ( $this->BakeExtra->hasFilters($modelClass) ): %> + <tr class="filter"> +<% foreach ( $this->BakeExtra->getFilters($modelClass) as $k => $filter): %> + <th colspan="<%= $filter['colspan'] %>"> + <?= $this->Form->input('<%= $k %>', [ + 'placeholder' => __('<%= $filter["hint"] %>'), + 'empty' => __('<%= $filter["hint"] %>') + ]) ?> + </th> +<% endforeach; %> + <th class="actions"> + <?= $this->Form->button('Filter', ['type' => 'submit']) . "\n" ?> + <?= $this->Html->link('Reset', ['action' => 'index']) . "\n" ?> + </th> + </tr> +<% endif; %> + <tr> +<% foreach ($fields as $field): %> + <th><?= $this->Paginator->sort('<%= $field %>') ?></th> +<% endforeach; %> + <th class="actions"><?= __('Actions') ?></th> + </tr> + </thead> +<% if ( $this->BakeExtra->hasFilters($modelClass) ): %> + <?= $this->Form->end() . "\n" ?> +<% endif; %> + <tbody> + <?php foreach ($<%= $pluralVar %> as $<%= $singularVar %>): ?> + <tr> +<% foreach ($fields as $field) { + $isKey = false; + if (!empty($associations['BelongsTo'])) { + foreach ($associations['BelongsTo'] as $alias => $details) { + if ($field === $details['foreignKey']) { + $isKey = true; + if ( $this->BakeExtra->hasAction("view", $details['controller']) ) { +%> + <td><?= $<%= $singularVar %>->has('<%= $details['property'] %>') ? $this->Html->link($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>, ['controller' => '<%= $details['controller'] %>', 'action' => 'view', $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['primaryKey'][0] %>]) : '' ?></td> +<% + } else { +%> + <td><?= $<%= $singularVar %>->has('<%= $details['property'] %>') ? h($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>) : '' ?></td> +<% + } + break; + } + } + } + if ($isKey !== true) { + if (!in_array($schema->columnType($field), ['integer', 'biginteger', 'decimal', 'float'])) { +%> + <td><?= h($<%= $singularVar %>-><%= $field %>) ?></td> +<% + } else { +%> + <td><?= $this->Number->format($<%= $singularVar %>-><%= $field %>) ?></td> +<% + } + } + } + + $pk = '$' . $singularVar . '->' . $primaryKey[0]; +%> + <td class="actions"> +<% + if ($this->BakeExtra->hasAction("view", $modelClass)): +%> + <?= $this->Html->link(__('View'), ['action' => 'view', <%= $pk %>]) ?> +<% + endif; + if ($this->BakeExtra->hasAction("edit", $modelClass)): +%> + <?= $this->Html->link(__('Edit'), ['action' => 'edit', <%= $pk %>]) ?> +<% + endif; + if ($this->BakeExtra->hasAction("delete", $modelClass)): +%> + <?= $this->Form->postLink(__('Delete'), ['action' => 'delete', <%= $pk %>], ['confirm' => __('Are you sure you want to delete # {0}?', <%= $pk %>)]) ?> +<% + endif; +%> + </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + <div class="paginator"> + <ul class="pagination"> + <?= $this->Paginator->prev('< ' . __('previous')) ?> + <?= $this->Paginator->numbers() ?> + <?= $this->Paginator->next(__('next') . ' >') ?> + </ul> + </div> + +</div> diff --git a/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Template/view.ctp b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Template/view.ctp new file mode 100644 index 0000000..8ab9916 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/Template/Bake/Template/view.ctp @@ -0,0 +1,215 @@ +<% +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * 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 0.1.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +use Cake\Utility\Inflector; + +$associations += ['BelongsTo' => [], 'HasOne' => [], 'HasMany' => [], 'BelongsToMany' => []]; +$immediateAssociations = $associations['BelongsTo'] + $associations['HasOne']; +$associationFields = collection($fields) + ->map(function($field) use ($immediateAssociations) { + foreach ($immediateAssociations as $alias => $details) { + if ($field === $details['foreignKey']) { + return [$field => $details]; + } + } + }) + ->filter() + ->reduce(function($fields, $value) { + return $fields + $value; + }, []); + +$groupedFields = collection($fields) + ->filter(function($field) use ($schema) { + return $schema->columnType($field) !== 'binary'; + }) + ->groupBy(function($field) use ($schema, $associationFields) { + $type = $schema->columnType($field); + if (isset($associationFields[$field])) { + return 'string'; + } + if (in_array($type, ['integer', 'float', 'decimal', 'biginteger'])) { + return 'number'; + } + if (in_array($type, ['date', 'time', 'datetime', 'timestamp'])) { + return 'date'; + } + return in_array($type, ['text', 'boolean']) ? $type : 'string'; + }) + ->toArray(); + +$groupedFields += ['number' => [], 'string' => [], 'boolean' => [], 'date' => [], 'text' => []]; +$pk = "\$$singularVar->{$primaryKey[0]}"; +%> +<nav class="large-2 medium-3 columns" id="actions-sidebar"> + <ul class="side-nav"> + <li class="heading"><?= __('Actions') ?></li> +<% + if ($this->BakeExtra->hasAction("edit", $modelClass)): +%> + <li><?= $this->Html->link(__('Edit <%= $singularHumanName %>'), ['action' => 'edit', <%= $pk %>]) ?> </li> +<% + endif; + if ($this->BakeExtra->hasAction("delete", $modelClass)): +%> + <li><?= $this->Form->postLink(__('Delete <%= $singularHumanName %>'), ['action' => 'delete', <%= $pk %>], ['confirm' => __('Are you sure you want to delete # {0}?', <%= $pk %>)]) ?> </li> +<% + endif; + if ($this->BakeExtra->hasAction("index", $modelClass)): +%> + <li><?= $this->Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?> </li> +<% + endif; + if ($this->BakeExtra->hasAction("add", $modelClass)): +%> + <li><?= $this->Html->link(__('New <%= $singularHumanName %>'), ['action' => 'add']) ?> </li> +<% + endif; + $done = []; + foreach ($associations as $type => $data) { + foreach ($data as $alias => $details) { + if ($details['controller'] !== $this->name && !in_array($details['controller'], $done)) { + if ($this->BakeExtra->hasAction("index", $details['controller'])): +%> + <li><?= $this->Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) ?> </li> +<% + endif; + if ($this->BakeExtra->hasAction("add", $details['controller'])): +%> + <li><?= $this->Html->link(__('New <%= Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) ?> </li> +<% + endif; + $done[] = $details['controller']; + } + } + } +%> + </ul> +</nav> +<div class="<%= $pluralVar %> view large-10 medium-9 columns content"> + <h3><?= h($<%= $singularVar %>-><%= $displayField %>) ?></h3> + <table class="vertical-table"> +<% if ($groupedFields['string']) : %> +<% foreach ($groupedFields['string'] as $field) : %> +<% if (isset($associationFields[$field])) : + $details = $associationFields[$field]; +%> + <tr> + <th><?= __('<%= Inflector::humanize($details['property']) %>') ?></th> +<% + if ( $this->BakeExtra->hasAction("view", $details['controller']) ): +%> + <td><?= $<%= $singularVar %>->has('<%= $details['property'] %>') ? $this->Html->link($<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %>, ['controller' => '<%= $details['controller'] %>', 'action' => 'view', $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['primaryKey'][0] %>]) : '' ?></td> +<% + else: +%> + <td><?= $<%= $singularVar %>-><%= $details['property'] %>-><%= $details['displayField'] %> ?></td> +<% + endif; +%> + </tr> +<% else : %> + <tr> + <th><?= __('<%= Inflector::humanize($field) %>') ?></th> + <td><?= h($<%= $singularVar %>-><%= $field %>) ?></td> + </tr> +<% endif; %> +<% endforeach; %> +<% endif; %> +<% if ($groupedFields['number']) : %> +<% foreach ($groupedFields['number'] as $field) : %> + <tr> + <th><?= __('<%= Inflector::humanize($field) %>') ?></th> + <td><?= $this->Number->format($<%= $singularVar %>-><%= $field %>) ?></td> + </tr> +<% endforeach; %> +<% endif; %> +<% if ($groupedFields['date']) : %> +<% foreach ($groupedFields['date'] as $field) : %> + <tr> + <th><%= "<%= __('" . Inflector::humanize($field) . "') %>" %></th> + <td><?= h($<%= $singularVar %>-><%= $field %>) ?></tr> + </tr> +<% endforeach; %> +<% endif; %> +<% if ($groupedFields['boolean']) : %> +<% foreach ($groupedFields['boolean'] as $field) : %> + <tr> + <th><?= __('<%= Inflector::humanize($field) %>') ?></th> + <td><?= $<%= $singularVar %>-><%= $field %> ? __('Yes') : __('No'); ?></td> + </tr> +<% endforeach; %> +<% endif; %> + </table> +<% if ($groupedFields['text']) : %> +<% foreach ($groupedFields['text'] as $field) : %> + <div class="row"> + <h4><?= __('<%= Inflector::humanize($field) %>') ?></h4> + <?= $this->Text->autoParagraph(h($<%= $singularVar %>-><%= $field %>)); ?> + </div> +<% endforeach; %> +<% endif; %> +<% +$relations = $associations['HasMany'] + $associations['BelongsToMany']; +foreach ($relations as $alias => $details): + $otherSingularVar = Inflector::variable($alias); + $otherPluralHumanName = Inflector::humanize(Inflector::underscore($details['controller'])); + %> + <div class="related"> + <h4><?= __('Related <%= $otherPluralHumanName %>') ?></h4> + <?php if (!empty($<%= $singularVar %>-><%= $details['property'] %>)): ?> + <table cellpadding="0" cellspacing="0"> + <tr> +<% foreach ($details['fields'] as $field): %> + <th><?= __('<%= Inflector::humanize($field) %>') ?></th> +<% endforeach; %> + <th class="actions"><?= __('Actions') ?></th> + </tr> +<!-- FIXME : ne pas prendre toutes les colonnes, rendre configurable ou faire un include d'un autre fichier Template --> + <?php foreach ($<%= $singularVar %>-><%= $details['property'] %> as $<%= $otherSingularVar %>): ?> + <tr> + <%- foreach ($details['fields'] as $field): %> + <td><?= h($<%= $otherSingularVar %>-><%= $field %>) ?></td> + <%- endforeach; %> + <%- $otherPk = "\${$otherSingularVar}->{$details['primaryKey'][0]}"; %> + <td class="actions"> +<!-- FIXME : ces liens devraient être conditionnels --> + <?= $this->Html->link(__('View'), ['controller' => '<%= $details['controller'] %>', 'action' => 'view', <%= $otherPk %>]) %> + <?= $this->Html->link(__('Edit'), ['controller' => '<%= $details['controller'] %>', 'action' => 'edit', <%= $otherPk %>]) %> + </td> + </tr> + <?php endforeach; ?> + </table> + <?php endif; ?> + </div> +<% endforeach; %> +</div> diff --git a/generator/before-bake/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/generator/before-bake/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php new file mode 100644 index 0000000..69506a9 --- /dev/null +++ b/generator/before-bake/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +namespace CustomTheme\View\Helper; + +use Cake\View\Helper; +use Cake\Utility\Hash; + +class BakeExtraHelper extends Helper +{ + public function hello() + { + return "<!-- BakeExtra::hello()\n" . print_r($this->_config, true) . "\n-->\n"; + } + + public function hasFilters($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + $filters = $this->getFilters($controllerName); + return (is_array($filters) && count($filters) > 0); + } + + public function getFilters($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + return Hash::get($this->_config, "$controllerName.filters"); + } + + public function hasAction($action, $controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + return in_array($action, $this->getActions($controllerName)); + } + + public function getActions($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + $actions = Hash::get($this->_config, "$controllerName.actions"); + if ( ! is_array($actions) ) { + $actions = Hash::get($this->_config, "default.actions"); + } + if ( ! is_array($actions) ) { + $actions = ['index', 'view', 'add', 'edit', 'delete']; + } + return $actions; + } + // TODO : modelClass or controllerName ? + public function getTitleOpts($modelClass) { + if ( ! is_string($modelClass) ) return FALSE; + return Hash::get($this->_config, "$modelClass.title"); + } +} diff --git a/generator/before-bake/src/View/AppView.php b/generator/before-bake/src/View/AppView.php new file mode 100644 index 0000000..65014f8 --- /dev/null +++ b/generator/before-bake/src/View/AppView.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +/** + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * 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 3.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +namespace App\View; + +use Cake\View\View; + +/** + * Application View + * + * Your application’s default view class + * + * @link http://book.cakephp.org/3.0/en/views.html#the-app-view + */ +class AppView extends View +{ + + /** + * Initialization hook method. + * + * Use this method to add common initialization code like loading helpers. + * + * e.g. `$this->loadHelper('Html');` + * + * @return void + */ + public function initialize() + { + parent::initialize(); + if ($this->request->action === 'add' || $this->request->action === 'edit') { + $this->loadHelper('Form', ['templates'=> ['dateWidget' => '{{day}}{{month}}{{year}}']]); + } + } +} diff --git a/generator/before-bake/tests/TestCase/View/I18nBasicTest.php b/generator/before-bake/tests/TestCase/View/I18nBasicTest.php new file mode 100644 index 0000000..de33609 --- /dev/null +++ b/generator/before-bake/tests/TestCase/View/I18nBasicTest.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ +namespace App\Test\TestCase\View; + +// use App\View\Helper\ProgressHelper; +use Cake\I18n\I18n; +use Cake\TestSuite\TestCase; +use Cake\View\View; + +class ProgressHelperTest extends TestCase +{ + public function setUp() + { + I18n::locale('fr-FR'); + } + + public function testBasicTranslation() + { + $this->assertContains('Juin', __('June')); + } +} diff --git a/generator/before-bake/webroot/.htaccess b/generator/before-bake/webroot/.htaccess new file mode 100644 index 0000000..01dde77 --- /dev/null +++ b/generator/before-bake/webroot/.htaccess @@ -0,0 +1,6 @@ +<IfModule mod_rewrite.c> + RewriteEngine On + RewriteBase /gestion + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] +</IfModule> diff --git a/generator/before-bake/webroot/css/local.css b/generator/before-bake/webroot/css/local.css new file mode 100644 index 0000000..6ec914a --- /dev/null +++ b/generator/before-bake/webroot/css/local.css @@ -0,0 +1,46 @@ +/** + * Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of CHD Gestion. + * + * CHD Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD Gestion. If not, see <http://www.gnu.org/licenses/>. +**/ + +.filter th { + padding-top:0; + padding-bottom:0; +} + +.filter input,button { + padding: 0.5rem; +} + +.filter label { + display: none; +} + +/* Retouche pour les tableaux (vues view) : pas de fer à droite */ +.vertical-table th { + width: 10rem; +} + +.vertical-table td { + text-align: left; +} + +/* Retouche alignement pour la top-bar du layout général lorsque le navigateur est étroit */ +.top-bar-section ul { + padding-left: 0.9375rem; +} diff --git a/generator/before-bake/webroot/favicon.ico b/generator/before-bake/webroot/favicon.ico new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/generator/before-bake/webroot/favicon.ico |