Sinisakrisan (Talk | contribs) |
Sinisakrisan (Talk | contribs) |
||
Line 3: | Line 3: | ||
Used in the standard community plugin to gather data for creating activity stream item | Used in the standard community plugin to gather data for creating activity stream item | ||
+ | |||
+ | 1) create a standart JomSocial plugin. | ||
+ | |||
+ | 2) add onCommunityStreamRender function in the plugin. The function must be public. | ||
+ | |||
+ | 3) Arrange the data according to this format:- | ||
+ | |||
+ | |||
+ | |||
+ | { | ||
+ | |||
+ | //UserId | ||
+ | |||
+ | "actor":5, | ||
+ | |||
+ | //target id | ||
+ | |||
+ | "target": 6, | ||
+ | |||
+ | "message":"string", | ||
+ | |||
+ | "group" : "JTableGroup object", | ||
+ | |||
+ | "event" : "JTableEvent object", | ||
+ | |||
+ | "headline" : "string", | ||
+ | |||
+ | "location" : "Kuala Lumpur", | ||
+ | |||
+ | "attachments": | ||
+ | |||
+ | [ | ||
+ | |||
+ | {"type":"media"}, | ||
+ | |||
+ | {"type":"video", "id":0, "title":"", "description":"", "duration": "string"}, | ||
+ | |||
+ | {"type":"quote"} | ||
+ | |||
+ | ] | ||
+ | |||
+ | |||
+ | |||
+ | PHP file of example plugin with code comments and explanations | ||
+ | |||
+ | //refer activities.videos.php file | ||
+ | |||
+ | $stream = new stdClass(); | ||
+ | |||
+ | $stream->actor = $user; | ||
+ | |||
+ | $stream->target = null; | ||
+ | |||
+ | $stream->headline = CVideos::getActivityTitleHTML($act);; | ||
+ | |||
+ | $stream->message = ""; | ||
+ | |||
+ | $stream->groupid = $act->groupid; | ||
+ | |||
+ | $stream->eventid = $act->eventid; | ||
+ | |||
+ | $stream->attachments = array(); | ||
+ | |||
+ | if($act->groupid){ | ||
+ | |||
+ | $group = JTable::getInstance( 'Group' , 'CTable' ); | ||
+ | |||
+ | $group->load( $act->groupid ); | ||
+ | |||
+ | $stream->group = $group; | ||
+ | |||
+ | } | ||
+ | |||
+ | $attachment = new stdClass(); | ||
+ | |||
+ | $attachment->type = 'video'; | ||
+ | |||
+ | $attachment->id = $act->cid; | ||
+ | |||
+ | $attachment->title = $video->title; | ||
+ | |||
+ | $attachment->thumbnail = $video->getThumbnail(); | ||
+ | |||
+ | $attachment->description = $video->description; | ||
+ | |||
+ | $attachment->duration = CVideosHelper::toNiceHMS(CVideosHelper::formatDuration($video->getDuration())); | ||
+ | |||
+ | $stream->attachments[] = $attachment; | ||
+ | |||
+ | $quoteContent = CActivities::format($act->title); | ||
+ | |||
+ | if(!empty($quoteContent) && $param->get('style') == COMMUNITY_STREAM_STYLE){ | ||
+ | |||
+ | $attachment = new stdClass(); | ||
+ | |||
+ | $attachment->type = 'quote'; | ||
+ | |||
+ | $attachment->message = $quoteContent; | ||
+ | |||
+ | $stream->attachments[] = $attachment; | ||
+ | |||
+ | } | ||
+ | |||
+ | $this->set('stream', $stream); | ||
+ | |||
+ | $this->load('activities.stream'); |
Revision as of 15:40, 28 March 2013
Used in the standard community plugin to gather data for creating activity stream item
1) create a standart JomSocial plugin.
2) add onCommunityStreamRender function in the plugin. The function must be public.
3) Arrange the data according to this format:-
{
//UserId
"actor":5,
//target id
"target": 6,
"message":"string",
"group" : "JTableGroup object",
"event" : "JTableEvent object",
"headline" : "string",
"location" : "Kuala Lumpur",
"attachments":
[
{"type":"media"},
{"type":"video", "id":0, "title":"", "description":"", "duration": "string"},
{"type":"quote"}
]
PHP file of example plugin with code comments and explanations
//refer activities.videos.php file
$stream = new stdClass();
$stream->actor = $user;
$stream->target = null;
$stream->headline = CVideos::getActivityTitleHTML($act);;
$stream->message = "";
$stream->groupid = $act->groupid;
$stream->eventid = $act->eventid;
$stream->attachments = array();
if($act->groupid){
$group = JTable::getInstance( 'Group' , 'CTable' );
$group->load( $act->groupid );
$stream->group = $group;
}
$attachment = new stdClass();
$attachment->type = 'video';
$attachment->id = $act->cid;
$attachment->title = $video->title;
$attachment->thumbnail = $video->getThumbnail();
$attachment->description = $video->description;
$attachment->duration = CVideosHelper::toNiceHMS(CVideosHelper::formatDuration($video->getDuration()));
$stream->attachments[] = $attachment;
$quoteContent = CActivities::format($act->title);
if(!empty($quoteContent) && $param->get('style') == COMMUNITY_STREAM_STYLE){
$attachment = new stdClass();
$attachment->type = 'quote';
$attachment->message = $quoteContent;
$stream->attachments[] = $attachment;
}
$this->set('stream', $stream);
$this->load('activities.stream');