\Ansel_Api

Ansel external API interface.

Copyright 2004-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Summary

Methods
Properties
Constants
browse()
put()
commentCallback()
hasComments()
saveImage()
postBatchUpload()
removeImage()
createGallery()
removeGallery()
count()
getGalleryKeyImage()
getImageUrl()
getImageContent()
listGalleries()
getGalleries()
selectGalleries()
listImages()
getRecentImages()
countGalleries()
listTagInfo()
searchTags()
galleryExists()
getGalleryStyles()
renderView()
No public properties found
No constants found
_getImageData()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

browse()

browse(string  $path = '', array  $properties = array()) : array

Browse through Ansel's gallery tree.

Parameters

string $path

The level of the tree to browse.

array $properties

The item properties to return. Defaults to 'name', 'icon', and 'browseable'.

Returns

array —

The contents of $path

put()

put(string  $path, string  $content, string  $content_type) : array

Saves an image into the gallery tree.

Parameters

string $path

The path where to PUT the file.

string $content

The file content.

string $content_type

The file's content type.

Throws

\Horde_Exception_PermissionDenied
\Horde_Exception_NotFound

Returns

array —

The event UIDs.

commentCallback()

commentCallback(integer  $image_id) : mixed

Callback for Agora comments.

Parameters

integer $image_id

Image id to check

Returns

mixed —

Image filename on success | false on failure

hasComments()

hasComments() : boolean

Checks if applications allows comments

Returns

boolean

saveImage()

saveImage(integer  $gallery_id, array  $image, array  $params = array()) : array

Stores an image in a gallery and returns gallery and image data.

Parameters

integer $gallery_id

The gallery id to add the image to.

array $image

Image data array. This can either be the return from Horde_Form_Type_image:: or an array with the following four fields: 'filename', 'description', 'data', 'type' and optionally 'tags'

array $params

An array of additional parameters:

  (string)slug         If set, use this as the gallery slug
                       (ignores $gallery_id)
  (string)scope        The scope to use, if not the default.
  (boolean)default     Set this as the key gallery image.
  (array)gallery_data  Any gallery parameters to change at this time.
  (string)encoding     The encoding type for the image data (base64 or binhex)
  (string)compression  The compression type for image data (gzip,lzf)
  (boolean)skiphook    Don't call the postupload hook(s).

Throws

\InvalidArgumentException
\Horde_Exception_PermissionDenied

Returns

array —

An array of image/gallery data

postBatchUpload()

postBatchUpload(array  $image_ids) 

Notify Ansel that a group of images has just been uploaded. Used for when the postupload hook should be called with a group of recently uploaded images, as opposed to calling it once after each image is saved.

Parameters

array $image_ids

An array of image ids.

removeImage()

removeImage(integer  $gallery_id, string  $image_id, array  $params = array()) 

Removes an image from a gallery.

Parameters

integer $gallery_id

The id of gallery.

string $image_id

The id of image to remove.

array $params

Additional parameters:

  (string)scope  The scope to use, if not the default.

Throws

\Horde_Exception_PermissionDenied

createGallery()

createGallery(array  $attributes, array  $params = array()) : integer

Add a new gallery to any application scope.

Parameters

array $attributes

The gallery attributes

array $params

Additional (optional) parameters:

   (string)scope    The scope to use, if not the default.
   (array)perm      An array of permission data if Ansel's defaults are
                    not desired. Takes an array like:
                       array('guest' => Horde_Perms::SHOW | Horde_Perms::READ,
                             'default' => Horde_Perms::SHOW | Horde_Perms::READ);
   (integer)parent  The gallery id of the parent gallery, if not a top level gallery.

Throws

\Horde_Exception_PermissionDenied

Returns

integer —

The gallery id of the new gallery

removeGallery()

removeGallery(integer  $gallery_id, array  $params = array()) 

Removes a gallery and its images.

Parameters

integer $gallery_id

The id of gallery.

array $params

Any additional, optional, parameters:

   (string)scope  the scope to use, if not the default
 

Throws

\Ansel_Exception
\Horde_Exception_PermissionDenied

