Dotclear

source: admin/post.php @ 1941:84f59a80ffe8

Revision 1941:84f59a80ffe8, 27.0 KB checked in by Dsls, 12 years ago (diff)

po_update.sh no more complains, removed duplicate l10n entries, replaced french words in code.

RevLine 
[0]1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
[1179]6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
[0]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
[195]35$page_title = __('New entry');
[0]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
[1288]52# Getting categories
[1719]53$categories_combo = dcAdminCombos::getCategoriesCombo(
54     $core->blog->getCategories(array('post_type'=>'post'))
55);
[1288]56
[1719]57$status_combo = dcAdminCombos::getPostStatusesCombo();
58
[933]59$img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />';
[0]60
61# Formaters combo
[1719]62$formaters_combo = dcAdminCombos::getFormatersCombo();
[0]63
64# Languages combo
65$rs = $core->blog->getLangs(array('order'=>'asc'));
[1719]66$lang_combo = dcAdminCombos::getLangsCombo($rs,true);
[0]67
[957]68# Validation flag
69$bad_dt = false;
[0]70
[1783]71# Trackbacks
72$TB = new dcTrackback($core);
73$tb_urls = $tb_excerpt = '';
74
[0]75# Get entry informations
76if (!empty($_REQUEST['id']))
77{
[1460]78     $page_title = __('Edit entry');
79     
[0]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,
[1353]117                    html::escapeHTML($next_rs->post_title),__('Next entry').'&nbsp;&#187;');
[0]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,
[1353]124                    html::escapeHTML($prev_rs->post_title),'&#171;&nbsp;'.__('Previous entry'));
[0]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);
[1537]131          } catch (Exception $e) {
132               $core->error->add($e->getMessage());
133          }
[1783]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          }
[0]166     }
167}
168
169# Format excerpt and content
[1783]170elseif (!empty($_POST) && $can_edit_post)
[0]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 {
[957]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          }
[0]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
[1068]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
[0]233# Create or update post
[957]234if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt)
[0]235{
[1417]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     
[0]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
[1417]320# Getting categories
[1719]321$categories_combo = dcAdminCombos::getCategoriesCombo(
[1831]322     $core->blog->getCategories(array('post_type'=>'post'))
[1719]323);
[0]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}
[1783]333elseif (!empty($_GET['tb'])) {
334     $default_tab = 'trackbacks';
335}
[0]336
[1358]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;
[1427]356} else {
357     $img_status = '';
[1358]358}
359
360
[195]361dcPage::open($page_title.' - '.__('Entries'),
[0]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).
[1358]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          ))
[0]378);
379
380if (!empty($_GET['upd'])) {
[1550]381     dcPage::success(__('Entry has been successfully updated.'));
[0]382}
383elseif (!empty($_GET['crea'])) {
[1550]384     dcPage::success(__('Entry has been successfully created.'));
[0]385}
386elseif (!empty($_GET['attached'])) {
[1550]387     dcPage::success(__('File has been successfully attached.'));
[0]388}
389elseif (!empty($_GET['rmattach'])) {
[1550]390     dcPage::success(__('Attachment has been successfully removed.'));
[0]391}
392
393if (!empty($_GET['creaco'])) {
[1550]394     dcPage::success(__('Comment has been successfully created.'));
[907]395}
[1783]396if (!empty($_GET['tbsent'])) {
397     dcPage::success(__('All pings sent.'));
398}
[0]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     
[907]407     dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.'));
[0]408}
409
410if ($post_id && $post->post_status == 1) {
[1353]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>';
[0]412}
413if ($post_id)
414{
[1333]415     echo '<p class="nav_prevnext">';
[0]416     if ($prev_link) { echo $prev_link; }
[1335]417     if ($next_link && $prev_link) { echo ' | '; }
[0]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{
[1398]436     $sidebar_items = new ArrayObject(array(
[1392]437          'status-box' => array(
438               'title' => __('Status'),
439               'items' => array(
440                    'post_status' => 
[1427]441                         '<p class="entry-status"><label for="post_status" class="ib">'.__('Entry status').' '.$img_status.'</label>'.
[1392]442                         form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish).
[1396]443                         '</p>',
[1392]444                    'post_dt' => 
[1396]445                         '<p><label for="post_dt" class="ib">'.__('Publication date and hour').'</label>'.
[1392]446                         form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).
[1396]447                         '</p>',
[1392]448                    'post_lang' =>
[1396]449                         '<p><label for="post_lang" class="ib">'.__('Entry lang').'</label>'.
[1392]450                         form::combo('post_lang',$lang_combo,$post_lang).
[1396]451                         '</p>',
[1392]452                    'post_format' =>
[1619]453                         '<div>'.
454                         '<h5 id="label_format"><label for="post_format" class="ib">'.__('Text formating').'</label></h5>'.
455                         '<p>'.form::combo('post_format',$formaters_combo,$post_format,'maximal').
[1396]456                         '</p>'.
[1830]457                         '<p class="format_control control_no_xhtml">'.
[1824]458                         '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').'" href="post.php?id='.$post_id.'&amp;xconv=1">'.
[1812]459                         __('Convert to XHTML').'</a></p></div>')),
[1392]460          'metas-box' => array(
461               'title' => __('Ordering'),
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' =>
[1935]468                         '<div>'.
469                         '<h5 id="label_cat_id">'.__('Category').'</h5>'.
470                         '<p><label for="cat_id">'.__('Category:').'</label>'.
[1392]471                         form::combo('cat_id',$categories_combo,$cat_id,'maximal').
[1468]472                         '</p>'.
473                         ($core->auth->check('categories', $core->blog->id) ?
[1936]474                              '<div>'.
[1530]475                              '<h5 id="create_cat">'.__('Add a new category').'</h5>'.
[1468]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').
[1936]480                              '</label></p>'.
481                              '</div>'
[1935]482                         : '').
483                         '</div>')),
[1392]484          'options-box' => array(
485               'title' => __('Options'),
486               'items' => array(
[1711]487                    'post_open_comment_tb' =>
488                         '<div>'.
[1941]489                         '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'.
[1392]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">'.
[1711]499                              __('Comments are not accepted on this blog so far.').'</p>').
[1392]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>') : 
[1711]508                              '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>').
509                         '</div>',
[1392]510                    'post_password' =>
[1396]511                         '<p><label for="post_password" class="ib">'.__('Password').'</label>'.
[1392]512                         form::field('post_password',10,32,html::escapeHTML($post_password),'maximal').
[1396]513                         '</p>',
[1392]514                    'post_url' =>
515                         '<div class="lockable">'.
[1396]516                         '<p><label for="post_url" class="ib">'.__('Edit basename').'</label>'.
[1392]517                         form::field('post_url',10,255,html::escapeHTML($post_url),'maximal').
[1396]518                         '</p>'.
[1392]519                         '<p class="form-note warn">'.
520                         __('Warning: If you set the URL manually, it may conflict with another entry.').
521                         '</p></div>'
522     ))));
[1398]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" =>
[1741]532               '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').' <span class="form-note">'.
[1697]533               __('Introduction to the post.').'</span></label> '.
[1398]534               form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)).
535               '</p>',
536         
537          "post_content" =>
[1813]538               '<p class="area" id="content-area"><label class="required" '.
[1398]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" =>
[1741]544               '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').' <span class="form-note">'.
[1697]545               __('Unpublished notes.').'</span></label>'.
[1398]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">';
[0]555     echo '<form action="post.php" method="post" id="entry-form">';
[458]556     echo '<div id="entry-wrapper">';
[536]557     echo '<div id="entry-content"><div class="constrained">';
[1398]558
[1789]559     echo '<h3 class="out-of-screen-if-js">'.__('Edit post').'</h3>';
[458]560     
[1398]561     foreach ($main_items as $id => $item) {
562          echo $item;
563     }
564
565     # --BEHAVIOR-- adminPostForm (may be deprecated)
[458]566     $core->callBehavior('adminPostForm',isset($post) ? $post : null);
567     
568     echo
[1398]569     '<p class="border-top">'.
[458]570     ($post_id ? form::hidden('id',$post_id) : '').
571     '<input type="submit" value="'.__('Save').' (s)" '.
[543]572     'accesskey="s" name="save" /> ';
[544]573     if ($post_id) {
[543]574          $preview_url =
[776]575          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'.
[543]576          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')).
[772]577          '/'.$post->post_url);
[1139]578          echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> ';
[1215]579     } else {
580          echo
581          '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>';
[543]582     }
[1215]583
[543]584     echo
[458]585     ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : '').
586     $core->formNonce().
587     '</p>';
588     
[536]589     echo '</div></div>';          // End #entry-content
[458]590     echo '</div>';      // End #entry-wrapper
591
[0]592     echo '<div id="entry-sidebar">';
593     
[1398]594     foreach ($sidebar_items as $id => $c) {
[1741]595          echo '<div id="'.$id.'" class="sb-box">'.
[1392]596               '<h4>'.$c['title'].'</h4>';
597          foreach ($c['items'] as $e_name=>$e_content) {
598               echo $e_content;
599          }
600          echo '</div>';
601     }
[0]602     
[1417]603     
[1398]604     # --BEHAVIOR-- adminPostFormSidebar (may be deprecated)
[0]605     $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null);
606     echo '</div>';      // End #entry-sidebar
[458]607
[0]608     echo '</form>';
[416]609     
610     # --BEHAVIOR-- adminPostForm
611     $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null);
612     
[0]613     echo '</div>';
614}
615
616if ($post_id)
617{
[1783]618     /* Comments
619     -------------------------------------------------------- */
620
[0]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     {
[1353]629          $combo_action[__('Publish')] = 'publish';
630          $combo_action[__('Unpublish')] = 'unpublish';
631          $combo_action[__('Mark as pending')] = 'pending';
632          $combo_action[__('Mark as junk')] = 'junk';
[0]633     }
634     
635     if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id))
636     {
[747]637          $combo_action[__('Delete')] = 'delete';
[0]638     }
639     
[1613]640     echo
[1741]641     '<div id="comments" class="clear multi-part" title="'.__('Comments').'">';
[1613]642         
[322]643     # --BEHAVIOR-- adminCommentsActionsCombo
644     $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
645     
[1783]646     $has_action = !empty($combo_action) && !$comments->isEmpty();
[1612]647     echo 
[1741]648     '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>';
[0]649     
650     if ($has_action) {
[1621]651          echo '<form action="comments_actions.php" id="form-comments" method="post">';
[0]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         
[96]666          '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.
[0]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     }
[1612]674     /* Add a comment
675     -------------------------------------------------------- */
[0]676
677     echo
[1613]678     '<div class="fieldset clear">'.
[0]679     '<h3>'.__('Add a comment').'</h3>'.
680     
681     '<form action="comment.php" method="post" id="comment-form">'.
[536]682     '<div class="constrained">'.
[1396]683     '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'.
[0]684     form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))).
[1396]685     '</p>'.
[0]686     
[1396]687     '<p><label for="comment_email">'.__('Email:').'</label>'.
[0]688     form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))).
[1396]689     '</p>'.
[0]690     
[1396]691     '<p><label for="comment_site">'.__('Web site:').'</label>'.
[0]692     form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))).
[1396]693     '</p>'.
[0]694     
[70]695     '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.
696     __('Comment:').'</label> '.
[0]697     form::textarea('comment_content',50,8,html::escapeHTML('')).
698     '</p>'.
699     
700     '<p>'.form::hidden('post_id',$post_id).
701     $core->formNonce().
[217]702     '<input type="submit" name="add" value="'.__('Save').'" /></p>'.
[1613]703     '</div>'. #constrained
704
[0]705     '</form>'.
[1613]706     '</div>'. #add comment
707     '</div>'; #comments
[0]708}
709
[1783]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
[916]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}
[0]842
843# Show comments or trackbacks
[70]844function showComments($rs,$has_action,$tb=false)
[0]845{
846     echo
847     '<table class="comments-list"><tr>'.
[1508]848     '<th colspan="2" class="first">'.__('Author').'</th>'.
[0]849     '<th>'.__('Date').'</th>'.
850     '<th class="nowrap">'.__('IP address').'</th>'.
851     '<th>'.__('Status').'</th>'.
[1508]852     '<th>'.__('Edit').'</th>'.
[0]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:
[1453]862                    $img_status = sprintf($img,__('Published'),'check-on.png');
[0]863                    break;
864               case 0:
[1453]865                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
[0]866                    break;
867               case -1:
[1453]868                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
[0]869                    break;
870               case -2:
[1453]871                    $img_status = sprintf($img,__('Junk'),'junk.png');
[0]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">'.
[70]880          ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'.
[0]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.'">'.
[1508]886          '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'.
[0]887         
888          '</tr>';
889     }
890     
891     echo '</table>';
892}
893
[1459]894dcPage::helpBlock('core_post','core_trackbacks','core_wiki');
[0]895dcPage::close();
[1329]896?>
Note: See TracBrowser for help on using the repository browser.

Sites map