getStyleDefinition() public static method

Get a pre-defined style definition for the requested named style
public static getStyleDefinition ( string $style ) : Ansel_Style
$style string The name of the style to fetch
return Ansel_Style The definition of the requested style if it's available, otherwise, the ansel_default style is returned.
Example #1
0
    /**
     */
    protected function _content()
    {
        $GLOBALS['page_output']->addScriptFile('block.js');
        /* Get the top level galleries */
        try {
            $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('perm' => Horde_Perms::EDIT, 'attributes' => $GLOBALS['registry']->getAuth(), 'all_levels' => false, 'count' => empty($this->_params['limit']) ? 0 : $this->_params['limit'], 'sort_by' => 'last_modified', 'direction' => Ansel::SORT_DESCENDING));
        } catch (Ansel_Exception $e) {
            return $e->getMessage();
        }
        $header = array(_("Gallery Name"), _("Last Modified"), _("Photo Count"));
        $html = <<<HEADER
<table class="linedRow" cellspacing="0" style="width:100%">
 <thead><tr class="item nowrap">
  <th class="item leftAlign">{$header['0']}</th>
  <th class="item leftAlign">{$header['1']}</th>
  <th class="item leftAlign">{$header['2']}</th>
 </tr></thead>
 <tbody>
HEADER;
        foreach ($galleries as $gallery) {
            $url = Ansel::getUrlFor('view', array('view' => 'Gallery', 'slug' => $gallery->get('slug'), 'gallery' => $gallery->id), true);
            $html .= '<tr><td>' . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");', 'onmouseover' => 'Ansel.previewImage(event, ' . $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) . ');')) . htmlspecialchars($gallery->get('name')) . '</a></td><td>' . strftime($GLOBALS['prefs']->getValue('date_format'), $gallery->get('last_modified')) . '</td><td>' . (int) $gallery->countImages(true) . '</td></tr>';
        }
        $html .= '</tbody></table>';
        return $html;
    }
Example #2
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 #3
0
 /**
  * Const'r
  *
  * @see Ansel_View_Base::__construct
  */
 public function __construct(array $params = array())
 {
     parent::__construct($params);
     if (!empty($params['gallery_slug'])) {
         $this->gallery = $this->_getGallery(null, $params['gallery_slug']);
     } elseif (!empty($params['gallery_id'])) {
         $this->gallery = $this->_getGallery($params['gallery_id']);
     } else {
         $this->gallery = $this->_getGallery();
     }
     // Check user age
     if (!$this->gallery->isOldEnough()) {
         if (!empty($params['api'])) {
             throw new Ansel_Exception('Locked galleries are not viewable via the api.');
         }
         $date = Ansel::getDateParameter(array('year' => isset($this->_params['year']) ? $this->_params['year'] : 0, 'month' => isset($this->_params['month']) ? $this->_params['month'] : 0, 'day' => isset($this->_params['day']) ? $this->_params['day'] : 0));
         $galleryurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Gallery'), $date), true);
         $params = array('gallery' => $this->gallery->id, 'url' => $galleryurl);
         Horde::url('disclamer.php')->add($params)->setRaw(true)->redirect();
         exit;
     }
     if ($this->gallery->hasPasswd()) {
         if (!empty($params['api'])) {
             throw new Ansel_Exception(_("Locked galleries are not viewable via the api."));
         }
         $date = Ansel::getDateParameter(array('year' => isset($this->_params['year']) ? $this->_params['year'] : 0, 'month' => isset($this->_params['month']) ? $this->_params['month'] : 0, 'day' => isset($this->_params['day']) ? $this->_params['day'] : 0));
         $galleryurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Gallery'), $date), true);
         $params = array('gallery' => $this->gallery->id, 'url' => $galleryurl);
         Horde::url('protect.php')->add($params)->setRaw(true)->redirect();
         exit;
     }
     if (!$this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         throw new Horde_Exception_PermissionDenied();
     }
     // Since this is a gallery view, the resource is the gallery.
     $this->resource = $this->gallery;
     // Do we have an explicit style set? If not, use the gallery's
     if (!empty($this->_params['style'])) {
         $style = Ansel::getStyleDefinition($this->_params['style']);
     } else {
         $style = $this->gallery->getStyle();
     }
     if (!empty($this->_params['gallery_view'])) {
         $renderer = $this->_params['gallery_view'];
     } else {
         $renderer = !empty($style->gallery_view) ? $style->gallery_view : 'Gallery';
     }
     // Load the helper
     $classname = 'Ansel_View_GalleryRenderer_' . basename($renderer);
     $this->_renderer = new $classname($this);
     $this->_renderer->init();
 }
