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