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