$infos) $new_fields_names[$f] = $infos; $fields_names = $new_fields_names; // Si champ 'nom', ajout auto du nice name debug($fields_names); if (empty($fields_names['nom'])) $fields_names['nom'] = ['nice_name'=>'Nom']; */ //debug($fields_names); //
= __('') ?> | $fnicename) echo "".$this->Paginator->sort($fname, $fnicename)." | "; //foreach ($fields_names as $fname=>$infos) { foreach ($fields_names as $fname=>$infos) { // Joli nom pour le titre de la colonne (nice name) $nice_name = isset($infos['nice_name']) ? $infos['nice_name'] : $fname; if ( in_array($fname, array_keys($sortWhitelist)) ) $fname = $sortWhitelist[$fname]; /* $sort_name = isset($infos['sort_name']) ? $infos['sort_name'] : $fname; echo "".$this->Paginator->sort($sort_name, ucfirst($nice_name))." | "; */ echo "".$this->Paginator->sort($fname, ucfirst($nice_name))." | "; } ?>
---|---|---|---|
id; //$CAN_EDIT = in_array($role, ['Administration', 'Super Administrateur']); $CAN_EDIT = $controller->isAuthorizedAction('edit', $id); $CAN_DELETE = $controller->isAuthorizedAction('delete', $id); //$CAN_DELETE=true; $style_num=1; $WITH_DIV = false; echo $this->element('buttons_edit_del', compact('id','CAN_EDIT','CAN_DELETE', 'style_num', 'WITH_DIV')); } ?> | toArray(); //debug($entity); //foreach ($e->toArray() as $fname=>$fval) { foreach ($fields_names as $fname=>$infos) { // $fval est soit un champ physique soit un champ virtuel (calculé par le Model) $fval = isset($entity[$fname]) ? $entity[$fname] : $e->connexDurAvg; //debug($fname); //if (! in_array($fname, array_keys($fields_names)) ) continue; //debug($fname); //= $this->Html->link($e->nom, ['action' => 'view', $e->id]) > | echo ""; // - S'il y a une fonction de transformation à appliquer, ben... on l'applique //var_dump($fname); if ( isset($fields_names[$fname]['f']) ) { $f = $fields_names[$fname]['f']; //debug($f); debug($fval); exit; //var_dump("Y"); echo $this->MyHelper->$f($fval); } // - Si c'est le champ "nom" ou "id", on l'affiche comme un lien elseif ($fname == 'nom' || $fname == 'id') echo $this->Html->link($fval, ['action' => 'view', $e->id]); // - Si le champ est boolean => on affiche oui/non //elseif ( (substr($fname,0,3)=='is_') && ($fval===false || $fval===true) ) elseif ( ( substr($fname,0,3)=='is_' || isset($infos['bool_values']) ) && ( $fval==false || $fval==true ) ) { $bool_values = isset($infos['bool_values']) ? $infos['bool_values'] : ['Oui','Non']; //echo $fval ? "Oui" : "Non"; echo $fval ? $bool_values[0] : $bool_values[1]; } // - Si le champ est une FK => on récupère la valeur du 'contained' //elseif ( strpos($fname,'_id') !== strlen($fname)-3 ) elseif ( substr($fname,-3) == '_id' ) { //var_dump($fname); //$fval = $e->has('sur_category') ? $e->sur_category->nom : $fval; // ex: materiel $contained_entity_name = $fields_names[$fname]['contained_entity_name']; // ex: Materiels $controller_name = $fields_names[$fname]['controller_name']; //$linkval = $e->has($contained_entity_name) ? $e->$contained_entity_name->nom : $fval; $name_field_label = $infos['name_field_label']; // 'nom' ou 'designation' ou ... //$projet->has('chef_science_id') ? $this->Html->link($projet->chef_science->nom, ['controller' => 'Users', 'action' => 'view', $projet->chef_science_id]) : '' > | //$linkval = $e->has($contained_entity_name) ? $e->$contained_entity_name->$name_field_label : $fval; if ($e->has($contained_entity_name)) { if ( isset($fields_names[$fname]['improved']) ) { $fk_field = $fields_names[$fname]['improved']; $linkval = $e->$fk_field; } else $linkval = $e->$contained_entity_name->$name_field_label; } else $linkval = $fval; //echo $this->Html->link($fval, ['controller' => $controller_name, 'action' => 'view', $e->sur_category->id]); echo $this->Html->link($linkval, ['controller' => $controller_name, 'action' => 'view', $fval]); /* //debug($fname); $parent_entity_infos = &$parent_entities_infos[$fname]; //debug($parent_entity_infos); $fk_contained_name = $parent_entity_infos['fk_contained_name']; //debug($fk_contained_name); //$fvalue = $associated_entity_infos['name']; $fvalue = $entity->$fk_contained_name->nom; $this->MyHelper->displayElement( __(ucfirst($parent_entity_infos['type_name'])), //$category->has('sur_category') ? $this->Html->link($category->sur_category->nom, [ $this->Html->link($fvalue, [ 'controller' => $parent_entity_infos['controller_name'], //'controller' => 'SurCategories', 'action' => 'view', //$associated_entity_infos['id'] $fval //$category->sur_category->id ]) ); */ } // FK // - Sinon, champ quelconque => on l'affiche directement else echo $fval; echo ""; } // foreach entity fields ?>