Copyright 2001-2016 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 (chuck@horde.org)
Author: Michael J. Rubinsky (mrubinsk@horde.org)
コード例 #1
0
ファイル: OtherGalleries.php プロジェクト: horde/horde
 /**
  * Build the HTML for the other galleries widget content.
  *
  * @param Horde_View $view  The view object.
  */
 protected function _getOtherGalleries(&$view)
 {
     $owner = $this->_view->gallery->get('owner');
     // Set up the tree
     $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('otherAnselGalleries_' . md5($owner), 'Javascript', array('class' => 'anselWidgets'));
     try {
         $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $owner));
     } catch (Ansel_Exception $e) {
         Horde::log($e, 'ERR');
         return;
     }
     foreach ($galleries as $gallery) {
         $parents = $gallery->get('parents');
         if (empty($parents)) {
             $parent = null;
         } else {
             $parents = explode(':', $parents);
             $parent = array_pop($parents);
         }
         $img = (string) Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'mini', true);
         $link = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery'), true);
         $tree->addNode(array('id' => $gallery->id, 'parent' => $parent, 'label' => $gallery->get('name'), 'expanded' => $gallery->id == $this->_view->gallery->id, 'params' => array('icon' => $img, 'url' => $link)));
     }
     Horde::startBuffer();
     $tree->sort('label');
     $tree->renderTree();
     $view->tree = Horde::endBuffer();
     $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_ToggleOtherGalleries', array('id' => 'othergalleries-toggle'));
 }
コード例 #2
0
ファイル: MyGalleries.php プロジェクト: horde/horde
    /**
     */
    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;
    }
