diff --git a/.gitattributes b/.gitattributes index 5a6ce964c5b7a6d472a195e6c079194a2ce3ecd4..7db8aa9f277b5837347e3ad97af1058789222485 100644 --- a/.gitattributes +++ b/.gitattributes @@ -100,6 +100,7 @@ ecrire/exec/controle_petition.php -text ecrire/exec/convert_utf8.php -text ecrire/exec/dater.php -text ecrire/exec/delete_all.php -text +ecrire/exec/discuter.php -text ecrire/exec/documenter.php -text ecrire/exec/documents_liste.php -text ecrire/exec/editer_mot.php -text diff --git a/ecrire/exec/articles.php b/ecrire/exec/articles.php index d9b64746a4dfb301e53ddff75eb5e62f70778d42..d5f52405bcfcc44f7e98fa1d345d0b25f8209288 100644 --- a/ecrire/exec/articles.php +++ b/ecrire/exec/articles.php @@ -18,9 +18,9 @@ include_spip('inc/rubriques'); include_spip('inc/mots'); include_spip('inc/date'); include_spip('inc/documents'); -include_spip('inc/forum'); include_spip('inc/petition'); include_spip('exec/virtualiser'); +include_spip('exec/discuter'); include_spip('base/abstract_sql'); // http://doc.spip.org/@exec_articles_dist @@ -270,9 +270,16 @@ if ($flag_editable) { echo "</div>"; fin_cadre_relief(); - affiche_forums_article($id_article, $id_rubrique, $titre, $debut); + echo "<br /><br />"; + + $tm = rawurlencode($titre); + echo "\n<div align='center'>"; + icone(_T('icone_poster_message'), generer_url_ecrire("forum_envoi","statut=prive&id_article=$id_article&titre_message=$tm&url=" . generer_url_retour("articles","id_article=$id_article")), "forum-interne-24.gif", "creer.gif"); + echo "</div><br />"; + + echo exec_discuter_dist($id_article, $debut); -fin_page(); + fin_page(); } @@ -1033,62 +1040,6 @@ function afficher_corps_articles($virtuel, $chapo, $texte, $ps, $extra) } } -// http://doc.spip.org/@affiche_forums_article -function affiche_forums_article($id_article, $id_rubrique, $titre, $debut, $mute=false) -{ - global $spip_lang_left; - - echo "<br /><br />"; - - if (!$mute) { - $tm = rawurlencode($titre); - echo "\n<div align='center'>"; - icone(_T('icone_poster_message'), generer_url_ecrire("forum_envoi","statut=prive&id_article=$id_article&titre_message=$tm&url=" . generer_url_retour("articles","id_article=$id_article")), "forum-interne-24.gif", "creer.gif"); - echo "</div>"; - } - - echo "<p align='$spip_lang_left'>"; - - $row = spip_fetch_array(spip_query("SELECT COUNT(*) AS cnt FROM spip_forum WHERE statut='prive' AND id_article='$id_article' AND id_parent=0")); - - $total = $row ? $row["cnt"] : 0; - - if (!$debut) $debut = 0; - $total_afficher = 8; - if ($total > $total_afficher) { - echo "<div class='serif2' align='center'>"; - for ($i = 0; $i < $total; $i = $i + $total_afficher){ - $y = $i + $total_afficher - 1; - if ($i == $debut) - echo "<font size='3'><b>[$i-$y]</b></font> "; - else - echo "[<a href='" . generer_url_ecrire("articles","id_article=$id_article&debut=$i") . "'>$i-$y</a>] "; - } - echo "</div>"; -} - - $result_forum = spip_query("SELECT * FROM spip_forum WHERE statut='prive' AND id_article='$id_article' AND id_parent=0 ORDER BY date_heure DESC" . " LIMIT $debut,$total_afficher" ); -# " LIMIT $total_afficher OFFSET $debut" # PG - - afficher_forum($result_forum, "articles","id_article=$id_article", $mute); - - if (!$debut) $debut = 0; - $total_afficher = 8; - if ($total > $total_afficher) { - echo "<div class='serif2' align='center'>"; - for ($i = 0; $i < $total; $i = $i + $total_afficher){ - $y = $i + $total_afficher - 1; - if ($i == $debut) - echo "<FONT SIZE=3><B>[$i-$y]</B></FONT> "; - else - echo "[<A href='" . generer_url_ecrire("articles","id_article=$id_article&debut=$i") . "'>$i-$y</A>] "; - } - echo "</div>"; - } - - echo "</div>\n"; -} - // http://doc.spip.org/@formulaire_instituer_article function formulaire_instituer_article($id_article, $statut, $script, $args) { diff --git a/ecrire/exec/articles_forum.php b/ecrire/exec/articles_forum.php index ce0f8fdeaa57328eb4f34b701597381deeab9850..39bdb0bd1db5a2c00f5736cc9fc8211f278f588f 100644 --- a/ecrire/exec/articles_forum.php +++ b/ecrire/exec/articles_forum.php @@ -53,7 +53,7 @@ function exec_articles_forum_dist() $res = spip_query("SELECT pied.*, max(thread.date_heure) AS date FROM spip_forum AS pied, spip_forum AS thread WHERE pied.id_article='$id_article' AND pied.id_parent=0 AND pied.statut IN ('publie', 'off', 'prop') AND thread.id_thread=pied.id_forum GROUP BY id_thread ORDER BY date DESC LIMIT $debut, $pack"); - afficher_forum($res,"", '', $id_article); + echo afficher_forum($res,"", '', $id_article); fin_page(); } diff --git a/ecrire/exec/breves_voir.php b/ecrire/exec/breves_voir.php index a24152a7d37881a6624ceffa293453431e5300ed..2ab58ffebaa0d56c4e7b78e325dcaaee19579e39 100644 --- a/ecrire/exec/breves_voir.php +++ b/ecrire/exec/breves_voir.php @@ -222,18 +222,16 @@ fin_cadre_relief(); $tm = rawurlencode($titre); -echo "<BR><BR>"; + echo "<br /><br />"; -echo "\n<div align='center'>"; + echo "\n<div align='center'>"; icone(_T('icone_poster_message'), generer_url_ecrire("forum_envoi", "statut=prive&id_breve=$id_breve&titre_message=$tm&url=".generer_url_retour("breves_voir", "id_breve=$id_breve")), "forum-interne-24.gif", "creer.gif"); -echo "</div>"; + echo "</div>"; + echo "<br />"; -echo "<P align='left'>"; - - - afficher_forum(spip_query("SELECT * FROM spip_forum WHERE statut='prive' AND id_breve='$id_breve' AND id_parent=0 ORDER BY date_heure DESC LIMIT 20"), "breves_voir", "id_breve=$id_breve"); + echo afficher_forum(spip_query("SELECT * FROM spip_forum WHERE statut='prive' AND id_breve='$id_breve' AND id_parent=0 ORDER BY date_heure DESC LIMIT 20"), "breves_voir", "id_breve=$id_breve"); fin_page(); } diff --git a/ecrire/exec/calendrier.php b/ecrire/exec/calendrier.php index 46ea7bd53c7a7e898ef65b96b69b38c74945d1e9..b93a5421b69263a293cac864d7ca26a4a8ba3cd9 100644 --- a/ecrire/exec/calendrier.php +++ b/ecrire/exec/calendrier.php @@ -44,7 +44,7 @@ function exec_calendrier_dist() $r = http_calendrier_init('', $type, '','',generer_url_ecrire('calendrier', ($type ? "type=$type" : '')) . "#$ancre"); - if (_request(var_ajax)) return $r; + if (_request('var_ajax')) return $r; debut_page($titre, "accueil", "calendrier","",$css); echo "<div> </div><div id='", $ancre, "'>",$r,'</div>'; diff --git a/ecrire/exec/discuter.php b/ecrire/exec/discuter.php new file mode 100644 index 0000000000000000000000000000000000000000..f5fea02fce45fdee1bcfb8e91d8451adf46df22f --- /dev/null +++ b/ecrire/exec/discuter.php @@ -0,0 +1,71 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2006 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + +include_spip('inc/forum'); +include_spip('inc/presentation'); + +// http://doc.spip.org/@affiche_forums_article +function formulaire_discuter($query, $total, $debut, $total_afficher, $script, $args, $mute=false) +{ + $res = $nav =''; + if ($total > $total_afficher) { + $nav = "<div class='serif2' align='center'>"; + for ($i = 0; $i < $total; $i = $i + $total_afficher){ + $y = $i + $total_afficher - 1; + if ($i == $debut) + $nav .= "<font size='3'><b>[$i-$y]</b></font> "; + else { + if ($_COOKIE['spip_accepte_ajax'] != 1 ) { + $h = generer_url_ecrire($script, "$args&debut=$i"); + $nav .= "[<a href='$h#forum'>$i-$y</a>] "; + } else { + $h = generer_url_ecrire('discuter', "$args&debut=$i&var_ajax=1#forum"); + $nav .= "[<span\nonclick='AjaxSqueeze(\"$h\",\n\t\"forum\")'>$i-$y</span>] "; + } + } + } + $nav .= "</div>"; + } + + $res = $nav + . afficher_forum($query, $script, $args, $mute) + . "<br />" + . $nav; + + return (_request('var_ajax')) ? $res : "<div id='forum'>$res</div>"; +} + +function exec_discuter_dist($id_article=-1, $debut=-1) +{ + if ($debut == -1) $debut = _request('debut'); + if ($id_article == -1) $id_article = _request('id_article'); + + $debut = intval($debut); + $id_article = intval($id_article); + + $row = spip_fetch_array(spip_query("SELECT COUNT(*) AS cnt FROM spip_forum WHERE statut='prive' AND id_article='$id_article' AND id_parent=0")); + $total = $row["cnt"]; + + if ($total) { + + $total_afficher = 8; + $forum = spip_query("SELECT * FROM spip_forum WHERE statut='prive' AND id_article='$id_article' AND id_parent=0 ORDER BY date_heure DESC" . " LIMIT $debut,$total_afficher" ); +# " LIMIT $total_afficher OFFSET $debut" # PG + + $total = formulaire_discuter($forum, $total, $debut, $total_afficher, 'articles', "id_article=$id_article"); + + } + return $total; +} +?> diff --git a/ecrire/exec/forum.php b/ecrire/exec/forum.php index e41359ac1c45f49f645def5e82a71e432375cf2b..8fd70d50312dace04e3056e01648dbe7651cdc98 100644 --- a/ecrire/exec/forum.php +++ b/ecrire/exec/forum.php @@ -82,7 +82,7 @@ function exec_forum_dist() $limit = $debut ? "LIMIT $debut,10" : "LIMIT 10" ; $result_forum = spip_query("SELECT * FROM spip_forum WHERE statut='$statutforum' AND id_parent=0 ORDER BY date_heure DESC $limit"); - afficher_forum($result_forum,$script,''); + echo afficher_forum($result_forum,$script,''); echo "</div>"; diff --git a/ecrire/exec/message.php b/ecrire/exec/message.php index 6fc267af201a36bf14e1a6e5d538360a62e0384a..30c59d1bdb7356a382e2dbd7c139cc5cf1d06f31 100644 --- a/ecrire/exec/message.php +++ b/ecrire/exec/message.php @@ -247,7 +247,7 @@ function http_afficher_forum_perso($id_message, $titre) echo "</div>\n<p align='left'>"; $query_forum = spip_query("SELECT * FROM spip_forum WHERE statut='perso' AND id_message='$id_message' AND id_parent=0 ORDER BY date_heure DESC LIMIT 20"); - afficher_forum($query_forum, "message","id_message=$id_message"); + echo afficher_forum($query_forum, "message","id_message=$id_message"); echo "\n</p>"; } diff --git a/ecrire/exec/sites.php b/ecrire/exec/sites.php index cfaa3012e386150b69f94baafe9be10418d9c649..916096f251f35f1bf688742cc1a06f526faa638f 100644 --- a/ecrire/exec/sites.php +++ b/ecrire/exec/sites.php @@ -522,11 +522,11 @@ fin_cadre_relief(); echo "</div><p align='left'>\n"; -$result_forum = spip_query("SELECT * FROM spip_forum WHERE statut='prive' AND id_syndic=$id_syndic AND id_parent=0 ORDER BY date_heure DESC LIMIT 20"); -afficher_forum($result_forum, "sites","id_syndic=$id_syndic"); + $result_forum = spip_query("SELECT * FROM spip_forum WHERE statut='prive' AND id_syndic=$id_syndic AND id_parent=0 ORDER BY date_heure DESC LIMIT 20"); + echo afficher_forum($result_forum, "sites","id_syndic=$id_syndic"); -fin_page(); + fin_page(); } // http://doc.spip.org/@analyser_site diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index 13bd82a3271ce05be4ea8f7fd217a90130583443..75f38da6a5415f221f2d4b83bfc643e3d0370702 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -1438,29 +1438,32 @@ function afficher_forum($request, $retour, $arg, $controle_id_article = false) { global $spip_display; static $compteur_forum = 0; static $nb_forum = array(); - static $i = array(); + static $thread = array(); $compteur_forum++; $nb_forum[$compteur_forum] = spip_num_rows($request); - $i[$compteur_forum] = 1; + $thread[$compteur_forum] = 1; - if ($spip_display == 4) echo "<ul>"; + $res = ''; + + if ($spip_display == 4) $res .= "<ul>"; while($row = spip_fetch_array($request)) { $statut=$row['statut']; - if ($compteur_forum==1) echo "\n<br /><br />"; + if ($compteur_forum==1) $res .= "\n<br />"; if (($controle_id_article) ? ($statut!="perso") : (($statut=="prive" OR $statut=="privrac" OR $statut=="privadm" OR $statut=="perso") OR ($statut=="publie" AND $id_parent > 0))) { - afficher_forum_thread($row, $controle_id_article, $compteur_forum, $nb_forum, $i, $retour, $arg); - afficher_forum(spip_query("SELECT * FROM spip_forum WHERE id_parent='" . $row['id_forum'] . "'" . ($controle_id_article ? " AND statut<>'off'" : '') . " ORDER BY date_heure"), $retour, $arg, $controle_id_article); + $res .= afficher_forum_thread($row, $controle_id_article, $compteur_forum, $nb_forum, $thread, $retour, $arg) + . afficher_forum(spip_query("SELECT * FROM spip_forum WHERE id_parent='" . $row['id_forum'] . "'" . ($controle_id_article ? " AND statut<>'off'" : '') . " ORDER BY date_heure"), $retour, $arg, $controle_id_article); } - $i[$compteur_forum]++; + $thread[$compteur_forum]++; } - if ($spip_display == 4) echo "</ul>"; + if ($spip_display == 4) $res .= "</ul>"; spip_free_result($request); $compteur_forum--; + return $res; } // http://doc.spip.org/@afficher_forum_thread @@ -1492,89 +1495,85 @@ function afficher_forum_thread($row, $controle_id_article, $compteur_forum, $nb_ $ip=$row["ip"]; $id_auteur=$row["id_auteur"]; - echo "<a id='$id_forum'></a>"; - if ($spip_display != 4) { - echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr>"; - afficher_forum_4($compteur_forum, $nb_forum, $i); - } - $titre_boite = ''; - if ($id_auteur AND $voir_logo) { - $logo_f = charger_fonction('chercher_logo', 'inc'); - if ($logo = $logo_f($id_auteur, 'id_auteur', 'on')) - if ($logo = decrire_logo("id_auteur", 'on', $id_auteur, 48, 48, $logo)) - $titre_boite = "<div style='$voir_logo'>$$logo</div>" ; - } + $res = "<a id='$id_forum'></a>"; - $titre_boite .= typo($titre); - if ($spip_display == 4) { - echo "<li>".typo($titre)."<br>"; + $res .= "<li>".typo($titre)."<br>"; } else { + + $titre_boite = ''; + if ($id_auteur AND $voir_logo) { + $logo_f = charger_fonction('chercher_logo', 'inc'); + if ($logo = $logo_f($id_auteur, 'id_auteur', 'on')) + if ($logo = decrire_logo("id_auteur", 'on', $id_auteur, 48, 48, $logo)) + $titre_boite = "<div style='$voir_logo'>$logo</div>" ; + } + + $titre_boite .= typo($titre); + + $res .= "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr>"; + $res .= afficher_forum_4($compteur_forum, $nb_forum, $i); + if ($compteur_forum == 1) - echo afficher_forum_logo($statut, $titre_boite); - else echo debut_cadre_thread_forum("", false, "", $titre_boite); + $res .= afficher_forum_logo($statut, $titre_boite); + else $res .= debut_cadre_thread_forum("", true, "", $titre_boite); } // Si refuse, cadre rouge if ($statut=="off") { - echo "<div style='border: 2px dashed red; padding: 5px;'>"; + $res .= "<div style='border: 2px dashed red; padding: 5px;'>"; } // Si propose, cadre jaune else if ($statut=="prop") { - echo "<div style='border: 1px solid yellow; padding: 5px;'>"; + $res .= "<div style='border: 1px solid yellow; padding: 5px;'>"; } - echo "<span class='arial2'>"; - // echo affdate_court($date_heure); - // echo ", "; - // echo heures($date_heure).":".minutes($date_heure); - - echo date_interface($date_heure); - - echo "</span> "; - + $res .= "<span class='arial2'>". date_interface($date_heure) . "</span> "; + if ($id_auteur) - echo "<a href='" . generer_url_ecrire("auteurs_edit","id_auteur=$id_auteur") . "'>".typo($auteur)."</a>"; + $res .= "<a href='" . generer_url_ecrire("auteurs_edit","id_auteur=$id_auteur") . "'>".typo($auteur)."</a>"; else if ($email_auteur) - echo "<a href='mailto:$email_auteur'>".typo($auteur)."</a>"; - else echo typo($auteur); + $res .= "<a href='mailto:$email_auteur'>".typo($auteur)."</a>"; + else $res .= typo($auteur); if ($id_auteur) { $bouton = bouton_imessage($id_auteur); - if ($bouton) echo " ".$bouton; + if ($bouton) $res .= " ".$bouton; } // boutons de moderation if ($controle_id_article) - echo boutons_controle_forum($id_forum, $statut, $id_auteur, "id_article=$id_article", $ip); + $res .= boutons_controle_forum($id_forum, $statut, $id_auteur, "id_article=$id_article", $ip); - echo safehtml(justifier(propre($texte))); + $res .= safehtml(justifier(propre($texte))); if ($nom_site) { if (strlen($url_site) > 10) - echo "<div align='left' class='verdana2'><b><a href='$url_site'>$nom_site</a></b></div>"; - else echo "<b>$nom_site</b>"; + $res .= "<div align='left' class='verdana2'><b><a href='$url_site'>$nom_site</a></b></div>"; + else $res .= "<b>$nom_site</b>"; } if (!$controle_id_article) { $tm = rawurlencode($titre); - echo "<div align='right' class='verdana1'>"; - echo "<b><a href='", generer_url_ecrire("forum_envoi","id_parent=$id_forum&titre_message=$tm&url=" . generer_url_retour($retour, $arg) .'#formulaire'), - "'>", - _T('lien_repondre_message'), - "</a></b></div>"; + $res .= "<div align='right' class='verdana1'>" + . "<b><a href='" + . generer_url_ecrire("forum_envoi","id_parent=$id_forum&titre_message=$tm&url=" . generer_url_retour($retour, $arg) .'#formulaire') + . "'>" + . _T('lien_repondre_message') + . "</a></b></div>"; } if ($GLOBALS['meta']["mots_cles_forums"] == "oui") - afficher_forum_mots($id_forum); + $res .= afficher_forum_mots($id_forum); - if ($statut == "off" OR $statut == "prop") echo "</div>"; + if ($statut == "off" OR $statut == "prop") $res .= "</div>"; if ($spip_display != 4) { - if ($compteur_forum == 1) echo fin_cadre_forum(); - else echo fin_cadre_thread_forum(); - echo "</td></tr></table>\n"; + if ($compteur_forum == 1) $res .= fin_cadre_forum(true); + else $res .= fin_cadre_thread_forum(true); + $res .= "</td></tr></table>\n"; } + return $res; } @@ -1585,43 +1584,47 @@ function afficher_forum_logo($statut, $titre_boite) else if ($statut == "privadm") $logo = "forum-admin-24.gif"; else if ($statut == "privrac") $logo = "forum-interne-24.gif"; else $logo = "forum-public-24.gif"; - return debut_cadre_forum($logo, false, "", $titre_boite); + return debut_cadre_forum($logo, true, "", $titre_boite); } // http://doc.spip.org/@afficher_forum_mots function afficher_forum_mots($id_forum) { - $result_mots = spip_query("SELECT * FROM spip_mots AS mots, spip_mots_forum AS lien WHERE lien.id_forum = '$id_forum' AND lien.id_mot = mots.id_mot"); + $result = spip_query("SELECT * FROM spip_mots AS mots, spip_mots_forum AS lien WHERE lien.id_forum = '$id_forum' AND lien.id_mot = mots.id_mot"); - echo '<ul>'; - while ($row_mots = spip_fetch_array($result_mots)) { - $id_mot = $row_mots['id_mot']; - $titre_mot = propre($row_mots['titre']); - $type_mot = propre($row_mots['type']); - echo "<li> <b>",$type_mot," :</b> ",$titre_mot, "<li>"; + $res = '<ul>'; + while ($row = spip_fetch_array($result)) { + $res .= "<li> <b>" + . propre($row['titre']) + . " :</b> " + . propre($row['type']) + . "<li>"; } - echo '</ul>'; + $res .= '</ul>'; + return $res; } // affiche les traits de liaisons entre les reponses // http://doc.spip.org/@afficher_forum_4 -function afficher_forum_4($compteur_forum, $nb_forum, $i) +function afficher_forum_4($compteur_forum, $nb_forum, $thread) { global $spip_lang_rtl; $fleche='rien.gif'; - for ($count=2;$count<=$compteur_forum AND $count<20;$count++){ - $fond[$count]=_DIR_IMG_PACK . 'rien.gif'; - if ($i[$count]!=$nb_forum[$count]){ - $fond[$count]=_DIR_IMG_PACK . 'forum-vert.gif'; + $res = ''; + for ($j=2;$j<=$compteur_forum AND $j<20;$j++){ + $fond[$j]=_DIR_IMG_PACK . 'rien.gif'; + if ($thread[$j]!=$nb_forum[$j]){ + $fond[$j]=_DIR_IMG_PACK . 'forum-vert.gif'; } - echo "<td width='10' valign='top' background=$fond[$count]>"; - if ($count==$compteur_forum){ + if ($j==$compteur_forum){ $fleche="forum-droite$spip_lang_rtl.gif"; } - echo http_img_pack($fleche, " ", "width='10' height='13'"), "</td>\n"; + $res .= "<td width='10' valign='top' background=$fond[$j]>" + . http_img_pack($fleche, " ", "width='10' height='13'") + . "</td>\n"; } - echo "\n<td width=100% valign='top'>"; + return $res . "\n<td width=100% valign='top'>"; }