From 5529246c9a1c515afc8283d8c0d6d30d7337a904 Mon Sep 17 00:00:00 2001
From: nicod_ <nicod@lerebooteux.fr>
Date: Sat, 15 Apr 2023 20:52:33 +0200
Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20identifiant=20qui=20servira=20?=
 =?UTF-8?q?=C3=A0=20trouver=20le=20squelette=20qui=20affiche=20chaque=20ty?=
 =?UTF-8?q?pe=20de=20bloc=20(blocks/identifiant.html=20ou=20blocks=5Fprive?=
 =?UTF-8?q?/identifiant.html)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 base/blocks.php                   | 10 ++++++----
 formulaires/editer_blocs_type.php | 12 +++++++++++-
 lang/blocs_type_fr.php            |  2 ++
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/base/blocks.php b/base/blocks.php
index d54b06c..981c683 100644
--- a/base/blocks.php
+++ b/base/blocks.php
@@ -91,17 +91,19 @@ function blocks_declarer_tables_objets_sql($tables) {
 		'field'               => [
 			'id_blocs_type' => 'bigint(21) NOT NULL',
 			'titre'         => 'text NOT NULL DEFAULT ""',
+			'identifiant'   => 'text NOT NULL DEFAULT ""',
 			'saisies'       => 'text NOT NULL DEFAULT ""',
 			'maj'           => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
 		],
 		'key'                 => [
-			'PRIMARY KEY' => 'id_blocs_type',
+			'PRIMARY KEY'     => 'id_blocs_type',
+			'KEY identifiant' => 'identifiant',
 		],
 		'titre'               => 'titre AS titre, "" AS lang',
 		#'date' => '',
-		'champs_editables'    => ['titre', 'saisies'],
-		'champs_versionnes'   => ['titre', 'saisies'],
-		'rechercher_champs'   => ["titre" => 10],
+		'champs_editables'    => ['titre', 'saisies', 'identifiant'],
+		'champs_versionnes'   => ['titre', 'saisies', 'identifiant'],
+		'rechercher_champs'   => ["titre" => 10, 'identifiant' => 5],
 		'tables_jointures'    => [],
 
 	];
diff --git a/formulaires/editer_blocs_type.php b/formulaires/editer_blocs_type.php
index b99e485..acee67f 100644
--- a/formulaires/editer_blocs_type.php
+++ b/formulaires/editer_blocs_type.php
@@ -45,6 +45,16 @@ function formulaires_editer_blocs_type_saisies_dist($id_blocs_type = 'new', $ret
 
 			],
 		],
+		[
+			'saisie'  => 'input',
+			'options' => [
+				'nom'         => 'identifiant',
+				'obligatoire' => 'oui',
+				'label'       => _T('blocs_type:champ_identifiant_label'),
+				'explication' => _T('blocs_type:champ_identifiant_explication'),
+
+			],
+		],
 	];
 	return $saisies;
 }
@@ -124,7 +134,7 @@ function formulaires_editer_blocs_type_charger_dist($id_blocs_type = 'new', $ret
  */
 function formulaires_editer_blocs_type_verifier_dist($id_blocs_type = 'new', $retour = '', $lier_trad = 0, $config_fonc = '', $row = [], $hidden = '') {
 
-	$erreurs = formulaires_editer_objet_verifier('blocs_type', $id_blocs_type, ['titre']);
+	$erreurs = formulaires_editer_objet_verifier('blocs_type', $id_blocs_type, ['titre', 'identifiant']);
 
 	return $erreurs;
 }
diff --git a/lang/blocs_type_fr.php b/lang/blocs_type_fr.php
index eafebb3..174f797 100644
--- a/lang/blocs_type_fr.php
+++ b/lang/blocs_type_fr.php
@@ -11,6 +11,8 @@ $GLOBALS[$GLOBALS['idx_lang']] = [
 	'ajouter_lien_blocs_type'                   => 'Ajouter ce type de bloc',
 
 	// C
+	'champ_identifiant_label'                   => 'Identifiant',
+	'champ_identifiant_explication'             => 'Unique, composé de lettres en minuscules, chiffres ou souligné <code>_</code><br>Cet identifiant servira aussi à trouver le squelette qui affichera ce type de bloc : <code>squelettes/blocks/identifiant.html</code></code>',
 	'champ_saisies_label'                       => 'Paramètres de ce type de bloc',
 	'champ_titre_label'                         => 'Titre',
 	'confirmer_supprimer_blocs_type'            => 'Confirmez-vous la suppression de cet type de bloc ?',
-- 
GitLab