mirror of
https://github.com/typecho/typecho.git
synced 2025-04-22 10:43:57 +02:00
Add function: mark status of multi posts.
This commit is contained in:
parent
586492e1b8
commit
26b70e2af8
@ -18,6 +18,8 @@ $stat = Typecho_Widget::widget('Widget_Stat');
|
||||
<button class="btn dropdown-toggle btn-s" type="button"><i class="sr-only"><?php _e('操作'); ?></i><?php _e('选中项'); ?> <i class="i-caret-down"></i></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a lang="<?php _e('你确认要删除这些页面吗?'); ?>" href="<?php $security->index('/action/contents-page-edit?do=delete'); ?>"><?php _e('删除'); ?></a></li>
|
||||
<li><a href="<?php $security->index('/action/contents-page-edit?do=mark&status=publish'); ?>"><?php _e('标记为<strong>%s</strong>', _t('公开')); ?></a></li>
|
||||
<li><a href="<?php $security->index('/action/contents-page-edit?do=mark&status=hidden'); ?>"><?php _e('标记为<strong>%s</strong>', _t('隐藏')); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -53,6 +53,10 @@ $isAllPosts = ('on' == $request->get('__typecho_all_posts') || 'on' == Typecho_C
|
||||
<button class="btn dropdown-toggle btn-s" type="button"><i class="sr-only"><?php _e('操作'); ?></i><?php _e('选中项'); ?> <i class="i-caret-down"></i></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a lang="<?php _e('你确认要删除这些文章吗?'); ?>" href="<?php $security->index('/action/contents-post-edit?do=delete'); ?>"><?php _e('删除'); ?></a></li>
|
||||
<li><a href="<?php $security->index('/action/contents-post-edit?do=mark&status=publish'); ?>"><?php _e('标记为<strong>%s</strong>', _t('公开')); ?></a></li>
|
||||
<li><a href="<?php $security->index('/action/contents-post-edit?do=mark&status=waiting'); ?>"><?php _e('标记为<strong>%s</strong>', _t('待审核')); ?></a></li>
|
||||
<li><a href="<?php $security->index('/action/contents-post-edit?do=mark&status=hidden'); ?>"><?php _e('标记为<strong>%s</strong>', _t('隐藏')); ?></a></li>
|
||||
<li><a href="<?php $security->index('/action/contents-post-edit?do=mark&status=private'); ?>"><?php _e('标记为<strong>%s</strong>', _t('私密')); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -227,7 +227,7 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
|
||||
->where('table.contents.cid = ?', $post)
|
||||
->limit(1), array($this, 'push'));
|
||||
|
||||
if ($this->isWriteable($condition) && $this->delete($condition)) {
|
||||
if ($this->isWriteable(clone $condition) && $this->delete($condition)) {
|
||||
/** 删除文件 */
|
||||
Widget_Upload::deleteHandle($row);
|
||||
|
||||
@ -285,7 +285,7 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
|
||||
->where('table.contents.cid = ?', $post)
|
||||
->limit(1), array($this, 'push'));
|
||||
|
||||
if ($this->isWriteable($condition) && $this->delete($condition)) {
|
||||
if ($this->isWriteable(clone $condition) && $this->delete($condition)) {
|
||||
/** 删除文件 */
|
||||
Widget_Upload::deleteHandle($row);
|
||||
|
||||
|
@ -126,6 +126,50 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记页面
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function markPage()
|
||||
{
|
||||
$status = $this->request->get('status');
|
||||
$statusList = array(
|
||||
'publish' => _t('公开'),
|
||||
'hidden' => _t('隐藏')
|
||||
);
|
||||
|
||||
if (!isset($statusList[$status])) {
|
||||
$this->response->goBack();
|
||||
}
|
||||
|
||||
$pages = $this->request->filter('int')->getArray('cid');
|
||||
$markCount = 0;
|
||||
|
||||
foreach ($pages as $page) {
|
||||
// 标记插件接口
|
||||
$this->pluginHandle()->mark($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);
|
||||
|
||||
$markCount ++;
|
||||
}
|
||||
|
||||
unset($condition);
|
||||
}
|
||||
|
||||
/** 设置提示信息 */
|
||||
$this->widget('Widget_Notice')->set($markCount > 0 ? _t('页面已经被标记为<strong>%s</strong>', $statusList[$status]) : _t('没有页面被标记'),
|
||||
$deleteCount > 0 ? 'success' : 'notice');
|
||||
|
||||
/** 返回原网页 */
|
||||
$this->response->goBack();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除页面
|
||||
*
|
||||
@ -256,6 +300,7 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
|
||||
$this->security->protect();
|
||||
$this->on($this->request->is('do=publish') || $this->request->is('do=save'))->writePage();
|
||||
$this->on($this->request->is('do=delete'))->deletePage();
|
||||
$this->on($this->request->is('do=mark'))->markPage();
|
||||
$this->on($this->request->is('do=deleteDraft'))->deletePageDraft();
|
||||
$this->on($this->request->is('do=sort'))->sortPage();
|
||||
$this->response->redirect($this->options->adminUrl);
|
||||
|
@ -785,6 +785,60 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记文章
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function markPost()
|
||||
{
|
||||
$status = $this->request->get('status');
|
||||
$statusList = array(
|
||||
'publish' => _t('公开'),
|
||||
'private' => _t('私密'),
|
||||
'hidden' => _t('隐藏'),
|
||||
'waiting' => _t('待审核')
|
||||
);
|
||||
|
||||
if (!isset($statusList[$status])) {
|
||||
$this->response->goBack();
|
||||
}
|
||||
|
||||
$posts = $this->request->filter('int')->getArray('cid');
|
||||
$markCount = 0;
|
||||
|
||||
foreach ($posts as $post) {
|
||||
// 标记插件接口
|
||||
$this->pluginHandle()->mark($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'));
|
||||
|
||||
if ($this->isWriteable(clone $condition) &&
|
||||
$postObject) {
|
||||
|
||||
/** 标记状态 */
|
||||
$this->db->query($condition->update('table.contents')->rows(array('status' => $status)));
|
||||
|
||||
// 完成标记插件接口
|
||||
$this->pluginHandle()->finishMark($post, $this);
|
||||
|
||||
$markCount ++;
|
||||
}
|
||||
|
||||
unset($condition);
|
||||
}
|
||||
|
||||
/** 设置提示信息 */
|
||||
$this->widget('Widget_Notice')->set($markCount > 0 ? _t('文章已经被标记为<strong>%s</strong>', $statusList[$status]) : _t('没有文章被标记'),
|
||||
$deleteCount > 0 ? 'success' : 'notice');
|
||||
|
||||
/** 返回原网页 */
|
||||
$this->response->goBack();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
*
|
||||
@ -804,7 +858,7 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
$postObject = $this->db->fetchObject($this->db->select('status', 'type')
|
||||
->from('table.contents')->where('cid = ? AND type = ?', $post, 'post'));
|
||||
|
||||
if ($this->isWriteable($condition) &&
|
||||
if ($this->isWriteable(clone $condition) &&
|
||||
$postObject &&
|
||||
$this->delete($condition)) {
|
||||
|
||||
@ -905,6 +959,7 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
$this->security->protect();
|
||||
$this->on($this->request->is('do=publish') || $this->request->is('do=save'))->writePost();
|
||||
$this->on($this->request->is('do=delete'))->deletePost();
|
||||
$this->on($this->request->is('do=mark'))->markPost();
|
||||
$this->on($this->request->is('do=deleteDraft'))->deletePostDraft();
|
||||
|
||||
$this->response->redirect($this->options->adminUrl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user