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

On utilise directement spip_blocks maintenant

parent 8fdfb66d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
**Technique** **Technique**
[ ] Supprimer spip_blocks_liens et déplacer objet/id_objet dans spip_blocks
**UX** **UX**
[ ] Saisie blocktypes : utilisation de leurs logos comme illustrations d'exemples de mise en page ? [ ] Saisie blocktypes : utilisation de leurs logos comme illustrations d'exemples de mise en page ?
......
...@@ -37,7 +37,6 @@ function action_supprimer_block_dist($arg = null) { ...@@ -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); 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', 'id_block=' . sql_quote($arg));
sql_delete('spip_blocks_liens', 'id_block=' . sql_quote($arg));
include_spip('action/editer_logo'); include_spip('action/editer_logo');
logo_supprimer('spip_blocks', $arg, 'on'); logo_supprimer('spip_blocks', $arg, 'on');
logo_supprimer('spip_blocks', $arg, 'off'); logo_supprimer('spip_blocks', $arg, 'off');
......
...@@ -140,18 +140,18 @@ function balise_GENERER_BLOCKS_dist($p) { ...@@ -140,18 +140,18 @@ function balise_GENERER_BLOCKS_dist($p) {
function _block_charger_blocks($objet, $id_objet): string { function _block_charger_blocks($objet, $id_objet): string {
$retour = ''; $retour = '';
$where = [ $where = [
'bl.objet = ' . sql_quote($objet), 'objet = ' . sql_quote($objet),
'bl.id_objet = ' . (int)$id_objet, 'id_objet = ' . (int)$id_objet,
]; ];
if (!test_espace_prive()) { if (!test_espace_prive()) {
$where[] = 'b.statut = ' . sql_quote('publie'); $where[] = 'statut = ' . sql_quote('publie');
} }
$blocks = sql_allfetsel( $blocks = sql_allfetsel(
'b.id_block', 'id_block',
'spip_blocks_liens bl join spip_blocks b using(id_block)', 'spip_blocks b',
$where, $where,
'', '',
'bl.rang_lien' 'rang_lien'
); );
foreach ($blocks as $block) { foreach ($blocks as $block) {
$retour .= _block_charger_block($block['id_block']); $retour .= _block_charger_block($block['id_block']);
...@@ -169,8 +169,8 @@ function _block_charger_blocks($objet, $id_objet): string { ...@@ -169,8 +169,8 @@ function _block_charger_blocks($objet, $id_objet): string {
*/ */
function generer_TITRE_BLOCK($id_block): string { function generer_TITRE_BLOCK($id_block): string {
if ($infos = sql_fetsel( if ($infos = sql_fetsel(
'bt.titre, bl.objet, bl.rang_lien, bl.id_objet', 'bt.titre, b.objet, b.rang_lien, b.id_objet',
'spip_blocks b join spip_blocktypes bt using(id_blocktype) left join spip_blocks_liens bl using(id_block)', 'spip_blocks b join spip_blocktypes bt using(id_blocktype)',
'b.id_block = ' . (int)$id_block 'b.id_block = ' . (int)$id_block
)) { )) {
$titre = $infos['titre']; $titre = $infos['titre'];
......
...@@ -49,7 +49,7 @@ function formulaires_editer_block_identifier_dist($id_block = 'new', $objet = nu ...@@ -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) { 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) { if ((int)$id_block) {
$id_blocktype = (int)sql_getfetsel('id_blocktype', 'spip_blocks', 'id_block = ' . $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']; $objet = $infos['objet'];
$id_objet = $infos['id_objet']; $id_objet = $infos['id_objet'];
$valeurs = formulaires_editer_objet_charger('block', $id_block, $id_blocktype, 0, $retour, ''); $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 ...@@ -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) { 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) { if ((int)$id_block) {
$id_blocktype = (int)sql_getfetsel('id_blocktype', 'spip_blocks', 'id_block = ' . $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']; $objet = $infos['objet'];
$id_objet = $infos['id_objet']; $id_objet = $infos['id_objet'];
$creation = false; $creation = false;
...@@ -228,21 +228,24 @@ function formulaires_editer_block_traiter_dist($id_block = 'new', $objet = null, ...@@ -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); sql_updateq('spip_blocks', ['valeurs' => blocks_serialize($valeurs)], 'id_block = ' . $id_block);
// associer à l'objet // associer à l'objet
if (autoriser('modifier', $objet, $id_objet)) { if ($creation) {
include_spip('action/editer_liens'); $rang_max = sql_getfetsel(
$qualif = []; 'max(rang_lien)',
if ($creation) { 'spip_blocks',
$rang = sql_getfetsel( [
'max(rang_lien)', 'objet = ' . sql_quote($objet),
'spip_blocks_liens', 'id_objet = ' . $id_objet,
[ ]
'objet = ' . sql_quote($objet), );
'id_objet = ' . $id_objet, sql_updateq(
] 'spip_blocks',
); [
$qualif = ['rang_lien' => $rang + 1]; 'id_objet' => $id_objet,
} 'objet' => $objet,
objet_associer(['block' => $id_block], [$objet => $id_objet], $qualif); 'rang_lien' => $rang_max + 1,
],
'id_block = ' . $id_block
);
} }
// un block est automatiquement publié lors de sa création // un block est automatiquement publié lors de sa création
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <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})]"> <tr class="[(#COMPTEUR_BOUCLE|alterner{row_odd,row_even})]">
<td class="picto">[(#CHEMIN_IMAGE{block-16.png}|balise_img)]</td> <td class="picto">[(#CHEMIN_IMAGE{block-16.png}|balise_img)]</td>
<td class="statut">[(#STATUT|puce_statut{block,#ID_BLOCK})]</td> <td class="statut">[(#STATUT|puce_statut{block,#ID_BLOCK})]</td>
......
<BOUCLE(BLOCKS spip_blocks_liens){id_block}> <BOUCLE(BLOCKS){id_block}>
#SET{identifiant,#INFO_IDENTIFIANT{blocktypes,#ID_BLOCKTYPE}} #SET{identifiant,#INFO_IDENTIFIANT{blocktypes,#ID_BLOCKTYPE}}
#SET{squelette,#GET{identifiant}|blocks_trouver_squelette} #SET{squelette,#GET{identifiant}|blocks_trouver_squelette}
<div class="block block--#GET{identifiant}"[ id="(#ANCRE)"]> <div class="block block--#GET{identifiant}"[ id="(#ANCRE)"]>
<INCLURE{fond=#GET{squelette}, env, objet=#OBJET, id_objet=#ID_OBJET}> <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}}} #SET{contexte, #INFO_SAISIES{blocktype,#ID_BLOCKTYPE}|block_get_valeurs{#INFO_VALEURS{block,#ID_BLOCK}}}
[(#VAL{inclure/block}|recuperer_fond{ [(#VAL{inclure/block}|recuperer_fond{
#ARRAY{id_block,#ID_BLOCK}|array_merge{#GET{contexte}} #ARRAY{id_block,#ID_BLOCK}|array_merge{#GET{contexte}}
......
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