From c60a3ac417fb35b0a07ce1b8aca80e0d3b737ab4 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Wed, 25 Oct 2006 10:37:39 +0000 Subject: [PATCH] =?UTF-8?q?Ajax=20sur=20controle=5Fperition=20(=3D=3D>=20#?= =?UTF-8?q?587).=20Mais=20il=20faudrait=20partager=20ce=20code=20ajaxant?= =?UTF-8?q?=20avec=20celui=20de=20la=20page=20du=20controleur=20des=20foru?= =?UTF-8?q?ms,=20et=20ajaxer=20cet=20ajaxeur=20qui=20est=20lui=20meme=20so?= =?UTF-8?q?uvent=20trop=20gros=20(d=C3=A9passer=20le=20millier=20de=20sign?= =?UTF-8?q?atures=20est=20fr=C3=A9quent,=20la=20r=C3=A9duction=20=C3=A0=20?= =?UTF-8?q?cent=20liens=20est=20insuffisante).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/action/editer_signatures.php | 2 +- ecrire/exec/controle_petition.php | 29 +++--- ecrire/inc/signatures.php | 145 +++++++++++++++------------- 3 files changed, 94 insertions(+), 82 deletions(-) diff --git a/ecrire/action/editer_signatures.php b/ecrire/action/editer_signatures.php index fd97dccfb5..9cbcc8d930 100644 --- a/ecrire/action/editer_signatures.php +++ b/ecrire/action/editer_signatures.php @@ -41,7 +41,7 @@ function action_editer_signatures_post($r) $result_forum = spip_query("UPDATE spip_signatures SET statut='publie' WHERE id_signature=$id"); } -spip_log("action_editer_signature_dist $id maj"); + // Invalider les pages ayant trait aux petitions if ($id) { include_spip('inc/invalideur'); diff --git a/ecrire/exec/controle_petition.php b/ecrire/exec/controle_petition.php index 874043c098..b35c5bf62b 100644 --- a/ecrire/exec/controle_petition.php +++ b/ecrire/exec/controle_petition.php @@ -23,31 +23,30 @@ function exec_controle_petition_dist() $id_article = intval($id_article); $debut = intval($debut); - debut_page(_T('titre_page_controle_petition'), "forum", "suivi-petition"); - debut_gauche(); - - debut_droite(); - - echo "<div class='serif2'>"; - - if ($connect_statut == "0minirezo") { - gros_titre(_T('titre_suivi_petition')); - + if ($connect_statut != "0minirezo") { + $r = "<b>"._T('avis_non_acces_page')."</b>"; + } else { $var_f = charger_fonction('signatures', 'inc'); - $var_f('controle_petition', + + $r = $var_f('controle_petition', $id_article, $debut, "(statut='publie' OR statut='poubelle')", "date_time DESC", 10); - } else { - echo "<b>"._T('avis_non_acces_page')."</b>"; } + if (_request('var_ajaxcharset')) ajax_retour($r); - echo "</div>"; + debut_page(_T('titre_page_controle_petition'), "forum", "suivi-petition"); + debut_gauche(); + + debut_droite(); + + gros_titre(_T('titre_suivi_petition')); - echo fin_page(); + $a = "editer_signature-" . $id_article; + echo "<div id='", $a, "' class='serif2'>", $r, "</div>", fin_page(); } ?> diff --git a/ecrire/inc/signatures.php b/ecrire/inc/signatures.php index 1716da9092..4ff02fa27c 100644 --- a/ecrire/inc/signatures.php +++ b/ecrire/inc/signatures.php @@ -23,14 +23,52 @@ function message_de_signature($row) // http://doc.spip.org/@controle_signatures function inc_signatures_dist($script, $id, $debut, $where, $order, $limit='') { - global $couleur_foncee; - $where = tronconne_signatures($script, $id, $debut, $where, $limit); + # filtre de duree (a remplacer par une vraie pagination) + #$where .= ($where ? " AND " : "") . "date_time>DATE_SUB(NOW(),INTERVAL 180 DAY)"; + if ($id_article) { + $args = "id_article=$id_article&"; + $where .= " AND id_article=$id_article"; + } + else $args = ""; + + $evt = (isset($_COOKIE['spip_accepte_ajax']) AND ($_COOKIE['spip_accepte_ajax'] == 1)); + + $a = "editer_signature-$id"; + + $q = spip_query("SELECT date_time FROM spip_signatures " . ($where ? "WHERE $where" : '') . " ORDER BY date_time DESC"); + + spip_log("sig $evt"); + while ($row = spip_fetch_array($q)) { + if($c++%$limit==0) { + if ($c > 1) $res .= " | "; + $date = (affdate_court($row['date_time'])); + if ($c == ($debut+1)) + $res .= "<font size='3'><b>$c</b></font>"; + else { + $h = generer_url_ecrire($script, $args ."debut=".($c-1)); + if ($evt) + $evt = "\nonclick=" + . ajax_action_declencheur($h,$a); + $res .= http_href("$h$a", $c, $date, '', '', $evt); + } + } + } + $limit = (!$limit AND !$debut) ? '' : (($debut ? "$debut," : "") . $limit); # ($limit . ($debut ? " OFFSET $debut" : "")); #PG $request = spip_query("SELECT * FROM spip_signatures " . ($where ? " WHERE $where" : "") . ($order ? " ORDER BY $order" : "") . (!$limit ? '' : " LIMIT $limit")); while($row=spip_fetch_array($request)){ + $res .= signatures_edit($script, $id, $debut, $row); + } + return $res; +} + +function signatures_edit($script, $id, $debut, $row) { + + global $couleur_foncee; + $id_signature = $row['id_signature']; $id_article = $row['id_article']; $date_time = $row['date_time']; @@ -40,94 +78,69 @@ function inc_signatures_dist($script, $id, $debut, $where, $order, $limit='') { $url_site = echapper_tags($row['url_site']); $statut = $row['statut']; - echo "<p>"; + $arg = ($statut=="publie") ? "-$id_signature" : $id_signature; + $res = ""; if ($statut=="poubelle"){ - echo "<table width='100%' cellpadding='2' cellspacing='0' border='0'><tr><td bgcolor='#FF0000'>"; + $res .= "<table width='100%' cellpadding='2' cellspacing='0' border='0'><tr><td bgcolor='#FF0000'>"; } - echo "<Table width='100%' cellpadding='3' cellspacing='0'><tr><td bgcolor='$couleur_foncee' class='verdana2' style='color: white;'><b>", - ($nom_site ? "$nom_site / " : ""), - $nom_email, - "</b></td></tr>", - "<tr><td bgcolor='#FFFFFF' class='serif'>"; + $res .= "<table width='100%' cellpadding='3' cellspacing='0'><tr><td bgcolor='$couleur_foncee' class='verdana2' style='color: white;'><b>" + . ($nom_site ? "$nom_site / " : "") + . $nom_email + . "</b></td></tr>" + . "<tr><td bgcolor='#FFFFFF' class='serif'>"; if ($statut=="publie"){ - icone (_T('icone_supprimer_signature'), - redirige_action_auteur('editer_signatures', "-$id_signature", $script, "id_article=$id&debut=$debut"), - "forum-interne-24.gif", - "supprimer.gif", - "right"); - } - if ($statut=="poubelle"){ - icone (_T('icone_valider_signature'), - redirige_action_auteur('editer_signatures', $id_signature, $script, "id_article=$id&debut=$debut"), - "forum-interne-24.gif", - "creer.gif", - "right"); + $res .= icone (_T('icone_supprimer_signature'), + redirige_action_auteur('editer_signatures', $arg, $script, "id_article=$id&debut=$debut"), + "forum-interne-24.gif", + "supprimer.gif", + "right", + false); + } elseif ($statut=="poubelle"){ + $res .= icone (_T('icone_valider_signature'), + redirige_action_auteur('editer_signatures', $arg, $script, "id_article=$id&debut=$debut"), + "forum-interne-24.gif", + "creer.gif", + "right", + false); } - echo "<font size='2'>".date_interface($date_time)."</font><br />"; + $res .= "<font size='2'>".date_interface($date_time)."</font><br />"; if ($statut=="poubelle"){ - echo "<font size='1' color='red'>"._T('info_message_efface')."</font><br />"; + $res .= "<font size='1' color='red'>"._T('info_message_efface')."</font><br />"; } if (strlen($url_site)>6 AND strlen($nom_site)>0){ - echo "<font size='1'>"._T('info_site_web')."</font> <a href='$url_site'>$nom_site</a><br />"; + $res .= "<font size='1'>"._T('info_site_web')."</font> <a href='$url_site'>$nom_site</a><br />"; } if (strlen($ad_email)>0){ - echo "<font size='1'>"._T('info_adresse_email')."</font> <a href='mailto:$ad_email'>$ad_email</a><br />"; + $res .= "<font size='1'>"._T('info_adresse_email')."</font> <a href='mailto:$ad_email'>$ad_email</a><br />"; } - echo "<p>",message_de_signature($row),"</p>"; + $res .= "<p>" . message_de_signature($row) ."</p>"; $titre = spip_fetch_array(spip_query("SELECT titre FROM spip_articles WHERE id_article=$id_article")); if (!$id) - echo "<span class='arial1' style='float: $spip_lang_right; color: black; padding-$spip_lang_left: 4px;'><b>", - _T('info_numero_abbreviation'), - $id_article, - " </b></span>"; + $res .= "<span class='arial1' style='float: $spip_lang_right; color: black; padding-$spip_lang_left: 4px;'><b>" + . _T('info_numero_abbreviation') + . $id_article + . " </b></span>"; - echo "<a href='", - (($statut == 'publie') ? + $res .= "<a href='" + . (($statut == 'publie') ? generer_url_action('redirect', "id_article=$id_article") : - generer_url_ecrire('articles', "id_article=$id_article")), - "'>", - typo($titre['titre']), - "</a>"; - - echo "</td></tr></table>"; + generer_url_ecrire('articles', "id_article=$id_article")) + . "'>" + . typo($titre['titre']) + . "</a>" + . "</td></tr></table>"; if ($statut=="poubelle"){ - echo "</td></tr></table>"; + $res .= "</td></tr></table>"; } - } -} - -// http://doc.spip.org/@tronconne_signatures -function tronconne_signatures($script, $id_article, $debut, $where, $limit=10) -{ - # filtre de duree (a remplacer par une vraie pagination) - #$where .= ($where ? " AND " : "") . "date_time>DATE_SUB(NOW(),INTERVAL 180 DAY)"; - if ($id_article) { - $args = "id_article=$id_article&"; - $where .= " AND id_article=$id_article"; - } - else $args = ""; - - $res = spip_query("SELECT date_time FROM spip_signatures " . ($where ? "WHERE $where" : '') . " ORDER BY date_time DESC"); - while ($row = spip_fetch_array($res)) { - if($c++%$limit==0) { - if ($c > 1) echo " | "; - $date = entites_html(affdate_court($row['date_time'])); - if ($c == ($debut+1)) - echo "<font size='3'><b>$c</b></font>"; - else - echo "<a alt=\"$date\" title=\"$date\" href='", generer_url_ecrire($script, $args ."debut=".($c-1)), "'>$c</a>"; - } - } - return $where; + return "<p>$res</p>"; } - ?> -- GitLab