本文整理汇总了PHP中Ansel::getImageUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Ansel::getImageUrl方法的具体用法?PHP Ansel::getImageUrl怎么用?PHP Ansel::getImageUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ansel
的用法示例。
在下文中一共展示了Ansel::getImageUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getOtherGalleries
/**
* Build the HTML for the other galleries widget content.
*
* @param Horde_View $view The view object.
*/
protected function _getOtherGalleries(&$view)
{
$owner = $this->_view->gallery->get('owner');
// Set up the tree
$tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('otherAnselGalleries_' . md5($owner), 'Javascript', array('class' => 'anselWidgets'));
try {
$galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $owner));
} catch (Ansel_Exception $e) {
Horde::log($e, 'ERR');
return;
}
foreach ($galleries as $gallery) {
$parents = $gallery->get('parents');
if (empty($parents)) {
$parent = null;
} else {
$parents = explode(':', $parents);
$parent = array_pop($parents);
}
$img = (string) Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'mini', true);
$link = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery'), true);
$tree->addNode(array('id' => $gallery->id, 'parent' => $parent, 'label' => $gallery->get('name'), 'expanded' => $gallery->id == $this->_view->gallery->id, 'params' => array('icon' => $img, 'url' => $link)));
}
Horde::startBuffer();
$tree->sort('label');
$tree->renderTree();
$view->tree = Horde::endBuffer();
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_ToggleOtherGalleries', array('id' => 'othergalleries-toggle'));
}
示例2: getTile
/**
* Outputs the html for a DateGallery tile.
*
* @param Ansel_Gallery_Decorator_Date $dgallery The Ansel_Gallery_Date we are
* displaying.
* @param Ansel_Style $style A style object.
* @param boolean $mini Force the use of a mini thumbail?
* @param array $params An array containing additional parameters.
* Currently, gallery_view_url and image_view_url
* are used to override the respective urls.
* %g and %i are replaced with image id and
* gallery id, respectively.
*
* @return string The HTML for the tile.
*/
public function getTile(Ansel_Gallery_Decorator_Date $dgallery, Ansel_Style $style = null, $mini = false, array $params = array())
{
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/tile');
// User's preferred date format
$date_format = $GLOBALS['prefs']->getValue('date_format');
$date_array = $dgallery->getDate();
if (empty($date_array['month'])) {
$date_array['month'] = 1;
}
if (empty($date_array['day'])) {
$date_array['day'] = 1;
}
$full_date = new Horde_Date($date_array);
// Need the unaltered date part array
$date_array = $dgallery->getDate();
// Figure out the needed link for the next drill down level. We *must*
// have at least a year since we are in a date tile.
if (empty($date_array['month'])) {
// unit == year
$view->caption = $full_date->strftime('%Y');
$next_date = array('year' => (int) $view->caption);
} elseif (empty($date_array['day'])) {
// unit == month
$view->caption = $full_date->strftime('%B %Y');
$next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()));
} else {
// unit == day
$view->caption = $full_date->strftime($date_format);
$next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()), 'day' => date('j', $full_date->timestamp()));
}
// Check permissions on the gallery and get appropriate tile image
if ($dgallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
if (is_null($style)) {
$style = $dgallery->getStyle();
}
$thumbstyle = $mini ? 'mini' : 'thumb';
$view->gallery_image = Ansel::getImageUrl($dgallery->getKeyImage(), $thumbstyle, true, $style);
} else {
$view->gallery_image = Horde_Themes::img('thumb-error.png');
}
/* Check for being called via the api and generate correct view links */
if (!isset($params['gallery_view_url'])) {
if (empty($params['style'])) {
$gstyle = $dgallery->getStyle();
} else {
$gstyle = $params['style'];
}
$params = array('gallery' => $dgallery->id, 'view' => 'Gallery', 'slug' => $dgallery->get('slug'));
$view->view_link = Ansel::getUrlFor('view', array_merge($params, $next_date));
} else {
$view->view_link = new Horde_Url(str_replace(array('%g', '%s'), array($dgallery->id, $dgallery->get('slug')), urldecode($params['gallery_view_url'])));
$view->view_link->add($next_date);
}
$view->gallery_count = $dgallery->countImages(true);
return $view->render('dategallery');
}
示例3: _content
/**
*/
protected function _content()
{
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery();
if (!$gallery) {
return _("There are no photo galleries available.");
}
$imagelist = $gallery->listImages(rand(0, $gallery->countImages() - 1), 1);
if (empty($imagelist)) {
return '';
}
$imageId = $imagelist[0];
$viewurl = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'image' => $imageId, 'view' => 'Image'), true);
if ($gallery->isOldEnough() && !$gallery->hasPasswd()) {
$img = '<img src="' . Ansel::getImageUrl($imageId, 'thumb', true, Ansel::getStyleDefinition('ansel_default')) . '" alt="[random photo]" />';
} else {
$img = Horde::img('thumb-error.png');
}
return $viewurl->link(array('title' => _("View Photo"))) . $img . '</a>';
}
示例4: _content
/**
*/
protected function _content()
{
try {
$gallery = $this->_getGallery();
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$params = array('gallery_id' => $gallery->id, 'count' => $this->_params['perpage']);
if (!empty($this->_params['use_lightbox'])) {
$params['lightbox'] = true;
}
$html = Ansel::embedCode($params);
// Be nice to people with <noscript>
$viewurl = Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $gallery->id, 'slug' => $gallery->get('slug')), true);
$html .= '<noscript>';
$html .= $viewurl->link(array('title' => sprintf(_("View %s"), $gallery->get('name'))));
if ($iid = $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) && $gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
$html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
} else {
$html .= Horde::img('thumb-error.png');
}
return $html . '</a></noscript>';
}
示例5: _getRelatedImages
/**
* Helper function for generating a widget of images related to this one.
*
*
* @return string The HTML
*/
public function _getRelatedImages()
{
$ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
$html = '';
$args = array('typeId' => 'image', 'userId' => $this->_view->gallery->get('owner'));
$results = $GLOBALS['injector']->getInstance('Ansel_Tagger')->listRelatedImages($this->_view->resource);
if (count($results)) {
$i = 0;
foreach ($results as $result) {
$img = $result['image'];
try {
$rGal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($img->gallery);
if ($rGal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
$html .= Ansel::getUrlFor('view', array('image' => $img->id, 'view' => 'Image', 'gallery' => abs($img->gallery), 'slug' => $rGal->get('slug')), true)->link(array('title' => sprintf(_("%s from %s"), $img->filename, $rGal->get('name')))) . '<img src="' . Ansel::getImageUrl($img->id, 'mini', true) . '" alt="' . htmlspecialchars($img->filename) . '" /></a>';
}
} catch (Ansel_Exception $e) {
Horde::log($e->getMessage(), 'ERR');
}
$i++;
}
}
return $html;
}
示例6: _content
/**
*/
protected function _content()
{
global $page_output, $registry, $injector, $prefs;
Horde::initMap();
$page_output->addScriptFile('map.js');
$page_output->addScriptFile('blocks/geotag.js');
try {
$images = $injector->getInstance('Ansel_Storage')->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$images = array_reverse($images);
foreach ($images as $key => $image) {
$id = $image['image_id'];
$gallery = $injector->getInstance('Ansel_Storage')->getGallery($image['gallery_id']);
// Don't show locked galleries in the block.
if (!$gallery->isOldEnough() || $gallery->hasPasswd()) {
continue;
}
$style = $gallery->getStyle();
// Generate the image view url
$url = Ansel::getUrlFor('view', array('view' => 'Image', 'slug' => $gallery->get('slug'), 'gallery' => $gallery->id, 'image' => $id, 'gallery_view' => $style->gallery_view), true);
$images[$key]['icon'] = strval(Ansel::getImageUrl($images[$key]['image_id'], 'mini', true));
$images[$key]['link'] = strval($url);
$images[$key]['markerOnly'] = false;
}
// URL for updating selected layer
$layerUrl = $registry->getServiceLink('ajax', 'ansel')->setRaw(true);
$layerUrl->url .= 'setPrefValue';
// And the current defaultLayer, if any.
$defaultLayer = $prefs->getValue('current_maplayer');
$opts = array('layerUpdateEndpoint' => strval($layerUrl), 'layerUpdatePref' => 'current_maplayer', 'defaultBaseLayer' => $defaultLayer);
$json = Horde_Serialize::serialize(array_values($images), Horde_Serialize::JSON);
$js = array('var opts = ' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON), 'new AnselBlockGeoTag(' . $json . ', opts);');
$page_output->addInlineScript($js, true);
return '<div id="ansel_map" style="height:' . $this->_params['height'] . 'px;"></div>';
}
示例7: catch
$image->save();
++$count;
} catch (Ansel_Exception $e) {
$notification->push(sprintf(_("There was an error editing the dates: %s"), $e->getMessage()), 'horde.error');
echo Horde::wrapInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();'));
exit;
}
}
$notification->push(sprintf(_("Successfully modified the date on %d photos."), $count), 'horde.success');
echo Horde::wrapInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();'));
exit;
}
$keys = array_keys($images);
$html = '';
foreach ($keys as $key) {
$html .= '<img src="' . Ansel::getImageUrl($key, 'mini', false) . '" style="margin:2px;" alt="[thumbnail]" />';
}
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(array_pop($keys));
/* Display the form */
$vars->set('image', $images);
$vars->set('gallery', $gallery_id);
$vars->set('page', $page);
$vars->set('actionID', 'edit_dates');
$vars->set('image_list', $html);
$vars->set('image_originalDate', $image->originalDate);
$renderer = new Horde_Form_Renderer();
$count = count($images);
$page_output->topbar = $page_output->sidebar = false;
$page_output->header();
$form->renderActive($renderer, $vars, null, 'post');
// Needed to ensure the body element is large enough to hold the pop up calendar
示例8: html
/**
* Build the HTML for the widget
*
* @return string
*/
public function html()
{
global $page_output;
$view = $GLOBALS['injector']->getInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/widgets');
$view->title = _("Location");
$view->background = $this->_style->background;
$ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
$geodata = $ansel_storage->getImagesGeodata($this->_params['images']);
$viewType = $this->_view->viewType();
// Exit early?
if (count($geodata) == 0 && $viewType != 'Image') {
return '';
}
// Setup map and javascript includes
Horde::initMap();
$page_output->addScriptFile('map.js');
$page_output->addScriptFile('popup.js', 'horde');
$page_output->addScriptFile('widgets/geotag.js');
// Values needed by map javascript
$relocate_url = Horde::url('map_edit.php', true);
$rtext = _("Relocate this image");
$dtext = _("Delete geotag");
$thisTitleText = _("This image");
$otherTitleText = _("Other images in this gallery");
$geotagUrl = $GLOBALS['registry']->getServiceLink('ajax', 'ansel')->setRaw(true);
$geotagUrl->url .= 'imageSaveGeotag';
$permsEdit = (int) $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
$view->haveEdit = $permsEdit;
// URL for updating selected layer
$layerUrl = $GLOBALS['registry']->getServiceLink('ajax', 'ansel')->setRaw(true);
$layerUrl->url .= 'setPrefValue';
// And the current defaultLayer, if any.
$defaultLayer = $GLOBALS['prefs']->getValue('current_maplayer');
// Add extra information to the JSON data to be sent:
foreach ($geodata as $id => $data) {
$geodata[$id]['icon'] = (string) Ansel::getImageUrl($geodata[$id]['image_id'], 'mini', true);
$geodata[$id]['markerOnly'] = $viewType == 'Image';
$geodata[$id]['link'] = (string) Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $this->_view->gallery->id, 'image' => $geodata[$id]['image_id']), true);
}
// Image view?
$view->isImageView = $viewType == 'Image';
// If this is an image view, get the other gallery images
if ($viewType == 'Image' && !empty($geodata)) {
$image_id = $this->_view->resource->id;
$others = $this->_getGalleryImagesWithGeodata();
foreach ($others as $id => $data) {
if ($id != $image_id) {
$others[$id]['icon'] = (string) Ansel::getImageUrl($others[$id]['image_id'], 'mini', true);
$others[$id]['link'] = (string) Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $this->_view->gallery->id, 'image' => $others[$id]['image_id']), true);
} else {
unset($others[$id]);
}
}
$geodata = array_values(array_merge($geodata, $others));
$view->geodata = $geodata;
}
if ($permsEdit) {
// Image view, but no geotags, provide ability to add it.
$addurl = Horde::url('map_edit.php')->add('image', $this->_params['images'][0]);
$view->addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $this->_params['images'][0]), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;'));
$view->imgs = $ansel_storage->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
if (count($view->imgs) > 0) {
foreach ($view->imgs as $id => &$data) {
if (!empty($data['image_location'])) {
$data['title'] = $data['image_location'];
} else {
$data['title'] = sprintf('%s %s', Ansel::point2Deg($data['image_latitude'], true), Ansel::point2Deg($data['image_longitude']));
}
$data['add_link'] = $addurl->link(array('title' => $title, 'onclick' => "Ansel.widgets.geotag.setLocation(" . $image_id . ",'" . $data['image_latitude'] . "', '" . $data['image_longitude'] . "'); return false"));
}
}
}
// Build the javascript to handle the map on the gallery/image views.
$json = Horde_Serialize::serialize(array_values($geodata), Horde_Serialize::JSON);
$js_params = array('smallMap' => 'ansel_map_small', 'mainMap' => 'ansel_map', 'viewType' => $viewType, 'relocateUrl' => strval($relocate_url), 'relocateText' => $rtext, 'markerLayerTitle' => $thisTitleText, 'imageLayerTitle' => $otherTitleText, 'defaultBaseLayer' => $defaultLayer, 'deleteGeotagText' => $dtext, 'hasEdit' => $permsEdit, 'updateEndpoint' => strval($geotagUrl), 'layerUpdateEndpoint' => strval($layerUrl), 'layerUpdatePref' => 'current_maplayer', 'geocoder' => $GLOBALS['conf']['maps']['geocoder']);
$js = array('Ansel.widgets = Ansel.widgets || {};', 'Ansel.widgets.geotag = new AnselGeoTagWidget(' . $json . ',' . Horde_Serialize::serialize($js_params, Horde_Serialize::JSON) . ');');
$page_output->addInlineScript($js, true);
if (count($geodata)) {
$page_output->addInlineScript('Ansel.widgets.geotag.doMap();', true);
}
return $view->render('geotag');
}
示例9: catch
<?php
/**
* Copyright 2007-2015 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Michael Rubinsky <mrubinsk@horde.org>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
$imageId = Horde_Util::getFormData('image');
try {
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($imageId);
$gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery));
$img = Ansel::getImageUrl($imageId, 'thumb', false, Ansel::getStyleDefinition('ansel_default'));
} catch (Ansel_Exception $e) {
Horde::log($e->getMessage(), 'ERR');
exit;
} catch (Horde_Exception_NotFound $e) {
Horde::log($e->getMessage(), 'ERR');
exit;
}
if ($gal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) && !$gal->hasPasswd() && $gal->isOldEnough()) {
echo '<img src="' . $img . '" alt="' . htmlspecialchars($image->filename) . '">';
} else {
echo '';
}
示例10: _html
/**
* Image view specific HTML - done so we can extend View_Image for things
* like the slideshow view etc...
*/
protected function _html()
{
global $conf, $registry, $prefs, $page_output;
// Build initial view properties
$view = $this->_getView();
$view->hide_slideshow = !empty($this->_params['hide_slideshow']);
// Starting image
$imageIndex = $this->_revList[$this->resource->id];
// Get the next and previous image ids
if (isset($this->_imageList[$imageIndex + 1])) {
$next = $this->_imageList[$imageIndex + 1];
} else {
$next = $this->_imageList[0];
}
if (isset($this->_imageList[$imageIndex - 1])) {
$prev = $this->_imageList[$imageIndex - 1];
} else {
$prev = $this->_imageList[count($this->_imageList) - 1];
}
// Calculate the page number of the next/prev images
$perpage = $prefs->getValue('tilesperpage');
$pagestart = $this->_page * $perpage;
$pageend = min(count($this->_imageList), $pagestart + $perpage - 1);
$page_next = $this->_page;
if ($this->_revList[$this->resource->id] + 1 > $pageend) {
++$page_next;
}
$page_prev = $this->_page;
if ($this->_revList[$this->resource->id] - 1 < $pagestart) {
--$page_prev;
}
// Previous image link
if (!empty($this->_params['image_view_url'])) {
$view->prev_url = str_replace(array('%i', '%g', '%s'), array($prev, $this->gallery->id, $this->_slug), urldecode($this->_params['image_view_url']));
} else {
$view->prev_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $prev, 'view' => 'Image', 'page' => $page_prev), $this->_date));
}
$prevImgSrc = Ansel::getImageUrl($prev, 'screen', true, $this->_style);
// Next image link
if (!empty($this->_params['image_view_url'])) {
$view->next_url = str_replace(array('%i', '%g', '%s'), array($prev, $this->gallery->id, $this->_slug), urldecode($this->_params['image_view_url']));
} else {
$view->next_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $next, 'view' => 'Image', 'page' => $page_next), $this->_date));
}
$nextImgSrc = Ansel::getImageUrl($next, 'screen', true, $this->_style);
// Slideshow link
if (!empty($this->_params['slideshow_link'])) {
$this->_urls['slideshow'] = str_replace(array('%i', '%g'), array($this->resource->id, $this->gallery->id), urldecode($this->_params['slideshow_link']));
} else {
$this->_urls['slideshow'] = Horde::url('view.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id, 'view' => 'Slideshow'), $this->_date));
}
// These items don't work when viewing through the api
if (empty($this->_params['api'])) {
$this->addWidget(Ansel_Widget::factory('Tags', array('view' => 'image')));
$this->addWidget(Ansel_Widget::factory('SimilarPhotos'));
$this->addWidget(Ansel_Widget::factory('Geotag', array('images' => array($this->resource->id))));
if ($conf['faces']['driver']) {
$this->addWidget(Ansel_Widget::factory('ImageFaces', array('selfUrl' => $this->_urls['self'])));
}
$this->addWidget(Ansel_Widget::factory('Links', array()));
// In line caption editing
if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_EditCaption', array('width' => $this->_geometry['width'], 'id' => 'anselcaption', 'dataid' => $this->resource->id));
}
}
// Output the js if we are calling via the api
if (!empty($this->_params['api'])) {
foreach (array('prototype.js', 'stripe.js', 'scriptaculous/effects.js') as $val) {
$tmp = new Horde_Script_File_JsDir($val, 'horde');
Horde::startBuffer();
echo $tmp->tag_full;
$html = Horde::endBuffer();
}
} else {
$html = '';
}
$js = array();
if (empty($this->_params['hide_slideshow'])) {
$js[] = '$$(\'.ssPlay\').each(function(n) { n.show(); });';
}
$js = array_merge($js, array('AnselImageView.nextImgSrc = "' . $nextImgSrc . '"', 'AnselImageView.prevImgSrc = "' . $prevImgSrc . '"', 'AnselImageView.urls = { "imgsrc": "' . $this->_urls['imgsrc'] . '" }', 'AnselImageView.onload()'));
$page_output->addInlineScript($js);
// Pass the urls now that we have them all.
$view->urls = $this->_urls;
// Get the exif data if needed.
if ($prefs->getValue('showexif')) {
$view->exif = array_chunk($this->resource->getAttributes(), 3, true);
}
// Comments
if ($comments = $this->_getCommentData()) {
if (!empty($comments['threads'])) {
$this->view->commentHtml = '<br>' . $comments['threads'];
}
if (!empty($comments['comments'])) {
$this->view->commentHtml .= '<br>' . $comments['comments'];
}
//.........这里部分代码省略.........
示例11: getTile
/**
* Outputs the HTML for an image thumbnail tile.
*
* @param Ansel_Image $image The Ansel_Image we are displaying.
* @param Ansel_Style $style A sytle definiition array.
* @param boolean $mini Force the use of a mini thumbnail?
* @param array $params Any other paramaters needed by this tile
*
* @return Outputs the HTML for the image tile.
*/
public static function getTile(Ansel_Image $image, Ansel_Style $style = null, $mini = false, array $params = array())
{
global $conf, $registry, $injector;
$page = isset($params['page']) ? $params['page'] : 0;
$view_type = isset($params['view']) ? $params['view'] : 'Gallery';
$view = $injector->createInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/tile');
$view->image = $image;
$view->view_type = $view_type;
try {
$view->parent = $injector->getInstance('Ansel_Storage')->getGallery($image->gallery);
} catch (Ansel_Exception $e) {
// @TODO: Short circuit here and return a generic error tile.
} catch (Horde_Exception_NotFound $e) {
// @TODO: Ditto above.
}
if (is_null($style)) {
$style = $view->parent->getStyle();
}
$date = $view->parent->getDate();
if ($view_type == 'Results') {
$haveSearch = 1;
} else {
$haveSearch = 0;
}
// Override the thumbnail to mini or use style default?
$thumbstyle = $mini ? 'mini' : 'thumb';
// URL for image properties/actions
$view->image_url = Horde::url('image.php')->add(array_merge(array('gallery' => $image->gallery, 'page' => $page, 'image' => $image->id, 'havesearch' => $haveSearch), $date));
// URL to view the image. This is the link for the Tile.
// $view_url is the link for the thumbnail and since this might not
// always point to the image view page, we set $img_view_url to link to
// the image view
$view->img_view_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $image->gallery, 'slug' => $view->parent->get('slug'), 'page' => $page, 'view' => 'Image', 'image' => $image->id, 'havesearch' => $haveSearch), $date));
if (!empty($params['image_view_src'])) {
$view->view_url = Ansel::getImageUrl($image->id, 'screen', true);
} elseif (empty($params['image_view_url'])) {
$view->view_url = new Horde_Url($view->img_view_url);
} else {
$view->view_url = new Horde_Url(str_replace(array('%i', '%g', '%s'), array($image->id, $image->gallery, $view->parent->get('slug')), urldecode($params['image_view_url'])));
// If we override the view_url, assume we want to override this also
$view->img_view_url = $view->view_url;
}
// Need the gallery URL to display the "From" link when showing
// the image tile from somewhere other than the gallery view.
if (!empty($view_type) || basename($_SERVER['PHP_SELF']) == 'view.php') {
$view->gallery_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $view->parent->id, 'slug' => $view->parent->get('slug'), 'view' => 'Gallery', 'havesearch' => $haveSearch), $date));
}
$view->thumb_url = Ansel::getImageUrl($image->id, $thumbstyle, true, $style);
$view->option_select = $view->parent->hasPermission($registry->getAuth(), Horde_Perms::DELETE);
$view->option_edit = $view->parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT);
$view->imgAttributes = !empty($params['image_view_attributes']) ? $params['image_view_attributes'] : array();
$view->option_comments = ($conf['comments']['allow'] == 'all' || $conf['comments']['allow'] == 'authenticated' && $registry->getAuth()) && empty($params['hide_comments']);
$view->imgOnClick = !empty($params['image_onclick']) ? str_replace('%i', $image->id, $params['image_onclick']) : '';
$view->imageCaption = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
if (!empty($params['image_view_title']) && !empty($image->_data[$params['image_view_title']])) {
$title = $image->_data[$params['image_view_title']];
} else {
$title = $image->filename;
}
// In-line caption editing if we have Horde_Perms::EDIT
if ($view->option_edit) {
try {
$geometry = $image->getDimensions($thumbstyle);
$injector->createInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_EditCaption', array('dataid' => $image->id, 'id' => $image->id . 'caption', 'width' => $geometry['width']));
} catch (Ansel_Exception $e) {
}
}
return $view->render('image');
}
示例12: toJson
/**
* Returns a json representation of this gallery.
*
* @param boolean $full Return all information (subgalleries and images)?
*
* @return StdClass An object describing the gallery
* <pre>
* 'id' - gallery id
* 'p' - gallery's parent's id (null if top level)
* 'pn' - gallery's parent's name (null if top level)
* 'n' - gallery name
* 'dc' - date created
* 'dm' - date modified
* 'd' - description
* 'ki' - key image
* 'sg' - an object with the following properties:
* 'n' - gallery name
* 'dc' - date created
* 'dm' - date modified
* 'd' - description
* 'ki' - key image
*
* 'imgs' - an array of image objects with the following properties:
* 'id' - the image id
* 'url' - the image url
* </pre>
*/
public function toJson($full = false)
{
// @TODO: Support date grouped galleries
$vMode = $this->get('view_mode');
if ($vMode != 'Normal') {
$this->_setModeHelper('Normal');
}
$style = Ansel::getStyleDefinition('ansel_mobile');
$json = new StdClass();
$json->id = $this->id;
$json->n = $this->get('name');
$json->dc = $this->get('date_created');
$json->dm = $this->get('last_modified');
$json->d = $this->get('desc');
$json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'thumb', false, $style)->toString(true);
$json->imgs = array();
// Parent
$parents = $this->getParents();
if (empty($parents)) {
$json->p = null;
$json->pn = null;
} else {
$p = array_pop($parents);
$json->p = $p->id;
$json->pn = $p->get('name');
}
if ($full) {
$json->tiny = $GLOBALS['conf']['image']['tiny'] && ($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->_share->hasPermission('', Horde_Perms::READ));
$json->sg = array();
if ($this->hasSubGalleries()) {
$sgs = $this->getChildren($GLOBALS['registry']->getAuth(), Horde_Perms::READ, false);
//GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('parent' => $this->id, 'all_levels' => false));
foreach ($sgs as $g) {
$json->sg[] = $g->toJson();
}
}
$images = $this->getImages();
foreach ($images as $img) {
$i = new StdClass();
$i->id = $img->id;
$i->url = Ansel::getImageUrl($img->id, 'thumb', false, $style)->toString(true);
$i->screen = Ansel::getImageUrl($img->id, 'screen', $json->tiny, Ansel::getStyleDefinition('ansel_default'))->toString(true);
$i->fn = $img->filename;
$json->imgs[] = $i;
}
}
if ($vMode != 'Normal') {
$this->_setModeHelper($vMode);
}
return $json;
}
示例13: Horde_Exception_PermissionDenied
}
$image = $injector->getInstance('Ansel_Storage')->getImage($image_id);
$gallery = $injector->getInstance('Ansel_Storage')->getGallery($image->gallery);
if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
throw new Horde_Exception_PermissionDenied(_("Not Authorized. Details have been logged for the server administrator."));
}
$view = $injector->getInstance('Horde_View');
$view->image_id = $image_id;
$view->loadingImg = Horde::img('loading.gif', _("Loading..."));
$view->filename = $image->filename;
// Determine if we already have a geotag or are we tagging it for the 1st time
if (empty($image->lat)) {
$geodata = array('image_id' => $image->id, 'image_latitude' => '20', 'image_longitude' => '40', 'image_location' => '', 'icon' => Ansel::getImageUrl($image->id, 'mini', true), 'markerOnly' => true, 'draggable' => true);
$isNew = 1;
} else {
$geodata = array('image_id' => $image->id, 'image_latitude' => $image->lat, 'image_longitude' => $image->lng, 'image_location' => $image->location, 'icon' => Ansel::getImageUrl($image->id, 'mini', true), 'markerOnly' => true, 'draggable' => true);
$isNew = 0;
}
// JSON representation of the image's geotag
$json = Horde_Serialize::serialize(array($geodata), Horde_Serialize::JSON);
// Url for geotag ajax helper
$gtUrl = $registry->getServiceLink('ajax', 'ansel')->setRaw(true);
$gtUrl->url .= 'imageSaveGeotag';
// Obtain other geotagged images to possibly locate this image at
$view->imgs = $injector->getInstance('Ansel_Storage')->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
if (count($view->imgs) > 0) {
$js = array();
foreach ($view->imgs as $id => $data) {
if ($id != $image_id) {
$js[] = '$("geo_' . $id . '").observe("click", function() { mapEdit.setLocation("' . $data['image_latitude'] . '", "' . $data['image_longitude'] . '", "' . $data['image_location'] . '");return false; } )';
}
示例14: getTile
/**
* Outputs the html for a gallery tile.
*
* @param Ansel_Gallery $gallery The Ansel_Gallery we are displaying.
* @param Ansel_Style $style A style object.
* @param boolean $mini Force the use of a mini thumbail?
* @param array $params An array containing additional parameters.
* Currently, gallery_view_url and
* image_view_url are used to override the
* respective urls. %g and %i are replaced
* with image id and gallery id, respectively
*
*
* @return Outputs the HTML for the tile.
*/
public static function getTile(Ansel_Gallery $gallery, Ansel_Style $style = null, $mini = false, array $params = array())
{
global $prefs, $registry, $injector;
// Create view
$view = $injector->createInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/tile');
$view->gallery = $gallery;
$view_type = Horde_Util::getFormData('view', 'Gallery');
$haveSearch = $view_type == 'Results' ? 1 : 0;
if ($view_type == 'Results' || $view_type == 'List' || basename($_SERVER['PHP_SELF']) == 'index.php' && $prefs->getValue('defaultview') == 'galleries') {
$showOwner = true;
} else {
$showOwner = false;
}
// Use the galleries style if not explicitly passed.
if (is_null($style)) {
$style = $gallery->getStyle();
}
// If the gallery has subgalleries, and no images, use one of the
// subgalleries' stack image. hasSubGalleries already takes
// permissions into account.
if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) && !$gallery->countImages() && $gallery->hasSubGalleries()) {
try {
$galleries = $injector->getInstance('Ansel_Storage')->listGalleries(array('parent' => $gallery->id, 'all_levels' => false, 'perm' => Horde_Perms::READ));
foreach ($galleries as $sgallery) {
if ($default_img = $sgallery->getKeyImage($style)) {
$view->gallery_image = Ansel::getImageUrl($default_img, $mini ? 'mini' : 'thumb', true, $style);
}
}
} catch (Ansel_Exception $e) {
}
} elseif ($gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) && $gallery->countImages()) {
$thumbstyle = $mini ? 'mini' : 'thumb';
if ($gallery->hasPasswd()) {
$view->gallery_image = Horde_Themes::img('gallery-locked.png');
} else {
$view->gallery_image = Ansel::getImageUrl($gallery->getKeyImage($style), $thumbstyle, true, $style);
}
}
// If no image at this point, we can't get one.
if (empty($view->gallery_image)) {
$view->gallery_image = Horde_Themes::img('thumb-error.png');
}
// Check for being called via the api and generate correct view links
if (!isset($params['gallery_view_url'])) {
$view->view_link = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'view' => 'Gallery', 'havesearch' => $haveSearch, 'slug' => $gallery->get('slug')));
} else {
$view->view_link = new Horde_Url(str_replace(array('%g', '%s'), array($gallery->id, $gallery->get('slug')), urldecode($params['gallery_view_url'])));
}
if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT) && !$mini) {
$view->properties_link = Horde::url('gallery.php', true)->add(array('gallery' => $gallery->id, 'actionID' => 'modify', 'havesearch' => $haveSearch, 'url' => Horde::selfUrl(true, false, true)));
}
if ($showOwner && !$mini && $registry->getAuth() != $gallery->get('owner')) {
$view->owner_link = Ansel::getUrlFor('view', array('view' => 'List', 'owner' => $gallery->get('owner'), 'groupby' => 'owner'), true);
$view->owner_string = $gallery->getIdentity()->getValue('fullname');
if (empty($view->owner_string)) {
$view->owner_string = $gallery->get('owner');
}
}
$view->background_color = $style->background;
$view->gallery_count = $gallery->countImages(true);
$view->date_format = $prefs->getValue('date_format');
return $view->render('gallery' . ($mini ? 'mini' : ''));
}
示例15: catch
*/
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
try {
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery((int) Horde_Util::getFormData('gallery'));
} catch (Ansel_Exception $e) {
echo $e->getMessage();
Horde::log($e->getMessage(), 'err');
exit;
}
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
throw new Horde_Exception_PermissionDenied();
}
$style = Ansel::getStyleDefinition('ansel_default');
$style->thumbstyle = 'SquareThumb';
$style->width = 115;
$style->height = 115;
$from = (int) Horde_Util::getFormData('from');
$to = (int) Horde_Util::getFormData('to');
$count = $to - $from + 1;
$old_mode = $gallery->get('view_mode');
$gallery->set('view_mode', 'Normal');
$images = $gallery->getImages($from, $count);
$gallery->set('view_mode', $old_mode);
foreach ($images as $image) {
echo '<li>';
echo '<div>';
$alt = htmlspecialchars($image->filename);
echo '<img src="' . Ansel::getImageUrl($image->id, 'thumb', false, $style) . '" alt="' . $alt . '" title="' . $alt . '" />';
echo '</div></li>' . "\n";
}