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() { $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() { $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); } }
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')); }
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() { $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'); }
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() { $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); } }
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); }
public static function getEmbedPhotoListContext($hash, $size, $limit = null, $context = null) { $link = photosCollection::getFrontendLink($hash); $collection = new photosCollection($hash); $thumb_key = 'thumb_' . $size; $photos = $collection->getPhotos('*, ' . $thumb_key, 0, $limit == null ? 500 : $limit); $photo_ids = array_keys($photos); $photo_model = new photosPhotoModel(); $public_photo_ids = $photo_model->filterByField($photo_ids, 'status', 1); $all_public = count($photo_ids) == count($public_photo_ids); // change default collection sort if hash looks like id/1,2,3,4 if (strstr($hash, 'id/') !== false) { $photo_ids = explode(',', preg_replace('/\\/*id\\//', '', $hash)); $old_photos = $photos; $photos = array(); foreach ($photo_ids as $photo_id) { $photo_id = intval($photo_id); // need in case of private photo (cause of hash suffix) if (isset($old_photos[$photo_id])) { $photos[$photo_id] = $old_photos[$photo_id]; } } } $urls = ''; $html = ''; $html_with_descriptions = ''; foreach ($photos as $photo) { $urls .= $photo[$thumb_key]['url'] . PHP_EOL; $img_html = photosPhoto::getEmbedImgHtml($photo, $size); $html_with_descriptions .= '<p>' . ($photo['description'] ? $photo['description'] . '<br>' : '') . $img_html . '</p>' . PHP_EOL; $html .= $img_html . '<br>' . PHP_EOL; } $params_string = '"' . $hash . '", "' . $size . '"'; $smarty_code = '{if $wa->photos}' . PHP_EOL; $smarty_code .= ' {$photos = $wa->photos->photos(' . $params_string . ')}' . PHP_EOL; $smarty_code .= ' {foreach $photos as $photo}' . PHP_EOL; $smarty_code .= ' <p>{if $photo.description}{$photo.description}<br>{/if}' . PHP_EOL; $smarty_code .= ' <img src=\'{$photo.' . $thumb_key . '.url}\' alt=\'{$photo.name}.{$photo.ext}\'>' . PHP_EOL; $smarty_code .= ' </p>' . PHP_EOL; $smarty_code .= ' {/foreach}' . PHP_EOL; $smarty_code .= '{/if}' . PHP_EOL; return array('urls' => $urls, 'html' => $html, 'html_with_descriptions' => $html_with_descriptions, 'link' => $link, 'smarty_code' => $smarty_code, 'count' => count($photos), 'all_public' => $all_public, 'domains' => self::getDomains($hash)); }