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