Dotclear

source: plugins/pages/page.php @ 1617:47b43ca4c6a7

Revision 1617:47b43ca4c6a7, 21.8 KB checked in by Dsls, 11 years ago (diff)

Updated pages plugin the same way as post.php, see #1533

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

Sites map