コード例 #1
0
 public function execute()
 {
     $query = trim(waRequest::post('q'), ' /');
     $hash = '/search/' . $query;
     $collection = new photosCollection($hash);
     if ($query == 'rate>0') {
         $collection->orderBy('p.rate DESC, p.id');
     }
     $this->template = 'templates/actions/photo/PhotoList.html';
     $count = $this->getConfig()->getOption('photos_per_page');
     $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, $count);
     $photos = photosCollection::extendPhotos($photos);
     $frontend_link = $query == 'rate>0' ? photosCollection::getFrontendLink('favorites', false) : photosCollection::getFrontendLink($hash, false);
     /**
      * @event search_frontend_link
      * @param string $query
      * @return array of bool|string if false - default frontend_link isn't overridden, if string - override default frontend link
      */
     $res = wa()->event('search_frontend_link', $query);
     foreach ($res as $r) {
         if (is_string($r)) {
             $frontend_link = $r;
             break;
         }
     }
     $config = $this->getConfig();
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('frontend_link', $frontend_link);
     $this->view->assign('photos', $photos);
     $this->view->assign('title', $query == 'rate>0' ? _w('Rated') : $collection->getTitle());
     $this->view->assign('total_count', $collection->count());
     $this->view->assign('sort_method', $query == 'rate>0' ? 'rate' : 'upload_datetime');
     $this->view->assign('hash', $hash);
 }
 public function execute()
 {
     $lazy = !is_null(waRequest::get('lazy'));
     if (!$lazy) {
         $this->setLayout(new photosDefaultFrontendLayout());
     } else {
         $this->setTemplate('FrontendPhotos');
     }
     $photos_per_page = wa('photos')->getConfig()->getOption('photos_per_page');
     $limit = $photos_per_page;
     $page = 1;
     if ($lazy) {
         $offset = max(0, waRequest::get('offset', 0, waRequest::TYPE_INT));
     } else {
         $page = max(1, waRequest::get('page', 1, waRequest::TYPE_INT));
         $offset = ($page - 1) * $photos_per_page;
     }
     $c = new photosCollection('publicgallery/myphotos');
     $photos = $c->getPhotos('*', $offset, $limit);
     $photos = photosCollection::extendPhotos($photos);
     $v = wa()->getVersion();
     wa('photos')->getResponse()->addJs('js/lazy.load.js?v=' . $v, true);
     wa('photos')->getResponse()->addJs('js/frontend.photos.js?v=' . $v, true);
     $storage = wa()->getStorage();
     $current_auth = $storage->read('auth_user_data');
     $current_auth_source = $current_auth ? $current_auth['source'] : null;
     $this->view->assign('current_auth', $current_auth, true);
     $adapters = wa()->getAuthAdapters();
     $total_count = $c->count();
     $this->view->assign(array('photos' => $photos, 'page' => $page, 'offset' => $offset, 'photos_per_page' => $photos_per_page, 'total_photos_count' => $total_count, 'lazy_load' => $lazy, 'image_upload_url' => wa()->getRouteUrl('photos/frontend/imageUpload'), 'pages_count' => floor($total_count / $photos_per_page) + 1, 'current_auth_source' => $current_auth_source, 'adapters' => $adapters));
 }
コード例 #3
0
 public function execute()
 {
     $count = $this->getConfig()->getOption('photos_per_page');
     $id = waRequest::post('id', 0, waRequest::TYPE_INT);
     $hash = waRequest::post('hash', '', waRequest::TYPE_STRING_TRIM);
     $offset = waRequest::post('offset', 1, waRequest::TYPE_INT);
     $direction = waRequest::post('direction', 1, waRequest::TYPE_INT);
     $this->collection = new photosCollection($hash);
     if (strstr($hash, 'rate>0') !== false) {
         $this->collection->orderBy('p.rate DESC, p.id');
     }
     if ($id) {
         $photo_model = new photosPhotoModel();
         $photo = $photo_model->getById($id);
         $offset = $this->collection->getPhotoOffset($photo);
         if ($direction > 0) {
             $offset += 1;
         } else {
             $offset -= $count;
             if ($offset < 0) {
                 $count += $offset;
                 $offset = 0;
             }
         }
     }
     $photos = array_values($this->getPhotos($offset, $count));
     $photos = photosCollection::extendPhotos($photos);
     $loaded = count($photos) + $offset;
     $count = $this->collection->count();
     $this->response['photos'] = $photos;
     $this->response['hash'] = $hash;
     $this->response['string'] = array('loaded' => _w('%d photo', '%d photos', $loaded), 'of' => sprintf(_w('of %d'), $count), 'chunk' => $loaded < $count ? _w('%d photo', '%d photos', min($this->getConfig()->getOption('photos_per_page'), $count - $loaded)) : false);
 }
