[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / inc / forum_envoi.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
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 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 include_spip('inc/presentation');
16
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) {
19
20 $id_parent= intval($id_parent);
21 $id = intval($id);
22 $row = sql_fetsel("*", "spip_forum", "id_forum=$id_parent");
23
24 // s'il existe, afficher le message auquel on repond
25 if (!$row)
26 $row = array('titre' =>'', 'texte' =>'', 'id_forum' =>0);
27 else $row = forum_envoi_parent($row);
28
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);
32 }
33
34 // determiner le retour et l'action
35
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 ='';
41
42 if (!$titre_message) {
43 if ($table) {
44 $titre_message = sql_getfetsel($titre, "spip_$table", "$objet=$id");
45 } else $titre_message = _T('texte_nouveau_message');
46 }
47
48 $h = _AJAX ? '' : generer_url_ecrire($script, $retour);
49
50 $form = forum_envoi_formulaire($id, $h, $statut, $texte, $titre_message, $nom_site, $url_site);
51
52 return forum_envoi_form($id, $row, $script, $statut, $titre, $row['texte'] . $corps, $form, $objet, $retour);
53 }
54
55 // http://doc.spip.org/@forum_envoi_form
56 function forum_envoi_form($id, $row, $script, $statut, $titre, $corps, $form, $objet, $args, $fct_ajax='') {
57
58 $id_parent = $row['id_forum'];
59 $cat = $id . '/'
60 . $id_parent . '/'
61 . $statut . '/'
62 . $script . '/'
63 . $objet;
64
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']));
69
70 $corps .= "\n<div>&nbsp;</div>" .
71 debut_cadre_formulaire(($statut == 'privac') ? "" : 'background-color: #dddddd;', true) .
72 $form
73 . "<div style='text-align: right'>"
74 . "<input type='submit' value='"
75 . _T('bouton_voir_message')
76 . "' /></div>"
77 . fin_cadre_formulaire(true);
78
79 if (_AJAX)
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'");
82 }
83
84 // Chercher a quoi on repond pour l'afficher au debut
85
86 // http://doc.spip.org/@forum_envoi_parent
87 function forum_envoi_parent($row)
88 {
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'];
96
97 $parent = debut_cadre_forum("forum-interne-24.gif", true, "", $titre)
98 . "<span class='arial2'>$date_heure</span> ";
99
100 if ($id_auteur) {
101 $formater_auteur = charger_fonction('formater_auteur', 'inc');
102 list($s, $mail, $nom, $w, $p) = $formater_auteur($id_auteur);
103 $parent .="$mail&nbsp;$nom";
104 } else $parent .=" " . typo($auteur);
105
106 $parent .= justifier(propre($texte));
107
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>";
110 }
111 $parent .= fin_cadre_forum(true);
112
113 $row['texte'] = $parent;
114
115 return $row;
116 }
117
118 // http://doc.spip.org/@forum_envoi_articles
119 function forum_envoi_articles($id, $row, $retour) {
120 $table ='articles';
121 $objet = 'id_article';
122 $titre = 'titre';
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, '');
127 }
128
129 // http://doc.spip.org/@forum_envoi_breves_voir
130 function forum_envoi_breves_voir($id, $row, $retour) {
131 $table = 'breves';
132 $objet = 'id_breve';
133 $titre = 'titre';
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, '');
138 }
139
140 // http://doc.spip.org/@forum_envoi_message
141 function forum_envoi_message($id, $row, $retour) {
142 $table = 'messages';
143 $objet = 'id_message';
144 $titre = 'titre';
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, '');
149 }
150
151 // http://doc.spip.org/@forum_envoi_naviguer
152 function forum_envoi_naviguer($id, $row, $retour) {
153 $table = 'rubriques';
154 $objet = 'id_rubrique';
155 $titre = 'titre';
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, '');
160 }
161
162 // http://doc.spip.org/@forum_envoi_sites
163 function forum_envoi_sites($id, $row, $retour) {
164 $table = 'syndic';
165 $objet = 'id_syndic';
166 $titre = 'nom_site';
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, '');
171 }
172
173 // http://doc.spip.org/@forum_envoi_forum
174 function forum_envoi_forum($id, $row, $retour) {
175
176 $table = $titre = $num = '';
177 $id = 0; // pour forcer la creation dans action/poster
178 $objet = 'id_forum';
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);
183 }
184
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);
188 }
189
190 // http://doc.spip.org/@forum_envoi_formulaire
191 function forum_envoi_formulaire($id, $retour, $statut, $texte, $titre, $nom_site, $url_site)
192 {
193
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'>"
196 ."<ul>"
197 ."<li class='obligatoire'><label for='titre_message'>"
198 . _T('info_titre')
199 ."</label>"
200 . "<input id='titre_message' name='titre_message' type='text' value=\""
201 . entites_html($titre)
202 . "\" class='text' />\n"
203 ."</li>"
204 ."<li class='haut'><label for='texte' >"
205 . _T('info_texte_message')
206 ."</label>"
207 ."<textarea name='texte' id='texte' rows='13' class='textarea'>\n"
208 . $texte
209 . "</textarea>"
210 ."<input type='hidden' name='modif_forum' value='oui' />\n"
211 ."</li>"
212 . (!($statut != 'perso')
213 ? ''
214 : (
215 "<li class='fieldset'><fieldset>"
216 ."<h3 class='legend'>"._T('info_lien_hypertexte')."</h3>"
217 ."<p class='explication'>". _T('texte_lien_hypertexte')."</p>\n"
218 ."<ul>"
219 . "<li><label for='nom_site'>"
220 . _T('form_prop_nom_site')
221 . "</label>"
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'>"
226 . _T('info_url')
227 ."</label>"
228 . "<input type='text' id='url_site' name='url_site' value=\"".entites_html($url_site)
229 . "\" class='text' /></li>"
230 ."</ul></fieldset></li>"
231 ))
232 ."</ul></div>";
233
234 }
235
236 // http://doc.spip.org/@forum_envoi_entete
237 function forum_envoi_entete($parent, $titre_parent, $texte, $titre, $nom_site, $url_site)
238 {
239 global $spip_lang_rtl;
240
241 return "\n<br /><br /><table width='100%' cellpadding='0' cellspacing='0' border='0'>"
242 . (!$parent ? '' : "<tr><td colspan='2'>$parent</td></tr>")
243 . "<tr>"
244 . (!$parent ? "<td colsan='2'"
245 : (" <td style='width: 10px; background-image: url("
246 . chemin_image('forum-vert.gif')
247 . ");'>"
248 . http_img_pack('rien.gif', ' ', " style='width: 0px; height: 0px; border: 0px;'")
249 . "</td>\n<td "))
250 . " style='width: 100%' valign='top' rowspan='2'>"
251 . debut_cadre_thread_forum("", true, "", typo($titre))
252 . propre($texte)
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)
258 . "</td>"
259 . "</tr>\n"
260 . (!$parent ? ''
261 : ("<tr><td valign='top' style='width: 10px; background-image: url("
262 . chemin_image('rien.gif')
263 . ");'>"
264 . http_img_pack("forum-droite$spip_lang_rtl.gif",
265 '&nbsp;',
266 " style='width: 10px; height: 13px'")
267 . "</td>\n</tr>"))
268 . "</table>";
269 }
270 ?>