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); }
public function execute() { $url = waRequest::param('url'); $album = waRequest::param('album'); $this->hash = waRequest::param('hash'); if (!$url) { throw new waException(_w('Page not found', 404)); } $this->photo_model = new photosPhotoModel(); $photo = $this->getPhoto($url); if (!$photo) { throw new waException(_w('Page not found'), 404); } if (!$this->private_hash && !$this->inCollection($photo, $this->hash)) { throw new waException(_w('Page not found'), 404); } $photo = photosPhoto::escapeFields($photo); $size = waRequest::get('size', null, waRequest::TYPE_STRING); $is_mini = waRequest::get('mini', 0, waRequest::TYPE_INT); if ($is_mini) { $size = $size ? $size : photosPhoto::getBigPhotoSize(); // mini version of loading photo (in albums loading photo in stack) $photo['thumb_custom'] = photosPhoto::getThumbInfo($photo, $size); $this->response['photo'] = $photo; return; } // delegate work to special render helper $render_helper = new photosPhotoRenderHelper($photo, $this->private_hash); $result = $render_helper->workUp(array('album' => $album, 'hash' => $this->hash, 'need_photo_stream' => false)); if ($size) { $result['photo']['thumb_custom'] = photosPhoto::getThumbInfo($result['photo'], $size); } // pull out result of working up $this->response['photo'] = $result['photo']; $this->response['tags'] = $result['blocks']['tags']; $this->response['exif'] = $result['blocks']['exif']; $this->response['albums'] = $result['blocks']['albums']; $this->response['author'] = $result['blocks']['author']; $this->response['stack_nav'] = $result['blocks']['stack_nav']; /** * 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 */ $this->response['frontend_photo'] = wa()->event('frontend_photo', $photo); }
public static function escapePhotoFields(&$photos) { foreach ($photos as &$photo) { $photo = photosPhoto::escapeFields($photo); } unset($photo); }
public function execute() { $id = waRequest::post('id', 0, waRequest::TYPE_INT); $in_stack = waRequest::post('in_stack', 0, waRequest::TYPE_INT); $hash = waRequest::post('hash', null, waRequest::TYPE_STRING_TRIM); $hash = urldecode($hash); // get photo $this->photo_model = new photosPhotoModel(); $this->photo = $this->photo_model->getById($id); if (!$this->photo) { throw new waException(_w("Photo doesn't exists"), 404); } $photo_rights_model = new photosPhotoRightsModel(); if (!$photo_rights_model->checkRights($this->photo)) { throw new waRightsException(_w("You don't have sufficient access rights")); } $this->photo['name_not_escaped'] = $this->photo['name']; $this->photo = photosPhoto::escapeFields($this->photo); $this->photo['upload_datetime_formatted'] = waDateTime::format('humandate', $this->photo['upload_datetime']); $this->photo['upload_timestamp'] = strtotime($this->photo['upload_datetime']); $this->photo['edit_rights'] = $photo_rights_model->checkRights($this->photo, true); $this->photo['private_url'] = photosPhotoModel::getPrivateUrl($this->photo); $this->photo['thumb'] = photosPhoto::getThumbInfo($this->photo, photosPhoto::getThumbPhotoSize()); $this->photo['thumb_big'] = photosPhoto::getThumbInfo($this->photo, photosPhoto::getBigPhotoSize()); $this->photo['thumb_middle'] = photosPhoto::getThumbInfo($this->photo, photosPhoto::getMiddlePhotoSize()); $original_photo_path = photosPhoto::getOriginalPhotoPath($this->photo); if (wa('photos')->getConfig()->getOption('save_original') && file_exists($original_photo_path)) { $this->photo['original_exists'] = true; } else { $this->photo['original_exists'] = false; } $photo_tags_model = new photosPhotoTagsModel(); $tags = $photo_tags_model->getTags($id); $this->photo['tags'] = $tags; $this->response['photo'] = $this->photo; // get stack if it's possible if (!$in_stack && ($stack = $this->photo_model->getStack($id, array('thumb' => true, 'thumb_crop' => true, 'thumb_big' => true, 'thumb_middle' => true)))) { $this->response['stack'] = $stack; } // get albums $album_photos_model = new photosAlbumPhotosModel(); $albums = $album_photos_model->getAlbums($id, array('id', 'name')); $this->response['albums'] = isset($albums[$id]) ? array_values($albums[$id]) : array(); // exif info $exif_model = new photosPhotoExifModel(); $exif = $exif_model->getByPhoto($this->photo['id']); if (isset($exif['DateTimeOriginal'])) { $exif['DateTimeOriginal'] = waDateTime::format('humandatetime', $exif['DateTimeOriginal'], date_default_timezone_get()); } $this->response['exif'] = $exif; // get author $contact = new waContact($this->photo['contact_id']); $this->response['author'] = array('id' => $contact['id'], 'name' => photosPhoto::escape($contact['name']), 'photo_url' => $contact->getPhoto(photosPhoto::AUTHOR_PHOTO_SIZE), 'backend_url' => $this->getConfig()->getBackendUrl(true) . 'contacts/#/contact/' . $contact['id']); // for making inline-editable widget $this->response['frontend_link_template'] = photosFrontendPhoto::getLink(array('url' => '%url%')); $hooks = array(); $parent_id = $this->photo_model->getStackParentId($this->photo); $photo_id = $parent_id ? $parent_id : $id; /** * Extend photo page * Add extra widget(s) * @event backend_photo * @return array[string][string]string $return[%plugin_id%]['bottom'] In bottom, under photo any widget */ $hooks['backend_photo'] = wa()->event('backend_photo', $photo_id); $this->response['hooks'] = $hooks; if ($hash !== null) { $collection = new photosCollection($hash); if (strstr($hash, 'rate>0') !== false) { $collection->orderBy('p.rate DESC, p.id'); } $this->response['photo_stream'] = $this->getPhotoStream($collection); if ($collection->getAlbum()) { $this->response['album'] = $collection->getAlbum(); } } }