Example #4
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 #5
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 #6
0
File: List.php Project: horde/horde
 /**
  * Return the HTML representing this view.
  *
  * @return string  The HTML.
  *
  */
 public function html()
 {
     global $conf, $prefs, $registry;
     $vars = Horde_Variables::getDefaultVariables();
     if (!empty($this->_params['page'])) {
         $vars->add('page', $this->_params['page']);
     }
     if (!empty($this->_params['pager_url'])) {
         $this->_pagerurl = $this->_params['pager_url'];
         $override = true;
     } else {
         $override = false;
         $this->_pagerurl = Ansel::getUrlFor('view', array('owner' => $this->_owner, 'special' => $this->_special, 'groupby' => $this->_view->groupby, 'view' => 'List'));
     }
     $p_params = array('num' => $this->_view->numGalleries, 'url' => $this->_pagerurl, 'perpage' => $this->_view->gPerPage);
     if ($override) {
         $p_params['url_callback'] = null;
     }
     $this->_pager = new Horde_Core_Ui_Pager('page', $vars, $p_params);
     $preserve = array('sort_dir' => $this->_view->sortDir);
     if (!empty($this->_view->sortBy)) {
         $preserve['sort'] = $this->_view->sortBy;
     }
     $this->_pager->preserve($preserve);
     if ($this->_view->numGalleries) {
         $min = $this->_page * $this->_view->gPerPage;
         $max = $min + $this->_view->gPerPage;
         if ($max > $this->_view->numGalleries) {
             $max = $this->_view->numGalleries - $min;
         }
         $this->_view->start = $min + 1;
         $this->_view->end = min($this->_view->numGalleries, $min + $this->_view->gPerPage);
         if ($this->_owner) {
             $this->_view->refresh_link = Ansel::getUrlFor('view', array('groupby' => $this->_view->groupby, 'owner' => $this->_owner, 'page' => $this->_page, 'view' => 'List'));
         } else {
             $this->_view->refresh_link = Ansel::getUrlFor('view', array('view' => 'List', 'groupby' => $this->_view->groupby, 'page' => $this->_page));
         }
         // Get top-level / default gallery style.
         if (empty($this->_params['style'])) {
             $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
         } else {
             $style = Ansel::getStyleDefinition($this->_params['style']);
         }
         // Final touches.
         if (empty($this->_params['api'])) {
             $this->_view->breadcrumbs = Ansel::getBreadcrumbs();
             $this->_view->groupbyUrl = strval(Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'owner')));
         }
         $this->_view->pager = $this->_pager->render();
         $this->_view->style = $style;
         $this->_view->tilesperrow = $prefs->getValue('tilesperrow');
         $this->_view->cellwidth = round(100 / $this->_view->tilesperrow);
         $this->_view->params = $this->_params;
         $GLOBALS['page_output']->addScriptFile('views/common.js');
         return $this->_view->render('list');
     }
     return '&nbsp;';
 }
Example #7
0
 /**
  * Get the HTML representing this view.
  *
  * @return string  The HTML
  */
 public function html()
 {
     global $conf, $prefs;
     $view = $GLOBALS['injector']->getInstance('Horde_View');
     $view->addTemplatePath(ANSEL_TEMPLATES . '/view');
     $view->perPage = $this->_perPage;
     // Ansel Storage
     $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
     // Get the slice of galleries/images to view on this page.
     try {
         $view->results = $this->_browser->getSlice($this->_page, $this->_perPage);
     } catch (Ansel_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         return _("An error has occured retrieving the image. Details have been logged.");
     }
     $view->total = $this->_browser->count();
     $view->total = $view->total['galleries'] + $view->total['images'];
     // The number of resources to display on this page.
     $view->numimages = count($view->results);
     $view->tilesperrow = $prefs->getValue('tilesperrow');
     $view->cellwidth = round(100 / $view->tilesperrow);
     // Get any related tags to display.
     if ($conf['tags']['relatedtags']) {
         $view->rtags = $this->_browser->getRelatedTags();
         $view->taglinks = Ansel::getTagLinks($view->rtags, 'add');
     }
     $vars = Horde_Variables::getDefaultVariables();
     $option_move = $option_copy = $ansel_storage->countGalleries($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::EDIT));
     $this->_pagestart = $this->_page * $this->_perPage + 1;
     $this->_pageend = min($this->_pagestart + $view->numimages - 1, $this->_pagestart + $this->_perPage - 1);
     $view->pageStart = $this->_pageStart;
     $view->pageEnd = $this->_pageEnd;
     $view->owner = $this->_owner;
     $view->tagTrail = $this->_browser->getTagTrail();
     $view->title = $this->getTitle();
     $view->params = $this->_params;
     $view->style = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
     $viewurl = Horde::url('view.php')->add(array('view' => 'Results', 'actionID' => 'add'));
     $view->pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $view->total, 'url' => $viewurl, 'perpage' => $this->_perPage));
     $GLOBALS['page_output']->addScriptFile('views/common.js');
     $GLOBALS['page_output']->addScriptFile('views/gallery.js');
     return $view->render('results');
 }
