auth->getOption('post_format'); $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_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 foreach ($core->blog->getAllPostStatus() as $k => $v) { $status_combo[$v] = (string) $k; } # Formaters combo foreach ($core->getFormaters() as $v) { $formaters_combo[$v] = $v; } # Languages combo $rs = $core->blog->getLangs(array('order'=>'asc')); $all_langs = l10n::getISOcodes(0,1); $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); while ($rs->fetch()) { if (isset($all_langs[$rs->post_lang])) { $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); } else { $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; } } unset($all_langs); unset($rs); # 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; $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) {} } } # 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 { $post_dt = strtotime($_POST['post_dt']); $post_dt = date('Y-m-d H:i',$post_dt); } $post_open_comment = !empty($_POST['post_open_comment']); $post_open_tb = !empty($_POST['post_open_tb']); $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 ); } # Create or update post if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page) { $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; 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()); } } } 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()); } } /* DISPLAY -------------------------------------------------------- */ $default_tab = 'edit-entry'; if (!$can_edit_page) { $default_tab = ''; } if (!empty($_GET['co'])) { $default_tab = 'comments'; } ?>
'.__('Go to this page on the site').'
'; if ($prev_link) { echo $prev_link; } if ($next_link && $prev_link) { echo ' - '; } if ($next_link) { echo $next_link; } # --BEHAVIOR-- adminPageNavLinks $core->callBehavior('adminPageNavLinks',isset($post) ? $post : null); echo '
'; } # Exit if we cannot view page if (!$can_view_page) { echo ''; return; } /* Post form if we can edit post -------------------------------------------------------- */ if ($can_edit_page) { echo ''.__('Author').' | '. ''.__('Date').' | '. ''.__('IP address').' | '. ''.__('Status').' | '. ''. ' | |
---|---|---|---|---|---|
'. ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.__('select this comment').'"') : '').' | '. ''.$rs->comment_author.' | '. ''.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).' | '. ''.$rs->comment_ip.' | '. ''.$img_status.' | '. ''.
'![]() | '.
'