Properties

$_db

$_db : \Horde_Db_Adapter

database handle

Type

\Horde_Db_Adapter

$_shares

$_shares : \Horde_Share

The Horde_Shares object to use for this scope.

Type

\Horde_Share

$_images

$_images : array

Local cache of retrieved images

Type

array

Methods

__construct()

__construct(\Horde_Core_Share_Driver  $shareOb) : \Ansel_Storage

Const'r

Parameters

\Horde_Core_Share_Driver $shareOb

Returns

\Ansel_Storage

__get()

__get(string  $property) 

Property accessor

Parameters

string $property

The property to access.

setStorage()

setStorage(mixed  $storage) 

Backend setter

Parameters

mixed $storage

The backend storage driver.

createGallery()

createGallery(array  $attributes = array(), \Horde_Perms_Permission  $perm = null, integer  $parent = null) : \Ansel_Gallery

Create and initialise a new gallery object.

Parameters

array $attributes

The gallery attributes.

\Horde_Perms_Permission $perm

The permissions for the gallery if the defaults are not desirable.

integer $parent

The id of the parent gallery (if any)

Throws

\Ansel_Exception

Returns

\Ansel_Gallery

A new gallery object.

getGalleryBySlug()

getGalleryBySlug(string  $slug, array  $overrides = array()) : \Ansel_Gallery

Retrieve an Ansel_Gallery given the gallery's slug

Parameters

string $slug

The gallery slug

array $overrides

An array of attributes that should be overridden when the gallery is returned.

Throws

\Horde_Exception_NotFound

Returns

\Ansel_Gallery

The gallery object

getGallery()

getGallery(integer  $gallery_id, array  $overrides = array()) : \Ansel_Gallery

Retrieve an Ansel_Gallery given the share id

Parameters

integer $gallery_id

The gallery_id to fetch

array $overrides

An array of attributes that should be overridden when the gallery is returned.

Throws

\Ansel_Exception

Returns

\Ansel_Gallery

getGalleriesBySlugs()

getGalleriesBySlugs(array  $slugs,   $perms = \Horde_Perms::SHOW) : array

Retrieve an array of Ansel_Gallery objects for the given slugs.

Parameters

array $slugs

The gallery slugs.

$perms

Throws

\Ansel_Exception

Returns

array —

An array of Ansel_Gallery objects.

getGalleries()

getGalleries(array  $ids, integer  $perms = \Horde_Perms::SHOW) : array

Retrieve an array of Ansel_Gallery objects for the requested ids

Parameters

array $ids

Gallery ids to fetch

integer $perms

Horde_Perms constant for the perms required.

Throws

\Ansel_Exception

Returns

array —

An array of Ansel_Gallery objects

emptyGallery()

emptyGallery(\Ansel_Gallery  $gallery) 

Empties a gallery of all images.

Parameters

\Ansel_Gallery $gallery

The ansel gallery to empty.

Throws

\Ansel_Exception

removeGallery()

removeGallery(\Ansel_Gallery  $gallery) 

Removes an Ansel_Gallery.

Parameters

\Ansel_Gallery $gallery

The gallery to delete

Throws

\Ansel_Exception

getImage()

getImage(integer  $id) : \Ansel_Image

Returns the image corresponding to the given id.

Parameters

integer $id

The image_id of the image to retrieve.

Throws

\Ansel_Exception,

Horde_Exception_NotFound

Returns

\Ansel_Image

The image object requested..

saveImage()

saveImage(\Ansel_Image  $image) : integer

Save image details to storage. Does NOT update the cached image files.

Parameters

\Ansel_Image $image

The image to save.

Throws

\Ansel_Exception

Returns

integer —

The image id

saveImageAttribute()

saveImageAttribute(integer  $image_id,   $attribute, string  $value) 

Store an image attribute to storage

Parameters

integer $image_id

The image id

$attribute
string $value

The attrbute value

Throws

\Ansel_Exception

clearImageAttributes()

clearImageAttributes(integer  $image_id) 

Clears an image's attributes from storage.

Parameters

integer $image_id

The image to clear

Throws

\Ansel_Exception

getImageAttributes()

getImageAttributes(integer  $image_id) : array

Get image's attribtues from storage

Parameters

integer $image_id

The image id

Throws

\Horde_Exception

Returns

array —

A image attribute hash

setImageSortOrder()

setImageSortOrder(integer  $imageId, integer  $pos) 

Set image sort order

Parameters

integer $imageId

The image id

integer $pos

The new sort order position

Throws

\Ansel_Exception

getImages()

getImages(array  $params = array()) : array

Return the images corresponding to the given ids.

Parameters

array $params

function parameters:

   'ids'        - An array of image ids to fetch.
   'preserve'   - Preserve the order of the image ids when returned.
   'gallery_id' - Return all images from requested gallery (ignores 'ids').
   'from'       - If passing a gallery, start at this image.
   'count'      - If passing a gallery, return this many images.
 

Throws

\Ansel_Exception,

Horde_Exception_NotFound, InvalidArgumentException

Returns

array —

An array of Ansel_Image objects.

getRecentImages()

getRecentImages(array  $galleries = array(), integer  $limit = 10, string  $slugs = array()) : array

Returns a list of Ansel_Images of the most recently added images for the current user.

Parameters

array $galleries

An array of gallery ids to search in. If left empty, will search all galleries with Horde_Perms::SHOW.

integer $limit

The maximum number of images to return

string $slugs

An array of gallery slugs.

Throws

\Ansel_Exception

Returns

