Skip to content
Extraits de code Groupes Projets
Valider bb5a5b65 rédigé par nicod's avatar nicod
Parcourir les fichiers

refactor: changement de signature, doc, rangement

parent 940f5e58
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -181,7 +181,7 @@ function generer_TITRE_BLOCK($id_block): string { ...@@ -181,7 +181,7 @@ function generer_TITRE_BLOCK($id_block): string {
'spip_blocks', 'spip_blocks',
'id_block = ' . (int)$id_block 'id_block = ' . (int)$id_block
)) { )) {
$titre = blocktype_info('titre', $infos['blocktype']); $titre = blocktype_info($infos['blocktype'], 'titre');
if ($infos['id_objet'] && $infos['objet']) { if ($infos['id_objet'] && $infos['objet']) {
$titre = generer_objet_info($infos['id_objet'], $infos['objet'], 'titre') . ' - ' . $titre . ' #' . $infos['rang_lien']; $titre = generer_objet_info($infos['id_objet'], $infos['objet'], 'titre') . ' - ' . $titre . ' #' . $infos['rang_lien'];
} }
......
...@@ -59,7 +59,7 @@ function blocktypes_lister_types(bool $exclure_ignores = true): array { ...@@ -59,7 +59,7 @@ function blocktypes_lister_types(bool $exclure_ignores = true): array {
$yaml_data['titre'] = _T_ou_typo($yaml_data['titre']); $yaml_data['titre'] = _T_ou_typo($yaml_data['titre']);
$yaml_data['identifiant'] = $blocktype; $yaml_data['identifiant'] = $blocktype;
$yaml_data['description'] = _T_ou_typo($yaml_data['description']); $yaml_data['description'] = _T_ou_typo($yaml_data['description']);
$yaml_data['icone'] = isset($yaml_data['icone']) ? blocktype_find_icone_path($yaml_data['icone']) : ''; $yaml_data['icone'] = isset($yaml_data['icone']) ? _blocktype_find_icone_path($yaml_data['icone']) : '';
$liste_blocktypes[$blocktype] = $yaml_data; $liste_blocktypes[$blocktype] = $yaml_data;
} }
...@@ -93,10 +93,10 @@ function blocktypes_lister_types(bool $exclure_ignores = true): array { ...@@ -93,10 +93,10 @@ function blocktypes_lister_types(bool $exclure_ignores = true): array {
/** /**
* Retrouver l'icone d'un blocktype, la réduire à 16 px * Retrouver l'icone d'un blocktype, la réduire à 16 px
* *
* @param string $blocktype * @param string $blocktype Type de bloc (identifiant)
* @return string chemin * @return string chemin
**/ **/
function blocktype_find_icone_path(string $blocktype): string { function _blocktype_find_icone_path(string $blocktype): string {
static $cache; static $cache;
if (isset($cache[$blocktype])) { if (isset($cache[$blocktype])) {
return $cache[$blocktype]; return $cache[$blocktype];
...@@ -121,6 +121,19 @@ function blocktype_find_icone_path(string $blocktype): string { ...@@ -121,6 +121,19 @@ function blocktype_find_icone_path(string $blocktype): string {
return $chemin; return $chemin;
} }
/**
* Obtenir une info de la config d'un block
*
* @param string $blocktype Type de bloc (identifiant)
* @param string $config Clé de la config à retrouver
* @return string|array|null
*/
function blocktype_info(string $blocktype, string $config) {
$blocktypes = blocktypes_lister_types();
return $blocktypes[$blocktype][$config] ?? null;
}
/** /**
* Obtenir les saisies d'un block * Obtenir les saisies d'un block
* *
...@@ -143,18 +156,6 @@ function block_get_saisies(int $id_block): array { ...@@ -143,18 +156,6 @@ function block_get_saisies(int $id_block): array {
return $saisies; return $saisies;
} }
/**
* Obtenir une info de la config d'un block
*
* @param string $blocktype
* @return string|array|null
*/
function blocktype_info(string $config, string $blocktype) {
$blocktypes = blocktypes_lister_types();
return $blocktypes[$blocktype][$config] ?? null;
}
/** /**
* Retourner un tableau des valeurs saisies * Retourner un tableau des valeurs saisies
* *
...@@ -177,7 +178,7 @@ function block_get_valeurs(array $saisies, array $valeurs): array { ...@@ -177,7 +178,7 @@ function block_get_valeurs(array $saisies, array $valeurs): array {
/** /**
* Chercher le squelette correspondant à un block par son identifiant * Chercher le squelette correspondant à un block par son identifiant
* *
* @param string $blocktype Identifiant du type de block * @param string $blocktype Type de bloc (identifiant)
* @param bool $force_public Forcer une recherche du squelette public * @param bool $force_public Forcer une recherche du squelette public
* @param bool $chemin_complet Retourne le chemin complet du squelette * @param bool $chemin_complet Retourne le chemin complet du squelette
* @param bool $dist Retourne le squelette par défaut (dist)) * @param bool $dist Retourne le squelette par défaut (dist))
...@@ -266,7 +267,7 @@ function bloctypes_trouver_parents($blocktype): array { ...@@ -266,7 +267,7 @@ function bloctypes_trouver_parents($blocktype): array {
/** /**
* Calculer une liste de types de blocks enfants ou parents en fonction du rôle * Calculer une liste de types de blocks enfants ou parents en fonction du rôle
* @param string $blocktype * @param string $blocktype Type de bloc (identifiant)
* @param string $role * @param string $role
* @return array * @return array
*/ */
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter