这是本文档旧的修订版!
目录
插件接口及功能列表
Widget内置的接口
在Typecho中只要这个类是继承自Typecho_Widget基类,它就默认具备了这个插件接口。接口开发者可以使用这个接口无缝地向当前的Class中注入方法
比如我要给Widget_Archive类增加一个方法获取当前文章的字数(charactersNum),只需要在你的插件`activate`方法中声明
Typecho_Plugin::factory('Widget_Archive')->___charactersNum = array('MyPlugin', 'charactersNum');
注意,我们在方法名前面加三个下划线表示这是一个内部方法。而实现这个方法也很简单,因为系统会将当前的对象作为参数传递给你
public static function charactersNum($archive) { return mb_strlen($archive->text, 'UTF-8'); }
那么这个方法就已经植入到Widget_Archive中去了,你在模版中可以直接调用如下代码输出它
<?php $this->charactersNum(); ?>
句柄接口
Widget_Archive
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
indexHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
error404Handle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
singleHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
categoryHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
tagHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
authorHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
dateHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
search
</td> <td>
$keywords
<br />
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
searchHandle
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
query
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
select
</td> <td>
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
handleInit
</td> <td>
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
handle
</td> <td>
$parameter->type
<br />
Widget_Archive
对象<br />
$select
</td> <td></td> </tr> <tr> <td>
pageNav
</td> <td>
$currentPage
<br />
$total
<br />
$parameter->pageSize
<br />
$prev
<br />
$next
<br />
$splitPage
<br />
$splitWord
</td> <td></td> </tr> <tr> <td>
headerOptions
</td> <td>
$allows
<br />
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
header
</td> <td>
$header
<br />
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
footer
</td> <td>
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
beforeRender
</td> <td>
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
afterRender
</td> <td>
Widget_Archive
对象</td> <td></td> </tr> <tr> <td>
commentFeedItem
</td> <td>
$feedType
<br />
$comments
</td> <td></td> </tr> <tr> <td>
feedItem
</td> <td>
$feedType
<br />
Widget_Archive
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Feedback
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
comment
</td> <td>
$comment
<br />
$content
</td> <td></td> </tr> <tr> <td>
finishComment
</td> <td>
Widget_Feedback
对象</td> <td></td> </tr> <tr> <td>
trackback
</td> <td>
$trackback
<br />
$content
</td> <td></td> </tr> <tr> <td>
finishTrackback
</td> <td>
Widget_Feedback
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Login
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
loginFail
</td> <td>
$user
<br />
$request->name
<br />
$request->password
<br />
1 == $request->remember
</td> <td></td> </tr> <tr> <td>
loginSucceed
</td> <td>
$user
<br />
$request->name
<br />
$request->password
<br />
1 == $request->remember
</td> <td></td> </tr> </tbody> </table> </html>
Widget_Logout
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
logout
</td> <td><cite>无</cite> </td> <td></td> </tr> </tbody> </table> </html>
Widget_Register
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
register
</td> <td>
$dataStruct
</td> <td></td> </tr> <tr> <td>
finishRegister
</td> <td>
Widget_Register
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Upload
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
beforeUpload
</td> <td>
$result
</td> <td></td> </tr> <tr> <td>
upload
</td> <td>
Widget_Upload
对象</td> <td></td> </tr> <tr> <td>
beforeModify
</td> <td>
$result
</td> <td></td> </tr> <tr> <td>
modify
</td> <td>
Widget_Upload
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_User
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
login
</td> <td>
$name
<br />
$password
<br />
$temporarily
<br />
$expire
</td> <td></td> </tr> <tr> <td>
hashValidate
</td> <td>
$password
<br />
$user['password']
</td> <td></td> </tr> <tr> <td>
loginSucceed
</td> <td>
Widget_User
对象<br />
$name
<br />
$password
<br />
$temporarily
<br />
$expire
</td> <td></td> </tr> <tr> <td>
loginFail
</td> <td>
Widget_User
对象<br />
$name
<br />
$password
<br />
$temporarily
<br />
$expire
</td> <td></td> </tr> <tr> <td>
logout
</td> <td><cite>无</cite> </td> <td></td> </tr> </tbody> </table> </html>
Widget_XmlRpc
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
textFilter
</td> <td>
$input['text']
<br />
Widget_XmlRpc
对象</td> <td></td> </tr> <tr> <td>
upload
</td> <td>
Widget_XmlRpc
对象</td> <td></td> </tr> <tr> <td>
pingback
</td> <td>
$pingback
<br />
$post
</td> <td></td> </tr> <tr> <td>
finishPingback
</td> <td>
Widget_XmlRpc
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Abstract_Comments
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
content
</td> <td>
$text
<br />
Widget_Abstract_Comments
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Feedback
<br />
Widget_Comments_Admin
<br />
Widget_Comments_Archive
<br />
Widget_Comments_Edit
<br />
Widget_Comments_Ping
<br />
Widget_Comments_Recent
</td> </tr> <tr> <td>
contentEx
</td> <td>
$text
<br />
Widget_Abstract_Comments
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Feedback
<br />
Widget_Comments_Admin
<br />
Widget_Comments_Archive
<br />
Widget_Comments_Edit
<br />
Widget_Comments_Ping
<br />
Widget_Comments_Recent
</td> </tr> <tr> <td>
filter
</td> <td>
$value
<br />
Widget_Abstract_Comments
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Feedback
<br />
Widget_Comments_Admin
<br />
Widget_Comments_Archive
<br />
Widget_Comments_Edit
<br />
Widget_Comments_Ping
<br />
Widget_Comments_Recent
</td> </tr> <tr> <td>
gravatar
</td> <td>
$size
<br />
$rating
<br />
$default
<br />
Widget_Abstract_Comments
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Feedback
<br />
Widget_Comments_Admin
<br />
Widget_Comments_Archive
<br />
Widget_Comments_Edit
<br />
Widget_Comments_Ping
<br />
Widget_Comments_Recent
</td> </tr> <tr> <td>
autoP
</td> <td>
$text
</td> <td>以下句柄同样具有此接口:<br />
Widget_Feedback
<br />
Widget_Comments_Admin
<br />
Widget_Comments_Archive
<br />
Widget_Comments_Edit
<br />
Widget_Comments_Ping
<br />
Widget_Comments_Recent
</td> </tr> <tr> <td>
markdown
</td> <td>
$text
</td> <td>以下句柄同样具有此接口:<br />
Widget_Feedback
<br />
Widget_Comments_Admin
<br />
Widget_Comments_Archive
<br />
Widget_Comments_Edit
<br />
Widget_Comments_Ping
<br />
Widget_Comments_Recent
</td> </tr> </tbody> </table> </html>
Widget_Abstract_Contents
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
excerpt
</td> <td>
$text
<br />
Widget_Abstract_Contents
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
excerptEx
</td> <td>
$excerpt
<br />
Widget_Abstract_Contents
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
content
</td> <td>
$text
<br />
Widget_Abstract_Contents
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
contentEx
</td> <td>
$content
<br />
Widget_Abstract_Contents
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
isFieldReadOnly
</td> <td>
$name
</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
filter
</td> <td>
$value
<br />
Widget_Abstract_Contents
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
title
</td> <td>
$title
<br />
Widget_Abstract_Contents
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
autoP
</td> <td>
$text
</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> <tr> <td>
markdown
</td> <td>
$text
</td> <td>以下句柄同样具有此接口:<br />
Widget_Archive
<br />
Widget_Upload
<br />
Widget_XmlRpc
<br />
Widget_Contents_Related
<br />
Widget_Contents_Attachment_Admin
<br />
Widget_Contents_Attachment_Related
<br />
Widget_Contents_Attachment_Unattached
<br />
Widget_Contents_Page_List
<br />
Widget_Contents_Post_Admin
<br />
Widget_Contents_Page_Admin
<br />
Widget_Contents_Post_Edit
<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
<br />
Widget_Contents_Post_Recent
<br />
Widget_Contents_Related_Author
</td> </tr> </tbody> </table> </html>
Widget_Abstract_Metas
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
filter
</td> <td>
$value
<br />
Widget_Abstract_Metas
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Metas_Category_Edit
<br />
Widget_Metas_Category_List
<br />
Widget_Metas_Category_Admin
<br />
Widget_Metas_Tag_Cloud
<br />
Widget_Metas_Tag_Admin
<br />
Widget_Metas_Tag_Edit
</td> </tr> </tbody> </table> </html>
Widget_Abstract_Users
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
filter
</td> <td>
$value
<br />
Widget_Abstract_Users
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Login
<br />
Widget_Logout
<br />
Widget_Register
<br />
Widget_Users_Admin
<br />
Widget_Users_Author
<br />
Widget_Users_Edit
<br />
Widget_Users_Profile
</td> </tr> </tbody> </table> </html>
Widget_Comments_Archive
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
listComments
</td> <td>
$singleCommentOptions
<br />
Widget_Comments_Archive
对象</td> <td></td> </tr> <tr> <td>
reply
</td> <td>
$word
<br />
Widget_Comments_Archive
对象</td> <td></td> </tr> <tr> <td>
cancelReply
</td> <td>
$word
<br />
Widget_Comments_Archive
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Comments_Edit
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
mark
</td> <td>
$comment
<br />
Widget_Comments_Edit
对象<br />
$status
</td> <td></td> </tr> <tr> <td>
delete
</td> <td>
$comment
<br />
Widget_Comments_Edit
对象</td> <td></td> </tr> <tr> <td>
finishDelete
</td> <td>
$comment
<br />
Widget_Comments_Edit
对象</td> <td></td> </tr> <tr> <td>
edit
</td> <td>
$comment
<br />
Widget_Comments_Edit
对象</td> <td></td> </tr> <tr> <td>
finishEdit
</td> <td>
Widget_Comments_Edit
对象</td> <td></td> </tr> <tr> <td>
comment
</td> <td>
$comment
<br />
Widget_Comments_Edit
对象</td> <td></td> </tr> <tr> <td>
finishComment
</td> <td>
Widget_Comments_Edit
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Contents_Attachment_Edit
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
delete
</td> <td>
$post
<br />
Widget_Contents_Attachment_Edit
对象</td> <td></td> </tr> <tr> <td>
finishDelete
</td> <td>
$post
<br />
Widget_Contents_Attachment_Edit
对象</td> <td></td> </tr> <tr> <td>
delete
</td> <td>
$post
<br />
Widget_Contents_Attachment_Edit
对象</td> <td></td> </tr> <tr> <td>
finishDelete
</td> <td>
$post
<br />
Widget_Contents_Attachment_Edit
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Contents_Page_Edit
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
write
</td> <td>
$contents
<br />
Widget_Contents_Page_Edit
对象</td> <td></td> </tr> <tr> <td>
finishPublish
</td> <td>
$contents
<br />
Widget_Contents_Page_Edit
对象</td> <td></td> </tr> <tr> <td>
finishSave
</td> <td>
$contents
<br />
Widget_Contents_Page_Edit
对象</td> <td></td> </tr> <tr> <td>
delete
</td> <td>
$page
<br />
Widget_Contents_Page_Edit
对象</td> <td></td> </tr> <tr> <td>
finishDelete
</td> <td>
$page
<br />
Widget_Contents_Page_Edit
对象</td> <td></td> </tr> </tbody> </table> </html>
Widget_Contents_Post_Edit
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
getDefaultFieldItems
</td> <td>
$layout
</td> <td>以下句柄同样具有此接口:<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
</td> </tr> <tr> <td>
write
</td> <td>
$contents
<br />
Widget_Contents_Post_Edit
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
</td> </tr> <tr> <td>
finishPublish
</td> <td>
$contents
<br />
Widget_Contents_Post_Edit
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
</td> </tr> <tr> <td>
finishSave
</td> <td>
$contents
<br />
Widget_Contents_Post_Edit
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
</td> </tr> <tr> <td>
delete
</td> <td>
$post
<br />
Widget_Contents_Post_Edit
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
</td> </tr> <tr> <td>
finishDelete
</td> <td>
$post
<br />
Widget_Contents_Post_Edit
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Contents_Attachment_Edit
<br />
Widget_Contents_Page_Edit
</td> </tr> </tbody> </table> </html>
Widget_Metas_Category_List
<html> <table class=“inline”><thead><tr>
<th width="15%">接口</th> <th width="20%">参数</th> <th>描述</th>
</tr></thead><tbody><tr> <td>
listCategories
</td> <td>
$categoryOptions
<br />
Widget_Metas_Category_List
对象</td> <td>以下句柄同样具有此接口:<br />
Widget_Metas_Category_Admin
</td> </tr> </tbody> </table> </html>