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

Ajax sur controle_perition (==> #587). Mais il faudrait partager ce code...

Ajax sur controle_perition (==> #587). Mais il faudrait partager ce code ajaxant avec celui de la page du controleur des forums, et ajaxer cet ajaxeur qui est lui meme souvent trop gros (dépasser le millier de signatures est fréquent, la réduction à cent liens est insuffisante).
parent 78bc9969
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -41,7 +41,7 @@ function action_editer_signatures_post($r) ...@@ -41,7 +41,7 @@ function action_editer_signatures_post($r)
$result_forum = spip_query("UPDATE spip_signatures SET statut='publie' WHERE id_signature=$id"); $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 // Invalider les pages ayant trait aux petitions
if ($id) { if ($id) {
include_spip('inc/invalideur'); include_spip('inc/invalideur');
......
...@@ -23,31 +23,30 @@ function exec_controle_petition_dist() ...@@ -23,31 +23,30 @@ function exec_controle_petition_dist()
$id_article = intval($id_article); $id_article = intval($id_article);
$debut = intval($debut); $debut = intval($debut);
debut_page(_T('titre_page_controle_petition'), "forum", "suivi-petition"); if ($connect_statut != "0minirezo") {
debut_gauche(); $r = "<b>"._T('avis_non_acces_page')."</b>";
} else {
debut_droite();
echo "<div class='serif2'>";
if ($connect_statut == "0minirezo") {
gros_titre(_T('titre_suivi_petition'));
$var_f = charger_fonction('signatures', 'inc'); $var_f = charger_fonction('signatures', 'inc');
$var_f('controle_petition',
$r = $var_f('controle_petition',
$id_article, $id_article,
$debut, $debut,
"(statut='publie' OR statut='poubelle')", "(statut='publie' OR statut='poubelle')",
"date_time DESC", "date_time DESC",
10); 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();
} }
?> ?>
...@@ -23,14 +23,52 @@ function message_de_signature($row) ...@@ -23,14 +23,52 @@ function message_de_signature($row)
// http://doc.spip.org/@controle_signatures // http://doc.spip.org/@controle_signatures
function inc_signatures_dist($script, $id, $debut, $where, $order, $limit='') { 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 = (!$limit AND !$debut) ? '' : (($debut ? "$debut," : "") . $limit);
# ($limit . ($debut ? " OFFSET $debut" : "")); #PG # ($limit . ($debut ? " OFFSET $debut" : "")); #PG
$request = spip_query("SELECT * FROM spip_signatures " . ($where ? " WHERE $where" : "") . ($order ? " ORDER BY $order" : "") . (!$limit ? '' : " LIMIT $limit")); $request = spip_query("SELECT * FROM spip_signatures " . ($where ? " WHERE $where" : "") . ($order ? " ORDER BY $order" : "") . (!$limit ? '' : " LIMIT $limit"));
while($row=spip_fetch_array($request)){ 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_signature = $row['id_signature'];
$id_article = $row['id_article']; $id_article = $row['id_article'];
$date_time = $row['date_time']; $date_time = $row['date_time'];
...@@ -40,94 +78,69 @@ function inc_signatures_dist($script, $id, $debut, $where, $order, $limit='') { ...@@ -40,94 +78,69 @@ function inc_signatures_dist($script, $id, $debut, $where, $order, $limit='') {
$url_site = echapper_tags($row['url_site']); $url_site = echapper_tags($row['url_site']);
$statut = $row['statut']; $statut = $row['statut'];
echo "<p>"; $arg = ($statut=="publie") ? "-$id_signature" : $id_signature;
$res = "";
if ($statut=="poubelle"){ 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>", $res .= "<table width='100%' cellpadding='3' cellspacing='0'><tr><td bgcolor='$couleur_foncee' class='verdana2' style='color: white;'><b>"
($nom_site ? "$nom_site / " : ""), . ($nom_site ? "$nom_site / " : "")
$nom_email, . $nom_email
"</b></td></tr>", . "</b></td></tr>"
"<tr><td bgcolor='#FFFFFF' class='serif'>"; . "<tr><td bgcolor='#FFFFFF' class='serif'>";
if ($statut=="publie"){ if ($statut=="publie"){
icone (_T('icone_supprimer_signature'), $res .= icone (_T('icone_supprimer_signature'),
redirige_action_auteur('editer_signatures', "-$id_signature", $script, "id_article=$id&debut=$debut"), redirige_action_auteur('editer_signatures', $arg, $script, "id_article=$id&debut=$debut"),
"forum-interne-24.gif", "forum-interne-24.gif",
"supprimer.gif", "supprimer.gif",
"right"); "right",
} false);
if ($statut=="poubelle"){ } elseif ($statut=="poubelle"){
icone (_T('icone_valider_signature'), $res .= icone (_T('icone_valider_signature'),
redirige_action_auteur('editer_signatures', $id_signature, $script, "id_article=$id&debut=$debut"), redirige_action_auteur('editer_signatures', $arg, $script, "id_article=$id&debut=$debut"),
"forum-interne-24.gif", "forum-interne-24.gif",
"creer.gif", "creer.gif",
"right"); "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"){ 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){ 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){ 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")); $titre = spip_fetch_array(spip_query("SELECT titre FROM spip_articles WHERE id_article=$id_article"));
if (!$id) if (!$id)
echo "<span class='arial1' style='float: $spip_lang_right; color: black; padding-$spip_lang_left: 4px;'><b>", $res .= "<span class='arial1' style='float: $spip_lang_right; color: black; padding-$spip_lang_left: 4px;'><b>"
_T('info_numero_abbreviation'), . _T('info_numero_abbreviation')
$id_article, . $id_article
" </b></span>"; . " </b></span>";
echo "<a href='", $res .= "<a href='"
(($statut == 'publie') ? . (($statut == 'publie') ?
generer_url_action('redirect', "id_article=$id_article") : generer_url_action('redirect', "id_article=$id_article") :
generer_url_ecrire('articles', "id_article=$id_article")), generer_url_ecrire('articles', "id_article=$id_article"))
"'>", . "'>"
typo($titre['titre']), . typo($titre['titre'])
"</a>"; . "</a>"
. "</td></tr></table>";
echo "</td></tr></table>";
if ($statut=="poubelle"){ 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)) { return "<p>$res</p>";
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;
} }
?> ?>
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