Dotclear

source: plugins/pages/page.php @ 2511:798af8190003

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

Fixes URL of "convert to XHTML" on page edit form, fixes #1838

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

Sites map