Dotclear

source: plugins/pages/page.php @ 957:3560dcbe4d0c

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

Sites map