Dotclear

source: admin/post.php @ 957:3560dcbe4d0c

Revision 957:3560dcbe4d0c, 20.4 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

add publication date validation on post and page editing forms, fixes #817

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17$post_id = '';
18$cat_id = '';
19$post_dt = '';
20$post_format = $core->auth->getOption('post_format');
21$post_password = '';
22$post_url = '';
23$post_lang = $core->auth->getInfo('user_lang');
24$post_title = '';
25$post_excerpt = '';
26$post_excerpt_xhtml = '';
27$post_content = '';
28$post_content_xhtml = '';
29$post_notes = '';
30$post_status = $core->auth->getInfo('user_post_status');
31$post_selected = false;
32$post_open_comment = $core->blog->settings->system->allow_comments;
33$post_open_tb = $core->blog->settings->system->allow_trackbacks;
34
35$page_title = __('New entry');
36
37$can_view_page = true;
38$can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id);
39$can_publish = $core->auth->check('publish,contentadmin',$core->blog->id);
40$can_delete = false;
41
42$post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />';
43$post_link = '<a href="post.php?id=%s" title="%s">%s</a>';
44
45$next_link = $prev_link = $next_headlink = $prev_headlink = null;
46
47# If user can't publish
48if (!$can_publish) {
49     $post_status = -2;
50}
51
52# Getting categories
53$categories_combo = array('&nbsp;' => '');
54try {
55     $categories = $core->blog->getCategories(array('post_type'=>'post'));
56     while ($categories->fetch()) {
57          $categories_combo[] = new formSelectOption(
58               str_repeat('&nbsp;&nbsp;',$categories->level-1).($categories->level-1 == 0 ? '' : '&bull; ').html::escapeHTML($categories->cat_title),
59               $categories->cat_id
60          );
61     }
62} catch (Exception $e) { }
63
64# Status combo
65foreach ($core->blog->getAllPostStatus() as $k => $v) {
66     $status_combo[$v] = (string) $k;
67}
68$img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />';
69
70# Formaters combo
71foreach ($core->getFormaters() as $v) {
72     $formaters_combo[$v] = $v;
73}
74
75# Languages combo
76$rs = $core->blog->getLangs(array('order'=>'asc'));
77$all_langs = l10n::getISOcodes(0,1);
78$lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1));
79while ($rs->fetch()) {
80     if (isset($all_langs[$rs->post_lang])) {
81          $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang;
82          unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]);
83     } else {
84          $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang;
85     }
86}
87unset($all_langs);
88unset($rs);
89
90# Validation flag
91$bad_dt = false;
92
93# Get entry informations
94if (!empty($_REQUEST['id']))
95{
96     $params['post_id'] = $_REQUEST['id'];
97     
98     $post = $core->blog->getPosts($params);
99     
100     if ($post->isEmpty())
101     {
102          $core->error->add(__('This entry does not exist.'));
103          $can_view_page = false;
104     }
105     else
106     {
107          $post_id = $post->post_id;
108          $cat_id = $post->cat_id;
109          $post_dt = date('Y-m-d H:i',strtotime($post->post_dt));
110          $post_format = $post->post_format;
111          $post_password = $post->post_password;
112          $post_url = $post->post_url;
113          $post_lang = $post->post_lang;
114          $post_title = $post->post_title;
115          $post_excerpt = $post->post_excerpt;
116          $post_excerpt_xhtml = $post->post_excerpt_xhtml;
117          $post_content = $post->post_content;
118          $post_content_xhtml = $post->post_content_xhtml;
119          $post_notes = $post->post_notes;
120          $post_status = $post->post_status;
121          $post_selected = (boolean) $post->post_selected;
122          $post_open_comment = (boolean) $post->post_open_comment;
123          $post_open_tb = (boolean) $post->post_open_tb;
124         
125          $page_title = __('Edit entry');
126         
127          $can_edit_post = $post->isEditable();
128          $can_delete= $post->isDeletable();
129         
130          $next_rs = $core->blog->getNextPost($post,1);
131          $prev_rs = $core->blog->getNextPost($post,-1);
132         
133          if ($next_rs !== null) {
134               $next_link = sprintf($post_link,$next_rs->post_id,
135                    html::escapeHTML($next_rs->post_title),__('next entry').'&nbsp;&#187;');
136               $next_headlink = sprintf($post_headlink,'next',
137                    html::escapeHTML($next_rs->post_title),$next_rs->post_id);
138          }
139         
140          if ($prev_rs !== null) {
141               $prev_link = sprintf($post_link,$prev_rs->post_id,
142                    html::escapeHTML($prev_rs->post_title),'&#171;&nbsp;'.__('previous entry'));
143               $prev_headlink = sprintf($post_headlink,'previous',
144                    html::escapeHTML($prev_rs->post_title),$prev_rs->post_id);
145          }
146         
147          try {
148               $core->media = new dcMedia($core);
149          } catch (Exception $e) {}
150     }
151}
152
153# Format excerpt and content
154if (!empty($_POST) && $can_edit_post)
155{
156     $post_format = $_POST['post_format'];
157     $post_excerpt = $_POST['post_excerpt'];
158     $post_content = $_POST['post_content'];
159     
160     $post_title = $_POST['post_title'];
161     
162     $cat_id = (integer) $_POST['cat_id'];
163     
164     if (isset($_POST['post_status'])) {
165          $post_status = (integer) $_POST['post_status'];
166     }
167     
168     if (empty($_POST['post_dt'])) {
169          $post_dt = '';
170     } else {
171          try
172          {
173               $post_dt = strtotime($_POST['post_dt']);
174               if ($post_dt == false || $post_dt == -1) {
175                    $bad_dt = true;
176                    throw new Exception(__('Invalid publication date'));
177               }
178               $post_dt = date('Y-m-d H:i',$post_dt);
179          }
180          catch (Exception $e)
181          {
182               $core->error->add($e->getMessage());
183          }
184     }
185     
186     $post_open_comment = !empty($_POST['post_open_comment']);
187     $post_open_tb = !empty($_POST['post_open_tb']);
188     $post_selected = !empty($_POST['post_selected']);
189     $post_lang = $_POST['post_lang'];
190     $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null;
191     
192     $post_notes = $_POST['post_notes'];
193     
194     if (isset($_POST['post_url'])) {
195          $post_url = $_POST['post_url'];
196     }
197     
198     $core->blog->setPostContent(
199          $post_id,$post_format,$post_lang,
200          $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml
201     );
202}
203
204# Create or update post
205if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt)
206{
207     $cur = $core->con->openCursor($core->prefix.'post');
208     
209     $cur->post_title = $post_title;
210     $cur->cat_id = ($cat_id ? $cat_id : null);
211     $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : '';
212     $cur->post_format = $post_format;
213     $cur->post_password = $post_password;
214     $cur->post_lang = $post_lang;
215     $cur->post_title = $post_title;
216     $cur->post_excerpt = $post_excerpt;
217     $cur->post_excerpt_xhtml = $post_excerpt_xhtml;
218     $cur->post_content = $post_content;
219     $cur->post_content_xhtml = $post_content_xhtml;
220     $cur->post_notes = $post_notes;
221     $cur->post_status = $post_status;
222     $cur->post_selected = (integer) $post_selected;
223     $cur->post_open_comment = (integer) $post_open_comment;
224     $cur->post_open_tb = (integer) $post_open_tb;
225     
226     if (isset($_POST['post_url'])) {
227          $cur->post_url = $post_url;
228     }
229     
230     # Update post
231     if ($post_id)
232     {
233          try
234          {
235               # --BEHAVIOR-- adminBeforePostUpdate
236               $core->callBehavior('adminBeforePostUpdate',$cur,$post_id);
237               
238               $core->blog->updPost($post_id,$cur);
239               
240               # --BEHAVIOR-- adminAfterPostUpdate
241               $core->callBehavior('adminAfterPostUpdate',$cur,$post_id);
242               
243               http::redirect('post.php?id='.$post_id.'&upd=1');
244          }
245          catch (Exception $e)
246          {
247               $core->error->add($e->getMessage());
248          }
249     }
250     else
251     {
252          $cur->user_id = $core->auth->userID();
253         
254          try
255          {
256               # --BEHAVIOR-- adminBeforePostCreate
257               $core->callBehavior('adminBeforePostCreate',$cur);
258               
259               $return_id = $core->blog->addPost($cur);
260               
261               # --BEHAVIOR-- adminAfterPostCreate
262               $core->callBehavior('adminAfterPostCreate',$cur,$return_id);
263               
264               http::redirect('post.php?id='.$return_id.'&crea=1');
265          }
266          catch (Exception $e)
267          {
268               $core->error->add($e->getMessage());
269          }
270     }
271}
272
273if (!empty($_POST['delete']) && $can_delete)
274{
275     try {
276          # --BEHAVIOR-- adminBeforePostDelete
277          $core->callBehavior('adminBeforePostDelete',$post_id);
278          $core->blog->delPost($post_id);
279          http::redirect('posts.php');
280     } catch (Exception $e) {
281          $core->error->add($e->getMessage());
282     }
283}
284
285/* DISPLAY
286-------------------------------------------------------- */
287$default_tab = 'edit-entry';
288if (!$can_edit_post) {
289     $default_tab = '';
290}
291if (!empty($_GET['co'])) {
292     $default_tab = 'comments';
293}
294
295dcPage::open($page_title.' - '.__('Entries'),
296     dcPage::jsDatePicker().
297     dcPage::jsToolBar().
298     dcPage::jsModal().
299     dcPage::jsMetaEditor().
300     dcPage::jsLoad('js/_post.js').
301     dcPage::jsConfirmClose('entry-form','comment-form').
302     # --BEHAVIOR-- adminPostHeaders
303     $core->callBehavior('adminPostHeaders').
304     dcPage::jsPageTabs($default_tab).
305     $next_headlink."\n".$prev_headlink
306);
307
308if (!empty($_GET['upd'])) {
309     dcPage::message(__('Entry has been successfully updated.'));
310}
311elseif (!empty($_GET['crea'])) {
312     dcPage::message(__('Entry has been successfully created.'));
313}
314elseif (!empty($_GET['attached'])) {
315     dcPage::message(__('File has been successfully attached.'));
316}
317elseif (!empty($_GET['rmattach'])) {
318     dcPage::message(__('Attachment has been successfully removed.'));
319}
320
321if (!empty($_GET['creaco'])) {
322     dcPage::message(__('Comment has been successfully created.'));
323}
324
325# XHTML conversion
326if (!empty($_GET['xconv']))
327{
328     $post_excerpt = $post_excerpt_xhtml;
329     $post_content = $post_content_xhtml;
330     $post_format = 'xhtml';
331     
332     dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.'));
333}
334
335echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.'<a href="posts.php">'.__('Entries').'</a> &rsaquo; <span class="page-title">'.$page_title;
336if ($post_id) {
337     switch ($post_status) {
338          case 1:
339               $img_status = sprintf($img_status_pattern,__('published'),'check-on.png');
340               break;
341          case 0:
342               $img_status = sprintf($img_status_pattern,__('unpublished'),'check-off.png');
343               break;
344          case -1:
345               $img_status = sprintf($img_status_pattern,__('scheduled'),'scheduled.png');
346               break;
347          case -2:
348               $img_status = sprintf($img_status_pattern,__('pending'),'check-wrn.png');
349               break;
350          default:
351               $img_status = '';
352     }
353     echo ' &ldquo;'.$post_title.'&rdquo;'.' '.$img_status;
354}
355echo '</span></h2>';
356
357if ($post_id && $post->post_status == 1) {
358     echo '<p><a href="'.$post->getURL().'" onclick="window.open(this.href);return false;" title="'.$post_title.' ('.__('new window').')'.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>';
359}
360if ($post_id)
361{
362     echo '<p>';
363     if ($prev_link) { echo $prev_link; }
364     if ($next_link && $prev_link) { echo ' - '; }
365     if ($next_link) { echo $next_link; }
366     
367     # --BEHAVIOR-- adminPostNavLinks
368     $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null);
369     
370     echo '</p>';
371}
372
373# Exit if we cannot view page
374if (!$can_view_page) {
375     dcPage::helpBlock('core_post');
376     dcPage::close();
377     exit;
378}
379
380/* Post form if we can edit post
381-------------------------------------------------------- */
382if ($can_edit_post)
383{
384     echo '<div class="multi-part" title="'.__('Edit entry').'" id="edit-entry">';
385     echo '<form action="post.php" method="post" id="entry-form">';
386     echo '<div id="entry-wrapper">';
387     echo '<div id="entry-content"><div class="constrained">';
388     
389     echo
390     '<p class="col"><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').
391     form::field('post_title',20,255,html::escapeHTML($post_title),'maximal').
392     '</label></p>'.
393     
394     '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '.
395     form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)).
396     '</p>'.
397     
398     '<p class="area"><label class="required" '.
399     'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '.
400     form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)).
401     '</p>'.
402     
403     '<p class="area" id="notes-area"><label for="post_notes">'.__('Notes:').'</label>'.
404     form::textarea('post_notes',50,5,html::escapeHTML($post_notes)).
405     '</p>';
406     
407     # --BEHAVIOR-- adminPostForm
408     $core->callBehavior('adminPostForm',isset($post) ? $post : null);
409     
410     echo
411     '<p>'.
412     ($post_id ? form::hidden('id',$post_id) : '').
413     '<input type="submit" value="'.__('Save').' (s)" '.
414     'accesskey="s" name="save" /> ';
415     if ($post_id) {
416          $preview_url =
417          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'.
418          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')).
419          '/'.$post->post_url);
420          echo '<a id="post-preview" href="'.$preview_url.'" class="button">'.__('Preview').'</a> ';
421     }
422     echo
423     ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : '').
424     $core->formNonce().
425     '</p>';
426     
427     echo '</div></div>';          // End #entry-content
428     echo '</div>';      // End #entry-wrapper
429
430     echo '<div id="entry-sidebar">';
431     
432     echo
433     '<p><label for="cat_id">'.__('Category:').
434     form::combo('cat_id',$categories_combo,$cat_id,'maximal').
435     '</label></p>'.
436     
437     '<p><label for="post_status">'.__('Entry status:').
438     form::combo('post_status',$status_combo,$post_status,'','',!$can_publish).
439     '</label></p>'.
440     
441     '<p><label for="post_dt">'.__('Published on:').
442     form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).
443     '</label></p>'.
444     
445     '<p><label for="post_format">'.__('Text formating:').
446     form::combo('post_format',$formaters_combo,$post_format).
447     '</label>'.
448     '</p>'.
449     '<p>'.($post_id && $post_format != 'xhtml' ? '<a id="convert-xhtml" class="button" href="post.php?id='.$post_id.'&amp;xconv=1">'.__('Convert to XHTML').'</a>' : '').'</p>'.
450     
451     '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '.
452     __('Accept comments').'</label></p>'.
453     ($core->blog->settings->system->allow_comments ? 
454          (isContributionAllowed($post_id,strtotime($post_dt),true) ? 
455               '' :
456               '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : 
457          '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>').
458
459     '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '.
460     __('Accept trackbacks').'</label></p>'.
461     ($core->blog->settings->system->allow_trackbacks ? 
462          (isContributionAllowed($post_id,strtotime($post_dt),false) ? 
463               '' :
464               '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 
465          '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>').
466
467     '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '.
468     __('Selected entry').'</label></p>'.
469     
470     '<p><label for="post_lang">'.__('Entry lang:').
471     form::combo('post_lang',$lang_combo,$post_lang).
472     '</label></p>'.
473     
474     '<p><label for="post_password">'.__('Entry password:').
475     form::field('post_password',10,32,html::escapeHTML($post_password),'maximal').
476     '</label></p>'.
477     
478     '<div class="lockable">'.
479     '<p><label for="post_url">'.__('Basename:').
480     form::field('post_url',10,255,html::escapeHTML($post_url),'maximal').
481     '</label></p>'.
482     '<p class="form-note warn">'.
483     __('Warning: If you set the URL manually, it may conflict with another entry.').
484     '</p>'.
485     '</div>';
486     
487     # --BEHAVIOR-- adminPostFormSidebar
488     $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null);
489     
490     echo '</div>';      // End #entry-sidebar
491
492     echo '</form>';
493     
494     # --BEHAVIOR-- adminPostForm
495     $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null);
496     
497     echo '</div>';
498     
499     if ($post_id && $post->post_status == 1) {
500          echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'.
501          __('Ping blogs').'</a></p>';
502     }
503     
504}
505
506
507/* Comments and trackbacks
508-------------------------------------------------------- */
509if ($post_id)
510{
511     $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');
512     
513     $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0)));
514     $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1)));
515     
516     # Actions combo box
517     $combo_action = array();
518     if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id))
519     {
520          $combo_action[__('publish')] = 'publish';
521          $combo_action[__('unpublish')] = 'unpublish';
522          $combo_action[__('mark as pending')] = 'pending';
523          $combo_action[__('mark as junk')] = 'junk';
524     }
525     
526     if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id))
527     {
528          $combo_action[__('Delete')] = 'delete';
529     }
530     
531     # --BEHAVIOR-- adminCommentsActionsCombo
532     $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
533     
534     $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty());
535     
536     echo
537     '<div id="comments" class="multi-part" title="'.__('Comments').'">';
538     
539     if ($has_action) {
540          echo '<form action="comments_actions.php" id="form-comments" method="post">';
541     }
542     
543     echo '<h3>'.__('Trackbacks').'</h3>';
544     
545     if (!$trackbacks->isEmpty()) {
546          showComments($trackbacks,$has_action,true);
547     } else {
548          echo '<p>'.__('No trackback').'</p>';
549     }
550     
551     echo '<h3>'.__('Comments').'</h3>';
552     if (!$comments->isEmpty()) {
553          showComments($comments,$has_action);
554     } else {
555          echo '<p>'.__('No comment').'</p>';
556     }
557     
558     if ($has_action) {
559          echo
560          '<div class="two-cols">'.
561          '<p class="col checkboxes-helpers"></p>'.
562         
563          '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.
564          form::combo('action',$combo_action).
565          form::hidden('redir','post.php?id='.$post_id.'&amp;co=1').
566          $core->formNonce().
567          '<input type="submit" value="'.__('ok').'" /></p>'.
568          '</div>'.
569          '</form>';
570     }
571     
572     echo '</div>';
573}
574
575/* Add a comment
576-------------------------------------------------------- */
577if ($post_id)
578{
579     echo
580     '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'.
581     '<h3>'.__('Add a comment').'</h3>'.
582     
583     '<form action="comment.php" method="post" id="comment-form">'.
584     '<div class="constrained">'.
585     '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').
586     form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))).
587     '</label></p>'.
588     
589     '<p><label for="comment_email">'.__('Email:').
590     form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))).
591     '</label></p>'.
592     
593     '<p><label for="comment_site">'.__('Web site:').
594     form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))).
595     '</label></p>'.
596     
597     '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.
598     __('Comment:').'</label> '.
599     form::textarea('comment_content',50,8,html::escapeHTML('')).
600     '</p>'.
601     
602     '<p>'.form::hidden('post_id',$post_id).
603     $core->formNonce().
604     '<input type="submit" name="add" value="'.__('Save').'" /></p>'.
605     '</div>'.
606     '</form>'.
607     '</div>';
608}
609
610# Controls comments or trakbacks capabilities
611function isContributionAllowed($id,$dt,$com=true)
612{
613     global $core;
614
615     if (!$id) {
616          return true;
617     }
618     if ($com) {
619          if (($core->blog->settings->system->comments_ttl == 0) || 
620               (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) {
621               return true;
622          }
623     } else {
624          if (($core->blog->settings->system->trackbacks_ttl == 0) || 
625               (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) {
626               return true;
627          }
628     }
629     return false;
630}
631
632# Show comments or trackbacks
633function showComments($rs,$has_action,$tb=false)
634{
635     echo
636     '<table class="comments-list"><tr>'.
637     '<th colspan="2">'.__('Author').'</th>'.
638     '<th>'.__('Date').'</th>'.
639     '<th class="nowrap">'.__('IP address').'</th>'.
640     '<th>'.__('Status').'</th>'.
641     '<th>&nbsp;</th>'.
642     '</tr>';
643     
644     while($rs->fetch())
645     {
646          $comment_url = 'comment.php?id='.$rs->comment_id;
647         
648          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
649          switch ($rs->comment_status) {
650               case 1:
651                    $img_status = sprintf($img,__('published'),'check-on.png');
652                    break;
653               case 0:
654                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
655                    break;
656               case -1:
657                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
658                    break;
659               case -2:
660                    $img_status = sprintf($img,__('junk'),'junk.png');
661                    break;
662          }
663         
664          echo
665          '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'.
666          ' id="c'.$rs->comment_id.'">'.
667         
668          '<td class="nowrap">'.
669          ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'.
670          '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'.
671          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'.
672          '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'.
673          '<td class="nowrap status">'.$img_status.'</td>'.
674          '<td class="nowrap status"><a href="'.$comment_url.'">'.
675          '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'.
676         
677          '</tr>';
678     }
679     
680     echo '</table>';
681}
682
683dcPage::helpBlock('core_post','core_wiki');
684dcPage::close();
685?>
Note: See TracBrowser for help on using the repository browser.

Sites map