getImageUrl() public static method

Return a link to an image, suitable for use in an tag Takes into account $conf['vfs']['direct'] and other factors.
public static getImageUrl ( string $imageId, string $view = 'screen', boolean $full = false, Ansel_Style $style = null ) : Horde_Url
$imageId string The id of the image.
$view string The view ('screen', 'thumb', 'full', 'mini') to show.
$full boolean Return a path that includes the server name?
$style Ansel_Style Use this gallery style
return Horde_Url The image path.
Example #1
0
 /**
  * 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'));
 }
Example #2
0
 /**
  * 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');
 }
Example #3
0
 /**
  */
 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>';
 }
Example #4
0
 /**
  */
 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>';
 }
Example #5
0
 /**
  * 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;
 }
 /**
  */
 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>';
 }
Example #7
0
            $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
Example #8
0
 /**
  * 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');
 }
Example #9
0
<?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 <*****@*****.**>
 */
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 '';
}
Example #10
0
 /**
  * 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'];
         }
     }
     return $html . $view->render('image');
 }
Example #11
0
 /**
  * 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');
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
}
$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; } )';
        }
Example #14
0
 /**
  * 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' : ''));
 }
Example #15
0
 */
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";
}
Example #16
0
 /**
  * Retrieve json data for an arbitrary list of image ids, not necessarily
  * from the same gallery.
  *
  * @param array $images        An array of image ids
  * @param Ansel_Style $style   A gallery style to force if requesting
  *                             pretty thumbs.
  * @param boolean $full        Generate full urls
  * @param string $image_view   Which image view to use? screen, thumb etc..
  * @param boolean $view_links  Include links to the image view
  *
  * @return string  The json data
  */
 public function getImageJson(array $images, Ansel_Style $style = null, $full = false, $image_view = 'mini', $view_links = false)
 {
     $galleries = array();
     if (is_null($style)) {
         $style = Ansel::getStyleDefinition('ansel_default');
     }
     $json = array();
     foreach ($images as $id) {
         $image = $this->getImage($id);
         $gallery_id = abs($image->gallery);
         if (empty($galleries[$gallery_id])) {
             $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id);
         }
         // Any authentication that needs to take place for any of the
         // images included here MUST have already taken place or the
         // image will not be incldued in the output.
         if (!isset($galleries[$gallery_id]['perm'])) {
             $galleries[$gallery_id]['perm'] = $galleries[$gallery_id]['gallery']->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ) && $galleries[$gallery_id]['gallery']->isOldEnough() && !$galleries[$gallery_id]['gallery']->hasPasswd();
         }
         if ($galleries[$gallery_id]['perm']) {
             $data = array((string) Ansel::getImageUrl($image->id, $image_view, $full, $style), htmlspecialchars($image->filename), $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)), $image->id, 0);
             if ($view_links) {
                 $data[] = (string) Ansel::getUrlFor('view', array('gallery' => $image->gallery, 'image' => $image->id, 'view' => 'Image', 'slug' => $galleries[$gallery_id]['gallery']->get('slug')), $full);
                 $data[] = (string) Ansel::getUrlFor('view', array('gallery' => $image->gallery, 'slug' => $galleries[$gallery_id]['gallery']->get('slug'), 'view' => 'Gallery'), $full);
             }
             $json[] = $data;
         }
     }
     return Horde_Serialize::serialize($json, Horde_Serialize::JSON);
 }
