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

fix: Toujours charger le block, même sans saisie ou valeurs

parent 2957790f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -52,77 +52,74 @@ function balise_GENERER_BLOCK_dist($p) { ...@@ -52,77 +52,74 @@ function balise_GENERER_BLOCK_dist($p) {
* @return string * @return string
*/ */
function _block_charger_block(int $id_block): string { function _block_charger_block(int $id_block): string {
$html = '';
$where = ['id_block = ' . $id_block]; $where = ['id_block = ' . $id_block];
if (!test_espace_prive()) { if (!test_espace_prive()) {
$where[] = 'statut = ' . sql_quote('publie'); $where[] = 'statut = ' . sql_quote('publie');
} }
$saisies = block_get_saisies($id_block); $saisies = block_get_saisies($id_block);
$valeurs = blocks_deserialize(sql_getfetsel('valeurs', 'spip_blocks', $where)); $valeurs = blocks_deserialize(sql_getfetsel('valeurs', 'spip_blocks', $where));
if ($saisies && $valeurs) {
$contexte = array_merge(
[
'id_block' => $id_block,
],
block_get_valeurs($saisies, $valeurs)
);
$html = recuperer_fond('inclure/block', $contexte); $contexte = array_merge(
[
if ($blocs_enfants = sql_allfetsel( 'id_block' => $id_block,
'id_block, blocktype, valeurs', ],
'spip_blocks', block_get_valeurs($saisies, $valeurs ?? [])
'objet="block" and id_objet = ' . $id_block );
)) {
$html_enfants = ''; $html = recuperer_fond('inclure/block', $contexte);
foreach ($blocs_enfants as $bloc_enfant) {
$contexte = array_merge(
[
'id_block' => $bloc_enfant['id_block'],
],
block_get_valeurs(
blocktype_info($bloc_enfant['blocktype'], 'saisies'),
blocks_deserialize($bloc_enfant['valeurs'])
)
);
if (test_espace_prive()) {
$squelette = 'prive/squelettes/inclure/block_objet';
$recuperer_fond_options = ['ajax' => 'block-' . $bloc_enfant['id_block']];
} else {
$squelette = 'inclure/block';
$recuperer_fond_options = [];
}
$html_enfants .= recuperer_fond(
$squelette,
$contexte,
$recuperer_fond_options
);
}
if (str_contains($html, '<!--blocks-->')) {
$html = str_replace('<!--blocks-->', $html_enfants, $html);
} else {
$html .= $html_enfants;
}
}
// Ajouter un block if ($blocs_enfants = sql_allfetsel(
if (test_espace_prive() && bloctype_trouver_enfants(block_get_blocktype($id_block))) { 'id_block, blocktype, valeurs',
$html .= recuperer_fond( 'spip_blocks',
'prive/squelettes/inclure/block_objet', 'objet="block" and id_objet = ' . $id_block
)) {
$html_enfants = '';
foreach ($blocs_enfants as $bloc_enfant) {
$contexte = array_merge(
[ [
'objet' => 'block', 'id_block' => $bloc_enfant['id_block'],
'id_objet' => $id_block,
// 'id_block' => 'new',
'blocktype_parent' => block_get_blocktype($id_block),
'edit_bloc' => 1,
], ],
[ block_get_valeurs(
'ajax' => 'new_block-' . $id_block, blocktype_info($bloc_enfant['blocktype'], 'saisies'),
] blocks_deserialize($bloc_enfant['valeurs']) ?? []
)
);
if (test_espace_prive()) {
$squelette = 'prive/squelettes/inclure/block_objet';
$recuperer_fond_options = ['ajax' => 'block-' . $bloc_enfant['id_block']];
} else {
$squelette = 'inclure/block';
$recuperer_fond_options = [];
}
$html_enfants .= recuperer_fond(
$squelette,
$contexte,
$recuperer_fond_options
); );
} }
if (str_contains($html, '<!--blocks-->')) {
$html = str_replace('<!--blocks-->', $html_enfants, $html);
} else {
$html .= $html_enfants;
}
}
//} // Ajouter un block
if (test_espace_prive() && bloctype_trouver_enfants(block_get_blocktype($id_block))) {
$html .= recuperer_fond(
'prive/squelettes/inclure/block_objet',
[
'objet' => 'block',
'id_objet' => $id_block,
// 'id_block' => 'new',
'blocktype_parent' => block_get_blocktype($id_block),
'edit_bloc' => 1,
],
[
'ajax' => 'new_block-' . $id_block,
]
);
}
return $html; return $html;
} }
......
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