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