Dotclear

source: admin/post.php @ 1488:bd03ce853d14

Revision 1488:bd03ce853d14, 21.8 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Add notice about new category auto-creation

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

Sites map