From 5d1a78d9ef6a113ea6ba0e093144b87c631607f3 Mon Sep 17 00:00:00 2001
From: nicod_ <nicod@lerebooteux.fr>
Date: Fri, 24 Jan 2025 23:44:16 +0100
Subject: [PATCH] refactor: Pas besoin de ce wrapper sans typage

Il suffit de faire attention lors de l'appel.
---
 inc/blocks.php                          | 35 +++++++------------------
 prive/objets/liste/blocktypes.html      |  2 +-
 prive/squelettes/contenu/blocktype.html |  6 ++---
 saisies/blocktypes.html                 |  2 +-
 squelettes/inclure/block.html           |  2 +-
 5 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/inc/blocks.php b/inc/blocks.php
index 9042005..877efd4 100644
--- a/inc/blocks.php
+++ b/inc/blocks.php
@@ -207,7 +207,16 @@ function blocktype_info(string $blocktype, string $config) {
 	return $blocktypes[$blocktype][$config] ?? $defaut;
 }
 
-function _blocktype_trouver_squelette(
+/**
+ * Retrouver les squelettes liés à un blocktype dans tout le path
+ *
+ * @param string $blocktype
+ * @param bool   $force_public
+ * @param bool   $chemin_complet
+ * @param bool   $dist
+ * @return string
+ */
+function blocktype_trouver_squelette(
 	string $blocktype,
 	bool $force_public = false,
 	bool $chemin_complet = false,
@@ -245,30 +254,6 @@ function _blocktype_trouver_squelette(
 	return $squelette;
 }
 
-/**
- * Wrapper sans typage de la fonction _blocktype_trouver_squelette pour les squelettes SPIP
- * Les paramètres peuvent être vides ou des chaines et pas des bool
- *
- * @param $blocktype
- * @param $force_public
- * @param $chemin_complet
- * @param $dist
- * @return string
- */
-function filtre_blocktype_squelette(
-	$blocktype,
-	$force_public = false,
-	$chemin_complet = false,
-	$dist = true
-) {
-	return _blocktype_trouver_squelette(
-		(string)$blocktype,
-		(bool)$force_public,
-		(bool)$chemin_complet,
-		(bool)$dist
-	);
-}
-
 /**
  * Calculer la liste des types de blocks pouvant être créés sous un type de block
  * @param $blocktype
diff --git a/prive/objets/liste/blocktypes.html b/prive/objets/liste/blocktypes.html
index 43d06f6..5eccb84 100644
--- a/prive/objets/liste/blocktypes.html
+++ b/prive/objets/liste/blocktypes.html
@@ -26,7 +26,7 @@
 			<td class="secondaire"><BOUCLE(BLOCKS){blocktype=#CLE}{tout}>#SET{total,#TOTAL_BOUCLE}</BOUCLE>[(#GET{total})]</td>
 			<td class="secondaire">#RANG</td>
 			<td class="secondaire">
-				[(#CLE|blocktype_squelette{1,1,0})]
+				[(#CLE|blocktype_trouver_squelette{1,1,0})]
 			</td>
 		</tr>
 	</BOUCLE_liste_blocktypes>
diff --git a/prive/squelettes/contenu/blocktype.html b/prive/squelettes/contenu/blocktype.html
index b71cbf9..f8b9325 100644
--- a/prive/squelettes/contenu/blocktype.html
+++ b/prive/squelettes/contenu/blocktype.html
@@ -37,13 +37,13 @@
 
 <p>
 	<strong class="label"><:blocktype:texte_squelette_public:/> : </strong>
-	#SET{skel, #BLOCKTYPE|blocktype_info{identifiant}|blocktype_squelette{1,1,0}}
-	#SET{skeldist, #BLOCKTYPE|blocktype_info{identifiant}|blocktype_squelette{1,1,1}}
+	#SET{skel, #BLOCKTYPE|blocktype_info{identifiant}|blocktype_trouver_squelette{1,1,0}}
+	#SET{skeldist, #BLOCKTYPE|blocktype_info{identifiant}|blocktype_trouver_squelette{1,1,1}}
 	[(#GET{skel}|oui) [(#GET{skel})] ]
 	[(#GET{skel}|non) [(#ALERTE_MESSAGE{<:blocktype:info_blocktypes_sans_squelette:/>})] ]
 </p>
 
-#SET{skel_prive, #BLOCKTYPE|blocktype_info{identifiant}|blocktype_squelette{0,1,0}}
+#SET{skel_prive, #BLOCKTYPE|blocktype_info{identifiant}|blocktype_trouver_squelette{0,1,0}}
 [(#GET{skel_prive}|et{#GET{skel_prive}|!=={#GET{skel}}})
 <p>
 	<strong class="label"><:blocktype:texte_squelette_prive:/> : </strong> [(#GET{skel_prive})]
diff --git a/saisies/blocktypes.html b/saisies/blocktypes.html
index cf6c5d7..931ddd3 100644
--- a/saisies/blocktypes.html
+++ b/saisies/blocktypes.html
@@ -1,4 +1,4 @@
-#SET{blocktypes_enfants,#ENV{blocktype_parent}|blocktype_trouver_enfants}
+#SET{blocktypes_enfants,#ENV{blocktype_parent}|sinon{#VAL{''}}|blocktype_trouver_enfants}
 #SET{data,#ARRAY}
 <BOUCLE(DATA){source tableau, #REM|blocktypes_lister_types} {cle !IN #ENV{exclus}} {par rang, titre}>
 	#SET{blocktypes_parents,#CLE|blocktype_trouver_parents}
diff --git a/squelettes/inclure/block.html b/squelettes/inclure/block.html
index 6d88a43..e914e83 100644
--- a/squelettes/inclure/block.html
+++ b/squelettes/inclure/block.html
@@ -1,5 +1,5 @@
 <BOUCLE_racine(BLOCKS){id_block}{statut?}>
-#SET{squelette,#BLOCKTYPE|blocktype_squelette}
+#SET{squelette,#BLOCKTYPE|blocktype_trouver_squelette}
 [(#GET{squelette}|oui)
 <[(#BLOCKTYPE|blocktype_info{conteneur_tag}|sinon{div})] class="block block--#BLOCKTYPE[ (#BLOCKTYPE|blocktype_info{conteneur_class})]">
 	<INCLURE{fond=#GET{squelette}, env, objet=#OBJET, id_objet=#ID_OBJET}>
-- 
GitLab