Commit 81e4cfd9f5a5fdd1ea592a12c2d795ae5f65c591
1 parent
c6900c63
Exists in
master
and in
1 other branch
Refactorisation de la vue 'view' pour toutes les 'autres' entités
(étape 2, étape 3 en cours...) => dans AppController:view_generic() => utilisation de mon helper src/View/Helper/MyHelperHelper/displayAssociatedEntitiesAsSectionShowHide() => un seul template unique utilisé /src/Template/Common/view.ctp, évite toutes ces trop nombreuses redondances, => plus efficace, on modifie tout en un seul endroit ! (au lieu d'une dizaine de pages web différentes avant !) v4.105.0-3.7.9
Showing
11 changed files
with
182 additions
and
257 deletions
Show diff stats
CHANGES.txt
@@ -119,9 +119,14 @@ Outre ces changements, voici d'autres changements importants : | @@ -119,9 +119,14 @@ Outre ces changements, voici d'autres changements importants : | ||
119 | 119 | ||
120 | ======= CHANGES ======= | 120 | ======= CHANGES ======= |
121 | 121 | ||
122 | -refactorisation de la vue 'view' pour toutes les 'autres' entités | 122 | +------- |
123 | +06/10/2020 v4.105.0-3.7.9 (EP) | ||
124 | + - (i) refactorisation de la vue 'view' pour toutes les 'autres' entités (étape 2, étape 3 en cours...) | ||
125 | + => dans AppController:view_generic() | ||
126 | + => utilisation de mon helper src/View/Helper/MyHelperHelper/displayAssociatedEntitiesAsSectionShowHide() | ||
127 | + => un seul template unique utilisé /src/Template/Common/view.ctp, évite toutes ces trop nombreuses redondances, | ||
128 | + => plus efficace, on modifie tout en un seul endroit ! (au lieu d'une dizaine de pages web différentes avant !) | ||
123 | 129 | ||
124 | -=> dans AppController:view_generic() | ||
125 | 130 | ||
126 | ------- | 131 | ------- |
127 | 05/10/2020 v4.104.5-3.7.9 (EP) | 132 | 05/10/2020 v4.104.5-3.7.9 (EP) |
README.md
@@ -42,8 +42,8 @@ Logiciel testé et validé sur les configurations suivantes : | @@ -42,8 +42,8 @@ Logiciel testé et validé sur les configurations suivantes : | ||
42 | 42 | ||
43 | -------------------------------------------------------------------------------------------- | 43 | -------------------------------------------------------------------------------------------- |
44 | 44 | ||
45 | -Date: 05/10/2020 | ||
46 | -Version: 4.104.5-3.7.9 | 45 | +Date: 06/10/2020 |
46 | +Version: 4.105.0-3.7.9 | ||
47 | 47 | ||
48 | 48 | ||
49 | HISTORIQUE DES CHANGEMENTS DE VERSION : voir le fichier CHANGES.txt (ou la page web /pages/changes) | 49 | HISTORIQUE DES CHANGEMENTS DE VERSION : voir le fichier CHANGES.txt (ou la page web /pages/changes) |
src/Controller/AppController.php
@@ -481,7 +481,13 @@ class AppController extends Controller | @@ -481,7 +481,13 @@ class AppController extends Controller | ||
481 | //return strtolower($this->name); | 481 | //return strtolower($this->name); |
482 | //return __CLASS__; | 482 | //return __CLASS__; |
483 | //return strtolower( substr($this->getName(),0,-1) ); | 483 | //return strtolower( substr($this->getName(),0,-1) ); |
484 | - return substr($this->getTypeNamePlural(),0,-1); | 484 | + $words = explode(' ',$this->getTypeNamePlural()); |
485 | + //debug($words); | ||
486 | + $type_name_singular = ''; | ||
487 | + foreach($words as $word) $type_name_singular .= substr($word,0,-1).' '; | ||
488 | + //debug($type_name_singular); | ||
489 | + return rtrim($type_name_singular); | ||
490 | + //return substr($this->getTypeNamePlural(),0,-1); | ||
485 | } | 491 | } |
486 | //@deprecated | 492 | //@deprecated |
487 | public function getNiceName() { return $this->getTypeNameSingular(); } | 493 | public function getNiceName() { return $this->getTypeNameSingular(); } |
@@ -2120,18 +2126,47 @@ class AppController extends Controller | @@ -2120,18 +2126,47 @@ class AppController extends Controller | ||
2120 | } // beforeFilter() | 2126 | } // beforeFilter() |
2121 | 2127 | ||
2122 | 2128 | ||
2123 | - public function view_generic($id, $associated_entity_types) { | 2129 | + public function view_generic($id, $associated_entity_types, $parent_entity_controller_name=[]) { |
2124 | 2130 | ||
2125 | // ex: SurCategories | 2131 | // ex: SurCategories |
2126 | $controller_name = $this->getName(); | 2132 | $controller_name = $this->getName(); |
2133 | + //debug($controller_name); exit; | ||
2127 | /* | 2134 | /* |
2128 | $entity = $this->SurCategories->get($id, [ | 2135 | $entity = $this->SurCategories->get($id, [ |
2129 | 'contain' => [] | 2136 | 'contain' => [] |
2130 | ]); | 2137 | ]); |
2131 | */ | 2138 | */ |
2132 | $entity = $this->$controller_name->get($id, [ | 2139 | $entity = $this->$controller_name->get($id, [ |
2133 | - 'contain' => [] | 2140 | + //'contain' => ['SurCategories'] |
2141 | + 'contain' => $parent_entity_controller_name | ||
2134 | ]); | 2142 | ]); |
2143 | + | ||
2144 | + // S'il y a une entité parente, on récupère ses infos | ||
2145 | + $parent_entity_infos = []; | ||
2146 | + if ($parent_entity_controller_name) { | ||
2147 | + //$parent_entity_name=$entity->sur_category->nom; | ||
2148 | + //$c_parent = 'App\\Controller\\'.'SurCategories'.'Controller'; | ||
2149 | + $c_parent = 'App\\Controller\\'.$parent_entity_controller_name.'Controller'; | ||
2150 | + $c_parent = new $c_parent(); | ||
2151 | + // 'Domaine' | ||
2152 | + $parent_entity_type_name=$c_parent->getTypeNameSingular(); | ||
2153 | + //debug($parent_entity_type_name); | ||
2154 | + // nom de l'instance de l'entité parente | ||
2155 | + // 'sur_category' | ||
2156 | + $parent_entity_contained_name = Inflector::classify($parent_entity_controller_name); | ||
2157 | + $parent_entity_contained_name = Inflector::underscore($parent_entity_contained_name); | ||
2158 | + //debug($parent_entity_contained_name);exit; | ||
2159 | + //$parent_entity_name=$entity->sur_category->nom; | ||
2160 | + $parent_entity_name_field_label = $c_parent->getNameFieldLabel(); | ||
2161 | + $parent_entity_name=$entity->$parent_entity_contained_name->$parent_entity_name_field_label; | ||
2162 | + //debug($parent_entity_name);exit; | ||
2163 | + $parent_entity_id=$entity->$parent_entity_contained_name->id; | ||
2164 | + $parent_entity_infos['controller_name'] = $parent_entity_controller_name; | ||
2165 | + $parent_entity_infos['type_name'] = $parent_entity_type_name; | ||
2166 | + $parent_entity_infos['name'] = $parent_entity_name; | ||
2167 | + $parent_entity_infos['id'] = $parent_entity_id; | ||
2168 | + } | ||
2169 | + | ||
2135 | $entities_list = []; | 2170 | $entities_list = []; |
2136 | // ex: 'sur_categorie_id' | 2171 | // ex: 'sur_categorie_id' |
2137 | $fk_name = $this->getFkName(); | 2172 | $fk_name = $this->getFkName(); |
@@ -2220,6 +2255,9 @@ class AppController extends Controller | @@ -2220,6 +2255,9 @@ class AppController extends Controller | ||
2220 | 'entity_type_name_singular', | 2255 | 'entity_type_name_singular', |
2221 | 'entity_name', | 2256 | 'entity_name', |
2222 | 'entity', | 2257 | 'entity', |
2258 | + 'parent_entity_infos', | ||
2259 | + //'parent_entity_controller_name','parent_entity_type_name', | ||
2260 | + //'parent_entity_name','parent_entity_id', | ||
2223 | 2261 | ||
2224 | // Infos sur les entités associées | 2262 | // Infos sur les entités associées |
2225 | 'entities_list' | 2263 | 'entities_list' |
@@ -2699,7 +2737,7 @@ class AppController extends Controller | @@ -2699,7 +2737,7 @@ class AppController extends Controller | ||
2699 | $printTableRow = $displayElement; | 2737 | $printTableRow = $displayElement; |
2700 | $this->set(compact('printTableRow')); | 2738 | $this->set(compact('printTableRow')); |
2701 | //@deprecated | 2739 | //@deprecated |
2702 | - $this->set('displayElement', $displayElement); | 2740 | + $this->set(compact('displayElement')); |
2703 | 2741 | ||
2704 | // Pass this function to all views | 2742 | // Pass this function to all views |
2705 | // @todo : Si cette fonction ne concerne que SuivisController, il faut la déplacer dans ce controleur | 2743 | // @todo : Si cette fonction ne concerne que SuivisController, il faut la déplacer dans ce controleur |
src/Controller/CategoriesController.php
@@ -19,6 +19,7 @@ class CategoriesController extends AppController | @@ -19,6 +19,7 @@ class CategoriesController extends AppController | ||
19 | //@Override | 19 | //@Override |
20 | public function getTypeNamePlural() { return 'catégories'; } | 20 | public function getTypeNamePlural() { return 'catégories'; } |
21 | 21 | ||
22 | + //@deprecated | ||
22 | public function getArticle() | 23 | public function getArticle() |
23 | { | 24 | { |
24 | return "La"; | 25 | return "La"; |
@@ -115,14 +116,13 @@ class CategoriesController extends AppController | @@ -115,14 +116,13 @@ class CategoriesController extends AppController | ||
115 | * @return \Cake\Network\Response|null | 116 | * @return \Cake\Network\Response|null |
116 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. | 117 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
117 | */ | 118 | */ |
118 | - public function view($id = null) | ||
119 | - { | 119 | + public function view($id = null) { |
120 | $associated_entity_types = [ | 120 | $associated_entity_types = [ |
121 | 'SousCategories', | 121 | 'SousCategories', |
122 | 'Materiels' | 122 | 'Materiels' |
123 | ]; | 123 | ]; |
124 | //return parent::view($id, $associated_entity_types); | 124 | //return parent::view($id, $associated_entity_types); |
125 | - return $this->view_generic($id, $associated_entity_types); | 125 | + return $this->view_generic($id, $associated_entity_types, 'SurCategories'); |
126 | 126 | ||
127 | /* | 127 | /* |
128 | $category = $this->Categories->get($id, [ | 128 | $category = $this->Categories->get($id, [ |
src/Controller/GroupesThematiquesController.php
@@ -12,6 +12,15 @@ use Cake\ORM\TableRegistry; | @@ -12,6 +12,15 @@ use Cake\ORM\TableRegistry; | ||
12 | class GroupesThematiquesController extends AppController | 12 | class GroupesThematiquesController extends AppController |
13 | { | 13 | { |
14 | 14 | ||
15 | + // Nom pluriel affichable pour cette entité | ||
16 | + //@Override | ||
17 | + public function getTypeNamePlural() { | ||
18 | + //return strtolower($this->name); | ||
19 | + //return strtolower($this->getName()); | ||
20 | + //return 'sur-catégories'; | ||
21 | + return 'groupes thématiques'; | ||
22 | + } | ||
23 | + | ||
15 | /** | 24 | /** |
16 | * Give authorization for groupes thematiques | 25 | * Give authorization for groupes thematiques |
17 | * | 26 | * |
@@ -80,6 +89,15 @@ class GroupesThematiquesController extends AppController | @@ -80,6 +89,15 @@ class GroupesThematiquesController extends AppController | ||
80 | */ | 89 | */ |
81 | public function view($id = null) | 90 | public function view($id = null) |
82 | { | 91 | { |
92 | + $associated_entity_types = [ | ||
93 | + 'Users', | ||
94 | + 'Materiels', | ||
95 | + 'Suivis', | ||
96 | + ]; | ||
97 | + //return parent::view($id, $associated_entity_types); | ||
98 | + return $this->view_generic($id, $associated_entity_types); | ||
99 | + | ||
100 | + /* | ||
83 | $groupesThematique = $this->GroupesThematiques->get($id, [ | 101 | $groupesThematique = $this->GroupesThematiques->get($id, [ |
84 | 'contain' => [ | 102 | 'contain' => [ |
85 | 'Materiels' | 103 | 'Materiels' |
@@ -105,6 +123,7 @@ class GroupesThematiquesController extends AppController | @@ -105,6 +123,7 @@ class GroupesThematiquesController extends AppController | ||
105 | $this->set('_serialize', [ | 123 | $this->set('_serialize', [ |
106 | 'groupesThematique' | 124 | 'groupesThematique' |
107 | ]); | 125 | ]); |
126 | + */ | ||
108 | } | 127 | } |
109 | 128 | ||
110 | /** | 129 | /** |
src/Controller/SousCategoriesController.php
@@ -11,12 +11,28 @@ use Cake\ORM\TableRegistry; | @@ -11,12 +11,28 @@ use Cake\ORM\TableRegistry; | ||
11 | */ | 11 | */ |
12 | class SousCategoriesController extends AppController | 12 | class SousCategoriesController extends AppController |
13 | { | 13 | { |
14 | - | 14 | + // Genre |
15 | + public $is_masculin = false; | ||
16 | + | ||
17 | + //@deprecated | ||
15 | public function getArticle() | 18 | public function getArticle() |
16 | { | 19 | { |
17 | return "La"; | 20 | return "La"; |
18 | } | 21 | } |
19 | 22 | ||
23 | + // Surcharge pour corriger bug cakephp qui renvoie 'Souscategories' au lieu de 'SousCategories' !! | ||
24 | + //@Override | ||
25 | + public function getName() { | ||
26 | + //return strtolower($this->name); | ||
27 | + //return strtolower($this->getName()); | ||
28 | + //return 'SousCategories'; | ||
29 | + $controller_name = substr(__CLASS__,strlen('App\\Controller\\')); | ||
30 | + return substr($controller_name,0,strpos($controller_name,'Controller')); | ||
31 | + } | ||
32 | + | ||
33 | + // Nom pluriel affichable pour cette entité | ||
34 | + //@Override | ||
35 | + public function getTypeNamePlural() { return 'sous-catégories'; } | ||
20 | 36 | ||
21 | /* | 37 | /* |
22 | * @Override | 38 | * @Override |
@@ -99,8 +115,13 @@ class SousCategoriesController extends AppController | @@ -99,8 +115,13 @@ class SousCategoriesController extends AppController | ||
99 | * @return \Cake\Network\Response|null | 115 | * @return \Cake\Network\Response|null |
100 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. | 116 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
101 | */ | 117 | */ |
102 | - public function view($id = null) | ||
103 | - { | 118 | + public function view($id = null) { |
119 | + $associated_entity_types = [ | ||
120 | + 'Materiels' | ||
121 | + ]; | ||
122 | + //return parent::view($id, $associated_entity_types); | ||
123 | + return $this->view_generic($id, $associated_entity_types, 'Categories'); | ||
124 | + /* | ||
104 | $sousCategory = $this->SousCategories->get($id, [ | 125 | $sousCategory = $this->SousCategories->get($id, [ |
105 | 'contain' => [ | 126 | 'contain' => [ |
106 | 'Categories' | 127 | 'Categories' |
@@ -116,6 +137,7 @@ class SousCategoriesController extends AppController | @@ -116,6 +137,7 @@ class SousCategoriesController extends AppController | ||
116 | $this->set('_serialize', [ | 137 | $this->set('_serialize', [ |
117 | 'sousCategory' | 138 | 'sousCategory' |
118 | ]); | 139 | ]); |
140 | + */ | ||
119 | } | 141 | } |
120 | 142 | ||
121 | /** | 143 | /** |
src/Controller/SurCategoriesController.php
@@ -21,18 +21,34 @@ class SurCategoriesController extends AppController | @@ -21,18 +21,34 @@ class SurCategoriesController extends AppController | ||
21 | return 'domaine'; | 21 | return 'domaine'; |
22 | } | 22 | } |
23 | */ | 23 | */ |
24 | - // Surcharge pour corriger bug cakephp qui renvoie 'Surcategories' au lieu de 'SurCategories' !! | 24 | + /* |
25 | + * Surcharge pour corriger bug cakephp qui renvoie 'Surcategories' au lieu de 'SurCategories' !! | ||
26 | + * (alors qu'il renvoie bien 'GroupesThematiques' pour le controleur GroupesThematiquesController !!) | ||
27 | + * | ||
28 | + * En fait, ce bug n'arrive que si on tape une URL comme ceci : | ||
29 | + * /surcategories/view/2 | ||
30 | + * au lieu de : | ||
31 | + * /sur-categories/view/2 | ||
32 | + * | ||
33 | + * Avec /sur-categories/view/2 => pas de problème, on a bien SurCategories | ||
34 | + * Avec /surcategories/view/2 => problème, on a Surcategories !!! | ||
35 | + * | ||
36 | + */ | ||
25 | //@Override | 37 | //@Override |
26 | public function getName() { | 38 | public function getName() { |
27 | //return strtolower($this->name); | 39 | //return strtolower($this->name); |
28 | //return strtolower($this->getName()); | 40 | //return strtolower($this->getName()); |
29 | - return 'SurCategories'; | 41 | + //return 'SurCategories'; |
42 | + //return __CLASS__; | ||
43 | + $controller_name = substr(__CLASS__,strlen('App\\Controller\\')); | ||
44 | + return substr($controller_name,0,strpos($controller_name,'Controller')); | ||
30 | } | 45 | } |
31 | // Nom pluriel affichable pour cette entité | 46 | // Nom pluriel affichable pour cette entité |
32 | //@Override | 47 | //@Override |
33 | public function getTypeNamePlural() { | 48 | public function getTypeNamePlural() { |
34 | //return strtolower($this->name); | 49 | //return strtolower($this->name); |
35 | //return strtolower($this->getName()); | 50 | //return strtolower($this->getName()); |
51 | + //return 'sur-catégories'; | ||
36 | return 'domaines'; | 52 | return 'domaines'; |
37 | } | 53 | } |
38 | 54 |
src/Template/Common/view.ctp
1 | <?php | 1 | <?php |
2 | +use App\Controller\SurCategoriesController; | ||
3 | +use App\Model\Entity\SurCategory; | ||
4 | + | ||
2 | $DEBUG=false; | 5 | $DEBUG=false; |
3 | //$DEBUG=true; | 6 | //$DEBUG=true; |
4 | 7 | ||
@@ -7,6 +10,14 @@ $DEBUG=false; | @@ -7,6 +10,14 @@ $DEBUG=false; | ||
7 | $role = $role; | 10 | $role = $role; |
8 | 11 | ||
9 | $entity = $entity; | 12 | $entity = $entity; |
13 | +$parent_entity_infos=$parent_entity_infos; | ||
14 | +/* | ||
15 | +$parent_entity_controller_name = $parent_entity_controller_name; | ||
16 | +$parent_entity_type_name = $parent_entity_type_name; | ||
17 | +$parent_entity_name = $parent_entity_name; | ||
18 | +$parent_entity_id = $parent_entity_id; | ||
19 | +*/ | ||
20 | + | ||
10 | //$categories = $categories; | 21 | //$categories = $categories; |
11 | //$materiels = $materiels; | 22 | //$materiels = $materiels; |
12 | $entity_article = $entity_article; | 23 | $entity_article = $entity_article; |
@@ -117,7 +128,35 @@ if ($DEBUG) { | @@ -117,7 +128,35 @@ if ($DEBUG) { | ||
117 | //$displayElement(__('Nom'), h($entity_name)); | 128 | //$displayElement(__('Nom'), h($entity_name)); |
118 | $this->MyHelper->displayElement(__('Nom'), h($entity_name)); | 129 | $this->MyHelper->displayElement(__('Nom'), h($entity_name)); |
119 | $this->MyHelper->displayElement(__('Description'), h($entity->description)); | 130 | $this->MyHelper->displayElement(__('Description'), h($entity->description)); |
120 | - | 131 | + // Affichage du nom de l'entité parente si elle existe |
132 | + // (ex: Domaine pour une catégorie, ou catégorie pour une sous-catégorie) | ||
133 | + //debug($entity->sur_category->getSource()); // 'SurCategories' | ||
134 | + /* | ||
135 | + $e = new SurCategory(); | ||
136 | + debug($e->getSource()); | ||
137 | + */ | ||
138 | + if($parent_entity_infos) | ||
139 | + //$this->MyHelper->displayElement(__('Domaine'), h($entity->sur_category->nom)); | ||
140 | + //$this->MyHelper->displayElement(__(ucfirst($parent_entity_type_name)), h($parent_entity_name)); | ||
141 | + $this->MyHelper->displayElement( | ||
142 | + __(ucfirst($parent_entity_infos['type_name'])), | ||
143 | + //$category->has('sur_category') ? $this->Html->link($category->sur_category->nom, [ | ||
144 | + $this->Html->link($parent_entity_infos['name'], [ | ||
145 | + 'controller' => $parent_entity_infos['controller_name'], | ||
146 | + //'controller' => 'SurCategories', | ||
147 | + 'action' => 'view', | ||
148 | + $parent_entity_infos['id'] | ||
149 | + //$category->sur_category->id | ||
150 | + ]) | ||
151 | + ); | ||
152 | + /* | ||
153 | + $this->MyHelper->displayElement(__('Domaine'), $this->Html->link($entity->sur_category->nom, [ | ||
154 | + 'controller' => 'SurCategories', | ||
155 | + 'action' => 'view', | ||
156 | + $entity->sur_category->id | ||
157 | + ]) | ||
158 | + ); | ||
159 | + */ | ||
121 | ?> | 160 | ?> |
122 | 161 | ||
123 | </table> | 162 | </table> |
src/Template/GroupesThematiques/view.ctp
1 | - | ||
2 | - | ||
3 | -<div class="groupesThematiques view"> | ||
4 | - <h2>Détail <?= $configuration->nom_groupe_thematique ?></h2> | ||
5 | - | ||
6 | - <table style="margin-bottom: 30px;"> | ||
7 | - | ||
8 | - <tr> | ||
9 | - <th style="width: 250px;"></th> | ||
10 | - <th></th> | ||
11 | - </tr> | ||
12 | - | ||
13 | - <?php | ||
14 | - if (in_array($role, [ | ||
15 | - 'Administration Plus', | ||
16 | - 'Super Administrateur' | ||
17 | - ])) { | ||
18 | - echo $this->Html->link(__('<i class="icon-pencil"></i> Editer ce ' . $configuration->nom_groupe_thematique), [ | ||
19 | - 'action' => 'edit', | ||
20 | - $groupesThematique->id | ||
21 | - ], [ | ||
22 | - 'style' => 'margin-right: 40px; display: inline-block', | ||
23 | - 'escape' => false, | ||
24 | - 'onclick' => 'return true;' | ||
25 | - ]); | ||
26 | - } | ||
27 | - | ||
28 | - if (in_array($role, [ | ||
29 | - 'Super Administrateur' | ||
30 | - ])) { | ||
31 | - echo $this->Form->postLink(__('<i class="icon-trash"></i> Supprimer ce ' . $configuration->nom_groupe_thematique), [ | ||
32 | - 'action' => 'delete', | ||
33 | - $groupesThematique->id | ||
34 | - ], [ | ||
35 | - 'style' => 'display: inline-block', | ||
36 | - 'escape' => false, | ||
37 | - 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $groupesThematique->id) | ||
38 | - ]); | ||
39 | - } | ||
40 | - | ||
41 | - $displayElement(__('Nom'), h($groupesThematique->nom)); | ||
42 | - $displayElement(__('Description'), h($groupesThematique->description)); | ||
43 | - ?> | ||
44 | - | ||
45 | - | ||
46 | - </table> | ||
47 | - | ||
48 | - <h3 id="t_users" class='toggle' style="cursor: pointer;"> | ||
49 | - <i class="icon-chevron-down" style="font-size: 14px;" id="i_users"></i> | ||
50 | - <span style="text-decoration: underline;">Utilisateurs associés (<?= $utilisateurs->count()?>)</span> | ||
51 | - </h3> | ||
52 | - <div id="users" style="margin-bottom: 20px;"> | ||
53 | - | ||
54 | - <?php if (!empty($utilisateurs)) { ?> | ||
55 | - <table> | ||
56 | - <tr> | ||
57 | - <th><?= __('Nom') ?></th> | ||
58 | - <th style="width: 50px;"><?= __('Détail') ?></th> | ||
59 | - </tr> | ||
60 | - <?php foreach ($utilisateurs as $utilisateur): ?> | ||
61 | - <tr> | ||
62 | - | ||
63 | - <td><?= $this->Html->link(h($utilisateur->nom), ['controller' => 'Users', 'action' => 'view', h($utilisateur->id)]); ?></td> | ||
64 | - | ||
65 | - <td class="actions"> | ||
66 | - <?= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => 'Users', 'action' => 'view', $utilisateur->id], ['escape' => false, 'style' => 'margin:0']) ?> | ||
67 | - </td> | ||
68 | - </tr> | ||
69 | - <?php endforeach; ?> | ||
70 | - </table> | ||
71 | - <?php }else { echo 'Aucun utilisateur lié à ce '.$configuration->nom_groupe_thematique; } ?> | ||
72 | - </div> | ||
73 | - | ||
74 | - | ||
75 | - <h3 id="t_suivis" class='toggle' style="cursor: pointer;"> | ||
76 | - <i class="icon-chevron-down" style="font-size: 14px;" id="i_suivis"></i> | ||
77 | - <span style="text-decoration: underline;">Suivis associés (<?= $suivis->count()?>)</span> | ||
78 | - </h3> | ||
79 | - <div id="suivis" style="margin-bottom: 20px;"> | ||
80 | - | ||
81 | - <?php if (!empty($suivis)) { ?> | ||
82 | - <table> | ||
83 | - <tr> | ||
84 | - <th><?= __('N° suivi') ?></th> | ||
85 | - <th style="width: 50px;"><?= __('Détail') ?></th> | ||
86 | - </tr> | ||
87 | - <?php foreach ($suivis as $suivi): ?> | ||
88 | - <tr> | ||
89 | - | ||
90 | - <td><?= $this->Html->link('Suivi '.h($suivi->id), ['controller' => 'Suivis', 'action' => 'view', h($suivi->id)]); ?></td> | ||
91 | - | ||
92 | - <td class="actions"> | ||
93 | - <?= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => 'Suivis', 'action' => 'view', $suivi->id], ['escape' => false, 'style' => 'margin:0']) ?> | ||
94 | - </td> | ||
95 | - </tr> | ||
96 | - <?php endforeach; ?> | ||
97 | - </table> | ||
98 | - <?php }else { echo 'Aucun suivi lié à ce '.$configuration->nom_groupe_thematique; } ?> | ||
99 | - </div> | ||
100 | - | ||
101 | - | ||
102 | - <h3 id="t_matos" class='toggle' style="cursor: pointer;"> | ||
103 | - <i class="icon-chevron-down" style="font-size: 14px;" id="i_matos"></i> | ||
104 | - <span style="text-decoration: underline;">Materiels associés (<?= $materiels->count()?>)</span> | ||
105 | - </h3> | ||
106 | - <div id="matos" style="margin-bottom: 20px;"> | ||
107 | - | ||
108 | - <?php if (!empty($materiels)) { ?> | ||
109 | - <table> | ||
110 | - <tr> | ||
111 | - <th><?= __('Désignation') ?></th> | ||
112 | - <th style="width: 50px;"><?= __('Détail') ?></th> | ||
113 | - </tr> | ||
114 | - <?php foreach ($materiels as $materiel): ?> | ||
115 | - <tr> | ||
116 | - | ||
117 | - <td><?= $this->Html->link(h($materiel->designation), ['controller' => 'Materiels', 'action' => 'view', h($materiel->id)]); ?></td> | ||
118 | - | ||
119 | - <td class="actions"> | ||
120 | - <?= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => 'Materiels', 'action' => 'view', $materiel->id], ['escape' => false, 'style' => 'margin:0']) ?> | ||
121 | - </td> | ||
122 | - </tr> | ||
123 | - <?php endforeach; ?> | ||
124 | - </table> | ||
125 | - <?php }else { echo 'Aucun matériel lié à ce '.$configuration->nom_groupe_thematique.'.'; } ?> | ||
126 | - </div> | ||
127 | - | ||
128 | - | ||
129 | - | ||
130 | -</div> | ||
131 | - | ||
132 | -<!-- | ||
133 | -<div class="actions"> | ||
134 | - <php echo $this->element('menu') ?> | ||
135 | - <php | ||
136 | - | ||
137 | -echo $this->element('menu_view', [ | ||
138 | - 'pluralHumanName' => $configuration->nom_groupe_thematique . 's', | ||
139 | - 'singularHumanName' => $configuration->nom_groupe_thematique, | ||
140 | - 'lien' => $groupesThematique->id | ||
141 | -])?> | ||
142 | - </div> | ||
143 | ---> | ||
144 | \ No newline at end of file | 1 | \ No newline at end of file |
2 | +<!-- src/Template/GroupesThematiques/view.ctp --> | ||
3 | +<?php | ||
4 | +$this->extend('/Common/view'); | ||
145 | \ No newline at end of file | 5 | \ No newline at end of file |
src/Template/SousCategories/view.ctp
1 | - | ||
2 | - | ||
3 | -<div class="sousCategories view"> | ||
4 | - <h2>Détail sous-catégorie</h2> | ||
5 | - <table style="margin-bottom: 30px;"> | ||
6 | - | ||
7 | - <tr> | ||
8 | - <th style="width: 250px;"></th> | ||
9 | - <th></th> | ||
10 | - </tr> | ||
11 | - | ||
12 | - <?php | ||
13 | - if (in_array($role, [ | ||
14 | - 'Administration Plus', | ||
15 | - 'Super Administrateur' | ||
16 | - ])) { | ||
17 | - echo $this->Html->link(__('<i class="icon-pencil"></i> Editer cette sous-catégorie'), [ | ||
18 | - 'action' => 'edit', | ||
19 | - $sousCategory->id | ||
20 | - ], [ | ||
21 | - 'style' => 'margin-right: 40px; display: inline-block', | ||
22 | - 'escape' => false, | ||
23 | - 'onclick' => 'return true;' | ||
24 | - ]); | ||
25 | - } | ||
26 | - | ||
27 | - if (in_array($role, [ | ||
28 | - 'Super Administrateur' | ||
29 | - ])) { | ||
30 | - echo $this->Form->postLink(__('<i class="icon-trash"></i> Supprimer cette sous-catégorie'), [ | ||
31 | - 'action' => 'delete', | ||
32 | - $sousCategory->id | ||
33 | - ], [ | ||
34 | - 'style' => 'display: inline-block', | ||
35 | - 'escape' => false, | ||
36 | - 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $sousCategory->id) | ||
37 | - ]); | ||
38 | - } | ||
39 | - | ||
40 | - $displayElement(__('Nom'), h($sousCategory->nom)); | ||
41 | - $displayElement(__('Catégorie'), $sousCategory->has('category') ? $this->Html->link($sousCategory->category->nom, [ | ||
42 | - 'controller' => 'Categories', | ||
43 | - 'action' => 'view', | ||
44 | - $sousCategory->category->id | ||
45 | - ]) : ''); | ||
46 | - | ||
47 | - ?> | ||
48 | - | ||
49 | - </table> | ||
50 | - | ||
51 | - <h3 id="t_matos" class='toggle' style="cursor: pointer;"> | ||
52 | - <i class="icon-chevron-down" style="font-size: 14px;" id="i_matos"></i> | ||
53 | - <span style="text-decoration: underline;">Materiels associés (<?= $materiels->count()?>)</span> | ||
54 | - </h3> | ||
55 | - <div id="matos" style="margin-bottom: 20px;"> | ||
56 | - | ||
57 | - <?php if (!empty($materiels)) { ?> | ||
58 | - <table> | ||
59 | - <tr> | ||
60 | - <th><?= __('Désignation') ?></th> | ||
61 | - <th style="width: 50px;"><?= __('Détail') ?></th> | ||
62 | - </tr> | ||
63 | - <?php foreach ($materiels as $materiel): ?> | ||
64 | - <tr> | ||
65 | - | ||
66 | - <td><?= $this->Html->link(h($materiel->designation), ['controller' => 'Materiels', 'action' => 'view', h($materiel->id)]); ?></td> | ||
67 | - | ||
68 | - <td class="actions"> | ||
69 | - <?= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => 'Materiels', 'action' => 'view', $materiel->id], ['escape' => false, 'style' => 'margin:0']) ?> | ||
70 | - </td> | ||
71 | - </tr> | ||
72 | - <?php endforeach; ?> | ||
73 | - </table> | ||
74 | - <?php }else { echo 'Aucun matériel lié à cette sous-catégorie.'; } ?> | ||
75 | - </div> | ||
76 | - | ||
77 | - | ||
78 | -</div> | ||
79 | - | ||
80 | -<!-- | ||
81 | -<div class="actions"> | ||
82 | - <php echo $this->element('menu') ?> | ||
83 | - <php | ||
84 | - | ||
85 | -echo $this->element('menu_view', [ | ||
86 | - 'pluralHumanName' => 'Sous-Catégories', | ||
87 | - 'singularHumanName' => 'Sous-Catégorie', | ||
88 | - 'lien' => $sousCategory->id | ||
89 | -])?> | ||
90 | - </div> | ||
91 | ---> | ||
92 | \ No newline at end of file | 1 | \ No newline at end of file |
2 | +<!-- src/Template/SousCategories/view.ctp --> | ||
3 | +<?php | ||
4 | +/* | ||
5 | +Le fichier de vue étendu ici est utilisé comme une vue parente. | ||
6 | +Il s’attend à ce que la vue l’étendant (celle-ci par exemple) | ||
7 | +définisse des blocks sidebar et title. | ||
8 | +Le block content est un block spécial que CakePHP crée. | ||
9 | +Il contiendra tous les contenus non capturés de la vue étendue. | ||
10 | +*/ | ||
11 | +$this->extend('/Common/view'); | ||
93 | \ No newline at end of file | 12 | \ No newline at end of file |
src/View/Helper/MyHelperHelper.php
@@ -52,17 +52,21 @@ class MyHelperHelper extends Helper { | @@ -52,17 +52,21 @@ class MyHelperHelper extends Helper { | ||
52 | // Ca c'est parce que sinon y'a au moins deux tests qui passent pas, a cause de l'espace dans la balise ... | 52 | // Ca c'est parce que sinon y'a au moins deux tests qui passent pas, a cause de l'espace dans la balise ... |
53 | //if ($valeur != "") echo '<tr> <td><strong>'.$nom.' </strong></td>' . $TD.$valeur.'</td></tr>'; | 53 | //if ($valeur != "") echo '<tr> <td><strong>'.$nom.' </strong></td>' . $TD.$valeur.'</td></tr>'; |
54 | //if ($valeur != "") echo '<tr><td><strong>' . $nom . ' </strong></td>' . $balise . $valeur . '</td></tr>'; | 54 | //if ($valeur != "") echo '<tr><td><strong>' . $nom . ' </strong></td>' . $balise . $valeur . '</td></tr>'; |
55 | - if ($valeur!="") echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".h($valeur)."</TD> </TR>"; | 55 | + //if ($valeur!="") echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".h($valeur)."</TD> </TR>"; |
56 | + if ($valeur!="") echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".$valeur."</TD> </TR>"; | ||
57 | + //if ($valeur!="") echo "<TR> <TD><strong>$nom</strong></TD> <$TD>$valeur</TD> </TR>"; | ||
56 | } | 58 | } |
57 | 59 | ||
58 | 60 | ||
61 | + | ||
62 | + | ||
59 | //function displaySectionShowHide($controller_name, $entity_type_name, $title, $id_name, $is_masculine, $name_field_name, $entities) { | 63 | //function displaySectionShowHide($controller_name, $entity_type_name, $title, $id_name, $is_masculine, $name_field_name, $entities) { |
60 | //function displaySectionShowHide($controller_name, $entity_type_name, $title, $is_masculine, $name_field_name, $entities) { | 64 | //function displaySectionShowHide($controller_name, $entity_type_name, $title, $is_masculine, $name_field_name, $entities) { |
61 | - function displayAssociatedEntitiesAsSectionShowHide($controller_name, $entity_type_name, $title, $is_masculine, $name_field_name, $entities) { | 65 | + function displayAssociatedEntitiesAsSectionShowHide($controller_name, $entity_type_name, $title, $is_masculin, $name_field_name, $entities) { |
62 | $id_name = $controller_name; | 66 | $id_name = $controller_name; |
63 | $id_h3 = 't_'.$id_name; | 67 | $id_h3 = 't_'.$id_name; |
64 | $id_i = 'i_'.$id_name; | 68 | $id_i = 'i_'.$id_name; |
65 | - $title = ucfirst($title).' associé'. ($is_masculine ? 's' : 'es'); | 69 | + $title = ucfirst($title).' associé'. ($is_masculin ? 's' : 'es'); |
66 | 70 | ||
67 | echo "<h3 id='$id_h3' class='toggle' style='cursor: pointer;'>"; | 71 | echo "<h3 id='$id_h3' class='toggle' style='cursor: pointer;'>"; |
68 | echo "<i class='icon-chevron-down' style='font-size: 14px;' id='$id_i'></i>"; | 72 | echo "<i class='icon-chevron-down' style='font-size: 14px;' id='$id_i'></i>"; |
@@ -71,9 +75,12 @@ class MyHelperHelper extends Helper { | @@ -71,9 +75,12 @@ class MyHelperHelper extends Helper { | ||
71 | 75 | ||
72 | echo "<div id='$id_name' style='margin-bottom: 20px;'>"; | 76 | echo "<div id='$id_name' style='margin-bottom: 20px;'>"; |
73 | //if (true) { | 77 | //if (true) { |
74 | - if (empty($entities)) { | 78 | + //if (empty($entities)) { |
79 | + $shift3 = ' '; | ||
80 | + $shift5 = ' '; | ||
81 | + if ($entities->isEmpty()) { | ||
75 | //echo "Aucune $entity_name liée à ce domaine."; | 82 | //echo "Aucune $entity_name liée à ce domaine."; |
76 | - echo ($is_masculine ? "Aucun $entity_type_name associé" : "Aucune $entity_type_name associée"); | 83 | + echo $shift5.($is_masculin ? "Aucun $entity_type_name associé" : "Aucune $entity_type_name associée"); |
77 | } | 84 | } |
78 | else { | 85 | else { |
79 | echo "<table>"; | 86 | echo "<table>"; |
@@ -86,7 +93,7 @@ class MyHelperHelper extends Helper { | @@ -86,7 +93,7 @@ class MyHelperHelper extends Helper { | ||
86 | foreach ($entities as $entity) { | 93 | foreach ($entities as $entity) { |
87 | echo "<tr>"; | 94 | echo "<tr>"; |
88 | echo "<td>"; | 95 | echo "<td>"; |
89 | - echo ' '.$this->Html->link(h($entity->$name_field_name), ['controller' => $controller_name, 'action' => 'view', h($entity->id)]); | 96 | + echo $shift3.$this->Html->link(h($entity->$name_field_name), ['controller' => $controller_name, 'action' => 'view', h($entity->id)]); |
90 | echo "</td>"; | 97 | echo "</td>"; |
91 | /* | 98 | /* |
92 | <td class="actions"> | 99 | <td class="actions"> |