This commit is contained in:
fen 2013-10-15 15:08:36 +08:00
commit 8fad2f0ebb
7 changed files with 22 additions and 23 deletions

View File

@ -71,7 +71,7 @@ $stat = Typecho_Widget::widget('Widget_Stat');
<td>
<a href="<?php $options->adminUrl('write-post.php?cid=' . $posts->cid); ?>"><?php $posts->title(); ?></a>
<?php
if ($posts->hasSaved() || 'post_draft' == $posts->type) {
if ($posts->hasSaved || 'post_draft' == $posts->type) {
echo '<em>(' . _t('草稿') . ')</em>';
} else if ('waiting' == $posts->status) {
echo '<em>(' . _t('待审核') . ')</em>';

View File

@ -128,6 +128,7 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
<?php
include 'copyright.php';
include 'common-js.php';
include 'form-js.php';
include 'write-js.php';
include 'file-upload-js.php';

View File

@ -57,7 +57,7 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
<div class="col-mb-12 col-tb-3">
<section class="typecho-post-option">
<label for="date" class="typecho-label"><?php _e('发布日期'); ?></label>
<p><input class="typecho-date w-100" type="text" name="date" id="date" value="<?php $post->date(); ?>" /></p>
<p><input class="typecho-date w-100" type="text" name="date" id="date" value="<?php $post->have() ? $post->date('Y-m-d H:i') : ''; ?>" /></p>
</section>
<section class="typecho-post-option category-option">
@ -139,6 +139,7 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
<?php
include 'copyright.php';
include 'common-js.php';
include 'form-js.php';
include 'write-js.php';
include 'file-upload-js.php';

View File

@ -345,10 +345,10 @@ class Widget_Abstract_Contents extends Widget_Abstract
$result = $slug;
/** 对草稿的slug做特殊处理 */
$draft = $this->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;
}

View File

@ -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)) {

View File

@ -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) {

View File

@ -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) {