Example #17
0
 /**
  * SearchTags API:
  * Returns an application-agnostic array (useful for when doing a tag search
  * across multiple applications)
  *
  * The 'raw' results array can be returned instead by setting $raw = true.
  *
  * @param array $names           An array of tag_names to search for.
  * @param integer $max           The maximum number of resources to return.
  * @param integer $from          The number of the resource to start with.
  * @param string $resource_type  The resource type [gallery, image, '']
  * @param string $user           Restrict results to resources owned by $user.
  * @param boolean $raw           Return the raw data?
  * @param string $app            Application scope to use, if not the default.
  *
  * @return array An array of results:
  * <pre>
  *  'title'    - The title for this resource.
  *  'desc'     - A terse description of this resource.
  *  'view_url' - The URL to view this resource.
  *  'app'      - The Horde application this resource belongs to.
  * </pre>
  */
 public function searchTags($names, $max = 10, $from = 0, $resource_type = '', $user = null, $raw = false, $app = 'ansel')
 {
     $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
     $results = $GLOBALS['injector']->getInstance('Ansel_Tagger')->search($names, array('type' => $resource_type, 'user' => $user));
     // Check for error or if we requested the raw data array.
     if ($raw) {
         return $results;
     }
     $return = array();
     if (!empty($results['images'])) {
         foreach ($results['images'] as $image_id) {
             $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id);
             $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
             $view_url = Ansel::getUrlFor('view', array('gallery' => $image->gallery, 'image' => $image_id, 'view' => 'Image'), true);
             $gurl = Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $image->gallery));
             $return[] = array('title' => $image->filename, 'desc' => $image->caption . ' ' . _("from") . ' ' . $gurl->link() . $g->get('name') . '</a>', 'view_url' => $view_url, 'app' => $app, 'icon' => Ansel::getImageUrl($image_id, 'mini'));
         }
     }
     if (!empty($results['galleries'])) {
         foreach ($results['galleries'] as $gallery) {
             $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery);
             $view_url = Horde::url('view.php')->add(array('gallery' => $gallery, 'view' => 'Gallery'));
             $gurl = Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $gallery));
             $return[] = array('desc' => $gurl->link() . $gal->get('name') . '</a>', 'view_url' => $view_url, 'app' => $app, 'icon' => Ansel::getImageUrl($gal->getKeyImage(), 'mini'));
         }
     }
     return $return;
 }
Example #18
0
        echo $url->link(array('title' => $title, 'id' => 'geo_' . $id));
        ?>
        <img src="<?php 
        echo Ansel::getImageUrl($id, 'mini', true);
        ?>
" alt="[thumbnail]" /></a>
   <?php 
    }
    ?>
 <?php 
}
?>
 </div>
 <div class="control" style="vertical-align:bottom;">
  <div style="text-align:center;margin-top:6px;"><img src="<?php 
echo Ansel::getImageUrl($this->image_id, 'thumb', true);
?>
" /></div>
  <div class="ansel_geolocation">
   <div id="ansel_locationtext">&nbsp;</div>
   <div id="ansel_latlng">&nbsp;</div>
  </div>
 </div>
</div>
<div class="clear"></div>
<div class="control">
 <input class="button" id="saveButton" type="submit" value="<?php 
