[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | 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 = ''; |
---|
[184] | 28 | $post_notes = ''; |
---|
[0] | 29 | $post_status = $core->auth->getInfo('user_post_status'); |
---|
| 30 | $post_position = 0; |
---|
| 31 | $post_open_comment = false; |
---|
| 32 | $post_open_tb = false; |
---|
[911] | 33 | $post_selected = false; |
---|
[0] | 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 |
---|
[1719] | 55 | $status_combo = dcAdminCombos::getPostStatusesCombo(); |
---|
| 56 | |
---|
[985] | 57 | $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
[0] | 58 | |
---|
| 59 | # Formaters combo |
---|
[1719] | 60 | $formaters_combo = dcAdminCombos::getFormatersCombo(); |
---|
[0] | 61 | |
---|
| 62 | # Languages combo |
---|
| 63 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
[1719] | 64 | $lang_combo = dcAdminCombos::getLangsCombo($rs,true); |
---|
| 65 | |
---|
[0] | 66 | |
---|
[957] | 67 | # Validation flag |
---|
| 68 | $bad_dt = false; |
---|
[0] | 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; |
---|
[184] | 96 | $post_notes = $post->post_notes; |
---|
[0] | 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; |
---|
[911] | 101 | $post_selected = (boolean) $post->post_selected; |
---|
[0] | 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, |
---|
[1454] | 113 | html::escapeHTML($next_rs->post_title),__('Next page').' »'); |
---|
[0] | 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, |
---|
[1454] | 120 | html::escapeHTML($prev_rs->post_title),'« '.__('Previous page')); |
---|
[0] | 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); |
---|
[1537] | 128 | } catch (Exception $e) { |
---|
| 129 | $core->error->add($e->getMessage()); |
---|
| 130 | } |
---|
[0] | 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 { |
---|
[957] | 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 | } |
---|
[0] | 163 | } |
---|
| 164 | |
---|
| 165 | $post_open_comment = !empty($_POST['post_open_comment']); |
---|
| 166 | $post_open_tb = !empty($_POST['post_open_tb']); |
---|
[911] | 167 | $post_selected = !empty($_POST['post_selected']); |
---|
[0] | 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 | |
---|
[184] | 172 | $post_notes = $_POST['post_notes']; |
---|
| 173 | |
---|
[0] | 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 | |
---|
[1068] | 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 |
---|
[957] | 198 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page && !$bad_dt) |
---|
[0] | 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; |
---|
[184] | 216 | $cur->post_notes = $post_notes; |
---|
[0] | 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; |
---|
[911] | 221 | $cur->post_selected = (integer) $post_selected; |
---|
[0] | 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 | |
---|
[1358] | 306 | if ($post_id) { |
---|
| 307 | switch ($post_status) { |
---|
| 308 | case 1: |
---|
[1454] | 309 | $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png'); |
---|
[1358] | 310 | break; |
---|
| 311 | case 0: |
---|
[1454] | 312 | $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png'); |
---|
[1358] | 313 | break; |
---|
| 314 | case -1: |
---|
[1454] | 315 | $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png'); |
---|
[1358] | 316 | break; |
---|
| 317 | case -2: |
---|
[1454] | 318 | $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png'); |
---|
[1358] | 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 | |
---|
[0] | 334 | if (!empty($_GET['upd'])) { |
---|
[1553] | 335 | dcPage::success(__('Page has been successfully updated.')); |
---|
[0] | 336 | } |
---|
| 337 | elseif (!empty($_GET['crea'])) { |
---|
[1553] | 338 | dcPage::success(__('Page has been successfully created.')); |
---|
[0] | 339 | } |
---|
| 340 | elseif (!empty($_GET['attached'])) { |
---|
[1553] | 341 | dcPage::success(__('File has been successfully attached.')); |
---|
[0] | 342 | } |
---|
| 343 | elseif (!empty($_GET['rmattach'])) { |
---|
[1553] | 344 | dcPage::success(__('Attachment has been successfully removed.')); |
---|
[0] | 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 | |
---|
[907] | 354 | dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); |
---|
[0] | 355 | } |
---|
| 356 | |
---|
| 357 | if ($post_id && $post->post_status == 1) { |
---|
[1454] | 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>'; |
---|
[0] | 359 | } |
---|
| 360 | |
---|
[559] | 361 | echo ''; |
---|
[0] | 362 | |
---|
| 363 | if ($post_id) |
---|
| 364 | { |
---|
[1336] | 365 | echo '<p class="nav_prevnext">'; |
---|
[0] | 366 | if ($prev_link) { echo $prev_link; } |
---|
[1336] | 367 | if ($next_link && $prev_link) { echo ' | '; } |
---|
[0] | 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 | |
---|
[1619] | 383 | /* Post form if we can edit page |
---|
[0] | 384 | -------------------------------------------------------- */ |
---|
| 385 | if ($can_edit_page) |
---|
| 386 | { |
---|
[1617] | 387 | $sidebar_items = new ArrayObject(array( |
---|
| 388 | 'status-box' => array( |
---|
| 389 | 'title' => __('Status'), |
---|
| 390 | 'items' => array( |
---|
| 391 | 'post_status' => |
---|
[1668] | 392 | '<p><label for="post_status" class="ib">'.__('Page status').'</label> '. |
---|
[1617] | 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' => |
---|
[1964] | 400 | '<p><label for="post_lang" class="ib">'.__('Page language').'</label>'. |
---|
[1617] | 401 | form::combo('post_lang',$lang_combo,$post_lang). |
---|
| 402 | '</p>', |
---|
| 403 | 'post_format' => |
---|
[1619] | 404 | '<div>'. |
---|
[1964] | 405 | '<h5 id="label_format"><label for="post_format" class="ib">'.__('Text formatting').'</label></h5>'. |
---|
[1619] | 406 | '<p>'.form::combo('post_format',$formaters_combo,$post_format,'maximal'). |
---|
[1617] | 407 | '</p>'. |
---|
[1947] | 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">'. |
---|
[1828] | 410 | __('Convert to XHTML').'</a></p></div>')), |
---|
[1617] | 411 | 'metas-box' => array( |
---|
[1964] | 412 | 'title' => __('Filing'), |
---|
[1617] | 413 | 'items' => array( |
---|
| 414 | 'post_position' => |
---|
[1668] | 415 | '<p><label for="post_position" class="classic">'.__('Page position').'</label> '. |
---|
[1617] | 416 | form::field('post_position',3,3,(string) $post_position). |
---|
| 417 | '</p>')), |
---|
| 418 | 'options-box' => array( |
---|
| 419 | 'title' => __('Options'), |
---|
| 420 | 'items' => array( |
---|
[1711] | 421 | 'post_open_comment_tb' => |
---|
| 422 | '<div>'. |
---|
[1941] | 423 | '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'. |
---|
[1617] | 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">'. |
---|
[1711] | 433 | __('Comments are not accepted on this blog so far.').'</p>'). |
---|
[1617] | 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>') : |
---|
[1711] | 442 | '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>'). |
---|
| 443 | '</div>', |
---|
[1619] | 444 | 'post_hide' => |
---|
| 445 | '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. |
---|
[1621] | 446 | __('Hide in widget Pages').'</label>'. |
---|
[1619] | 447 | '</p>', |
---|
[1617] | 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" => |
---|
[1741] | 469 | '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').' <span class="form-note">'. |
---|
[1947] | 470 | __('Introduction to the page.').'</span></label> '. |
---|
[1617] | 471 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). |
---|
| 472 | '</p>', |
---|
| 473 | |
---|
| 474 | "post_content" => |
---|
[1828] | 475 | '<p class="area" id="content-area"><label class="required" '. |
---|
[1617] | 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" => |
---|
[1741] | 481 | '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').' <span class="form-note">'. |
---|
| 482 | __('Unpublished notes.').'</span></label>'. |
---|
[1617] | 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 | |
---|
[1948] | 491 | echo '<div class="multi-part" title="'.($post_id ? __('Edit page') : __('New page')).'" id="edit-entry">'; |
---|
[0] | 492 | echo '<form action="'.html::escapeURL($redir_url).'" method="post" id="entry-form">'; |
---|
[458] | 493 | |
---|
| 494 | echo '<div id="entry-wrapper">'; |
---|
[536] | 495 | echo '<div id="entry-content"><div class="constrained">'; |
---|
[1833] | 496 | echo '<h3 class="out-of-screen-if-js">'.__('Edit page').'</h3>'; |
---|
[458] | 497 | |
---|
| 498 | |
---|
[1617] | 499 | foreach ($main_items as $id => $item) { |
---|
| 500 | echo $item; |
---|
| 501 | } |
---|
[458] | 502 | |
---|
| 503 | # --BEHAVIOR-- adminPageForm |
---|
| 504 | $core->callBehavior('adminPageForm',isset($post) ? $post : null); |
---|
| 505 | |
---|
| 506 | echo |
---|
[1454] | 507 | '<p class="border-top">'. |
---|
[458] | 508 | ($post_id ? form::hidden('id',$post_id) : ''). |
---|
| 509 | '<input type="submit" value="'.__('Save').' (s)" '. |
---|
[559] | 510 | 'accesskey="s" name="save" /> '; |
---|
| 511 | |
---|
| 512 | if ($post_id) { |
---|
[776] | 513 | $preview_url = $core->blog->url. |
---|
[773] | 514 | $core->url->getURLFor('pagespreview', |
---|
[559] | 515 | $core->auth->userID().'/'. |
---|
| 516 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). |
---|
[773] | 517 | '/'.$post->post_url); |
---|
[1139] | 518 | echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a>'; |
---|
[1215] | 519 | } else { |
---|
| 520 | echo |
---|
| 521 | '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; |
---|
[559] | 522 | } |
---|
[1214] | 523 | |
---|
| 524 | echo |
---|
[458] | 525 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). |
---|
| 526 | $core->formNonce(). |
---|
| 527 | '</p>'; |
---|
| 528 | |
---|
[536] | 529 | echo '</div></div>'; // End #entry-content |
---|
[458] | 530 | echo '</div>'; // End #entry-wrapper |
---|
| 531 | |
---|
[0] | 532 | echo '<div id="entry-sidebar">'; |
---|
| 533 | |
---|
[1617] | 534 | foreach ($sidebar_items as $id => $c) { |
---|
[1741] | 535 | echo '<div id="'.$id.'" class="sb-box">'. |
---|
[1617] | 536 | '<h4>'.$c['title'].'</h4>'; |
---|
| 537 | foreach ($c['items'] as $e_name=>$e_content) { |
---|
| 538 | echo $e_content; |
---|
[0] | 539 | } |
---|
[1617] | 540 | echo '</div>'; |
---|
[0] | 541 | } |
---|
| 542 | |
---|
| 543 | # --BEHAVIOR-- adminPageFormSidebar |
---|
| 544 | $core->callBehavior('adminPageFormSidebar',isset($post) ? $post : null); |
---|
| 545 | |
---|
| 546 | echo '</div>'; // End #entry-sidebar |
---|
| 547 | |
---|
| 548 | echo '</form>'; |
---|
[1621] | 549 | echo '</div>'; // End |
---|
[0] | 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 | { |
---|
[1454] | 576 | $combo_action[__('Publish')] = 'publish'; |
---|
| 577 | $combo_action[__('Unpublish')] = 'unpublish'; |
---|
| 578 | $combo_action[__('Mark as pending')] = 'pending'; |
---|
| 579 | $combo_action[__('Mark as junk')] = 'junk'; |
---|
[0] | 580 | } |
---|
| 581 | |
---|
| 582 | if ($can_edit_page && $core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 583 | { |
---|
[1508] | 584 | $combo_action[__('Delete')] = 'delete'; |
---|
[0] | 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 | |
---|
[1621] | 592 | echo |
---|
[1741] | 593 | '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>'; |
---|
[1621] | 594 | |
---|
[0] | 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 | |
---|
[1508] | 619 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[0] | 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 | } |
---|
[1621] | 627 | /* Add a comment |
---|
| 628 | -------------------------------------------------------- */ |
---|
[0] | 629 | |
---|
| 630 | echo |
---|
[1621] | 631 | '<div class="fieldset clear">'. |
---|
[0] | 632 | '<h3>'.__('Add a comment').'</h3>'. |
---|
| 633 | |
---|
| 634 | '<form action="comment.php" method="post" id="comment-form">'. |
---|
[536] | 635 | '<div class="constrained">'. |
---|
[1454] | 636 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. |
---|
[0] | 637 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). |
---|
[1454] | 638 | '</p>'. |
---|
[0] | 639 | |
---|
[1454] | 640 | '<p><label for="comment_email">'.__('Email:').'</label>'. |
---|
[0] | 641 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). |
---|
[1454] | 642 | '</p>'. |
---|
[0] | 643 | |
---|
[1454] | 644 | '<p><label for="comment_site">'.__('Web site:').'</label>'. |
---|
[0] | 645 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). |
---|
[1454] | 646 | '</p>'. |
---|
[0] | 647 | |
---|
[1621] | 648 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
| 649 | __('Comment:').'</label> '. |
---|
[0] | 650 | form::textarea('comment_content',50,8,html::escapeHTML('')). |
---|
| 651 | '</p>'. |
---|
| 652 | |
---|
| 653 | '<p>'.form::hidden('post_id',$post_id). |
---|
| 654 | $core->formNonce(). |
---|
[217] | 655 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. |
---|
[1621] | 656 | '</div>'. #constrained |
---|
| 657 | |
---|
[0] | 658 | '</form>'. |
---|
[1621] | 659 | '</div>'. #add comment |
---|
| 660 | '</div>'; #comments |
---|
[0] | 661 | } |
---|
| 662 | |
---|
[917] | 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 | } |
---|
[0] | 684 | |
---|
| 685 | # Show comments or trackbacks |
---|
| 686 | function showComments($rs,$has_action) |
---|
| 687 | { |
---|
| 688 | echo |
---|
| 689 | '<table class="comments-list"><tr>'. |
---|
[1508] | 690 | '<th colspan="2" class="nowrap first">'.__('Author').'</th>'. |
---|
[0] | 691 | '<th>'.__('Date').'</th>'. |
---|
| 692 | '<th class="nowrap">'.__('IP address').'</th>'. |
---|
| 693 | '<th>'.__('Status').'</th>'. |
---|
[1508] | 694 | '<th>'.__('Edit').'</th>'. |
---|
[0] | 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: |
---|
[1454] | 704 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[0] | 705 | break; |
---|
| 706 | case 0: |
---|
[1454] | 707 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[0] | 708 | break; |
---|
| 709 | case -1: |
---|
[1454] | 710 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[0] | 711 | break; |
---|
| 712 | case -2: |
---|
[1454] | 713 | $img_status = sprintf($img,__('Junk'),'junk.png'); |
---|
[0] | 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">'. |
---|
[1454] | 722 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.__('Select this comment').'"') : '').'</td>'. |
---|
[0] | 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.'">'. |
---|
[1508] | 728 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'. |
---|
[0] | 729 | |
---|
| 730 | '</tr>'; |
---|
| 731 | } |
---|
| 732 | |
---|
| 733 | echo '</table>'; |
---|
| 734 | } |
---|
[198] | 735 | dcPage::helpBlock('page'); |
---|
[0] | 736 | ?> |
---|
| 737 | </body> |
---|
[1454] | 738 | </html> |
---|