Dotclear

source: admin/post.php @ 1964:bfde9296c3c5

Revision 1964:bfde9296c3c5, 27.0 KB checked in by Krazy Kitty <krazykitty@…>, 12 years ago (diff)

A few English language modifications to posts and pages. Only modified the .php and corresponding .html, did not touch the .po

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17$post_id = '';
18$cat_id = '';
19$post_dt = '';
20$post_format = $core->auth->getOption('post_format');
21$post_password = '';
22$post_url = '';
23$post_lang = $core->auth->getInfo('user_lang');
24$post_title = '';
25$post_excerpt = '';
26$post_excerpt_xhtml = '';
27$post_content = '';
28$post_content_xhtml = '';
29$post_notes = '';
30$post_status = $core->auth->getInfo('user_post_status');
31$post_selected = false;
32$post_open_comment = $core->blog->settings->system->allow_comments;
33$post_open_tb = $core->blog->settings->system->allow_trackbacks;
34
35$page_title = __('New entry');
36
37$can_view_page = true;
38$can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id);
39$can_publish = $core->auth->check('publish,contentadmin',$core->blog->id);
40$can_delete = false;
41
42$post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />';
43$post_link = '<a href="post.php?id=%s" title="%s">%s</a>';
44
45$next_link = $prev_link = $next_headlink = $prev_headlink = null;
46
47# If user can't publish
48if (!$can_publish) {
49     $post_status = -2;
50}
51
52# Getting categories
53$categories_combo = dcAdminCombos::getCategoriesCombo(
54     $core->blog->getCategories(array('post_type'=>'post'))
55);
56
57$status_combo = dcAdminCombos::getPostStatusesCombo();
58
59$img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />';
60
61# Formaters combo
62$formaters_combo = dcAdminCombos::getFormatersCombo();
63
64# Languages combo
65$rs = $core->blog->getLangs(array('order'=>'asc'));
66$lang_combo = dcAdminCombos::getLangsCombo($rs,true);
67
68# Validation flag
69$bad_dt = false;
70
71# Trackbacks
72$TB = new dcTrackback($core);
73$tb_urls = $tb_excerpt = '';
74
75# Get entry informations
76if (!empty($_REQUEST['id']))
77{
78     $page_title = __('Edit entry');
79     
80     $params['post_id'] = $_REQUEST['id'];
81     
82     $post = $core->blog->getPosts($params);
83     
84     if ($post->isEmpty())
85     {
86          $core->error->add(__('This entry does not exist.'));
87          $can_view_page = false;
88     }
89     else
90     {
91          $post_id = $post->post_id;
92          $cat_id = $post->cat_id;
93          $post_dt = date('Y-m-d H:i',strtotime($post->post_dt));
94          $post_format = $post->post_format;
95          $post_password = $post->post_password;
96          $post_url = $post->post_url;
97          $post_lang = $post->post_lang;
98          $post_title = $post->post_title;
99          $post_excerpt = $post->post_excerpt;
100          $post_excerpt_xhtml = $post->post_excerpt_xhtml;
101          $post_content = $post->post_content;
102          $post_content_xhtml = $post->post_content_xhtml;
103          $post_notes = $post->post_notes;
104          $post_status = $post->post_status;
105          $post_selected = (boolean) $post->post_selected;
106          $post_open_comment = (boolean) $post->post_open_comment;
107          $post_open_tb = (boolean) $post->post_open_tb;
108         
109          $can_edit_post = $post->isEditable();
110          $can_delete= $post->isDeletable();
111         
112          $next_rs = $core->blog->getNextPost($post,1);
113          $prev_rs = $core->blog->getNextPost($post,-1);
114         
115          if ($next_rs !== null) {
116               $next_link = sprintf($post_link,$next_rs->post_id,
117                    html::escapeHTML($next_rs->post_title),__('Next entry').'&nbsp;&#187;');
118               $next_headlink = sprintf($post_headlink,'next',
119                    html::escapeHTML($next_rs->post_title),$next_rs->post_id);
120          }
121         
122          if ($prev_rs !== null) {
123               $prev_link = sprintf($post_link,$prev_rs->post_id,
124                    html::escapeHTML($prev_rs->post_title),'&#171;&nbsp;'.__('Previous entry'));
125               $prev_headlink = sprintf($post_headlink,'previous',
126                    html::escapeHTML($prev_rs->post_title),$prev_rs->post_id);
127          }
128         
129          try {
130               $core->media = new dcMedia($core);
131          } catch (Exception $e) {
132               $core->error->add($e->getMessage());
133          }
134
135          # Sanitize trackbacks excerpt
136          $tb_excerpt = empty($_POST['tb_excerpt']) ? 
137               $post_excerpt_xhtml.' '.$post_content_xhtml :
138               $_POST['tb_excerpt'];
139          $tb_excerpt = html::decodeEntities(html::clean($tb_excerpt));
140          $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt), 255);
141          $tb_excerpt = preg_replace('/\s+/ms', ' ', $tb_excerpt);
142     }
143}
144
145# Ping blogs
146if (!empty($_POST['ping']))
147{
148     if (!empty($_POST['tb_urls']) && $post_id && $post_status == 1 && $can_edit_post)
149     {
150          $tb_urls = $_POST['tb_urls'];
151          $tb_urls = str_replace("\r", '', $tb_urls);
152          $tb_post_title = html::escapeHTML(trim(html::clean($post_title)));
153         
154          foreach (explode("\n", $tb_urls) as $tb_url)
155          {
156               try {
157                    $TB->ping($tb_url, $post_id, $tb_post_title, $tb_excerpt, $post_url);
158               } catch (Exception $e) {
159                    $core->error->add($e->getMessage());
160               }
161          }
162         
163          if (!$core->error->flag()) {
164               http::redirect('post.php?id='.$post_id.'&tbsent=1&tb=1');
165          }
166     }
167}
168
169# Format excerpt and content
170elseif (!empty($_POST) && $can_edit_post)
171{
172     $post_format = $_POST['post_format'];
173     $post_excerpt = $_POST['post_excerpt'];
174     $post_content = $_POST['post_content'];
175     
176     $post_title = $_POST['post_title'];
177     
178     $cat_id = (integer) $_POST['cat_id'];
179     
180     if (isset($_POST['post_status'])) {
181          $post_status = (integer) $_POST['post_status'];
182     }
183     
184     if (empty($_POST['post_dt'])) {
185          $post_dt = '';
186     } else {
187          try
188          {
189               $post_dt = strtotime($_POST['post_dt']);
190               if ($post_dt == false || $post_dt == -1) {
191                    $bad_dt = true;
192                    throw new Exception(__('Invalid publication date'));
193               }
194               $post_dt = date('Y-m-d H:i',$post_dt);
195          }
196          catch (Exception $e)
197          {
198               $core->error->add($e->getMessage());
199          }
200     }
201     
202     $post_open_comment = !empty($_POST['post_open_comment']);
203     $post_open_tb = !empty($_POST['post_open_tb']);
204     $post_selected = !empty($_POST['post_selected']);
205     $post_lang = $_POST['post_lang'];
206     $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null;
207     
208     $post_notes = $_POST['post_notes'];
209     
210     if (isset($_POST['post_url'])) {
211          $post_url = $_POST['post_url'];
212     }
213     
214     $core->blog->setPostContent(
215          $post_id,$post_format,$post_lang,
216          $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml
217     );
218}
219
220# Delete post
221if (!empty($_POST['delete']) && $can_delete)
222{
223     try {
224          # --BEHAVIOR-- adminBeforePostDelete
225          $core->callBehavior('adminBeforePostDelete',$post_id);
226          $core->blog->delPost($post_id);
227          http::redirect('posts.php');
228     } catch (Exception $e) {
229          $core->error->add($e->getMessage());
230     }
231}
232
233# Create or update post
234if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt)
235{
236     # Create category
237     if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) {
238     
239          $cur_cat = $core->con->openCursor($core->prefix.'category');
240          $cur_cat->cat_title = $_POST['new_cat_title'];
241          $cur_cat->cat_url = '';
242         
243          $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : '';
244         
245          # --BEHAVIOR-- adminBeforeCategoryCreate
246          $core->callBehavior('adminBeforeCategoryCreate', $cur_cat);
247         
248          $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat);
249         
250          # --BEHAVIOR-- adminAfterCategoryCreate
251          $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id);
252     }
253     
254     $cur = $core->con->openCursor($core->prefix.'post');
255     
256     $cur->post_title = $post_title;
257     $cur->cat_id = ($cat_id ? $cat_id : null);
258     $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : '';
259     $cur->post_format = $post_format;
260     $cur->post_password = $post_password;
261     $cur->post_lang = $post_lang;
262     $cur->post_title = $post_title;
263     $cur->post_excerpt = $post_excerpt;
264     $cur->post_excerpt_xhtml = $post_excerpt_xhtml;
265     $cur->post_content = $post_content;
266     $cur->post_content_xhtml = $post_content_xhtml;
267     $cur->post_notes = $post_notes;
268     $cur->post_status = $post_status;
269     $cur->post_selected = (integer) $post_selected;
270     $cur->post_open_comment = (integer) $post_open_comment;
271     $cur->post_open_tb = (integer) $post_open_tb;
272     
273     if (isset($_POST['post_url'])) {
274          $cur->post_url = $post_url;
275     }
276     
277     # Update post
278     if ($post_id)
279     {
280          try
281          {
282               # --BEHAVIOR-- adminBeforePostUpdate
283               $core->callBehavior('adminBeforePostUpdate',$cur,$post_id);
284               
285               $core->blog->updPost($post_id,$cur);
286               
287               # --BEHAVIOR-- adminAfterPostUpdate
288               $core->callBehavior('adminAfterPostUpdate',$cur,$post_id);
289               
290               http::redirect('post.php?id='.$post_id.'&upd=1');
291          }
292          catch (Exception $e)
293          {
294               $core->error->add($e->getMessage());
295          }
296     }
297     else
298     {
299          $cur->user_id = $core->auth->userID();
300         
301          try
302          {
303               # --BEHAVIOR-- adminBeforePostCreate
304               $core->callBehavior('adminBeforePostCreate',$cur);
305               
306               $return_id = $core->blog->addPost($cur);
307               
308               # --BEHAVIOR-- adminAfterPostCreate
309               $core->callBehavior('adminAfterPostCreate',$cur,$return_id);
310               
311               http::redirect('post.php?id='.$return_id.'&crea=1');
312          }
313          catch (Exception $e)
314          {
315               $core->error->add($e->getMessage());
316          }
317     }
318}
319
320# Getting categories
321$categories_combo = dcAdminCombos::getCategoriesCombo(
322     $core->blog->getCategories(array('post_type'=>'post'))
323);
324/* DISPLAY
325-------------------------------------------------------- */
326$default_tab = 'edit-entry';
327if (!$can_edit_post) {
328     $default_tab = '';
329}
330if (!empty($_GET['co'])) {
331     $default_tab = 'comments';
332}
333elseif (!empty($_GET['tb'])) {
334     $default_tab = 'trackbacks';
335}
336
337if ($post_id) {
338     switch ($post_status) {
339          case 1:
340               $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png');
341               break;
342          case 0:
343               $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png');
344               break;
345          case -1:
346               $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png');
347               break;
348          case -2:
349               $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png');
350               break;
351          default:
352               $img_status = '';
353     }
354     $edit_entry_str = __('&ldquo;%s&rdquo;');
355     $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status;
356} else {
357     $img_status = '';
358}
359
360
361dcPage::open($page_title.' - '.__('Entries'),
362     dcPage::jsDatePicker().
363     dcPage::jsToolBar().
364     dcPage::jsModal().
365     dcPage::jsMetaEditor().
366     dcPage::jsLoad('js/_post.js').
367     dcPage::jsConfirmClose('entry-form','comment-form').
368     # --BEHAVIOR-- adminPostHeaders
369     $core->callBehavior('adminPostHeaders').
370     dcPage::jsPageTabs($default_tab).
371     $next_headlink."\n".$prev_headlink,
372     dcPage::breadcrumb(
373          array(
374               html::escapeHTML($core->blog->name) => '',
375               __('Entries') => 'posts.php',
376               '<span class="page-title">'.($post_id ? $page_title_edit : $page_title).'</span>' => ''
377          ))
378);
379
380if (!empty($_GET['upd'])) {
381     dcPage::success(__('Entry has been successfully updated.'));
382}
383elseif (!empty($_GET['crea'])) {
384     dcPage::success(__('Entry has been successfully created.'));
385}
386elseif (!empty($_GET['attached'])) {
387     dcPage::success(__('File has been successfully attached.'));
388}
389elseif (!empty($_GET['rmattach'])) {
390     dcPage::success(__('Attachment has been successfully removed.'));
391}
392
393if (!empty($_GET['creaco'])) {
394     dcPage::success(__('Comment has been successfully created.'));
395}
396if (!empty($_GET['tbsent'])) {
397     dcPage::success(__('All pings sent.'));
398}
399
400# XHTML conversion
401if (!empty($_GET['xconv']))
402{
403     $post_excerpt = $post_excerpt_xhtml;
404     $post_content = $post_content_xhtml;
405     $post_format = 'xhtml';
406     
407     dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.'));
408}
409
410if ($post_id && $post->post_status == 1) {
411     echo '<p><a class="onblog_link" href="'.$post->getURL().'" onclick="window.open(this.href);return false;" title="'.$post_title.' ('.__('new window').')'.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>';
412}
413if ($post_id)
414{
415     echo '<p class="nav_prevnext">';
416     if ($prev_link) { echo $prev_link; }
417     if ($next_link && $prev_link) { echo ' | '; }
418     if ($next_link) { echo $next_link; }
419     
420     # --BEHAVIOR-- adminPostNavLinks
421     $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null);
422     
423     echo '</p>';
424}
425
426# Exit if we cannot view page
427if (!$can_view_page) {
428     dcPage::helpBlock('core_post');
429     dcPage::close();
430     exit;
431}
432/* Post form if we can edit post
433-------------------------------------------------------- */
434if ($can_edit_post)
435{
436     $sidebar_items = new ArrayObject(array(
437          'status-box' => array(
438               'title' => __('Status'),
439               'items' => array(
440                    'post_status' => 
441                         '<p class="entry-status"><label for="post_status" class="ib">'.__('Entry status').' '.$img_status.'</label>'.
442                         form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish).
443                         '</p>',
444                    'post_dt' => 
445                         '<p><label for="post_dt" class="ib">'.__('Publication date and hour').'</label>'.
446                         form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).
447                         '</p>',
448                    'post_lang' =>
449                         '<p><label for="post_lang" class="ib">'.__('Entry language').'</label>'.
450                         form::combo('post_lang',$lang_combo,$post_lang).
451                         '</p>',
452                    'post_format' =>
453                         '<div>'.
454                         '<h5 id="label_format"><label for="post_format" class="ib">'.__('Text formatting').'</label></h5>'.
455                         '<p>'.form::combo('post_format',$formaters_combo,$post_format,'maximal').
456                         '</p>'.
457                         '<p class="format_control control_no_xhtml">'.
458                         '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').'" href="post.php?id='.$post_id.'&amp;xconv=1">'.
459                         __('Convert to XHTML').'</a></p></div>')),
460          'metas-box' => array(
461               'title' => __('Filing'),
462               'items' => array(
463                    'post_selected' => 
464                         '<p><label for="post_selected" class="classic">'.
465                         form::checkbox('post_selected',1,$post_selected).' '.
466                         __('Selected entry').'</label></p>',
467                    'cat_id' =>
468                         '<div>'.
469                         '<h5 id="label_cat_id">'.__('Category').'</h5>'.
470                         '<p><label for="cat_id">'.__('Category:').'</label>'.
471                         form::combo('cat_id',$categories_combo,$cat_id,'maximal').
472                         '</p>'.
473                         ($core->auth->check('categories', $core->blog->id) ?
474                              '<div>'.
475                              '<h5 id="create_cat">'.__('Add a new category').'</h5>'.
476                              '<p><label for="new_cat_title">'.__('Title:').' '.
477                              form::field('new_cat_title',30,255,'','maximal').'</label></p>'.
478                              '<p><label for="new_cat_parent">'.__('Parent:').' '.
479                              form::combo('new_cat_parent',$categories_combo,'','maximal').
480                              '</label></p>'.
481                              '</div>'
482                         : '').
483                         '</div>')),
484          'options-box' => array(
485               'title' => __('Options'),
486               'items' => array(
487                    'post_open_comment_tb' =>
488                         '<div>'.
489                         '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'.
490                         '<p><label for="post_open_comment" class="classic">'.
491                         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">'.
497                                   __('Warning: Comments are not more accepted for this entry.').'</p>') : 
498                              '<p class="form-note warn">'.
499                              __('Comments are not accepted on this blog so far.').'</p>').
500                         '<p><label for="post_open_tb" class="classic">'.
501                         form::checkbox('post_open_tb',1,$post_open_tb).' '.
502                         __('Accept trackbacks').'</label></p>'.
503                         ($core->blog->settings->system->allow_trackbacks ? 
504                              (isContributionAllowed($post_id,strtotime($post_dt),false) ? 
505                                   '' :
506                                   '<p class="form-note warn">'.
507                                   __('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 
508                              '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>').
509                         '</div>',
510                    'post_password' =>
511                         '<p><label for="post_password" class="ib">'.__('Password').'</label>'.
512                         form::field('post_password',10,32,html::escapeHTML($post_password),'maximal').
513                         '</p>',
514                    'post_url' =>
515                         '<div class="lockable">'.
516                         '<p><label for="post_url" class="ib">'.__('Edit basename').'</label>'.
517                         form::field('post_url',10,255,html::escapeHTML($post_url),'maximal').
518                         '</p>'.
519                         '<p class="form-note warn">'.
520                         __('Warning: If you set the URL manually, it may conflict with another entry.').
521                         '</p></div>'
522     ))));
523
524     $main_items = new ArrayObject(array(
525          "post_title" =>
526               '<p class="col">'.
527               '<label class="required no-margin"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'.
528               form::field('post_title',20,255,html::escapeHTML($post_title),'maximal').
529               '</p>',
530         
531          "post_excerpt" =>
532               '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').' <span class="form-note">'.
533               __('Introduction to the post.').'</span></label> '.
534               form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)).
535               '</p>',
536         
537          "post_content" =>
538               '<p class="area" id="content-area"><label class="required" '.
539               'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '.
540               form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)).
541               '</p>',
542         
543          "post_notes" =>
544               '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').' <span class="form-note">'.
545               __('Unpublished notes.').'</span></label>'.
546               form::textarea('post_notes',50,5,html::escapeHTML($post_notes)).
547               '</p>'
548          )
549     );
550     
551     # --BEHAVIOR-- adminPostFormItems
552     $core->callBehavior('adminPostFormItems',$main_items,$sidebar_items, isset($post) ? $post : null);
553
554     echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">';
555     echo '<form action="post.php" method="post" id="entry-form">';
556     echo '<div id="entry-wrapper">';
557     echo '<div id="entry-content"><div class="constrained">';
558
559     echo '<h3 class="out-of-screen-if-js">'.__('Edit post').'</h3>';
560     
561     foreach ($main_items as $id => $item) {
562          echo $item;
563     }
564
565     # --BEHAVIOR-- adminPostForm (may be deprecated)
566     $core->callBehavior('adminPostForm',isset($post) ? $post : null);
567     
568     echo
569     '<p class="border-top">'.
570     ($post_id ? form::hidden('id',$post_id) : '').
571     '<input type="submit" value="'.__('Save').' (s)" '.
572     'accesskey="s" name="save" /> ';
573     if ($post_id) {
574          $preview_url =
575          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'.
576          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')).
577          '/'.$post->post_url);
578          echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> ';
579     } else {
580          echo
581          '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>';
582     }
583
584     echo
585     ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : '').
586     $core->formNonce().
587     '</p>';
588     
589     echo '</div></div>';          // End #entry-content
590     echo '</div>';      // End #entry-wrapper
591
592     echo '<div id="entry-sidebar">';
593     
594     foreach ($sidebar_items as $id => $c) {
595          echo '<div id="'.$id.'" class="sb-box">'.
596               '<h4>'.$c['title'].'</h4>';
597          foreach ($c['items'] as $e_name=>$e_content) {
598               echo $e_content;
599          }
600          echo '</div>';
601     }
602     
603     
604     # --BEHAVIOR-- adminPostFormSidebar (may be deprecated)
605     $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null);
606     echo '</div>';      // End #entry-sidebar
607
608     echo '</form>';
609     
610     # --BEHAVIOR-- adminPostForm
611     $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null);
612     
613     echo '</div>';
614}
615
616if ($post_id)
617{
618     /* Comments
619     -------------------------------------------------------- */
620
621     $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');
622     
623     $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0)));
624     
625     # Actions combo box
626     $combo_action = array();
627     if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id))
628     {
629          $combo_action[__('Publish')] = 'publish';
630          $combo_action[__('Unpublish')] = 'unpublish';
631          $combo_action[__('Mark as pending')] = 'pending';
632          $combo_action[__('Mark as junk')] = 'junk';
633     }
634     
635     if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id))
636     {
637          $combo_action[__('Delete')] = 'delete';
638     }
639     
640     echo
641     '<div id="comments" class="clear multi-part" title="'.__('Comments').'">';
642         
643     # --BEHAVIOR-- adminCommentsActionsCombo
644     $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
645     
646     $has_action = !empty($combo_action) && !$comments->isEmpty();
647     echo 
648     '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>';
649     
650     if ($has_action) {
651          echo '<form action="comments_actions.php" id="form-comments" method="post">';
652     }
653     
654     echo '<h3>'.__('Comments').'</h3>';
655     if (!$comments->isEmpty()) {
656          showComments($comments,$has_action);
657     } else {
658          echo '<p>'.__('No comment').'</p>';
659     }
660     
661     if ($has_action) {
662          echo
663          '<div class="two-cols">'.
664          '<p class="col checkboxes-helpers"></p>'.
665         
666          '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.
667          form::combo('action',$combo_action).
668          form::hidden('redir','post.php?id='.$post_id.'&amp;co=1').
669          $core->formNonce().
670          '<input type="submit" value="'.__('ok').'" /></p>'.
671          '</div>'.
672          '</form>';
673     }
674     /* Add a comment
675     -------------------------------------------------------- */
676
677     echo
678     '<div class="fieldset clear">'.
679     '<h3>'.__('Add a comment').'</h3>'.
680     
681     '<form action="comment.php" method="post" id="comment-form">'.
682     '<div class="constrained">'.
683     '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'.
684     form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))).
685     '</p>'.
686     
687     '<p><label for="comment_email">'.__('Email:').'</label>'.
688     form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))).
689     '</p>'.
690     
691     '<p><label for="comment_site">'.__('Web site:').'</label>'.
692     form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))).
693     '</p>'.
694     
695     '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.
696     __('Comment:').'</label> '.
697     form::textarea('comment_content',50,8,html::escapeHTML('')).
698     '</p>'.
699     
700     '<p>'.form::hidden('post_id',$post_id).
701     $core->formNonce().
702     '<input type="submit" name="add" value="'.__('Save').'" /></p>'.
703     '</div>'. #constrained
704
705     '</form>'.
706     '</div>'. #add comment
707     '</div>'; #comments
708}
709
710if ($post_id && $post_status == 1)
711{
712     /* Trackbacks
713     -------------------------------------------------------- */
714
715     $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');
716     $trackbacks = $core->blog->getComments(array_merge($params, array('comment_trackback' => 1)));
717     
718     # Actions combo box
719     $combo_action = array();
720     if ($can_edit_post && $core->auth->check('publish,contentadmin', $core->blog->id))
721     {
722          $combo_action[__('Publish')] = 'publish';
723          $combo_action[__('Unpublish')] = 'unpublish';
724          $combo_action[__('Mark as pending')] = 'pending';
725          $combo_action[__('Mark as junk')] = 'junk';
726     }
727     
728     if ($can_edit_post && $core->auth->check('delete,contentadmin', $core->blog->id))
729     {
730          $combo_action[__('Delete')] = 'delete';
731     }
732     
733     # --BEHAVIOR-- adminTrackbacksActionsCombo
734     $core->callBehavior('adminTrackbacksActionsCombo', array(&$combo_action));
735     
736     $has_action = !empty($combo_action) && !$trackbacks->isEmpty();
737     
738     if (!empty($_GET['tb_auto'])) {
739          $tb_urls = implode("\n", $TB->discover($post_excerpt_xhtml.' '.$post_content_xhtml));
740     }
741     
742     # Display tab
743     echo
744     '<div id="trackbacks" class="clear multi-part" title="'.__('Trackbacks').'">';
745     
746     # tracbacks actions
747     if ($has_action) {
748          echo '<form action="comments_actions.php" id="form-trackbacks" method="post">';
749     }
750     
751     echo '<h3>'.__('Trackbacks').'</h3>';
752     
753     if (!$trackbacks->isEmpty()) {
754          showComments($trackbacks, $has_action, true);
755     } else {
756          echo '<p>'.__('No trackback').'</p>';
757     }
758     
759     if ($has_action) {
760          echo
761          '<div class="two-cols">'.
762          '<p class="col checkboxes-helpers"></p>'.
763         
764          '<p class="col right"><label for="action" class="classic">'.__('Selected trackbacks action:').'</label> '.
765          form::combo('action', $combo_action).
766          form::hidden('redir', 'post.php?id='.$post_id.'&amp;tb=1').
767          $core->formNonce().
768          '<input type="submit" value="'.__('ok').'" /></p>'.
769          '</div>'.
770          '</form>';
771     }
772     
773     /* Add trackbacks
774     -------------------------------------------------------- */
775     if ($can_edit_post && $post->post_status) {
776          echo
777          '<div class="fieldset clear">';
778
779          echo
780          '<h3>'.__('Ping blogs').'</h3>'.
781          '<form action="post.php?id='.$post_id.'" id="trackback-form" method="post">'.
782          '<p><label for="tb_urls" class="area">'.__('URLs to ping:').'</label>'.
783          form::textarea('tb_urls', 60, 5, $tb_urls).
784          '</p>'.
785
786          '<p><label for="tb_excerpt" class="area">'.__('Send excerpt:').'</label>'.
787          form::textarea('tb_excerpt', 60, 5, $tb_excerpt).'</p>'.
788
789          '<p>'.
790          $core->formNonce().
791          '<input type="submit" name="ping" value="'.__('Ping blogs').'" />'.
792          (empty($_GET['tb_auto']) ? 
793               '&nbsp;&nbsp;<a class="button" href="'.
794               'post.php?id='.$post_id.'&amp;tb_auto=1&amp;tb=1'.
795               '">'.__('Auto discover ping URLs').'</a>'
796          : '').
797          '</p>'.
798          '</form>';
799
800          $pings = $TB->getPostPings($post_id);
801
802          if (!$pings->isEmpty())
803          {
804               echo '<h3>'.__('Previously sent pings').'</h3>';
805               
806               echo '<ul class="nice">';
807               while ($pings->fetch()) {
808                    echo
809                    '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'), $pings->ping_dt).' - '.
810                    $pings->ping_url.'</li>';
811               }
812               echo '</ul>';
813          }
814
815          echo '</div>';
816     }
817
818     echo '</div>'; #trackbacks
819}
820
821# Controls comments or trakbacks capabilities
822function isContributionAllowed($id,$dt,$com=true)
823{
824     global $core;
825
826     if (!$id) {
827          return true;
828     }
829     if ($com) {
830          if (($core->blog->settings->system->comments_ttl == 0) || 
831               (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) {
832               return true;
833          }
834     } else {
835          if (($core->blog->settings->system->trackbacks_ttl == 0) || 
836               (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) {
837               return true;
838          }
839     }
840     return false;
841}
842
843# Show comments or trackbacks
844function showComments($rs,$has_action,$tb=false)
845{
846     echo
847     '<table class="comments-list"><tr>'.
848     '<th colspan="2" class="first">'.__('Author').'</th>'.
849     '<th>'.__('Date').'</th>'.
850     '<th class="nowrap">'.__('IP address').'</th>'.
851     '<th>'.__('Status').'</th>'.
852     '<th>'.__('Edit').'</th>'.
853     '</tr>';
854     
855     while($rs->fetch())
856     {
857          $comment_url = 'comment.php?id='.$rs->comment_id;
858         
859          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
860          switch ($rs->comment_status) {
861               case 1:
862                    $img_status = sprintf($img,__('Published'),'check-on.png');
863                    break;
864               case 0:
865                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
866                    break;
867               case -1:
868                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
869                    break;
870               case -2:
871                    $img_status = sprintf($img,__('Junk'),'junk.png');
872                    break;
873          }
874         
875          echo
876          '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'.
877          ' id="c'.$rs->comment_id.'">'.
878         
879          '<td class="nowrap">'.
880          ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'.
881          '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'.
882          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'.
883          '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'.
884          '<td class="nowrap status">'.$img_status.'</td>'.
885          '<td class="nowrap status"><a href="'.$comment_url.'">'.
886          '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'.
887         
888          '</tr>';
889     }
890     
891     echo '</table>';
892}
893
894dcPage::helpBlock('core_post','core_trackbacks','core_wiki');
895dcPage::close();
896?>
Note: See TracBrowser for help on using the repository browser.

Sites map