echo _("Save");
?>
" /><input class="button" type="submit" onclick="window.close();" value="<?php 
echo _("Return to image view");
Example #19
0
                 $imgs[$i]['latitude'] = $images[$i]->lat;
                 $imgs[$i]['longitude'] = $images[$i]->lng;
             }
         }
 }
 if (!isset($imgs)) {
     $imgs = array();
     $cnt = count($images);
     for ($i = 0; $i < $cnt; ++$i) {
         $imgs[$i]['link'] = Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $images[$i]->gallery, 'image' => $images[$i]->id), true);
         $imgs[$i]['filename'] = $images[$i]->filename;
         $imgs[$i]['caption'] = $images[$i]->caption;
         $imgs[$i]['url'] = htmlspecialchars(Ansel::getImageUrl($images[$i]->id, 'screen', true));
         $imgs[$i]['type'] = $images[$i]->getType('screen');
         $imgs[$i]['author'] = $author;
         $imgs[$i]['thumb'] = htmlspecialchars(Ansel::getImageUrl($images[$i]->id, 'thumb', true));
         $imgs[$i]['latitude'] = $images[$i]->lat;
         $imgs[$i]['longitude'] = $images[$i]->lng;
     }
 }
 $xsl = Horde_Themes::getFeedXsl();
 $stream_name = htmlspecialchars($params['name']);
 $stream_desc = htmlspecialchars($params['desc']);
 $stream_updated = htmlspecialchars(date('r', $params['last_modified']));
 $stream_official = htmlspecialchars($params['link']);
 $image_url = htmlspecialchars($params['image_url']);
 $image_link = htmlspecialchars($params['image_link']);
 $image_alt = htmlspecialchars($params['image_alt']);
 $ansel = 'Ansel ' . $registry->getVersion('ansel') . ' (http://www.horde.org/)';
 if ($stream_type != 'all' && $type != 'rss2') {
     $getparams = array('stream_type' => $stream_type, 'type' => $type);
Example #20
0
 /**
  * JSON representation of this gallery's images. We don't use
  * Ansel_Gallery::toJson() on purpose since that is a general jsonification
  * of the gallery data. This method is specific to the view, paging, links
  * etc...
  *
  * @param Ansel_Gallery $gallery  The gallery to represent in this view
  * @param array $params           An array of parameters for this method:
  *   <pre>
  *      full       - Should a full URL be generated? [false]
  *      from       - Starting image count [0]
  *      count      - The number of images to include (starting at from) [0]
  *      image_view - The type of ImageGenerator to obtain the src url for. [screen]
  *      view_links - Should the JSON include links to the Image and/or Gallery View? [false]
  *      perpage    - Number of images per page [from user prefs]
  *   </pre>
  *
  * @return string  A serialized JSON array.
  */
 public static function json(Ansel_Gallery $gallery, $params = array())
 {
     global $conf, $prefs;
     $default = array('full' => false, 'from' => 0, 'count' => 0, 'image_view' => 'screen', 'view_links' => false, 'perpage' => $prefs->getValue('tilesperpage', $conf['thumbnail']['perpage']));
     $params = array_merge($default, $params);
     $json = array();
     $curimage = 0;
     $curpage = 0;
     if (empty($params['images'])) {
         $images = $gallery->getImages($params['from'], $params['count']);
     }
     $style = $gallery->getStyle();
     if ($params['image_view'] == 'thumb' && !empty($params['generator'])) {
         $style->thumbstyle = $params['generator'];
     }
     foreach ($images as $image) {
         // Calculate the page this image will appear on in the gallery view.
         if (++$curimage > $params['perpage']) {
             ++$curpage;
             $curimage = 0;
         }
         $data = array((string) Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style), htmlspecialchars($image->filename), $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)), $image->id, $curpage);
         if ($params['view_links']) {
             $data[] = (string) Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'image' => $image->id, 'view' => 'Image', 'page' => $curpage), true);
             $data[] = (string) Ansel::getUrlFor('view', array('gallery' => $image->gallery, 'slug' => $gallery->get('slug'), 'view' => 'Gallery'), true);
         }
         // Source, Width, Height, Name, Caption, Image Id, Gallery Page
         $json[] = $data;
     }
     return Horde_Serialize::serialize($json, Horde_Serialize::JSON);
 }
Example #21
0
    ?>
    <?php 
    if ($this->haveEdit) {
        ?>
      <div class="ansel_location_sameas">
        <?php 
        echo sprintf(_("No location data present. Place using %s map %s or click on image to place at the same location."), $this->addLink, '</a>');
        ?>
        <?php 
        foreach ($this->imgs as $id => $data) {
            ?>
          <?php 
            echo $data['add_link'];
            ?>
<img src="<?php 
            echo Ansel::getImageUrl($id, 'mini', true);
            ?>
" alt="[image]" /></a>
        <?php 
        }
        ?>
      </div>
    <?php 
    } else {
        ?>
      <?php 
        echo _("No location data present.");
        ?>
    <?php 
    }
    ?>