count()

count(integer  $gallery_id = null, array  $params = array()) : integer

Returns the number of images in a gallery.

Parameters

integer $gallery_id

The gallery id.

array $params

Array of optional parameters:

   (string)scope  Scope to use, if not the default.
   (string)slug   If set, ignore gallery_id and use this as the slug.

Throws

\Ansel_Exception

Returns

integer —

The number of images in the gallery.

getGalleryKeyImage()

getGalleryKeyImage(integer  $gallery_id, array  $params = array()) : integer

Returns the id of the specified gallery's key image.

Parameters

integer $gallery_id

The gallery id.

array $params

Additional parameters:

 (string)scope   Application scope, if not the default
 (string)style   A named style to use, if not ansel_default
 (string)slug    Ignore gallery_id, and use this as the slug

Returns

integer —

The key image id.

getImageUrl()

getImageUrl(integer  $image_id, array  $params = array()) : string

Returns the URL to the specified image.

Parameters

integer $image_id

The id of the image.

array $params

Additional optional parameters:

   (string)scope  The application scope, if not the default.
   (string)view   The image view type to return (screen, thumb, etc...)
   (string)full   Return a fully qualified path?
   (string)style  Use this gallery style instead of ansel_default.
 

Returns

string —

The image path.

getImageContent()

getImageContent(integer  $image_id, array  $params = array()) : string

Returns raw image data in specified encoding/compression format.

Parameters

integer $image_id

The id of the image.

array $params

Optional parameters:

 (string)scope        Application scope, if not default.
 (string)view         The image view type to return (screen, thumb etc...)
 (string)style        Force the use of this gallery style
 (string)encoding     Encoding type (base64, binhex)
 (string)compression  Compression type (gzip, lzf)

Throws

\Horde_Exception_Permission_Denied
\Ansel_Exception

Returns

string —

The raw image data.

listGalleries()

listGalleries(array  $params = array()) : array

Returns a list of all galleries.

Parameters

array $params

Optional parameters:

 (string)scope       The application scope, if not default.
 (integer)perm       The permissions filter to use [Horde_Perms::SHOW]
 (mixed)attributes   Restrict the galleries returned to those matching
                     the filters. Can be an array of attribute/values
                     pairs or a gallery owner username.
 (integer)parent     The parent share to start listing at.
 (boolean)all_levels If set, return all levels below parent, not just
                     direct children [TRUE]
 (integer)from       The gallery to start listing at.
 (integer)count      The number of galleries to return.
 (string)sort_by     Attribute to sort by
 (integer)direction  The direction to sort by [Ansel::SORT_ASCENDING]
 (array)tags        An array of tags to limit results by.

Returns

array —

An array of gallery information.

getGalleries()

getGalleries(array  $ids, string  $app = null, array  $slugs = array()) : array

Returns an array of gallery information.

Parameters

array $ids

An array of gallery ids.

string $app

Application scope to use, if not the default.

array $slugs

An array of gallery slugs (ignore $ids).

Returns

array —

An array of gallery data arrays

selectGalleries()

selectGalleries(array  $params = array()) 

Returns a 'select' menu from the list of galleries created by listGalleries().

Parameters

array $params

Optional parameters:

 (string)scope      Application scope, if not default.
 (integer)selected  The gallery_id of the gallery that is selected
 (integer)perm      The permissions filter to use [Horde_Perms::SHOW]
 (mixed)filter      Restrict the galleries returned to those matching
                    the filters. Can be an array of attribute/values
                    pairs or a gallery owner username.
 (integer)parent    The parent share to start listing at.
 (integer)from      The gallery to start listing at.
 (integer)count     The number of galleries to return.
 (integer)ignore    An Ansel_Gallery id to ignore when building the tree.

listImages()

listImages(integer  $gallery_id, array  $params = array()) : array

Returns a list of all images in a gallery.

The return has the URL because in a lot of cases you'll want the url also. Using api call getImageURL results in a lot of overhead when e.g. generating a select list.

Parameters

integer $gallery_id

Gallery id to get images from.

array $params

