From 36db3d93306ce16e3586a003151a43f7cd28f675 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Sun, 13 Jun 2010 07:32:04 -0400 Subject: Hugely unfinished Photo plugin --- plugins/SocialPhoto/NewSocialPhotoAction.php | 50 ++++++++++++++++++++++++++++ plugins/SocialPhoto/SocialPhoto.php | 50 ++++++++++++++++++++++++++++ plugins/SocialPhoto/SocialPhotoForm.php | 23 +++++++++++++ plugins/SocialPhoto/SocialPhotoPlugin.php | 22 ++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 plugins/SocialPhoto/NewSocialPhotoAction.php create mode 100644 plugins/SocialPhoto/SocialPhoto.php create mode 100644 plugins/SocialPhoto/SocialPhotoForm.php create mode 100644 plugins/SocialPhoto/SocialPhotoPlugin.php 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 @@ +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 @@ +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 @@ +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 @@ +plugin_path = dirname(__FILE__); + } +} -- cgit v1.2.3