Example #1
0
 function prepare($args)
 {
     parent::prepare($args);
     $args = $this->returnToArgs();
     $this->user = common_current_user();
     $this->photoid = $args[1]['photoid'];
     $this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
     return true;
 }
 function getThumbUri()
 {
     $photo = GNUsocialPhoto::getKV('album_id', $this->album_id);
     if (empty($photo)) {
         return '/theme/default/default-avatar-profile.png';
     }
     //For now...
     return $photo->thumb_uri;
 }
Example #3
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $args = $this->returnToArgs();
     $this->photoid = $args[1]['photoid'];
     $this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
     $this->notice = Notice::getKV('id', $this->photo->notice_id);
     $this->user = Profile::getKV('id', $this->notice->profile_id);
     $this->conv = $this->notice->getConversation();
     return true;
 }
Example #4
0
 function deleteAlbum()
 {
     $cur = common_current_user();
     if (empty($cur)) {
         return;
     }
     $album_id = $this->trimmed('album');
     $album = GNUsocialPhotoAlbum::getKV('album_id', $album_id);
     if (empty($album)) {
         $this->showForm(_('This album does not exist or has been deleted.'));
         return;
     }
     //Check if the album has any photos in it before deleting
     $photos = GNUsocialPhoto::getKV('album_id', $album_id);
     if (empty($photos)) {
         $album->delete();
         $this->showForm(_('Album deleted'), true);
     } else {
         $this->showForm(_('Cannot delete album when there are photos in it!'), false);
     }
 }
Example #5
0
 function showAlbum($album_id)
 {
     $album = GNUsocialPhotoAlbum::getKV('album_id', $album_id);
     if (!$album) {
         return;
     }
     $page = $_GET['pageid'];
     if (!filter_var($page, FILTER_VALIDATE_INT)) {
         $page = 1;
     }
     $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9);
     $this->elementStart('div', array('class' => 'galleryheader'));
     if ($page > 1) {
         $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page - 1)), 'Previous page');
         $this->raw(' | ');
     }
     if (GNUsocialPhoto::getGalleryPage($page + 1, $album->album_id, 9)) {
         $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page + 1)), 'Next page');
         $this->raw(' | ');
     }
     //$this->element('a', array('href' => '#',
     //                          'onclick' => 'return increasePhotoSize()'), '+');
     //$this->raw(' | ');
     //$this->element('a', array('href' => '#',
     //                          'onclick' => 'return decreasePhotoSize()'), '-');
     //$this->raw(' | ');
     $this->showResizeImagesBox();
     $this->elementEnd('div');
     foreach ($photos as $photo) {
         $this->elementStart('a', array('href' => $photo->getPageLink()));
         $this->elementStart('div', array('class' => 'photocontainer'));
         $this->element('img', array('src' => $photo->thumb_uri, 'class' => 'photoingallery'));
         $this->element('div', array('class' => 'phototitle'), $photo->title);
         $this->elementEnd('div');
         $this->elementEnd('a');
     }
 }
 function onStartShowNoticeItem($action)
 {
     $photo = GNUsocialPhoto::getKV('notice_id', $action->notice->id);
     if ($photo) {
         $action->out->elementStart('div', 'entry-title');
         $action->showAuthor();
         $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');
         $action->out->elementEnd('div');
         $action->showNoticeInfo();
         $action->showNoticeOptions();
         return false;
     }
     return true;
 }
 static function getGalleryPage($page_id, $album_id, $gallery_size)
 {
     $page_offset = ($page_id - 1) * $gallery_size;
     $sql = 'SELECT * FROM GNUsocialPhoto WHERE album_id = ' . $album_id . ' ORDER BY notice_id LIMIT ' . $page_offset . ',' . $gallery_size;
     $photo = new GNUsocialPhoto();
     $photo->query($sql);
     $photos = array();
     while ($photo->fetch()) {
         $photos[] = clone $photo;
     }
     return $photos;
 }