コード例 #3
0
ファイル: Actions.php プロジェクト: horde/horde
 /**
  * Helper function for generating the gallery actions selection widget.
  *
  * @param Horde_View $view  The view object.
  */
 protected function _getGalleryActions(&$view)
 {
     global $registry, $conf;
     $id = $this->_view->gallery->id;
     $galleryurl = Horde::url('gallery.php')->add('gallery', $id);
     $selfurl = Horde::selfUrl(true, false, true);
     $view->count = $count = $this->_view->gallery->countImages();
     $date = $this->_view->gallery->getDate();
     // Buid the url parameters to the zip link
     $view_params = array('gallery' => $this->_view->gallery->id, 'view' => 'Gallery', 'slug' => $this->_view->gallery->get('slug'), 'page' => !empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0);
     // Append the date information to the parameters if we need it
     $view_params = array_merge($view_params, $date);
     // Bookmark link
     if ($registry->hasMethod('bookmarks/getAddUrl')) {
         $api_params = array('url' => Ansel::getUrlFor('view', $view_params, true), 'title' => $this->_view->gallery->get('name'));
         try {
             $view->bookmark_url = new Horde_Url($registry->bookmarks->getAddUrl($api_params));
         } catch (Horde_Exception $e) {
         }
     }
     // Download as ZIP link
     if (!empty($conf['gallery']['downloadzip']) && $this->_view->gallery->canDownload() && $count && $this->_view->gallery->hasFeature('zipdownload')) {
         $zip_params = array_merge(array('actionID' => 'downloadzip'), $date);
         $view->zip_url = $galleryurl->copy()->add($zip_params)->link(array('class' => 'widget'));
     }
     // Image upload, subgalleries, captions etc..
     if ($this->_view->gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $view->hasEdit = true;
         $view->properties_url = $galleryurl->copy()->add(array('actionID' => 'modify', 'url' => $selfurl))->link(array('class' => 'widget'));
         if ($count) {
             if ($this->_view->gallery->hasFeature('image_captions')) {
                 $params = array_merge(array('gallery' => $id), $date);
                 $view->captions_url = Horde::url('gallery/captions.php')->add($params)->link(array('class' => 'widget'));
             }
             if ($this->_view->gallery->hasFeature('sort_images')) {
                 $view->sort_url = Horde::url('gallery/sort.php')->add(array_merge(array('gallery' => $id), $date))->link(array('class' => 'widget'));
                 $view->resetsort_url = Horde::url('gallery/sort.php')->add(array_merge(array('gallery' => $id, 'action' => 'Reset'), $date))->link(array('class' => 'widget'));
             }
             $view->regenerate_url = $galleryurl->copy()->add(array('actionID' => 'generateThumbs'))->link(array('class' => 'widget'));
             $view->regenerate_all = $galleryurl->copy()->add(array('actionID' => 'deleteCache'))->link(array('class' => 'widget'));
             if ($conf['faces']['driver'] && $conf['faces']['driver'] !== 'user' && $this->_view->gallery->hasFeature('faces')) {
                 $view->faces_url = Horde::url('faces/gallery.php')->add(array_merge($date, array('gallery' => $id, 'page' => !empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0)))->link(array('class' => 'widget'));
             }
         }
         if ($this->_view->gallery->hasFeature('stacks')) {
             $view->gendefault_url = $galleryurl->copy()->add(array('actionID' => 'generateDefault', 'url' => $selfurl))->link(array('class' => 'widget'));
         }
     }
     if ($registry->getAuth() && $this->_view->gallery->get('owner') == $registry->getAuth()) {
         $url = new Horde_Url('#');
         $view->perms_link = $url->link(array('class' => 'popup widget', 'onclick' => Horde::popupJs(Horde::url('perms.php'), array('params' => array('cid' => $this->_view->gallery->id), 'urlencode' => true)) . 'return false;'));
     } elseif (!empty($conf['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $registry->isAuthenticated() || $conf['report_content']['allow'] == 'all')) {
         $view->report_url = Horde::url('report.php')->add('gallery', $id)->link(array('class' => 'widget'));
     }
     if ($this->_view->gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
         $view->have_delete = true;
         $view->deleteall_url = $galleryurl->copy()->add('actionID', 'empty')->link(array('class' => 'widget'));
         $view->deletegallery_url = $galleryurl->copy()->add('actionID', 'delete')->link(array('class' => 'widget'));
     }
 }
コード例 #4
0
ファイル: Links.php プロジェクト: jubinpatel/horde
 public function html()
 {
     global $registry;
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addTemplatePath(ANSEL_TEMPLATES . '/widgets');
     $view->owner = $this->_view->gallery->get('owner');
     $view->userfeedurl = Ansel::getUrlFor('rss_user', array('owner' => $view->owner));
     $view->slug = $this->_view->gallery->get('slug');
     $view->galleryname = $this->_view->gallery->get('name');
     $view->galleryfeedurl = Ansel::getUrlFor('rss_gallery', array('gallery' => $this->_view->gallery->id, 'slug' => $view->slug));
     $view->title = _("Links");
     /* Embed html */
     if (empty($this->_view->_params['image_id'])) {
         /* Gallery view */
         $params = array('count' => 10);
         if (!empty($slug)) {
             $params['gallery_slug'] = $slug;
         } else {
             $params['gallery_id'] = $this->_view->gallery->id;
         }
     } else {
         // This is an image view
         $params = array('thumbsize' => 'screen', 'images' => $this->_view->_params['image_id'], 'count' => 10);
     }
     $view->embed = Ansel::embedCode($params);
     return $view->render('links');
 }
コード例 #5
0
ファイル: RoundedThumb.php プロジェクト: jubinpatel/horde
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), true);
     /* Don't bother with these effects for a stack image
      * (which will have a negative gallery_id). */
     if ($this->_image->gallery > 0) {
         if (is_null($this->_style)) {
             $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery);
             $styleDef = $gal->getStyle();
         } else {
             $styleDef = $this->_style;
         }
         try {
             /* Apply the effects - continue on error, but be sure to log */
             $this->_image->addEffect('RoundCorners', array('border' => 2, 'bordercolor' => '#333'));
             $this->_image->addEffect('DropShadow', array('background' => $styleDef->background, 'padding' => 5, 'distance' => 5, 'fade' => 3));
             if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
                 $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
             }
             $this->_image->applyEffects();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
         return $this->_image->getHordeImage();
     }
 }
