[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 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 | } |
---|
| 68 | |
---|
| 69 | # Formaters combo |
---|
| 70 | foreach ($core->getFormaters() as $v) { |
---|
| 71 | $formaters_combo[$v] = $v; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | # Languages combo |
---|
| 75 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
| 76 | $all_langs = l10n::getISOcodes(0,1); |
---|
| 77 | $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); |
---|
| 78 | while ($rs->fetch()) { |
---|
| 79 | if (isset($all_langs[$rs->post_lang])) { |
---|
| 80 | $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; |
---|
| 81 | unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); |
---|
| 82 | } else { |
---|
| 83 | $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | unset($all_langs); |
---|
| 87 | unset($rs); |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | # Get entry informations |
---|
| 91 | if (!empty($_REQUEST['id'])) |
---|
| 92 | { |
---|
| 93 | $params['post_id'] = $_REQUEST['id']; |
---|
| 94 | |
---|
| 95 | $post = $core->blog->getPosts($params); |
---|
| 96 | |
---|
| 97 | if ($post->isEmpty()) |
---|
| 98 | { |
---|
| 99 | $core->error->add(__('This entry does not exist.')); |
---|
| 100 | $can_view_page = false; |
---|
| 101 | } |
---|
| 102 | else |
---|
| 103 | { |
---|
| 104 | $post_id = $post->post_id; |
---|
| 105 | $cat_id = $post->cat_id; |
---|
| 106 | $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); |
---|
| 107 | $post_format = $post->post_format; |
---|
| 108 | $post_password = $post->post_password; |
---|
| 109 | $post_url = $post->post_url; |
---|
| 110 | $post_lang = $post->post_lang; |
---|
| 111 | $post_title = $post->post_title; |
---|
| 112 | $post_excerpt = $post->post_excerpt; |
---|
| 113 | $post_excerpt_xhtml = $post->post_excerpt_xhtml; |
---|
| 114 | $post_content = $post->post_content; |
---|
| 115 | $post_content_xhtml = $post->post_content_xhtml; |
---|
| 116 | $post_notes = $post->post_notes; |
---|
| 117 | $post_status = $post->post_status; |
---|
| 118 | $post_selected = (boolean) $post->post_selected; |
---|
| 119 | $post_open_comment = (boolean) $post->post_open_comment; |
---|
| 120 | $post_open_tb = (boolean) $post->post_open_tb; |
---|
| 121 | |
---|
| 122 | $page_title = __('Edit entry'); |
---|
| 123 | |
---|
| 124 | $can_edit_post = $post->isEditable(); |
---|
| 125 | $can_delete= $post->isDeletable(); |
---|
| 126 | |
---|
| 127 | $next_rs = $core->blog->getNextPost($post,1); |
---|
| 128 | $prev_rs = $core->blog->getNextPost($post,-1); |
---|
| 129 | |
---|
| 130 | if ($next_rs !== null) { |
---|
| 131 | $next_link = sprintf($post_link,$next_rs->post_id, |
---|
| 132 | html::escapeHTML($next_rs->post_title),__('next entry').' »'); |
---|
| 133 | $next_headlink = sprintf($post_headlink,'next', |
---|
| 134 | html::escapeHTML($next_rs->post_title),$next_rs->post_id); |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | if ($prev_rs !== null) { |
---|
| 138 | $prev_link = sprintf($post_link,$prev_rs->post_id, |
---|
| 139 | html::escapeHTML($prev_rs->post_title),'« '.__('previous entry')); |
---|
| 140 | $prev_headlink = sprintf($post_headlink,'previous', |
---|
| 141 | html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | try { |
---|
| 145 | $core->media = new dcMedia($core); |
---|
| 146 | } catch (Exception $e) {} |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | # Format excerpt and content |
---|
| 151 | if (!empty($_POST) && $can_edit_post) |
---|
| 152 | { |
---|
| 153 | $post_format = $_POST['post_format']; |
---|
| 154 | $post_excerpt = $_POST['post_excerpt']; |
---|
| 155 | $post_content = $_POST['post_content']; |
---|
| 156 | |
---|
| 157 | $post_title = $_POST['post_title']; |
---|
| 158 | |
---|
| 159 | $cat_id = (integer) $_POST['cat_id']; |
---|
| 160 | |
---|
| 161 | if (isset($_POST['post_status'])) { |
---|
| 162 | $post_status = (integer) $_POST['post_status']; |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | if (empty($_POST['post_dt'])) { |
---|
| 166 | $post_dt = ''; |
---|
| 167 | } else { |
---|
| 168 | $post_dt = strtotime($_POST['post_dt']); |
---|
| 169 | $post_dt = date('Y-m-d H:i',$post_dt); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | $post_open_comment = !empty($_POST['post_open_comment']); |
---|
| 173 | $post_open_tb = !empty($_POST['post_open_tb']); |
---|
| 174 | $post_selected = !empty($_POST['post_selected']); |
---|
| 175 | $post_lang = $_POST['post_lang']; |
---|
| 176 | $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; |
---|
| 177 | |
---|
| 178 | $post_notes = $_POST['post_notes']; |
---|
| 179 | |
---|
| 180 | if (isset($_POST['post_url'])) { |
---|
| 181 | $post_url = $_POST['post_url']; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | $core->blog->setPostContent( |
---|
| 185 | $post_id,$post_format,$post_lang, |
---|
| 186 | $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml |
---|
| 187 | ); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | # Create or update post |
---|
| 191 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post) |
---|
| 192 | { |
---|
| 193 | $cur = $core->con->openCursor($core->prefix.'post'); |
---|
| 194 | |
---|
| 195 | $cur->post_title = $post_title; |
---|
| 196 | $cur->cat_id = ($cat_id ? $cat_id : null); |
---|
| 197 | $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; |
---|
| 198 | $cur->post_format = $post_format; |
---|
| 199 | $cur->post_password = $post_password; |
---|
| 200 | $cur->post_lang = $post_lang; |
---|
| 201 | $cur->post_title = $post_title; |
---|
| 202 | $cur->post_excerpt = $post_excerpt; |
---|
| 203 | $cur->post_excerpt_xhtml = $post_excerpt_xhtml; |
---|
| 204 | $cur->post_content = $post_content; |
---|
| 205 | $cur->post_content_xhtml = $post_content_xhtml; |
---|
| 206 | $cur->post_notes = $post_notes; |
---|
| 207 | $cur->post_status = $post_status; |
---|
| 208 | $cur->post_selected = (integer) $post_selected; |
---|
| 209 | $cur->post_open_comment = (integer) $post_open_comment; |
---|
| 210 | $cur->post_open_tb = (integer) $post_open_tb; |
---|
| 211 | |
---|
| 212 | if (isset($_POST['post_url'])) { |
---|
| 213 | $cur->post_url = $post_url; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | # Update post |
---|
| 217 | if ($post_id) |
---|
| 218 | { |
---|
| 219 | try |
---|
| 220 | { |
---|
| 221 | # --BEHAVIOR-- adminBeforePostUpdate |
---|
| 222 | $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); |
---|
| 223 | |
---|
| 224 | $core->blog->updPost($post_id,$cur); |
---|
| 225 | |
---|
| 226 | # --BEHAVIOR-- adminAfterPostUpdate |
---|
| 227 | $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); |
---|
| 228 | |
---|
| 229 | http::redirect('post.php?id='.$post_id.'&upd=1'); |
---|
| 230 | } |
---|
| 231 | catch (Exception $e) |
---|
| 232 | { |
---|
| 233 | $core->error->add($e->getMessage()); |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | else |
---|
| 237 | { |
---|
| 238 | $cur->user_id = $core->auth->userID(); |
---|
| 239 | |
---|
| 240 | try |
---|
| 241 | { |
---|
| 242 | # --BEHAVIOR-- adminBeforePostCreate |
---|
| 243 | $core->callBehavior('adminBeforePostCreate',$cur); |
---|
| 244 | |
---|
| 245 | $return_id = $core->blog->addPost($cur); |
---|
| 246 | |
---|
| 247 | # --BEHAVIOR-- adminAfterPostCreate |
---|
| 248 | $core->callBehavior('adminAfterPostCreate',$cur,$return_id); |
---|
| 249 | |
---|
| 250 | http::redirect('post.php?id='.$return_id.'&crea=1'); |
---|
| 251 | } |
---|
| 252 | catch (Exception $e) |
---|
| 253 | { |
---|
| 254 | $core->error->add($e->getMessage()); |
---|
| 255 | } |
---|
| 256 | } |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | if (!empty($_POST['delete']) && $can_delete) |
---|
| 260 | { |
---|
| 261 | try { |
---|
| 262 | # --BEHAVIOR-- adminBeforePostDelete |
---|
| 263 | $core->callBehavior('adminBeforePostDelete',$post_id); |
---|
| 264 | $core->blog->delPost($post_id); |
---|
| 265 | http::redirect('posts.php'); |
---|
| 266 | } catch (Exception $e) { |
---|
| 267 | $core->error->add($e->getMessage()); |
---|
| 268 | } |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | /* DISPLAY |
---|
| 272 | -------------------------------------------------------- */ |
---|
| 273 | $default_tab = 'edit-entry'; |
---|
| 274 | if (!$can_edit_post) { |
---|
| 275 | $default_tab = ''; |
---|
| 276 | } |
---|
| 277 | if (!empty($_GET['co'])) { |
---|
| 278 | $default_tab = 'comments'; |
---|
| 279 | } |
---|
| 280 | |
---|
[195] | 281 | dcPage::open($page_title.' - '.__('Entries'), |
---|
[0] | 282 | dcPage::jsDatePicker(). |
---|
| 283 | dcPage::jsToolBar(). |
---|
| 284 | dcPage::jsModal(). |
---|
| 285 | dcPage::jsMetaEditor(). |
---|
| 286 | dcPage::jsLoad('js/_post.js'). |
---|
| 287 | dcPage::jsConfirmClose('entry-form','comment-form'). |
---|
| 288 | # --BEHAVIOR-- adminPostHeaders |
---|
| 289 | $core->callBehavior('adminPostHeaders'). |
---|
| 290 | dcPage::jsPageTabs($default_tab). |
---|
| 291 | $next_headlink."\n".$prev_headlink |
---|
| 292 | ); |
---|
| 293 | |
---|
| 294 | if (!empty($_GET['upd'])) { |
---|
| 295 | echo '<p class="message">'.__('Entry has been successfully updated.').'</p>'; |
---|
| 296 | } |
---|
| 297 | elseif (!empty($_GET['crea'])) { |
---|
| 298 | echo '<p class="message">'.__('Entry has been successfully created.').'</p>'; |
---|
| 299 | } |
---|
| 300 | elseif (!empty($_GET['attached'])) { |
---|
| 301 | echo '<p class="message">'.__('File has been successfully attached.').'</p>'; |
---|
| 302 | } |
---|
| 303 | elseif (!empty($_GET['rmattach'])) { |
---|
| 304 | echo '<p class="message">'.__('Attachment has been successfully removed.').'</p>'; |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | if (!empty($_GET['creaco'])) { |
---|
| 308 | echo '<p class="message">'.__('Comment has been successfully created.').'</p>'; |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | # XHTML conversion |
---|
| 312 | if (!empty($_GET['xconv'])) |
---|
| 313 | { |
---|
| 314 | $post_excerpt = $post_excerpt_xhtml; |
---|
| 315 | $post_content = $post_content_xhtml; |
---|
[537] | 316 | $post_title = $post_title_xhtml; |
---|
[0] | 317 | $post_format = 'xhtml'; |
---|
| 318 | |
---|
| 319 | echo '<p class="message">'.__('Don\'t forget to validate your XHTML conversion by saving your post.').'</p>'; |
---|
| 320 | } |
---|
| 321 | |
---|
[559] | 322 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.'<a href="posts.php">'.__('Entries').'</a> › <span class="page-title">'.$page_title; |
---|
| 323 | |
---|
| 324 | if ($post_id) { |
---|
| 325 | echo ' “'.$post_title.'”'; |
---|
| 326 | } |
---|
| 327 | echo '</span></h2>'; |
---|
[0] | 328 | |
---|
| 329 | if ($post_id && $post->post_status == 1) { |
---|
[543] | 330 | echo '<p><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>'; |
---|
[0] | 331 | } |
---|
| 332 | if ($post_id) |
---|
| 333 | { |
---|
| 334 | echo '<p>'; |
---|
| 335 | if ($prev_link) { echo $prev_link; } |
---|
| 336 | if ($next_link && $prev_link) { echo ' - '; } |
---|
| 337 | if ($next_link) { echo $next_link; } |
---|
| 338 | |
---|
| 339 | # --BEHAVIOR-- adminPostNavLinks |
---|
| 340 | $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); |
---|
| 341 | |
---|
| 342 | echo '</p>'; |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | # Exit if we cannot view page |
---|
| 346 | if (!$can_view_page) { |
---|
| 347 | dcPage::helpBlock('core_post'); |
---|
| 348 | dcPage::close(); |
---|
| 349 | exit; |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | /* Post form if we can edit post |
---|
| 353 | -------------------------------------------------------- */ |
---|
| 354 | if ($can_edit_post) |
---|
| 355 | { |
---|
| 356 | echo '<div class="multi-part" title="'.__('Edit entry').'" id="edit-entry">'; |
---|
| 357 | echo '<form action="post.php" method="post" id="entry-form">'; |
---|
[458] | 358 | echo '<div id="entry-wrapper">'; |
---|
[536] | 359 | echo '<div id="entry-content"><div class="constrained">'; |
---|
[458] | 360 | |
---|
| 361 | echo |
---|
| 362 | '<p class="col"><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). |
---|
| 363 | form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). |
---|
| 364 | '</label></p>'. |
---|
| 365 | |
---|
| 366 | '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '. |
---|
| 367 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). |
---|
| 368 | '</p>'. |
---|
| 369 | |
---|
| 370 | '<p class="area"><label class="required" '. |
---|
| 371 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. |
---|
| 372 | form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). |
---|
| 373 | '</p>'. |
---|
| 374 | |
---|
| 375 | '<p class="area" id="notes-area"><label for="post_notes">'.__('Notes:').'</label>'. |
---|
| 376 | form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). |
---|
| 377 | '</p>'; |
---|
| 378 | |
---|
| 379 | # --BEHAVIOR-- adminPostForm |
---|
| 380 | $core->callBehavior('adminPostForm',isset($post) ? $post : null); |
---|
| 381 | |
---|
| 382 | echo |
---|
| 383 | '<p>'. |
---|
| 384 | ($post_id ? form::hidden('id',$post_id) : ''). |
---|
| 385 | '<input type="submit" value="'.__('Save').' (s)" '. |
---|
[543] | 386 | 'accesskey="s" name="save" /> '; |
---|
[544] | 387 | if ($post_id) { |
---|
[543] | 388 | $preview_url = |
---|
[772] | 389 | $core->url->getURLFor('preview',$core->auth->userID().'/'. |
---|
[543] | 390 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). |
---|
[772] | 391 | '/'.$post->post_url); |
---|
[543] | 392 | echo '<a id="post-preview" href="'.$preview_url.'" class="button">'.__('Preview').'</a> '; |
---|
| 393 | } |
---|
| 394 | echo |
---|
[458] | 395 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). |
---|
| 396 | $core->formNonce(). |
---|
| 397 | '</p>'; |
---|
| 398 | |
---|
[536] | 399 | echo '</div></div>'; // End #entry-content |
---|
[458] | 400 | echo '</div>'; // End #entry-wrapper |
---|
| 401 | |
---|
[0] | 402 | echo '<div id="entry-sidebar">'; |
---|
| 403 | |
---|
| 404 | echo |
---|
[70] | 405 | '<p><label for="cat_id">'.__('Category:'). |
---|
[454] | 406 | form::combo('cat_id',$categories_combo,$cat_id,'maximal'). |
---|
[0] | 407 | '</label></p>'. |
---|
| 408 | |
---|
[70] | 409 | '<p><label for="post_status">'.__('Entry status:'). |
---|
[454] | 410 | form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). |
---|
[0] | 411 | '</label></p>'. |
---|
| 412 | |
---|
[70] | 413 | '<p><label for="post_dt">'.__('Published on:'). |
---|
[454] | 414 | form::field('post_dt',16,16,$post_dt). |
---|
[0] | 415 | '</label></p>'. |
---|
| 416 | |
---|
[70] | 417 | '<p><label for="post_format">'.__('Text formating:'). |
---|
[454] | 418 | form::combo('post_format',$formaters_combo,$post_format). |
---|
[197] | 419 | '</label>'. |
---|
| 420 | '</p>'. |
---|
| 421 | '<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>'. |
---|
[0] | 422 | |
---|
[454] | 423 | '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. |
---|
[0] | 424 | __('Accept comments').'</label></p>'. |
---|
[454] | 425 | '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. |
---|
[0] | 426 | __('Accept trackbacks').'</label></p>'. |
---|
[454] | 427 | '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. |
---|
[0] | 428 | __('Selected entry').'</label></p>'. |
---|
| 429 | |
---|
[70] | 430 | '<p><label for="post_lang">'.__('Entry lang:'). |
---|
[454] | 431 | form::combo('post_lang',$lang_combo,$post_lang). |
---|
[0] | 432 | '</label></p>'. |
---|
| 433 | |
---|
[70] | 434 | '<p><label for="post_password">'.__('Entry password:'). |
---|
[454] | 435 | form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). |
---|
[0] | 436 | '</label></p>'. |
---|
| 437 | |
---|
| 438 | '<div class="lockable">'. |
---|
[70] | 439 | '<p><label for="post_url">'.__('Basename:'). |
---|
[454] | 440 | form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). |
---|
[0] | 441 | '</label></p>'. |
---|
| 442 | '<p class="form-note warn">'. |
---|
| 443 | __('Warning: If you set the URL manually, it may conflict with another entry.'). |
---|
| 444 | '</p>'. |
---|
| 445 | '</div>'; |
---|
| 446 | |
---|
| 447 | # --BEHAVIOR-- adminPostFormSidebar |
---|
| 448 | $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); |
---|
| 449 | |
---|
| 450 | echo '</div>'; // End #entry-sidebar |
---|
[458] | 451 | |
---|
[0] | 452 | echo '</form>'; |
---|
[416] | 453 | |
---|
| 454 | # --BEHAVIOR-- adminPostForm |
---|
| 455 | $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); |
---|
| 456 | |
---|
[0] | 457 | echo '</div>'; |
---|
| 458 | |
---|
| 459 | if ($post_id && $post->post_status == 1) { |
---|
[70] | 460 | echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. |
---|
[0] | 461 | __('Ping blogs').'</a></p>'; |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | |
---|
| 467 | /* Comments and trackbacks |
---|
| 468 | -------------------------------------------------------- */ |
---|
| 469 | if ($post_id) |
---|
| 470 | { |
---|
| 471 | $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); |
---|
| 472 | |
---|
| 473 | $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); |
---|
| 474 | $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); |
---|
| 475 | |
---|
| 476 | # Actions combo box |
---|
| 477 | $combo_action = array(); |
---|
| 478 | if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 479 | { |
---|
| 480 | $combo_action[__('publish')] = 'publish'; |
---|
| 481 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
| 482 | $combo_action[__('mark as pending')] = 'pending'; |
---|
| 483 | $combo_action[__('mark as junk')] = 'junk'; |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 487 | { |
---|
[747] | 488 | $combo_action[__('Delete')] = 'delete'; |
---|
[0] | 489 | } |
---|
| 490 | |
---|
[322] | 491 | # --BEHAVIOR-- adminCommentsActionsCombo |
---|
| 492 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
---|
| 493 | |
---|
[0] | 494 | $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); |
---|
| 495 | |
---|
| 496 | echo |
---|
| 497 | '<div id="comments" class="multi-part" title="'.__('Comments').'">'; |
---|
| 498 | |
---|
| 499 | if ($has_action) { |
---|
| 500 | echo '<form action="comments_actions.php" id="form-comments" method="post">'; |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | echo '<h3>'.__('Trackbacks').'</h3>'; |
---|
| 504 | |
---|
| 505 | if (!$trackbacks->isEmpty()) { |
---|
[70] | 506 | showComments($trackbacks,$has_action,true); |
---|
[0] | 507 | } else { |
---|
| 508 | echo '<p>'.__('No trackback').'</p>'; |
---|
| 509 | } |
---|
| 510 | |
---|
| 511 | echo '<h3>'.__('Comments').'</h3>'; |
---|
| 512 | if (!$comments->isEmpty()) { |
---|
| 513 | showComments($comments,$has_action); |
---|
| 514 | } else { |
---|
| 515 | echo '<p>'.__('No comment').'</p>'; |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | if ($has_action) { |
---|
| 519 | echo |
---|
| 520 | '<div class="two-cols">'. |
---|
| 521 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 522 | |
---|
[96] | 523 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[0] | 524 | form::combo('action',$combo_action). |
---|
| 525 | form::hidden('redir','post.php?id='.$post_id.'&co=1'). |
---|
| 526 | $core->formNonce(). |
---|
| 527 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 528 | '</div>'. |
---|
| 529 | '</form>'; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | echo '</div>'; |
---|
| 533 | } |
---|
| 534 | |
---|
| 535 | /* Add a comment |
---|
| 536 | -------------------------------------------------------- */ |
---|
| 537 | if ($post_id) |
---|
| 538 | { |
---|
| 539 | echo |
---|
| 540 | '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. |
---|
| 541 | '<h3>'.__('Add a comment').'</h3>'. |
---|
| 542 | |
---|
| 543 | '<form action="comment.php" method="post" id="comment-form">'. |
---|
[536] | 544 | '<div class="constrained">'. |
---|
[70] | 545 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). |
---|
[0] | 546 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). |
---|
| 547 | '</label></p>'. |
---|
| 548 | |
---|
[70] | 549 | '<p><label for="comment_email">'.__('Email:'). |
---|
[0] | 550 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). |
---|
| 551 | '</label></p>'. |
---|
| 552 | |
---|
[70] | 553 | '<p><label for="comment_site">'.__('Web site:'). |
---|
[0] | 554 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). |
---|
| 555 | '</label></p>'. |
---|
| 556 | |
---|
[70] | 557 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
| 558 | __('Comment:').'</label> '. |
---|
[0] | 559 | form::textarea('comment_content',50,8,html::escapeHTML('')). |
---|
| 560 | '</p>'. |
---|
| 561 | |
---|
| 562 | '<p>'.form::hidden('post_id',$post_id). |
---|
| 563 | $core->formNonce(). |
---|
[217] | 564 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. |
---|
[536] | 565 | '</div>'. |
---|
[0] | 566 | '</form>'. |
---|
| 567 | '</div>'; |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | |
---|
| 571 | # Show comments or trackbacks |
---|
[70] | 572 | function showComments($rs,$has_action,$tb=false) |
---|
[0] | 573 | { |
---|
| 574 | echo |
---|
| 575 | '<table class="comments-list"><tr>'. |
---|
| 576 | '<th colspan="2">'.__('Author').'</th>'. |
---|
| 577 | '<th>'.__('Date').'</th>'. |
---|
| 578 | '<th class="nowrap">'.__('IP address').'</th>'. |
---|
| 579 | '<th>'.__('Status').'</th>'. |
---|
| 580 | '<th> </th>'. |
---|
| 581 | '</tr>'; |
---|
| 582 | |
---|
| 583 | while($rs->fetch()) |
---|
| 584 | { |
---|
| 585 | $comment_url = 'comment.php?id='.$rs->comment_id; |
---|
| 586 | |
---|
| 587 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 588 | switch ($rs->comment_status) { |
---|
| 589 | case 1: |
---|
| 590 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
| 591 | break; |
---|
| 592 | case 0: |
---|
| 593 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
| 594 | break; |
---|
| 595 | case -1: |
---|
| 596 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
| 597 | break; |
---|
| 598 | case -2: |
---|
| 599 | $img_status = sprintf($img,__('junk'),'junk.png'); |
---|
| 600 | break; |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | echo |
---|
| 604 | '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. |
---|
| 605 | ' id="c'.$rs->comment_id.'">'. |
---|
| 606 | |
---|
| 607 | '<td class="nowrap">'. |
---|
[70] | 608 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. |
---|
[0] | 609 | '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. |
---|
| 610 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. |
---|
| 611 | '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. |
---|
| 612 | '<td class="nowrap status">'.$img_status.'</td>'. |
---|
| 613 | '<td class="nowrap status"><a href="'.$comment_url.'">'. |
---|
| 614 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. |
---|
| 615 | |
---|
| 616 | '</tr>'; |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | echo '</table>'; |
---|
| 620 | } |
---|
| 621 | |
---|
| 622 | dcPage::helpBlock('core_post','core_wiki'); |
---|
| 623 | dcPage::close(); |
---|
| 624 | ?> |
---|