コード例 #1
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'));
 }
コード例 #2
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');
 }
コード例 #3
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);
 }
コード例 #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 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);
 }
コード例 #6
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);
 }
コード例 #7
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);
 }
コード例 #8
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());
 }
コード例 #9
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, '/#') . '/'));
 }