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