diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/SocialPhoto/NewSocialPhotoAction.php | 50 | ||||
-rw-r--r-- | plugins/SocialPhoto/SocialPhoto.php | 50 | ||||
-rw-r--r-- | plugins/SocialPhoto/SocialPhotoForm.php | 23 | ||||
-rw-r--r-- | plugins/SocialPhoto/SocialPhotoPlugin.php | 22 |
4 files changed, 145 insertions, 0 deletions
diff --git a/plugins/SocialPhoto/NewSocialPhotoAction.php b/plugins/SocialPhoto/NewSocialPhotoAction.php new file mode 100644 index 000000000..a7402ab87 --- /dev/null +++ b/plugins/SocialPhoto/NewSocialPhotoAction.php @@ -0,0 +1,50 @@ +<?php + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/plugins/SocialPhoto/NewSocialObjectAction.php'; + +class NewSocialPhotoAction extends NewSocialObjectAction +{ + private $slug='photo'; + private $dbclass='SocialPhoto'; + + function validate() + { + return true; + } + + function getSummary() + { + $title = $this->trimmed('photo-title'); + $max_len = Notice::maxContent() - 30; + if(strlen($title) > $max_len) { + return substr($title, 0, $max_len-1) . '…'; #ellipsis ;) + } + return $title; + } + + function getMentions() + { + $this->trimmed('mentions'); + } + + function getTags() + { + $this->trimmed('tags'); + } + + function getGroups() + { + $this->trimmed('groups'); + } + + function showSocialObjectForm() + { + require_once dirname(__FILE__) . '/SocialPhotoForm.php'; + $form = new SocialPhotoForm($this); + $form->show(); + } +} diff --git a/plugins/SocialPhoto/SocialPhoto.php b/plugins/SocialPhoto/SocialPhoto.php new file mode 100644 index 000000000..f072ab814 --- /dev/null +++ b/plugins/SocialPhoto/SocialPhoto.php @@ -0,0 +1,50 @@ +<?php + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/plugins/SocialObject/SocialObject.php'; + +class SocialPhoto extends SocialObject +{ + public $__table = 'social_photo'; + public $id; + public $url; + public $title; + public $description; + + var $slug = 'photo'; + static function saveNew($notice, $action) + { + $photo = new SocialPhoto(); + $photo->id = $notice->id; # very essential + $photo->title = $action->trimmed('photo-title'); + $att = $notice->attachments(); + if(empty($att)) { + # no attachment uploaded? + $action->clientError(_('No photo was uploaded')); + $photo->delete(); + } + $att = $att[0]; # just use the 1st one :P + $photo->url = $att->url; + # TODO: Size the photo up/down and + # save copies of different sizes + $photo->insert(); + } + + static function schemaDef() + { + return array(new ColumnDef('id', 'int', + /*size*/null, + /*nullable*/false, + /*key*/'PRI'), + new ColumnDef('title', 'varchar', + /*size*/255, + /*nullable*/false), + new ColumnDef('url', 'varchar', + 255, false), + new ColumnDef('description', 'text', + null, true)); + } +} diff --git a/plugins/SocialPhoto/SocialPhotoForm.php b/plugins/SocialPhoto/SocialPhotoForm.php new file mode 100644 index 000000000..dbce1d1c2 --- /dev/null +++ b/plugins/SocialPhoto/SocialPhotoForm.php @@ -0,0 +1,23 @@ +<?php + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR.'/plugins/SocialLayout/SocialObjectForm.php'; + +class SocialPhotoForm extends SocialObjectForm +{ + function showFormElements() + { + $this->out->element('label', + array('for' => 'notice_data-text'), sprintf(_('Photo'))); + $this->out->input('photo-title', _('Title')); + $this->element('textarea', array('rows' => 3, + 'cols' => 30, 'class' => 'photo-description')); + $this->out->input('mentions', _('Replies')); + $this->out->input('groups', _('Groups')); + $this->out->input('tags', _('Tags')); + } +} + diff --git a/plugins/SocialPhoto/SocialPhotoPlugin.php b/plugins/SocialPhoto/SocialPhotoPlugin.php new file mode 100644 index 000000000..2af00af82 --- /dev/null +++ b/plugins/SocialPhoto/SocialPhotoPlugin.php @@ -0,0 +1,22 @@ +<?php + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once dirname(__FILE__) . 'SocialPhoto.php'; +require_once INSTALLDIR . '/plugins/SocialObject/SocialObjectPlugin.php'; + +class SocialPhotoPlugin extends SocialObjectPlugin +{ + var $name = 'Photo'; + var $name_plural = 'Photos'; + var $slug = 'photo'; + var $slug_plural = 'photos'; + var $plugin_path = null; + var $dbclass = 'SocialPhoto'; + + function initialize() { + $this->plugin_path = dirname(__FILE__); + } +} |