check(1); include dirname(__FILE__).'/inc/connexion.php'; # Tableau des mois de l'année for ($i=1;$i<=12;$i++) { $m = sprintf('%02d',$i); $arry_dt_m[dt::str('%B',strtotime('2000-'.$m.'-01'))] = $m; } # Les catégories du blog $cat_id = (!empty($_GET['cat_id'])) ? $_GET['cat_id'] : ''; $rsCat = $blog->getCat(); while (!$rsCat->EOF()) { $arry_cat[$rsCat->f('cat_libelle')] = $rsCat->f('cat_id'); $rsCat->moveNext(); } # Valeurs par défaut $err = ''; $titre = ''; $titre_url = ''; $cat_id = $_SESSION['sess_user_pref_cat']; $dt_m = $dt_d = $dt_y = ''; $chapo = $preview_chapo = ''; $content = $preview_content = ''; $notes = ''; $is_editable = true; $format = $_SESSION['sess_user_format']; $etat = $_SESSION['sess_user_post_pub']; $open_comment = 1; $open_tb = 1; $lang = DC_LANG; $selected = 0; $return_link = 'index.php'; $do_trackbacks = false; $objWiki = new wiki2xhtml(); if (dc_encoding != 'UTF-8') { $objWiki->setOpt('active_fix_word_entities',1); } # Billet existant if (!empty($_REQUEST['post_id'])) { $post = $blog->getPostById($_REQUEST['post_id']); if (!$post->isEmpty()) { $post_id = $post->f('post_id'); $titre = $post->f('post_titre'); $titre_url = $post->f('post_titre_url'); $cat_id = $post->f('cat_id'); $format = $post->getFormat(); $etat = (integer) $post->f('post_pub'); $open_comment = (integer) $post->f('post_open_comment'); $open_tb = (integer) $post->f('post_open_tb'); $lang = $post->f('post_lang'); $selected = $post->f('post_selected'); $chapo = ($post->f('post_chapo_wiki') != '') ? $post->f('post_chapo_wiki') : $post->f('post_chapo'); $preview_chapo = $post->f('post_chapo'); $content = ($post->f('post_content_wiki') != '') ? $post->f('post_content_wiki') : $post->f('post_content'); $notes = $post->f('post_notes'); $preview_content = $post->f('post_content'); $return_link = 'index.php?m='.$post->f('postyear').$post->f('postmonth').'#p'.$post_id; $post_ts = $post->getTS(); $post_perm_url = $post->getPermURL(); $dt_y = date('Y',$post_ts); $dt_m = date('m',$post_ts); $dt_d = date('d',$post_ts); $dt_h = (string) date('H',$post_ts); $dt_i = (string) date('i',$post_ts); $dt_s = (string) date('s',$post_ts); $objWiki->setOpt('note_prefix','pnote-'.$post_id); $comments = $blog->getComments($post_id); if (isset($comments)) { $trackbacks = $comments->extractTrackbacks(); } # Le post n'est éditable que par un admin ou son rédacteur, # qu'on se le dise ! if ($post->f('user_id') != $_SESSION['sess_user_id'] && $_SESSION['sess_user_level'] < 9) { $is_editable = false; } # Ajout d'un commentaire if (!empty($_POST['add_comment'])) { if ($blog->addComment($post_id,$_POST['com_nom'], $_POST['com_email'],$_POST['com_web'],$_POST['com_content']) !== false) { header('Location: poster.php?post_id='.$post_id.'#comments'); exit; } else { $err = $blog->error(1); } } # Suppression d'un billet if (!empty($_POST['delete']) && $is_editable) { if ($blog->delPost($post_id) !== false) { $msg = __('Entry successfully removed'); header('Location: index.php?msg='.urlencode($msg)); exit; } else { $err = $blog->error(1); } } } } # Valeurs pour la prévisualisation, la création ou la modification d'un billet if (!empty($_POST['preview']) || !empty($_POST['publish']) || !empty($_POST['transform'])) { $titre = $_POST['p_titre']; $titre_url = $_POST['p_titre_url']; $cat_id = $_POST['p_cat']; $format = $_POST['p_format']; $etat = $_POST['p_etat']; $open_comment = $_POST['p_open_comment']; $open_tb = $_POST['p_open_tb']; $lang = $_POST['p_lang']; $selected = $_POST['p_selected']; $content = $_POST['p_content']; $notes = $_POST['p_notes']; $chapo = $_POST['p_chapo']; $do_trackbacks = !empty($_POST['p_do_trackbacks']) ? true : false; if (!empty($post_id)) { $dt_y = (string) sprintf('%04d',$_POST['p_dt_y']); $dt_m = (string) sprintf('%02d',$_POST['p_dt_m']); $dt_d = (string) sprintf('%02d',$_POST['p_dt_d']); $dt_h = (string) sprintf('%02d',$_POST['p_dt_h']); $dt_i = (string) sprintf('%02d',$_POST['p_dt_i']); $dt_s = (string) sprintf('%02d',$_POST['p_dt_s']); # Corrections jour & heure if ($dt_d > 31 || $dt_d < 1) { $dt_d = '01'; } if ($dt_h > 23 || $dt_h < 0) { $dt_h = '00'; } if ($dt_i > 59 || $dt_i < 0) { $dt_i = '00'; } if ($dt_s > 59 || $dt_s < 0) { $dt_s = '00'; } $new_date = strtotime($dt_y.'-'.$dt_m.'-'.$dt_d.' '.$dt_h.':'.$dt_i.':'.$dt_s); } if (strpos($lang,'fr') === 0) { $objWiki->setOpt('active_fr_syntax',1); } if (!empty($_POST['transform'])) { $format = 'html'; $content = $objWiki->transform($content); $chapo = $objWiki->transform($chapo); } if ($format == 'wiki') { $preview_content = $objWiki->transform($content); $preview_chapo = $objWiki->transform($chapo); } else { $preview_content = $content; $preview_chapo = $chapo; } } # Insertion ou modification d'un billet if (!empty($_POST['publish'])) { # Insertion if (empty($post_id)) { if (($post_id = $blog->addPost($_SESSION['sess_user_id'],$titre,$titre_url,$chapo,$content, $notes,$cat_id,$format,$etat,$open_comment,$open_tb,$lang,$selected, $_SESSION['sess_user_delta'])) !== false) { if ($do_trackbacks) { $return_link = 'trackback.php?post_id='.$post_id.'&auto=1'; } else { $return_link = 'poster.php?post_id='.$post_id; } header('Location: '.$return_link); exit; } else { $err = $blog->error(1); } } else { if ($is_editable) { if ($blog->updPost($post_id,$titre,$titre_url,$chapo,$content,$notes,$cat_id, $format,$etat,$open_comment,$open_tb,$new_date,$lang,$selected, $_SESSION['sess_user_delta']) !== false ) { if ($do_trackbacks) { $return_link = 'trackback.php?post_id='.$post_id.'&auto=1'; } else { $return_link = 'poster.php?post_id='.$post_id; } header('Location: '.$return_link); exit; } else { $err = $blog->error(1); } } } } # Création du sous-menu $mySubMenu->addItem(__('Back to list of entries'),$return_link,'images/ico_retour.png',false); if (!empty($content) && !empty($post_id) && empty($_POST['preview']) && empty($_POST['publish']) && $is_editable) { $mySubMenu->addItem( __('New entry'),array('poster.php','accesskey="n"'), 'images/ico_edit.png',false); $mySubMenu->addItem( __('XHTML validation'), array('validpost.php?post_id='.$post_id,'onclick="popup(this.href); return false;"'), 'images/ico_ok.png',false); $mySubMenu->addItem( __('Trackbacks'), 'trackback.php?post_id='.$post_id, 'images/ico_link.png',false); $mySubMenu->addItem( __('View entry'),$post_perm_url, 'images/ico_goto.png',false); } openPage( __('Entry'), jsHelpers::confirmClose('formPost','formComment'). (($is_editable)?jsHelpers::toolbar():''). '' ); if ($err != '') { echo '

