123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class GNUsocialVideoPlugin extends MicroAppPlugin
- {
- var $oldSaveNew = true;
- function onCheckSchema()
- {
- $schema = Schema::get();
- $schema->ensureTable('video', Video::schemaDef());
- return true;
- }
- function onRouterInitialized($m)
- {
- $m->connect('main/postvideo', array('action' => 'postvideo'));
- $m->connect('showvideo/:id', array('action' => 'showvideo'));
- return true;
- }
- function entryForm($out)
- {
- return new VideoForm($out);
- }
- function appTitle()
- {
- return _('Video');
- }
- function tag()
- {
- return 'GNUsocialVideo';
- }
- function types()
- {
- return array(Video::OBJECT_TYPE);
- }
- function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options=array())
- {
- if(count($activity->objects) != 1) {
- throw new Exception('Too many activity objects.');
- }
- $videoObj = $activity->objects[0];
- if ($videoObj->type != Video::OBJECT_TYPE) {
- throw new Exception('Wrong type for object.');
- }
-
-
- $uri = ActivityUtils::getLink($activity->entry, 'enclosure');
- $options['object_type'] = Video::OBJECT_TYPE;
- Video::saveNew($actor, $uri, $options);
-
- }
- function activityObjectFromNotice(Notice $notice)
- {
- $object = new ActivityObject();
- $object->id = $notice->uri;
- $object->type = Video::OBJECT_TYPE;
- $object->title = $notice->content;
- $object->summary = $notice->content;
- $object->link = $notice->getUrl();
- $vid = Video::getByNotice($notice);
- if ($vid) {
- $object->extra[] = array('link', array('rel' => 'enclosure', 'href' => $vid->url), array());
- }
-
- return $object;
-
- }
- function showNotice(Notice $notice, HTMLOutputter $out)
- {
- $vid = Video::getByNotice($notice);
- if ($vid) {
- $out->element('video', array('src' => $vid->url,
- 'width' => '100%',
- 'controls' => 'controls'));
- }
- }
- function deleteRelated(Notice $notice)
- {
- $vid = Video::getByNotice($notice);
- if ($vid) {
- $vid->delete();
- }
- }
- }
|