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