public function execute()
 {
     $count = $this->getConfig()->getOption('photos_per_page');
     $padding_count = 2;
     $direction = waRequest::get('direction', 1, waRequest::TYPE_INT);
     $album = waRequest::param('album');
     $hash = waRequest::param('hash');
     $url = waRequest::param('url');
     $album = waRequest::param('album');
     if (!$url) {
         throw new waException(_w('Page not found', 404));
     }
     if ($album && $album['status'] <= 0) {
         $album['full_url'] = photosCollection::frontendAlbumHashToUrl($hash);
     }
     $photo_model = new photosPhotoModel();
     $photo = $photo_model->getByField('url', $url);
     $real_count = $count;
     if ($photo) {
         $c = new photosCollection($hash);
         $offset = $c->getPhotoOffset($photo);
         if ($direction > 0) {
             $offset += 1;
             // next photos
         } else {
             $offset -= $real_count;
             // prev photos
             if ($offset < 0) {
                 $real_count += $offset;
                 $offset = 0;
             }
         }
         $photo_stream = $c->getPhotos('*,thumb,thumb_crop,tags', $offset, $real_count);
         $photo_stream = photosCollection::extendPhotos($photo_stream);
         foreach ($photo_stream as &$item) {
             $item['thumb_custom'] = array('url' => photosPhoto::getPhotoUrlTemplate($item));
             $item['full_url'] = photosFrontendPhoto::getLink(array('url' => $item['url']), $album ? $album : $hash);
         }
         unset($item);
         $real_count = count($photo_stream);
         if ($real_count < $count) {
             if ($direction > 0) {
                 $photo_stream = array_merge($photo_stream, array_pad(array(), $padding_count, null));
             } else {
                 $photo_stream = array_merge(array_pad(array(), $padding_count, null), $photo_stream);
             }
         }
         $renderer = new photosPhotoHtmlRenderer($this->getTheme());
         echo $renderer->getPhotoStream($photo_stream, null);
     }
     exit;
 }
 private function renderStackNavigationPanel()
 {
     if ($this->stack) {
         return $this->renderer->getStackNavigationPanel($this->stack, $this->photo);
     } else {
         return '';
     }
 }
 protected function workupPhotos(&$photos)
 {
     $renderer = new photosPhotoHtmlRenderer($this->getTheme());
     $photo_model = new photosPhotoModel();
     // parent of current photo (that stacked, i.e. in stack)
     $parent_id = null;
     if ($this->photo_url) {
         $stacked_photo = $photo_model->getByField('url', $this->photo_url);
         if (!$stacked_photo) {
             throw new waException(_w('Page not found', 404));
         }
         $parent_id = $photo_model->getStackParentId($stacked_photo);
     }
     // During going over all photos we also look if some photo is a parent of current stacked photo
     foreach ($photos as &$photo) {
         $photo['stack_nav'] = '';
         $stack = (array) $photo_model->getStack($photo['id'], array('tags' => true));
         if ($stack) {
             foreach ($stack as &$item) {
                 $item['thumb_custom'] = array('url' => photosPhoto::getPhotoUrlTemplate($item));
                 $item['full_url'] = photosFrontendAlbum::getLink($this->album) . $item['url'] . '/';
             }
             unset($item);
             // iterable photo is parent of current stacked photo - replace
             if ($parent_id == $photo['id']) {
                 $photo = $stacked_photo;
                 $photo['full_url'] = photosFrontendAlbum::getLink($this->album) . $photo['url'] . '/';
                 $photo['stack_nav'] = $renderer->getStackNavigationPanel($stack, $photo);
             } else {
                 $photo['stack_nav'] = $renderer->getStackNavigationPanel($stack, $photo);
             }
         }
         $photo['frontend_link'] = photosFrontendPhoto::getLink($photo, array('full_url' => $this->album_url));
     }
     unset($photo);
 }