diff --git a/admin/manage-posts.php b/admin/manage-posts.php
index c376999b..4eecb03d 100644
--- a/admin/manage-posts.php
+++ b/admin/manage-posts.php
@@ -71,7 +71,7 @@ $stat = Typecho_Widget::widget('Widget_Stat');
title(); ?>
hasSaved() || 'post_draft' == $posts->type) {
+ if ($posts->hasSaved || 'post_draft' == $posts->type) {
echo '(' . _t('草稿') . ')';
} else if ('waiting' == $posts->status) {
echo '(' . _t('待审核') . ')';
diff --git a/admin/write-page.php b/admin/write-page.php
index 5711a2ab..b1950695 100644
--- a/admin/write-page.php
+++ b/admin/write-page.php
@@ -128,6 +128,7 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
to($post);
@@ -144,6 +144,7 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
db->fetchObject($this->db->select('status', 'parent')
+ $draft = $this->db->fetchObject($this->db->select('type', 'parent')
->from('table.contents')->where('cid = ?', $cid));
- if ('draft' == $draft->status && $draft->parent) {
+ if ('_draft' == substr($draft->type, -6) && $draft->parent) {
$result = '@' . $result;
}
diff --git a/var/Widget/Contents/Page/Admin.php b/var/Widget/Contents/Page/Admin.php
index 0fdc8573..c478f162 100644
--- a/var/Widget/Contents/Page/Admin.php
+++ b/var/Widget/Contents/Page/Admin.php
@@ -27,12 +27,8 @@ class Widget_Contents_Page_Admin extends Widget_Contents_Post_Admin
*/
public function execute()
{
- /** 构建基础查询 */
- $select = $this->select()->where('table.contents.type = ?', 'page');
-
/** 过滤状态 */
- $select->where('table.contents.status = ? OR table.contents.status = ? OR (table.contents.status = ? AND table.contents.parent = 0)',
- 'publish', 'waiting', 'draft');
+ $select = $this->select()->where('table.contents.type = ? OR (table.contents.type = ? AND table.contents.parent = ?)', 'page', 'page_draft', 0);
/** 过滤标题 */
if (NULL != ($keywords = $this->request->keywords)) {
diff --git a/var/Widget/Contents/Page/Edit.php b/var/Widget/Contents/Page/Edit.php
index 636398f8..70f1048a 100644
--- a/var/Widget/Contents/Page/Edit.php
+++ b/var/Widget/Contents/Page/Edit.php
@@ -35,11 +35,11 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
if (!empty($this->request->cid) && 'delete' != $this->request->do
&& 'sort' != $this->request->do) {
$this->db->fetchRow($this->select()
- ->where('table.contents.type = ?', 'page')
+ ->where('table.contents.type = ? OR table.contents.type = ?', 'page', 'page_draft')
->where('table.contents.cid = ?', $this->request->filter('int')->cid)
->limit(1), array($this, 'push'));
- if ('draft' == $this->status && $this->parent) {
+ if ('page_draft' == $this->status && $this->parent) {
$this->response->redirect(Typecho_Common::url('write-page.php?cid=' . $this->parent, $this->options->adminUrl));
}
@@ -61,14 +61,14 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
{
$contents = $this->request->from('text', 'template', 'allowComment',
'allowPing', 'allowFeed', 'slug', 'order');
- $contents['type'] = 'page';
$contents['title'] = $this->request->get('title', _t('未命名页面'));
$contents['created'] = $this->getCreated();
$contents = $this->pluginHandle()->write($contents, $this);
- if ($this->request->is('do=publish')) {
+ if ($this->request->is('do=publish')) {
/** 重新发布已经存在的文章 */
+ $contents['type'] = 'page';
$this->publish($contents);
/** 发送ping */
@@ -85,6 +85,7 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
$this->response->redirect(Typecho_Common::url('manage-pages.php?', $this->options->adminUrl));
} else {
/** 保存文章 */
+ $contents['type'] = 'page_draft';
$this->save($contents);
if ($this->request->isAjax()) {
@@ -137,8 +138,8 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
/** 删除草稿 */
$draft = $this->db->fetchRow($this->db->select('cid')
->from('table.contents')
- ->where('table.contents.parent = ? AND table.contents.type = ? AND table.contents.status = ?',
- $page, 'page', 'draft')
+ ->where('table.contents.parent = ? AND table.contents.type = ?',
+ $page, 'page_draft')
->limit(1));
if ($draft) {
@@ -177,8 +178,8 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
/** 删除草稿 */
$draft = $this->db->fetchRow($this->db->select('cid')
->from('table.contents')
- ->where('table.contents.parent = ? AND table.contents.type = ? AND table.contents.status = ?',
- $page, 'page', 'draft')
+ ->where('table.contents.parent = ? AND table.contents.type = ?',
+ $page, 'page_draft')
->limit(1));
if ($draft) {
diff --git a/var/Widget/Contents/Post/Edit.php b/var/Widget/Contents/Post/Edit.php
index 114bed63..724ffc6a 100644
--- a/var/Widget/Contents/Post/Edit.php
+++ b/var/Widget/Contents/Post/Edit.php
@@ -343,15 +343,15 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
*/
public function filter(array $value)
{
- if ('post' == $value['type']) {
+ if ('post' == $value['type'] || 'page' == $value['type']) {
$draft = $this->db->fetchRow($this->widget('Widget_Abstract_Contents')->select()
- ->where('table.contents.parent = ? AND table.contents.type = ? AND table.contents.status = ?',
- $value['cid'], 'post_draft', $value['status'])
+ ->where('table.contents.parent = ? AND table.contents.type = ?',
+ $value['cid'], $value['type'] . '_draft')
->limit(1));
if (!empty($draft)) {
$draft['slug'] = ltrim($draft['slug'], '@');
- $draft['status'] = $value['status'];
+ $draft['type'] = $value['type'];
$draft = parent::filter($draft);
@@ -641,8 +641,8 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
/** 删除草稿 */
$draft = $this->db->fetchRow($this->db->select('cid')
->from('table.contents')
- ->where('table.contents.parent = ? AND table.contents.type = ? AND table.contents.status = ?',
- $post, 'post', 'draft')
+ ->where('table.contents.parent = ? AND table.contents.type = ?',
+ $post, 'post_draft')
->limit(1));
if ($draft) {
|