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