コード例 #6
0
ファイル: SquareThumb.php プロジェクト: raz0rsdge/horde
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     // Take the largest requested dimension
     if (empty($this->_params['width'])) {
         $size = min($GLOBALS['conf']['thumbnail']['height'], $GLOBALS['conf']['thumbnail']['width']);
     } else {
         $size = min($this->_params['width'], $this->_params['height']);
     }
     // Use smartcrop algorithm if we have it, otherwise a plain center crop.
     if (Ansel::isAvailable('SmartCrop') && $GLOBALS['conf']['image']['smartcrop']) {
         $this->_image->addEffect('SmartCrop', array('width' => $size, 'height' => $size));
     } else {
         $this->_image->addEffect('CenterCrop', array('width' => $size, 'height' => $size));
     }
     $this->_image->applyEffects();
     if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
         try {
             $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
             $this->_image->applyEffects();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
     }
     return $this->_image->getHordeImage();
 }
コード例 #7
0
ファイル: DateGallery.php プロジェクト: jubinpatel/horde
 /**
  * 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');
 }
コード例 #8
0
ファイル: Gallery.php プロジェクト: raz0rsdge/horde
 /**
  * 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();
 }
コード例 #9
0
ファイル: Screen.php プロジェクト: jubinpatel/horde
 /**
  *
  * @return boolean
  */
 protected function _create()
 {
     $this->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']), min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']), true);
     if ($GLOBALS['conf']['screen']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
         try {
             $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['screen']['radius'], 'threshold' => $GLOBALS['conf']['screen']['threshold'], 'amount' => $GLOBALS['conf']['screen']['amount']));
             $this->_image->applyEffects();
         } catch (Horde_Image $e) {
             throw new Ansel_Exception($e);
         }
     }
     return $this->_image->getHordeImage();
 }
コード例 #10
0
ファイル: Application.php プロジェクト: raz0rsdge/horde
 /**
  */
 public function menu($menu)
 {
     global $conf, $registry;
     /* Browse/Search */
     $menu->add(Horde::url('browse.php'), _("_Browse"), 'ansel-browse', null, null, null, $GLOBALS['prefs']->getValue('defaultview') == 'browse' && basename($_SERVER['PHP_SELF']) == 'index.php' || basename($_SERVER['PHP_SELF']) == 'browse.php' ? 'current' : '__noselection');
     if ($GLOBALS['registry']->getAuth()) {
         $url = Ansel::getUrlFor('view', array('owner' => $GLOBALS['registry']->getAuth(), 'groupby' => 'owner', 'view' => 'List'));
         $menu->add($url, _("_My Galleries"), 'ansel-mygalleries', null, null, null, Horde_Util::getFormData('owner', false) == $GLOBALS['registry']->getAuth() ? 'current' : '__noselection');
     }
     $menu->add(Ansel::getUrlFor('view', array('view' => 'List')), _("_All Galleries"), 'ansel-allgalleries', null, null, null, $GLOBALS['prefs']->getValue('defaultview') == 'galleries' && basename($_SERVER['PHP_SELF']) == 'index.php' || basename($_SERVER['PHP_SELF']) == 'group.php' && Horde_Util::getFormData('owner') !== $GLOBALS['registry']->getAuth() ? 'current' : '__noselection');
     if ($conf['faces']['driver'] && $registry->isAuthenticated()) {
         $menu->add(Horde::url('faces/search/all.php'), _("_Faces"), 'ansel-faces');
     }
 }
コード例 #11
0
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     $imgobjs = $this->_getStackImages();
     $style = $this->_params['style'];
     $params = array('width' => 100, 'height' => 100, 'background' => $style->background);
     $baseImg = Ansel::getImageObject($params);
     try {
         $baseImg->addEffect('PhotoStack', array('images' => $imgobjs, 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], 'padding' => 0, 'background' => $style->background, 'type' => 'rounded'));
         $baseImg->applyEffects();
         $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], $GLOBALS['conf']['thumbnail']['height']);
     } catch (Horde_Image_Exception $e) {
         throw new Ansel_Exception($e);
     }
     return $baseImg;
 }