Example #8
0
<?php

/**
 * Copyright 2003-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 Chuck Hagenbuch <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image'));
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
    throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
}
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
    /* Need to ensure the file exists */
    try {
        $image->createView('screen', Ansel::getStyleDefinition('ansel_default'), $GLOBALS['prefs']->getValue('watermark_auto') ? $GLOBALS['prefs']->getValue('watermark_text', '') : '');
    } catch (Ansel_Exception $e) {
        Horde::log($result, 'ERR');
        exit;
    }
    $filename = $injector->getInstance('Horde_Core_Factory_Vfs')->create('images')->readFile($image->getVFSPath('screen'), $image->getVFSName('screen'));
    Ansel::doSendfile($filename, $image->getType('screen'));
    exit;
}
$image->display('screen');
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
 /**
  * Build variables needed to output the html. Extracted to this method so
  * child classes can use this as well.
  */
 protected function _prepare()
 {
     global $conf;
     $this->_page = isset($this->_params['page']) ? $this->_params['page'] : 0;
     $this->_slug = $this->gallery->get('slug');
     $this->_date = $this->gallery->getDate();
     $this->_style = empty($this->_params['style']) ? $this->gallery->getStyle() : Ansel::getStyleDefinition($this->_params['style']);
     // Make sure the screen view is loaded and get the geometry
     try {
         $this->_geometry = $this->resource->getDimensions('screen');
     } catch (Ansel_Exception $e) {
         Horde::log($e, 'ERR');
         $this->_geometry = $GLOBALS['conf']['screen'];
     }
     // Get the image lists
     $this->_imageList = $this->gallery->listImages();
     $this->_revList = array_flip($this->_imageList);
     // Not needed when being called via api
     if (empty($this->_params['api'])) {
         // Build the various urls
         $imageActionUrl = Horde::url('image.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id, 'page' => $this->_page), $this->_date));
         if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             $this->_urls['prop_popup'] = Horde::popupJs($imageActionUrl, array('urlencode' => true, 'height' => 360, 'width' => 500, 'params' => array('actionID' => 'modify', 'ret' => 'image', 'gallery' => $this->gallery->id, 'image' => $this->resource->id, 'page' => $this->_page)));
             $this->_urls['edit'] = $imageActionUrl->copy()->add('actionID', 'editimage');
         }
         if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
             $this->_urls['delete'] = $imageActionUrl->copy()->add('actionID', 'delete');
         }
         if (!empty($conf['ecard']['enable'])) {
             $this->_urls['ecard'] = Horde::url('img/ecard.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id), $this->_date));
         }
         if ($this->gallery->canDownload()) {
             $this->_urls['download'] = Horde::url('img/download.php', true)->add('image', $this->resource->id);
         }
         if ((!$GLOBALS['registry']->getAuth() || $this->gallery->get('owner') != $GLOBALS['registry']->getAuth()) && !empty($GLOBALS['conf']['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $GLOBALS['registry']->isAuthenticated() || $conf['report_content']['allow'] == 'all')) {
             $this->_urls['report'] = Horde::url('report.php')->add(array('gallery' => $this->gallery->id, 'image' => $this->resource->id));
         }
     }
     // Check for an explicit gallery view url to use
     if (!empty($this->_params['gallery_view_url'])) {
         $this->_urls['gallery'] = new Horde_Url(str_replace(array('%g', '%s'), array($this->gallery->id, $this->_slug), urldecode($this->_params['gallery_view_url'])));
         $this->_urls['gallery']->add($this->_date);
     } else {
         $this->_urls['gallery'] = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'page' => $this->_page, 'view' => 'Gallery'), $this->_date), true);
     }
     // Get the image src url
     $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style);
     // A self url. Can't use Horde::selfUrl() since that would ignore
     // pretty urls.
     $this->_urls['self'] = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $this->resource->id, 'view' => 'Image', 'page' => $this->_page), $this->_date));
 }