コード例 #4
0
 public function execute()
 {
     $tag_name = waRequest::get('tag');
     $tag_name = urldecode($tag_name);
     $tag_model = new photosTagModel();
     $tag = $tag_model->getByName($tag_name);
     $title = _w('Tag not found');
     $photos = array();
     $config = $this->getConfig();
     if ($tag) {
         $hash = '/tag/' . $tag_name;
         $collection = new photosCollection($hash);
         $count = $config->getOption('photos_per_page');
         $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, $count);
         $photos = photosCollection::extendPhotos($photos);
         $title = $collection->getTitle();
         $this->view->assign('frontend_link', photosCollection::getFrontendLink($hash));
         $this->view->assign('total_count', $collection->count());
     }
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('title', $title);
     $this->view->assign('photos', $photos);
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('sort_method', 'upload_datetime');
     $this->template = 'templates/actions/photo/PhotoList.html';
 }
コード例 #5
0
 public static function loadAlbums(&$posts)
 {
     $album_ids = array();
     foreach ($posts as &$p) {
         $p['album'] = null;
         if ($p['album_id']) {
             $album_ids[$p['album_id']] = $p['album_id'];
         }
     }
     unset($p);
     if (!$album_ids || !self::isAvailable()) {
         return $posts;
     }
     wa('photos');
     // Albums
     $album_model = new photosAlbumModel();
     $albums = $album_model->getById($album_ids);
     $albums[0] = $album_model->getEmptyRow();
     // Album photos and additional fields
     foreach ($albums as &$a) {
         $a['params'] = array();
         $a['photos'] = array();
         $a['frontend_link'] = photosFrontendAlbum::getLink($a);
         if (wa()->getEnv() == 'backend') {
             $a['backend_link'] = wa()->getAppUrl('photos') . '#/album/' . $a['id'] . '/';
         }
         if ($a['id']) {
             $collection = new photosCollection('album/' . $a['id']);
             $collection->setCheckRights(false);
             $a['photos'] = $collection->getPhotos("*,thumb,thumb_crop,thumb_big,frontend_link,tags", 0, 100500);
             if ($a['photos']) {
                 $a['photos'] = photosCollection::extendPhotos($a['photos']);
             }
         }
     }
     unset($a);
     // Album params
     $album_params_model = new photosAlbumParamsModel();
     foreach ($album_params_model->get(array_keys($albums)) as $album_id => $params) {
         $albums[$album_id] += $params;
         $albums[$album_id]['params'] = $params;
     }
     // Attach albums to posts
     foreach ($posts as &$p) {
         if ($p['album_id']) {
             if (!empty($albums[$p['album_id']])) {
                 $p['album'] = $albums[$p['album_id']];
             } else {
                 $p['album'] = $albums[0];
             }
         }
     }
     unset($p);
     return $posts;
 }
コード例 #6
0
 public function execute()
 {
     $this->collection = new photosCollection('');
     $count = $this->getConfig()->getOption('photos_per_page');
     $photos = $this->getPhotos(0, $count);
     $photos = photosCollection::extendPhotos($photos);
     $this->view->assign('photos', $photos);
     $this->view->assign('frontend_link', photosCollection::getFrontendLink(''));
     $this->view->assign('title', $this->collection->getTitle());
     $this->view->assign('total_count', $this->collection->count());
     $this->view->assign('big_size', $this->getConfig()->getSize('big'));
 }