コード例 #12
0
ファイル: Cloud.php プロジェクト: jubinpatel/horde
 /**
  */
 protected function _content()
 {
     /* Get the tags */
     $tags = $GLOBALS['injector']->getInstance('Ansel_Tagger')->getCloud(null, $this->_params['count']);
     if (count($tags)) {
         $cloud = new Horde_Core_Ui_TagCloud();
         foreach ($tags as $id => $tag) {
             $link = Ansel::getUrlFor('view', array('view' => 'Results', 'tag' => $tag['tag_name']));
             $cloud->addElement($tag['tag_name'], $link, $tag['count']);
         }
         $html = $cloud->buildHTML();
     } else {
         $html = '';
     }
     return $html;
 }
コード例 #13
0
ファイル: Mini.php プロジェクト: jubinpatel/horde
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     if ($GLOBALS['conf']['image']['squaremini']) {
         $generator = Ansel_ImageGenerator::factory('SquareThumb', array('width' => min(50, $this->_dimensions['width']), 'height' => min(50, $this->_dimensions['height']), 'image' => $this->_image, 'style' => $this->_params['style']));
         return $generator->create();
     } else {
         $this->_image->resize(min(50, $this->_dimensions['width']), min(50, $this->_dimensions['height']), true);
         if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
             try {
                 $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
                 $this->_image->applyEffects();
             } catch (Horde_Image_Exception $e) {
                 throw new Ansel_Exception($e);
             }
         }
         return $this->_image->getHordeImage();
     }
 }
コード例 #14
0
ファイル: RandomPhoto.php プロジェクト: jubinpatel/horde
 /**
  */
 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>';
 }
コード例 #15
0
ファイル: Gallery.php プロジェクト: horde/horde
 /**
  */
 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>';
 }
コード例 #16
0
ファイル: SimilarPhotos.php プロジェクト: jubinpatel/horde
 /**
  * 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;
 }
コード例 #17
0
 /**
  */
 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>';
 }
コード例 #18
0
ファイル: PolaroidThumb.php プロジェクト: jubinpatel/horde
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), true);
     /* Don't bother with these effects for a custom gallery key image
        (which will have a negative gallery_id). */
     if ($this->_image->gallery > 0) {
         if (is_null($this->_style)) {
             $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery);
             $styleDef = $gal->getStyle();
         } else {
             $styleDef = $this->_style;
         }
         try {
             $this->_image->addEffect('PolaroidImage', array('background' => $styleDef->background, 'padding' => 5));
             if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
                 $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
             }
             $this->_image->applyEffects();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
         return true;
     }
 }
コード例 #19
0
ファイル: sort.php プロジェクト: jubinpatel/horde
" />
  <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();
