这是本文档旧的修订版!
目录
插件接口及功能列表
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
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
indexHandle |
Widget_Archive 对象$select |
无 | |
error404Handle |
Widget_Archive 对象$select |
无 | |
singleHandle |
Widget_Archive 对象$select |
无 | |
categoryHandle |
Widget_Archive 对象$select |
无 | |
tagHandle |
Widget_Archive 对象$select |
无 | |
authorHandle |
Widget_Archive 对象$select |
无 | |
dateHandle |
Widget_Archive 对象$select |
无 | |
search |
$keywords Widget_Archive 对象 |
无 | |
searchHandle |
Widget_Archive 对象$select |
无 | |
query |
Widget_Archive 对象$select |
无 | |
select |
Widget_Archive 对象 |
无 | |
handleInit |
Widget_Archive 对象$select |
无 | |
handle |
$parameter->type Widget_Archive 对象$select |
无 | |
pageNav |
$currentPage $total $parameter->pageSize $prev $next $splitPage $splitWord |
无 | |
headerOptions |
$allows Widget_Archive 对象 |
无 | |
header |
$header Widget_Archive 对象 |
无 | |
footer |
Widget_Archive 对象 |
无 | |
beforeRender |
Widget_Archive 对象 |
无 | |
afterRender |
Widget_Archive 对象 |
无 | |
commentFeedItem |
$feedType $comments |
无 | |
feedItem |
$feedType Widget_Archive 对象 |
无 |
Widget_Feedback
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
comment |
$comment $content |
无 | |
finishComment |
Widget_Feedback 对象 |
无 | |
trackback |
$trackback $content |
无 | |
finishTrackback |
Widget_Feedback 对象 |
无 |
Widget_Login
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
loginFail |
$user $request->name $request->password 1 == $request->remember |
无 | |
loginSucceed |
$user $request->name $request->password 1 == $request->remember |
无 |
Widget_Logout
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
logout |
无 | 无 |
Widget_Register
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
register |
$dataStruct |
无 | |
finishRegister |
Widget_Register 对象 |
无 |
Widget_Upload
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
beforeUpload |
$result |
无 | |
upload |
Widget_Upload 对象 |
无 | |
beforeModify |
$result |
无 | |
modify |
Widget_Upload 对象 |
无 |
Widget_User
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
login |
$name $password $temporarily $expire |
无 | |
hashValidate |
$password $user['password'] |
无 | |
loginSucceed |
Widget_User 对象$name $password $temporarily $expire |
无 | |
loginFail |
Widget_User 对象$name $password $temporarily $expire |
无 | |
logout |
无 | 无 |
Widget_XmlRpc
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
textFilter |
$input['text'] Widget_XmlRpc 对象 |
无 | |
upload |
Widget_XmlRpc 对象 |
无 | |
pingback |
$pingback $post |
无 | |
finishPingback |
Widget_XmlRpc 对象 |
无 |
Widget_Abstract_Comments
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
content |
$text Widget_Abstract_Comments 对象 |
Widget_Feedback Widget_Comments_Admin Widget_Comments_Archive Widget_Comments_Edit Widget_Comments_Ping Widget_Comments_Recent |
|
contentEx |
$text Widget_Abstract_Comments 对象 |
Widget_Feedback Widget_Comments_Admin Widget_Comments_Archive Widget_Comments_Edit Widget_Comments_Ping Widget_Comments_Recent |
|
filter |
$value Widget_Abstract_Comments 对象 |
Widget_Feedback Widget_Comments_Admin Widget_Comments_Archive Widget_Comments_Edit Widget_Comments_Ping Widget_Comments_Recent |
|
gravatar |
$size $rating $default Widget_Abstract_Comments 对象 |
Widget_Feedback Widget_Comments_Admin Widget_Comments_Archive Widget_Comments_Edit Widget_Comments_Ping Widget_Comments_Recent |
|
autoP |
$text |
Widget_Feedback Widget_Comments_Admin Widget_Comments_Archive Widget_Comments_Edit Widget_Comments_Ping Widget_Comments_Recent |
|
markdown |
$text |
Widget_Feedback Widget_Comments_Admin Widget_Comments_Archive Widget_Comments_Edit Widget_Comments_Ping Widget_Comments_Recent |
Widget_Abstract_Contents
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
excerpt |
$text Widget_Abstract_Contents 对象 |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
excerptEx |
$excerpt Widget_Abstract_Contents 对象 |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
content |
$text Widget_Abstract_Contents 对象 |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
contentEx |
$content Widget_Abstract_Contents 对象 |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
isFieldReadOnly |
$name |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
filter |
$value Widget_Abstract_Contents 对象 |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
title |
$title Widget_Abstract_Contents 对象 |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
autoP |
$text |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
|
markdown |
$text |
Widget_Archive Widget_Upload Widget_XmlRpc Widget_Contents_Related Widget_Contents_Attachment_Admin Widget_Contents_Attachment_Related Widget_Contents_Attachment_Unattached Widget_Contents_Page_List Widget_Contents_Post_Admin Widget_Contents_Page_Admin Widget_Contents_Post_Edit Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit Widget_Contents_Post_Recent Widget_Contents_Related_Author |
Widget_Abstract_Metas
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
filter |
$value Widget_Abstract_Metas 对象 |
Widget_Metas_Category_Edit Widget_Metas_Category_List Widget_Metas_Category_Admin Widget_Metas_Tag_Cloud Widget_Metas_Tag_Admin Widget_Metas_Tag_Edit |
Widget_Abstract_Users
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
filter |
$value Widget_Abstract_Users 对象 |
Widget_Login Widget_Logout Widget_Register Widget_Users_Admin Widget_Users_Author Widget_Users_Edit Widget_Users_Profile |
Widget_Comments_Archive
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
listComments |
$singleCommentOptions Widget_Comments_Archive 对象 |
无 | |
reply |
$word Widget_Comments_Archive 对象 |
无 | |
cancelReply |
$word Widget_Comments_Archive 对象 |
无 |
Widget_Comments_Edit
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
mark |
$comment Widget_Comments_Edit 对象$status |
无 | |
delete |
$comment Widget_Comments_Edit 对象 |
无 | |
finishDelete |
$comment Widget_Comments_Edit 对象 |
无 | |
edit |
$comment Widget_Comments_Edit 对象 |
无 | |
finishEdit |
Widget_Comments_Edit 对象 |
无 | |
comment |
$comment Widget_Comments_Edit 对象 |
无 | |
finishComment |
Widget_Comments_Edit 对象 |
无 |
Widget_Contents_Attachment_Edit
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
delete |
$post Widget_Contents_Attachment_Edit 对象 |
无 | |
finishDelete |
$post Widget_Contents_Attachment_Edit 对象 |
无 | |
delete |
$post Widget_Contents_Attachment_Edit 对象 |
无 | |
finishDelete |
$post Widget_Contents_Attachment_Edit 对象 |
无 |
Widget_Contents_Page_Edit
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
write |
$contents Widget_Contents_Page_Edit 对象 |
无 | |
finishPublish |
$contents Widget_Contents_Page_Edit 对象 |
无 | |
finishSave |
$contents Widget_Contents_Page_Edit 对象 |
无 | |
delete |
$page Widget_Contents_Page_Edit 对象 |
无 | |
finishDelete |
$page Widget_Contents_Page_Edit 对象 |
无 |
Widget_Contents_Post_Edit
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
getDefaultFieldItems |
$layout |
Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit |
|
write |
$contents Widget_Contents_Post_Edit 对象 |
Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit |
|
finishPublish |
$contents Widget_Contents_Post_Edit 对象 |
Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit |
|
finishSave |
$contents Widget_Contents_Post_Edit 对象 |
Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit |
|
delete |
$post Widget_Contents_Post_Edit 对象 |
Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit |
|
finishDelete |
$post Widget_Contents_Post_Edit 对象 |
Widget_Contents_Attachment_Edit Widget_Contents_Page_Edit |
Widget_Metas_Category_List
接口 | 参数 | 描述 | 因为继承同样具有此接口的句柄 |
---|---|---|---|
listCategories |
$categoryOptions Widget_Metas_Category_List 对象 |
Widget_Metas_Category_Admin |