コード例 #7
0
 public function execute()
 {
     $id = waRequest::get('id', null, waRequest::TYPE_INT);
     if (!$id) {
         throw new waException(_w('Unknown album'));
     }
     $album_model = new photosAlbumModel();
     $album = $album_model->getById($id);
     if (!$album) {
         throw new waException(_w('Unknown album'));
     }
     // check rights
     $album_rights_model = new photosAlbumRightsModel();
     if (!$album_rights_model->checkRights($album)) {
         throw new waRightsException(_w("You don't have sufficient access rights"));
     }
     $album['edit_rights'] = $album_rights_model->checkRights($album, true);
     $child_albums = $album_model->getChildren($album['id']);
     $album_model->keyPhotos($child_albums);
     $hash = '/album/' . $id;
     $frontend_link = photosCollection::getFrontendLink($hash);
     $collection = new photosCollection($hash);
     $config = $this->getConfig();
     $count = $config->getOption('photos_per_page');
     $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, $count);
     $photos = photosCollection::extendPhotos($photos);
     $album_photos_model = new photosAlbumPhotosModel();
     $album['count'] = $collection->count();
     if ($album['type'] == photosAlbumModel::TYPE_DYNAMIC) {
         $album['conditions'] = photosCollection::parseConditions($album['conditions']);
     }
     $album['count_new'] = 0;
     $sort_method = 'sort';
     if ($album['type'] == photosAlbumModel::TYPE_DYNAMIC) {
         $params_model = new photosAlbumParamsModel();
         $params = $params_model->get($album['id']);
         if ($params && isset($params['order']) && $params['order'] == 'rate') {
             $sort_method = 'rate';
         } else {
             $sort_method = 'upload_datetime';
         }
     }
     $this->template = 'templates/actions/photo/PhotoList.html';
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('album', $album);
     $this->view->assign('child_albums', $child_albums);
     $this->view->assign('frontend_link', $frontend_link);
     $this->view->assign('photos', $photos);
     $this->view->assign('title', $collection->getTitle());
     $this->view->assign('hash', $hash);
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('sort_method', $sort_method);
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 public function execute()
 {
     $this->collection = new photosCollection('');
     $config = $this->getConfig();
     $count = $config->getOption('photos_per_page');
     $photos = $this->getPhotos(0, $count);
     $photos = photosCollection::extendPhotos($photos);
     $this->view->assign('photos', $photos);
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('frontend_link', photosCollection::getFrontendLink(''));
     $this->view->assign('title', $this->collection->getTitle());
     $this->view->assign('total_count', $this->collection->count());
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('sort_method', 'upload_datetime');
 }
コード例 #10
0
 public function finite()
 {
     $collection = new photosCollection($this->hash);
     $photos = $collection->getPhotos("*,thumb,frontend_link,tags", $this->offset, $this->photos_per_page);
     $photos = photosCollection::extendPhotos($photos);
     if ($this->hash) {
         $title = $collection->getTitle();
         if (!$title) {
             $this->getResponse()->setTitle(waRequest::param('title') ? waRequest::param('title') : wa()->accountName());
         } else {
             $this->getResponse()->setTitle($title);
         }
         $this->view->assign('title', photosPhoto::escape($title));
     } else {
         $this->getResponse()->setTitle(waRequest::param('title') ? waRequest::param('title') : wa()->accountName());
         $this->getResponse()->setMeta('keywords', waRequest::param('meta_keywords'));
         $this->getResponse()->setMeta('description', waRequest::param('meta_description'));
         $this->view->assign('title', '');
     }
     $this->workupPhotos($photos);
     $total_count = $collection->count();
     $this->view->assign('photos_per_page', $this->photos_per_page);
     $this->view->assign('pages_count', floor($total_count / $this->photos_per_page) + 1);
     $this->view->assign('total_photos_count', $total_count);
     $this->view->assign('offset', $this->offset);
     $this->view->assign('photos', $photos);
     $is_xhr = waRequest::isXMLHttpRequest();
     $this->view->assign('is_xhr', $is_xhr);
     if ($is_xhr) {
         $this->view->assign('frontend_collection', array());
     } else {
         /**
          * @event frontend_collection
          * @return array[string][string]string $return[%plugin_id%]['name'] Extra name info
          * @return array[string][string]string $return[%plugin_id%]['content'] Extra album description and etc
          * @return array[string][string]string $return[%plugin_id%]['footer'] Footer section
          * @return array[string][string]string $return[%plugin_id%]['sidebar'] Footer section
          * @return array[string][string]string $return[%plugin_id%]['footer'] Footer section
          */
         $this->view->assign('frontend_collection', wa()->event('frontend_collection'));
     }
     $this->view->assign('lazy_load', !is_null(waRequest::get('lazy')));
     $v = wa()->getVersion();
     $this->getResponse()->addJs('js/lazy.load.js?v=' . $v, true);
     $this->getResponse()->addJs('js/frontend.photos.js?v=' . $v, true);
 }
