fix error
This commit is contained in:
@@ -70,7 +70,7 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
|
||||
<div id="tab-advance" class="tab-content">
|
||||
<section class="typecho-post-option" role="application">
|
||||
<label for="date" class="typecho-label"><?php _e('发布日期'); ?></label>
|
||||
<p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off" value="<?php $page->have() ? $page->date('Y-m-d H:i') : ''; ?>" /></p>
|
||||
<p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off" value="<?php $page->have() && $page->created > 0 ? $page->date('Y-m-d H:i') : ''; ?>" /></p>
|
||||
</section>
|
||||
|
||||
<section class="typecho-post-option">
|
||||
|
||||
@@ -77,7 +77,7 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
|
||||
<div id="tab-advance" class="tab-content">
|
||||
<section class="typecho-post-option" role="application">
|
||||
<label for="date" class="typecho-label"><?php _e('发布日期'); ?></label>
|
||||
<p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off" value="<?php $post->have() ? $post->date('Y-m-d H:i') : ''; ?>" /></p>
|
||||
<p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off" value="<?php $post->have() && $post->created > 0 ? $post->date('Y-m-d H:i') : ''; ?>" /></p>
|
||||
</section>
|
||||
|
||||
<section class="typecho-post-option category-option">
|
||||
|
||||
@@ -232,7 +232,8 @@ class Widget_Abstract_Contents extends Widget_Abstract
|
||||
{
|
||||
$select = $this->db->select(array('COUNT(table.contents.cid)' => 'num'))->from('table.contents')
|
||||
->where("table.contents.{$column} > {$offset}")
|
||||
->where("table.contents.type = ?", $type);
|
||||
->where("table.contents.type = ? OR (table.contents.type = ? AND table.contents.parent = ?)",
|
||||
$type, $type . '_draft', 0);
|
||||
|
||||
if (!empty($status)) {
|
||||
$select->where("table.contents.status = ?", $status);
|
||||
@@ -272,7 +273,7 @@ class Widget_Abstract_Contents extends Widget_Abstract
|
||||
/** 构建插入结构 */
|
||||
$insertStruct = array(
|
||||
'title' => !isset($content['title']) || strlen($content['title']) === 0 ? NULL : htmlspecialchars($content['title']),
|
||||
'created' => empty($content['created']) ? $this->options->time : $content['created'],
|
||||
'created' => !isset($content['created']) ? $this->options->time : $content['created'],
|
||||
'modified' => $this->options->time,
|
||||
'text' => !isset($content['text']) || strlen($content['text']) === 0 ? NULL : $content['text'],
|
||||
'order' => empty($content['order']) ? 0 : intval($content['order']),
|
||||
@@ -341,7 +342,7 @@ class Widget_Abstract_Contents extends Widget_Abstract
|
||||
}
|
||||
|
||||
/** 更新创建时间 */
|
||||
if (!empty($content['created'])) {
|
||||
if (isset($content['created'])) {
|
||||
$updateStruct['created'] = $content['created'];
|
||||
}
|
||||
|
||||
|
||||
@@ -149,12 +149,12 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
|
||||
|
||||
foreach ($pages as $page) {
|
||||
// 标记插件接口
|
||||
$this->pluginHandle()->mark($page, $this);
|
||||
$this->pluginHandle()->mark($status, $page, $this);
|
||||
$condition = $this->db->sql()->where('cid = ?', $page);
|
||||
|
||||
if ($this->db->query($condition->update('table.contents')->rows(array('status' => $status)))) {
|
||||
// 完成标记插件接口
|
||||
$this->pluginHandle()->finishMark($page, $this);
|
||||
$this->pluginHandle()->finishMark($status, $page, $this);
|
||||
|
||||
$markCount ++;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class Widget_Contents_Post_Admin extends Widget_Abstract_Contents
|
||||
$this->_countSql = clone $select;
|
||||
|
||||
/** 提交查询 */
|
||||
$select->order('table.contents.created', Typecho_Db::SORT_DESC)
|
||||
$select->order('table.contents.cid', Typecho_Db::SORT_DESC)
|
||||
->page($this->_currentPage, $this->parameter->pageSize);
|
||||
|
||||
$this->db->fetchAll($select, array($this, 'push'));
|
||||
|
||||
@@ -145,9 +145,12 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
$day = intval($this->request->day);
|
||||
|
||||
$created = mktime($hour, $min, $second, $month, $day, $year) - $this->options->timezone + $this->options->serverTimezone;
|
||||
} else if ($this->request->is('cid')) {
|
||||
} else if ($this->have() && $this->created > 0) {
|
||||
//如果是修改文章
|
||||
$created = $this->created;
|
||||
} else if ($this->request->is('do=save')) {
|
||||
// 如果是草稿而且没有任何输入则保持原状
|
||||
$created = 0;
|
||||
}
|
||||
|
||||
return $created;
|
||||
@@ -188,13 +191,13 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
* 获取页面偏移的URL Query
|
||||
*
|
||||
* @access protected
|
||||
* @param integer $created 创建时间
|
||||
* @param integer $cid 文章id
|
||||
* @param string $status 状态
|
||||
* @return string
|
||||
*/
|
||||
protected function getPageOffsetQuery($created, $status = NULL)
|
||||
protected function getPageOffsetQuery($cid, $status = NULL)
|
||||
{
|
||||
return 'page=' . $this->getPageOffset('created', $created, 'post', $status,
|
||||
return 'page=' . $this->getPageOffset('cid', $cid, 'post', $status,
|
||||
'on' == $this->request->__typecho_all_posts ? 0 : $this->user->uid);
|
||||
}
|
||||
|
||||
@@ -755,7 +758,7 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
$this->widget('Widget_Notice')->highlight($this->theId);
|
||||
|
||||
/** 获取页面偏移 */
|
||||
$pageQuery = $this->getPageOffsetQuery($this->created);
|
||||
$pageQuery = $this->getPageOffsetQuery($this->cid);
|
||||
|
||||
/** 页面跳转 */
|
||||
$this->response->redirect(Typecho_Common::url('manage-posts.php?' . $pageQuery, $this->options->adminUrl));
|
||||
@@ -810,20 +813,40 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
|
||||
foreach ($posts as $post) {
|
||||
// 标记插件接口
|
||||
$this->pluginHandle()->mark($post, $this);
|
||||
$this->pluginHandle()->mark($status, $post, $this);
|
||||
|
||||
$condition = $this->db->sql()->where('cid = ?', $post);
|
||||
$postObject = $this->db->fetchObject($this->db->select('status', 'type')
|
||||
->from('table.contents')->where('cid = ? AND type = ?', $post, 'post'));
|
||||
->from('table.contents')->where('cid = ? AND (type = ? OR type = ?)', $post, 'post', 'post_draft'));
|
||||
|
||||
if ($this->isWriteable(clone $condition) &&
|
||||
$postObject) {
|
||||
count((array) $postObject)) {
|
||||
|
||||
/** 标记状态 */
|
||||
$this->db->query($condition->update('table.contents')->rows(array('status' => $status)));
|
||||
|
||||
// 刷新Metas
|
||||
if ($postObject->type == 'post') {
|
||||
$op = NULL;
|
||||
|
||||
if ($status == 'publish' && $postObject->status != 'publish') {
|
||||
$op = '+';
|
||||
} else if ($status != 'publish' && $postObject->status == 'publish') {
|
||||
$op = '-';
|
||||
}
|
||||
|
||||
if (!empty($op)) {
|
||||
$metas = $this->db->fetchAll($this->db->select()->from('table.relationships')->where('cid = ?', $post));
|
||||
foreach ($metas as $meta) {
|
||||
$this->db->query($this->db->update('table.metas')
|
||||
->expression('count', 'count ' . $op . ' 1')
|
||||
->where('mid = ? AND (type = ? OR type = ?)', $meta['mid'], 'category', 'tag'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 完成标记插件接口
|
||||
$this->pluginHandle()->finishMark($post, $this);
|
||||
$this->pluginHandle()->finishMark($status, $post, $this);
|
||||
|
||||
$markCount ++;
|
||||
}
|
||||
@@ -856,10 +879,10 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
|
||||
$condition = $this->db->sql()->where('cid = ?', $post);
|
||||
$postObject = $this->db->fetchObject($this->db->select('status', 'type')
|
||||
->from('table.contents')->where('cid = ? AND type = ?', $post, 'post'));
|
||||
->from('table.contents')->where('cid = ? AND (type = ? OR type = ?)', $post, 'post', 'post_draft'));
|
||||
|
||||
if ($this->isWriteable(clone $condition) &&
|
||||
$postObject &&
|
||||
count((array) $postObject) &&
|
||||
$this->delete($condition)) {
|
||||
|
||||
/** 删除分类 */
|
||||
|
||||
Reference in New Issue
Block a user