コード例 #20
0
ファイル: upload_preview.php プロジェクト: horde/horde
 */
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";
}
コード例 #21
0
ファイル: Base.php プロジェクト: raz0rsdge/horde
 /**
  * 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);
 }
コード例 #22
0
ファイル: report.php プロジェクト: raz0rsdge/horde
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
$title = _("Do you really want to report this gallery?");
$gallery_id = (int) Horde_Util::getFormData('gallery');
try {
    $gallery = $injector->getInstance('Ansel_Storage')->getGallery($gallery_id);
} catch (Ansel_Exception $e) {
    $notification->push($e->getMessage());
    Horde::url('view.php?view=List', true)->redirect();
    exit;
}
if (($image_id = Horde_Util::getFormData('image')) !== null) {
    $title = _("Do you really want to report this photo?");
    $return_url = Ansel::getUrlFor('view', array('view' => 'Image', 'image' => $image_id, 'gallery' => $gallery_id), true);
} else {
    $return_url = Ansel::getUrlFor('view', array('gallery' => $gallery_id, 'view' => 'Gallery'), true);
}
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, $title);
$form->setButtons(array(array('class' => 'horde-default', 'value' => _("Report")), array('class' => 'horde-cancel', 'value' => _("Cancel"))));
$enum = array('advertisement' => _("Advertisement content"), 'terms' => _("Terms and conditions infringement"), 'offensive' => _("Offensive content"), 'copyright' => _("Copyright infringement"));
$form->addVariable($gallery->get('name'), 'name', 'description', false);
$form->addVariable($gallery->get('desc'), 'desc', 'description', false);
$form->addHidden('', 'gallery', 'text', true, true);
$vars->set('gallery', $gallery_id);
$form->addVariable(_("Report type"), 'type', 'radio', true, false, null, array($enum));
$form->addVariable(_("Report reason"), 'reason', 'longtext', true);
$gallery_id = Horde_Util::getFormData('id');
if ($vars->get('submitbutton') == _("Cancel")) {
    Horde::url('', true)->redirect();
}
コード例 #23
0
ファイル: Base.php プロジェクト: jubinpatel/horde
 /**
  * Get a Horde_Image object representing the requested face.
  *
  * @param integer $face_id  The requested face_id
  *
  * @return Horde_Image  The requested Horde_Image object
  * @throws Ansel_Exception
  */
 public function getFaceImageObject($face_id)
 {
     $face = $this->getFaceById($face_id, true);
     // Load the image for this face
     if (!$this->viewExists($face['image_id'], $face_id, true)) {
         throw new Ansel_Exception(sprintf("Unable to create or locate face_id %u", $face_id));
     }
     $vfspath = Ansel_Faces::getVFSPath($face['image_id']) . 'faces';
     $vfsname = $face_id . Ansel_Faces::getExtension();
     $img = Ansel::getImageObject();
     try {
         $data = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->read($vfspath, $vfsname);
     } catch (Horde_Vfs_Exception $e) {
         throw new Ansel_Exception($e);
     }
     $img->loadString($data);
     return $img;
 }
コード例 #24
0
ファイル: mini.php プロジェクト: raz0rsdge/horde
/**
 * 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'));
コード例 #25
0
ファイル: GalleryProperties.php プロジェクト: raz0rsdge/horde
 /**
  * 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;
 }
コード例 #26
0
ファイル: index.php プロジェクト: jubinpatel/horde
<?php

/**
 * Copyright 2001-2014 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');
/* Load mobile? */
if (in_array($registry->getView(), array(Horde_Registry::VIEW_MINIMAL, Horde_Registry::VIEW_SMARTMOBILE))) {
    include ANSEL_BASE . '/smartmobile.php';
    exit;
}
Ansel::getUrlFor('default_view', array())->redirect();
コード例 #27
0
ファイル: GallerySelect.php プロジェクト: horde/horde
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     return _("Default style for galleries") . Ansel::getStyleSelect('default_gallerystyle_select', $GLOBALS['prefs']->getValue('default_gallerystyle')) . '<br />';
 }