Example #11
0
File: Mini.php Project: horde/horde
    /**
     * Build the javascript that will render the view.
     *
     * @return string  A string containing valid javascript.
     */
    public function html()
    {
        // Required
        $node = $this->_params['container'];
        if (empty($node)) {
            return '';
        }
        // Optional
        $gallery_slug = !empty($this->_params['gallery_slug']) ? $this->_params['gallery_slug'] : '';
        $gallery_id = !empty($this->_params['gallery_id']) ? $this->_params['gallery_id'] : null;
        $start = isset($this->_params['start']) ? $this->_params['start'] : 0;
        $count = isset($this->_params['count']) ? $this->_params['count'] : 0;
        $perpage = isset($this->_params['perpage']) ? $this->_params['perpage'] : 0;
        $thumbsize = !empty($this->_params['thumbsize']) ? $this->_params['thumbsize'] : 'mini';
        if ($thumbsize != 'mini' && $thumbsize != 'thumb' && $thumbsize != 'screen') {
            $thumbsize = 'mini';
        }
        $thumbtype = !empty($this->_params['thumbtype']) ? $this->_params['thumbtype'] : 'squarethumb';
        // Do we have a gallery, imagelist or user?
        $images = !empty($this->_params['images']) ? $this->_params['images'] : array();
        if (!empty($images)) {
            // Images are filtered for age and password protected galleries
            // in the ::getImageJson() call since they could all be from different
            // galleries.
            $images = explode(':', $images);
        } elseif (!empty($this->_params['user'])) {
            // User's most recent images.
            $galleries = array();
            $gs = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $this->_params['user']));
            foreach ($gs as $gallery) {
                $galleries[] = $gallery->id;
            }
            $images = array();
            $is = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages($galleries, $count);
            foreach ($is as $i) {
                $images[] = $i->id;
            }
        } else {
            try {
                $this->gallery = $this->_getGallery($gallery_id, $gallery_slug);
            } catch (Exception $e) {
                Horde::log($e, 'ERR');
                exit;
            }
            // We don't allow age restricted or password locked galleries to be
            // viewed via the mini embedded view since it shows *all* the images
            if (!$this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ) || !$this->gallery->isOldEnough() || $this->gallery->hasPasswd()) {
                return '';
            }
        }
        if (empty($images)) {
            $images = $json = self::json($this->gallery, array('full' => true, 'from' => $start, 'count' => $count, 'image_view' => $thumbsize, 'view_links' => true, 'generator' => $thumbtype));
            $json_full = self::json($this->gallery, array('full' => true, 'from' => $start, 'count' => $count, 'view_links' => true));
        } else {
            if ($thumbsize == 'thumb') {
                $style = Ansel::getStyleDefinition('ansel_default');
                $style->thumbstyle = $thumbtype;
            } else {
                $style = null;
            }
            $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, $style, true, $thumbsize, true);
            $json_full = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, $style, true, 'screen', true);
        }
        global $page_output;
        $page_output->addThemeStylesheet('embed.css');
        /* Some paths */
        $js_path = $GLOBALS['registry']->get('jsuri', 'horde');
        $pturl = Horde::url($js_path . '/prototype.js', true);
        $hjsurl = Horde::url($js_path . '/tooltips.js', true);
        $ansel_js_path = $GLOBALS['registry']->get('jsuri', 'ansel');
        $jsurl = Horde::url($ansel_js_path . '/embed.js', true);
        $hideLinks = (bool) (!empty($this->_params['hidelinks']));
        /* Lightbox specific URLs */
        if (!empty($this->_params['lightbox'])) {
            $effectsurl = Horde::url($js_path . '/scriptaculous/effects.js', true);
            $lbjsurl = Horde::url($ansel_js_path . '/lightbox.js', true);
            $page_output->addThemeStylesheet('lightbox.css');
        }
        Horde::startBuffer();
        $page_output->includeStylesheetFiles(array('nobase' => true), true);
        $css = Horde::endBuffer();
        /* Start building the javascript */
        $html = <<<EOT
            //<![CDATA[
            // Old fashioned way to play nice with Safari 2 (Adding script inline with the
            // DOM won't work).  Need two seperate files output here since the incldued
            // files don't seem to be parsed until after the entire page is loaded, so we
            // can't include prototype on the same page it's needed.

            if (typeof anseljson == 'undefined') {
                if (typeof Prototype == 'undefined') {
                    document.write('<script type="text/javascript" src="{$pturl}"></script>');
                }
                if (typeof Horde_ToolTips == 'undefined') {
                    document.write('<script type="text/javascript" src="{$hjsurl}"></script>');
                }

                anselnodes = new Array();
                anseljson = new Object();
                document.write('{$css}');
                document.write('<script type="text/javascript" src="{$jsurl}"></script>');
            }
            anselnodes[anselnodes.length] = '{$node}';
            anseljson['{$node}'] = new Object();
            anseljson['{$node}']['data'] = {$json};
            anseljson['{$node}']['perpage'] = {$perpage};
            anseljson['{$node}']['page'] = 0;
            anseljson['{$node}']['hideLinks'] = '{$hideLinks}';
            //]]>

