Usability with photos tab

This commit is contained in:
Max Shinn 2010-12-26 20:42:45 -06:00
parent a10a9c4a90
commit cbf296e804
4 changed files with 36 additions and 20 deletions

View File

@ -22,6 +22,7 @@
* @category Widget * @category Widget
* @package GNU Social * @package GNU Social
* @author Ian Denhardt <ian@zenhack.net> * @author Ian Denhardt <ian@zenhack.net>
* @author Max Shinn <trombonechamp@gmail.com>
* @copyright 2010 Free Software Foundation, Inc. * @copyright 2010 Free Software Foundation, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @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(':nickname/photos', array('action' => 'photos'));
$m->connect('main/uploadphoto', array('action' => 'photoupload')); $m->connect('main/uploadphoto', array('action' => 'photoupload'));
$m->connect(':nickname/photo/:photoid', array('action' => 'photo')); $m->connect('photo/:photoid', array('action' => 'photo'));
return true; return true;
} }
@ -162,7 +163,7 @@ class GNUsocialPhotosPlugin extends Plugin
if($photo) { if($photo) {
$action->out->elementStart('div', 'entry-title'); $action->out->elementStart('div', 'entry-title');
$action->showAuthor(); $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, $action->out->element('img', array('src' => $photo->thumb_uri,
'width' => 256, 'height' => 192)); 'width' => 256, 'height' => 192));
$action->out->elementEnd('a'); $action->out->elementEnd('a');
@ -174,9 +175,22 @@ class GNUsocialPhotosPlugin extends Plugin
return true; 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) function onEndPersonalGroupNav($nav)
{ {
$nav->out->menuItem(common_local_url('photos', $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');
} }
} }

View File

@ -44,18 +44,13 @@ class PhotoAction extends Action
parent::prepare($args); parent::prepare($args);
$args = $this->returnToArgs(); $args = $this->returnToArgs();
$username = $args[1]['nickname'];
$this->photoid = $args[1]['photoid']; $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->photo = GNUsocialPhoto::staticGet('notice_id', $this->photoid);
$this->notice = Notice::staticGet('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); $this->conversation = new ConversationTree($notices, $this);
return true; return true;
@ -97,7 +92,7 @@ class PhotoAction extends Action
$this->elementEnd('a'); $this->elementEnd('a');
$this->element('p', array(), $this->photo->photo_description); $this->element('p', array(), $this->photo->photo_description);
//This is a hack to hide the top-level comment //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(); $this->conversation->show();
} }
} }

View File

@ -31,6 +31,8 @@ if (!defined('STATUSNET')) {
exit(1); exit(1);
} }
require_once INSTALLDIR.'/lib/personalgroupnav.php';
class PhotosAction extends Action class PhotosAction extends Action
{ {
var $user = null; var $user = null;
@ -66,7 +68,7 @@ class PhotosAction extends Action
function showLocalNav() function showLocalNav()
{ {
$nav = new GNUsocialPhotoNav($this); $nav = new PersonalGroupNav($this);
$nav->show(); $nav->show();
} }
@ -80,21 +82,22 @@ class PhotosAction extends Action
$page = 1; $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. //TODO choice of available albums by user.
//Currently based on fact that each user can only have one album. //Currently based on fact that each user can only have one album.
$album = GNUSocialPhotoAlbum::staticGet('profile_id', $this->user->id); $album = GNUSocialPhotoAlbum::staticGet('profile_id', $this->user->id);
$photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9); $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')); $this->elementStart('ul', array('class' => 'photothumbs'));
foreach ($photos as $photo) { foreach ($photos as $photo) {
$this->elementStart('li'); $this->elementStart('li');
$photolink = '/' . $this->user->nickname . '/photo/' . $photo->notice_id; $this->elementStart('a', array('href' => $photo->getPageLink()));
$this->elementStart('a', array('href' => $photolink));
$this->element('img', array('src' => $photo->thumb_uri)); $this->element('img', array('src' => $photo->thumb_uri));
$this->elementEnd('a'); $this->elementEnd('a');
$this->elementEnd('li'); $this->elementEnd('li');

View File

@ -116,6 +116,10 @@ class GNUsocialPhoto extends Memcached_DataObject
} }
} }
function getPageLink()
{
return '/photo/' . $this->notice_id;
}
/* /*
* TODO: -Sanitize input * TODO: -Sanitize input