Dotclear

source: admin/post.php @ 1421:e8fea3c9a1dd

Revision 1421:e8fea3c9a1dd, 21.7 KB checked in by Denis Jean-Christian <contact@…>, 12 years ago (diff)

Added creation of category on the fly. And under heavy pressure, revert to the other list style, fixes #1424

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><label for="new_cat_title">'.__('Title:').' '.
469          form::field('new_cat_title',30,255,'','maximal').'</label></p>'.
470          '<p><label for="new_cat_parent">'.__('Parent:').' '.
471          form::combo('new_cat_parent',$categories_combo,'','maximal').
472          '</label></p>'.
473          '</div>'
474     : '').
475     
476     '<p><label for="post_status">'.__('Entry status:').
477     form::combo('post_status',$status_combo,$post_status,'','',!$can_publish).
478     '</label></p>'.
479     
480     '<p><label for="post_dt">'.__('Published on:').
481     form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).
482     '</label></p>'.
483     
484     '<p><label for="post_format">'.__('Text formating:').
485     form::combo('post_format',$formaters_combo,$post_format).
486     '</label>'.
487     '</p>'.
488     '<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>'.
489     
490     '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '.
491     __('Accept comments').'</label></p>'.
492     ($core->blog->settings->system->allow_comments ? 
493          (isContributionAllowed($post_id,strtotime($post_dt),true) ? 
494               '' :
495               '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : 
496          '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>').
497
498     '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '.
499     __('Accept trackbacks').'</label></p>'.
500     ($core->blog->settings->system->allow_trackbacks ? 
501          (isContributionAllowed($post_id,strtotime($post_dt),false) ? 
502               '' :
503               '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 
504          '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>').
505
506     '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '.
507     __('Selected entry').'</label></p>'.
508     
509     '<p><label for="post_lang">'.__('Entry lang:').
510     form::combo('post_lang',$lang_combo,$post_lang).
511     '</label></p>'.
512     
513     '<p><label for="post_password">'.__('Entry password:').
514     form::field('post_password',10,32,html::escapeHTML($post_password),'maximal').
515     '</label></p>'.
516     
517     '<div class="lockable">'.
518     '<p><label for="post_url">'.__('Basename:').
519     form::field('post_url',10,255,html::escapeHTML($post_url),'maximal').
520     '</label></p>'.
521     '<p class="form-note warn">'.
522     __('Warning: If you set the URL manually, it may conflict with another entry.').
523     '</p>'.
524     '</div>';
525     
526     # --BEHAVIOR-- adminPostFormSidebar
527     $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null);
528     
529     echo '</div>';      // End #entry-sidebar
530
531     echo '</form>';
532     
533     # --BEHAVIOR-- adminPostForm
534     $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null);
535     
536     echo '</div>';
537     
538     if ($post_id && $post->post_status == 1) {
539          echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'.
540          __('Ping blogs').'</a></p>';
541     }
542     
543}
544
545
546/* Comments and trackbacks
547-------------------------------------------------------- */
548if ($post_id)
549{
550     $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');
551     
552     $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0)));
553     $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1)));
554     
555     # Actions combo box
556     $combo_action = array();
557     if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id))
558     {
559          $combo_action[__('publish')] = 'publish';
560          $combo_action[__('unpublish')] = 'unpublish';
561          $combo_action[__('mark as pending')] = 'pending';
562          $combo_action[__('mark as junk')] = 'junk';
563     }
564     
565     if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id))
566     {
567          $combo_action[__('Delete')] = 'delete';
568     }
569     
570     # --BEHAVIOR-- adminCommentsActionsCombo
571     $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
572     
573     $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty());
574     
575     echo
576     '<div id="comments" class="multi-part" title="'.__('Comments').'">';
577     
578     if ($has_action) {
579          echo '<form action="comments_actions.php" id="form-comments" method="post">';
580     }
581     
582     echo '<h3>'.__('Trackbacks').'</h3>';
583     
584     if (!$trackbacks->isEmpty()) {
585          showComments($trackbacks,$has_action,true);
586     } else {
587          echo '<p>'.__('No trackback').'</p>';
588     }
589     
590     echo '<h3>'.__('Comments').'</h3>';
591     if (!$comments->isEmpty()) {
592          showComments($comments,$has_action);
593     } else {
594          echo '<p>'.__('No comment').'</p>';
595     }
596     
597     if ($has_action) {
598          echo
599          '<div class="two-cols">'.
600          '<p class="col checkboxes-helpers"></p>'.
601         
602          '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.
603          form::combo('action',$combo_action).
604          form::hidden('redir','post.php?id='.$post_id.'&amp;co=1').
605          $core->formNonce().
606          '<input type="submit" value="'.__('ok').'" /></p>'.
607          '</div>'.
608          '</form>';
609     }
610     
611     echo '</div>';
612}
613
614/* Add a comment
615-------------------------------------------------------- */
616if ($post_id)
617{
618     echo
619     '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'.
620     '<h3>'.__('Add a comment').'</h3>'.
621     
622     '<form action="comment.php" method="post" id="comment-form">'.
623     '<div class="constrained">'.
624     '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').
625     form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))).
626     '</label></p>'.
627     
628     '<p><label for="comment_email">'.__('Email:').
629     form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))).
630     '</label></p>'.
631     
632     '<p><label for="comment_site">'.__('Web site:').
633     form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))).
634     '</label></p>'.
635     
636     '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.
637     __('Comment:').'</label> '.
638     form::textarea('comment_content',50,8,html::escapeHTML('')).
639     '</p>'.
640     
641     '<p>'.form::hidden('post_id',$post_id).
642     $core->formNonce().
643     '<input type="submit" name="add" value="'.__('Save').'" /></p>'.
644     '</div>'.
645     '</form>'.
646     '</div>';
647}
648
649# Controls comments or trakbacks capabilities
650function isContributionAllowed($id,$dt,$com=true)
651{
652     global $core;
653
654     if (!$id) {
655          return true;
656     }
657     if ($com) {
658          if (($core->blog->settings->system->comments_ttl == 0) || 
659               (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) {
660               return true;
661          }
662     } else {
663          if (($core->blog->settings->system->trackbacks_ttl == 0) || 
664               (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) {
665               return true;
666          }
667     }
668     return false;
669}
670
671# Show comments or trackbacks
672function showComments($rs,$has_action,$tb=false)
673{
674     echo
675     '<table class="comments-list"><tr>'.
676     '<th colspan="2">'.__('Author').'</th>'.
677     '<th>'.__('Date').'</th>'.
678     '<th class="nowrap">'.__('IP address').'</th>'.
679     '<th>'.__('Status').'</th>'.
680     '<th>&nbsp;</th>'.
681     '</tr>';
682     
683     while($rs->fetch())
684     {
685          $comment_url = 'comment.php?id='.$rs->comment_id;
686         
687          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
688          switch ($rs->comment_status) {
689               case 1:
690                    $img_status = sprintf($img,__('published'),'check-on.png');
691                    break;
692               case 0:
693                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
694                    break;
695               case -1:
696                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
697                    break;
698               case -2:
699                    $img_status = sprintf($img,__('junk'),'junk.png');
700                    break;
701          }
702         
703          echo
704          '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'.
705          ' id="c'.$rs->comment_id.'">'.
706         
707          '<td class="nowrap">'.
708          ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'.
709          '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'.
710          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'.
711          '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'.
712          '<td class="nowrap status">'.$img_status.'</td>'.
713          '<td class="nowrap status"><a href="'.$comment_url.'">'.
714          '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'.
715         
716          '</tr>';
717     }
718     
719     echo '</table>';
720}
721
722dcPage::helpBlock('core_post','core_wiki');
723dcPage::close();
724?>
Note: See TracBrowser for help on using the repository browser.

Sites map