EOT;
        /* Special requirements for lightbox */
        if (!empty($lbjsurl)) {
            $loading_img = Horde_Themes::img('lightbox/loading.gif');
            $close_img = Horde_Themes::img('lightbox/closelabel.gif');
            $imageText = _("Photo");
            $labelOf = _("of");
            $html .= <<<EOT
                if (typeof Effect == 'undefined') {
                    document.write('<script type="text/javascript" src="{$effectsurl}"></script>');
                }

                /* Make sure we only include this stuff once */
                if (typeof lbOptions == 'undefined') {

                    document.write('<script type="text/javascript" src="{$lbjsurl}"></script>');

                    lbOptions = {
                        fileLoadingImage: '{$loading_img}',
                        fileBottomNavCloseImage: '{$close_img}',
                        overlayOpacity: 0.8,
                        animate: true,
                        resizeSpeed: 7,
                        borderSize: 10,
                        labelImage: '{$imageText}',
                        labelOf: '{$labelOf}',
                        returnURL: '#',
                        startPage: 0
                    }
                }
                anseljson['{$node}']['lightbox'] = {$json_full};
EOT;
        }
        return $html;
    }
Example #12
0
<?php

global $prefs, $registry;
$ansel_webroot = $registry->get('webroot');
$horde_webroot = $registry->get('webroot', 'horde');
$style = Ansel::getStyleDefinition('ansel_mobile');
/* Variables used in core javascript files. */
$code['conf'] = array('SESSION_ID' => SID, 'thumbWidth' => $style->width ? $style->width : 75, 'thumbHeight' => $style->height ? $style->height : 75, 'user' => $GLOBALS['registry']->convertUsername($GLOBALS['registry']->getAuth(), false), 'name' => $registry->get('name'));
// List of top level galleries
$gallerylist = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('all_levels' => false, 'attributes' => $registry->getAuth()));
$galleries = array();
foreach ($gallerylist as $gallery) {
    $galleries[] = $gallery->toJson();
}
$code['conf']['galleries'] = $galleries;
/* Gettext strings used in core javascript files. */
$code['text'] = array('ajax_error' => _("Error when communicating with the server."));
echo $GLOBALS['page_output']->addInlineJsVars(array('var Ansel' => $code), array('top' => true));
Example #13
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 #14
0
 /**
  * Get a list of available, currently usable thumbnail styles.
  *
  * @return array  An array of Classnames => titles
  */
 protected function _thumbStyles()
 {
     // Iterate all available thumbstyles:
     $dir = ANSEL_BASE . '/lib/ImageGenerator';
     $files = scandir($dir);
     $thumbs = array();
     foreach ($files as $file) {
         if (substr($file, -9) == 'Thumb.php') {
             try {
                 $generator = Ansel_ImageGenerator::factory(substr($file, 0, -4), array('style' => Ansel::getStyleDefinition('ansel_default')));
                 $thumbs[substr($file, 0, -4)] = $generator->title;
             } catch (Ansel_Exception $e) {
             }
         }
     }
     return $thumbs;
 }
