Dotclear

source: admin/post.php @ 1459:7f908f9968e0

Revision 1459:7f908f9968e0, 22.4 KB checked in by Denis Jean-Christian <contact@…>, 11 years ago (diff)

Split post help for trackbacks (en, fr), fixes #1499

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 -----------------------------------------
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# Delete post
205if (!empty($_POST['delete']) && $can_delete)
206{
207     try {
208          # --BEHAVIOR-- adminBeforePostDelete
209          $core->callBehavior('adminBeforePostDelete',$post_id);
210          $core->blog->delPost($post_id);
211          http::redirect('posts.php');
212     } catch (Exception $e) {
213          $core->error->add($e->getMessage());
214     }
215}
216
217# Create or update post
218if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt)
219{
220     $cur = $core->con->openCursor($core->prefix.'post');
221     
222     $cur->post_title = $post_title;
223     $cur->cat_id = ($cat_id ? $cat_id : null);
224     $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : '';
225     $cur->post_format = $post_format;
226     $cur->post_password = $post_password;
227     $cur->post_lang = $post_lang;
228     $cur->post_title = $post_title;
229     $cur->post_excerpt = $post_excerpt;
230     $cur->post_excerpt_xhtml = $post_excerpt_xhtml;
231     $cur->post_content = $post_content;
232     $cur->post_content_xhtml = $post_content_xhtml;
233     $cur->post_notes = $post_notes;
234     $cur->post_status = $post_status;
235     $cur->post_selected = (integer) $post_selected;
236     $cur->post_open_comment = (integer) $post_open_comment;
237     $cur->post_open_tb = (integer) $post_open_tb;
238     
239     if (isset($_POST['post_url'])) {
240          $cur->post_url = $post_url;
241     }
242     
243     # Update post
244     if ($post_id)
245     {
246          try
247          {
248               # --BEHAVIOR-- adminBeforePostUpdate
249               $core->callBehavior('adminBeforePostUpdate',$cur,$post_id);
250               
251               $core->blog->updPost($post_id,$cur);
252               
253               # --BEHAVIOR-- adminAfterPostUpdate
254               $core->callBehavior('adminAfterPostUpdate',$cur,$post_id);
255               
256               http::redirect('post.php?id='.$post_id.'&upd=1');
257          }
258          catch (Exception $e)
259          {
260               $core->error->add($e->getMessage());
261          }
262     }
263     else
264     {
265          $cur->user_id = $core->auth->userID();
266         
267          try
268          {
269               # --BEHAVIOR-- adminBeforePostCreate
270               $core->callBehavior('adminBeforePostCreate',$cur);
271               
272               $return_id = $core->blog->addPost($cur);
273               
274               # --BEHAVIOR-- adminAfterPostCreate
275               $core->callBehavior('adminAfterPostCreate',$cur,$return_id);
276               
277               http::redirect('post.php?id='.$return_id.'&crea=1');
278          }
279          catch (Exception $e)
280          {
281               $core->error->add($e->getMessage());
282          }
283     }
284}
285
286/* DISPLAY
287-------------------------------------------------------- */
288$default_tab = 'edit-entry';
289if (!$can_edit_post) {
290     $default_tab = '';
291}
292if (!empty($_GET['co'])) {
293     $default_tab = 'comments';
294}
295
296if ($post_id) {
297     switch ($post_status) {
298          case 1:
299               $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png');
300               break;
301          case 0:
302               $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png');
303               break;
304          case -1:
305               $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png');
306               break;
307          case -2:
308               $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png');
309               break;
310          default:
311               $img_status = '';
312     }
313     $edit_entry_str = __('&ldquo;%s&rdquo;');
314     $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status;
315} else {
316     $img_status = '';
317}
318
319
320dcPage::open($page_title.' - '.__('Entries'),
321     dcPage::jsDatePicker().
322     dcPage::jsToolBar().
323     dcPage::jsModal().
324     dcPage::jsMetaEditor().
325     dcPage::jsLoad('js/_post.js').
326     dcPage::jsConfirmClose('entry-form','comment-form').
327     # --BEHAVIOR-- adminPostHeaders
328     $core->callBehavior('adminPostHeaders').
329     dcPage::jsPageTabs($default_tab).
330     $next_headlink."\n".$prev_headlink,
331     dcPage::breadcrumb(
332          array(
333               html::escapeHTML($core->blog->name) => '',
334               __('Entries') => 'posts.php',
335               '<span class="page-title">'.($post_id ? $page_title_edit : $page_title).'</span>' => ''
336          ))
337);
338
339if (!empty($_GET['upd'])) {
340     dcPage::message(__('Entry has been successfully updated.'));
341}
342elseif (!empty($_GET['crea'])) {
343     dcPage::message(__('Entry has been successfully created.'));
344}
345elseif (!empty($_GET['attached'])) {
346     dcPage::message(__('File has been successfully attached.'));
347}
348elseif (!empty($_GET['rmattach'])) {
349     dcPage::message(__('Attachment has been successfully removed.'));
350}
351
352if (!empty($_GET['creaco'])) {
353     dcPage::message(__('Comment has been successfully created.'));
354}
355
356# XHTML conversion
357if (!empty($_GET['xconv']))
358{
359     $post_excerpt = $post_excerpt_xhtml;
360     $post_content = $post_content_xhtml;
361     $post_format = 'xhtml';
362     
363     dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.'));
364}
365
366if ($post_id && $post->post_status == 1) {
367     echo '<p><a class="onblog_link" 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>';
368}
369if ($post_id)
370{
371     echo '<p class="nav_prevnext">';
372     if ($prev_link) { echo $prev_link; }
373     if ($next_link && $prev_link) { echo ' | '; }
374     if ($next_link) { echo $next_link; }
375     
376     # --BEHAVIOR-- adminPostNavLinks
377     $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null);
378     
379     echo '</p>';
380}
381
382# Exit if we cannot view page
383if (!$can_view_page) {
384     dcPage::helpBlock('core_post');
385     dcPage::close();
386     exit;
387}
388/* Post form if we can edit post
389-------------------------------------------------------- */
390if ($can_edit_post)
391{
392     $sidebar_items = new ArrayObject(array(
393          'status-box' => array(
394               'title' => __('Status'),
395               'items' => array(
396                    'post_status' => 
397                         '<p class="entry-status"><label for="post_status" class="ib">'.__('Entry status').' '.$img_status.'</label>'.
398                         form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish).
399                         '</p>',
400                    'post_dt' => 
401                         '<p><label for="post_dt" class="ib">'.__('Publication date and hour').'</label>'.
402                         form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).
403                         '</p>',
404                    'post_lang' =>
405                         '<p><label for="post_lang" class="ib">'.__('Entry lang').'</label>'.
406                         form::combo('post_lang',$lang_combo,$post_lang).
407                         '</p>',
408                    'post_format' =>
409                         '<p><label for="post_format" class="ib">'.__('Text formating').'</label>'.
410                         form::combo('post_format',$formaters_combo,$post_format,'maximal').
411                         '</p>'.
412                         '<p>'.($post_id && $post_format != 'xhtml' ? 
413                         '<a id="convert-xhtml" class="button maximal" href="post.php?id='.$post_id.'&amp;xconv=1">'.
414                         __('Convert to XHTML').'</a>' : '').'</p>')),
415          'metas-box' => array(
416               'title' => __('Ordering'),
417               'items' => array(
418                    'post_selected' => 
419                         '<p><label for="post_selected" class="classic">'.
420                         form::checkbox('post_selected',1,$post_selected).' '.
421                         __('Selected entry').'</label></p>',
422                    'cat_id' =>
423                         '<p><label for="cat_id" class="ib">'.__('Category').'</label>'.
424                         form::combo('cat_id',$categories_combo,$cat_id,'maximal').
425                         '</p>')),
426          'options-box' => array(
427               'title' => __('Options'),
428               'items' => array(
429                    'post_open_comment' =>
430                         '<p><label for="post_open_comment" class="classic">'.
431                         form::checkbox('post_open_comment',1,$post_open_comment).' '.
432                         __('Accept comments').'</label></p>'.
433                         ($core->blog->settings->system->allow_comments ? 
434                              (isContributionAllowed($post_id,strtotime($post_dt),true) ? 
435                                   '' :
436                                   '<p class="form-note warn">'.
437                                   __('Warning: Comments are not more accepted for this entry.').'</p>') : 
438                              '<p class="form-note warn">'.
439                              __('Warning: Comments are not accepted on this blog.').'</p>'),
440                    'post_open_tb' =>
441                         '<p><label for="post_open_tb" class="classic">'.
442                         form::checkbox('post_open_tb',1,$post_open_tb).' '.
443                         __('Accept trackbacks').'</label></p>'.
444                         ($core->blog->settings->system->allow_trackbacks ? 
445                              (isContributionAllowed($post_id,strtotime($post_dt),false) ? 
446                                   '' :
447                                   '<p class="form-note warn">'.
448                                   __('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 
449                              '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'),
450                    'post_password' =>
451                         '<p><label for="post_password" class="ib">'.__('Password').'</label>'.
452                         form::field('post_password',10,32,html::escapeHTML($post_password),'maximal').
453                         '</p>',
454                    'post_url' =>
455                         '<div class="lockable">'.
456                         '<p><label for="post_url" class="ib">'.__('Edit basename').'</label>'.
457                         form::field('post_url',10,255,html::escapeHTML($post_url),'maximal').
458                         '</p>'.
459                         '<p class="form-note warn">'.
460                         __('Warning: If you set the URL manually, it may conflict with another entry.').
461                         '</p></div>'
462     ))));
463
464     $main_items = new ArrayObject(array(
465          "post_title" =>
466               '<p class="col">'.
467               '<label class="required no-margin"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'.
468               form::field('post_title',20,255,html::escapeHTML($post_title),'maximal').
469               '</p>',
470         
471          "post_excerpt" =>
472               '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'<span class="form-note">'.
473               __('Add an introduction to the post.').'</span></label> '.
474               form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)).
475               '</p>',
476         
477          "post_content" =>
478               '<p class="area"><label class="required" '.
479               'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '.
480               form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)).
481               '</p>',
482         
483          "post_notes" =>
484               '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').'<span class="form-note">'.
485               __('Add unpublished notes.').'</span></label>'.
486               form::textarea('post_notes',50,5,html::escapeHTML($post_notes)).
487               '</p>'
488          )
489     );
490     
491     # --BEHAVIOR-- adminPostFormItems
492     $core->callBehavior('adminPostFormItems',$main_items,$sidebar_items, isset($post) ? $post : null);
493
494     echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">';
495     echo '<form action="post.php" method="post" id="entry-form">';
496     echo '<div id="entry-wrapper">';
497     echo '<div id="entry-content"><div class="constrained">';
498
499     echo '<h3 class="hidden">'.__('Edit post').'</h3>';
500     
501     foreach ($main_items as $id => $item) {
502          echo $item;
503     }
504
505     # --BEHAVIOR-- adminPostForm (may be deprecated)
506     $core->callBehavior('adminPostForm',isset($post) ? $post : null);
507     
508     echo
509     '<p class="border-top">'.
510     ($post_id ? form::hidden('id',$post_id) : '').
511     '<input type="submit" value="'.__('Save').' (s)" '.
512     'accesskey="s" name="save" /> ';
513     if ($post_id) {
514          $preview_url =
515          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'.
516          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')).
517          '/'.$post->post_url);
518          echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> ';
519     } else {
520          echo
521          '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>';
522     }
523
524     echo
525     ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : '').
526     $core->formNonce().
527     '</p>';
528     
529     echo '</div></div>';          // End #entry-content
530     echo '</div>';      // End #entry-wrapper
531
532     echo '<div id="entry-sidebar">';
533     
534     foreach ($sidebar_items as $id => $c) {
535          echo '<div id="'.$id.'" class="box">'.
536               '<h4>'.$c['title'].'</h4>';
537          foreach ($c['items'] as $e_name=>$e_content) {
538               echo $e_content;
539          }
540          echo '</div>';
541     }
542     
543     
544     # --BEHAVIOR-- adminPostFormSidebar (may be deprecated)
545     $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null);
546     echo '</div>';      // End #entry-sidebar
547
548     echo '</form>';
549     
550     # --BEHAVIOR-- adminPostForm
551     $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null);
552     
553     echo '</div>';
554     
555     if ($post_id && $post->post_status == 1) {
556          echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'.
557          __('Ping blogs').'</a></p>';
558     }
559     
560}
561
562
563/* Comments and trackbacks
564-------------------------------------------------------- */
565if ($post_id)
566{
567     $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');
568     
569     $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0)));
570     $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1)));
571     
572     # Actions combo box
573     $combo_action = array();
574     if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id))
575     {
576          $combo_action[__('Publish')] = 'publish';
577          $combo_action[__('Unpublish')] = 'unpublish';
578          $combo_action[__('Mark as pending')] = 'pending';
579          $combo_action[__('Mark as junk')] = 'junk';
580     }
581     
582     if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id))
583     {
584          $combo_action[__('Delete')] = 'delete';
585     }
586     
587     # --BEHAVIOR-- adminCommentsActionsCombo
588     $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
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" id="form-comments" method="post">';
597     }
598     
599     echo '<h3>'.__('Trackbacks').'</h3>';
600     
601     if (!$trackbacks->isEmpty()) {
602          showComments($trackbacks,$has_action,true);
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','post.php?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> '.
654     __('Comment:').'</label> '.
655     form::textarea('comment_content',50,8,html::escapeHTML('')).
656     '</p>'.
657     
658     '<p>'.form::hidden('post_id',$post_id).
659     $core->formNonce().
660     '<input type="submit" name="add" value="'.__('Save').'" /></p>'.
661     '</div>'.
662     '</form>'.
663     '</div>';
664}
665
666# Controls comments or trakbacks capabilities
667function isContributionAllowed($id,$dt,$com=true)
668{
669     global $core;
670
671     if (!$id) {
672          return true;
673     }
674     if ($com) {
675          if (($core->blog->settings->system->comments_ttl == 0) || 
676               (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) {
677               return true;
678          }
679     } else {
680          if (($core->blog->settings->system->trackbacks_ttl == 0) || 
681               (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) {
682               return true;
683          }
684     }
685     return false;
686}
687
688# Show comments or trackbacks
689function showComments($rs,$has_action,$tb=false)
690{
691     echo
692     '<table class="comments-list"><tr>'.
693     '<th colspan="2">'.__('Author').'</th>'.
694     '<th>'.__('Date').'</th>'.
695     '<th class="nowrap">'.__('IP address').'</th>'.
696     '<th>'.__('Status').'</th>'.
697     '<th>&nbsp;</th>'.
698     '</tr>';
699     
700     while($rs->fetch())
701     {
702          $comment_url = 'comment.php?id='.$rs->comment_id;
703         
704          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
705          switch ($rs->comment_status) {
706               case 1:
707                    $img_status = sprintf($img,__('Published'),'check-on.png');
708                    break;
709               case 0:
710                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
711                    break;
712               case -1:
713                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
714                    break;
715               case -2:
716                    $img_status = sprintf($img,__('Junk'),'junk.png');
717                    break;
718          }
719         
720          echo
721          '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'.
722          ' id="c'.$rs->comment_id.'">'.
723         
724          '<td class="nowrap">'.
725          ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'.
726          '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'.
727          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'.
728          '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'.
729          '<td class="nowrap status">'.$img_status.'</td>'.
730          '<td class="nowrap status"><a href="'.$comment_url.'">'.
731          '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'.
732         
733          '</tr>';
734     }
735     
736     echo '</table>';
737}
738
739dcPage::helpBlock('core_post','core_trackbacks','core_wiki');
740dcPage::close();
741?>
Note: See TracBrowser for help on using the repository browser.

Sites map