[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']; |
---|
[2511] | 75 | |
---|
[0] | 76 | $post = $core->blog->getPosts($params); |
---|
[2511] | 77 | |
---|
[0] | 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; |
---|
[2511] | 102 | |
---|
[0] | 103 | $page_title = __('Edit page'); |
---|
[2511] | 104 | |
---|
[0] | 105 | $can_edit_page = $post->isEditable(); |
---|
| 106 | $can_delete= $post->isDeletable(); |
---|
[2511] | 107 | |
---|
[0] | 108 | $next_rs = $core->blog->getNextPost($post,1); |
---|
| 109 | $prev_rs = $core->blog->getNextPost($post,-1); |
---|
[2511] | 110 | |
---|
[0] | 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 | } |
---|
[2511] | 117 | |
---|
[0] | 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 | } |
---|
[2511] | 124 | |
---|
[0] | 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']; |
---|
[2511] | 140 | |
---|
[0] | 141 | $post_title = $_POST['post_title']; |
---|
[2511] | 142 | |
---|
[0] | 143 | if (isset($_POST['post_status'])) { |
---|
| 144 | $post_status = (integer) $_POST['post_status']; |
---|
| 145 | } |
---|
[2511] | 146 | |
---|
[0] | 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 | } |
---|
[2511] | 164 | |
---|
[0] | 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']; |
---|
[2511] | 171 | |
---|
[184] | 172 | $post_notes = $_POST['post_notes']; |
---|
| 173 | |
---|
[0] | 174 | if (isset($_POST['post_url'])) { |
---|
| 175 | $post_url = $_POST['post_url']; |
---|
| 176 | } |
---|
[2511] | 177 | |
---|
[0] | 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'); |
---|
[2511] | 201 | |
---|
[0] | 202 | # Magic tweak :) |
---|
| 203 | $core->blog->settings->system->post_url_format = $page_url_format; |
---|
[2511] | 204 | |
---|
[0] | 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; |
---|
[2511] | 222 | |
---|
[0] | 223 | if (isset($_POST['post_url'])) { |
---|
| 224 | $cur->post_url = $post_url; |
---|
| 225 | } |
---|
[2511] | 226 | |
---|
[0] | 227 | # Update post |
---|
| 228 | if ($post_id) |
---|
| 229 | { |
---|
| 230 | try |
---|
| 231 | { |
---|
| 232 | # --BEHAVIOR-- adminBeforePageUpdate |
---|
| 233 | $core->callBehavior('adminBeforePageUpdate',$cur,$post_id); |
---|
[2511] | 234 | |
---|
[0] | 235 | $core->blog->updPost($post_id,$cur); |
---|
[2511] | 236 | |
---|
[0] | 237 | # --BEHAVIOR-- adminAfterPageUpdate |
---|
| 238 | $core->callBehavior('adminAfterPageUpdate',$cur,$post_id); |
---|
[2511] | 239 | |
---|
[0] | 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(); |
---|
[2511] | 250 | |
---|
[0] | 251 | try |
---|
| 252 | { |
---|
| 253 | # --BEHAVIOR-- adminBeforePageCreate |
---|
| 254 | $core->callBehavior('adminBeforePageCreate',$cur); |
---|
[2511] | 255 | |
---|
[0] | 256 | $return_id = $core->blog->addPost($cur); |
---|
[2511] | 257 | |
---|
[0] | 258 | # --BEHAVIOR-- adminAfterPageCreate |
---|
| 259 | $core->callBehavior('adminAfterPageCreate',$cur,$return_id); |
---|
[2511] | 260 | |
---|
[0] | 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::jsModal(). |
---|
| 292 | dcPage::jsLoad('js/_post.js'). |
---|
[2614] | 293 | $core->callBehavior('adminPostEditor'). |
---|
[0] | 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, |
---|
[2166] | 331 | $edit_entry_title => '' |
---|
[1358] | 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'; |
---|
[2511] | 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) { |
---|
[2225] | 358 | echo '<p><a class="onblog_link outgoing" href="'.$post->getURL().'" title="'.$post_title.'">'.__('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; } |
---|
[2511] | 369 | |
---|
| 370 | # --BEHAVIOR-- adminPageNavLinks |
---|
[0] | 371 | $core->callBehavior('adminPageNavLinks',isset($post) ? $post : null); |
---|
[2511] | 372 | |
---|
[0] | 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( |
---|
[2511] | 391 | 'post_status' => |
---|
[2390] | 392 | '<p><label for="post_status">'.__('Page status').'</label> '. |
---|
[1617] | 393 | form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). |
---|
| 394 | '</p>', |
---|
[2511] | 395 | 'post_dt' => |
---|
[2390] | 396 | '<p><label for="post_dt">'.__('Publication date and hour').'</label>'. |
---|
[1617] | 397 | form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). |
---|
| 398 | '</p>', |
---|
| 399 | 'post_lang' => |
---|
[2390] | 400 | '<p><label for="post_lang">'.__('Page language').'</label>'. |
---|
[1617] | 401 | form::combo('post_lang',$lang_combo,$post_lang). |
---|
| 402 | '</p>', |
---|
| 403 | 'post_format' => |
---|
[1619] | 404 | '<div>'. |
---|
[2390] | 405 | '<h5 id="label_format"><label for="post_format" class="classic">'.__('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">'. |
---|
[2511] | 409 | '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : ''). |
---|
| 410 | '" href="'.html::escapeURL($redir_url).'&id='.$post_id.'&xconv=1">'. |
---|
[1828] | 411 | __('Convert to XHTML').'</a></p></div>')), |
---|
[1617] | 412 | 'metas-box' => array( |
---|
[1964] | 413 | 'title' => __('Filing'), |
---|
[1617] | 414 | 'items' => array( |
---|
[2511] | 415 | 'post_position' => |
---|
[1668] | 416 | '<p><label for="post_position" class="classic">'.__('Page position').'</label> '. |
---|
[1617] | 417 | form::field('post_position',3,3,(string) $post_position). |
---|
| 418 | '</p>')), |
---|
| 419 | 'options-box' => array( |
---|
| 420 | 'title' => __('Options'), |
---|
| 421 | 'items' => array( |
---|
[1711] | 422 | 'post_open_comment_tb' => |
---|
| 423 | '<div>'. |
---|
[1941] | 424 | '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'. |
---|
[1617] | 425 | '<p><label for="post_open_comment" class="classic">'. |
---|
| 426 | form::checkbox('post_open_comment',1,$post_open_comment).' '. |
---|
| 427 | __('Accept comments').'</label></p>'. |
---|
[2511] | 428 | ($core->blog->settings->system->allow_comments ? |
---|
| 429 | (isContributionAllowed($post_id,strtotime($post_dt),true) ? |
---|
[1617] | 430 | '' : |
---|
| 431 | '<p class="form-note warn">'. |
---|
[2511] | 432 | __('Warning: Comments are not more accepted for this entry.').'</p>') : |
---|
[1617] | 433 | '<p class="form-note warn">'. |
---|
[1711] | 434 | __('Comments are not accepted on this blog so far.').'</p>'). |
---|
[1617] | 435 | '<p><label for="post_open_tb" class="classic">'. |
---|
| 436 | form::checkbox('post_open_tb',1,$post_open_tb).' '. |
---|
| 437 | __('Accept trackbacks').'</label></p>'. |
---|
[2511] | 438 | ($core->blog->settings->system->allow_trackbacks ? |
---|
| 439 | (isContributionAllowed($post_id,strtotime($post_dt),false) ? |
---|
[1617] | 440 | '' : |
---|
| 441 | '<p class="form-note warn">'. |
---|
[2511] | 442 | __('Warning: Trackbacks are not more accepted for this entry.').'</p>') : |
---|
[1711] | 443 | '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>'). |
---|
| 444 | '</div>', |
---|
[2511] | 445 | 'post_hide' => |
---|
[1619] | 446 | '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. |
---|
[1621] | 447 | __('Hide in widget Pages').'</label>'. |
---|
[1619] | 448 | '</p>', |
---|
[1617] | 449 | 'post_password' => |
---|
[2390] | 450 | '<p><label for="post_password">'.__('Password').'</label>'. |
---|
[1617] | 451 | form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). |
---|
| 452 | '</p>', |
---|
| 453 | 'post_url' => |
---|
| 454 | '<div class="lockable">'. |
---|
[2390] | 455 | '<p><label for="post_url">'.__('Edit basename').'</label>'. |
---|
[1617] | 456 | form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). |
---|
| 457 | '</p>'. |
---|
| 458 | '<p class="form-note warn">'. |
---|
[1981] | 459 | __('Warning: If you set the URL manually, it may conflict with another page.'). |
---|
[1617] | 460 | '</p></div>' |
---|
| 461 | )))); |
---|
| 462 | $main_items = new ArrayObject(array( |
---|
| 463 | "post_title" => |
---|
| 464 | '<p class="col">'. |
---|
[2390] | 465 | '<label class="required no-margin bold"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. |
---|
[1617] | 466 | form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). |
---|
| 467 | '</p>', |
---|
[2511] | 468 | |
---|
[1617] | 469 | "post_excerpt" => |
---|
[2390] | 470 | '<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">'.__('Excerpt:').' <span class="form-note">'. |
---|
[1947] | 471 | __('Introduction to the page.').'</span></label> '. |
---|
[1617] | 472 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). |
---|
| 473 | '</p>', |
---|
[2511] | 474 | |
---|
[1617] | 475 | "post_content" => |
---|
[2390] | 476 | '<p class="area" id="content-area"><label class="required bold" '. |
---|
[1617] | 477 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. |
---|
| 478 | form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). |
---|
| 479 | '</p>', |
---|
[2511] | 480 | |
---|
[1617] | 481 | "post_notes" => |
---|
[2390] | 482 | '<p class="area" id="notes-area"><label for="post_notes" class="bold">'.__('Personal notes:').' <span class="form-note">'. |
---|
[1741] | 483 | __('Unpublished notes.').'</span></label>'. |
---|
[1617] | 484 | form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). |
---|
| 485 | '</p>' |
---|
| 486 | ) |
---|
| 487 | ); |
---|
| 488 | |
---|
| 489 | # --BEHAVIOR-- adminPostFormItems |
---|
| 490 | $core->callBehavior('adminPageFormItems',$main_items,$sidebar_items, isset($post) ? $post : null); |
---|
| 491 | |
---|
[1948] | 492 | echo '<div class="multi-part" title="'.($post_id ? __('Edit page') : __('New page')).'" id="edit-entry">'; |
---|
[0] | 493 | echo '<form action="'.html::escapeURL($redir_url).'" method="post" id="entry-form">'; |
---|
[458] | 494 | |
---|
| 495 | echo '<div id="entry-wrapper">'; |
---|
[536] | 496 | echo '<div id="entry-content"><div class="constrained">'; |
---|
[1833] | 497 | echo '<h3 class="out-of-screen-if-js">'.__('Edit page').'</h3>'; |
---|
[2511] | 498 | |
---|
| 499 | |
---|
[1617] | 500 | foreach ($main_items as $id => $item) { |
---|
| 501 | echo $item; |
---|
| 502 | } |
---|
[458] | 503 | |
---|
| 504 | # --BEHAVIOR-- adminPageForm |
---|
| 505 | $core->callBehavior('adminPageForm',isset($post) ? $post : null); |
---|
[2511] | 506 | |
---|
[458] | 507 | echo |
---|
[1454] | 508 | '<p class="border-top">'. |
---|
[458] | 509 | ($post_id ? form::hidden('id',$post_id) : ''). |
---|
| 510 | '<input type="submit" value="'.__('Save').' (s)" '. |
---|
[559] | 511 | 'accesskey="s" name="save" /> '; |
---|
| 512 | |
---|
| 513 | if ($post_id) { |
---|
[776] | 514 | $preview_url = $core->blog->url. |
---|
[773] | 515 | $core->url->getURLFor('pagespreview', |
---|
[559] | 516 | $core->auth->userID().'/'. |
---|
| 517 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). |
---|
[773] | 518 | '/'.$post->post_url); |
---|
[1139] | 519 | echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a>'; |
---|
[1215] | 520 | } else { |
---|
| 521 | echo |
---|
| 522 | '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; |
---|
[559] | 523 | } |
---|
[1214] | 524 | |
---|
| 525 | echo |
---|
[458] | 526 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). |
---|
| 527 | $core->formNonce(). |
---|
| 528 | '</p>'; |
---|
[2511] | 529 | |
---|
[536] | 530 | echo '</div></div>'; // End #entry-content |
---|
[458] | 531 | echo '</div>'; // End #entry-wrapper |
---|
| 532 | |
---|
[0] | 533 | echo '<div id="entry-sidebar">'; |
---|
[2511] | 534 | |
---|
[1617] | 535 | foreach ($sidebar_items as $id => $c) { |
---|
[1741] | 536 | echo '<div id="'.$id.'" class="sb-box">'. |
---|
[1617] | 537 | '<h4>'.$c['title'].'</h4>'; |
---|
| 538 | foreach ($c['items'] as $e_name=>$e_content) { |
---|
| 539 | echo $e_content; |
---|
[0] | 540 | } |
---|
[1617] | 541 | echo '</div>'; |
---|
[0] | 542 | } |
---|
[2511] | 543 | |
---|
[0] | 544 | # --BEHAVIOR-- adminPageFormSidebar |
---|
| 545 | $core->callBehavior('adminPageFormSidebar',isset($post) ? $post : null); |
---|
[2511] | 546 | |
---|
[0] | 547 | echo '</div>'; // End #entry-sidebar |
---|
[2511] | 548 | |
---|
[0] | 549 | echo '</form>'; |
---|
[2511] | 550 | echo '</div>'; // End |
---|
| 551 | |
---|
[0] | 552 | if ($post_id && !empty($post_media)) |
---|
| 553 | { |
---|
| 554 | echo |
---|
| 555 | '<form action="post_media.php" id="attachment-remove-hide" method="post">'. |
---|
| 556 | '<div>'.form::hidden(array('post_id'),$post_id). |
---|
| 557 | form::hidden(array('media_id'),''). |
---|
| 558 | form::hidden(array('remove'),1). |
---|
| 559 | $core->formNonce().'</div></form>'; |
---|
| 560 | } |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | |
---|
| 564 | /* Comments and trackbacks |
---|
| 565 | -------------------------------------------------------- */ |
---|
| 566 | if ($post_id) |
---|
| 567 | { |
---|
| 568 | $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); |
---|
[2511] | 569 | |
---|
[0] | 570 | $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); |
---|
| 571 | $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); |
---|
[2511] | 572 | |
---|
[0] | 573 | # Actions combo box |
---|
| 574 | $combo_action = array(); |
---|
| 575 | if ($can_edit_page && $core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 576 | { |
---|
[1454] | 577 | $combo_action[__('Publish')] = 'publish'; |
---|
| 578 | $combo_action[__('Unpublish')] = 'unpublish'; |
---|
| 579 | $combo_action[__('Mark as pending')] = 'pending'; |
---|
| 580 | $combo_action[__('Mark as junk')] = 'junk'; |
---|
[0] | 581 | } |
---|
[2511] | 582 | |
---|
[0] | 583 | if ($can_edit_page && $core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 584 | { |
---|
[1508] | 585 | $combo_action[__('Delete')] = 'delete'; |
---|
[0] | 586 | } |
---|
[2511] | 587 | |
---|
[0] | 588 | $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); |
---|
[2511] | 589 | |
---|
[0] | 590 | echo |
---|
| 591 | '<div id="comments" class="multi-part" title="'.__('Comments').'">'; |
---|
[2511] | 592 | |
---|
[1621] | 593 | echo |
---|
[1741] | 594 | '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>'; |
---|
[1621] | 595 | |
---|
[0] | 596 | if ($has_action) { |
---|
| 597 | echo '<form action="comments_actions.php" method="post">'; |
---|
| 598 | } |
---|
[2511] | 599 | |
---|
[0] | 600 | echo '<h3>'.__('Trackbacks').'</h3>'; |
---|
[2511] | 601 | |
---|
[0] | 602 | if (!$trackbacks->isEmpty()) { |
---|
| 603 | showComments($trackbacks,$has_action); |
---|
| 604 | } else { |
---|
| 605 | echo '<p>'.__('No trackback').'</p>'; |
---|
| 606 | } |
---|
[2511] | 607 | |
---|
[0] | 608 | echo '<h3>'.__('Comments').'</h3>'; |
---|
| 609 | if (!$comments->isEmpty()) { |
---|
| 610 | showComments($comments,$has_action); |
---|
| 611 | } else { |
---|
| 612 | echo '<p>'.__('No comment').'</p>'; |
---|
| 613 | } |
---|
[2511] | 614 | |
---|
[0] | 615 | if ($has_action) { |
---|
| 616 | echo |
---|
| 617 | '<div class="two-cols">'. |
---|
| 618 | '<p class="col checkboxes-helpers"></p>'. |
---|
[2511] | 619 | |
---|
[1508] | 620 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[0] | 621 | form::combo('action',$combo_action). |
---|
| 622 | form::hidden('redir',html::escapeURL($redir_url).'&id='.$post_id.'&co=1'). |
---|
| 623 | $core->formNonce(). |
---|
| 624 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 625 | '</div>'. |
---|
| 626 | '</form>'; |
---|
| 627 | } |
---|
[1621] | 628 | /* Add a comment |
---|
| 629 | -------------------------------------------------------- */ |
---|
[0] | 630 | |
---|
| 631 | echo |
---|
[1621] | 632 | '<div class="fieldset clear">'. |
---|
[0] | 633 | '<h3>'.__('Add a comment').'</h3>'. |
---|
[2511] | 634 | |
---|
[0] | 635 | '<form action="comment.php" method="post" id="comment-form">'. |
---|
[536] | 636 | '<div class="constrained">'. |
---|
[1454] | 637 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. |
---|
[0] | 638 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). |
---|
[1454] | 639 | '</p>'. |
---|
[2511] | 640 | |
---|
[1454] | 641 | '<p><label for="comment_email">'.__('Email:').'</label>'. |
---|
[0] | 642 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). |
---|
[1454] | 643 | '</p>'. |
---|
[2511] | 644 | |
---|
[1454] | 645 | '<p><label for="comment_site">'.__('Web site:').'</label>'. |
---|
[0] | 646 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). |
---|
[1454] | 647 | '</p>'. |
---|
[2511] | 648 | |
---|
[1621] | 649 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
| 650 | __('Comment:').'</label> '. |
---|
[0] | 651 | form::textarea('comment_content',50,8,html::escapeHTML('')). |
---|
| 652 | '</p>'. |
---|
[2511] | 653 | |
---|
[0] | 654 | '<p>'.form::hidden('post_id',$post_id). |
---|
| 655 | $core->formNonce(). |
---|
[217] | 656 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. |
---|
[1621] | 657 | '</div>'. #constrained |
---|
| 658 | |
---|
[0] | 659 | '</form>'. |
---|
[1621] | 660 | '</div>'. #add comment |
---|
| 661 | '</div>'; #comments |
---|
[0] | 662 | } |
---|
| 663 | |
---|
[917] | 664 | # Controls comments or trakbacks capabilities |
---|
| 665 | function isContributionAllowed($id,$dt,$com=true) |
---|
| 666 | { |
---|
| 667 | global $core; |
---|
| 668 | |
---|
| 669 | if (!$id) { |
---|
| 670 | return true; |
---|
| 671 | } |
---|
| 672 | if ($com) { |
---|
[2511] | 673 | if (($core->blog->settings->system->comments_ttl == 0) || |
---|
[917] | 674 | (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { |
---|
| 675 | return true; |
---|
| 676 | } |
---|
| 677 | } else { |
---|
[2511] | 678 | if (($core->blog->settings->system->trackbacks_ttl == 0) || |
---|
[917] | 679 | (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { |
---|
| 680 | return true; |
---|
| 681 | } |
---|
| 682 | } |
---|
| 683 | return false; |
---|
| 684 | } |
---|
[0] | 685 | |
---|
| 686 | # Show comments or trackbacks |
---|
| 687 | function showComments($rs,$has_action) |
---|
| 688 | { |
---|
| 689 | echo |
---|
| 690 | '<table class="comments-list"><tr>'. |
---|
[1508] | 691 | '<th colspan="2" class="nowrap first">'.__('Author').'</th>'. |
---|
[0] | 692 | '<th>'.__('Date').'</th>'. |
---|
| 693 | '<th class="nowrap">'.__('IP address').'</th>'. |
---|
| 694 | '<th>'.__('Status').'</th>'. |
---|
[1508] | 695 | '<th>'.__('Edit').'</th>'. |
---|
[0] | 696 | '</tr>'; |
---|
[2511] | 697 | |
---|
[0] | 698 | while($rs->fetch()) |
---|
| 699 | { |
---|
| 700 | $comment_url = 'comment.php?id='.$rs->comment_id; |
---|
[2511] | 701 | |
---|
[0] | 702 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 703 | switch ($rs->comment_status) { |
---|
| 704 | case 1: |
---|
[1454] | 705 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[0] | 706 | break; |
---|
| 707 | case 0: |
---|
[1454] | 708 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[0] | 709 | break; |
---|
| 710 | case -1: |
---|
[1454] | 711 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[0] | 712 | break; |
---|
| 713 | case -2: |
---|
[1454] | 714 | $img_status = sprintf($img,__('Junk'),'junk.png'); |
---|
[0] | 715 | break; |
---|
| 716 | } |
---|
[2511] | 717 | |
---|
[0] | 718 | echo |
---|
| 719 | '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. |
---|
| 720 | ' id="c'.$rs->comment_id.'">'. |
---|
[2511] | 721 | |
---|
[0] | 722 | '<td class="nowrap">'. |
---|
[1454] | 723 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.__('Select this comment').'"') : '').'</td>'. |
---|
[0] | 724 | '<td class="maximal">'.$rs->comment_author.'</td>'. |
---|
| 725 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. |
---|
| 726 | '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. |
---|
| 727 | '<td class="nowrap status">'.$img_status.'</td>'. |
---|
| 728 | '<td class="nowrap status"><a href="'.$comment_url.'">'. |
---|
[1508] | 729 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'. |
---|
[2511] | 730 | |
---|
[0] | 731 | '</tr>'; |
---|
| 732 | } |
---|
[2511] | 733 | |
---|
[0] | 734 | echo '</table>'; |
---|
| 735 | } |
---|
[2314] | 736 | dcPage::helpBlock('page','core_wiki'); |
---|
[0] | 737 | ?> |
---|
| 738 | </body> |
---|
[1454] | 739 | </html> |
---|