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