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 | |
---|
13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
14 | |
---|
15 | dcPage::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 |
---|
48 | if (!$can_publish) { |
---|
49 | $post_status = -2; |
---|
50 | } |
---|
51 | |
---|
52 | # Status combo |
---|
53 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
---|
54 | $status_combo[$v] = (string) $k; |
---|
55 | } |
---|
56 | $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
57 | |
---|
58 | # Formaters combo |
---|
59 | foreach ($core->getFormaters() as $v) { |
---|
60 | $formaters_combo[$v] = $v; |
---|
61 | } |
---|
62 | |
---|
63 | # Languages combo |
---|
64 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
65 | $all_langs = l10n::getISOcodes(0,1); |
---|
66 | $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); |
---|
67 | while ($rs->fetch()) { |
---|
68 | if (isset($all_langs[$rs->post_lang])) { |
---|
69 | $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; |
---|
70 | unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); |
---|
71 | } else { |
---|
72 | $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; |
---|
73 | } |
---|
74 | } |
---|
75 | unset($all_langs); |
---|
76 | unset($rs); |
---|
77 | |
---|
78 | # Validation flag |
---|
79 | $bad_dt = false; |
---|
80 | |
---|
81 | # Get entry informations |
---|
82 | if (!empty($_REQUEST['id'])) |
---|
83 | { |
---|
84 | $params['post_id'] = $_REQUEST['id']; |
---|
85 | |
---|
86 | $post = $core->blog->getPosts($params); |
---|
87 | |
---|
88 | if ($post->isEmpty()) |
---|
89 | { |
---|
90 | $core->error->add(__('This entry does not exist.')); |
---|
91 | $can_view_page = false; |
---|
92 | } |
---|
93 | else |
---|
94 | { |
---|
95 | $post_id = $post->post_id; |
---|
96 | $cat_id = $post->cat_id; |
---|
97 | $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); |
---|
98 | $post_format = $post->post_format; |
---|
99 | $post_password = $post->post_password; |
---|
100 | $post_url = $post->post_url; |
---|
101 | $post_lang = $post->post_lang; |
---|
102 | $post_title = $post->post_title; |
---|
103 | $post_excerpt = $post->post_excerpt; |
---|
104 | $post_excerpt_xhtml = $post->post_excerpt_xhtml; |
---|
105 | $post_content = $post->post_content; |
---|
106 | $post_content_xhtml = $post->post_content_xhtml; |
---|
107 | $post_notes = $post->post_notes; |
---|
108 | $post_status = $post->post_status; |
---|
109 | $post_selected = (boolean) $post->post_selected; |
---|
110 | $post_open_comment = (boolean) $post->post_open_comment; |
---|
111 | $post_open_tb = (boolean) $post->post_open_tb; |
---|
112 | |
---|
113 | $page_title = __('Edit entry'); |
---|
114 | |
---|
115 | $can_edit_post = $post->isEditable(); |
---|
116 | $can_delete= $post->isDeletable(); |
---|
117 | |
---|
118 | $next_rs = $core->blog->getNextPost($post,1); |
---|
119 | $prev_rs = $core->blog->getNextPost($post,-1); |
---|
120 | |
---|
121 | if ($next_rs !== null) { |
---|
122 | $next_link = sprintf($post_link,$next_rs->post_id, |
---|
123 | html::escapeHTML($next_rs->post_title),__('next entry').' »'); |
---|
124 | $next_headlink = sprintf($post_headlink,'next', |
---|
125 | html::escapeHTML($next_rs->post_title),$next_rs->post_id); |
---|
126 | } |
---|
127 | |
---|
128 | if ($prev_rs !== null) { |
---|
129 | $prev_link = sprintf($post_link,$prev_rs->post_id, |
---|
130 | html::escapeHTML($prev_rs->post_title),'« '.__('previous entry')); |
---|
131 | $prev_headlink = sprintf($post_headlink,'previous', |
---|
132 | html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); |
---|
133 | } |
---|
134 | |
---|
135 | try { |
---|
136 | $core->media = new dcMedia($core); |
---|
137 | } catch (Exception $e) {} |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | # Format excerpt and content |
---|
142 | if (!empty($_POST) && $can_edit_post) |
---|
143 | { |
---|
144 | $post_format = $_POST['post_format']; |
---|
145 | $post_excerpt = $_POST['post_excerpt']; |
---|
146 | $post_content = $_POST['post_content']; |
---|
147 | |
---|
148 | $post_title = $_POST['post_title']; |
---|
149 | |
---|
150 | $cat_id = (integer) $_POST['cat_id']; |
---|
151 | |
---|
152 | if (isset($_POST['post_status'])) { |
---|
153 | $post_status = (integer) $_POST['post_status']; |
---|
154 | } |
---|
155 | |
---|
156 | if (empty($_POST['post_dt'])) { |
---|
157 | $post_dt = ''; |
---|
158 | } else { |
---|
159 | try |
---|
160 | { |
---|
161 | $post_dt = strtotime($_POST['post_dt']); |
---|
162 | if ($post_dt == false || $post_dt == -1) { |
---|
163 | $bad_dt = true; |
---|
164 | throw new Exception(__('Invalid publication date')); |
---|
165 | } |
---|
166 | $post_dt = date('Y-m-d H:i',$post_dt); |
---|
167 | } |
---|
168 | catch (Exception $e) |
---|
169 | { |
---|
170 | $core->error->add($e->getMessage()); |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | $post_open_comment = !empty($_POST['post_open_comment']); |
---|
175 | $post_open_tb = !empty($_POST['post_open_tb']); |
---|
176 | $post_selected = !empty($_POST['post_selected']); |
---|
177 | $post_lang = $_POST['post_lang']; |
---|
178 | $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; |
---|
179 | |
---|
180 | $post_notes = $_POST['post_notes']; |
---|
181 | |
---|
182 | if (isset($_POST['post_url'])) { |
---|
183 | $post_url = $_POST['post_url']; |
---|
184 | } |
---|
185 | |
---|
186 | $core->blog->setPostContent( |
---|
187 | $post_id,$post_format,$post_lang, |
---|
188 | $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml |
---|
189 | ); |
---|
190 | } |
---|
191 | |
---|
192 | # Delete post |
---|
193 | if (!empty($_POST['delete']) && $can_delete) |
---|
194 | { |
---|
195 | try { |
---|
196 | # --BEHAVIOR-- adminBeforePostDelete |
---|
197 | $core->callBehavior('adminBeforePostDelete',$post_id); |
---|
198 | $core->blog->delPost($post_id); |
---|
199 | http::redirect('posts.php'); |
---|
200 | } catch (Exception $e) { |
---|
201 | $core->error->add($e->getMessage()); |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | # Create or update post |
---|
206 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) |
---|
207 | { |
---|
208 | # Create category |
---|
209 | if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { |
---|
210 | |
---|
211 | $cur_cat = $core->con->openCursor($core->prefix.'category'); |
---|
212 | $cur_cat->cat_title = $_POST['new_cat_title']; |
---|
213 | $cur_cat->cat_url = ''; |
---|
214 | |
---|
215 | $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : ''; |
---|
216 | |
---|
217 | # --BEHAVIOR-- adminBeforeCategoryCreate |
---|
218 | $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); |
---|
219 | |
---|
220 | $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat); |
---|
221 | |
---|
222 | # --BEHAVIOR-- adminAfterCategoryCreate |
---|
223 | $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id); |
---|
224 | } |
---|
225 | |
---|
226 | $cur = $core->con->openCursor($core->prefix.'post'); |
---|
227 | |
---|
228 | $cur->post_title = $post_title; |
---|
229 | $cur->cat_id = ($cat_id ? $cat_id : null); |
---|
230 | $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; |
---|
231 | $cur->post_format = $post_format; |
---|
232 | $cur->post_password = $post_password; |
---|
233 | $cur->post_lang = $post_lang; |
---|
234 | $cur->post_title = $post_title; |
---|
235 | $cur->post_excerpt = $post_excerpt; |
---|
236 | $cur->post_excerpt_xhtml = $post_excerpt_xhtml; |
---|
237 | $cur->post_content = $post_content; |
---|
238 | $cur->post_content_xhtml = $post_content_xhtml; |
---|
239 | $cur->post_notes = $post_notes; |
---|
240 | $cur->post_status = $post_status; |
---|
241 | $cur->post_selected = (integer) $post_selected; |
---|
242 | $cur->post_open_comment = (integer) $post_open_comment; |
---|
243 | $cur->post_open_tb = (integer) $post_open_tb; |
---|
244 | |
---|
245 | if (isset($_POST['post_url'])) { |
---|
246 | $cur->post_url = $post_url; |
---|
247 | } |
---|
248 | |
---|
249 | # Update post |
---|
250 | if ($post_id) |
---|
251 | { |
---|
252 | try |
---|
253 | { |
---|
254 | # --BEHAVIOR-- adminBeforePostUpdate |
---|
255 | $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); |
---|
256 | |
---|
257 | $core->blog->updPost($post_id,$cur); |
---|
258 | |
---|
259 | # --BEHAVIOR-- adminAfterPostUpdate |
---|
260 | $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); |
---|
261 | |
---|
262 | http::redirect('post.php?id='.$post_id.'&upd=1'); |
---|
263 | } |
---|
264 | catch (Exception $e) |
---|
265 | { |
---|
266 | $core->error->add($e->getMessage()); |
---|
267 | } |
---|
268 | } |
---|
269 | else |
---|
270 | { |
---|
271 | $cur->user_id = $core->auth->userID(); |
---|
272 | |
---|
273 | try |
---|
274 | { |
---|
275 | # --BEHAVIOR-- adminBeforePostCreate |
---|
276 | $core->callBehavior('adminBeforePostCreate',$cur); |
---|
277 | |
---|
278 | $return_id = $core->blog->addPost($cur); |
---|
279 | |
---|
280 | # --BEHAVIOR-- adminAfterPostCreate |
---|
281 | $core->callBehavior('adminAfterPostCreate',$cur,$return_id); |
---|
282 | |
---|
283 | http::redirect('post.php?id='.$return_id.'&crea=1'); |
---|
284 | } |
---|
285 | catch (Exception $e) |
---|
286 | { |
---|
287 | $core->error->add($e->getMessage()); |
---|
288 | } |
---|
289 | } |
---|
290 | } |
---|
291 | |
---|
292 | # Getting categories |
---|
293 | $categories_combo = array(__('(No cat)') => ''); |
---|
294 | try { |
---|
295 | $categories = $core->blog->getCategories(array('post_type'=>'post')); |
---|
296 | if (!$categories->isEmpty()) { |
---|
297 | $l = $categories->level; |
---|
298 | $full_name = array($categories->cat_title); |
---|
299 | |
---|
300 | while ($categories->fetch()) { |
---|
301 | if ($categories->level < $l) { |
---|
302 | $full_name = array(); |
---|
303 | } elseif ($categories->level == $l) { |
---|
304 | array_pop($full_name); |
---|
305 | } |
---|
306 | $full_name[] = html::escapeHTML($categories->cat_title); |
---|
307 | $categories_combo[implode(' / ',$full_name)] = $categories->cat_id; |
---|
308 | $l = $categories->level; |
---|
309 | } |
---|
310 | } |
---|
311 | } catch (Exception $e) { } |
---|
312 | |
---|
313 | /* DISPLAY |
---|
314 | -------------------------------------------------------- */ |
---|
315 | $default_tab = 'edit-entry'; |
---|
316 | if (!$can_edit_post) { |
---|
317 | $default_tab = ''; |
---|
318 | } |
---|
319 | if (!empty($_GET['co'])) { |
---|
320 | $default_tab = 'comments'; |
---|
321 | } |
---|
322 | |
---|
323 | dcPage::open($page_title.' - '.__('Entries'), |
---|
324 | dcPage::jsDatePicker(). |
---|
325 | dcPage::jsToolBar(). |
---|
326 | dcPage::jsModal(). |
---|
327 | dcPage::jsMetaEditor(). |
---|
328 | dcPage::jsLoad('js/_post.js'). |
---|
329 | dcPage::jsConfirmClose('entry-form','comment-form'). |
---|
330 | # --BEHAVIOR-- adminPostHeaders |
---|
331 | $core->callBehavior('adminPostHeaders'). |
---|
332 | dcPage::jsPageTabs($default_tab). |
---|
333 | $next_headlink."\n".$prev_headlink |
---|
334 | ); |
---|
335 | |
---|
336 | if (!empty($_GET['upd'])) { |
---|
337 | dcPage::message(__('Entry has been successfully updated.')); |
---|
338 | } |
---|
339 | elseif (!empty($_GET['crea'])) { |
---|
340 | dcPage::message(__('Entry has been successfully created.')); |
---|
341 | } |
---|
342 | elseif (!empty($_GET['attached'])) { |
---|
343 | dcPage::message(__('File has been successfully attached.')); |
---|
344 | } |
---|
345 | elseif (!empty($_GET['rmattach'])) { |
---|
346 | dcPage::message(__('Attachment has been successfully removed.')); |
---|
347 | } |
---|
348 | |
---|
349 | if (!empty($_GET['creaco'])) { |
---|
350 | dcPage::message(__('Comment has been successfully created.')); |
---|
351 | } |
---|
352 | |
---|
353 | # XHTML conversion |
---|
354 | if (!empty($_GET['xconv'])) |
---|
355 | { |
---|
356 | $post_excerpt = $post_excerpt_xhtml; |
---|
357 | $post_content = $post_content_xhtml; |
---|
358 | $post_format = 'xhtml'; |
---|
359 | |
---|
360 | dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); |
---|
361 | } |
---|
362 | |
---|
363 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.'<a href="posts.php">'.__('Entries').'</a> › <span class="page-title">'; |
---|
364 | if ($post_id) { |
---|
365 | switch ($post_status) { |
---|
366 | case 1: |
---|
367 | $img_status = sprintf($img_status_pattern,__('published'),'check-on.png'); |
---|
368 | break; |
---|
369 | case 0: |
---|
370 | $img_status = sprintf($img_status_pattern,__('unpublished'),'check-off.png'); |
---|
371 | break; |
---|
372 | case -1: |
---|
373 | $img_status = sprintf($img_status_pattern,__('scheduled'),'scheduled.png'); |
---|
374 | break; |
---|
375 | case -2: |
---|
376 | $img_status = sprintf($img_status_pattern,__('pending'),'check-wrn.png'); |
---|
377 | break; |
---|
378 | default: |
---|
379 | $img_status = ''; |
---|
380 | } |
---|
381 | $edit_entry_str = __('Edit entry “%s”'); |
---|
382 | echo sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; |
---|
383 | } else { |
---|
384 | echo $page_title; |
---|
385 | } |
---|
386 | echo '</span></h2>'; |
---|
387 | |
---|
388 | if ($post_id && $post->post_status == 1) { |
---|
389 | echo '<p><a href="'.$post->getURL().'" onclick="window.open(this.href);return false;" title="'.$post_title.' ('.__('new window').')'.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; |
---|
390 | } |
---|
391 | if ($post_id) |
---|
392 | { |
---|
393 | echo '<p>'; |
---|
394 | if ($prev_link) { echo $prev_link; } |
---|
395 | if ($next_link && $prev_link) { echo ' - '; } |
---|
396 | if ($next_link) { echo $next_link; } |
---|
397 | |
---|
398 | # --BEHAVIOR-- adminPostNavLinks |
---|
399 | $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); |
---|
400 | |
---|
401 | echo '</p>'; |
---|
402 | } |
---|
403 | |
---|
404 | # Exit if we cannot view page |
---|
405 | if (!$can_view_page) { |
---|
406 | dcPage::helpBlock('core_post'); |
---|
407 | dcPage::close(); |
---|
408 | exit; |
---|
409 | } |
---|
410 | |
---|
411 | /* Post form if we can edit post |
---|
412 | -------------------------------------------------------- */ |
---|
413 | if ($can_edit_post) |
---|
414 | { |
---|
415 | echo '<div class="multi-part" title="'.__('Edit entry').'" id="edit-entry">'; |
---|
416 | echo '<form action="post.php" method="post" id="entry-form">'; |
---|
417 | echo '<div id="entry-wrapper">'; |
---|
418 | echo '<div id="entry-content"><div class="constrained">'; |
---|
419 | |
---|
420 | echo |
---|
421 | '<p class="col"><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). |
---|
422 | form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). |
---|
423 | '</label></p>'. |
---|
424 | |
---|
425 | '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '. |
---|
426 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). |
---|
427 | '</p>'. |
---|
428 | |
---|
429 | '<p class="area"><label class="required" '. |
---|
430 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. |
---|
431 | form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). |
---|
432 | '</p>'. |
---|
433 | |
---|
434 | '<p class="area" id="notes-area"><label for="post_notes">'.__('Notes:').'</label>'. |
---|
435 | form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). |
---|
436 | '</p>'; |
---|
437 | |
---|
438 | # --BEHAVIOR-- adminPostForm |
---|
439 | $core->callBehavior('adminPostForm',isset($post) ? $post : null); |
---|
440 | |
---|
441 | echo |
---|
442 | '<p>'. |
---|
443 | ($post_id ? form::hidden('id',$post_id) : ''). |
---|
444 | '<input type="submit" value="'.__('Save').' (s)" '. |
---|
445 | 'accesskey="s" name="save" /> '; |
---|
446 | if ($post_id) { |
---|
447 | $preview_url = |
---|
448 | $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. |
---|
449 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). |
---|
450 | '/'.$post->post_url); |
---|
451 | echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> '; |
---|
452 | } else { |
---|
453 | echo |
---|
454 | '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; |
---|
455 | } |
---|
456 | |
---|
457 | echo |
---|
458 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). |
---|
459 | $core->formNonce(). |
---|
460 | '</p>'; |
---|
461 | |
---|
462 | echo '</div></div>'; // End #entry-content |
---|
463 | echo '</div>'; // End #entry-wrapper |
---|
464 | |
---|
465 | echo '<div id="entry-sidebar">'; |
---|
466 | |
---|
467 | echo |
---|
468 | '<p><label for="cat_id">'.__('Category:'). |
---|
469 | form::combo('cat_id',$categories_combo,$cat_id,'maximal'). |
---|
470 | '</label></p>'. |
---|
471 | |
---|
472 | ($core->auth->check('categories', $core->blog->id) ? |
---|
473 | '<div>'. |
---|
474 | '<p id="new_cat">'.__('Add a new category').'</p>'. |
---|
475 | '<p><label for="new_cat_title">'.__('Title:').' '. |
---|
476 | form::field('new_cat_title',30,255,'','maximal').'</label></p>'. |
---|
477 | '<p><label for="new_cat_parent">'.__('Parent:').' '. |
---|
478 | form::combo('new_cat_parent',$categories_combo,'','maximal'). |
---|
479 | '</label></p>'. |
---|
480 | '</div>' |
---|
481 | : ''). |
---|
482 | |
---|
483 | '<p><label for="post_status">'.__('Entry status:'). |
---|
484 | form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). |
---|
485 | '</label></p>'. |
---|
486 | |
---|
487 | '<p><label for="post_dt">'.__('Published on:'). |
---|
488 | form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). |
---|
489 | '</label></p>'. |
---|
490 | |
---|
491 | '<p><label for="post_format">'.__('Text formating:'). |
---|
492 | form::combo('post_format',$formaters_combo,$post_format). |
---|
493 | '</label>'. |
---|
494 | '</p>'. |
---|
495 | '<p>'.($post_id && $post_format != 'xhtml' ? '<a id="convert-xhtml" class="button" href="post.php?id='.$post_id.'&xconv=1">'.__('Convert to XHTML').'</a>' : '').'</p>'. |
---|
496 | |
---|
497 | '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. |
---|
498 | __('Accept comments').'</label></p>'. |
---|
499 | ($core->blog->settings->system->allow_comments ? |
---|
500 | (isContributionAllowed($post_id,strtotime($post_dt),true) ? |
---|
501 | '' : |
---|
502 | '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : |
---|
503 | '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>'). |
---|
504 | |
---|
505 | '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. |
---|
506 | __('Accept trackbacks').'</label></p>'. |
---|
507 | ($core->blog->settings->system->allow_trackbacks ? |
---|
508 | (isContributionAllowed($post_id,strtotime($post_dt),false) ? |
---|
509 | '' : |
---|
510 | '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : |
---|
511 | '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'). |
---|
512 | |
---|
513 | '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. |
---|
514 | __('Selected entry').'</label></p>'. |
---|
515 | |
---|
516 | '<p><label for="post_lang">'.__('Entry lang:'). |
---|
517 | form::combo('post_lang',$lang_combo,$post_lang). |
---|
518 | '</label></p>'. |
---|
519 | |
---|
520 | '<p><label for="post_password">'.__('Entry password:'). |
---|
521 | form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). |
---|
522 | '</label></p>'. |
---|
523 | |
---|
524 | '<div class="lockable">'. |
---|
525 | '<p><label for="post_url">'.__('Basename:'). |
---|
526 | form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). |
---|
527 | '</label></p>'. |
---|
528 | '<p class="form-note warn">'. |
---|
529 | __('Warning: If you set the URL manually, it may conflict with another entry.'). |
---|
530 | '</p>'. |
---|
531 | '</div>'; |
---|
532 | |
---|
533 | # --BEHAVIOR-- adminPostFormSidebar |
---|
534 | $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); |
---|
535 | |
---|
536 | echo '</div>'; // End #entry-sidebar |
---|
537 | |
---|
538 | echo '</form>'; |
---|
539 | |
---|
540 | # --BEHAVIOR-- adminPostForm |
---|
541 | $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); |
---|
542 | |
---|
543 | echo '</div>'; |
---|
544 | |
---|
545 | if ($post_id && $post->post_status == 1) { |
---|
546 | echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. |
---|
547 | __('Ping blogs').'</a></p>'; |
---|
548 | } |
---|
549 | |
---|
550 | } |
---|
551 | |
---|
552 | |
---|
553 | /* Comments and trackbacks |
---|
554 | -------------------------------------------------------- */ |
---|
555 | if ($post_id) |
---|
556 | { |
---|
557 | $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); |
---|
558 | |
---|
559 | $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); |
---|
560 | $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); |
---|
561 | |
---|
562 | # Actions combo box |
---|
563 | $combo_action = array(); |
---|
564 | if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
565 | { |
---|
566 | $combo_action[__('publish')] = 'publish'; |
---|
567 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
568 | $combo_action[__('mark as pending')] = 'pending'; |
---|
569 | $combo_action[__('mark as junk')] = 'junk'; |
---|
570 | } |
---|
571 | |
---|
572 | if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
573 | { |
---|
574 | $combo_action[__('Delete')] = 'delete'; |
---|
575 | } |
---|
576 | |
---|
577 | # --BEHAVIOR-- adminCommentsActionsCombo |
---|
578 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
---|
579 | |
---|
580 | $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); |
---|
581 | |
---|
582 | echo |
---|
583 | '<div id="comments" class="multi-part" title="'.__('Comments').'">'; |
---|
584 | |
---|
585 | if ($has_action) { |
---|
586 | echo '<form action="comments_actions.php" id="form-comments" method="post">'; |
---|
587 | } |
---|
588 | |
---|
589 | echo '<h3>'.__('Trackbacks').'</h3>'; |
---|
590 | |
---|
591 | if (!$trackbacks->isEmpty()) { |
---|
592 | showComments($trackbacks,$has_action,true); |
---|
593 | } else { |
---|
594 | echo '<p>'.__('No trackback').'</p>'; |
---|
595 | } |
---|
596 | |
---|
597 | echo '<h3>'.__('Comments').'</h3>'; |
---|
598 | if (!$comments->isEmpty()) { |
---|
599 | showComments($comments,$has_action); |
---|
600 | } else { |
---|
601 | echo '<p>'.__('No comment').'</p>'; |
---|
602 | } |
---|
603 | |
---|
604 | if ($has_action) { |
---|
605 | echo |
---|
606 | '<div class="two-cols">'. |
---|
607 | '<p class="col checkboxes-helpers"></p>'. |
---|
608 | |
---|
609 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
610 | form::combo('action',$combo_action). |
---|
611 | form::hidden('redir','post.php?id='.$post_id.'&co=1'). |
---|
612 | $core->formNonce(). |
---|
613 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
614 | '</div>'. |
---|
615 | '</form>'; |
---|
616 | } |
---|
617 | |
---|
618 | echo '</div>'; |
---|
619 | } |
---|
620 | |
---|
621 | /* Add a comment |
---|
622 | -------------------------------------------------------- */ |
---|
623 | if ($post_id) |
---|
624 | { |
---|
625 | echo |
---|
626 | '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. |
---|
627 | '<h3>'.__('Add a comment').'</h3>'. |
---|
628 | |
---|
629 | '<form action="comment.php" method="post" id="comment-form">'. |
---|
630 | '<div class="constrained">'. |
---|
631 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). |
---|
632 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). |
---|
633 | '</label></p>'. |
---|
634 | |
---|
635 | '<p><label for="comment_email">'.__('Email:'). |
---|
636 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). |
---|
637 | '</label></p>'. |
---|
638 | |
---|
639 | '<p><label for="comment_site">'.__('Web site:'). |
---|
640 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). |
---|
641 | '</label></p>'. |
---|
642 | |
---|
643 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
644 | __('Comment:').'</label> '. |
---|
645 | form::textarea('comment_content',50,8,html::escapeHTML('')). |
---|
646 | '</p>'. |
---|
647 | |
---|
648 | '<p>'.form::hidden('post_id',$post_id). |
---|
649 | $core->formNonce(). |
---|
650 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. |
---|
651 | '</div>'. |
---|
652 | '</form>'. |
---|
653 | '</div>'; |
---|
654 | } |
---|
655 | |
---|
656 | # Controls comments or trakbacks capabilities |
---|
657 | function isContributionAllowed($id,$dt,$com=true) |
---|
658 | { |
---|
659 | global $core; |
---|
660 | |
---|
661 | if (!$id) { |
---|
662 | return true; |
---|
663 | } |
---|
664 | if ($com) { |
---|
665 | if (($core->blog->settings->system->comments_ttl == 0) || |
---|
666 | (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { |
---|
667 | return true; |
---|
668 | } |
---|
669 | } else { |
---|
670 | if (($core->blog->settings->system->trackbacks_ttl == 0) || |
---|
671 | (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { |
---|
672 | return true; |
---|
673 | } |
---|
674 | } |
---|
675 | return false; |
---|
676 | } |
---|
677 | |
---|
678 | # Show comments or trackbacks |
---|
679 | function showComments($rs,$has_action,$tb=false) |
---|
680 | { |
---|
681 | echo |
---|
682 | '<table class="comments-list"><tr>'. |
---|
683 | '<th colspan="2">'.__('Author').'</th>'. |
---|
684 | '<th>'.__('Date').'</th>'. |
---|
685 | '<th class="nowrap">'.__('IP address').'</th>'. |
---|
686 | '<th>'.__('Status').'</th>'. |
---|
687 | '<th> </th>'. |
---|
688 | '</tr>'; |
---|
689 | |
---|
690 | while($rs->fetch()) |
---|
691 | { |
---|
692 | $comment_url = 'comment.php?id='.$rs->comment_id; |
---|
693 | |
---|
694 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
695 | switch ($rs->comment_status) { |
---|
696 | case 1: |
---|
697 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
698 | break; |
---|
699 | case 0: |
---|
700 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
701 | break; |
---|
702 | case -1: |
---|
703 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
704 | break; |
---|
705 | case -2: |
---|
706 | $img_status = sprintf($img,__('junk'),'junk.png'); |
---|
707 | break; |
---|
708 | } |
---|
709 | |
---|
710 | echo |
---|
711 | '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. |
---|
712 | ' id="c'.$rs->comment_id.'">'. |
---|
713 | |
---|
714 | '<td class="nowrap">'. |
---|
715 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. |
---|
716 | '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. |
---|
717 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. |
---|
718 | '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. |
---|
719 | '<td class="nowrap status">'.$img_status.'</td>'. |
---|
720 | '<td class="nowrap status"><a href="'.$comment_url.'">'. |
---|
721 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. |
---|
722 | |
---|
723 | '</tr>'; |
---|
724 | } |
---|
725 | |
---|
726 | echo '</table>'; |
---|
727 | } |
---|
728 | |
---|
729 | dcPage::helpBlock('core_post','core_wiki'); |
---|
730 | dcPage::close(); |
---|
731 | ?> |
---|