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