auth->getOption('post_format'); $post_editor = $core->auth->getOption('editor'); $post_password = ''; $post_url = ''; $post_lang = $core->auth->getInfo('user_lang'); $post_title = ''; $post_excerpt = ''; $post_excerpt_xhtml = ''; $post_content = ''; $post_content_xhtml = ''; $post_notes = ''; $post_status = $core->auth->getInfo('user_post_status'); $post_position = 0; $post_open_comment = false; $post_open_tb = false; $post_selected = false; $post_media = array(); $page_title = __('New page'); $can_view_page = true; $can_edit_page = $core->auth->check('pages,usage', $core->blog->id); $can_publish = $core->auth->check('pages,publish,contentadmin', $core->blog->id); $can_delete = false; $post_headlink = ''; $post_link = '%s'; $next_link = $prev_link = $next_headlink = $prev_headlink = null; # If user can't publish if (!$can_publish) { $post_status = -2; } # Status combo $status_combo = dcAdminCombos::getPostStatusesCombo(); $img_status_pattern = '%1$s'; # Formaters combo $core_formaters = $core->getFormaters(); $available_formats = array('' => ''); foreach ($core_formaters as $editor => $formats) { foreach ($formats as $format) { $available_formats[$format] = $format; } } # Languages combo $rs = $core->blog->getLangs(array('order' => 'asc')); $lang_combo = dcAdminCombos::getLangsCombo($rs, true); # Validation flag $bad_dt = false; # Get page informations if (!empty($_REQUEST['id'])) { $params['post_type'] = 'page'; $params['post_id'] = $_REQUEST['id']; $post = $core->blog->getPosts($params); if ($post->isEmpty()) { $core->error->add(__('This page does not exist.')); $can_view_page = false; } else { $post_id = $post->post_id; $post_dt = date('Y-m-d H:i', strtotime($post->post_dt)); $post_format = $post->post_format; $post_password = $post->post_password; $post_url = $post->post_url; $post_lang = $post->post_lang; $post_title = $post->post_title; $post_excerpt = $post->post_excerpt; $post_excerpt_xhtml = $post->post_excerpt_xhtml; $post_content = $post->post_content; $post_content_xhtml = $post->post_content_xhtml; $post_notes = $post->post_notes; $post_status = $post->post_status; $post_position = (integer) $post->post_position; $post_open_comment = (boolean) $post->post_open_comment; $post_open_tb = (boolean) $post->post_open_tb; $post_selected = (boolean) $post->post_selected; $page_title = __('Edit page'); $can_edit_page = $post->isEditable(); $can_delete = $post->isDeletable(); $next_rs = $core->blog->getNextPost($post, 1); $prev_rs = $core->blog->getNextPost($post, -1); if ($next_rs !== null) { $next_link = sprintf($post_link, $next_rs->post_id, html::escapeHTML($next_rs->post_title), __('Next page') . ' »'); $next_headlink = sprintf($post_headlink, 'next', html::escapeHTML($next_rs->post_title), $next_rs->post_id); } if ($prev_rs !== null) { $prev_link = sprintf($post_link, $prev_rs->post_id, html::escapeHTML($prev_rs->post_title), '« ' . __('Previous page')); $prev_headlink = sprintf($post_headlink, 'previous', html::escapeHTML($prev_rs->post_title), $prev_rs->post_id); } try { $core->media = new dcMedia($core); $post_media = $core->media->getPostMedia($post_id); } catch (Exception $e) { $core->error->add($e->getMessage()); } } } # Format content if (!empty($_POST) && $can_edit_page) { $post_format = $_POST['post_format']; $post_excerpt = $_POST['post_excerpt']; $post_content = $_POST['post_content']; $post_title = $_POST['post_title']; if (isset($_POST['post_status'])) { $post_status = (integer) $_POST['post_status']; } if (empty($_POST['post_dt'])) { $post_dt = ''; } else { try { $post_dt = strtotime($_POST['post_dt']); if ($post_dt == false || $post_dt == -1) { $bad_dt = true; throw new Exception(__('Invalid publication date')); } $post_dt = date('Y-m-d H:i', $post_dt); } catch (Exception $e) { $core->error->add($e->getMessage()); } } $post_open_comment = !empty($_POST['post_open_comment']); $post_open_tb = !empty($_POST['post_open_tb']); $post_selected = !empty($_POST['post_selected']); $post_lang = $_POST['post_lang']; $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; $post_position = (integer) $_POST['post_position']; $post_notes = $_POST['post_notes']; if (isset($_POST['post_url'])) { $post_url = $_POST['post_url']; } $core->blog->setPostContent( $post_id, $post_format, $post_lang, $post_excerpt, $post_excerpt_xhtml, $post_content, $post_content_xhtml ); } # Delete page if (!empty($_POST['delete']) && $can_delete) { try { # --BEHAVIOR-- adminBeforePageDelete $core->callBehavior('adminBeforePageDelete', $post_id); $core->blog->delPost($post_id); http::redirect($p_url); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Create or update page if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page && !$bad_dt) { $cur = $core->con->openCursor($core->prefix . 'post'); # Magic tweak :) $core->blog->settings->system->post_url_format = $page_url_format; $cur->post_type = 'page'; $cur->post_title = $post_title; $cur->post_dt = $post_dt ? date('Y-m-d H:i:00', strtotime($post_dt)) : ''; $cur->post_format = $post_format; $cur->post_password = $post_password; $cur->post_lang = $post_lang; $cur->post_title = $post_title; $cur->post_excerpt = $post_excerpt; $cur->post_excerpt_xhtml = $post_excerpt_xhtml; $cur->post_content = $post_content; $cur->post_content_xhtml = $post_content_xhtml; $cur->post_notes = $post_notes; $cur->post_status = $post_status; $cur->post_position = $post_position; $cur->post_open_comment = (integer) $post_open_comment; $cur->post_open_tb = (integer) $post_open_tb; $cur->post_selected = (integer) $post_selected; if (isset($_POST['post_url'])) { $cur->post_url = $post_url; } # Update post if ($post_id) { try { # --BEHAVIOR-- adminBeforePageUpdate $core->callBehavior('adminBeforePageUpdate', $cur, $post_id); $core->blog->updPost($post_id, $cur); # --BEHAVIOR-- adminAfterPageUpdate $core->callBehavior('adminAfterPageUpdate', $cur, $post_id); http::redirect($redir_url . '&id=' . $post_id . '&upd=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } else { $cur->user_id = $core->auth->userID(); try { # --BEHAVIOR-- adminBeforePageCreate $core->callBehavior('adminBeforePageCreate', $cur); $return_id = $core->blog->addPost($cur); # --BEHAVIOR-- adminAfterPageCreate $core->callBehavior('adminAfterPageCreate', $cur, $return_id); http::redirect($redir_url . '&id=' . $return_id . '&crea=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } } /* DISPLAY -------------------------------------------------------- */ $default_tab = 'edit-entry'; if (!$can_edit_page) { $default_tab = ''; } if (!empty($_GET['co'])) { $default_tab = 'comments'; } $admin_post_behavior = ''; if ($post_editor) { $p_edit = $c_edit = ''; if (!empty($post_editor[$post_format])) { $p_edit = $post_editor[$post_format]; } if (!empty($post_editor['xhtml'])) { $c_edit = $post_editor['xhtml']; } if ($p_edit == $c_edit) { $admin_post_behavior .= $core->callBehavior('adminPostEditor', $p_edit, 'page', array('#post_excerpt', '#post_content', '#comment_content'), $post_format); } else { $admin_post_behavior .= $core->callBehavior('adminPostEditor', $p_edit, 'page', array('#post_excerpt', '#post_content'), $post_format); $admin_post_behavior .= $core->callBehavior('adminPostEditor', $c_edit, 'comment', array('#comment_content'), 'xhtml'); } } ?> <?php echo $page_title . ' - ' . __('Pages'); ?> callBehavior('adminPageHeaders') . dcPage::jsPageTabs($default_tab) . $next_headlink . "\n" . $prev_headlink; ?> blog->name) => '', __('Pages') => $p_url, $edit_entry_title => '' )); if (!empty($_GET['upd'])) { dcPage::success(__('Page has been successfully updated.')); } elseif (!empty($_GET['crea'])) { dcPage::success(__('Page has been successfully created.')); } elseif (!empty($_GET['attached'])) { dcPage::success(__('File has been successfully attached.')); } elseif (!empty($_GET['rmattach'])) { dcPage::success(__('Attachment has been successfully removed.')); } # XHTML conversion if (!empty($_GET['xconv'])) { $post_excerpt = $post_excerpt_xhtml; $post_content = $post_content_xhtml; $post_format = 'xhtml'; dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); } if ($post_id && $post->post_status == 1) { echo '