Additional parameters:

 (string)app          Application scope to use [ansel].
 (string)view         View size to generate URLs for [thumb].
 (boolean)full        Return a full URL [false].
 (integer)from        Start image.
 (integer)limit       Max count of images to return.
 (string)style        Use this gallery style.
 (string)slug         Gallery slug (ignore gallery_id).

Returns

array —

Hash of image data (see below) keyed by image_id.

 name
 caption
 type
 uploaded
 original_date
 url

getRecentImages()

getRecentImages(array  $params = array()) : array

Return a list of recently added images

Parameters

array $params

Parameter (optionally) containing:

  (string)app       Application used if null then use default.
  (array)galleries  An array of gallery ids to check.  If left empty,
                    will search all galleries with the given
                    permissions for the current user.
  (string)view      The type of image view to return.
  (boolean)full     Return a full URL if this is true.
  (integer)limit    The maximum number of images to return.
  (string)style     Force the use of this gallery style
  (array)slugs      An array of gallery slugs

Returns

array —

A hash of image information arrays, keyed by image_id:

countGalleries()

countGalleries(array  $params = array()) : integer

Counts the number of galleries.

Parameters

array $params

Parameter array containing the following optional:

 (string)app         Application scope to use, if not the default.
 (integer)perm       The level of permissions to require for a gallery
                     to return it.
 (mixed)attributes   Restrict the galleries counted to those matching
                     attributes. An array of attribute/value pairs or
                     a gallery owner username.
 (integer)parent     The parent gallery id to start searching at.
 (boolean)all_levels  Return all levels, or just the direct children of
                     $parent?

Returns

integer —

Returns the number of matching galleries.

listTagInfo()

listTagInfo(array  $tags = null,   $user = null) : array

Retrieve the list of used tag_names, tag_ids and the total number of resources that are linked to that tag.

Parameters

array $tags

An optional array of tag_ids. If omitted, all tags will be included.

$user

Returns

array —

An array containing tag_name, and total

searchTags()

searchTags(array  $names, integer  $max = 10, integer  $from, string  $resource_type = '', string  $user = null, boolean  $raw = false, string  $app = 'ansel') : array

SearchTags API: Returns an application-agnostic array (useful for when doing a tag search across multiple applications)

The 'raw' results array can be returned instead by setting $raw = true.

Parameters

array $names

An array of tag_names to search for.

integer $max

The maximum number of resources to return.

integer $from

The number of the resource to start with.

string $resource_type

The resource type [gallery, image, '']

string $user

Restrict results to resources owned by $user.

boolean $raw

Return the raw data?

string $app

Application scope to use, if not the default.

Returns

array —

An array of results:

 'title'    - The title for this resource.
 'desc'     - A terse description of this resource.
 'view_url' - The URL to view this resource.
 'app'      - The Horde application this resource belongs to.

galleryExists()

galleryExists(integer  $gallery_id, string  $slug = '', string  $app = null) : boolean

Checks if the gallery exists

Parameters

integer $gallery_id

The gallery id

string $slug

The gallery slug

string $app

Application scope to use, if not the default.

Returns

boolean

getGalleryStyles()

getGalleryStyles() : \hash

Get a list of all pre-configured styles.

Returns

\hash —

of style definitions.

renderView()

renderView(array  $params = array(), string  $app = null, string  $view = 'Gallery') : array

Renders a gallery view

Parameters

array $params

Any parameters that the view might need. @see AnselView* classes for descriptions of available parameters to use here.

string $app

Application scope to use, if not the default.

string $view

The generic type of view we want. (Gallery, Image, List, Embedded)

Returns

array —

An array containing 'html' and 'crumbs' keys.

_getImageData()

_getImageData(string  $data, string  $encoding = 'none', string  $compression = 'none', boolean  $upload = true) : string

Returns decoded image data

Parameters

string $data

The image data

string $encoding

The encoding type for the image data. (none, base64, or binhex)

string $compression

The compression type for the image data. (none, gzip, or lzf)

boolean $upload

Process direction (true of encode/compress or false if decode/decompress)

Returns

string —

The decoded/encoded image data