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