' . __('Go to this page on the site') . '

'; } echo ''; if ($post_id) { echo ''; } # Exit if we cannot view page if (!$can_view_page) { echo ''; return; } /* Post form if we can edit page -------------------------------------------------------- */ if ($can_edit_page) { $sidebar_items = new ArrayObject(array( 'status-box' => array( 'title' => __('Status'), 'items' => array( 'post_status' => '

' . form::combo('post_status', $status_combo, array('default' => $post_status, 'disabled' => !$can_publish)) . '

', 'post_dt' => '

' . form::field('post_dt', 16, 16, $post_dt, ($bad_dt ? 'invalid' : '')) . /* Previous line will be replaced by this one as soon as every browser will support datetime-local input type Dont forget to remove call to datepicker in post.js form::datetime('post_dt', array( 'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($post_dt))), 'class' => ($bad_dt ? 'invalid' : '') )) . */ '

', 'post_lang' => '

' . form::combo('post_lang', $lang_combo, $post_lang) . '

', 'post_format' => '
' . '
' . '

' . form::combo('post_format', $available_formats, $post_format, 'maximal') . '

' . '

' . '' . __('Convert to XHTML') . '

')), 'metas-box' => array( 'title' => __('Filing'), 'items' => array( 'post_position' => '

' . form::number('post_position', array( 'default' => $post_position )) . '

