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; }
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); }
static function getUrl($post, $type = 'post') { if ($type == 'post' && !empty($post['album_id']) && $post['album_link_type'] == 'photos') { wa('photos'); if (empty($post['album']['full_url'])) { $album_full_url = photosCollection::frontendAlbumHashToUrl('album/' . $post['album_id']); } else { $album_full_url = $post['album']['full_url']; } $url = photosFrontendAlbum::getLink($album_full_url); if (wa()->getEnv() == 'backend') { return array($url); } else { return $url; } } static $blog_urls = array(); $params = array(); $fields = array('blog_url', 'year', 'month', 'day'); foreach ($fields as $field) { if (isset($post[$field])) { $params[$field] = $post[$field]; } } if (isset($post['id']) && $post['id'] && isset($post['url']) && $post['url']) { $params['post_url'] = $post['url']; } elseif ($type != 'timeline') { $params['post_url'] = '%post_url%'; } $blog_id = null; if ($type != 'author') { if (isset($post['datetime']) && $post['datetime'] && ($time = date_parse($post['datetime']))) { $params['post_year'] = sprintf('%04d', $time['year']); $params['post_month'] = sprintf('%02d', $time['month']); $params['post_day'] = sprintf('%02d', $time['day']); } elseif ($type != 'timeline') { $params['post_year'] = '%year%'; $params['post_month'] = '%month%'; $params['post_day'] = '%day%'; } if (!isset($params['blog_url']) && isset($post['blog_id'])) { $blog_id = $post['blog_id']; if (!isset($blog_urls[$blog_id])) { $blog_urls[$blog_id] = false; $blog_model = new blogBlogModel(); if ($blog_data = $blog_model->getById($blog_id)) { if ($blog_data['status'] == blogBlogModel::STATUS_PUBLIC) { if (strlen($blog_data['url'])) { $blog_urls[$blog_id] = $blog_data['url']; } else { $blog_urls[$blog_id] = $blog_id; } } } } $params['blog_url'] = $blog_urls[$blog_id]; } elseif (isset($params['blog_url']) && isset($post['blog_id'])) { $blog_id = $post['blog_id']; } } $route = false; if (!isset($params['blog_url']) || $params['blog_url'] !== false) { switch ($type) { case 'comment': $route = 'blog/frontend/comment'; break; case 'timeline': $route = 'blog/frontend'; break; case 'author': if ($params['contact_id'] = $post['contact_id']) { $route = 'blog/frontend'; } break; case 'post': default: $route = 'blog/frontend/post'; break; } } return $route ? blogHelper::getUrl($blog_id, $route, $params) : array(); }
/** Description of all framework settlements. */ public static function getDomains($hash, $photo = null) { $domains = array(); // Params for getRouteUrl() based on $hash or $photo if ($photo) { $route_module_action = 'photos/frontend/photo'; $route_url_params = array('url' => $photo['url'] . (isset($photo['status']) && ($photo['status'] <= 0 && !empty($photo['hash'])) ? ':' . $photo['hash'] : '')); } else { $route_module_action = 'photos/frontend'; $route_url_params = array(); $hash = trim($hash, '#/'); $hash = explode('/', $hash); if (count($hash) >= 2) { if ($hash[0] == 'album') { $route_module_action = 'photos/frontend/album'; $route_url_params = array('url' => photosCollection::frontendAlbumHashToUrl('album/' . $hash[1])); } else { $route_url_params[$hash[0]] = $hash[1]; } } else { if (count($hash) == 1) { $route_url_params[$hash[0]] = $hash[0]; } } } // Domains with Photos frontend foreach (wa()->getRouting()->getByApp('photos') as $domain => $params) { $domain_url = 'http://' . rtrim(wa()->getRouting()->getDomainUrl($domain), '/') . '/'; $domains[$domain_url] = array('url' => $domain_url, 'frontend_url' => wa()->getRouteUrl($route_module_action, $route_url_params, true, $domain)); } // Other domains foreach (array_merge(wa()->getRouting()->getDomains(), array(waRequest::server('HTTP_HOST') . wa()->getConfig()->getRootUrl())) as $domain) { $domain_url = 'http://' . rtrim(wa()->getRouting()->getDomainUrl($domain), '/') . '/'; if (empty($domains[$domain_url])) { $domains[$domain_url] = array('url' => $domain_url, 'frontend_url' => ''); } } return $domains; }