Example #15
0
File: Base.php Project: horde/horde
 /**
  * Initialize the renderer. This *must* be called before any attempt is made
  * to display or otherwise interact with the renderer.
  *
  */
 public function init()
 {
     global $prefs, $conf, $registry, $page_output;
     $this->galleryId = $this->view->gallery->id;
     $this->gallerySlug = $this->view->gallery->get('slug');
     $this->page = $this->view->page;
     // Number perpage from prefs or config
     if ($this->view->tilesperpage) {
         $this->perpage = $this->view->tilesperpage;
     } else {
         $this->perpage = min($prefs->getValue('tilesperpage'), $conf['thumbnail']['perpage']);
     }
     $this->pagestart = $this->page * $this->perpage + 1;
     // Fetch the children
     $this->fetchChildren($this->view->force_grouping);
     // Do we have an explicit style set from the API?
     // If not, use the gallery's
     if (!empty($this->view->style)) {
         $this->style = Ansel::getStyleDefinition($this->view->style);
     } else {
         $this->style = $this->view->gallery->getStyle();
     }
     // Include any widgets
     if (!empty($this->style->widgets) && !$this->view->api) {
         // Special case widgets - these are built in
         if (array_key_exists('Actions', $this->style->widgets)) {
             // Don't show action widget if no actions
             if ($registry->getAuth() || !empty($conf['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $registry->isAuthenticated() || $conf['report_content']['allow'] == 'all')) {
                 $this->view->addWidget(Ansel_Widget::factory('Actions'));
             }
             unset($this->style->widgets['Actions']);
         }
         // Gallery widgets always receive an array of image ids for
         // the current page.
         $ids = $this->getChildImageIds();
         foreach ($this->style->widgets as $wname => $wparams) {
             $wparams = array_merge($wparams, array('images' => $ids));
             $this->view->addWidget(Ansel_Widget::factory($wname, $wparams));
         }
     }
     if (empty($this->view->api)) {
         $page_output->addScriptFile('views/common.js');
         $page_output->addScriptFile('views/gallery.js');
         $page_output->addScriptFile('popup.js', 'horde');
         $strings = array('delete_conf' => _("Are you sure you want to delete the selected photos?"), 'choose_gallery_move' => _("You must choose a gallery to move photos to."), 'choose_images' => _("You must first choose photos."));
         $urls = array('image_date' => strval(Horde::url('edit_dates.php')->add(array('gallery' => $this->galleryId))));
         $js = array('Ansel = window.Ansel || {};', 'Ansel.galleryview_strings = ' . Horde_Serialize::serialize($strings, Horde_Serialize::JSON), 'Ansel.galleryview_urls = ' . Horde_Serialize::serialize($urls, Horde_Serialize::JSON), 'Ansel.has_edit = ' . $this->view->gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT) ? 1 : 0, 'Ansel.has_delete = ' . $this->view->gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE) ? 1 : 0);
         $page_output->addInlineScript($js, true);
     }
     // Perform any initialization of the subclasses.
     $this->_init();
 }
Example #16
0
 /**
  * Renders a gallery view
  *
  * @param array $params         Any parameters that the view might need.
  *                              @see Ansel_View_* classes for descriptions of
  *                              available parameters to use here.
  * @param string $app           Application scope to use, if not the default.
  * @param string $view          The generic type of view we want.
  *                              (Gallery, Image, List, Embedded)
  *
  * @return array  An array containing 'html' and 'crumbs' keys.
  */
 public function renderView($params = array(), $app = null, $view = 'Gallery')
 {
     if (!is_null($app)) {
         $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
     }
     $classname = 'Ansel_View_' . basename($view);
     $params['api'] = true;
     $params['view'] = $view;
     if ($params['style']) {
         $params['style'] = Ansel::getStyleDefinition($params['style']);
     }
     $trail = array();
     $return = array();
     try {
         $view = new $classname($params);
     } catch (Ansel_Exception $e) {
         $return['html'] = $e->getMessage();
         $return['crumbs'] = array();
         return $return;
     }
     $return['html'] = $view->html();
     if ($params['view'] == 'Gallery' || $params['view'] == 'Image') {
         $trail = $view->getGalleryCrumbData();
     }
     $return['crumbs'] = $trail;
     return $return;
 }
Example #17
0
 /**
  * Return a link to an image, suitable for use in an <img/> tag
  * Takes into account $conf['vfs']['direct'] and other
  * factors.
  *
  * @param string $imageId     The id of the image.
  * @param string $view        The view ('screen', 'thumb', 'full', 'mini')
  *                            to show.
  * @param boolean $full       Return a path that includes the server name?
  * @param Ansel_Style $style  Use this gallery style
  *
  * @return Horde_Url The image path.
  */
 public static function getImageUrl($imageId, $view = 'screen', $full = false, Ansel_Style $style = null)
 {
     global $conf;
     if (empty($imageId)) {
         return Horde::url((string) Ansel::getErrorImage($view), $full);
     }
     // Default to ansel_default
     if (is_null($style)) {
         $style = Ansel::getStyleDefinition('ansel_default');
     }
     // Don't load the image if the view exists
     $viewHash = Ansel_Image::viewExists($imageId, $view, $style);
     if ($conf['vfs']['src'] != 'php' && $viewHash === false) {
         // We have to make sure the image exists first, since we won't
         // be going through img/*.php to auto-create it.
         try {
             $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($imageId);
         } catch (Exception $e) {
             Horde::log($e, 'ERR');
             return Horde::url((string) Ansel::getErrorImage($view), $full);
         }
         try {
             $image->createView($view, $style, $GLOBALS['prefs']->getValue('watermark_auto') && $view == 'screen' ? $GLOBALS['prefs']->getValue('watermark_text', '') : '');
         } catch (Ansel_Exception $e) {
             return Horde::url((string) Ansel::getErrorImage($view), $full);
         }
         $viewHash = $image->getViewHash($view, $style) . '/' . $image->getVFSName($view);
     }
     // First check for vfs-direct. If we are not using it, pass this off to
     // the img/*.php files, and check for sendfile support there.
     if ($conf['vfs']['src'] != 'direct') {
         $params = array('image' => $imageId);
         if (!is_null($style)) {
             $params['t'] = $style->thumbstyle;
             $params['b'] = $style->background;
             if ($style->width) {
                 $params['w'] = $style->width;
             }
             if ($style->height) {
                 $params['h'] = $style->height;
             }
         }
         return Horde::url('img/' . $view . '.php', $full)->add($params);
     }
     // Using vfs-direct
     $path = substr(str_pad($imageId, 2, 0, STR_PAD_LEFT), -2) . '/' . $viewHash;
     if ($full && substr($conf['vfs']['path'], 0, 7) != 'http://') {
         return Horde::url($conf['vfs']['path'] . $path, true, -1);
     } else {
         return new Horde_Url($conf['vfs']['path'] . htmlspecialchars($path));
     }
 }
