Dotclear

source: plugins/pages/page.php @ 986:bc45491ad423

Revision 986:bc45491ad423, 21.4 KB checked in by franck <carnet.franck.paul@…>, 13 years ago (diff)

More consistent term for hidden page, addresses #1353

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

Sites map