PHP Класс Ansel_Storage, horde

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.
Автор: Michael J Rubinsky ([email protected])
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_db Horde_Db_Adapter database handle
$_images array Local cache of retrieved images
$_shares Horde_Share The Horde_Shares object to use for this scope.

Открытые методы

Метод Описание
__construct ( Horde_Core_Share_Driver $shareOb ) : Ansel_Storage Const'r
__get ( string $property ) Property accessor
buildGalleries ( array $shares ) : array Build an array of Ansel_Gallery objects from an array of Horde_Share_Object objects.
buildGallery ( Horde_Share_Object $share ) : Ansel_Gallery Build a single Ansel_Gallery object from a Horde_Share_Object
clearImageAttributes ( integer $image_id ) Clears an image's attributes from storage.
countGalleries ( $userid, array $params = [] ) : integer Return the count of galleries that the user has specified permissions to and that match any of the requested attributes.
createGallery ( array $attributes = [], Horde_Perms_Permission $perm = null, integer $parent = null ) : Ansel_Gallery Create and initialise a new gallery object.
emptyGallery ( Ansel_Gallery $gallery ) Empties a gallery of all images.
ensureHash ( string $hash ) Ensure the style hash is recorded in the database.
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.
getGalleries ( array $ids, integer $perms = Horde_Perms::SHOW ) : array Retrieve an array of Ansel_Gallery objects for the requested ids
getGalleriesBySlugs ( array $slugs, $perms = Horde_Perms::SHOW ) : array Retrieve an array of Ansel_Gallery objects for the given slugs.
getGallery ( integer $gallery_id, array $overrides = [] ) : Ansel_Gallery Retrieve an Ansel_Gallery given the share id
getGalleryBySlug ( string $slug, array $overrides = [] ) : Ansel_Gallery Retrieve an Ansel_Gallery given the gallery's slug
getHashes ( ) : array Get a list of all known styleHashes.
getImage ( integer $id ) : Ansel_Image Returns the image corresponding to the given id.
getImageAttributes ( integer $image_id ) : array Get image's attribtues from storage
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.
getImages ( array $params = [] ) : array Return the images corresponding to the given ids.
getImagesGeodata ( array $image_ids = [], integer $gallery = null ) : array Return images' geolocation data.
getRandomGallery ( array $params = [] ) Returns a random Ansel_Gallery from a list fitting the search criteria.
getRecentImages ( array $galleries = [], integer $limit = 10, array $slugs = [] ) : array Returns a list of Ansel_Images of the most recently added images for the current user.
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.
listAllGalleries ( ) : array Returns a list of ALL galleries, regardless of permissions.
listGalleries ( array $params = [] ) : array Retrieves the current user's gallery list from storage.
listImages ( array $params = [] ) : array Lists a slice of the image ids in the given gallery.
removeGallery ( Ansel_Gallery $gallery ) Removes an Ansel_Gallery.
removeImage ( integer $image_id ) Deletes an Ansel_Image from data storage.
saveImage ( Ansel_Image $image ) : integer Save image details to storage. Does NOT update the cached image files.
saveImageAttribute ( integer $image_id, $attribute, string $value ) Store an image attribute to storage
searchLocations ( string $search = '' ) : array Search for a textual location string from the passed in search token.
setImageSortOrder ( integer $imageId, integer $pos ) Set image sort order
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.
setStorage ( mixed $storage ) Backend setter

Защищенные методы

Метод Описание
_getImageCommentCounts ( array $ids ) : array Get the total number of comments for an image.
_getImageFields ( $alias = '' ) : string Helper function to get a string of field names
_toImageDriverName ( string $field ) : string Convert an Ansel_Image property to it's backend storage field name.

Описание методов

__construct() публичный Метод

Const'r
public __construct ( Horde_Core_Share_Driver $shareOb ) : Ansel_Storage
$shareOb Horde_Core_Share_Driver
Результат Ansel_Storage

__get() публичный Метод

Property accessor
public __get ( string $property )
$property string The property to access.

_getImageCommentCounts() защищенный Метод

Get the total number of comments for an image.
protected _getImageCommentCounts ( array $ids ) : array
$ids array Array of image ids
Результат array of results. @see forums/numMessagesBatch api call