Example #22
0
" />
  <p>
   <?php 
echo _("Drag photos to the desired sort position.");
?>
   <input type="submit" onclick="jQuery('#order').val(jQuery('#sortContainer').sortable('serialize', { key: 'order[]' }));" class="button" value="<?php 
echo _("Done");
?>
" />
  </p>
 </form>
</div>

<div id="sortContainer" style="background:<?php 
echo $style->background;
?>
">

<?php 
$images = $gallery->getImages();
foreach ($images as $image) {
    $caption = htmlspecialchars(empty($image->caption) ? $image->filename : $image->caption);
    echo '<div id="o_' . (int) $image->id . '"><a title="' . $caption . '" href="#">' . '<img src="' . Ansel::getImageUrl($image->id, 'thumb', false, $style) . '" alt="' . htmlspecialchars($image->filename) . '" />' . '</a></div>';
}
echo '</div>';
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script>jQuery.noConflict();</script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js" type="text/javascript"></script>
<?php 
$page_output->footer();
Example #23
0
 /**
  * Save/update image geotag.
  *
  * @return object  Object with 2 parameters:
  *   - message
  *   - response
  */
 public function imageSaveGeotag()
 {
     global $injector, $registry;
     $type = $this->vars->action;
     $location = $this->vars->location;
     $lat = $this->vars->lat;
     $lng = $this->vars->lng;
     $img = $this->vars->img;
     $result = new stdClass();
     $result->response = 0;
     if (empty($img) || $type == 'location' && empty($location) || (empty($type) || $type == 'all') && ($type == 'all' && empty($lat))) {
         return new Horde_Core_Ajax_Response_Prototypejs($result);
     }
     // Get the image and gallery to check perms
     try {
         $ansel_storage = $injector->getInstance('Ansel_Storage');
         $image = $ansel_storage->getImage((int) $img);
         $gallery = $ansel_storage->getGallery($image->gallery);
     } catch (Ansel_Exception $e) {
         return new Horde_Core_Ajax_Response_Prototypejs($result);
     }
     // Bail out if no perms on the image.
     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         return new Horde_Core_Ajax_Response_Prototypejs($result);
     }
     switch ($type) {
         case 'geotag':
             $image->geotag($lat, $lng, !empty($location) ? $location : '');
             $result->response = 1;
             break;
         case 'location':
             $image->location = !empty($location) ? urldecode($location) : '';
             $image->save();
             $result->response = 1;
             $result->message = htmlentities($image->location);
             break;
         case 'untag':
             $image->geotag('', '', '');
             // Now get the "add geotag" stuff
             $addurl = Horde::url('map_edit.php')->add('image', $img);
             $addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;'));
             $imgs = $ansel_storage->getRecentImagesGeodata($registry->getAuth());
             if (count($imgs) > 0) {
                 $imgsrc = '<div class="ansel_location_sameas">';
                 foreach ($imgs as $id => $data) {
                     $title = empty($data['image_location']) ? Ansel::point2Deg($data['image_latitude'], true) . ' ' . Ansel::point2Deg($data['image_longitude']) : $data['image_location'];
                     $imgsrc .= $addurl->link(array('title' => $title, 'onclick' => "Ansel.widgets.geotag.setLocation('" . $data['image_latitude'] . "', '" . $data['image_longitude'] . "');return false")) . '<img src="' . Ansel::getImageUrl($id, 'mini', true) . '" alt="[image]" /></a>';
                 }
                 $imgsrc .= '</div>';
                 $result->message = sprintf(_("No location data present. Place using %smap%s or click on image to place at the same location."), $addLink, '</a>') . $imgsrc;
             } else {
                 $result->message = sprintf(_("No location data present. You may add some %s."), $addLink . _("here") . '</a>');
             }
             $result->response = 1;
             break;
     }
     return new Horde_Core_Ajax_Response_Prototypejs($result);
 }