public function execute() { $id = waRequest::post('id', null, waRequest::TYPE_INT); $parent_id = waRequest::post('parent_id', null, waRequest::TYPE_INT); $before_id = waRequest::post('before_id', 0, waRequest::TYPE_INT); $album_model = new photosAlbumModel(); $album = $album_model->move($id, $before_id, $parent_id); $this->response['album'] = $album; if ($album['status'] == 1) { $this->response['frontend_link'] = photosFrontendAlbum::getLink($album); } // recalculate // TODO: optimaize $albums = $album_model->getDescendant($album['id']); $albums[] = $album; $counters = array(); foreach ($albums as &$item) { if ($item['type'] == photosAlbumModel::TYPE_DYNAMIC) { $c = new photosCollection('album/' . $item['id']); $counters[$item['id']] = $c->count(); } } unset($item); $this->response['counters'] = $counters; }
public function execute() { $album_id = waRequest::post('id', null, waRequest::TYPE_INT); $status = waRequest::post('status', 0, waRequest::TYPE_INT); $groups = waRequest::post('groups', array(), waRequest::TYPE_ARRAY_INT); $count = waRequest::post('count', 0, waRequest::TYPE_INT); $offset = waRequest::post('offset', 0, waRequest::TYPE_INT); $collection = new photosCollection('album/' . $album_id); $this->response['offset'] = $offset; $photos = $collection->getPhotos('*', $offset, $count, false); $photo_ids = array(); foreach ($photos as $photo) { if ($photo['status'] == 1 && $status == 1) { continue; } if ($photo['stack_count'] > 0) { $photo_ids = array_merge($photo_ids, $photo_model->getIdsByParent($photo['id'])); } else { $photo_ids[] = $photo['id']; } } $photo_rights_model = new photosPhotoRightsModel(); $allowed_photo_ids = $photo_rights_model->filterAllowedPhotoIds($photo_ids, true); $photo_model = new photosPhotoModel(); $photo_model->updateAccess($allowed_photo_ids, $status, $groups); }
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'; }
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)); }
public function execute() { $hash = $this->get('hash'); $collection = new photosCollection($hash); $offset = waRequest::get('offset', 0, 'int'); if ($offset < 0) { throw new waAPIException('invalid_param', 'Param offset must be greater than or equal to zero'); } $limit = waRequest::get('limit', 100, 'int'); if ($limit < 0) { throw new waAPIException('invalid_param', 'Param limit must be greater than or equal to zero'); } if ($limit > 1000) { throw new waAPIException('invalid_param', 'Param limit must be less or equal 1000'); } $photos = $collection->getPhotos('*,thumb', $offset, $limit); foreach ($photos as &$p) { if (isset($p['thumb']['url'])) { $p['image_url'] = $p['thumb']['url']; unset($p['thumb']); } } unset($p); $this->response['count'] = $collection->count(); $this->response['offset'] = $offset; $this->response['limit'] = $limit; $this->response['photos'] = array_values($photos); }
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 getPhotos($offset, $limit) { $fields = "*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights"; if ($this->getRequest()->isMobile()) { $fields = "*,thumb_mobile"; } return $this->collection->getPhotos($fields, $offset, $limit); }
private function inCollection($photo, $hash) { $parent = $this->photo_model->getStackParent($photo); $photo = $parent ? $parent : $photo; // check existing in collection $collection = new photosCollection($hash); $current_offset = $collection->getPhotoOffset($photo); $collection_photos = $collection->getPhotos("id", $current_offset, 1, false); return isset($collection_photos[$photo['id']]); }
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; }
public function execute() { $album_id = waRequest::get('id', null, waRequest::TYPE_INT); if (!$album_id) { throw new waException(_w('Unknown album')); } $album_model = new photosAlbumModel(); $album = $album_model->getById($album_id); $this->view->assign('album', $album); $collection = new photosCollection('/album/' . $album_id); $this->view->assign('photos_count', $collection->count()); }
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); }
public function execute() { $photo_ids = waRequest::get('photo_ids', '', waRequest::TYPE_STRING_TRIM); $size = waRequest::get('size', null, waRequest::TYPE_STRING_TRIM); $hash = waRequest::get('hash', '', waRequest::TYPE_STRING_TRIM); if (strstr($hash, 'search') !== false) { $hash = urldecode($hash); } $sizes = $this->getConfig()->getSizes(); if (!$size || in_array($size, $sizes) === false) { $size = current($sizes); } $photo_model = new photosPhotoModel(); $limit = $photo_model->countAll(); $entire_context['all']['count'] = $limit; if (strstr($hash, 'album') !== false) { $album_collection = new photosCollection($hash); $limit = $album_collection->count(); $entire_context['album']['count'] = $limit; } else { if (strstr($hash, 'tag') !== false) { $tag_collection = new photosCollection($hash); $limit = $tag_collection->count(); $tag = rtrim(end(explode('/', $hash)), '/'); $entire_context['tag'] = array('count' => $limit, 'tag' => $tag); } else { if (strstr($hash, 'rate') !== false) { $rate_collection = new photosCollection($hash); $limit = $rate_collection->count(); $entire_context['rate']['count'] = $limit; } } } if (!$photo_ids && strstr($hash, 'album') === false && strstr($hash, 'tag') === false && strstr($hash, 'rate') === false) { $hash = ''; } else { if ($photo_ids) { $hash = '/id/' . $photo_ids; } } $context = photosPhoto::getEmbedPhotoListContext($hash, $size, $limit); $domains = $context['domains']; if (count($domains) <= 1) { $domains = array(); } $this->view->assign('sizes', $sizes); $this->view->assign('size', $size); $this->view->assign('context', $context); $this->view->assign('is_entire', !$photo_ids); $this->view->assign('entire_context', $entire_context); $this->view->assign('original_domain', wa()->getRootUrl(true)); $this->view->assign('domains', $domains); }
public function execute() { if ($this->getRights('upload')) { $this->executeAction('upload_dialog', new photosUploadAction()); } $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(); $top_level_albums_count = 0; foreach ($albums as $a) { if (!$a['parent_id']) { $top_level_albums_count++; } } /** * Extend photo toolbar in photo-page * Add extra item to toolbar * @event backend_photo_toolbar * @return array[string][string]string $return[%plugin_id%]['edit_menu'] Extra item for edit_menu in photo_toolbar * @return array[string][string]string $return[%plugin_id%]['share_menu'] Extra item for edit_menu in photo_toolbar */ $this->view->assign('backend_photo_toolbar', wa()->event('backend_photo_toolbar')); $tree = new photosViewTree($albums); $this->view->assign('albums', $tree->display()); $this->view->assign('albums_count', count($albums)); $this->view->assign('top_level_albums_count', $top_level_albums_count); $this->view->assign('app_albums', self::getAppAlbums()); $collection = new photosCollection(); $collection_rated = new photosCollection('search/rate>0'); $this->view->assign('count', $collection->count()); $this->view->assign('rated_count', $collection_rated->count()); $this->view->assign('last_login_datetime', $this->getConfig()->getLastLoginTime()); /** * Extend sidebar * Add extra item to sidebar * @event backend_sidebar * @return array[string][string]string $return[%plugin_id%]['menu'] Extra item for menu in sidebar * @return array[string][string]string $return[%plugin_id%]['section'] Extra section in sidebar */ $this->view->assign('backend_sidebar', wa()->event('backend_sidebar')); /** * Include plugins js and css * @event backend_assets * @return array[string]string $return[%plugin_id%] Extra head tag content */ $this->view->assign('backend_assets', wa()->event('backend_assets')); $photo_tag_model = new photosTagModel(); $this->view->assign('cloud', $photo_tag_model->getCloud()); $this->view->assign('popular_tags', $photo_tag_model->popularTags()); $this->view->assign('rights', array('upload' => $this->getRights('upload'), 'edit' => $this->getRights('edit'))); $config = $this->getConfig(); $this->view->assign('big_size', $config->getSize('big')); $this->view->assign('sidebar_width', $config->getSidebarWidth()); }
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; }
/** * * Get data array from photos collection * @param string $hash selector hash * @param int|string|null $size numerical size or size name * @param int $offset optional parameter * @param int $limit optional parameter * * If $limit is omitted but $offset is not than $offset is interpreted as 'limit' and method returns first 'limit' items * If $limit and $offset are omitted that method returns first 500 items * * @return array */ public function photos($hash = '', $size = null, $offset = null, $limit = null) { $size = !is_null($size) ? $size : photosPhoto::getThumbPhotoSize(); $collection = new photosCollection($hash); if (!$limit && $offset) { $limit = $offset; $offset = 0; } if (!$offset && !$limit) { $offset = 0; $limit = 500; } return $collection->getPhotos("*,frontend_link,thumb_" . $size, $offset, $limit, true); }
public function execute() { $album_id = waRequest::get('id', null, waRequest::TYPE_INT); $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(); $album = ifset($albums[$album_id]); if (!$album_id || !$album) { throw new waException(_w('Unknown album')); } $collection = new photosCollection('/album/' . $album_id); $this->view->assign('album', $album); $this->view->assign('photos_count', $collection->count()); $this->view->assign('offspring', $this->getOffspringIds($albums, $album_id)); }
public function execute() { $id = $this->get('id', true); $collection = new photosCollection('id/' . $id); $data = $collection->getPhotos('*,thumb_big'); if (!isset($data[$id])) { throw new waAPIException('invalid_param', 'Photo not found', 404); } $data = $data[$id]; if (isset($data['thumb_big']['url'])) { $data['image_url'] = $data['thumb_big']['url']; unset($data['thumb_big']); } $this->response = $data; }
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); }
public function execute() { $id = waRequest::get('id', null, waRequest::TYPE_INT); $album_model = new photosAlbumModel(); $album = $album_model->getById($id); if (!$album) { throw new waException(_w("Unknown album"), 404); } $album_right_model = new photosAlbumRightsModel(); if (!$album_right_model->checkRights($album, true)) { throw new waException(_w("You don't have sufficient access rights"), 403); } if ($album['type'] == photosAlbumModel::TYPE_DYNAMIC && $album['conditions']) { $album['conditions'] = photosCollection::parseConditions($album['conditions']); } if (!$album['conditions']) { $album['conditions'] = array(); } $absolute_full_url = photosFrontendAlbum::getLink($album); if ($absolute_full_url) { $pos = strrpos($absolute_full_url, $album['url']); $full_base_url = $pos !== false ? rtrim(substr($absolute_full_url, 0, $pos), '/') . '/' : ''; $album['full_base_url'] = $full_base_url; } $this->view->assign('album', $album); if ($album['parent_id']) { $this->view->assign('parent', $album_model->getById($album['parent_id'])); } $collection = new photosCollection('album/' . $id); $photos_count = $collection->count(); $this->view->assign('photos_count', $photos_count); $album_params_model = new photosAlbumParamsModel(); $this->view->assign('params', $album_params_model->get($id)); $groups_model = new waGroupModel(); $groups = $groups_model->getAll('id', true); $rights = $album_right_model->getByField('album_id', $id, 'group_id'); $photo_tag_model = new photosTagModel(); $cloud = $photo_tag_model->getCloud('name'); if (!empty($album['conditions']['tag'][1])) { foreach ($album['conditions']['tag'][1] as $tag_name) { $cloud[$tag_name]['checked'] = true; } } $this->view->assign('rights', $rights); $this->view->assign('groups', $groups); $this->view->assign('cloud', $cloud); }
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); }
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); }
public function execute() { $routes = $this->getRoutes(); $app_id = wa()->getApp(); $album_model = new photosAlbumModel(); $album_photos_model = new photosAlbumPhotosModel(); $page_model = new photosPageModel(); $real_domain = $this->routing->getDomain(null, true, false); foreach ($routes as $route) { $this->routing->setRoute($route); $albums = $album_model->getByField(array('type' => photosAlbumModel::TYPE_STATIC, 'status' => 1), 'id'); $favorites_lastmod_time = null; // albums and photos in albums if ($albums) { $current_album_id = null; $current_album_lastmod_time = null; foreach ((array) $album_photos_model->getPhotos(array_keys($albums)) as $photo) { if ($photo['album_id'] != $current_album_id) { if ($current_album_id) { $this->addUrl(photosFrontendAlbum::getLink($albums[$current_album_id]), $current_album_lastmod_time); } $current_album_id = $photo['album_id']; } $photo_url = photosFrontendPhoto::getLink($photo, $albums[$current_album_id]); $lastmod_time = max($photo['edit_datetime'], $photo['upload_datetime']); $this->addUrl($photo_url, $lastmod_time); $current_album_lastmod_time = max($current_album_lastmod_time, $lastmod_time); if ($photo['rate'] > 0) { $favorites_lastmod_time = max($favorites_lastmod_time, $lastmod_time); } } } // just photos (that aren't inside any album) foreach ((array) $album_photos_model->getPhotos() as $photo) { $photo_url = photosFrontendPhoto::getLink($photo); $lastmod_time = max($photo['edit_datetime'], $photo['upload_datetime']); $this->addUrl($photo_url, $lastmod_time); if ($photo['rate'] > 0) { $favorites_lastmod_time = max($favorites_lastmod_time, $lastmod_time); } } // favorite page $this->addUrl(photosCollection::getFrontendLink('favorites', false), $favorites_lastmod_time ? $favorites_lastmod_time : time()); // pages $main_url = wa()->getRouteUrl($app_id . "/frontend", array(), true, $real_domain); $domain = $this->routing->getDomain(null, true); $sql = "SELECT full_url, url, create_datetime, update_datetime FROM " . $page_model->getTableName() . ' WHERE status = 1 AND domain = s:domain AND route = s:route'; $pages = $page_model->query($sql, array('domain' => $domain, 'route' => $route['url']))->fetchAll(); foreach ($pages as $p) { $this->addUrl($main_url . $p['full_url'], $p['update_datetime'] ? $p['update_datetime'] : $p['create_datetime'], self::CHANGE_MONTHLY, 0.6); } // main page $this->addUrl($main_url, time(), self::CHANGE_DAILY, 1.0); } }
/** * * Get data array from photos collection * @param string $hash selector hash * @param int|string|null $size numerical size or size name * @param int $offset optional parameter * @param int $limit optional parameter * * If $limit is omitted but $offset is not than $offset is interpreted as 'limit' and method returns first 'limit' items * If $limit and $offset are omitted that method returns first 500 items * * @return array */ public function photos($hash = '', $size = null, $offset = null, $limit = null) { $size = !is_null($size) ? $size : photosPhoto::getThumbPhotoSize(); $sizes = array(); foreach (explode(',', $size) as $s) { $sizes[] = 'thumb_' . trim($s); } $sizes = implode(',', $sizes); $collection = new photosCollection($hash); if (!$limit && $offset) { $limit = $offset; $offset = 0; } if (!$offset && !$limit) { $offset = 0; $limit = 500; } return $collection->getPhotos("*,frontend_link,tags," . $sizes, $offset, $limit, true); }
public function execute() { $enabled = wa()->getSetting('enabled', 0, array('photos', 'fotorss')); if (!$enabled) { return null; } $url = wa()->getRouting(); $url = $url->getRouteParam('url_type'); $route = ''; if ($url == 0) { $route = 'photo/'; } $author_on = wa()->getSetting('author_tag', 0, array('photos', 'fotorss')); $max_entries = max(1, wa()->getSetting('posts_number', 0, array('photos', 'fotorss'))); $link = wa()->getRouteUrl('photos/frontend', array(), true); $rss_link = wa()->getRouteUrl('photos/frontend/fotorss', array(), true); $title = waRequest::param('title') ? waRequest::param('title') : wa()->accountName(); $collection = new photosCollection(); $fields = "*,"; $thumbs = wa()->getSetting('thumb', 'default', array('photos', 'fotorss')); if ($thumbs == 'big' || $thumbs == 'middle' || $thumbs == 'mobile' || $thumbs == 'crop') { $thumbs = "thumb_" . $thumbs; } elseif ($thumbs == 'default' || empty($thumbs)) { $thumbs = 'thumb'; } $fields .= $thumbs; $posts = $collection->getphotos($fields, 0, $max_entries); foreach ($posts as &$post) { if ($author_on) { $contact = new waContact($post['contact_id']); $post['author'] = $contact->get('name'); } $post['thumb'] = $post[$thumbs]; if ($thumbs == 'vk') { $post['thumb'] = photosPhoto::getThumbInfo($post, '590x0'); } } wa()->getResponse()->addHeader('Content-type', 'application/rss+xml; charset=utf-8', true); $this->view->assign('posts', $posts); $this->view->assign('info', array('title' => $title, 'link' => $link, 'description' => '', 'language' => 'ru', 'pubDate' => date(DATE_RSS), 'lastBuildDate' => date(DATE_RSS), 'photourl' => $route, 'self' => $rss_link)); }
private function getAlbumsCounters() { $config = $this->getConfig(); $last_activity_datetime = $config->getLastLoginTime(); $albums = array(); $photo_albums = $this->album_photos_model->getAlbums($this->photo_ids, array('id', 'name')); foreach ($photo_albums as &$p_albums) { foreach ($p_albums as $a_id => &$album) { if (!isset($albums[$a_id])) { $collection = new photosCollection('/album/' . $a_id); $album['count'] = $collection->count(); //$album['count_new'] = XXX; $album['count_new'] = 0; $albums[$a_id] = $album; } } unset($album); } unset($p_albums); return $albums; }
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, '/#') . '/')); }
public function execute() { $url = waRequest::param('url'); $this->album = waRequest::param('album'); $this->hash = waRequest::param('hash'); if (!$url) { throw new waException(_w('Page not found', 404)); } $this->photo_model = new photosPhotoModel(); $this->photo = $this->getPhoto($url); if (!$this->photo) { throw new waException(_w('Page not found'), 404); } $this->photo = photosPhoto::escapeFields($this->photo); if ($this->album && $this->album['status'] <= 0) { $this->album['full_url'] = photosCollection::frontendAlbumHashToUrl($this->hash); } // delegate work to special render helper $render_helper = new photosPhotoRenderHelper($this->photo, $this->private_hash); $result = $render_helper->workUp(array('album' => $this->album, 'hash' => $this->hash)); waRequest::setParam('title', $this->photo['name']); waRequest::setParam('nofollow', $this->isNeedNofollow()); waRequest::setParam('breadcrumbs', $this->getBreadcrumbs()); waRequest::setParam('disable_sidebar', true); // pull out work's up result $this->view->assign('photo', $result['photo']); $this->view->assign('albums', $result['blocks']['albums']); $this->view->assign('tags', $result['blocks']['tags']); $this->view->assign('exif', $result['blocks']['exif']); $this->view->assign('author', $result['blocks']['author']); $this->view->assign('stack_nav', $result['blocks']['stack_nav']); $this->view->assign('photo_stream', $result['blocks']['photo_stream']); // if we are not in album, than $album is null $this->view->assign('album', $this->album); /** * Add extra widgets to photo page * @event frontend_photo * @param string[array]mixed $photo photo data * @return array[string][string]string $return[%plugin_id%]['bottom'] In bottom, under photo - any widget * @return array[string][string]string $return[%plugin_id%]['sidebar'] * @return array[string][string]string $return[%plugin_id%]['top_left'] * @return array[string][string]string $return[%plugin_id%]['top_right'] */ $this->view->assign('frontend_photo', wa()->event('frontend_photo', $this->photo)); $version = wa()->getVersion(); $this->getResponse()->addJs('js/common.js?v=' . $version, true); $this->getResponse()->addJs('js/photo.stream.slider.js?v=' . $version, true); $this->getResponse()->addJs('js/frontend.photo.js?v=' . $version, true); }
protected function route($url) { $hash = photosCollection::frontendAlbumUrlToHash($url, $album); if (!$album) { if (preg_match('/^([^\\s]+)\\/([^\\s\\/]+)/', trim($url, '/'), $m)) { $album_url = $m[1]; $photo_url = $m[2]; $hash = photosCollection::frontendAlbumUrlToHash($album_url, $album); $this->photo_url = $photo_url; $this->album_url = $album_url; } } else { $this->album_url = $url; } $this->album = $album; $this->hash = $hash; }
public function execute() { $routes = $this->getRoutes(); $app_id = wa()->getApp(); $album_model = new photosAlbumModel(); $album_photos_model = new photosAlbumPhotosModel(); foreach ($routes as $route) { $this->routing->setRoute($route); $albums = $album_model->getByField(array('type' => photosAlbumModel::TYPE_STATIC, 'status' => 1), 'id'); $favorites_lastmod_time = null; // albums and photos in albums if ($albums) { $current_album_id = null; $current_album_lastmod_time = null; foreach ((array) $album_photos_model->getPhotos(array_keys($albums)) as $photo) { if ($photo['album_id'] != $current_album_id) { if ($current_album_id) { $this->addUrl(photosFrontendAlbum::getLink($albums[$current_album_id]), $current_album_lastmod_time); } $current_album_id = $photo['album_id']; } $photo_url = photosFrontendPhoto::getLink($photo, $albums[$current_album_id]); $lastmod_time = max($photo['edit_datetime'], $photo['upload_datetime']); $this->addUrl($photo_url, $lastmod_time); $current_album_lastmod_time = max($current_album_lastmod_time, $lastmod_time); if ($photo['rate'] > 0) { $favorites_lastmod_time = max($favorites_lastmod_time, $lastmod_time); } } } // just photos (that aren't inside any album) foreach ((array) $album_photos_model->getPhotos() as $photo) { $photo_url = photosFrontendPhoto::getLink($photo); $lastmod_time = max($photo['edit_datetime'], $photo['upload_datetime']); $this->addUrl($photo_url, $lastmod_time); if ($photo['rate'] > 0) { $favorites_lastmod_time = max($favorites_lastmod_time, $lastmod_time); } } // favorite page $this->addUrl(photosCollection::getFrontendLink('favorites', false), $favorites_lastmod_time); // main page wa()->getRouteUrl($app_id . "/frontend", array(), true); } }