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
* @package GNU Social
* @author Ian Denhardt <ian@zenhack.net>
* @author Max Shinn <trombonechamp@gmail.com>
* @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');
}
}

View File

@ -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();
}
}

View File

@ -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');

View File

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