poster.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. $auth->check(1);
  24. include dirname(__FILE__).'/inc/connexion.php';
  25. # Tableau des mois de l'année
  26. for ($i=1;$i<=12;$i++) {
  27. $m = sprintf('%02d',$i);
  28. $arry_dt_m[dt::str('%B',strtotime('2000-'.$m.'-01'))] = $m;
  29. }
  30. # Les catégories du blog
  31. $cat_id = (!empty($_GET['cat_id'])) ? $_GET['cat_id'] : '';
  32. $rsCat = $blog->getCat();
  33. while (!$rsCat->EOF())
  34. {
  35. $arry_cat[$rsCat->f('cat_libelle')] = $rsCat->f('cat_id');
  36. $rsCat->moveNext();
  37. }
  38. # Valeurs par défaut
  39. $err = '';
  40. $titre = '';
  41. $titre_url = '';
  42. $cat_id = $_SESSION['sess_user_pref_cat'];
  43. $dt_m = $dt_d = $dt_y = '';
  44. $chapo = $preview_chapo = '';
  45. $content = $preview_content = '';
  46. $notes = '';
  47. $is_editable = true;
  48. $format = $_SESSION['sess_user_format'];
  49. $etat = $_SESSION['sess_user_post_pub'];
  50. $open_comment = 1;
  51. $open_tb = 1;
  52. $lang = DC_LANG;
  53. $selected = 0;
  54. $return_link = 'index.php';
  55. $do_trackbacks = false;
  56. $objWiki = new wiki2xhtml();
  57. if (dc_encoding != 'UTF-8') {
  58. $objWiki->setOpt('active_fix_word_entities',1);
  59. }
  60. # Billet existant
  61. if (!empty($_REQUEST['post_id']))
  62. {
  63. $post = $blog->getPostById($_REQUEST['post_id']);
  64. if (!$post->isEmpty())
  65. {
  66. $post_id = $post->f('post_id');
  67. $titre = $post->f('post_titre');
  68. $titre_url = $post->f('post_titre_url');
  69. $cat_id = $post->f('cat_id');
  70. $format = $post->getFormat();
  71. $etat = (integer) $post->f('post_pub');
  72. $open_comment = (integer) $post->f('post_open_comment');
  73. $open_tb = (integer) $post->f('post_open_tb');
  74. $lang = $post->f('post_lang');
  75. $selected = $post->f('post_selected');
  76. $chapo = ($post->f('post_chapo_wiki') != '') ? $post->f('post_chapo_wiki') : $post->f('post_chapo');
  77. $preview_chapo = $post->f('post_chapo');
  78. $content = ($post->f('post_content_wiki') != '') ? $post->f('post_content_wiki') : $post->f('post_content');
  79. $notes = $post->f('post_notes');
  80. $preview_content = $post->f('post_content');
  81. $return_link = 'index.php?m='.$post->f('postyear').$post->f('postmonth').'#p'.$post_id;
  82. $post_ts = $post->getTS();
  83. $post_perm_url = $post->getPermURL();
  84. $dt_y = date('Y',$post_ts);
  85. $dt_m = date('m',$post_ts);
  86. $dt_d = date('d',$post_ts);
  87. $dt_h = (string) date('H',$post_ts);
  88. $dt_i = (string) date('i',$post_ts);
  89. $dt_s = (string) date('s',$post_ts);
  90. $objWiki->setOpt('note_prefix','pnote-'.$post_id);
  91. $comments = $blog->getComments($post_id);
  92. # Le post n'est éditable que par un admin ou son rédacteur,
  93. # qu'on se le dise !
  94. if ($post->f('user_id') != $_SESSION['sess_user_id'] && $_SESSION['sess_user_level'] < 9) {
  95. $is_editable = false;
  96. }
  97. # Changement du status ou suppression d'un commentaire
  98. if (!empty($_GET['comment_id']))
  99. {
  100. if ($is_editable) {
  101. if (!empty($_GET['comment_del'])) {
  102. if ($blog->delComment($_GET['comment_id']) !== false) {
  103. header('Location: poster.php?post_id='.$post_id.'#comments');
  104. exit;
  105. } else {
  106. $err = $blog->error(1);
  107. }
  108. } else {
  109. if ($blog->statusComment($_GET['comment_id']) !== false) {
  110. header('Location: poster.php?post_id='.$post_id.'#c'.$_GET['comment_id']);
  111. exit;
  112. } else {
  113. $err = $blog->error(1);
  114. }
  115. }
  116. } else {
  117. $err = '<ul><li>'.__('You are not allowed to edit a comment').'</li></ul>';
  118. }
  119. }
  120. # Ajout d'un commentaire
  121. if (!empty($_POST['add_comment']))
  122. {
  123. if ($blog->addComment($post_id,$_POST['com_nom'],
  124. $_POST['com_email'],$_POST['com_web'],$_POST['com_content']) !== false) {
  125. header('Location: poster.php?post_id='.$post_id.'#comments');
  126. exit;
  127. } else {
  128. $err = $blog->error(1);
  129. }
  130. }
  131. # Changement du status d'un billet
  132. if (!empty($_GET['cancel']) && $is_editable)
  133. {
  134. if ($blog->statusPost($post_id) !== false) {
  135. header('Location: '.$return_link);
  136. exit;
  137. } else {
  138. $err = $blog->error(1);
  139. }
  140. }
  141. # Suppression d'un billet
  142. if (!empty($_POST['delete']) && $is_editable)
  143. {
  144. if ($blog->delPost($post_id) !== false) {
  145. $msg = __('Entry successfully removed');
  146. header('Location: index.php?msg='.urlencode($msg));
  147. exit;
  148. } else {
  149. $err = $blog->error(1);
  150. }
  151. }
  152. }
  153. }
  154. # Valeurs pour la prévisualisation, la création ou la modification d'un billet
  155. if (!empty($_POST['preview']) || !empty($_POST['publish']) || !empty($_POST['transform']))
  156. {
  157. $titre = $_POST['p_titre'];
  158. $titre_url = $_POST['p_titre_url'];
  159. $cat_id = $_POST['p_cat'];
  160. $format = $_POST['p_format'];
  161. $etat = $_POST['p_etat'];
  162. $open_comment = $_POST['p_open_comment'];
  163. $open_tb = $_POST['p_open_tb'];
  164. $lang = $_POST['p_lang'];
  165. $selected = $_POST['p_selected'];
  166. $content = $_POST['p_content'];
  167. $notes = $_POST['p_notes'];
  168. $chapo = $_POST['p_chapo'];
  169. $do_trackbacks = !empty($_POST['p_do_trackbacks']) ? true : false;
  170. if (!empty($post_id))
  171. {
  172. $dt_y = (string) sprintf('%04d',$_POST['p_dt_y']);
  173. $dt_m = (string) sprintf('%02d',$_POST['p_dt_m']);
  174. $dt_d = (string) sprintf('%02d',$_POST['p_dt_d']);
  175. $dt_h = (string) sprintf('%02d',$_POST['p_dt_h']);
  176. $dt_i = (string) sprintf('%02d',$_POST['p_dt_i']);
  177. $dt_s = (string) sprintf('%02d',$_POST['p_dt_s']);
  178. # Corrections jour & heure
  179. if ($dt_d > 31 || $dt_d < 1) { $dt_d = '01'; }
  180. if ($dt_h > 23 || $dt_h < 0) { $dt_h = '00'; }
  181. if ($dt_i > 59 || $dt_i < 0) { $dt_i = '00'; }
  182. if ($dt_s > 59 || $dt_s < 0) { $dt_s = '00'; }
  183. $new_date = strtotime($dt_y.'-'.$dt_m.'-'.$dt_d.' '.$dt_h.':'.$dt_i.':'.$dt_s);
  184. }
  185. if (strpos($lang,'fr') === 0) {
  186. $objWiki->setOpt('active_fr_syntax',1);
  187. }
  188. if (!empty($_POST['transform'])) {
  189. $format = 'html';
  190. $content = $objWiki->transform($content);
  191. $chapo = $objWiki->transform($chapo);
  192. }
  193. if ($format == 'wiki') {
  194. $preview_content = $objWiki->transform($content);
  195. $preview_chapo = $objWiki->transform($chapo);
  196. } else {
  197. $preview_content = $content;
  198. $preview_chapo = $chapo;
  199. }
  200. }
  201. # Insertion ou modification d'un billet
  202. if (!empty($_POST['publish']))
  203. {
  204. # Insertion
  205. if (empty($post_id))
  206. {
  207. if (($post_id = $blog->addPost($_SESSION['sess_user_id'],$titre,$titre_url,$chapo,$content,
  208. $notes,$cat_id,$format,$etat,$open_comment,$open_tb,$lang,$selected,
  209. $_SESSION['sess_user_delta'])) !== false) {
  210. if ($do_trackbacks) {
  211. $return_link = 'trackback.php?post_id='.$post_id.'&auto=1';
  212. } else {
  213. $return_link = 'poster.php?post_id='.$post_id;
  214. }
  215. header('Location: '.$return_link);
  216. exit;
  217. } else {
  218. $err = $blog->error(1);
  219. }
  220. }
  221. else
  222. {
  223. if ($is_editable) {
  224. if ($blog->updPost($post_id,$titre,$titre_url,$chapo,$content,$notes,$cat_id,
  225. $format,$etat,$open_comment,$open_tb,$new_date,$lang,$selected,
  226. $_SESSION['sess_user_delta']) !== false ) {
  227. if ($do_trackbacks) {
  228. $return_link = 'trackback.php?post_id='.$post_id.'&auto=1';
  229. } else {
  230. $return_link = 'poster.php?post_id='.$post_id;
  231. }
  232. header('Location: '.$return_link);
  233. exit;
  234. } else {
  235. $err = $blog->error(1);
  236. }
  237. }
  238. }
  239. }
  240. # Création du sous-menu
  241. $mySubMenu->addItem(__('Back to list of entries'),$return_link,'images/ico_retour.png',false);
  242. if (!empty($content) && !empty($post_id) &&
  243. empty($_POST['preview']) && empty($_POST['publish']) && $is_editable)
  244. {
  245. $mySubMenu->addItem(
  246. __('New entry'),array('poster.php','accesskey="n"'),
  247. 'images/ico_edit.png',false);
  248. $mySubMenu->addItem(
  249. __('XHTML validation'),
  250. array('validpost.php?post_id='.$post_id,'onclick="popup(this.href); return false;"'),
  251. 'images/ico_ok.png',false);
  252. $mySubMenu->addItem(
  253. __('Trackbacks'),
  254. 'trackback.php?post_id='.$post_id,
  255. 'images/ico_link.png',false);
  256. $mySubMenu->addItem(
  257. __('View entry'),$post_perm_url,
  258. 'images/ico_goto.png',false);
  259. }
  260. openPage(__('Entry'),
  261. '<script type="text/javascript" src="js/form.js"></script>'."\n".
  262. '<script type="text/javascript">'."\n".
  263. "window.onload = function() {\n".
  264. " openCloseOptions('moreOptions','dc_options');\n".
  265. " getCurrentForms(); addFormsEvent();\n".
  266. " closePagePrompt = '".str_replace("'","\'",__('You have unsaved changes.'))."';\n".
  267. "}\n".
  268. "window.onbeforeunload = confirmCloseForms;\n".
  269. "</script>\n"
  270. );
  271. if ($err != '')
  272. {
  273. echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  274. $err.'</div>';
  275. }
  276. echo '<h2>'.__('Entry').'</h2>';
  277. /* Entry preview
  278. -------------------------------------------------------- */
  279. if (!empty($content) && dc_show_previews)
  280. {
  281. if (!empty($_POST['preview'])) {
  282. $preview_titre = htmlspecialchars($titre);
  283. } else {
  284. $preview_titre = $titre;
  285. }
  286. echo '<div class="cadre preview clear">'.
  287. '<h3>'.$titre.'</h3>'.
  288. ((trim($preview_chapo) != '') ? $preview_chapo.'<hr class="thin" />' : '').
  289. $preview_content.'</div>';
  290. if (!empty($post_perm_url)) {
  291. echo '<p class="clear"><strong>'.
  292. __('Permanent link').'</strong>&nbsp;: '.
  293. util::getPageURL($post_perm_url).'</p>';
  294. }
  295. }
  296. if (!empty($_POST['preview'])) {
  297. $titre = htmlspecialchars($titre);
  298. }
  299. /* Valeurs pouvant être passées en URL par un bookmarklet
  300. -------------------------------------------------------- */
  301. if (!empty($_GET['dcb']))
  302. {
  303. $purl = !empty($_GET['purl']) ? $_GET['purl'] : '';
  304. $ptitle = !empty($_GET['ptitle']) ? $_GET['ptitle'] : '';
  305. $ptext = !empty($_GET['ptext']) ? $_GET['ptext'] : '';
  306. $titre = $ptitle;
  307. if ($format == 'wiki') {
  308. $content = '['.$ptitle.'|'.$purl."]\n\n".$ptext;
  309. } else {
  310. $content = '<a href="'.$purl.'">'.$ptitle."</a>\n\n<p>".$ptext.'</p>';
  311. }
  312. }
  313. /* Entry form
  314. -------------------------------------------------------- */
  315. if ($is_editable)
  316. {
  317. echo '<form action="poster.php" method="post" id="formPost">';
  318. echo '<table class="clear post-entry-info">';
  319. echo
  320. '<tr><td><label for="p_cat">'.
  321. __('Category').' '.helpLink('entry','category').'</label></td> '.
  322. '<td>'.form::combo('p_cat',$arry_cat,$cat_id,'','',1).'</td>';
  323. echo
  324. '<td><label for="p_format">'.
  325. __('Format').' '.helpLink('entry','format').'</label></td> '.
  326. '<td>'.form::combo('p_format',array('HTML'=>'html','Wiki'=>'wiki'),$format,'','',2).'</td>';
  327. echo
  328. '<td><label for="p_etat">'.
  329. __('Status').' '.helpLink('entry','status').'</label></td> '.
  330. '<td>'.form::combo('p_etat',array(__('Online')=>'1',__('Offline')=>'0'),$etat,'','',3).'</td></tr>';
  331. echo '</table>';
  332. echo
  333. '<p><label for="p_titre"><strong>'.__('Title').'</strong> '.
  334. helpLink('entry','title').'</label> '.
  335. form::field('p_titre',30,255,$titre,4,'class="max"').'</p>';
  336. echo
  337. '<p><label for="p_chapo">'.__('Abstract').' ('.__('optional').') '.
  338. helpLink('entry','abstract').'</label> '.
  339. form::textArea('p_chapo',60,4,htmlspecialchars($chapo),5,'class="max"').'</p>';
  340. echo
  341. '<p>'.
  342. '<label for="p_content"><strong>'.__('Entry').' '.helpLink('entry','entry').'</strong>'.
  343. ' - '.helpLink('wiki2xhtml','',__('Wiki formatting rules')).'</label>'.
  344. '</p>'.
  345. '<p>'.form::textArea('p_content',60,$_SESSION['sess_user_edit_size'],
  346. htmlspecialchars($content),6,'class="max"').'</p>';
  347. # Toolbar
  348. echo
  349. '<script type="text/javascript" src="js/toolbar.js"></script>'.
  350. '<script type="text/javascript">'.
  351. "if (document.getElementById) {
  352. var tb = new dcToolBar(document.getElementById('p_content'),
  353. document.getElementById('p_format'),'images/');
  354. tb.btStrong('".str_replace("'","\'",__('Strong emphasis'))."');
  355. tb.btEm('".str_replace("'","\'",__('Emphasis'))."');
  356. tb.btIns('".str_replace("'","\'",__('Inserted'))."');
  357. tb.btDel('".str_replace("'","\'",__('Deleted'))."');
  358. tb.btQ('".str_replace("'","\'",__('Inline quote'))."');
  359. tb.btCode('".str_replace("'","\'",__('Code'))."');
  360. tb.addSpace(10);
  361. tb.btBr('".str_replace("'","\'",__('Line break'))."');
  362. tb.addSpace(10);
  363. tb.btBquote('".str_replace("'","\'",__('Blockquote'))."');
  364. tb.btPre('".str_replace("'","\'",__('Preformated text'))."');
  365. tb.btList('".str_replace("'","\'",__('Unordered list'))."','ul');
  366. tb.btList('".str_replace("'","\'",__('Ordered list'))."','ol');
  367. tb.addSpace(10);
  368. tb.btLink('".str_replace("'","\'",__('Link'))."',
  369. '".str_replace("'","\'",__('URL?'))."',
  370. '".str_replace("'","\'",__('Language?'))."',
  371. '".DC_LANG."');
  372. tb.btImgLink('".str_replace("'","\'",__('External image'))."',
  373. '".str_replace("'","\'",__('URL?'))."');
  374. tb.addSpace(10);
  375. tb.btImg('".str_replace("'","\'",__('Internal image'))."','images-popup.php');
  376. tb.draw('".str_replace("'","\'",__('You can use the following shortcuts to refine your layout.'))."');
  377. }
  378. </script>";
  379. # Fin toolbar
  380. echo
  381. '<h3 class="moreOptions">'.
  382. '<a href="#" onclick="openCloseOptions(\'moreOptions\',\'dc_options\',0); return false;">'.
  383. '<img src="images/plus.png" id="img_moreOptions" '.
  384. 'alt="" /></a>'.
  385. ' <a href="#" onclick="openCloseOptions(\'moreOptions\',\'dc_options\',0); return false;">'.
  386. __('More options').'</a></h3>';
  387. echo
  388. '<div id="moreOptions" class="moreOptions">'.
  389. '<p><label for="p_notes">'.__('Notepad').' '.helpLink('entry','notepad').'</label>'.
  390. form::textArea('p_notes',30,6,htmlspecialchars($notes),7,'class="max"').'</p>';
  391. echo
  392. '<p><label for="p_titre_url">'.__('URLed title').' '.
  393. helpLink('entry','title_url').
  394. ' <a href="#" '.
  395. 'onclick="document.forms[0].p_titre_url.value=str2url(document.forms[0].p_titre.value,\''.dc_encoding.'\'); return false;">'.
  396. __('Use').'</a></label> '.
  397. form::field('p_titre_url',30,255,htmlspecialchars($titre_url),8,'class="max"').'</p>';
  398. if (!empty($post_id))
  399. {
  400. echo
  401. '<p><label class="inline" for="p_dt_d">'.__('Date').'</label> '.
  402. form::field('p_dt_d',2,2,$dt_d,9).' '.
  403. form::combo('p_dt_m',$arry_dt_m,$dt_m,'','',10).' '.
  404. form::field('p_dt_y',4,4,$dt_y,11).' '.
  405. '<label class="inline" for="p_dt_h">'.__('Hour').'</label> '.
  406. form::field('p_dt_h',2,2,$dt_h,12).':'.
  407. form::field('p_dt_i',2,2,$dt_i,13).':'.
  408. form::field('p_dt_s',2,2,$dt_s,14).' '.
  409. "<a href=\"#\" onclick=\"setNow(); return false;\">".__('now').'</a> '.
  410. helpLink('entry','datetime').
  411. '</p>';
  412. }
  413. echo '<table class="clear post-entry-info">';
  414. echo
  415. '<tr><td><label for="p_lang">'.
  416. __('Language').' '.helpLink('entry','language').'</label></td> '.
  417. '<td>'.form::field('p_lang',5,5,$lang,15).'</td>';
  418. echo
  419. '<td><label for="p_selected">'.
  420. __('Selection').' '.helplink('entry','selected').'</label></td>'.
  421. '<td>'.form::combo('p_selected',array(__('yes')=>1,__('no')=>0),$selected,'','',16).'</td></tr>';
  422. echo
  423. '<tr><td><label for="p_open_comment">'.
  424. __('Comments').' '.helpLink('entry','comment').'</label></td> '.
  425. '<td>'.form::combo('p_open_comment',array(__('Open')=>'1',__('Closed')=>'0'),$open_comment,'','',17).'</td>';
  426. echo
  427. '<td><label for="p_open_tb">'.
  428. __('Trackbacks').' '.helpLink('entry','trackback').'</label></td>'.
  429. '<td>'.form::combo('p_open_tb',array(__('Open')=>'1',__('Closed')=>'0'),$open_tb,'','',18).'</td></tr>';
  430. echo '</table>';
  431. echo '</div>';
  432. $p_tb_checked = ($do_trackbacks) ? ' checked="checked"' : '';
  433. echo
  434. '<p><input type="checkbox" name="p_do_trackbacks" id="p_do_trackbacks" '.
  435. $p_tb_checked.' /> '.
  436. '<label class="inline" for="p_do_trackbacks">'.__('Ping URLs').'</label></p>';
  437. echo
  438. '<p>'.
  439. '<input name="preview" type="submit" class="submit" '.
  440. 'value="'.__('preview').' [v]" accesskey="v" tabindex="20" />&nbsp; '.
  441. '<input name="publish" type="submit" class="submit" '.
  442. 'value="'.__('save').' [s]" accesskey="s" tabindex="21" />';
  443. if (!empty($post_id) && $format == 'wiki') {
  444. echo
  445. '&nbsp;<input name="transform" type="submit" class="submit" '.
  446. 'value="'.__('convert into XHTML').'" tabindex="22" />';
  447. }
  448. if (!empty($post_id)) {
  449. echo
  450. '&nbsp;<input name="delete" type="submit" class="submit" tabindex="23" '.
  451. 'value="'.__('delete').'" onclick="return '.
  452. 'window.confirm(\''.__('Are you sure you want to delete this entry?').'\')" />'.
  453. form::hidden('post_id',$post_id);
  454. }
  455. echo '</p>';
  456. echo '</form>';
  457. }
  458. /* Comments
  459. -------------------------------------------------------- */
  460. if (!empty($post_id))
  461. {
  462. echo '<h2>'.__('Comments').'</h2>';
  463. if (isset($comments)) {
  464. $trackbacks = $comments->extractTrackbacks();
  465. }
  466. if (isset($trackbacks))
  467. {
  468. echo '<h3 id="trackbacks">'.__('Trackbacks list').'</h3>';
  469. if (!$trackbacks->isEmpty()) {
  470. showComments($trackbacks);
  471. } else {
  472. echo __('No trackback');
  473. }
  474. }
  475. if (isset($comments))
  476. {
  477. echo '<h3 id="comments">'.__('Comments list').'</h3>';
  478. if (!$comments->isEmpty()) {
  479. showComments($comments);
  480. } else {
  481. echo __('No comment');
  482. }
  483. }
  484. echo
  485. '<h3>'.__('Post a comment').'</h3>'.
  486. '<form action="poster.php" method="post">'.
  487. '<p class="field"><label class="float" for="com_nom"><strong>'.
  488. __('Name').'&nbsp;:</strong></label> '.
  489. form::field('com_nom',30,255,htmlspecialchars($_SESSION['sess_user_cn'])).
  490. '</p>';
  491. echo
  492. '<p class="field"><label class="float" for="com_email">'.
  493. __('Email').' ('.__('optional').')&nbsp;:</label> '.
  494. form::field('com_email',30,255,htmlspecialchars($_SESSION['sess_user_email'])).
  495. '</p>';
  496. echo
  497. '<p class="field"><label class="float" for="com_web">'.
  498. __('Site').' ('.__('optional').')&nbsp;:</label> '.
  499. form::field('com_web',30,255,'http://').'</p>';
  500. echo
  501. '<p class="field"><label for="com_content"><strong>'.
  502. __('Comment').'&nbsp;:</strong></label> '.
  503. form::textArea('com_content',40,10,'&lt;p&gt;&lt;/p&gt;','','class="max"').'</p>';
  504. echo
  505. '<p class="field"><input type="submit" class="submit" name="add_comment"
  506. value="'.__('save').'" />'.
  507. '<input type="hidden" name="post_id" value="'.$post_id.'" /></p>';
  508. echo '</form>';
  509. echo '<p><strong>'.__('Notice').'</strong> : '.__('This comment has to be in HTML format').'.</p>';
  510. }
  511. # Affichage de commentaires ou trackbacks
  512. function showComments(&$rs)
  513. {
  514. global $is_editable, $post_id;
  515. while(!$rs->EOF())
  516. {
  517. if ($rs->f('comment_pub')) {
  518. $com_style = '';
  519. $com_cancel = __('set offline');
  520. } else {
  521. $com_style = 'style="color:#999;"';
  522. $com_cancel = __('set online');
  523. }
  524. echo '<div class="ligne" '.$com_style.' id="c'.$rs->f('comment_id').'">';
  525. echo
  526. '<p>'.(($rs->f('comment_trackback')==1) ? '<strong>'.__('Trackback').'</strong><br />' : '').
  527. __('From').'&nbsp;: '.$rs->f('comment_auteur').'<br />'.
  528. dt::str(__('On %A %e %B %Y, %I:%M %p'),$rs->getTS()).'<br />'.
  529. __('Email').'&nbsp;: '.$rs->f('comment_email').'<br />'.
  530. __('Site').'&nbsp;: '.(($rs->f('comment_site')) ? 'http://'.$rs->f('comment_site') : '').'<br />'.
  531. '@IP : '.$rs->f('comment_ip').'</p>'.
  532. '<div>'.$rs->getContent().'</div>';
  533. if($is_editable)
  534. {
  535. echo
  536. '<p style="text-align:right">'.
  537. '<a href="poster.php?post_id='.$post_id.
  538. '&amp;comment_id='.$rs->f('comment_id').'">'.$com_cancel.'</a>'.
  539. ' - <a href="comment.php?comment_id='.$rs->f('comment_id').'">'.__('edit').'</a>'.
  540. ' - <a href="poster.php?post_id='.$post_id.
  541. '&amp;comment_id='.$rs->f('comment_id').'&amp;comment_del=1" '.
  542. 'onclick="return window.confirm(\''.__('Are you sure you want to delete this comment?').'\');">'.__('delete').'</a>'.
  543. '</p>';
  544. }
  545. echo '</div>';
  546. $rs->moveNext();
  547. }
  548. }
  549. closePage();
  550. ?>