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