* @package GNU Social
* @author Ian Denhardt <ian@zenhack.net>
* @author Sean Corbett <sean@gnu.org>
+ * @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
*/
$args = $this->returnToArgs();
$username = $args[1]['nickname'];
+ $this->albumid = $args[1]['albumid'];
if (common_valid_profile_tag($username) == 0) {
$this->user = null;
} else {
$nav->show();
}
- function showContent()
+ function showAlbums()
+ {
+ $album = new GNUsocialPhotoAlbum();
+ $album->user_id = $this->user->id;
+
+ $albums = array();
+ if (!$album->find()) {
+ GNUsocialPhotoAlbum::newAlbum($cur->id, 'Default');
+ }
+ $this->elementStart('ul', array('class' => 'photothumbs'));
+ while ($album->fetch()) {
+ $this->elementStart('li');
+ $this->element('h3', array(), $album->title);
+ $this->elementStart('a', array('href' => $album->getPageLink()));
+ $this->element('img', array('src' => $album->getThumbUri()));
+ $this->elementEnd('a');
+ $this->elementEnd('li');
+ }
+ $this->elementEnd('ul');
+
+ }
+
+ function showAlbum($album_id)
{
- if(empty($this->user)) {
+ $album = GNUSocialPhotoAlbum::staticGet('album_id', $album_id);
+ if (!$album) {
return;
}
+
$page = $_GET['pageid'];
if (!filter_var($page, FILTER_VALIDATE_INT)){
$page = 1;
}
-
- //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);
- if (!$album) {
- $album = GNUSocialPhotoAlbum::newAlbum($this->user->id, 'Default');
- }
- $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');
+ $this->element('a', array('href' => $album->getPageLink() . '?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->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page+1) ), 'Next page');
}
$this->elementStart('ul', array('class' => 'photothumbs'));
}
$this->elementEnd('ul');
}
+
+
+ function showContent()
+ {
+ if (!empty($this->albumid))
+ $this->showAlbum($this->albumid);
+ else
+ $this->showAlbums();
+ }
}
return array('album_id', true, false);
}
+ function getPageLink()
+ {
+ $profile = Profile::StaticGet('id', $this->profile_id);
+ return '/' . $profile->nickname . '/photos/' . $this->album_id;
+ }
+
+ function getThumbUri()
+ {
+ $photo = GNUsocialPhoto::staticGet('album_id', $this->album_id);
+ if (empty($photo))
+ return '/theme/default/default-avatar-profile.png'; //For now...
+ return $photo->thumb_uri;
+ }
+
static function newAlbum($profile_id, $album_name, $album_description)
{
//TODO: Should use foreign key instead...
}
common_log(LOG_INFO, 'album_id : ' . $album->album_id);
return $album;
- }
+ }
}