From cbf296e804465836b094ff39233fb014851cb89b Mon Sep 17 00:00:00 2001 From: Max Shinn Date: Sun, 26 Dec 2010 20:42:45 -0600 Subject: [PATCH] Usability with photos tab --- .../GNUsocialPhotos/GNUsocialPhotosPlugin.php | 20 ++++++++++++++++--- plugins/GNUsocialPhotos/actions/photo.php | 13 ++++-------- plugins/GNUsocialPhotos/actions/photos.php | 19 ++++++++++-------- .../classes/gnusocialphoto.php | 4 ++++ 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php index d0a58533df..4ba5aee732 100644 --- a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php +++ b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php @@ -22,6 +22,7 @@ * @category Widget * @package GNU Social * @author Ian Denhardt + * @author Max Shinn * @copyright 2010 Free Software Foundation, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 */ @@ -85,7 +86,7 @@ class GNUsocialPhotosPlugin extends Plugin { $m->connect(':nickname/photos', array('action' => 'photos')); $m->connect('main/uploadphoto', array('action' => 'photoupload')); - $m->connect(':nickname/photo/:photoid', array('action' => 'photo')); + $m->connect('photo/:photoid', array('action' => 'photo')); return true; } @@ -162,7 +163,7 @@ class GNUsocialPhotosPlugin extends Plugin if($photo) { $action->out->elementStart('div', 'entry-title'); $action->showAuthor(); - $action->out->elementStart('a', array('href' => $photo->uri)); + $action->out->elementStart('a', array('href' => $photo->getPageLink())); $action->out->element('img', array('src' => $photo->thumb_uri, 'width' => 256, 'height' => 192)); $action->out->elementEnd('a'); @@ -174,9 +175,22 @@ class GNUsocialPhotosPlugin extends Plugin return true; } + /* function onEndShowNoticeFormData($action) + { + $link = "/main/uploadphoto"; + $action->out->element('label', array('for' => 'photofile'),_('Attach')); + $action->out->element('input', array('id' => 'photofile', + 'type' => 'file', + 'name' => 'photofile', + 'title' => _('Upload a photo'))); + } + */ function onEndPersonalGroupNav($nav) { + $nav->out->menuItem(common_local_url('photos', - array('nickname' => $nav->action->trimmed('nickname'))), 'Photos'); + array('nickname' => $nav->action->trimmed('nickname'))), _('Photos'), + _('Photo gallery'), $nav->action->trimmed('action') == 'photos', 'nav_photos'); } } + diff --git a/plugins/GNUsocialPhotos/actions/photo.php b/plugins/GNUsocialPhotos/actions/photo.php index 3c2014eb8c..64d3e16a17 100644 --- a/plugins/GNUsocialPhotos/actions/photo.php +++ b/plugins/GNUsocialPhotos/actions/photo.php @@ -44,18 +44,13 @@ class PhotoAction extends Action parent::prepare($args); $args = $this->returnToArgs(); - $username = $args[1]['nickname']; $this->photoid = $args[1]['photoid']; - if (common_valid_profile_tag($username) == 0) { - $this->user = null; - } else { - $this->user = Profile::staticGet('nickname', $username); - } $this->photo = GNUsocialPhoto::staticGet('notice_id', $this->photoid); - $this->notice = Notice::staticGet('id', $this->photoid); - $notices = Notice::conversationStream((int)$this->photoid-1, null, null); //Why do I have to do -1? + $this->user = Profile::staticGet('id', $this->notice->profile_id); + + $notices = Notice::conversationStream((int)$this->photoid-1, null, null); //Why do I have to do -1? $this->conversation = new ConversationTree($notices, $this); return true; @@ -97,7 +92,7 @@ class PhotoAction extends Action $this->elementEnd('a'); $this->element('p', array(), $this->photo->photo_description); //This is a hack to hide the top-level comment - //$this->element('style', array(), "#notice-{$this->photoid} div { display: none } #notice-{$this->photoid} ol li div { display: inline }"); + $this->element('style', array(), "#notice-{$this->photoid} div { display: none } #notice-{$this->photoid} ol li div { display: inline }"); $this->conversation->show(); } } diff --git a/plugins/GNUsocialPhotos/actions/photos.php b/plugins/GNUsocialPhotos/actions/photos.php index 37ec8ce32f..7adcaadadd 100644 --- a/plugins/GNUsocialPhotos/actions/photos.php +++ b/plugins/GNUsocialPhotos/actions/photos.php @@ -31,6 +31,8 @@ if (!defined('STATUSNET')) { exit(1); } +require_once INSTALLDIR.'/lib/personalgroupnav.php'; + class PhotosAction extends Action { var $user = null; @@ -66,7 +68,7 @@ class PhotosAction extends Action function showLocalNav() { - $nav = new GNUsocialPhotoNav($this); + $nav = new PersonalGroupNav($this); $nav->show(); } @@ -80,21 +82,22 @@ class PhotosAction extends Action $page = 1; } - if ($page > 1) { - $this->element('a', array('href' => 'photos?pageid=' . ($page-1)), 'Previous page'); - } - $this->element('a', array('href' => 'photos?pageid=' . ($page+1) ), 'Next page'); - //TODO choice of available albums by user. //Currently based on fact that each user can only have one album. $album = GNUSocialPhotoAlbum::staticGet('profile_id', $this->user->id); $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9); + if ($page > 1) { + $this->element('a', array('href' => 'photos?pageid=' . ($page-1)), 'Previous page'); + } + if (GNUsocialPhoto::getGalleryPage($page+1, $album->album_id, 9)) { + $this->element('a', array('href' => 'photos?pageid=' . ($page+1) ), 'Next page'); + } + $this->elementStart('ul', array('class' => 'photothumbs')); foreach ($photos as $photo) { $this->elementStart('li'); - $photolink = '/' . $this->user->nickname . '/photo/' . $photo->notice_id; - $this->elementStart('a', array('href' => $photolink)); + $this->elementStart('a', array('href' => $photo->getPageLink())); $this->element('img', array('src' => $photo->thumb_uri)); $this->elementEnd('a'); $this->elementEnd('li'); diff --git a/plugins/GNUsocialPhotos/classes/gnusocialphoto.php b/plugins/GNUsocialPhotos/classes/gnusocialphoto.php index 5e6a63b44c..34daff73bb 100644 --- a/plugins/GNUsocialPhotos/classes/gnusocialphoto.php +++ b/plugins/GNUsocialPhotos/classes/gnusocialphoto.php @@ -116,6 +116,10 @@ class GNUsocialPhoto extends Memcached_DataObject } } + function getPageLink() + { + return '/photo/' . $this->notice_id; + } /* * TODO: -Sanitize input