PHPCS BookmarkPlugin.php

This commit is contained in:
Evan Prodromou 2010-12-21 10:13:20 -05:00
parent 331639d6e4
commit c96faf065d

View File

@ -46,6 +46,8 @@ if (!defined('STATUSNET')) {
class BookmarkPlugin extends Plugin class BookmarkPlugin extends Plugin
{ {
const VERSION = '0.1';
/** /**
* Database schema setup * Database schema setup
* *
@ -76,6 +78,14 @@ class BookmarkPlugin extends Plugin
return true; return true;
} }
/**
* When a notice is deleted, delete the related Notice_bookmark
*
* @param Notice $notice Notice being deleted
*
* @return boolean hook value
*/
function onNoticeDeleteRelated($notice) function onNoticeDeleteRelated($notice)
{ {
$nb = Notice_bookmark::staticGet('notice_id', $notice->id); $nb = Notice_bookmark::staticGet('notice_id', $notice->id);
@ -87,6 +97,14 @@ class BookmarkPlugin extends Plugin
return true; return true;
} }
/**
* Show the CSS necessary for this plugin
*
* @param Action $action the action being run
*
* @return boolean hook value
*/
function onEndShowStyles($action) function onEndShowStyles($action)
{ {
$action->style('.bookmark_tags li { display: inline; }'); $action->style('.bookmark_tags li { display: inline; }');
@ -140,6 +158,14 @@ class BookmarkPlugin extends Plugin
return true; return true;
} }
/**
* Output the HTML for a bookmark in a list
*
* @param NoticeListItem $nli The list item being shown.
*
* @return boolean hook value
*/
function onStartShowNoticeItem($nli) function onStartShowNoticeItem($nli)
{ {
$nb = Notice_bookmark::staticGet('notice_id', $nb = Notice_bookmark::staticGet('notice_id',
@ -193,6 +219,15 @@ class BookmarkPlugin extends Plugin
return true; return true;
} }
/**
* Render a notice as a Bookmark object
*
* @param Notice $notice Notice to render
* @param ActivityObject &$object Empty object to fill
*
* @return boolean hook value
*/
function onStartActivityObjectFromNotice($notice, &$object) function onStartActivityObjectFromNotice($notice, &$object)
{ {
$nb = Notice_bookmark::staticGet('notice_id', $nb = Notice_bookmark::staticGet('notice_id',
@ -211,7 +246,8 @@ class BookmarkPlugin extends Plugin
$attachments = $notice->attachments(); $attachments = $notice->attachments();
if (count($attachments) != 1) { if (count($attachments) != 1) {
throw new ServerException(_('Bookmark notice with the wrong number of attachments.')); throw new ServerException(_('Bookmark notice with the '.
'wrong number of attachments.'));
} }
$target = $attachments[0]; $target = $attachments[0];
@ -250,10 +286,18 @@ class BookmarkPlugin extends Plugin
return true; return true;
} }
/**
* Plugin version data
*
* @param array &$versions array of version data
*
* @return value
*/
function onPluginVersion(&$versions) function onPluginVersion(&$versions)
{ {
$versions[] = array('name' => 'Sample', $versions[] = array('name' => 'Sample',
'version' => STATUSNET_VERSION, 'version' => self::VERSION,
'author' => 'Evan Prodromou', 'author' => 'Evan Prodromou',
'homepage' => 'http://status.net/wiki/Plugin:Bookmark', 'homepage' => 'http://status.net/wiki/Plugin:Bookmark',
'rawdescription' => 'rawdescription' =>