diff --git a/TODO.md b/TODO.md index 45717dea3a1af1fb734c07655808690166d195d5..ea348f562dea609e389896a1a62c8c9eb7097ef1 100644 --- a/TODO.md +++ b/TODO.md @@ -16,8 +16,6 @@ **Technique** -[ ] Supprimer spip_blocks_liens et déplacer objet/id_objet dans spip_blocks - **UX** [ ] Saisie blocktypes : utilisation de leurs logos comme illustrations d'exemples de mise en page ? diff --git a/action/supprimer_block.php b/action/supprimer_block.php index 4a05381eaae7a9eb2d82b6d53a0b5b65c3251e64..0de4f0a81aa06e99c8a7cedf008de03d1daba9bb 100644 --- a/action/supprimer_block.php +++ b/action/supprimer_block.php @@ -37,7 +37,6 @@ function action_supprimer_block_dist($arg = null) { spip_log("SUPPRESSION block#$arg par $qui : " . json_encode($objet), "suppressions" . _LOG_INFO_IMPORTANTE); sql_delete('spip_blocks', 'id_block=' . sql_quote($arg)); - sql_delete('spip_blocks_liens', 'id_block=' . sql_quote($arg)); include_spip('action/editer_logo'); logo_supprimer('spip_blocks', $arg, 'on'); logo_supprimer('spip_blocks', $arg, 'off'); diff --git a/blocks_fonctions.php b/blocks_fonctions.php index c70872cea6dd978b3d205a03657095399d63b5bd..e62bfff7942f3bb7acf73d820d5810c76fd1ae49 100644 --- a/blocks_fonctions.php +++ b/blocks_fonctions.php @@ -140,18 +140,18 @@ function balise_GENERER_BLOCKS_dist($p) { function _block_charger_blocks($objet, $id_objet): string { $retour = ''; $where = [ - 'bl.objet = ' . sql_quote($objet), - 'bl.id_objet = ' . (int)$id_objet, + 'objet = ' . sql_quote($objet), + 'id_objet = ' . (int)$id_objet, ]; if (!test_espace_prive()) { - $where[] = 'b.statut = ' . sql_quote('publie'); + $where[] = 'statut = ' . sql_quote('publie'); } $blocks = sql_allfetsel( - 'b.id_block', - 'spip_blocks_liens bl join spip_blocks b using(id_block)', + 'id_block', + 'spip_blocks b', $where, '', - 'bl.rang_lien' + 'rang_lien' ); foreach ($blocks as $block) { $retour .= _block_charger_block($block['id_block']); @@ -169,8 +169,8 @@ function _block_charger_blocks($objet, $id_objet): string { */ function generer_TITRE_BLOCK($id_block): string { if ($infos = sql_fetsel( - 'bt.titre, bl.objet, bl.rang_lien, bl.id_objet', - 'spip_blocks b join spip_blocktypes bt using(id_blocktype) left join spip_blocks_liens bl using(id_block)', + 'bt.titre, b.objet, b.rang_lien, b.id_objet', + 'spip_blocks b join spip_blocktypes bt using(id_blocktype)', 'b.id_block = ' . (int)$id_block )) { $titre = $infos['titre']; diff --git a/formulaires/editer_block.php b/formulaires/editer_block.php index 38efc475aeb660aac63681391fc91f7d251d2111..4896f780ee93c44467ecfd0cb52785c1f235b516 100644 --- a/formulaires/editer_block.php +++ b/formulaires/editer_block.php @@ -49,7 +49,7 @@ function formulaires_editer_block_identifier_dist($id_block = 'new', $objet = nu function formulaires_editer_block_charger_dist($id_block = 'new', $objet = null, $id_objet = null, $id_blocktype_parent = null, $retour = null, $include = null) { if ((int)$id_block) { $id_blocktype = (int)sql_getfetsel('id_blocktype', 'spip_blocks', 'id_block = ' . $id_block); - $infos = sql_fetsel('id_objet, objet', 'spip_blocks_liens', 'id_block = ' . $id_block); + $infos = sql_fetsel('id_objet, objet', 'spip_blocks', 'id_block = ' . $id_block); $objet = $infos['objet']; $id_objet = $infos['id_objet']; $valeurs = formulaires_editer_objet_charger('block', $id_block, $id_blocktype, 0, $retour, ''); @@ -198,7 +198,7 @@ function formulaires_editer_block_verifier_dist($id_block = 'new', $objet = null function formulaires_editer_block_traiter_dist($id_block = 'new', $objet = null, $id_objet = null, $id_blocktype_parent = null, $retour = null, $include = null) { if ((int)$id_block) { $id_blocktype = (int)sql_getfetsel('id_blocktype', 'spip_blocks', 'id_block = ' . $id_block); - $infos = sql_fetsel('id_objet, objet', 'spip_blocks_liens', 'id_block = ' . $id_block); + $infos = sql_fetsel('id_objet, objet', 'spip_blocks', 'id_block = ' . $id_block); $objet = $infos['objet']; $id_objet = $infos['id_objet']; $creation = false; @@ -228,21 +228,24 @@ function formulaires_editer_block_traiter_dist($id_block = 'new', $objet = null, sql_updateq('spip_blocks', ['valeurs' => blocks_serialize($valeurs)], 'id_block = ' . $id_block); // associer à l'objet - if (autoriser('modifier', $objet, $id_objet)) { - include_spip('action/editer_liens'); - $qualif = []; - if ($creation) { - $rang = sql_getfetsel( - 'max(rang_lien)', - 'spip_blocks_liens', - [ - 'objet = ' . sql_quote($objet), - 'id_objet = ' . $id_objet, - ] - ); - $qualif = ['rang_lien' => $rang + 1]; - } - objet_associer(['block' => $id_block], [$objet => $id_objet], $qualif); + if ($creation) { + $rang_max = sql_getfetsel( + 'max(rang_lien)', + 'spip_blocks', + [ + 'objet = ' . sql_quote($objet), + 'id_objet = ' . $id_objet, + ] + ); + sql_updateq( + 'spip_blocks', + [ + 'id_objet' => $id_objet, + 'objet' => $objet, + 'rang_lien' => $rang_max + 1, + ], + 'id_block = ' . $id_block + ); } // un block est automatiquement publié lors de sa création diff --git a/prive/objets/liste/blocks.html b/prive/objets/liste/blocks.html index 70b6496e2c057c6197fb320d639aa8485ef77099..a88fcc87518a658199ae4528b9b4a7ef4d3b2dad 100644 --- a/prive/objets/liste/blocks.html +++ b/prive/objets/liste/blocks.html @@ -17,7 +17,7 @@ </tr> </thead> <tbody> - <BOUCLE_liste_blocks(BLOCKS){id_?}{spip_blocks_liens.objet?}{where?}{statut?}{recherche?}{tri #ENV{par,date},#GET{defaut_tri}}{!par date}{pagination #ENV{nb,10}}> + <BOUCLE_liste_blocks(BLOCKS){id_?}{objet?}{where?}{statut?}{recherche?}{tri #ENV{par,date},#GET{defaut_tri}}{!par date}{pagination #ENV{nb,10}}> <tr class="[(#COMPTEUR_BOUCLE|alterner{row_odd,row_even})]"> <td class="picto">[(#CHEMIN_IMAGE{block-16.png}|balise_img)]</td> <td class="statut">[(#STATUT|puce_statut{block,#ID_BLOCK})]</td> diff --git a/squelettes/inclure/block.html b/squelettes/inclure/block.html index 2d75d92129c41f18566dd9827f0467ceefb7a6c2..2afed635a3223718b539cf0551653b9564084c1b 100644 --- a/squelettes/inclure/block.html +++ b/squelettes/inclure/block.html @@ -1,9 +1,9 @@ -<BOUCLE(BLOCKS spip_blocks_liens){id_block}> +<BOUCLE(BLOCKS){id_block}> #SET{identifiant,#INFO_IDENTIFIANT{blocktypes,#ID_BLOCKTYPE}} #SET{squelette,#GET{identifiant}|blocks_trouver_squelette} <div class="block block--#GET{identifiant}"[ id="(#ANCRE)"]> <INCLURE{fond=#GET{squelette}, env, objet=#OBJET, id_objet=#ID_OBJET}> - <BOUCLE(spip_blocks_liens){objet=block}{id_objet=#ID_BLOCK}{si #ENV{racine}|non}> + <BOUCLE(BLOCKS){objet=block}{id_objet=#ID_BLOCK}{si #ENV{racine}|non}> #SET{contexte, #INFO_SAISIES{blocktype,#ID_BLOCKTYPE}|block_get_valeurs{#INFO_VALEURS{block,#ID_BLOCK}}} [(#VAL{inclure/block}|recuperer_fond{ #ARRAY{id_block,#ID_BLOCK}|array_merge{#GET{contexte}}