From a065afc55cc83facb6257833aae13368fa11ffb7 Mon Sep 17 00:00:00 2001
From: joyqi <magike.net@gmail.com>
Date: Thu, 19 Dec 2013 10:20:40 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8F=92=E4=BB=B6=E6=8E=A5?=
 =?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

根据issue #136的提议,在发布和删除内容后添加相应的插件接口,以实现一些特定的功能需求
---
 var/Widget/Contents/Page/Edit.php | 12 ++++++++++++
 var/Widget/Contents/Post/Edit.php | 11 +++++++++++
 2 files changed, 23 insertions(+)

diff --git a/var/Widget/Contents/Page/Edit.php b/var/Widget/Contents/Page/Edit.php
index 490b5552..d3ce3c1d 100644
--- a/var/Widget/Contents/Page/Edit.php
+++ b/var/Widget/Contents/Page/Edit.php
@@ -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 ++;
                 }
             }
diff --git a/var/Widget/Contents/Post/Edit.php b/var/Widget/Contents/Post/Edit.php
index 04117c5c..0826915e 100644
--- a/var/Widget/Contents/Post/Edit.php
+++ b/var/Widget/Contents/Post/Edit.php
@@ -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 ++;
                 }