Changeset 1413:0581a433675d for admin/post.php
- Timestamp:
- 08/12/13 13:34:09 (12 years ago)
- Branch:
- twig
- Parents:
- 1319:32528cac0405 (diff), 1333:5e1388edd0c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/post.php
r1333 r1413 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 15 15 dcPage::check('usage,contentadmin'); 16 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; 17 function savePost($form) { 18 global $_ctx; 19 $_ctx->setAlert('save'); 20 21 } 22 23 function deletePost($form) { 24 print_r($form); exit; 25 } 34 26 35 27 $page_title = __('New entry'); … … 47 39 # If user can't publish 48 40 if (!$can_publish) { 49 $ post_status = -2;41 $form->post_status = -2; 50 42 } 51 43 … … 55 47 $categories = $core->blog->getCategories(array('post_type'=>'post')); 56 48 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_id60 );49 $categories_combo[$categories->cat_id] = 50 str_repeat(' ',$categories->level-1). 51 ($categories->level-1 == 0 ? '' : '• '). 52 html::escapeHTML($categories->cat_title); 61 53 } 62 54 } catch (Exception $e) { } … … 64 56 # Status combo 65 57 foreach ($core->blog->getAllPostStatus() as $k => $v) { 66 $status_combo[$v] = (string) $k; 67 } 68 $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 58 $status_combo[$k] = $v; 59 } 69 60 70 61 # Formaters combo … … 88 79 unset($rs); 89 80 90 # Validation flag 91 $bad_dt = false; 92 81 $form = new dcForm($core,'post','post.php'); 82 $form 83 ->addField( 84 new dcFieldText('post_title','', array( 85 'size' => 20, 86 'required' => true, 87 'label' => __('Title')))) 88 ->addField( 89 new dcFieldTextArea('post_excerpt','', array( 90 'cols' => 50, 91 'rows' => 5, 92 'label' => __("Excerpt:")))) 93 ->addField( 94 new dcFieldTextArea('post_content','', array( 95 'required' => true, 96 'label' => __("Content:")))) 97 ->addField( 98 new dcFieldTextArea('post_notes','', array( 99 'label' => __("Notes")))) 100 ->addField( 101 new dcFieldSubmit('save',__('Save'),array( 102 'action' => 'savePost'))) 103 ->addField( 104 new dcFieldSubmit('delete',__('Delete'),array( 105 'action' => 'deletePost'))) 106 ->addField( 107 new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( 108 'disabled' => !$can_publish, 109 'label' => __('Entry status:')))) 110 ->addField( 111 new dcFieldCombo('cat_id','',$categories_combo,array( 112 "label" => __('Category:')))) 113 ->addField( 114 new dcFieldText('post_dt','',array( 115 "label" => __('Published on:')))) 116 ->addField( 117 new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( 118 "label" => __('Text formating:')))) 119 ->addField( 120 new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( 121 "label" => __('Accept comments')))) 122 ->addField( 123 new dcFieldCheckbox ('post_open_tb',$core->blog->settings->system->allow_trackbacks,array( 124 "label" => __('Accept trackbacks')))) 125 ->addField( 126 new dcFieldCheckbox ('post_selected',false,array( 127 "label" => __('Selected entry')))) 128 ->addField( 129 new dcFieldCombo ('post_lang',$core->auth->getInfo('user_lang'),$lang_combo, array( 130 "label" => __('Entry lang:')))) 131 ->addField( 132 new dcFieldText('post_password','',array( 133 "maxlength" => 32, 134 "label" => __('Entry password:')))) 135 ->addField( 136 new dcFieldText('post_url','',array( 137 "maxlength" => 255, 138 "label" => __('Basename:')))) 139 ->addField( 140 new dcFieldHidden ('id','')) 141 ; 93 142 # Get entry informations 94 143 if (!empty($_REQUEST['id'])) … … 105 154 else 106 155 { 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; 156 $form->id = $post_id = $post->post_id; 157 $form->cat_id = $post->cat_id; 158 $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 159 $form->post_format = $post->post_format; 160 $form->post_password = $post->post_password; 161 $form->post_url = $post->post_url; 162 $form->post_lang = $post->post_lang; 163 $form->post_title = $post->post_title; 164 $form->post_excerpt = $post->post_excerpt; 165 $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; 166 $form->post_content = $post->post_content; 167 $form->post_content_xhtml = $post->post_content_xhtml; 168 $form->post_notes = $post->post_notes; 169 $form->post_status = $post->post_status; 170 $form->post_selected = (boolean) $post->post_selected; 171 $form->post_open_comment = (boolean) $post->post_open_comment; 172 $form->post_open_tb = (boolean) $post->post_open_tb; 173 $form->can_edit_post = $post->isEditable(); 174 $form->can_delete= $post->isDeletable(); 175 $page_title = __('Edit entry'); 176 177 } 178 } 179 if ($post_id) { 180 $_ctx->post_id = $post->post_id; 181 182 $_ctx->preview_url = 183 $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 184 http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 185 '/'.$post->post_url); 124 186 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, 135 html::escapeHTML($next_rs->post_title),__('next entry').' »'); 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, 142 html::escapeHTML($prev_rs->post_title),'« '.__('previous entry')); 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 { 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 } 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 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 217 # Create or update post 218 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 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 } 187 188 $form_comment = new dcForm($core,'add-comment','post.php'); 189 $form_comment 190 ->addField( 191 new dcFieldText('comment_author','', array( 192 'maxlength' => 255, 193 'required' => true, 194 'label' => __('Name:')))) 195 ->addField( 196 new dcFieldText('comment_email','', array( 197 'maxlength' => 255, 198 'required' => true, 199 'label' => __('Email:')))) 200 ->addField( 201 new dcFieldText('comment_site','', array( 202 'maxlength' => 255, 203 'label' => __('Web site:')))) 204 ->addField( 205 new dcFieldTextArea('comment_content','', array( 206 'required' => true, 207 'label' => __('Comment:')))) 208 ->addField( 209 new dcFieldSubmit('add',__('Save'),array( 210 'action' => 'addComment'))) 211 ; 212 213 214 } 215 216 $form->setup(); 285 217 286 218 /* DISPLAY … … 294 226 } 295 227 296 dcPage::open($page_title.' - '.__('Entries'), 297 dcPage::jsDatePicker(). 298 dcPage::jsToolBar(). 299 dcPage::jsModal(). 300 dcPage::jsMetaEditor(). 301 dcPage::jsLoad('js/_post.js'). 302 dcPage::jsConfirmClose('entry-form','comment-form'). 303 # --BEHAVIOR-- adminPostHeaders 304 $core->callBehavior('adminPostHeaders'). 305 dcPage::jsPageTabs($default_tab). 306 $next_headlink."\n".$prev_headlink 307 ); 308 309 if (!empty($_GET['upd'])) { 310 dcPage::message(__('Entry has been successfully updated.')); 311 } 312 elseif (!empty($_GET['crea'])) { 313 dcPage::message(__('Entry has been successfully created.')); 314 } 315 elseif (!empty($_GET['attached'])) { 316 dcPage::message(__('File has been successfully attached.')); 317 } 318 elseif (!empty($_GET['rmattach'])) { 319 dcPage::message(__('Attachment has been successfully removed.')); 320 } 321 322 if (!empty($_GET['creaco'])) { 323 dcPage::message(__('Comment has been successfully created.')); 324 } 325 326 # XHTML conversion 327 if (!empty($_GET['xconv'])) 328 { 329 $post_excerpt = $post_excerpt_xhtml; 330 $post_content = $post_content_xhtml; 331 $post_format = 'xhtml'; 332 333 dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 334 } 335 336 if ($post_id) { 337 switch ($post_status) { 338 case 1: 339 $img_status = sprintf($img_status_pattern,__('published'),'check-on.png'); 340 break; 341 case 0: 342 $img_status = sprintf($img_status_pattern,__('unpublished'),'check-off.png'); 343 break; 344 case -1: 345 $img_status = sprintf($img_status_pattern,__('scheduled'),'scheduled.png'); 346 break; 347 case -2: 348 $img_status = sprintf($img_status_pattern,__('pending'),'check-wrn.png'); 349 break; 350 default: 351 $img_status = ''; 352 } 353 $edit_entry_str = __('Edit entry “%s”'); 354 $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; 355 } 356 echo dcPage::breadcrumb( 357 array( 358 html::escapeHTML($core->blog->name) => '', 359 __('Entries') => 'posts.php', 360 '<span class="page-title">'.($post_id ? $page_title_edit : $page_title).'</span>' => '' 361 )); 362 363 if ($post_id && $post->post_status == 1) { 364 echo '<p class="preview_entry"><a 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>'; 365 } 366 if ($post_id) 367 { 368 echo '<p class="nav_prevnext">'; 369 if ($prev_link) { echo $prev_link; } 370 if ($next_link && $prev_link) { echo ' - '; } 371 if ($next_link) { echo $next_link; } 372 373 # --BEHAVIOR-- adminPostNavLinks 374 $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); 375 376 echo '</p>'; 377 } 378 379 # Exit if we cannot view page 380 if (!$can_view_page) { 381 dcPage::helpBlock('core_post'); 382 dcPage::close(); 383 exit; 384 } 385 386 /* Post form if we can edit post 387 -------------------------------------------------------- */ 388 if ($can_edit_post) 389 { 390 echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">'; 391 echo '<form action="post.php" method="post" id="entry-form">'; 392 echo '<div id="entry-wrapper">'; 393 echo '<div id="entry-content"><div class="constrained">'; 394 395 echo 396 '<p class="col"><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 397 form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). 398 '</p>'. 399 400 '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '. 401 form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 402 '</p>'. 403 404 '<p class="area"><label class="required" '. 405 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 406 form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). 407 '</p>'. 408 409 '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').'</label>'. 410 form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 411 '</p>'; 412 413 # --BEHAVIOR-- adminPostForm 414 $core->callBehavior('adminPostForm',isset($post) ? $post : null); 415 416 echo 417 '<p>'. 418 ($post_id ? form::hidden('id',$post_id) : ''). 419 '<input type="submit" value="'.__('Save').' (s)" '. 420 'accesskey="s" name="save" /> '; 421 if ($post_id) { 422 $preview_url = 423 $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 424 http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 425 '/'.$post->post_url); 426 echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> '; 427 } else { 428 echo 429 '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; 430 } 431 432 echo 433 ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 434 $core->formNonce(). 435 '</p>'; 436 437 echo '</div></div>'; // End #entry-content 438 echo '</div>'; // End #entry-wrapper 439 440 echo '<div id="entry-sidebar">'; 441 442 echo 443 '<p><label for="cat_id">'.__('Category:'). 444 form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 445 '</label></p>'. 446 447 '<p><label for="post_status">'.__('Entry status:'). 448 form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). 449 '</label></p>'. 450 451 '<p><label for="post_dt">'.__('Published on:'). 452 form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 453 '</label></p>'. 454 455 '<p><label for="post_format">'.__('Text formating:'). 456 form::combo('post_format',$formaters_combo,$post_format). 457 '</label>'. 458 '</p>'. 459 '<p>'.($post_id && $post_format != 'xhtml' ? '<a id="convert-xhtml" class="button" href="post.php?id='.$post_id.'&xconv=1">'.__('Convert to XHTML').'</a>' : '').'</p>'. 460 461 '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. 462 __('Accept comments').'</label></p>'. 463 ($core->blog->settings->system->allow_comments ? 464 (isContributionAllowed($post_id,strtotime($post_dt),true) ? 465 '' : 466 '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : 467 '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>'). 468 469 '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. 470 __('Accept trackbacks').'</label></p>'. 471 ($core->blog->settings->system->allow_trackbacks ? 472 (isContributionAllowed($post_id,strtotime($post_dt),false) ? 473 '' : 474 '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 475 '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'). 476 477 '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. 478 __('Selected entry').'</label></p>'. 479 480 '<p><label for="post_lang">'.__('Entry lang:'). 481 form::combo('post_lang',$lang_combo,$post_lang). 482 '</label></p>'. 483 484 '<p><label for="post_password">'.__('Entry password:'). 485 form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 486 '</label></p>'. 487 488 '<div class="lockable">'. 489 '<p><label for="post_url">'.__('Basename:'). 490 form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 491 '</label></p>'. 492 '<p class="form-note warn">'. 493 __('Warning: If you set the URL manually, it may conflict with another entry.'). 494 '</p>'. 495 '</div>'; 496 497 # --BEHAVIOR-- adminPostFormSidebar 498 $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 499 500 echo '</div>'; // End #entry-sidebar 501 502 echo '</form>'; 503 504 # --BEHAVIOR-- adminPostForm 505 $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); 506 507 echo '</div>'; 508 509 if ($post_id && $post->post_status == 1) { 510 echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. 511 __('Ping blogs').'</a></p>'; 512 } 513 514 } 515 516 517 /* Comments and trackbacks 518 -------------------------------------------------------- */ 519 if ($post_id) 520 { 521 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 522 523 $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 524 $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); 525 526 # Actions combo box 527 $combo_action = array(); 528 if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) 529 { 530 $combo_action[__('publish')] = 'publish'; 531 $combo_action[__('unpublish')] = 'unpublish'; 532 $combo_action[__('mark as pending')] = 'pending'; 533 $combo_action[__('mark as junk')] = 'junk'; 534 } 535 536 if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) 537 { 538 $combo_action[__('Delete')] = 'delete'; 539 } 540 541 # --BEHAVIOR-- adminCommentsActionsCombo 542 $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); 543 544 $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); 545 546 echo 547 '<div id="comments" class="multi-part" title="'.__('Comments').'">'; 548 549 if ($has_action) { 550 echo '<form action="comments_actions.php" id="form-comments" method="post">'; 551 } 552 553 echo '<h3>'.__('Trackbacks').'</h3>'; 554 555 if (!$trackbacks->isEmpty()) { 556 showComments($trackbacks,$has_action,true); 557 } else { 558 echo '<p>'.__('No trackback').'</p>'; 559 } 560 561 echo '<h3>'.__('Comments').'</h3>'; 562 if (!$comments->isEmpty()) { 563 showComments($comments,$has_action); 564 } else { 565 echo '<p>'.__('No comment').'</p>'; 566 } 567 568 if ($has_action) { 569 echo 570 '<div class="two-cols">'. 571 '<p class="col checkboxes-helpers"></p>'. 572 573 '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 574 form::combo('action',$combo_action). 575 form::hidden('redir','post.php?id='.$post_id.'&co=1'). 576 $core->formNonce(). 577 '<input type="submit" value="'.__('ok').'" /></p>'. 578 '</div>'. 579 '</form>'; 580 } 581 582 echo '</div>'; 583 } 584 585 /* Add a comment 586 -------------------------------------------------------- */ 587 if ($post_id) 588 { 589 echo 590 '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. 591 '<h3>'.__('Add a comment').'</h3>'. 592 593 '<form action="comment.php" method="post" id="comment-form">'. 594 '<div class="constrained">'. 595 '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). 596 form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). 597 '</label></p>'. 598 599 '<p><label for="comment_email">'.__('Email:'). 600 form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 601 '</label></p>'. 602 603 '<p><label for="comment_site">'.__('Web site:'). 604 form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 605 '</label></p>'. 606 607 '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 608 __('Comment:').'</label> '. 609 form::textarea('comment_content',50,8,html::escapeHTML('')). 610 '</p>'. 611 612 '<p>'.form::hidden('post_id',$post_id). 613 $core->formNonce(). 614 '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 615 '</div>'. 616 '</form>'. 617 '</div>'; 618 } 619 620 # Controls comments or trakbacks capabilities 621 function isContributionAllowed($id,$dt,$com=true) 622 { 623 global $core; 624 625 if (!$id) { 626 return true; 627 } 628 if ($com) { 629 if (($core->blog->settings->system->comments_ttl == 0) || 630 (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 631 return true; 632 } 633 } else { 634 if (($core->blog->settings->system->trackbacks_ttl == 0) || 635 (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 636 return true; 637 } 638 } 639 return false; 640 } 641 642 # Show comments or trackbacks 643 function showComments($rs,$has_action,$tb=false) 644 { 645 echo 646 '<table class="comments-list"><tr>'. 647 '<th colspan="2">'.__('Author').'</th>'. 648 '<th>'.__('Date').'</th>'. 649 '<th class="nowrap">'.__('IP address').'</th>'. 650 '<th>'.__('Status').'</th>'. 651 '<th> </th>'. 652 '</tr>'; 653 654 while($rs->fetch()) 655 { 656 $comment_url = 'comment.php?id='.$rs->comment_id; 657 658 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 659 switch ($rs->comment_status) { 660 case 1: 661 $img_status = sprintf($img,__('published'),'check-on.png'); 662 break; 663 case 0: 664 $img_status = sprintf($img,__('unpublished'),'check-off.png'); 665 break; 666 case -1: 667 $img_status = sprintf($img,__('pending'),'check-wrn.png'); 668 break; 669 case -2: 670 $img_status = sprintf($img,__('junk'),'junk.png'); 671 break; 672 } 673 674 echo 675 '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 676 ' id="c'.$rs->comment_id.'">'. 677 678 '<td class="nowrap">'. 679 ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 680 '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 681 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 682 '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. 683 '<td class="nowrap status">'.$img_status.'</td>'. 684 '<td class="nowrap status"><a href="'.$comment_url.'">'. 685 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. 686 687 '</tr>'; 688 } 689 690 echo '</table>'; 691 } 692 693 dcPage::helpBlock('core_post','core_wiki'); 694 dcPage::close(); 228 $_ctx 229 ->fillPageTitle(html::escapeHTML($core->blog->name)) 230 ->fillPageTitle(__('Entries'),'posts.php') 231 ->fillPageTitle($page_title) 232 ->default_tab = $default_tab; 233 234 $core->tpl->display('post.html.twig'); 695 235 ?>
Note: See TracChangeset
for help on using the changeset viewer.