_getImageFields() защищенный Метод

Helper function to get a string of field names
protected _getImageFields ( $alias = '' ) : string
Результат string

_toImageDriverName() защищенный Метод

Convert an Ansel_Image property to it's backend storage field name.
protected _toImageDriverName ( string $field ) : string
$field string The field name
Результат string The converted field name suitable for use in backend.

buildGalleries() публичный Метод

Build an array of Ansel_Gallery objects from an array of Horde_Share_Object objects.
public buildGalleries ( array $shares ) : array
$shares array An array of Horde_Share_Object objects.
Результат array Ansel_Gallery objects.

buildGallery() публичный Метод

Build a single Ansel_Gallery object from a Horde_Share_Object
public buildGallery ( Horde_Share_Object $share ) : Ansel_Gallery
$share Horde_Share_Object The share
Результат Ansel_Gallery

clearImageAttributes() публичный Метод

Clears an image's attributes from storage.
public clearImageAttributes ( integer $image_id )
$image_id integer The image to clear

countGalleries() публичный Метод

Return the count of galleries that the user has specified permissions to and that match any of the requested attributes.
public countGalleries ( $userid, array $params = [] ) : integer
$params array 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.
Результат integer The count

createGallery() публичный Метод

Create and initialise a new gallery object.
public createGallery ( array $attributes = [], Horde_Perms_Permission $perm = null, integer $parent = null ) : Ansel_Gallery
$attributes array The gallery attributes.
$perm Horde_Perms_Permission The permissions for the gallery if the defaults are not desirable.
$parent integer The id of the parent gallery (if any)
Результат Ansel_Gallery A new gallery object.

emptyGallery() публичный Метод

Empties a gallery of all images.
public emptyGallery ( Ansel_Gallery $gallery )
$gallery Ansel_Gallery The ansel gallery to empty.

ensureHash() публичный Метод

Ensure the style hash is recorded in the database.
public ensureHash ( string $hash )
$hash string The hash to record.

galleryExists() публичный Метод

Check if a gallery exists. Need to do this here so we can also check by gallery slug.
public galleryExists ( integer $gallery_id = null, string $slug = null ) : boolean
$gallery_id integer The gallery id
$slug string The gallery slug
Результат boolean

getGalleries() публичный Метод

Retrieve an array of Ansel_Gallery objects for the requested ids
public getGalleries ( array $ids, integer $perms = Horde_Perms::SHOW ) : array
$ids array Gallery ids to fetch
$perms integer Horde_Perms constant for the perms required.
Результат array An array of Ansel_Gallery objects

getGalleriesBySlugs() публичный Метод

Retrieve an array of Ansel_Gallery objects for the given slugs.
public getGalleriesBySlugs ( array $slugs, $perms = Horde_Perms::SHOW ) : array
$slugs array The gallery slugs.
Результат array An array of Ansel_Gallery objects.

getGallery() публичный Метод

Retrieve an Ansel_Gallery given the share id
public getGallery ( integer $gallery_id, array $overrides = [] ) : Ansel_Gallery
$gallery_id integer The gallery_id to fetch
$overrides array An array of attributes that should be overridden when the gallery is returned.
Результат Ansel_Gallery

getGalleryBySlug() публичный Метод

Retrieve an Ansel_Gallery given the gallery's slug
public getGalleryBySlug ( string $slug, array $overrides = [] ) : Ansel_Gallery
$slug string The gallery slug
$overrides array An array of attributes that should be overridden when the gallery is returned.
Результат Ansel_Gallery The gallery object

getHashes() публичный Метод

Get a list of all known styleHashes.
public getHashes ( ) : array
Результат array An array of style hashes.

getImage() публичный Метод

Returns the image corresponding to the given id.
public getImage ( integer $id ) : Ansel_Image
$id integer The image_id of the image to retrieve.
Результат Ansel_Image The image object requested..

getImageAttributes() публичный Метод

Get image's attribtues from storage
public getImageAttributes ( integer $image_id ) : array
$image_id integer The image id
Результат array A image attribute hash

getImageJson() публичный Метод