コード例 #28
0
ファイル: custom.php プロジェクト: horde/horde
$urlparams = array('page' => $page);
if (!empty($url)) {
    $urlparams['url'] = $url;
}
$form_post = Horde::url('faces/savecustom.php')->add($urlparams);
try {
    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id);
} catch (Ansel_Exception $e) {
    $notification->push($image);
    Horde::url('list.php')->redirect();
    exit;
}
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
    $notification->push(_("Access denied editing the photo."));
    Ansel::getUrlFor('view', array('gallery' => $image->gallery))->redirect();
    exit;
}
$x1 = 0;
$y1 = 0;
$x2 = $conf['screen']['width'];
$y2 = $conf['screen']['width'];
$name = Horde_Util::getFormData('name');
if ($face_id) {
    $faces = $injector->getInstance('Ansel_Faces');
    try {
        $face = $faces->getFaceById($face_id, true);
        $x1 = $face['face_x1'];
        $y1 = $face['face_y1'];
        $x2 = $face['face_x2'];
        $y2 = $face['face_y2'];
コード例 #29
0
ファイル: ActionHandler.php プロジェクト: raz0rsdge/horde
 public static function galleryActions($actionID)
 {
     global $registry, $notification, $page_output;
     if (self::download($actionID)) {
         return true;
     }
     $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
     switch ($actionID) {
         case 'add':
         case 'addchild':
         case 'save':
         case 'modify':
             $view = new Ansel_View_GalleryProperties(array('actionID' => $actionID, 'url' => new Horde_Url(Horde_Util::getFormData('url')), 'gallery' => Horde_Util::getFormData('gallery')));
             $view->run();
             exit;
         case 'downloadzip':
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
                 if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
                     $notification->push(_("Access denied downloading photos from this gallery."), 'horde.error');
                     Horde::url('view.php?view=List', true)->redirect();
                     exit;
                 }
                 Ansel::downloadImagesAsZip($gallery);
             } catch (Ansel_Exception $e) {
                 $notification->push($gallery->getMessage(), 'horde.error');
                 Horde::url('view.php?view=List', true)->redirect();
                 exit;
             }
             exit;
         case 'delete':
         case 'empty':
             // Print the confirmation screen.
             $galleryId = Horde_Util::getFormData('gallery');
             if ($galleryId) {
                 try {
                     $gallery = $ansel_storage->getGallery($galleryId);
                     $page_output->header();
                     $notification->notify(array('listeners' => 'status'));
                     require ANSEL_TEMPLATES . '/gallery/delete_confirmation.inc';
                     $page_output->footer();
                     exit;
                 } catch (Ansel_Exception $e) {
                     $notification->push($gallery->getMessage(), 'horde.error');
                 }
             }
             // Return to the gallery list.
             Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
             exit;
         case 'do_delete':
         case 'do_empty':
             $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
             $galleryId = Horde_Util::getPost('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
             } catch (Ansel_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
                 Ansel::getUrlFor('default_view', array())->redirect();
                 exit;
             }
             switch ($actionID) {
                 case 'do_delete':
                     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
                         $notification->push(_("Access denied deleting this gallery."), 'horde.error');
                     } else {
                         try {
                             $ansel_storage->removeGallery($gallery);
                             $notification->push(sprintf(_("Successfully deleted %s."), $gallery->get('name')), 'horde.success');
                         } catch (Ansel_Exception $e) {
                             $notification->push(sprintf(_("There was a problem deleting %s: %s"), $gallery->get('name'), $e->getMessage()), 'horde.error');
                         } catch (Horde_Exception_NotFound $e) {
                             Horde::log($e, 'err');
                         }
                     }
                     // Return to the default view.
                     Ansel::getUrlFor('default_view', array())->redirect();
                     exit;
                 case 'do_empty':
                     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
                         $notification->push(_("Access denied deleting this gallery."), 'horde.error');
                     } else {
                         $ansel_storage->emptyGallery($gallery);
                         $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name')), 'horde.success');
                     }
                     Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $galleryId, 'slug' => $gallery->get('slug')), true)->redirect();
                     exit;
                 default:
                     Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $galleryId, 'slug' => $gallery->get('slug')), true)->redirect();
                     exit;
             }
         case 'generateDefault':
             // Re-generate the default pretty gallery image.
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
                 $gallery->clearStacks();
                 $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success');
                 Horde::url('view.php', true)->add('gallery', $galleryId)->redirect();
                 exit;
             } catch (Ansel_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
                 Horde::url('index.php', true)->redirect();
                 exit;
             }
         case 'generateThumbs':
             // Re-generate all of this gallery's prettythumbs.
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
             } catch (Ansel_Exception $e) {
                 $notification->push($gallery->getMessage(), 'horde.error');
                 Horde::url('index.php', true)->redirect();
                 exit;
             }
             $gallery->clearThumbs();
             $notification->push(_("The gallery's thumbnails have successfully been reset."), 'horde.success');
             Horde::url('view.php', true)->add('gallery', $galleryId)->redirect();
             exit;
         case 'deleteCache':
             // Delete all cached image views.
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
             } catch (Ansel_Exception $e) {
                 $notification->push($gallery->getMessage(), 'horde.error');
                 Horde::url('index.php', true)->redirect();
                 exit;
             }
             $gallery->clearViews();
             $notification->push(_("The gallery's views have successfully been reset."), 'horde.success');
             Horde::url('view.php', true)->add('gallery', $galleryId)->redirect();
             exit;
     }
     return false;
 }
コード例 #30
0
ファイル: Storage.php プロジェクト: raz0rsdge/horde
 /**
  * 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);
 }