'.__('Error(s)').' :

'. $err.'
'; } echo '

'.__('Entry').'

'; /* Entry preview -------------------------------------------------------- */ if (!empty($content) && dc_show_previews) { if (!empty($_POST['preview'])) { $preview_titre = htmlspecialchars($titre); } else { $preview_titre = $titre; } echo '
'. '

'.$titre.'

'. ((trim($preview_chapo) != '') ? $preview_chapo.'
' : ''). $preview_content.'
'; if (!empty($post_perm_url)) { echo '

'. __('Permanent link').' : '. util::getPageURL($post_perm_url).'

'; } } if (!empty($_POST['preview'])) { $titre = htmlspecialchars($titre); } /* Valeurs pouvant être passées en URL par un bookmarklet -------------------------------------------------------- */ if (!empty($_GET['dcb'])) { $purl = !empty($_GET['purl']) ? $_GET['purl'] : ''; $ptitle = !empty($_GET['ptitle']) ? $_GET['ptitle'] : ''; $ptext = !empty($_GET['ptext']) ? $_GET['ptext'] : ''; $titre = $ptitle; if ($format == 'wiki') { $content = '['.$ptitle.'|'.$purl."]\n\n".$ptext; } else { $content = ''.$ptitle."\n\n

".$ptext.'

'; } } /* Entry form -------------------------------------------------------- */ if ($is_editable) { echo '
'; echo ''; echo ' '. ''; echo ' '. ''; echo ' '. ''; echo '
'.form::combo('p_cat',$arry_cat,$cat_id,'','',1).''.form::combo('p_format',array('HTML'=>'html','Wiki'=>'wiki'),$format,'','',2).''.form::combo('p_etat',array(__('Online')=>'1',__('Offline')=>'0'),$etat,'','',3).'
'; echo '

'. form::field('p_titre',30,255,$titre,4,'class="max"').'

'; echo '

'. form::textArea('p_chapo',60,4,htmlspecialchars($chapo),5,'class="max"').'

'; echo '

'. ''. '

'. '

'.form::textArea('p_content',60,$_SESSION['sess_user_edit_size'], htmlspecialchars($content),6,'class="max"').'

'; echo '

'. ' '. __('More options').'

'; echo '
'. '

'. form::textArea('p_notes',30,6,htmlspecialchars($notes),7,'class="max"').'

'; echo '

'. form::field('p_titre_url',30,255,htmlspecialchars($titre_url),8,'class="max"').'

'; if (!empty($post_id)) { echo '

'. form::field('p_dt_d',2,2,$dt_d,9).' '. form::combo('p_dt_m',$arry_dt_m,$dt_m,'','',10).' '. form::field('p_dt_y',4,4,$dt_y,11).' '. ' '. form::field('p_dt_h',2,2,$dt_h,12).':'. form::field('p_dt_i',2,2,$dt_i,13).':'. form::field('p_dt_s',2,2,$dt_s,14).' '. "".__('now').' '. helpLink('entry','datetime'). '

'; } echo ''; echo ' '. ''; echo ''. ''; echo ' '. ''; echo ''. ''; echo ''; echo '
'; $p_tb_checked = ($do_trackbacks) ? ' checked="checked"' : ''; echo '

'. '

'; echo '

'. '  '. ''; if (!empty($post_id) && $format == 'wiki') { echo ' '; } if (!empty($post_id)) { echo ' '. form::hidden('post_id',$post_id); } echo dcNonce::form(). '

'; echo '
'; } /* Comments -------------------------------------------------------- */ if (!empty($post_id)) { echo '

'.__('Comments').'

'; if (isset($trackbacks)) { echo '

'.__('Trackbacks list').'

'; if (!$trackbacks->isEmpty()) { showComments($trackbacks, true); } else { echo __('No trackback'); } } if (isset($comments)) { echo '

'.__('Comments list').'

'; if (!$comments->isEmpty()) { showComments($comments); } else { echo __('No comment'); } } echo '

'.__('Post a comment').'

'. '
'. '

'. form::field('com_nom',30,255,htmlspecialchars($_SESSION['sess_user_cn'])). '

'; echo '

'. form::field('com_email',30,255,htmlspecialchars($_SESSION['sess_user_email'])). '

'; echo '

'. form::field('com_web',30,255,'http://').'

'; echo '

'. form::textArea('com_content',40,10,'<p></p>','','class="max"').'

'; echo '

'. dcNonce::form(). '

'; echo '
'; echo '

'.__('Notice').' : '.__('This comment has to be in HTML format').'.

'; } # Affichage de commentaires ou trackbacks function showComments(&$rs, $trackbacks = false) { global $is_editable, $post_id; $redir = 'poster.php?post_id='.(integer)$post_id; $comment_actions = array( '' => ' ', 'status' => __('switch status'), 'delete' => __('delete') ); $str_tb = ($rs->f('comment_trackback') == 1) ? ' - trackback' : ''; $html_id = ($rs->f('comment_trackback') == 1) ? 'trackback' : 'comment'; echo '

'. '
'; while(!$rs->EOF()) { if ($rs->f('comment_pub')) { $com_style = ''; $com_img = ' '; } else { $com_style = ' cancel'; $com_img = ' '; } echo '
'; $edit_link = ''; if ($is_editable) { $edit_link .= ' - [ '.__('edit'). ' ]'; } echo '

'. $com_img. form::checkbox('c_ids[]',$rs->f('comment_id'),'','','',!$is_editable). '  '. ''.__('From').' : '.$rs->f('comment_auteur').''.$str_tb. '

'. '

'.dt::str(__('On %A %e %B %Y, %I:%M %p'),$rs->getTS()).$edit_link.'

'. ''. '
'; $rs->moveNext(); } echo '
'. '

'. '

'. dcNonce::form(). form::hidden('redir',$redir). ' '. '

'; } closePage(); ?>