public function execute() { $photo_id = waRequest::get('photo_id', array(), waRequest::TYPE_ARRAY_INT); if (!$photo_id) { throw new waException(_w('Empty photo list')); } $photo_model = new photosPhotoModel(); // dialog for one photo if (count($photo_id) == 1) { $photo_id = current($photo_id); $photo = $photo_model->getById($photo_id); $photo_right_model = new photosPhotoRightsModel(); if (!$photo_right_model->checkRights($photo, true)) { $rights = array(0 => array('group_id' => 0, 'photo_id' => null)); } else { $rights = $photo_right_model->getByField('photo_id', $photo_id, 'group_id'); } } else { // dialog for several selected photos // dummies for correct template randering $photo = array('status' => 1); $rights = array(0 => array('group_id' => 0, 'photo_id' => null)); $allowed_photo_id = (array) $photo_model->filterByField($photo_id, 'status', 1); $this->view->assign('photo_count', count($photo_id)); $this->view->assign('disable_submit', count($allowed_photo_id) != count($photo_id)); } $groups_model = new waGroupModel(); $groups = $groups_model->getAll('id', true); $this->view->assign('groups', $groups); $this->view->assign('photo', $photo); $this->view->assign('rights', $rights); }
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)); }