Retrieve json data for an arbitrary list of image ids, not necessarily from the same gallery.
public getImageJson ( array $images, Ansel_Style $style = null, boolean $full = false, string $image_view = 'mini', boolean $view_links = false ) : string
$images array An array of image ids
$style Ansel_Style A gallery style to force if requesting pretty thumbs.
$full boolean Generate full urls
$image_view string Which image view to use? screen, thumb etc..
$view_links boolean Include links to the image view
Результат string The json data

getImages() публичный Метод

Return the images corresponding to the given ids.
public getImages ( array $params = [] ) : array
$params array 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.
Результат array An array of Ansel_Image objects.

getImagesGeodata() публичный Метод

Return images' geolocation data.
public getImagesGeodata ( array $image_ids = [], integer $gallery = null ) : array
$image_ids array An array of image_ids to look up.
$gallery integer A gallery id. If this is provided, will return all images in the gallery that have geolocation data ($image_ids would be ignored).
Результат array of geodata

getRandomGallery() публичный Метод

Returns a random Ansel_Gallery from a list fitting the search criteria.
См. также: Ansel_Storage::listGalleries()
public getRandomGallery ( array $params = [] )
$params array

getRecentImages() публичный Метод

Returns a list of Ansel_Images of the most recently added images for the current user.
public getRecentImages ( array $galleries = [], integer $limit = 10, array $slugs = [] ) : array
$galleries array An array of gallery ids to search in. If left empty, will search all galleries with Horde_Perms::SHOW.
$limit integer The maximum number of images to return
$slugs array An array of gallery slugs.
Результат array An array of Ansel_Image objects

getRecentImagesGeodata() публичный Метод

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.
public getRecentImagesGeodata ( string $user = null, integer $start, integer $count = 8 ) : array
$user string Limit images to this user
$start integer Start a slice at this image number
$count integer Include this many images
Результат array An array of image ids

listAllGalleries() публичный Метод

Returns a list of ALL galleries, regardless of permissions.
public listAllGalleries ( ) : array
Результат array

listGalleries() публичный Метод

Retrieves the current user's gallery list from storage.
public listGalleries ( array $params = [] ) : array
$params array 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.
Результат array An array of Ansel_Gallery objects

listImages() публичный Метод

Lists a slice of the image ids in the given gallery.
public listImages ( array $params = [] ) : array
$params array 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.
Результат array An array of images. Either an array of ids, or an array of field values, keyed by id.

removeGallery() публичный Метод

Removes an Ansel_Gallery.
public removeGallery ( Ansel_Gallery $gallery )
$gallery Ansel_Gallery The gallery to delete

removeImage() публичный Метод

Deletes an Ansel_Image from data storage.
public removeImage ( integer $image_id )
$image_id integer The image id(s) to remove.

saveImage() публичный Метод

Save image details to storage. Does NOT update the cached image files.
public saveImage ( Ansel_Image $image ) : integer
$image Ansel_Image The image to save.
Результат integer The image id

saveImageAttribute() публичный Метод

Store an image attribute to storage
public saveImageAttribute ( integer $image_id, $attribute, string $value )
$image_id integer The image id
$value string The attrbute value

searchLocations() публичный Метод

Used for location autocompletion.
public searchLocations ( string $search = '' ) : array
$search string Search fragment for autocompleting location strings
Результат array The results

setImageSortOrder() публичный Метод

Set image sort order
public setImageSortOrder ( integer $imageId, integer $pos )
$imageId integer The image id
$pos integer The new sort order position

setImagesGallery() публичный Метод

Set the gallery id for a set of images. Useful for bulk updating images when moving from one gallery to another.
public setImagesGallery ( array $image_ids, integer $gallery_id )
$image_ids array An array of image ids
$gallery_id integer The gallery id to move the images to.

setStorage() публичный Метод

Backend setter
public setStorage ( mixed $storage )
$storage mixed The backend storage driver.

Описание свойств

$_db защищенное свойство

database handle
protected Horde_Db_Adapter $_db
Результат Horde_Db_Adapter

$_images защищенное свойство

Local cache of retrieved images
protected array $_images
Результат array

$_shares защищенное свойство

The Horde_Shares object to use for this scope.
protected Horde_Share $_shares
Результат Horde_Share