Example #18
0
             $subs = array();
             foreach ($subgalleries as $subgallery) {
                 $subs[] = $subgallery->id;
             }
             $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages($subs);
         } else {
             $images = $gallery->getRecentImages();
             $owner = $gallery->getIdentity();
             $author = $owner->getValue('from_addr');
         }
     }
     if (!count($images)) {
         $images = array();
     } else {
         $viewurl = Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $id), true);
         $img =& $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')));
         $params = array('last_modified' => $gallery->get('last_modified'), 'name' => sprintf(_("%s on %s"), $gallery->get('name'), $conf['server']['name']), 'link' => $viewurl, 'desc' => $gallery->get('desc'), 'image_url' => Ansel::getImageUrl($img->id, 'thumb', true), 'image_alt' => $img->caption, 'image_link' => Ansel::getUrlFor('view', array('image' => $img->id, 'gallery' => $img->gallery, 'view' => 'Image'), true));
     }
     break;
 case 'user':
     $galleries = array();
     try {
         $shares = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $id));
         foreach ($shares as $gallery) {
             if ($gallery->isOldEnough() && !$gallery->hasPasswd()) {
                 $galleries[] = $gallery->id;
             }
         }
     } catch (Horde_Share_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
     }
Example #19
0
    /**
     * Build the javascript that will render the view.
     *
     * @return string  A string containing valid javascript.
     */
    public function html()
    {
        // Required
        $node = $this->_params['container'];
        if (empty($node)) {
            return '';
        }
        // Need at least one of these
        $galleries = !empty($this->_params['gallery_slug']) ? explode(':', $this->_params['gallery_slug']) : '';
        $haveSlugs = true;
        if (empty($galleries)) {
            $galleries = !empty($this->_params['gallery_id']) ? explode(':', $this->_params['gallery_id']) : null;
            $haveSlugs = false;
        }
        // Determine the style/thumnailsize etc...
        $thumbsize = empty($this->_params['thumbsize']) ? 'thumb' : $this->_params['thumbsize'];
        $images = array();
        foreach ($galleries as $id) {
            try {
                if ($haveSlugs) {
                    $gallery = $this->_getGallery(null, $id);
                } else {
                    $gallery = $this->_getGallery($id);
                }
            } catch (Ansel_Exception $e) {
                Horde::log($e, 'ERR');
                exit;
            }
            if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
                return '';
            }
            // Since we are possibly displaying multiple galleries, standardize
            // on a single gallery style. If none is requested, default to
            // ansel_default.
            $gallery_style = empty($this->_params['style']) ? 'ansel_default' : $this->_params['style'];
            $images[] = $gallery->getKeyImage(Ansel::getStyleDefinition($gallery_style));
        }
        $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, null, true, $thumbsize, true);
        global $page_output;
        $page_output->addThemeStylesheet('jsembed.css');
        Horde::startBuffer();
        $page_output->includeStylesheetFiles(array('nobase' => true, 'nohorde' => true), true);
        $css = Horde::endBuffer();
        // Some paths
        $js_path = $GLOBALS['registry']->get('jsuri', 'horde');
        $pturl = Horde::url($js_path . '/prototype.js', true);
        $ansel_js_path = $GLOBALS['registry']->get('jsuri', 'ansel');
        $jsurl = Horde::url($ansel_js_path . '/embed.js', true);
        // Start building the javascript - we use the same parameters as with
        //the mini gallery view so we can use the same javascript to display it
        $html = <<<EOT
            //<![CDATA[
            // Old fashioned way to play nice with Safari 2 (Adding script inline with the
            // DOM won't work).  Need two seperate files output here since the incldued
            // files don't seem to be parsed until after the entire page is loaded, so we
            // can't include prototype on the same page it's needed.

            if (typeof anseljson == 'undefined') {
                if (typeof Prototype == 'undefined') {
                    document.write('<script type="text/javascript" src="{$pturl}"></script>');
                }
                anselnodes = new Array();
                anseljson = new Object();
                document.write('{$css}');
                document.write('<script type="text/javascript" src="{$jsurl}"></script>');
            }
            anselnodes[anselnodes.length] = '{$node}';
            anseljson['{$node}'] = new Object();
            anseljson['{$node}']['data'] = {$json};
            anseljson['{$node}']['perpage'] = 0;
            anseljson['{$node}']['page'] = 0;
            anseljson['{$node}']['hideLinks'] = false;
            anseljson['{$node}']['linkToGallery'] = true;
            //]]>
