[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 | |
---|
| 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( |
---|
[202] | 58 | str_repeat(' ',$categories->level-1).($categories->level-1 == 0 ? '' : '• ').html::escapeHTML($categories->cat_title), |
---|
[0] | 59 | $categories->cat_id |
---|
| 60 | ); |
---|
| 61 | } |
---|
| 62 | } catch (Exception $e) { } |
---|
| 63 | |
---|
| 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 | { |
---|
| 96 | $params['post_id'] = $_REQUEST['id']; |
---|
| 97 | |
---|
| 98 | $post = $core->blog->getPosts($params); |
---|
| 99 | |
---|
| 100 | if ($post->isEmpty()) |
---|
| 101 | { |
---|
| 102 | $core->error->add(__('This entry does not exist.')); |
---|
| 103 | $can_view_page = false; |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | { |
---|
| 107 | $post_id = $post->post_id; |
---|
| 108 | $cat_id = $post->cat_id; |
---|
| 109 | $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); |
---|
| 110 | $post_format = $post->post_format; |
---|
| 111 | $post_password = $post->post_password; |
---|
| 112 | $post_url = $post->post_url; |
---|
| 113 | $post_lang = $post->post_lang; |
---|
| 114 | $post_title = $post->post_title; |
---|
| 115 | $post_excerpt = $post->post_excerpt; |
---|
| 116 | $post_excerpt_xhtml = $post->post_excerpt_xhtml; |
---|
| 117 | $post_content = $post->post_content; |
---|
| 118 | $post_content_xhtml = $post->post_content_xhtml; |
---|
| 119 | $post_notes = $post->post_notes; |
---|
| 120 | $post_status = $post->post_status; |
---|
| 121 | $post_selected = (boolean) $post->post_selected; |
---|
| 122 | $post_open_comment = (boolean) $post->post_open_comment; |
---|
| 123 | $post_open_tb = (boolean) $post->post_open_tb; |
---|
| 124 | |
---|
| 125 | $page_title = __('Edit entry'); |
---|
| 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); |
---|
| 149 | } catch (Exception $e) {} |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | # Format excerpt and content |
---|
| 154 | if (!empty($_POST) && $can_edit_post) |
---|
| 155 | { |
---|
| 156 | $post_format = $_POST['post_format']; |
---|
| 157 | $post_excerpt = $_POST['post_excerpt']; |
---|
| 158 | $post_content = $_POST['post_content']; |
---|
| 159 | |
---|
| 160 | $post_title = $_POST['post_title']; |
---|
| 161 | |
---|
| 162 | $cat_id = (integer) $_POST['cat_id']; |
---|
| 163 | |
---|
| 164 | if (isset($_POST['post_status'])) { |
---|
| 165 | $post_status = (integer) $_POST['post_status']; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | if (empty($_POST['post_dt'])) { |
---|
| 169 | $post_dt = ''; |
---|
| 170 | } else { |
---|
[957] | 171 | try |
---|
| 172 | { |
---|
| 173 | $post_dt = strtotime($_POST['post_dt']); |
---|
| 174 | if ($post_dt == false || $post_dt == -1) { |
---|
| 175 | $bad_dt = true; |
---|
| 176 | throw new Exception(__('Invalid publication date')); |
---|
| 177 | } |
---|
| 178 | $post_dt = date('Y-m-d H:i',$post_dt); |
---|
| 179 | } |
---|
| 180 | catch (Exception $e) |
---|
| 181 | { |
---|
| 182 | $core->error->add($e->getMessage()); |
---|
| 183 | } |
---|
[0] | 184 | } |
---|
| 185 | |
---|
| 186 | $post_open_comment = !empty($_POST['post_open_comment']); |
---|
| 187 | $post_open_tb = !empty($_POST['post_open_tb']); |
---|
| 188 | $post_selected = !empty($_POST['post_selected']); |
---|
| 189 | $post_lang = $_POST['post_lang']; |
---|
| 190 | $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; |
---|
| 191 | |
---|
| 192 | $post_notes = $_POST['post_notes']; |
---|
| 193 | |
---|
| 194 | if (isset($_POST['post_url'])) { |
---|
| 195 | $post_url = $_POST['post_url']; |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | $core->blog->setPostContent( |
---|
| 199 | $post_id,$post_format,$post_lang, |
---|
| 200 | $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml |
---|
| 201 | ); |
---|
| 202 | } |
---|
| 203 | |
---|
[1068] | 204 | # Delete post |
---|
| 205 | if (!empty($_POST['delete']) && $can_delete) |
---|
| 206 | { |
---|
| 207 | try { |
---|
| 208 | # --BEHAVIOR-- adminBeforePostDelete |
---|
| 209 | $core->callBehavior('adminBeforePostDelete',$post_id); |
---|
| 210 | $core->blog->delPost($post_id); |
---|
| 211 | http::redirect('posts.php'); |
---|
| 212 | } catch (Exception $e) { |
---|
| 213 | $core->error->add($e->getMessage()); |
---|
| 214 | } |
---|
| 215 | } |
---|
| 216 | |
---|
[0] | 217 | # Create or update post |
---|
[957] | 218 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) |
---|
[0] | 219 | { |
---|
| 220 | $cur = $core->con->openCursor($core->prefix.'post'); |
---|
| 221 | |
---|
| 222 | $cur->post_title = $post_title; |
---|
| 223 | $cur->cat_id = ($cat_id ? $cat_id : null); |
---|
| 224 | $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; |
---|
| 225 | $cur->post_format = $post_format; |
---|
| 226 | $cur->post_password = $post_password; |
---|
| 227 | $cur->post_lang = $post_lang; |
---|
| 228 | $cur->post_title = $post_title; |
---|
| 229 | $cur->post_excerpt = $post_excerpt; |
---|
| 230 | $cur->post_excerpt_xhtml = $post_excerpt_xhtml; |
---|
| 231 | $cur->post_content = $post_content; |
---|
| 232 | $cur->post_content_xhtml = $post_content_xhtml; |
---|
| 233 | $cur->post_notes = $post_notes; |
---|
| 234 | $cur->post_status = $post_status; |
---|
| 235 | $cur->post_selected = (integer) $post_selected; |
---|
| 236 | $cur->post_open_comment = (integer) $post_open_comment; |
---|
| 237 | $cur->post_open_tb = (integer) $post_open_tb; |
---|
| 238 | |
---|
| 239 | if (isset($_POST['post_url'])) { |
---|
| 240 | $cur->post_url = $post_url; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | # Update post |
---|
| 244 | if ($post_id) |
---|
| 245 | { |
---|
| 246 | try |
---|
| 247 | { |
---|
| 248 | # --BEHAVIOR-- adminBeforePostUpdate |
---|
| 249 | $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); |
---|
| 250 | |
---|
| 251 | $core->blog->updPost($post_id,$cur); |
---|
| 252 | |
---|
| 253 | # --BEHAVIOR-- adminAfterPostUpdate |
---|
| 254 | $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); |
---|
| 255 | |
---|
| 256 | http::redirect('post.php?id='.$post_id.'&upd=1'); |
---|
| 257 | } |
---|
| 258 | catch (Exception $e) |
---|
| 259 | { |
---|
| 260 | $core->error->add($e->getMessage()); |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | else |
---|
| 264 | { |
---|
| 265 | $cur->user_id = $core->auth->userID(); |
---|
| 266 | |
---|
| 267 | try |
---|
| 268 | { |
---|
| 269 | # --BEHAVIOR-- adminBeforePostCreate |
---|
| 270 | $core->callBehavior('adminBeforePostCreate',$cur); |
---|
| 271 | |
---|
| 272 | $return_id = $core->blog->addPost($cur); |
---|
| 273 | |
---|
| 274 | # --BEHAVIOR-- adminAfterPostCreate |
---|
| 275 | $core->callBehavior('adminAfterPostCreate',$cur,$return_id); |
---|
| 276 | |
---|
| 277 | http::redirect('post.php?id='.$return_id.'&crea=1'); |
---|
| 278 | } |
---|
| 279 | catch (Exception $e) |
---|
| 280 | { |
---|
| 281 | $core->error->add($e->getMessage()); |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | /* DISPLAY |
---|
| 287 | -------------------------------------------------------- */ |
---|
| 288 | $default_tab = 'edit-entry'; |
---|
| 289 | if (!$can_edit_post) { |
---|
| 290 | $default_tab = ''; |
---|
| 291 | } |
---|
| 292 | if (!empty($_GET['co'])) { |
---|
| 293 | $default_tab = 'comments'; |
---|
| 294 | } |
---|
| 295 | |
---|
[1358] | 296 | if ($post_id) { |
---|
| 297 | switch ($post_status) { |
---|
| 298 | case 1: |
---|
| 299 | $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png'); |
---|
| 300 | break; |
---|
| 301 | case 0: |
---|
| 302 | $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png'); |
---|
| 303 | break; |
---|
| 304 | case -1: |
---|
| 305 | $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png'); |
---|
| 306 | break; |
---|
| 307 | case -2: |
---|
| 308 | $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png'); |
---|
| 309 | break; |
---|
| 310 | default: |
---|
| 311 | $img_status = ''; |
---|
| 312 | } |
---|
| 313 | $edit_entry_str = __('“%s”'); |
---|
| 314 | $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | |
---|
[195] | 318 | dcPage::open($page_title.' - '.__('Entries'), |
---|
[0] | 319 | dcPage::jsDatePicker(). |
---|
| 320 | dcPage::jsToolBar(). |
---|
| 321 | dcPage::jsModal(). |
---|
| 322 | dcPage::jsMetaEditor(). |
---|
| 323 | dcPage::jsLoad('js/_post.js'). |
---|
| 324 | dcPage::jsConfirmClose('entry-form','comment-form'). |
---|
| 325 | # --BEHAVIOR-- adminPostHeaders |
---|
| 326 | $core->callBehavior('adminPostHeaders'). |
---|
| 327 | dcPage::jsPageTabs($default_tab). |
---|
[1358] | 328 | $next_headlink."\n".$prev_headlink, |
---|
| 329 | dcPage::breadcrumb( |
---|
| 330 | array( |
---|
| 331 | html::escapeHTML($core->blog->name) => '', |
---|
| 332 | __('Entries') => 'posts.php', |
---|
| 333 | '<span class="page-title">'.($post_id ? $page_title_edit : $page_title).'</span>' => '' |
---|
| 334 | )) |
---|
[0] | 335 | ); |
---|
| 336 | |
---|
| 337 | if (!empty($_GET['upd'])) { |
---|
[907] | 338 | dcPage::message(__('Entry has been successfully updated.')); |
---|
[0] | 339 | } |
---|
| 340 | elseif (!empty($_GET['crea'])) { |
---|
[907] | 341 | dcPage::message(__('Entry has been successfully created.')); |
---|
[0] | 342 | } |
---|
| 343 | elseif (!empty($_GET['attached'])) { |
---|
[907] | 344 | dcPage::message(__('File has been successfully attached.')); |
---|
[0] | 345 | } |
---|
| 346 | elseif (!empty($_GET['rmattach'])) { |
---|
[907] | 347 | dcPage::message(__('Attachment has been successfully removed.')); |
---|
[0] | 348 | } |
---|
| 349 | |
---|
| 350 | if (!empty($_GET['creaco'])) { |
---|
[907] | 351 | dcPage::message(__('Comment has been successfully created.')); |
---|
| 352 | } |
---|
[0] | 353 | |
---|
| 354 | # XHTML conversion |
---|
| 355 | if (!empty($_GET['xconv'])) |
---|
| 356 | { |
---|
| 357 | $post_excerpt = $post_excerpt_xhtml; |
---|
| 358 | $post_content = $post_content_xhtml; |
---|
| 359 | $post_format = 'xhtml'; |
---|
| 360 | |
---|
[907] | 361 | dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); |
---|
[0] | 362 | } |
---|
| 363 | |
---|
| 364 | if ($post_id && $post->post_status == 1) { |
---|
[1353] | 365 | 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] | 366 | } |
---|
| 367 | if ($post_id) |
---|
| 368 | { |
---|
[1333] | 369 | echo '<p class="nav_prevnext">'; |
---|
[0] | 370 | if ($prev_link) { echo $prev_link; } |
---|
[1335] | 371 | if ($next_link && $prev_link) { echo ' | '; } |
---|
[0] | 372 | if ($next_link) { echo $next_link; } |
---|
| 373 | |
---|
| 374 | # --BEHAVIOR-- adminPostNavLinks |
---|
| 375 | $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); |
---|
| 376 | |
---|
| 377 | echo '</p>'; |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | # Exit if we cannot view page |
---|
| 381 | if (!$can_view_page) { |
---|
| 382 | dcPage::helpBlock('core_post'); |
---|
| 383 | dcPage::close(); |
---|
| 384 | exit; |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | /* Post form if we can edit post |
---|
| 388 | -------------------------------------------------------- */ |
---|
| 389 | if ($can_edit_post) |
---|
| 390 | { |
---|
[1311] | 391 | echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">'; |
---|
[0] | 392 | echo '<form action="post.php" method="post" id="entry-form">'; |
---|
[458] | 393 | echo '<div id="entry-wrapper">'; |
---|
[536] | 394 | echo '<div id="entry-content"><div class="constrained">'; |
---|
[1365] | 395 | |
---|
| 396 | echo '<h3 class="hidden">'.__('Edit post').'</h3>'; |
---|
[458] | 397 | |
---|
| 398 | echo |
---|
[1353] | 399 | '<p class="col"><label class="required no-margin"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. |
---|
[458] | 400 | form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). |
---|
[1311] | 401 | '</p>'. |
---|
[458] | 402 | |
---|
[1353] | 403 | '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'<span class="form-note">'. |
---|
| 404 | __('Add an introduction to the post.').'</span></label> '. |
---|
[458] | 405 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). |
---|
| 406 | '</p>'. |
---|
| 407 | |
---|
| 408 | '<p class="area"><label class="required" '. |
---|
| 409 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. |
---|
| 410 | form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). |
---|
| 411 | '</p>'. |
---|
| 412 | |
---|
[1353] | 413 | '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').'<span class="form-note">'. |
---|
| 414 | __('Add unpublished notes.').'</span></label>'. |
---|
[458] | 415 | form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). |
---|
| 416 | '</p>'; |
---|
| 417 | |
---|
| 418 | # --BEHAVIOR-- adminPostForm |
---|
| 419 | $core->callBehavior('adminPostForm',isset($post) ? $post : null); |
---|
| 420 | |
---|
| 421 | echo |
---|
[1353] | 422 | '<p class="border-top">'. |
---|
[458] | 423 | ($post_id ? form::hidden('id',$post_id) : ''). |
---|
| 424 | '<input type="submit" value="'.__('Save').' (s)" '. |
---|
[543] | 425 | 'accesskey="s" name="save" /> '; |
---|
[544] | 426 | if ($post_id) { |
---|
[543] | 427 | $preview_url = |
---|
[776] | 428 | $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. |
---|
[543] | 429 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). |
---|
[772] | 430 | '/'.$post->post_url); |
---|
[1139] | 431 | echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> '; |
---|
[1215] | 432 | } else { |
---|
| 433 | echo |
---|
| 434 | '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; |
---|
[543] | 435 | } |
---|
[1215] | 436 | |
---|
[543] | 437 | echo |
---|
[458] | 438 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). |
---|
| 439 | $core->formNonce(). |
---|
| 440 | '</p>'; |
---|
| 441 | |
---|
[536] | 442 | echo '</div></div>'; // End #entry-content |
---|
[458] | 443 | echo '</div>'; // End #entry-wrapper |
---|
| 444 | |
---|
[0] | 445 | echo '<div id="entry-sidebar">'; |
---|
| 446 | |
---|
| 447 | echo |
---|
[1365] | 448 | '<div id="status-box" class="box">'. |
---|
| 449 | '<h4>Statut</h4>'. |
---|
| 450 | |
---|
[70] | 451 | '<p><label for="post_status">'.__('Entry status:'). |
---|
[1365] | 452 | form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish). |
---|
[0] | 453 | '</label></p>'. |
---|
| 454 | |
---|
[70] | 455 | '<p><label for="post_dt">'.__('Published on:'). |
---|
[957] | 456 | form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). |
---|
[0] | 457 | '</label></p>'. |
---|
| 458 | |
---|
[70] | 459 | '<p><label for="post_format">'.__('Text formating:'). |
---|
[1353] | 460 | form::combo('post_format',$formaters_combo,$post_format,'maximal'). |
---|
[197] | 461 | '</label>'. |
---|
| 462 | '</p>'. |
---|
[1365] | 463 | |
---|
[1353] | 464 | '<p>'.($post_id && $post_format != 'xhtml' ? '<a id="convert-xhtml" class="button maximal" href="post.php?id='.$post_id.'&xconv=1">'.__('Convert to XHTML').'</a>' : '').'</p>'. |
---|
[1365] | 465 | |
---|
| 466 | '<p><label for="post_lang">'.__('Entry lang:'). |
---|
| 467 | form::combo('post_lang',$lang_combo,$post_lang). |
---|
| 468 | '</label></p>'. |
---|
[1353] | 469 | |
---|
[1365] | 470 | '</div>'. // End status box |
---|
| 471 | |
---|
| 472 | '<div id="metas-box" class="box">'. |
---|
| 473 | '<h4>Classement</h4>'. |
---|
| 474 | |
---|
| 475 | '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. |
---|
| 476 | __('Selected entry').'</label></p>'. |
---|
| 477 | |
---|
| 478 | '<p><label for="cat_id">'.__('Category:'). |
---|
[1353] | 479 | form::combo('cat_id',$categories_combo,$cat_id,'maximal'). |
---|
| 480 | '</label></p>'. |
---|
[1365] | 481 | |
---|
| 482 | '</div>'. // End metas box |
---|
[0] | 483 | |
---|
[1365] | 484 | '<div id="options-box" class="box">'. |
---|
| 485 | '<h4>Options</h4>'. |
---|
[454] | 486 | '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. |
---|
[0] | 487 | __('Accept comments').'</label></p>'. |
---|
[916] | 488 | ($core->blog->settings->system->allow_comments ? |
---|
| 489 | (isContributionAllowed($post_id,strtotime($post_dt),true) ? |
---|
| 490 | '' : |
---|
| 491 | '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : |
---|
| 492 | '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>'). |
---|
| 493 | |
---|
[454] | 494 | '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. |
---|
[0] | 495 | __('Accept trackbacks').'</label></p>'. |
---|
[916] | 496 | ($core->blog->settings->system->allow_trackbacks ? |
---|
| 497 | (isContributionAllowed($post_id,strtotime($post_dt),false) ? |
---|
| 498 | '' : |
---|
| 499 | '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : |
---|
| 500 | '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'). |
---|
| 501 | |
---|
[1365] | 502 | '<p><label for="post_password">'.__('Password:'). |
---|
[454] | 503 | form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). |
---|
[0] | 504 | '</label></p>'. |
---|
| 505 | |
---|
| 506 | '<div class="lockable">'. |
---|
[1365] | 507 | '<p><label for="post_url">'.__('Edit basename:'). |
---|
[454] | 508 | form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). |
---|
[0] | 509 | '</label></p>'. |
---|
| 510 | '<p class="form-note warn">'. |
---|
| 511 | __('Warning: If you set the URL manually, it may conflict with another entry.'). |
---|
| 512 | '</p>'. |
---|
| 513 | '</div>'; |
---|
| 514 | |
---|
| 515 | # --BEHAVIOR-- adminPostFormSidebar |
---|
| 516 | $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); |
---|
[1365] | 517 | |
---|
| 518 | echo '</div>'; // End options box |
---|
[0] | 519 | |
---|
| 520 | echo '</div>'; // End #entry-sidebar |
---|
[458] | 521 | |
---|
[0] | 522 | echo '</form>'; |
---|
[416] | 523 | |
---|
| 524 | # --BEHAVIOR-- adminPostForm |
---|
| 525 | $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); |
---|
| 526 | |
---|
[0] | 527 | echo '</div>'; |
---|
| 528 | |
---|
| 529 | if ($post_id && $post->post_status == 1) { |
---|
[70] | 530 | echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. |
---|
[0] | 531 | __('Ping blogs').'</a></p>'; |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | |
---|
| 537 | /* Comments and trackbacks |
---|
| 538 | -------------------------------------------------------- */ |
---|
| 539 | if ($post_id) |
---|
| 540 | { |
---|
| 541 | $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); |
---|
| 542 | |
---|
| 543 | $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); |
---|
| 544 | $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); |
---|
| 545 | |
---|
| 546 | # Actions combo box |
---|
| 547 | $combo_action = array(); |
---|
| 548 | if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 549 | { |
---|
[1353] | 550 | $combo_action[__('Publish')] = 'publish'; |
---|
| 551 | $combo_action[__('Unpublish')] = 'unpublish'; |
---|
| 552 | $combo_action[__('Mark as pending')] = 'pending'; |
---|
| 553 | $combo_action[__('Mark as junk')] = 'junk'; |
---|
[0] | 554 | } |
---|
| 555 | |
---|
| 556 | if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 557 | { |
---|
[747] | 558 | $combo_action[__('Delete')] = 'delete'; |
---|
[0] | 559 | } |
---|
| 560 | |
---|
[322] | 561 | # --BEHAVIOR-- adminCommentsActionsCombo |
---|
| 562 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
---|
| 563 | |
---|
[0] | 564 | $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); |
---|
| 565 | |
---|
| 566 | echo |
---|
| 567 | '<div id="comments" class="multi-part" title="'.__('Comments').'">'; |
---|
| 568 | |
---|
| 569 | if ($has_action) { |
---|
| 570 | echo '<form action="comments_actions.php" id="form-comments" method="post">'; |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | echo '<h3>'.__('Trackbacks').'</h3>'; |
---|
| 574 | |
---|
| 575 | if (!$trackbacks->isEmpty()) { |
---|
[70] | 576 | showComments($trackbacks,$has_action,true); |
---|
[0] | 577 | } else { |
---|
| 578 | echo '<p>'.__('No trackback').'</p>'; |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | echo '<h3>'.__('Comments').'</h3>'; |
---|
| 582 | if (!$comments->isEmpty()) { |
---|
| 583 | showComments($comments,$has_action); |
---|
| 584 | } else { |
---|
| 585 | echo '<p>'.__('No comment').'</p>'; |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | if ($has_action) { |
---|
| 589 | echo |
---|
| 590 | '<div class="two-cols">'. |
---|
| 591 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 592 | |
---|
[96] | 593 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[0] | 594 | form::combo('action',$combo_action). |
---|
| 595 | form::hidden('redir','post.php?id='.$post_id.'&co=1'). |
---|
| 596 | $core->formNonce(). |
---|
| 597 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 598 | '</div>'. |
---|
| 599 | '</form>'; |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | echo '</div>'; |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | /* Add a comment |
---|
| 606 | -------------------------------------------------------- */ |
---|
| 607 | if ($post_id) |
---|
| 608 | { |
---|
| 609 | echo |
---|
| 610 | '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. |
---|
| 611 | '<h3>'.__('Add a comment').'</h3>'. |
---|
| 612 | |
---|
| 613 | '<form action="comment.php" method="post" id="comment-form">'. |
---|
[536] | 614 | '<div class="constrained">'. |
---|
[70] | 615 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). |
---|
[0] | 616 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). |
---|
| 617 | '</label></p>'. |
---|
| 618 | |
---|
[70] | 619 | '<p><label for="comment_email">'.__('Email:'). |
---|
[0] | 620 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). |
---|
| 621 | '</label></p>'. |
---|
| 622 | |
---|
[70] | 623 | '<p><label for="comment_site">'.__('Web site:'). |
---|
[0] | 624 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). |
---|
| 625 | '</label></p>'. |
---|
| 626 | |
---|
[70] | 627 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
| 628 | __('Comment:').'</label> '. |
---|
[0] | 629 | form::textarea('comment_content',50,8,html::escapeHTML('')). |
---|
| 630 | '</p>'. |
---|
| 631 | |
---|
| 632 | '<p>'.form::hidden('post_id',$post_id). |
---|
| 633 | $core->formNonce(). |
---|
[217] | 634 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. |
---|
[536] | 635 | '</div>'. |
---|
[0] | 636 | '</form>'. |
---|
| 637 | '</div>'; |
---|
| 638 | } |
---|
| 639 | |
---|
[916] | 640 | # Controls comments or trakbacks capabilities |
---|
| 641 | function isContributionAllowed($id,$dt,$com=true) |
---|
| 642 | { |
---|
| 643 | global $core; |
---|
| 644 | |
---|
| 645 | if (!$id) { |
---|
| 646 | return true; |
---|
| 647 | } |
---|
| 648 | if ($com) { |
---|
| 649 | if (($core->blog->settings->system->comments_ttl == 0) || |
---|
| 650 | (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { |
---|
| 651 | return true; |
---|
| 652 | } |
---|
| 653 | } else { |
---|
| 654 | if (($core->blog->settings->system->trackbacks_ttl == 0) || |
---|
| 655 | (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { |
---|
| 656 | return true; |
---|
| 657 | } |
---|
| 658 | } |
---|
| 659 | return false; |
---|
| 660 | } |
---|
[0] | 661 | |
---|
| 662 | # Show comments or trackbacks |
---|
[70] | 663 | function showComments($rs,$has_action,$tb=false) |
---|
[0] | 664 | { |
---|
| 665 | echo |
---|
| 666 | '<table class="comments-list"><tr>'. |
---|
| 667 | '<th colspan="2">'.__('Author').'</th>'. |
---|
| 668 | '<th>'.__('Date').'</th>'. |
---|
| 669 | '<th class="nowrap">'.__('IP address').'</th>'. |
---|
| 670 | '<th>'.__('Status').'</th>'. |
---|
| 671 | '<th> </th>'. |
---|
| 672 | '</tr>'; |
---|
| 673 | |
---|
| 674 | while($rs->fetch()) |
---|
| 675 | { |
---|
| 676 | $comment_url = 'comment.php?id='.$rs->comment_id; |
---|
| 677 | |
---|
| 678 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 679 | switch ($rs->comment_status) { |
---|
| 680 | case 1: |
---|
| 681 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
| 682 | break; |
---|
| 683 | case 0: |
---|
| 684 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
| 685 | break; |
---|
| 686 | case -1: |
---|
| 687 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
| 688 | break; |
---|
| 689 | case -2: |
---|
| 690 | $img_status = sprintf($img,__('junk'),'junk.png'); |
---|
| 691 | break; |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | echo |
---|
| 695 | '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. |
---|
| 696 | ' id="c'.$rs->comment_id.'">'. |
---|
| 697 | |
---|
| 698 | '<td class="nowrap">'. |
---|
[70] | 699 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. |
---|
[0] | 700 | '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. |
---|
| 701 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. |
---|
| 702 | '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. |
---|
| 703 | '<td class="nowrap status">'.$img_status.'</td>'. |
---|
| 704 | '<td class="nowrap status"><a href="'.$comment_url.'">'. |
---|
| 705 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. |
---|
| 706 | |
---|
| 707 | '</tr>'; |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | echo '</table>'; |
---|
| 711 | } |
---|
| 712 | |
---|
| 713 | dcPage::helpBlock('core_post','core_wiki'); |
---|
| 714 | dcPage::close(); |
---|
[1329] | 715 | ?> |
---|