array —

An array of Ansel_Image objects

galleryExists()

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

Check if a gallery exists. Need to do this here so we can also check by gallery slug.

Parameters

integer $gallery_id

The gallery id

string $slug

The gallery slug

Throws

\Ansel_Exception

Returns

boolean

countGalleries()

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

Return the count of galleries that the user has specified permissions to and that match any of the requested attributes.

Parameters

$userid
array $params

Parameter array:

 (integer)perm          The level of permissions to require for a
                        gallery to return it [Horde_Perms::SHOW]
 (mixed)attributes      Restrict the galleries counted to those
                        matching $attributes. An array of
                        attribute/values pairs or a gallery owner
                        username.
(Ansel_Gallery)parent   The parent share to start counting at.
(boolean)all_levels      Return all levels, or just the direct children of
                        $parent? [true]
(array)tags             Filter results by galleries tagged with tags.

Throws

\Ansel_Exception

Returns

integer —

The count

listGalleries()

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

Retrieves the current user's gallery list from storage.

Parameters

array $params

Optional parameters:

    (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.
  

Throws

\Ansel_Exception

Returns

array —

An array of Ansel_Gallery objects

listAllGalleries()

listAllGalleries() : array

Returns a list of ALL galleries, regardless of permissions.

Returns

array

getImageJson()

getImageJson(array  $images, \Ansel_Style  $style = null, boolean  $full = false, string  $image_view = 'mini', boolean  $view_links = false) : string

Retrieve json data for an arbitrary list of image ids, not necessarily from the same gallery.

Parameters

array $images

An array of image ids

\Ansel_Style $style

A gallery style to force if requesting pretty thumbs.

boolean $full

Generate full urls

string $image_view

Which image view to use? screen, thumb etc..

boolean $view_links

Include links to the image view

Returns

string —

The json data

getRandomGallery()

getRandomGallery(array  $params = array()) 

Returns a random Ansel_Gallery from a list fitting the search criteria.

Parameters

array $params

listImages()

listImages(array  $params = array()) : array

Lists a slice of the image ids in the given gallery.

Parameters

array $params

Filter parameters.

 integer|array 'gallery_id'  - A gallery id to list images from
 integer 'offset'            - The image to start listing from
 integer 'limit'             - How many images to return
 array|string 'fields'       - The fields to return
 string 'sort'               - The field to sort by.
 array  'filter'             - Additional filters. Each element is an
                               array containing 'property', 'op', and
                               'value' keys. Passing 'IN' as the 'op'
                               and an array as 'value' will produce a
                               SQL IN conditional.

Throws

\Ansel_Exception,

InvalidArgumentException

Returns

array —

An array of images. Either an array of ids, or an array of field values, keyed by id.

getImagesGeodata()

getImagesGeodata(array  $image_ids = array(), integer  $gallery = null) : array

Return images' geolocation data.

Parameters

array $image_ids

An array of image_ids to look up.

integer $gallery

A gallery id. If this is provided, will return all images in the gallery that have geolocation data ($image_ids would be ignored).

Returns

array —

of geodata

getRecentImagesGeodata()

getRecentImagesGeodata(string  $user = null, integer  $start, integer  $count = 8) : array

Like getRecentImages, but returns geotag data for the most recently added images from the current user. Useful for providing images to help locate images at the same place.

Parameters

string $user

Limit images to this user

integer $start

Start a slice at this image number

integer $count

Include this many images

Returns

array —

An array of image ids

searchLocations()

searchLocations(string  $search = '') : array

Search for a textual location string from the passed in search token.

Used for location autocompletion.

Parameters

string $search

Search fragment for autocompleting location strings

Throws

\Ansel_Exception

Returns

array —

The results

setImagesGallery()

setImagesGallery(array  $image_ids, integer  $gallery_id) 

Set the gallery id for a set of images. Useful for bulk updating images when moving from one gallery to another.

Parameters

array $image_ids

An array of image ids

integer $gallery_id

The gallery id to move the images to.

Throws

\Ansel_Exception

removeImage()

removeImage(integer  $image_id) 

Deletes an Ansel_Image from data storage.

Parameters

integer $image_id

The image id(s) to remove.

Throws

\Ansel_Exception

ensureHash()

ensureHash(string  $hash) 

Ensure the style hash is recorded in the database.

Parameters

string $hash

The hash to record.

getHashes()

getHashes() : array

Get a list of all known styleHashes.

Returns

array —

An array of style hashes.

buildGallery()

buildGallery(\Horde_Share_Object  $share) : \Ansel_Gallery

Build a single Ansel_Gallery object from a Horde_Share_Object

Parameters

\Horde_Share_Object $share

The share

Returns

\Ansel_Gallery

buildGalleries()

buildGalleries(array  $shares) : array

Build an array of Ansel_Gallery objects from an array of Horde_Share_Object objects.

Parameters

array $shares

An array of Horde_Share_Object objects.

Returns

array —

Ansel_Gallery objects.

_getImageCommentCounts()

_getImageCommentCounts(array  $ids) : array

Get the total number of comments for an image.

Parameters

array $ids

Array of image ids

Returns

array —

of results. @see forums/numMessagesBatch api call

_getImageFields()

_getImageFields(  $alias = '') : string

Helper function to get a string of field names

Parameters

$alias

Returns

string

_toImageDriverName()

_toImageDriverName(string  $field) : string

Convert an Ansel_Image property to it's backend storage field name.

Parameters

string $field

The field name

Returns

string —

The converted field name suitable for use in backend.