[0] | 1 | <?php |
---|
[3731] | 2 | /** |
---|
| 3 | * @package Dotclear |
---|
| 4 | * @subpackage Backend |
---|
| 5 | * |
---|
| 6 | * @copyright Olivier Meunier & Association Dotclear |
---|
| 7 | * @copyright GPL-2.0-only |
---|
| 8 | */ |
---|
[0] | 9 | |
---|
[3703] | 10 | require dirname(__FILE__) . '/../inc/admin/prepend.php'; |
---|
[0] | 11 | |
---|
| 12 | dcPage::check('usage,contentadmin'); |
---|
| 13 | |
---|
[3703] | 14 | $post_id = ''; |
---|
| 15 | $cat_id = ''; |
---|
| 16 | $post_dt = ''; |
---|
| 17 | $post_format = $core->auth->getOption('post_format'); |
---|
| 18 | $post_editor = $core->auth->getOption('editor'); |
---|
| 19 | $post_password = ''; |
---|
| 20 | $post_url = ''; |
---|
| 21 | $post_lang = $core->auth->getInfo('user_lang'); |
---|
| 22 | $post_title = ''; |
---|
| 23 | $post_excerpt = ''; |
---|
[0] | 24 | $post_excerpt_xhtml = ''; |
---|
[3703] | 25 | $post_content = ''; |
---|
[0] | 26 | $post_content_xhtml = ''; |
---|
[3703] | 27 | $post_notes = ''; |
---|
| 28 | $post_status = $core->auth->getInfo('user_post_status'); |
---|
| 29 | $post_selected = false; |
---|
| 30 | $post_open_comment = $core->blog->settings->system->allow_comments; |
---|
| 31 | $post_open_tb = $core->blog->settings->system->allow_trackbacks; |
---|
[0] | 32 | |
---|
[195] | 33 | $page_title = __('New entry'); |
---|
[0] | 34 | |
---|
| 35 | $can_view_page = true; |
---|
[3703] | 36 | $can_edit_post = $core->auth->check('usage,contentadmin', $core->blog->id); |
---|
| 37 | $can_publish = $core->auth->check('publish,contentadmin', $core->blog->id); |
---|
| 38 | $can_delete = false; |
---|
[0] | 39 | |
---|
[3874] | 40 | $post_headlink = '<link rel="%s" title="%s" href="' . $core->adminurl->get('admin.post', ['id' => "%s"], '&', true) . '" />'; |
---|
| 41 | $post_link = '<a href="' . $core->adminurl->get('admin.post', ['id' => "%s"], '&', true) . '" title="%s">%s</a>'; |
---|
[3703] | 42 | $next_link = $prev_link = $next_headlink = $prev_headlink = null; |
---|
[0] | 43 | |
---|
| 44 | # If user can't publish |
---|
| 45 | if (!$can_publish) { |
---|
[3703] | 46 | $post_status = -2; |
---|
[0] | 47 | } |
---|
| 48 | |
---|
[1288] | 49 | # Getting categories |
---|
[1719] | 50 | $categories_combo = dcAdminCombos::getCategoriesCombo( |
---|
[3703] | 51 | $core->blog->getCategories() |
---|
[1719] | 52 | ); |
---|
[1288] | 53 | |
---|
[1719] | 54 | $status_combo = dcAdminCombos::getPostStatusesCombo(); |
---|
| 55 | |
---|
[933] | 56 | $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
[0] | 57 | |
---|
[2736] | 58 | # Formats combo |
---|
[3703] | 59 | $core_formaters = $core->getFormaters(); |
---|
[3874] | 60 | $available_formats = ['' => '']; |
---|
[2736] | 61 | foreach ($core_formaters as $editor => $formats) { |
---|
[3703] | 62 | foreach ($formats as $format) { |
---|
| 63 | $available_formats[$format] = $format; |
---|
| 64 | } |
---|
[2705] | 65 | } |
---|
[0] | 66 | |
---|
| 67 | # Languages combo |
---|
[3874] | 68 | $rs = $core->blog->getLangs(['order' => 'asc']); |
---|
[3703] | 69 | $lang_combo = dcAdminCombos::getLangsCombo($rs, true); |
---|
[0] | 70 | |
---|
[957] | 71 | # Validation flag |
---|
| 72 | $bad_dt = false; |
---|
[0] | 73 | |
---|
[1783] | 74 | # Trackbacks |
---|
[3703] | 75 | $TB = new dcTrackback($core); |
---|
[1783] | 76 | $tb_urls = $tb_excerpt = ''; |
---|
| 77 | |
---|
[0] | 78 | # Get entry informations |
---|
[2705] | 79 | if (!empty($_REQUEST['id'])) { |
---|
[3703] | 80 | $page_title = __('Edit entry'); |
---|
[2542] | 81 | |
---|
[3703] | 82 | $params['post_id'] = $_REQUEST['id']; |
---|
[2542] | 83 | |
---|
[3703] | 84 | $post = $core->blog->getPosts($params); |
---|
[2542] | 85 | |
---|
[3703] | 86 | if ($post->isEmpty()) { |
---|
| 87 | $core->error->add(__('This entry does not exist.')); |
---|
| 88 | $can_view_page = false; |
---|
| 89 | } else { |
---|
| 90 | $post_id = $post->post_id; |
---|
| 91 | $cat_id = $post->cat_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; |
---|
| 102 | $post_notes = $post->post_notes; |
---|
| 103 | $post_status = $post->post_status; |
---|
| 104 | $post_selected = (boolean) $post->post_selected; |
---|
| 105 | $post_open_comment = (boolean) $post->post_open_comment; |
---|
| 106 | $post_open_tb = (boolean) $post->post_open_tb; |
---|
[2542] | 107 | |
---|
[3703] | 108 | $can_edit_post = $post->isEditable(); |
---|
| 109 | $can_delete = $post->isDeletable(); |
---|
[2542] | 110 | |
---|
[3703] | 111 | $next_rs = $core->blog->getNextPost($post, 1); |
---|
| 112 | $prev_rs = $core->blog->getNextPost($post, -1); |
---|
[2542] | 113 | |
---|
[3703] | 114 | if ($next_rs !== null) { |
---|
| 115 | $next_link = sprintf($post_link, $next_rs->post_id, |
---|
| 116 | html::escapeHTML($next_rs->post_title), __('Next entry') . ' »'); |
---|
| 117 | $next_headlink = sprintf($post_headlink, 'next', |
---|
| 118 | html::escapeHTML($next_rs->post_title), $next_rs->post_id); |
---|
| 119 | } |
---|
[2542] | 120 | |
---|
[3703] | 121 | if ($prev_rs !== null) { |
---|
| 122 | $prev_link = sprintf($post_link, $prev_rs->post_id, |
---|
| 123 | html::escapeHTML($prev_rs->post_title), '« ' . __('Previous entry')); |
---|
| 124 | $prev_headlink = sprintf($post_headlink, 'previous', |
---|
| 125 | html::escapeHTML($prev_rs->post_title), $prev_rs->post_id); |
---|
| 126 | } |
---|
[2542] | 127 | |
---|
[3703] | 128 | try { |
---|
| 129 | $core->media = new dcMedia($core); |
---|
| 130 | } catch (Exception $e) { |
---|
| 131 | $core->error->add($e->getMessage()); |
---|
| 132 | } |
---|
[1783] | 133 | |
---|
[3703] | 134 | # Sanitize trackbacks excerpt |
---|
| 135 | $tb_excerpt = empty($_POST['tb_excerpt']) ? |
---|
| 136 | $post_excerpt_xhtml . ' ' . $post_content_xhtml : |
---|
| 137 | $_POST['tb_excerpt']; |
---|
| 138 | $tb_excerpt = html::decodeEntities(html::clean($tb_excerpt)); |
---|
| 139 | $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt), 255); |
---|
| 140 | $tb_excerpt = preg_replace('/\s+/ms', ' ', $tb_excerpt); |
---|
| 141 | } |
---|
[1783] | 142 | } |
---|
[3703] | 143 | if (isset($_REQUEST['section']) && $_REQUEST['section'] == 'trackbacks') { |
---|
| 144 | $anchor = 'trackbacks'; |
---|
[2067] | 145 | } else { |
---|
[3703] | 146 | $anchor = 'comments'; |
---|
[2542] | 147 | } |
---|
[2071] | 148 | |
---|
[3874] | 149 | $comments_actions_page = new dcCommentsActionsPage($core, $core->adminurl->get('admin.post'), ['id' => $post_id, '_ANCHOR' => $anchor, 'section' => $anchor]); |
---|
[2067] | 150 | |
---|
| 151 | if ($comments_actions_page->process()) { |
---|
[3703] | 152 | return; |
---|
[2067] | 153 | } |
---|
[1783] | 154 | |
---|
| 155 | # Ping blogs |
---|
[3703] | 156 | if (!empty($_POST['ping'])) { |
---|
| 157 | if (!empty($_POST['tb_urls']) && $post_id && $post_status == 1 && $can_edit_post) { |
---|
| 158 | $tb_urls = $_POST['tb_urls']; |
---|
| 159 | $tb_urls = str_replace("\r", '', $tb_urls); |
---|
| 160 | $tb_post_title = html::escapeHTML(trim(html::clean($post_title))); |
---|
| 161 | $tb_post_url = $post->getURL(); |
---|
[2542] | 162 | |
---|
[3703] | 163 | foreach (explode("\n", $tb_urls) as $tb_url) { |
---|
| 164 | try { |
---|
| 165 | # --BEHAVIOR-- adminBeforePingTrackback |
---|
| 166 | $core->callBehavior('adminBeforePingTrackback', $tb_url, $post_id, $tb_post_title, $tb_excerpt, $tb_post_url); |
---|
[3415] | 167 | |
---|
[3703] | 168 | $TB->ping($tb_url, $post_id, $tb_post_title, $tb_excerpt, $tb_post_url); |
---|
| 169 | } catch (Exception $e) { |
---|
| 170 | $core->error->add($e->getMessage()); |
---|
| 171 | } |
---|
| 172 | } |
---|
[2542] | 173 | |
---|
[3703] | 174 | if (!$core->error->flag()) { |
---|
| 175 | dcPage::addSuccessNotice(__('All pings sent.')); |
---|
| 176 | $core->adminurl->redirect( |
---|
| 177 | 'admin.post', |
---|
[3874] | 178 | ['id' => $post_id, 'tb' => '1'] |
---|
[3703] | 179 | ); |
---|
| 180 | } |
---|
| 181 | } |
---|
[0] | 182 | } |
---|
| 183 | |
---|
| 184 | # Format excerpt and content |
---|
[2705] | 185 | elseif (!empty($_POST) && $can_edit_post) { |
---|
[3703] | 186 | $post_format = $_POST['post_format']; |
---|
| 187 | $post_excerpt = $_POST['post_excerpt']; |
---|
| 188 | $post_content = $_POST['post_content']; |
---|
[2542] | 189 | |
---|
[3703] | 190 | $post_title = $_POST['post_title']; |
---|
[2542] | 191 | |
---|
[3703] | 192 | $cat_id = (integer) $_POST['cat_id']; |
---|
[2542] | 193 | |
---|
[3703] | 194 | if (isset($_POST['post_status'])) { |
---|
| 195 | $post_status = (integer) $_POST['post_status']; |
---|
| 196 | } |
---|
[2542] | 197 | |
---|
[3703] | 198 | if (empty($_POST['post_dt'])) { |
---|
| 199 | $post_dt = ''; |
---|
| 200 | } else { |
---|
| 201 | try |
---|
| 202 | { |
---|
| 203 | $post_dt = strtotime($_POST['post_dt']); |
---|
| 204 | if ($post_dt == false || $post_dt == -1) { |
---|
| 205 | $bad_dt = true; |
---|
| 206 | throw new Exception(__('Invalid publication date')); |
---|
| 207 | } |
---|
| 208 | $post_dt = date('Y-m-d H:i', $post_dt); |
---|
| 209 | } catch (Exception $e) { |
---|
| 210 | $core->error->add($e->getMessage()); |
---|
| 211 | } |
---|
| 212 | } |
---|
[2542] | 213 | |
---|
[3703] | 214 | $post_open_comment = !empty($_POST['post_open_comment']); |
---|
| 215 | $post_open_tb = !empty($_POST['post_open_tb']); |
---|
| 216 | $post_selected = !empty($_POST['post_selected']); |
---|
| 217 | $post_lang = $_POST['post_lang']; |
---|
| 218 | $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; |
---|
[2542] | 219 | |
---|
[3703] | 220 | $post_notes = $_POST['post_notes']; |
---|
[2542] | 221 | |
---|
[3703] | 222 | if (isset($_POST['post_url'])) { |
---|
| 223 | $post_url = $_POST['post_url']; |
---|
| 224 | } |
---|
[2542] | 225 | |
---|
[3703] | 226 | $core->blog->setPostContent( |
---|
| 227 | $post_id, $post_format, $post_lang, |
---|
| 228 | $post_excerpt, $post_excerpt_xhtml, $post_content, $post_content_xhtml |
---|
| 229 | ); |
---|
[0] | 230 | } |
---|
| 231 | |
---|
[1068] | 232 | # Delete post |
---|
[3703] | 233 | if (!empty($_POST['delete']) && $can_delete) { |
---|
| 234 | try { |
---|
| 235 | # --BEHAVIOR-- adminBeforePostDelete |
---|
| 236 | $core->callBehavior('adminBeforePostDelete', $post_id); |
---|
| 237 | $core->blog->delPost($post_id); |
---|
| 238 | $core->adminurl->redirect("admin.posts"); |
---|
| 239 | } catch (Exception $e) { |
---|
| 240 | $core->error->add($e->getMessage()); |
---|
| 241 | } |
---|
[1068] | 242 | } |
---|
| 243 | |
---|
[0] | 244 | # Create or update post |
---|
[3703] | 245 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) { |
---|
| 246 | # Create category |
---|
| 247 | if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { |
---|
[2542] | 248 | |
---|
[3703] | 249 | $cur_cat = $core->con->openCursor($core->prefix . 'category'); |
---|
| 250 | $cur_cat->cat_title = $_POST['new_cat_title']; |
---|
| 251 | $cur_cat->cat_url = ''; |
---|
[2542] | 252 | |
---|
[3703] | 253 | $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : ''; |
---|
[2542] | 254 | |
---|
[3703] | 255 | # --BEHAVIOR-- adminBeforeCategoryCreate |
---|
| 256 | $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); |
---|
[2542] | 257 | |
---|
[3703] | 258 | $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat); |
---|
[2542] | 259 | |
---|
[3703] | 260 | # --BEHAVIOR-- adminAfterCategoryCreate |
---|
| 261 | $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id); |
---|
| 262 | } |
---|
[2542] | 263 | |
---|
[3703] | 264 | $cur = $core->con->openCursor($core->prefix . 'post'); |
---|
[2542] | 265 | |
---|
[3703] | 266 | $cur->post_title = $post_title; |
---|
| 267 | $cur->cat_id = ($cat_id ?: null); |
---|
| 268 | $cur->post_dt = $post_dt ? date('Y-m-d H:i:00', strtotime($post_dt)) : ''; |
---|
| 269 | $cur->post_format = $post_format; |
---|
| 270 | $cur->post_password = $post_password; |
---|
| 271 | $cur->post_lang = $post_lang; |
---|
| 272 | $cur->post_title = $post_title; |
---|
| 273 | $cur->post_excerpt = $post_excerpt; |
---|
| 274 | $cur->post_excerpt_xhtml = $post_excerpt_xhtml; |
---|
| 275 | $cur->post_content = $post_content; |
---|
| 276 | $cur->post_content_xhtml = $post_content_xhtml; |
---|
| 277 | $cur->post_notes = $post_notes; |
---|
| 278 | $cur->post_status = $post_status; |
---|
| 279 | $cur->post_selected = (integer) $post_selected; |
---|
| 280 | $cur->post_open_comment = (integer) $post_open_comment; |
---|
| 281 | $cur->post_open_tb = (integer) $post_open_tb; |
---|
[2542] | 282 | |
---|
[3703] | 283 | if (isset($_POST['post_url'])) { |
---|
| 284 | $cur->post_url = $post_url; |
---|
| 285 | } |
---|
[2542] | 286 | |
---|
[3703] | 287 | # Update post |
---|
| 288 | if ($post_id) { |
---|
| 289 | try { |
---|
| 290 | # --BEHAVIOR-- adminBeforePostUpdate |
---|
| 291 | $core->callBehavior('adminBeforePostUpdate', $cur, $post_id); |
---|
[2542] | 292 | |
---|
[3703] | 293 | $core->blog->updPost($post_id, $cur); |
---|
[2542] | 294 | |
---|
[3703] | 295 | # --BEHAVIOR-- adminAfterPostUpdate |
---|
| 296 | $core->callBehavior('adminAfterPostUpdate', $cur, $post_id); |
---|
| 297 | dcPage::addSuccessNotice(sprintf(__('The post "%s" has been successfully updated'), html::escapeHTML($cur->post_title))); |
---|
| 298 | $core->adminurl->redirect( |
---|
| 299 | 'admin.post', |
---|
[3874] | 300 | ['id' => $post_id] |
---|
[3703] | 301 | ); |
---|
| 302 | } catch (Exception $e) { |
---|
| 303 | $core->error->add($e->getMessage()); |
---|
| 304 | } |
---|
| 305 | } else { |
---|
| 306 | $cur->user_id = $core->auth->userID(); |
---|
[2542] | 307 | |
---|
[3703] | 308 | try { |
---|
| 309 | # --BEHAVIOR-- adminBeforePostCreate |
---|
| 310 | $core->callBehavior('adminBeforePostCreate', $cur); |
---|
[2542] | 311 | |
---|
[3703] | 312 | $return_id = $core->blog->addPost($cur); |
---|
[2542] | 313 | |
---|
[3703] | 314 | # --BEHAVIOR-- adminAfterPostCreate |
---|
| 315 | $core->callBehavior('adminAfterPostCreate', $cur, $return_id); |
---|
[2256] | 316 | |
---|
[3703] | 317 | dcPage::addSuccessNotice(__('Entry has been successfully created.')); |
---|
| 318 | $core->adminurl->redirect( |
---|
| 319 | 'admin.post', |
---|
[3874] | 320 | ['id' => $return_id] |
---|
[3703] | 321 | ); |
---|
| 322 | } catch (Exception $e) { |
---|
| 323 | $core->error->add($e->getMessage()); |
---|
| 324 | } |
---|
| 325 | } |
---|
[0] | 326 | } |
---|
| 327 | |
---|
[1417] | 328 | # Getting categories |
---|
[1719] | 329 | $categories_combo = dcAdminCombos::getCategoriesCombo( |
---|
[3703] | 330 | $core->blog->getCategories() |
---|
[1719] | 331 | ); |
---|
[0] | 332 | /* DISPLAY |
---|
| 333 | -------------------------------------------------------- */ |
---|
| 334 | $default_tab = 'edit-entry'; |
---|
| 335 | if (!$can_edit_post) { |
---|
[3703] | 336 | $default_tab = ''; |
---|
[0] | 337 | } |
---|
| 338 | if (!empty($_GET['co'])) { |
---|
[3703] | 339 | $default_tab = 'comments'; |
---|
| 340 | } elseif (!empty($_GET['tb'])) { |
---|
| 341 | $default_tab = 'trackbacks'; |
---|
[1783] | 342 | } |
---|
[0] | 343 | |
---|
[1358] | 344 | if ($post_id) { |
---|
[3703] | 345 | switch ($post_status) { |
---|
| 346 | case 1: |
---|
| 347 | $img_status = sprintf($img_status_pattern, __('Published'), 'check-on.png'); |
---|
| 348 | break; |
---|
| 349 | case 0: |
---|
| 350 | $img_status = sprintf($img_status_pattern, __('Unpublished'), 'check-off.png'); |
---|
| 351 | break; |
---|
| 352 | case -1: |
---|
| 353 | $img_status = sprintf($img_status_pattern, __('Scheduled'), 'scheduled.png'); |
---|
| 354 | break; |
---|
| 355 | case -2: |
---|
| 356 | $img_status = sprintf($img_status_pattern, __('Pending'), 'check-wrn.png'); |
---|
| 357 | break; |
---|
| 358 | default: |
---|
| 359 | $img_status = ''; |
---|
| 360 | } |
---|
| 361 | $edit_entry_str = __('“%s”'); |
---|
| 362 | $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)) . ' ' . $img_status; |
---|
[1427] | 363 | } else { |
---|
[3703] | 364 | $img_status = ''; |
---|
[1358] | 365 | } |
---|
| 366 | |
---|
[2705] | 367 | $admin_post_behavior = ''; |
---|
[2856] | 368 | if ($post_editor) { |
---|
| 369 | $p_edit = $c_edit = ''; |
---|
| 370 | if (!empty($post_editor[$post_format])) { |
---|
| 371 | $p_edit = $post_editor[$post_format]; |
---|
| 372 | } |
---|
| 373 | if (!empty($post_editor['xhtml'])) { |
---|
| 374 | $c_edit = $post_editor['xhtml']; |
---|
| 375 | } |
---|
| 376 | if ($p_edit == $c_edit) { |
---|
| 377 | $admin_post_behavior .= $core->callBehavior('adminPostEditor', |
---|
[3874] | 378 | $p_edit, 'post', ['#post_excerpt', '#post_content', '#comment_content'], $post_format); |
---|
[2856] | 379 | } else { |
---|
| 380 | $admin_post_behavior .= $core->callBehavior('adminPostEditor', |
---|
[3874] | 381 | $p_edit, 'post', ['#post_excerpt', '#post_content'], $post_format); |
---|
[2856] | 382 | $admin_post_behavior .= $core->callBehavior('adminPostEditor', |
---|
[3874] | 383 | $c_edit, 'comment', ['#comment_content'], 'xhtml'); |
---|
[2856] | 384 | } |
---|
[2705] | 385 | } |
---|
[1358] | 386 | |
---|
[3703] | 387 | dcPage::open($page_title . ' - ' . __('Entries'), |
---|
| 388 | dcPage::jsDatePicker() . |
---|
| 389 | dcPage::jsModal() . |
---|
| 390 | dcPage::jsMetaEditor() . |
---|
| 391 | $admin_post_behavior . |
---|
| 392 | dcPage::jsLoad('js/_post.js') . |
---|
| 393 | dcPage::jsConfirmClose('entry-form', 'comment-form') . |
---|
| 394 | # --BEHAVIOR-- adminPostHeaders |
---|
| 395 | $core->callBehavior('adminPostHeaders') . |
---|
| 396 | dcPage::jsPageTabs($default_tab) . |
---|
| 397 | $next_headlink . "\n" . $prev_headlink, |
---|
| 398 | dcPage::breadcrumb( |
---|
[3874] | 399 | [ |
---|
[3703] | 400 | html::escapeHTML($core->blog->name) => '', |
---|
| 401 | __('Entries') => $core->adminurl->get("admin.posts"), |
---|
| 402 | ($post_id ? $page_title_edit : $page_title) => '' |
---|
[3874] | 403 | ]) |
---|
| 404 | , [ |
---|
[3703] | 405 | 'x-frame-allow' => $core->blog->url |
---|
[3874] | 406 | ] |
---|
[0] | 407 | ); |
---|
| 408 | |
---|
| 409 | if (!empty($_GET['upd'])) { |
---|
[3703] | 410 | dcPage::success(__('Entry has been successfully updated.')); |
---|
| 411 | } elseif (!empty($_GET['crea'])) { |
---|
| 412 | dcPage::success(__('Entry has been successfully created.')); |
---|
| 413 | } elseif (!empty($_GET['attached'])) { |
---|
| 414 | dcPage::success(__('File has been successfully attached.')); |
---|
| 415 | } elseif (!empty($_GET['rmattach'])) { |
---|
| 416 | dcPage::success(__('Attachment has been successfully removed.')); |
---|
[0] | 417 | } |
---|
| 418 | |
---|
| 419 | if (!empty($_GET['creaco'])) { |
---|
[3703] | 420 | dcPage::success(__('Comment has been successfully created.')); |
---|
[907] | 421 | } |
---|
[1783] | 422 | if (!empty($_GET['tbsent'])) { |
---|
[3703] | 423 | dcPage::success(__('All pings sent.')); |
---|
[1783] | 424 | } |
---|
[0] | 425 | |
---|
| 426 | # XHTML conversion |
---|
[3703] | 427 | if (!empty($_GET['xconv'])) { |
---|
| 428 | $post_excerpt = $post_excerpt_xhtml; |
---|
| 429 | $post_content = $post_content_xhtml; |
---|
| 430 | $post_format = 'xhtml'; |
---|
[2542] | 431 | |
---|
[3703] | 432 | dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); |
---|
[0] | 433 | } |
---|
| 434 | |
---|
| 435 | if ($post_id && $post->post_status == 1) { |
---|
[3771] | 436 | echo '<p><a class="onblog_link outgoing" href="' . $post->getURL() . '" title="' . html::escapeHTML($post_title) . '">' . __('Go to this entry on the site') . ' <img src="images/outgoing-link.svg" alt="" /></a></p>'; |
---|
[0] | 437 | } |
---|
[3703] | 438 | if ($post_id) { |
---|
| 439 | echo '<p class="nav_prevnext">'; |
---|
| 440 | if ($prev_link) {echo $prev_link;} |
---|
| 441 | if ($next_link && $prev_link) {echo ' | ';} |
---|
| 442 | if ($next_link) {echo $next_link;} |
---|
[2542] | 443 | |
---|
[3703] | 444 | # --BEHAVIOR-- adminPostNavLinks |
---|
| 445 | $core->callBehavior('adminPostNavLinks', isset($post) ? $post : null, 'post'); |
---|
[2542] | 446 | |
---|
[3703] | 447 | echo '</p>'; |
---|
[0] | 448 | } |
---|
| 449 | |
---|
| 450 | # Exit if we cannot view page |
---|
| 451 | if (!$can_view_page) { |
---|
[3703] | 452 | dcPage::helpBlock('core_post'); |
---|
| 453 | dcPage::close(); |
---|
| 454 | exit; |
---|
[0] | 455 | } |
---|
[3491] | 456 | |
---|
| 457 | # Controls comments or trakbacks capabilities |
---|
[3703] | 458 | $isContributionAllowed = function ($id, $dt, $com = true) { |
---|
| 459 | global $core; |
---|
[3491] | 460 | |
---|
[3703] | 461 | if (!$id) { |
---|
| 462 | return true; |
---|
| 463 | } |
---|
| 464 | if ($com) { |
---|
| 465 | if (($core->blog->settings->system->comments_ttl == 0) || |
---|
| 466 | (time() - $core->blog->settings->system->comments_ttl * 86400 < $dt)) { |
---|
| 467 | return true; |
---|
| 468 | } |
---|
| 469 | } else { |
---|
| 470 | if (($core->blog->settings->system->trackbacks_ttl == 0) || |
---|
| 471 | (time() - $core->blog->settings->system->trackbacks_ttl * 86400 < $dt)) { |
---|
| 472 | return true; |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | return false; |
---|
[3491] | 476 | }; |
---|
| 477 | |
---|
| 478 | # Show comments or trackbacks |
---|
[3703] | 479 | $showComments = function ($rs, $has_action, $tb = false) { |
---|
| 480 | global $core; |
---|
| 481 | echo |
---|
| 482 | '<div class="table-outer">' . |
---|
| 483 | '<table class="comments-list"><tr>' . |
---|
| 484 | '<th colspan="2" class="first">' . __('Author') . '</th>' . |
---|
| 485 | '<th>' . __('Date') . '</th>' . |
---|
| 486 | '<th class="nowrap">' . __('IP address') . '</th>' . |
---|
| 487 | '<th>' . __('Status') . '</th>' . |
---|
| 488 | '<th>' . __('Edit') . '</th>' . |
---|
| 489 | '</tr>'; |
---|
[3874] | 490 | $comments = []; |
---|
[3703] | 491 | if (isset($_REQUEST['comments'])) { |
---|
| 492 | foreach ($_REQUEST['comments'] as $v) { |
---|
| 493 | $comments[(integer) $v] = true; |
---|
| 494 | } |
---|
| 495 | } |
---|
[3491] | 496 | |
---|
[3703] | 497 | while ($rs->fetch()) { |
---|
[3874] | 498 | $comment_url = $core->adminurl->get("admin.comment", ['id' => $rs->comment_id]); |
---|
[3491] | 499 | |
---|
[3878] | 500 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 501 | $sts_class = ''; |
---|
[3703] | 502 | switch ($rs->comment_status) { |
---|
| 503 | case 1: |
---|
| 504 | $img_status = sprintf($img, __('Published'), 'check-on.png'); |
---|
[3878] | 505 | $sts_class = 'sts-online'; |
---|
[3703] | 506 | break; |
---|
| 507 | case 0: |
---|
| 508 | $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); |
---|
[3878] | 509 | $sts_class = 'sts-offline'; |
---|
[3703] | 510 | break; |
---|
| 511 | case -1: |
---|
| 512 | $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); |
---|
[3878] | 513 | $sts_class = 'sts-pending'; |
---|
[3703] | 514 | break; |
---|
| 515 | case -2: |
---|
| 516 | $img_status = sprintf($img, __('Junk'), 'junk.png'); |
---|
[3878] | 517 | $sts_class = 'sts-junk'; |
---|
[3703] | 518 | break; |
---|
| 519 | } |
---|
[3491] | 520 | |
---|
[3703] | 521 | echo |
---|
[3878] | 522 | '<tr class="line ' . ($rs->comment_status != 1 ? ' offline ' : '') . $sts_class . '"' . |
---|
[3703] | 523 | ' id="c' . $rs->comment_id . '">' . |
---|
[3491] | 524 | |
---|
[3703] | 525 | '<td class="nowrap">' . |
---|
[3874] | 526 | ($has_action ? form::checkbox(['comments[]'], $rs->comment_id, |
---|
| 527 | [ |
---|
[3707] | 528 | 'checked' => isset($comments[$rs->comment_id]), |
---|
| 529 | 'extra_html' => 'title="' . ($tb ? __('select this trackback') : __('select this comment') . '"') |
---|
[3874] | 530 | ] |
---|
[3710] | 531 | ) : '') . '</td>' . |
---|
| 532 | '<td class="maximal">' . html::escapeHTML($rs->comment_author) . '</td>' . |
---|
| 533 | '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $rs->comment_dt) . '</td>' . |
---|
[3874] | 534 | '<td class="nowrap"><a href="' . $core->adminurl->get("admin.comments", ['ip' => $rs->comment_ip]) . '">' . $rs->comment_ip . '</a></td>' . |
---|
[3710] | 535 | '<td class="nowrap status">' . $img_status . '</td>' . |
---|
| 536 | '<td class="nowrap status"><a href="' . $comment_url . '">' . |
---|
| 537 | '<img src="images/edit-mini.png" alt="" title="' . __('Edit this comment') . '" /> ' . __('Edit') . '</a></td>' . |
---|
[3491] | 538 | |
---|
[3710] | 539 | '</tr>'; |
---|
| 540 | } |
---|
[3491] | 541 | |
---|
[3710] | 542 | echo '</table></div>'; |
---|
| 543 | }; |
---|
[3491] | 544 | |
---|
[0] | 545 | /* Post form if we can edit post |
---|
| 546 | -------------------------------------------------------- */ |
---|
[3710] | 547 | if ($can_edit_post) { |
---|
[3874] | 548 | $sidebar_items = new ArrayObject([ |
---|
| 549 | 'status-box' => [ |
---|
[3710] | 550 | 'title' => __('Status'), |
---|
[3874] | 551 | 'items' => [ |
---|
[3710] | 552 | 'post_status' => |
---|
| 553 | '<p class="entry-status"><label for="post_status">' . __('Entry status') . ' ' . $img_status . '</label>' . |
---|
| 554 | form::combo('post_status', $status_combo, |
---|
[3874] | 555 | ['default' => $post_status, 'class' => 'maximal', 'disabled' => !$can_publish]) . |
---|
[3710] | 556 | '</p>', |
---|
| 557 | 'post_dt' => |
---|
| 558 | '<p><label for="post_dt">' . __('Publication date and hour') . '</label>' . |
---|
| 559 | form::field('post_dt', 16, 16, $post_dt, ($bad_dt ? 'invalid' : '')) . |
---|
[3725] | 560 | /* |
---|
| 561 | Previous line will be replaced by this one as soon as every browser will support datetime-local input type |
---|
| 562 | Dont forget to remove call to datepicker in post.js |
---|
| 563 | |
---|
[3874] | 564 | form::datetime('post_dt', [ |
---|
[3730] | 565 | 'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($post_dt))), |
---|
| 566 | 'class' => ($bad_dt ? 'invalid' : '') |
---|
[3874] | 567 | ]) . |
---|
[3730] | 568 | */ |
---|
[3710] | 569 | '</p>', |
---|
| 570 | 'post_lang' => |
---|
| 571 | '<p><label for="post_lang">' . __('Entry language') . '</label>' . |
---|
| 572 | form::combo('post_lang', $lang_combo, $post_lang) . |
---|
| 573 | '</p>', |
---|
| 574 | 'post_format' => |
---|
| 575 | '<div>' . |
---|
| 576 | '<h5 id="label_format"><label for="post_format" class="classic">' . __('Text formatting') . '</label></h5>' . |
---|
| 577 | '<p>' . form::combo('post_format', $available_formats, $post_format, 'maximal') . '</p>' . |
---|
| 578 | '<p class="format_control control_no_xhtml">' . |
---|
| 579 | '<a id="convert-xhtml" class="button' . ($post_id && $post_format != 'wiki' ? ' hide' : '') . '" href="' . |
---|
[3874] | 580 | $core->adminurl->get('admin.post', ['id' => $post_id, 'xconv' => '1']) . |
---|
[3710] | 581 | '">' . |
---|
[3874] | 582 | __('Convert to XHTML') . '</a></p></div>']], |
---|
| 583 | 'metas-box' => [ |
---|
[3710] | 584 | 'title' => __('Filing'), |
---|
[3874] | 585 | 'items' => [ |
---|
[3710] | 586 | 'post_selected' => |
---|
| 587 | '<p><label for="post_selected" class="classic">' . |
---|
| 588 | form::checkbox('post_selected', 1, $post_selected) . ' ' . |
---|
| 589 | __('Selected entry') . '</label></p>', |
---|
| 590 | 'cat_id' => |
---|
| 591 | '<div>' . |
---|
| 592 | '<h5 id="label_cat_id">' . __('Category') . '</h5>' . |
---|
| 593 | '<p><label for="cat_id">' . __('Category:') . '</label>' . |
---|
| 594 | form::combo('cat_id', $categories_combo, $cat_id, 'maximal') . |
---|
| 595 | '</p>' . |
---|
| 596 | ($core->auth->check('categories', $core->blog->id) ? |
---|
[3703] | 597 | '<div>' . |
---|
[3710] | 598 | '<h5 id="create_cat">' . __('Add a new category') . '</h5>' . |
---|
| 599 | '<p><label for="new_cat_title">' . __('Title:') . ' ' . |
---|
[3874] | 600 | form::field('new_cat_title', 30, 255, ['class' => 'maximal']) . '</label></p>' . |
---|
[3710] | 601 | '<p><label for="new_cat_parent">' . __('Parent:') . ' ' . |
---|
| 602 | form::combo('new_cat_parent', $categories_combo, '', 'maximal') . |
---|
| 603 | '</label></p>' . |
---|
| 604 | '</div>' |
---|
| 605 | : '') . |
---|
[3874] | 606 | '</div>']], |
---|
| 607 | 'options-box' => [ |
---|
[3710] | 608 | 'title' => __('Options'), |
---|
[3874] | 609 | 'items' => [ |
---|
[3710] | 610 | 'post_open_comment_tb' => |
---|
| 611 | '<div>' . |
---|
| 612 | '<h5 id="label_comment_tb">' . __('Comments and trackbacks list') . '</h5>' . |
---|
| 613 | '<p><label for="post_open_comment" class="classic">' . |
---|
| 614 | form::checkbox('post_open_comment', 1, $post_open_comment) . ' ' . |
---|
| 615 | __('Accept comments') . '</label></p>' . |
---|
| 616 | ($core->blog->settings->system->allow_comments ? |
---|
| 617 | ($isContributionAllowed($post_id, strtotime($post_dt), true) ? |
---|
| 618 | '' : |
---|
[3703] | 619 | '<p class="form-note warn">' . |
---|
[3710] | 620 | __('Warning: Comments are not more accepted for this entry.') . '</p>') : |
---|
[3703] | 621 | '<p class="form-note warn">' . |
---|
[3710] | 622 | __('Comments are not accepted on this blog so far.') . '</p>') . |
---|
| 623 | '<p><label for="post_open_tb" class="classic">' . |
---|
| 624 | form::checkbox('post_open_tb', 1, $post_open_tb) . ' ' . |
---|
| 625 | __('Accept trackbacks') . '</label></p>' . |
---|
| 626 | ($core->blog->settings->system->allow_trackbacks ? |
---|
| 627 | ($isContributionAllowed($post_id, strtotime($post_dt), false) ? |
---|
| 628 | '' : |
---|
| 629 | '<p class="form-note warn">' . |
---|
| 630 | __('Warning: Trackbacks are not more accepted for this entry.') . '</p>') : |
---|
| 631 | '<p class="form-note warn">' . __('Trackbacks are not accepted on this blog so far.') . '</p>') . |
---|
| 632 | '</div>', |
---|
| 633 | 'post_password' => |
---|
| 634 | '<p><label for="post_password">' . __('Password') . '</label>' . |
---|
| 635 | form::field('post_password', 10, 32, html::escapeHTML($post_password), 'maximal') . |
---|
| 636 | '</p>', |
---|
| 637 | 'post_url' => |
---|
| 638 | '<div class="lockable">' . |
---|
| 639 | '<p><label for="post_url">' . __('Edit basename') . '</label>' . |
---|
| 640 | form::field('post_url', 10, 255, html::escapeHTML($post_url), 'maximal') . |
---|
| 641 | '</p>' . |
---|
| 642 | '<p class="form-note warn">' . |
---|
| 643 | __('Warning: If you set the URL manually, it may conflict with another entry.') . |
---|
| 644 | '</p></div>' |
---|
[3874] | 645 | ]]]); |
---|
[1398] | 646 | |
---|
[3874] | 647 | $main_items = new ArrayObject([ |
---|
[3710] | 648 | "post_title" => |
---|
| 649 | '<p class="col">' . |
---|
| 650 | '<label class="required no-margin bold" for="post_title"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Title:') . '</label>' . |
---|
[3874] | 651 | form::field('post_title', 20, 255, [ |
---|
[3725] | 652 | 'default' => html::escapeHTML($post_title), |
---|
| 653 | 'class' => 'maximal', |
---|
[3898] | 654 | 'extra_html' => 'required placeholder="' . __('Title') . '" lang="' . $post_lang . '" spellcheck="true"' |
---|
[3874] | 655 | ]) . |
---|
[3710] | 656 | '</p>', |
---|
[2542] | 657 | |
---|
[3710] | 658 | "post_excerpt" => |
---|
| 659 | '<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">' . __('Excerpt:') . ' <span class="form-note">' . |
---|
| 660 | __('Introduction to the post.') . '</span></label> ' . |
---|
[3897] | 661 | form::textarea('post_excerpt', 50, 5, |
---|
| 662 | [ |
---|
| 663 | 'default' => html::escapeHTML($post_excerpt), |
---|
[3898] | 664 | 'extra_html' => 'lang="' . $post_lang . '" spellcheck="true"' |
---|
[3897] | 665 | ]) . |
---|
[3710] | 666 | '</p>', |
---|
[2542] | 667 | |
---|
[3710] | 668 | "post_content" => |
---|
| 669 | '<p class="area" id="content-area"><label class="required bold" ' . |
---|
| 670 | 'for="post_content"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Content:') . '</label> ' . |
---|
| 671 | form::textarea('post_content', 50, $core->auth->getOption('edit_size'), |
---|
[3874] | 672 | [ |
---|
[3710] | 673 | 'default' => html::escapeHTML($post_content), |
---|
[3898] | 674 | 'extra_html' => 'required placeholder="' . __('Content') . '" lang="' . $post_lang . '" spellcheck="true"' |
---|
[3874] | 675 | ]) . |
---|
[3710] | 676 | '</p>', |
---|
[2542] | 677 | |
---|
[3710] | 678 | "post_notes" => |
---|
| 679 | '<p class="area" id="notes-area"><label for="post_notes" class="bold">' . __('Personal notes:') . ' <span class="form-note">' . |
---|
| 680 | __('Unpublished notes.') . '</span></label>' . |
---|
[3898] | 681 | form::textarea('post_notes', 50, 5, |
---|
| 682 | [ |
---|
| 683 | 'default' => html::escapeHTML($post_notes), |
---|
| 684 | 'extra_html' => 'lang="' . $post_lang . '" spellcheck="true"' |
---|
| 685 | ]) . |
---|
[3710] | 686 | '</p>' |
---|
[3874] | 687 | ] |
---|
[3710] | 688 | ); |
---|
[2542] | 689 | |
---|
[3710] | 690 | # --BEHAVIOR-- adminPostFormItems |
---|
| 691 | $core->callBehavior('adminPostFormItems', $main_items, $sidebar_items, isset($post) ? $post : null, 'post'); |
---|
[1398] | 692 | |
---|
[3710] | 693 | echo '<div class="multi-part" title="' . ($post_id ? __('Edit entry') : __('New entry')) . |
---|
| 694 | sprintf(' › %s', $post_format) . '" id="edit-entry">'; |
---|
| 695 | echo '<form action="' . $core->adminurl->get('admin.post') . '" method="post" id="entry-form">'; |
---|
| 696 | echo '<div id="entry-wrapper">'; |
---|
| 697 | echo '<div id="entry-content"><div class="constrained">'; |
---|
[1398] | 698 | |
---|
[3710] | 699 | echo '<h3 class="out-of-screen-if-js">' . __('Edit post') . '</h3>'; |
---|
[2542] | 700 | |
---|
[3710] | 701 | foreach ($main_items as $id => $item) { |
---|
| 702 | echo $item; |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | # --BEHAVIOR-- adminPostForm (may be deprecated) |
---|
| 706 | $core->callBehavior('adminPostForm', isset($post) ? $post : null, 'post'); |
---|
| 707 | |
---|
| 708 | echo |
---|
| 709 | '<p class="border-top">' . |
---|
| 710 | ($post_id ? form::hidden('id', $post_id) : '') . |
---|
| 711 | '<input type="submit" value="' . __('Save') . ' (s)" ' . |
---|
| 712 | 'accesskey="s" name="save" /> '; |
---|
| 713 | if ($post_id) { |
---|
| 714 | $preview_url = |
---|
| 715 | $core->blog->url . $core->url->getURLFor('preview', $core->auth->userID() . '/' . |
---|
| 716 | http::browserUID(DC_MASTER_KEY . $core->auth->userID() . $core->auth->cryptLegacy($core->auth->userID())) . |
---|
| 717 | '/' . $post->post_url); |
---|
| 718 | echo '<a id="post-preview" href="' . $preview_url . '" class="button modal" accesskey="p">' . __('Preview') . ' (p)' . '</a>'; |
---|
| 719 | } else { |
---|
| 720 | echo |
---|
| 721 | '<a id="post-cancel" href="' . $core->adminurl->get("admin.home") . '" class="button" accesskey="c">' . __('Cancel') . ' (c)</a>'; |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | echo |
---|
| 725 | ($can_delete ? ' <input type="submit" class="delete" value="' . __('Delete') . '" name="delete" />' : '') . |
---|
| 726 | $core->formNonce() . |
---|
| 727 | '</p>'; |
---|
| 728 | |
---|
| 729 | echo '</div></div>'; // End #entry-content |
---|
| 730 | echo '</div>'; // End #entry-wrapper |
---|
| 731 | |
---|
| 732 | echo '<div id="entry-sidebar" role="complementary">'; |
---|
| 733 | |
---|
| 734 | foreach ($sidebar_items as $id => $c) { |
---|
| 735 | echo '<div id="' . $id . '" class="sb-box">' . |
---|
| 736 | '<h4>' . $c['title'] . '</h4>'; |
---|
| 737 | foreach ($c['items'] as $e_name => $e_content) { |
---|
| 738 | echo $e_content; |
---|
[3707] | 739 | } |
---|
[3710] | 740 | echo '</div>'; |
---|
| 741 | } |
---|
[1398] | 742 | |
---|
[3710] | 743 | # --BEHAVIOR-- adminPostFormSidebar (may be deprecated) |
---|
| 744 | $core->callBehavior('adminPostFormSidebar', isset($post) ? $post : null, 'post'); |
---|
| 745 | echo '</div>'; // End #entry-sidebar |
---|
| 746 | |
---|
| 747 | echo '</form>'; |
---|
| 748 | |
---|
| 749 | # --BEHAVIOR-- adminPostForm |
---|
| 750 | $core->callBehavior('adminPostAfterForm', isset($post) ? $post : null, 'post'); |
---|
| 751 | |
---|
| 752 | echo '</div>'; |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | if ($post_id) { |
---|
| 756 | /* Comments |
---|
| 757 | -------------------------------------------------------- */ |
---|
| 758 | |
---|
[3874] | 759 | $params = ['post_id' => $post_id, 'order' => 'comment_dt ASC']; |
---|
[3710] | 760 | |
---|
[3874] | 761 | $comments = $core->blog->getComments(array_merge($params, ['comment_trackback' => 0])); |
---|
[3710] | 762 | |
---|
| 763 | echo |
---|
| 764 | '<div id="comments" class="clear multi-part" title="' . __('Comments') . '">'; |
---|
| 765 | $combo_action = $comments_actions_page->getCombo(); |
---|
| 766 | $has_action = !empty($combo_action) && !$comments->isEmpty(); |
---|
| 767 | echo |
---|
| 768 | '<p class="top-add"><a class="button add" href="#comment-form">' . __('Add a comment') . '</a></p>'; |
---|
| 769 | |
---|
| 770 | if ($has_action) { |
---|
| 771 | echo '<form action="' . $core->adminurl->get('admin.post') . '" id="form-comments" method="post">'; |
---|
| 772 | } |
---|
| 773 | |
---|
| 774 | echo '<h3>' . __('Comments') . '</h3>'; |
---|
| 775 | if (!$comments->isEmpty()) { |
---|
| 776 | $showComments($comments, $has_action); |
---|
| 777 | } else { |
---|
| 778 | echo '<p>' . __('No comments') . '</p>'; |
---|
| 779 | } |
---|
| 780 | |
---|
| 781 | if ($has_action) { |
---|
| 782 | echo |
---|
| 783 | '<div class="two-cols">' . |
---|
| 784 | '<p class="col checkboxes-helpers"></p>' . |
---|
| 785 | |
---|
| 786 | '<p class="col right"><label for="action" class="classic">' . __('Selected comments action:') . '</label> ' . |
---|
| 787 | form::combo('action', $combo_action) . |
---|
[3874] | 788 | form::hidden(['section'], 'comments') . |
---|
| 789 | form::hidden(['id'], $post_id) . |
---|
[3710] | 790 | $core->formNonce() . |
---|
| 791 | '<input type="submit" value="' . __('ok') . '" /></p>' . |
---|
| 792 | '</div>' . |
---|
| 793 | '</form>'; |
---|
| 794 | } |
---|
| 795 | /* Add a comment |
---|
| 796 | -------------------------------------------------------- */ |
---|
| 797 | |
---|
| 798 | echo |
---|
| 799 | '<div class="fieldset clear">' . |
---|
| 800 | '<h3>' . __('Add a comment') . '</h3>' . |
---|
| 801 | |
---|
| 802 | '<form action="' . $core->adminurl->get("admin.comment") . '" method="post" id="comment-form">' . |
---|
| 803 | '<div class="constrained">' . |
---|
| 804 | '<p><label for="comment_author" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Name:') . '</label>' . |
---|
[3874] | 805 | form::field('comment_author', 30, 255, [ |
---|
[3725] | 806 | 'default' => html::escapeHTML($core->auth->getInfo('user_cn')), |
---|
| 807 | 'extra_html' => 'required placeholder="' . __('Author') . '"' |
---|
[3874] | 808 | ]) . |
---|
[3710] | 809 | '</p>' . |
---|
| 810 | |
---|
| 811 | '<p><label for="comment_email">' . __('Email:') . '</label>' . |
---|
[3725] | 812 | form::email('comment_email', 30, 255, html::escapeHTML($core->auth->getInfo('user_email'))) . |
---|
[3710] | 813 | '</p>' . |
---|
| 814 | |
---|
| 815 | '<p><label for="comment_site">' . __('Web site:') . '</label>' . |
---|
[3725] | 816 | form::url('comment_site', 30, 255, html::escapeHTML($core->auth->getInfo('user_url'))) . |
---|
[3710] | 817 | '</p>' . |
---|
| 818 | |
---|
| 819 | '<p class="area"><label for="comment_content" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . |
---|
| 820 | __('Comment:') . '</label> ' . |
---|
[3897] | 821 | form::textarea('comment_content', 50, 8, |
---|
| 822 | [ |
---|
[3898] | 823 | 'extra_html' => 'required placeholder="' . __('Comment') . '" lang="' . $core->auth->getInfo('user_lang') . |
---|
| 824 | '" spellcheck="true"' |
---|
[3897] | 825 | ]) . |
---|
[3710] | 826 | '</p>' . |
---|
| 827 | |
---|
| 828 | '<p>' . |
---|
| 829 | form::hidden('post_id', $post_id) . |
---|
| 830 | $core->formNonce() . |
---|
| 831 | '<input type="submit" name="add" value="' . __('Save') . '" /></p>' . |
---|
| 832 | '</div>' . #constrained |
---|
| 833 | |
---|
| 834 | '</form>' . |
---|
| 835 | '</div>' . #add comment |
---|
| 836 | '</div>'; #comments |
---|
| 837 | } |
---|
| 838 | |
---|
| 839 | if ($post_id && $post_status == 1) { |
---|
| 840 | /* Trackbacks |
---|
| 841 | -------------------------------------------------------- */ |
---|
| 842 | |
---|
[3874] | 843 | $params = ['post_id' => $post_id, 'order' => 'comment_dt ASC']; |
---|
| 844 | $trackbacks = $core->blog->getComments(array_merge($params, ['comment_trackback' => 1])); |
---|
[3710] | 845 | |
---|
| 846 | # Actions combo box |
---|
| 847 | $combo_action = $comments_actions_page->getCombo(); |
---|
| 848 | $has_action = !empty($combo_action) && !$trackbacks->isEmpty(); |
---|
| 849 | |
---|
| 850 | if (!empty($_GET['tb_auto'])) { |
---|
| 851 | $tb_urls = implode("\n", $TB->discover($post_excerpt_xhtml . ' ' . $post_content_xhtml)); |
---|
| 852 | } |
---|
| 853 | |
---|
| 854 | # Display tab |
---|
| 855 | echo |
---|
| 856 | '<div id="trackbacks" class="clear multi-part" title="' . __('Trackbacks') . '">'; |
---|
| 857 | |
---|
| 858 | # tracbacks actions |
---|
| 859 | if ($has_action) { |
---|
| 860 | echo '<form action="' . $core->adminurl->get("admin.post") . '" id="form-trackbacks" method="post">'; |
---|
| 861 | } |
---|
| 862 | |
---|
| 863 | echo '<h3>' . __('Trackbacks received') . '</h3>'; |
---|
| 864 | |
---|
| 865 | if (!$trackbacks->isEmpty()) { |
---|
| 866 | $showComments($trackbacks, $has_action, true); |
---|
| 867 | } else { |
---|
| 868 | echo '<p>' . __('No trackback') . '</p>'; |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | if ($has_action) { |
---|
| 872 | echo |
---|
| 873 | '<div class="two-cols">' . |
---|
| 874 | '<p class="col checkboxes-helpers"></p>' . |
---|
| 875 | |
---|
| 876 | '<p class="col right"><label for="action" class="classic">' . __('Selected trackbacks action:') . '</label> ' . |
---|
| 877 | form::combo('action', $combo_action) . |
---|
| 878 | form::hidden('id', $post_id) . |
---|
[3874] | 879 | form::hidden(['section'], 'trackbacks') . |
---|
[3710] | 880 | $core->formNonce() . |
---|
| 881 | '<input type="submit" value="' . __('ok') . '" /></p>' . |
---|
| 882 | '</div>' . |
---|
| 883 | '</form>'; |
---|
| 884 | } |
---|
| 885 | |
---|
| 886 | /* Add trackbacks |
---|
| 887 | -------------------------------------------------------- */ |
---|
| 888 | if ($can_edit_post && $post->post_status) { |
---|
| 889 | echo |
---|
| 890 | '<div class="fieldset clear">'; |
---|
[1783] | 891 | |
---|
[3703] | 892 | echo |
---|
[3710] | 893 | '<h3>' . __('Ping blogs') . '</h3>' . |
---|
[3874] | 894 | '<form action="' . $core->adminurl->get("admin.post", ['id' => $post_id]) . '" id="trackback-form" method="post">' . |
---|
[3710] | 895 | '<p><label for="tb_urls" class="area">' . __('URLs to ping:') . '</label>' . |
---|
| 896 | form::textarea('tb_urls', 60, 5, $tb_urls) . |
---|
| 897 | '</p>' . |
---|
| 898 | |
---|
| 899 | '<p><label for="tb_excerpt" class="area">' . __('Excerpt to send:') . '</label>' . |
---|
| 900 | form::textarea('tb_excerpt', 60, 5, $tb_excerpt) . '</p>' . |
---|
| 901 | |
---|
| 902 | '<p>' . |
---|
| 903 | $core->formNonce() . |
---|
| 904 | '<input type="submit" name="ping" value="' . __('Ping blogs') . '" />' . |
---|
| 905 | (empty($_GET['tb_auto']) ? |
---|
| 906 | ' <a class="button" href="' . |
---|
[3874] | 907 | $core->adminurl->get("admin.post", ['id' => $post_id, 'tb_auto' => 1, 'tb' => 1]) . |
---|
[3710] | 908 | '">' . __('Auto discover ping URLs') . '</a>' |
---|
| 909 | : '') . |
---|
| 910 | '</p>' . |
---|
| 911 | '</form>'; |
---|
| 912 | |
---|
| 913 | $pings = $TB->getPostPings($post_id); |
---|
| 914 | |
---|
| 915 | if (!$pings->isEmpty()) { |
---|
| 916 | echo '<h3>' . __('Previously sent pings') . '</h3>'; |
---|
| 917 | |
---|
| 918 | echo '<ul class="nice">'; |
---|
| 919 | while ($pings->fetch()) { |
---|
| 920 | echo |
---|
| 921 | '<li>' . dt::dt2str(__('%Y-%m-%d %H:%M'), $pings->ping_dt) . ' - ' . |
---|
| 922 | $pings->ping_url . '</li>'; |
---|
| 923 | } |
---|
| 924 | echo '</ul>'; |
---|
[3707] | 925 | } |
---|
[1783] | 926 | |
---|
[3703] | 927 | echo '</div>'; |
---|
| 928 | } |
---|
[1783] | 929 | |
---|
[3710] | 930 | echo '</div>'; #trackbacks |
---|
| 931 | } |
---|
[1783] | 932 | |
---|
[3710] | 933 | dcPage::helpBlock('core_post', 'core_trackbacks', 'core_wiki'); |
---|
| 934 | dcPage::close(); |
---|