3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 include_spip('inc/presentation');
17 // http://doc.spip.org/@inc_forum_envoi_dist
18 function inc_forum_envoi_dist($id, $id_parent, $script, $statut, $titre_message, $texte, $modif_forum, $nom_site, $url_site) {
20 $id_parent= intval($id_parent);
22 $row = sql_fetsel("*", "spip_forum", "id_forum=$id_parent");
24 // s'il existe, afficher le message auquel on repond
26 $row = array('titre' =>'', 'texte' =>'', 'id_forum' =>0);
27 else $row = forum_envoi_parent($row);
29 // apres le premier appel, afficher la saisie precedente
30 if ($modif_forum == "oui") {
31 $row['texte'] = forum_envoi_entete($row['texte'], $row['titre'], $texte, $titre_message, $nom_site, $url_site);
34 // determiner le retour et l'action
36 list($script,$retour) = preg_split(',\?,', urldecode($script));
37 if (function_exists($f = 'forum_envoi_' . $script))
38 list($table, $objet, $titre, $num, $retour, $id, $corps) =
39 $f($id, $row, $retour);
40 else $table = $objet = $titre = $num = $retour = $corps ='';
42 if (!$titre_message) {
44 $titre_message = sql_getfetsel($titre, "spip_$table", "$objet=$id");
45 } else $titre_message = _T('texte_nouveau_message');
48 $h = _AJAX ?
'' : generer_url_ecrire($script, $retour);
50 $form = forum_envoi_formulaire($id, $h, $statut, $texte, $titre_message, $nom_site, $url_site);
52 return forum_envoi_form($id, $row, $script, $statut, $titre, $row['texte'] . $corps, $form, $objet, $retour);
55 // http://doc.spip.org/@forum_envoi_form
56 function forum_envoi_form($id, $row, $script, $statut, $titre, $corps, $form, $objet, $args, $fct_ajax='') {
58 $id_parent = $row['id_forum'];
65 // si reponse directe a l'article etc, reincruster tout le forum
66 // sinon incruster juste le fil
67 $args .= "#poster_forum_prive"
68 . (!$id_parent ?
'' : ("-" . $row['id_thread']));
70 $corps .= "\n<div> </div>" .
71 debut_cadre_formulaire(($statut == 'privac') ?
"" : 'background-color: #dddddd;', true) .
73 . "<div style='text-align: right'>"
74 . "<input type='submit' value='"
75 . _T('bouton_voir_message')
77 . fin_cadre_formulaire(true);
80 return ajax_action_post('poster_forum_prive',$cat, $script, $args, $corps, array(),'','', "&id=$id&id_parent=$id_parent&statut=$statut", $fct_ajax);
81 else return redirige_action_auteur('poster_forum_prive',$cat, $script, $args, $corps, "\nmethod='post' id='formulaire'");
84 // Chercher a quoi on repond pour l'afficher au debut
86 // http://doc.spip.org/@forum_envoi_parent
87 function forum_envoi_parent($row)
89 $titre = typo($row['titre']);
90 $texte = $row['texte'];
91 $auteur = $row['auteur'];
92 $id_auteur = $row['id_auteur'];
93 $date_heure = $row['date_heure'];
94 $nom_site = $row['nom_site'];
95 $url_site = $row['url_site'];
97 $parent = debut_cadre_forum("forum-interne-24.gif", true, "", $titre)
98 . "<span class='arial2'>$date_heure</span> ";
101 $formater_auteur = charger_fonction('formater_auteur', 'inc');
102 list($s, $mail, $nom, $w, $p) = $formater_auteur($id_auteur);
103 $parent .="$mail $nom";
104 } else $parent .=" " . typo($auteur);
106 $parent .= justifier(propre($texte));
108 if (strlen($url_site) > 10 AND $nom_site) {
109 $parent .="<p style='text-align: left; font-weight: bold;' class='verdana1'><a href='$url_site'>$nom_site</a></p>";
111 $parent .= fin_cadre_forum(true);
113 $row['texte'] = $parent;
118 // http://doc.spip.org/@forum_envoi_articles
119 function forum_envoi_articles($id, $row, $retour) {
121 $objet = 'id_article';
123 $num = _T('info_numero_article');
124 if (!$id) $id = $row['id_article'];
125 if (!$retour) $retour = "$objet=$id";
126 return array($table, $objet, $titre, $num, $retour, $id, '');
129 // http://doc.spip.org/@forum_envoi_breves_voir
130 function forum_envoi_breves_voir($id, $row, $retour) {
134 $num = _T('info_gauche_numero_breve');
135 if (!$id) $id = $row['id_breve'];
136 if (!$retour) $retour = "$objet=$id";
137 return array($table, $objet, $titre, $num, $retour, $id, '');
140 // http://doc.spip.org/@forum_envoi_message
141 function forum_envoi_message($id, $row, $retour) {
143 $objet = 'id_message';
145 $num = _T('message') . ' ' ._T('info_numero_abbreviation');
146 if (!$id) $id = $row['id_message'];
147 if (!$retour) $retour = "$objet=$id";
148 return array($table, $objet, $titre, $num, $retour, $id, '');
151 // http://doc.spip.org/@forum_envoi_naviguer
152 function forum_envoi_naviguer($id, $row, $retour) {
153 $table = 'rubriques';
154 $objet = 'id_rubrique';
156 $num = _T('titre_numero_rubrique');
157 if (!$id) $id = $row['id_rubrique'];
158 if (!$retour) $retour = "$objet=$id";
159 return array($table, $objet, $titre, $num, $retour, $id, '');
162 // http://doc.spip.org/@forum_envoi_sites
163 function forum_envoi_sites($id, $row, $retour) {
165 $objet = 'id_syndic';
167 $num = _T('titre_site_numero');
168 if (!$id) $id = $row['id_syndic'];
169 if (!$retour) $retour = "$objet=$id";
170 return array($table, $objet, $titre, $num, $retour, $id, '');
173 // http://doc.spip.org/@forum_envoi_forum
174 function forum_envoi_forum($id, $row, $retour) {
176 $table = $titre = $num = '';
177 $id = 0; // pour forcer la creation dans action/poster
179 $debut = intval(_request('debut'));
180 $retour = ("debut=$debut");
181 $corps .= "<input type='hidden' name='debut' value='$debut' />";
182 return array($table, $objet, $titre, $num, $retour, $id, $corps);
185 // http://doc.spip.org/@forum_envoi_forum_admin
186 function forum_envoi_forum_admin($id, $row, $retour) {
187 return forum_envoi_forum($id, $row, $retour);
190 // http://doc.spip.org/@forum_envoi_formulaire
191 function forum_envoi_formulaire($id, $retour, $statut, $texte, $titre, $nom_site, $url_site)
194 return (!$retour ?
'' : "<div class='entete-formulaire'>".icone(_T('icone_retour'), $retour, forum_logo($statut), '','', false)."</div>")
195 . "<div class='formulaire_spip formulaire_editer formulaire_editer_message_forum'>"
197 ."<li class='obligatoire'><label for='titre_message'>"
200 . "<input id='titre_message' name='titre_message' type='text' value=\""
201 . entites_html($titre)
202 . "\" class='text' />\n"
204 ."<li class='haut'><label for='texte' >"
205 . _T('info_texte_message')
207 ."<textarea name='texte' id='texte' rows='13' class='textarea'>\n"
210 ."<input type='hidden' name='modif_forum' value='oui' />\n"
212 . (!($statut != 'perso')
215 "<li class='fieldset'><fieldset>"
216 ."<h3 class='legend'>"._T('info_lien_hypertexte')."</h3>"
217 ."<p class='explication'>". _T('texte_lien_hypertexte')."</p>\n"
219 . "<li><label for='nom_site'>"
220 . _T('form_prop_nom_site')
222 . "<input type='text' id='nom_site' name='nom_site' value=\""
223 . entites_html($nom_site)
224 . "\" class='text' /></li>"
225 . "<li><label for='url_site'>"
228 . "<input type='text' id='url_site' name='url_site' value=\"".entites_html($url_site)
229 . "\" class='text' /></li>"
230 ."</ul></fieldset></li>"
236 // http://doc.spip.org/@forum_envoi_entete
237 function forum_envoi_entete($parent, $titre_parent, $texte, $titre, $nom_site, $url_site)
239 global $spip_lang_rtl;
241 return "\n<br /><br /><table width='100%' cellpadding='0' cellspacing='0' border='0'>"
242 . (!$parent ?
'' : "<tr><td colspan='2'>$parent</td></tr>")
244 . (!$parent ?
"<td colsan='2'"
245 : (" <td style='width: 10px; background-image: url("
246 . chemin_image('forum-vert.gif')
248 . http_img_pack('rien.gif', ' ', " style='width: 0px; height: 0px; border: 0px;'")
250 . " style='width: 100%' valign='top' rowspan='2'>"
251 . debut_cadre_thread_forum("", true, "", typo($titre))
253 . (!$nom_site ?
'' : "<p><a href='$url_site'>$nom_site</a></p>")
254 . "\n<div style='text-align: right'><input type='submit' name='valider_forum' value='"
255 . _T('bouton_envoyer_message')
256 . "'\nonclick='AjaxNamedSubmit(this)' /></div>"
257 . fin_cadre_thread_forum(true)
261 : ("<tr><td valign='top' style='width: 10px; background-image: url("
262 . chemin_image('rien.gif')
264 . http_img_pack("forum-droite$spip_lang_rtl.gif",
266 " style='width: 10px; height: 13px'")