EOT;
        return $html;
    }
Example #20
0
/**
 * Copyright 2003-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 Chuck Hagenbuch <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image'));
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery));
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
    throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
}
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
    /* Need to ensure the file exists */
    try {
        $image->createView('mini', Ansel::getStyleDefinition('ansel_default'));
    } catch (Ansel_Exception $e) {
        Horde::log($e, 'ERR');
        exit;
    }
    $filename = $injector->getInstance('Horde_Core_Factory_Vfs')->create('images')->readFile($image->getVFSPath('mini'), $image->getVFSName('mini'));
    Ansel::doSendFile($filename, $image->getType('mini'));
    exit;
}
$image->display('mini', Ansel::getStyleDefinition('ansel_default'));
Example #21
0
 /**
  * Creates and caches the given view.
  *
  * @param string $view         Which view to create.
  * @param Ansel_Style  $style  A style object
  *
  * @throws Ansel_Exception
  */
 public function createView($view, Ansel_Style $style = null, $watermark = '')
 {
     // Default to the gallery's style
     if (empty($style)) {
         $style = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->gallery)->getStyle();
     }
     // Get the VFS info.
     $vfspath = $this->getVFSPath($view, $style);
     if ($GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->exists($vfspath, $this->getVFSName($view))) {
         return;
     }
     try {
         $data = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->read($this->getVFSPath('full'), $this->getVFSName('full'));
     } catch (Horde_Vfs_Exception $e) {
         Horde::log($e, 'ERR');
         throw new Ansel_Exception($e);
     }
     // Force screen images to ALWAYS be jpegs for performance/size
     if ($view == 'screen' && $GLOBALS['conf']['image']['type'] != 'jpeg') {
         $originalType = $this->_image->setType('jpeg');
     } else {
         $originalType = false;
     }
     $vHash = $this->getViewHash($view, $style);
     $this->_image->loadString($data);
     if ($view == 'thumb') {
         $viewType = $style->thumbstyle;
     } else {
         // Screen, Mini
         $viewType = ucfirst($view);
     }
     try {
         $iview = Ansel_ImageGenerator::factory($viewType, array('image' => $this, 'style' => $style));
     } catch (Ansel_Exception $e) {
         // It could be we don't support the requested effect, try
         // ansel_default before giving up.
         if ($view == 'thumb' && $viewType != 'Thumb') {
             $iview = Ansel_ImageGenerator::factory('Thumb', array('image' => $this, 'style' => Ansel::getStyleDefinition('ansel_default')));
         } else {
             // If it wasn't a thumb, then something else must be wrong
             throw $e;
         }
     }
     // generate the view
     $iview->create();
     // Cache the data from the new ImageGenerator
     try {
         $this->_data[$vHash] = $this->_image->raw();
     } catch (Horde_Image_Exception $e) {
         throw new Ansel_Exception($e);
     }
     // ...and put it in Horde_Image obejct, then save
     $this->_image->loadString($this->_data[$vHash]);
     $this->_loaded[$vHash] = true;
     $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->writeData($vfspath, $this->getVFSName($vHash), $this->_data[$vHash], true);
     // Watermark
     if (!empty($watermark)) {
         $this->watermark($view);
         // Cache the data again
         try {
             $this->_data[$vHash] = $this->_image->raw();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
         $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->writeData($vfspath, $this->getVFSName($view), $this->_data[$vHash]);
     }
     // Revert any type change
     if ($originalType) {
         $this->_image->setType($originalType);
     }
 }
Example #22
0
 *
 * @author Chuck Hagenbuch <*****@*****.**>
 */
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 . '" />';
Example #23
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;
 }