')), 'options-box' => array( 'title' => __('Options'), 'items' => array( 'post_open_comment_tb' => '
' . '
' . __('Comments and trackbacks list') . '
' . '

' . ($core->blog->settings->system->allow_comments ? (isContributionAllowed($post_id, strtotime($post_dt), true) ? '' : '

' . __('Warning: Comments are not more accepted for this entry.') . '

') : '

' . __('Comments are not accepted on this blog so far.') . '

') . '

' . ($core->blog->settings->system->allow_trackbacks ? (isContributionAllowed($post_id, strtotime($post_dt), false) ? '' : '

' . __('Warning: Trackbacks are not more accepted for this entry.') . '

') : '

' . __('Trackbacks are not accepted on this blog so far.') . '

') . '
', 'post_hide' => '

' . '

', 'post_password' => '

' . form::field('post_password', 10, 32, html::escapeHTML($post_password), 'maximal') . '

', 'post_url' => '
' . '

' . form::field('post_url', 10, 255, html::escapeHTML($post_url), 'maximal') . '

' . '

' . __('Warning: If you set the URL manually, it may conflict with another page.') . '

' )))); $main_items = new ArrayObject(array( "post_title" => '

' . '' . form::field('post_title', 20, 255, array( 'default' => html::escapeHTML($post_title), 'class' => 'maximal', 'extra_html' => 'required placeholder="' . __('Title') . '"' )) . '

', "post_excerpt" => '

' . form::textarea('post_excerpt', 50, 5, html::escapeHTML($post_excerpt)) . '

', "post_content" => '

' . form::textarea('post_content', 50, $core->auth->getOption('edit_size'), array( 'default' => html::escapeHTML($post_content), 'extra_html' => 'required placeholder="' . __('Content') . '"' )) . '

', "post_notes" => '

' . form::textarea('post_notes', 50, 5, html::escapeHTML($post_notes)) . '

' ) ); # --BEHAVIOR-- adminPostFormItems $core->callBehavior('adminPageFormItems', $main_items, $sidebar_items, isset($post) ? $post : null); echo '
'; echo '
'; echo '
'; echo '
'; echo '

' . __('Edit page') . '

'; foreach ($main_items as $id => $item) { echo $item; } # --BEHAVIOR-- adminPageForm $core->callBehavior('adminPageForm', isset($post) ? $post : null); echo '

' . ($post_id ? form::hidden('id', $post_id) : '') . ' '; if ($post_id) { $preview_url = $core->blog->url . $core->url->getURLFor('pagespreview', $core->auth->userID() . '/' . http::browserUID(DC_MASTER_KEY . $core->auth->userID() . $core->auth->cryptLegacy($core->auth->userID())) . '/' . $post->post_url); echo '' . __('Preview') . ' (p)' . ''; } else { echo '' . __('Cancel') . ' (c)'; } echo ($can_delete ? ' ' : '') . $core->formNonce() . '