コード例 #11
0
 public function execute()
 {
     $query = trim(waRequest::post('q'), ' /');
     $hash = '/search/' . $query;
     $collection = new photosCollection($hash);
     if ($query == 'rate>0') {
         $collection->orderBy('p.rate DESC, p.id');
     }
     $this->template = 'templates/actions/photo/PhotoList.html';
     $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights");
     $photos = photosCollection::extendPhotos($photos);
     $this->view->assign('big_size', $this->getConfig()->getSize('big'));
     $this->view->assign('frontend_link', $query == 'rate>0' ? photosCollection::getFrontendLink('favorites', false) : photosCollection::getFrontendLink($hash, false));
     $this->view->assign('photos', $photos);
     $this->view->assign('title', $query == 'rate>0' ? _w('Rated') : $collection->getTitle());
     $this->view->assign('total_count', $collection->count());
 }
 public function execute()
 {
     $status = waRequest::get('status', 'waited', waRequest::TYPE_STRING_TRIM);
     $offset = waRequest::get('offset', 1, waRequest::TYPE_INT);
     $c = new photosCollection('', array('ignore_moderation' => true));
     $c->addWhere("p.moderation='" . ($status == 'waited' ? 'waited' : 'declined') . "'");
     $fields = "*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights";
     if ($this->getRequest()->isMobile()) {
         $fields = "*,thumb_mobile";
     }
     $photos = array_values($c->getPhotos($fields, $offset, $this->getConfig()->getOption('photos_per_page')));
     $photos = photosCollection::extendPhotos($photos);
     $loaded = count($photos) + $offset;
     $count = $c->count();
     $this->response['photos'] = $photos;
     $this->response['status'] = $status;
     $this->response['string'] = array('loaded' => _w('%d photo', '%d photos', $loaded), 'of' => sprintf(_w('of %d'), $count), 'chunk' => $loaded < $count ? _w('%d photo', '%d photos', min($this->getConfig()->getOption('photos_per_page'), $count - $loaded)) : false);
 }
コード例 #13
0
 public function execute()
 {
     $app_id = waRequest::request('app_id');
     if ($app_id && wa()->appExists($app_id) && wa()->getUser()->getRights($app_id, 'backend')) {
         $hash = 'app/' . $app_id;
     } else {
         $hash = '';
     }
     $this->collection = new photosCollection($hash);
     $config = $this->getConfig();
     $count = $config->getOption('photos_per_page');
     $photos = $this->getPhotos(0, $count);
     $photos = photosCollection::extendPhotos($photos);
     $this->view->assign('photos', $photos);
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('frontend_link', $hash ? '' : photosCollection::getFrontendLink($hash));
     $this->view->assign('title', $this->collection->getTitle());
     $this->view->assign('total_count', $this->collection->count());
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('sort_method', 'upload_datetime');
     $this->view->assign('hash', $hash);
 }
コード例 #14
0
 public function execute()
 {
     $collection = new photosCollection();
     $hash = '';
     // Specific album?
     if ($id = waRequest::request('album_id', null, 'int')) {
         $album_model = new photosAlbumModel();
         $album = $album_model->getById($id);
         if (!$album) {
             throw new waException(_w('Unknown album'));
         }
         // check rights
         $album_rights_model = new photosAlbumRightsModel();
         if (!$album_rights_model->checkRights($album)) {
             throw new waRightsException(_w("You don't have sufficient access rights"));
         }
         $album['edit_rights'] = $album_rights_model->checkRights($album, true);
         $hash = '/album/' . $id;
     } else {
         if ($app_id = waRequest::request('app_id', '', 'string')) {
             if (wa()->appExists($app_id) && wa()->getUser()->getRights($app_id, 'backend')) {
                 $hash = 'app/' . $app_id;
             } else {
                 throw new waRightsException(_w("You don't have sufficient access rights"));
             }
         }
     }
     // Photos
     $collection = new photosCollection($hash);
     $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, 100500);
     $photos = photosCollection::extendPhotos($photos);
     // Album tree
     $album_model = new photosAlbumModel();
     $albums = $album_model->getAlbums();
     $albums_tree = new photosViewTree($albums);
     $this->view->assign(array('title' => $collection->getTitle(), 'photos' => $photos, 'albums_tree_html' => $albums_tree->display(), 'app_albums' => photosDefaultLayout::getAppAlbums('blog'), 'hash' => '#/' . trim($hash, '/#') . '/'));
 }