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