'; echo '
'; // End #entry-content echo '
'; // End #entry-wrapper echo ''; // End #entry-sidebar echo '
'; # --BEHAVIOR-- adminPostForm $core->callBehavior('adminPageAfterForm', isset($post) ? $post : null); echo '
'; // End if ($post_id && !empty($post_media)) { echo '
' . '
' . form::hidden(array('post_id'), $post_id) . form::hidden(array('media_id'), '') . form::hidden(array('remove'), 1) . $core->formNonce() . '
'; } } /* Comments and trackbacks -------------------------------------------------------- */ if ($post_id) { $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); $comments = $core->blog->getComments(array_merge($params, array('comment_trackback' => 0))); $trackbacks = $core->blog->getComments(array_merge($params, array('comment_trackback' => 1))); # Actions combo box $combo_action = array(); if ($can_edit_page && $core->auth->check('publish,contentadmin', $core->blog->id)) { $combo_action[__('Publish')] = 'publish'; $combo_action[__('Unpublish')] = 'unpublish'; $combo_action[__('Mark as pending')] = 'pending'; $combo_action[__('Mark as junk')] = 'junk'; } if ($can_edit_page && $core->auth->check('delete,contentadmin', $core->blog->id)) { $combo_action[__('Delete')] = 'delete'; } $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); echo '
'; echo '

' . __('Add a comment') . '

'; if ($has_action) { echo '
'; } echo '

' . __('Trackbacks') . '

'; if (!$trackbacks->isEmpty()) { showComments($trackbacks, $has_action); } else { echo '

' . __('No trackback') . '

'; } echo '

' . __('Comments') . '

'; if (!$comments->isEmpty()) { showComments($comments, $has_action); } else { echo '

' . __('No comments') . '

'; } if ($has_action) { echo '
' . '

' . '

' . form::combo('action', $combo_action) . form::hidden('redir', html::escapeURL($redir_url) . '&id=' . $post_id . '&co=1') . $core->formNonce() . '

' . '
' . '
'; } /* Add a comment -------------------------------------------------------- */ echo '
' . '

' . __('Add a comment') . '

' . '
' . '
' . '

' . form::field('comment_author', 30, 255, array( 'default' => html::escapeHTML($core->auth->getInfo('user_cn')), 'extra_html' => 'required placeholder="' . __('Author') . '"' )) . '

' . '

' . form::email('comment_email', array( 'size' => 30, 'default' => html::escapeHTML($core->auth->getInfo('user_email')), 'autocomplete' => 'email' )) . '

' . '

' . form::url('comment_site', array( 'size' => 30, 'default' => html::escapeHTML($core->auth->getInfo('user_url')), 'autocomplete' => 'url' )) . '

' . '

' . form::textarea('comment_content', 50, 8, array('extra_html' => 'required placeholder="' . __('Comment') . '"')) . '

' . '

' . form::hidden('post_id', $post_id) . $core->formNonce() . '

' . '
' . #constrained '
' . '
' . #add comment '
'; #comments } # Controls comments or trakbacks capabilities function isContributionAllowed($id, $dt, $com = true) { global $core; if (!$id) { return true; } if ($com) { if (($core->blog->settings->system->comments_ttl == 0) || (time() - $core->blog->settings->system->comments_ttl * 86400 < $dt)) { return true; } } else { if (($core->blog->settings->system->trackbacks_ttl == 0) || (time() - $core->blog->settings->system->trackbacks_ttl * 86400 < $dt)) { return true; } } return false; } # Show comments or trackbacks function showComments($rs, $has_action) { global $core; echo '' . '' . '' . '' . '' . '' . ''; while ($rs->fetch()) { $comment_url = $core->adminurl->get('admin.comment', array('id' => $rs->comment_id)); $img = '%1$s'; switch ($rs->comment_status) { case 1: $img_status = sprintf($img, __('Published'), 'check-on.png'); break; case 0: $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); break; case -1: $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); break; case -2: $img_status = sprintf($img, __('Junk'), 'junk.png'); break; } echo '' . '' . '' . '' . '' . '' . '' . ''; } echo '
' . __('Author') . '' . __('Date') . '' . __('IP address') . '' . __('Status') . '' . __('Edit') . '
' . ($has_action ? form::checkbox(array('comments[]'), $rs->comment_id, array( 'extra_html' => 'title="' . __('Select this comment') . '"' ) ) : '') . '' . $rs->comment_author . '' . dt::dt2str(__('%Y-%m-%d %H:%M'), $rs->comment_dt) . '' . $rs->comment_ip . '' . $img_status . '' . ' ' . __('Edit') . '
'; } dcPage::helpBlock('page', 'core_wiki'); ?>