添加插件接口

根据issue #136的提议,在发布和删除内容后添加相应的插件接口,以实现一些特定的功能需求
This commit is contained in:
joyqi 2013-12-19 10:20:40 +08:00
parent a77eedd18f
commit a065afc55c
2 changed files with 23 additions and 0 deletions

View File

@ -85,6 +85,9 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
$contents['type'] = 'page';
$this->publish($contents);
// 完成发布插件接口
$this->pluginHandle()->finishPublish($contents, $this);
/** 发送ping */
$this->widget('Widget_Service')->sendPing($this->cid);
@ -101,6 +104,9 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
$contents['type'] = 'page_draft';
$this->save($contents);
// 完成发布插件接口
$this->pluginHandle()->finishSave($contents, $this);
if ($this->request->isAjax()) {
$created = new Typecho_Date($this->options->gmtTime);
$this->response->throwJson(array(
@ -133,6 +139,9 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
/** 格式化页面主键 */
$pages = is_array($cid) ? $cid : array($cid);
foreach ($pages as $page) {
// 删除插件接口
$this->pluginHandle->delete($page, $this);
if ($this->delete($this->db->sql()->where('cid = ?', $page))) {
/** 删除评论 */
$this->db->query($this->db->delete('table.comments')
@ -163,6 +172,9 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
$this->deleteFields($draft['cid']);
}
// 完成删除插件接口
$this->pluginHandle()->finishDelete($page, $this);
$deleteCount ++;
}
}

View File

@ -716,6 +716,9 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
$contents['type'] = 'post';
$this->publish($contents);
// 完成发布插件接口
$this->pluginHandle()->finishPublish($contents, $this);
/** 发送ping */
$trackback = array_unique(preg_split("/(\r|\n|\r\n)/", trim($this->request->trackback)));
$this->widget('Widget_Service')->sendPing($this->cid, $trackback);
@ -738,6 +741,9 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
$contents['type'] = 'post_draft';
$this->save($contents);
// 完成保存插件接口
$this->pluginHandle()->finishSave($contents, $this);
if ($this->request->isAjax()) {
$created = new Typecho_Date($this->options->gmtTime);
$this->response->throwJson(array(
@ -770,6 +776,8 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
/** 格式化文章主键 */
$posts = is_array($cid) ? $cid : array($cid);
foreach ($posts as $post) {
// 删除插件接口
$this->pluginHandle->delete($post, $this);
$condition = $this->db->sql()->where('cid = ?', $post);
$postObject = $this->db->fetchObject($this->db->select('status', 'type')
@ -809,6 +817,9 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
$this->deleteFields($draft['cid']);
}
// 完成删除插件接口
$this->pluginHandle()->finishDelete($post, $this);
$deleteCount ++;
}