PHP Class Ansel_Gallery, 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.
Author: Michael J. Rubinsky ([email protected])
Inheritance: implements Serializable
显示文件 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_modeHelper Ansel_GalleryMode_ The gallery mode helper
$_share Horde_Share_Object The share object for this gallery.

Public Methods

Method Description
__construct ( Horde_Share_Object $share ) : Ansel_Gallery The Ansel_Gallery constructor.
__get ( string $property ) : mixed Helper for accessing the gallery id
addImage ( array $image_data, boolean $default = false ) : integer Add an image to this gallery.
addImageObject ( Ansel_Image $image, boolean $default = false ) : integer Adds an Ansel_Image object to this gallery.
canDownload ( ) : boolean Checks if the user can download the full photo
clearStacks ( ) Clear all of this gallery's key image stacks from the VFS and the gallery's data store.
clearThumbs ( ) Removes all generated and cached thumbnails for this gallery.
clearViews ( ) Removes all generated and cached views for this gallery.
copyImagesTo ( array $images, Ansel_Gallery $gallery ) : integer Copy image and related data to specified gallery.
countChildren ( $user, $perm = Horde_Perms::SHOW, $allLevels = true )
countGalleryChildren ( integer $perm = Horde_Perms::SHOW, boolean $galleries_only = false, boolean $noauto = true ) : integer Return the count of this gallery's children
countImages ( boolean $subgalleries = false ) : integer Returns the number of images in this gallery and, optionally, all sub-galleries.
get ( string $property ) : mixed Get a gallery property
getChildren ( string $user, integer $perm = Horde_Perms::SHOW, boolean $allLevels = true ) : array Get all children of this share.
getDate ( )
getGalleryChildren ( integer $perm = Horde_Perms::SHOW, integer $from, integer $to, boolean $noauto = true ) : A Get the children of this gallery.
getGalleryCrumbData ( ) : An Get an array describing where this gallery is in a breadcrumb trail.
getIdentity ( ) : Horde_Prefs_Identity Returns this share's owner's Identity object.
getImage ( integer $id ) : Ansel_Image Returns the image in this gallery corresponding to the given id.
getImages ( integer $from, integer $count ) Gets a slice of the images in this gallery.
getKeyImage ( Ansel_Style $style = null ) : mixed Returns the key image for this gallery.
getParent ( ) : Ansel_Gallery
getParents ( ) : array
getPermission ( ) : Horde_Perms_Permission Returns the permission of this share.
getRecentImages ( integer $limit = 10 ) : array Return the most recently added images in this gallery.
getShare ( ) : Horde_Share_Object Get the gallery's share object.
getStyle ( ) : Ansel_Style Return the style definition for this gallery.
getTags ( ) : array Returns this gallery's tags.
getTile ( Ansel_Gallery $parent = null, Ansel_Style $style = null, boolean $mini = false, array $params = [] ) : Ansel_Tile_Gallery Output the HTML for this gallery's tile.
hasFeature ( string $feature ) : boolean Check for special capabilities of this gallery.
hasPasswd ( ) : boolean Determine if we need to unlock a password protected gallery
hasPermission ( string $userid, integer $permission, string $creator = null ) : boolean Checks to see if a user has a given permission.
hasSubGalleries ( ) : boolean Checks if the gallery has any subgallery
isOldEnough ( ) : boolean Check user age limtation
listImages ( integer $from, integer $count ) : array Lists a slice of the image ids in this gallery.
moveImagesTo ( array $images, Ansel_Gallery $gallery ) : integer Move images from this gallery to a new gallery.
removeImage ( mixed $image, boolean $isStack = false ) Remove the given image from this gallery.
removeTag ( string $tag ) Remove a single tag from this gallery's tag collection
resetKeyImage ( ) Reset the gallery's key image. This will force Ansel to attempt to fetch a new key image the next time one is requested.
save ( ) Saves any changes to this object to the backend permanently.
serialize ( ) : string Serialize this object.
set ( string $attribute, mixed $value, boolean $update = false ) Sets an attribute value in this object.
setDate ( $date )
setImageOrder ( integer $imageId, integer $pos ) Set the order of an image in this gallery.
setParent ( mixed $parent ) Sets this gallery's parent gallery.
setPermission ( Horde_Perms_Permission $permission, $update = true )
setTags ( array $tags, $replace = true ) Set/replace this gallery's tags.
toArray ( )
toJson ( boolean $full = false ) : StdClass Returns a json representation of this gallery.
unserialize ( $data )
updateImageCount ( integer $images, boolean $add = true ) Update the gallery image count.

Protected Methods

Method Description
_getDefaultImageId ( ) : integer | boolean Returns the id for the key image of this gallery.
_setModeHelper ( string $type = 'Normal' ) : Ansel_Gallery_Mode Simple factory to set the proper mode object.

Method Details

__construct() public method

The Ansel_Gallery constructor.
public __construct ( Horde_Share_Object $share ) : Ansel_Gallery
$share Horde_Share_Object
return Ansel_Gallery

__get() public method

Helper for accessing the gallery id
public __get ( string $property ) : mixed
$property string The property
return mixed

_getDefaultImageId() protected method

Returns the id for the key image of this gallery.
protected _getDefaultImageId ( ) : integer | boolean
return integer | boolean The image id or false if none found.

_setModeHelper() protected method

Simple factory to set the proper mode object.
protected _setModeHelper ( string $type = 'Normal' ) : Ansel_Gallery_Mode
$type string The mode to use
return Ansel_Gallery_Mode object

addImage() public method

Add an image to this gallery.
public addImage ( array $image_data, boolean $default = false ) : integer
$image_data array The image to add. Keys include:
  image_filename   - The filename of the image [REQUIRED].
  data             - The binary image data [REQUIRED]
  image_caption    - The caption/description. Defaults to filename.
  image_type       - The MIME type of the image. Attempts to detect.
'image_caption', and 'data'. Optional keys include 'image_filename' and 'image_type'
$default boolean Make this image the new default tile image.
return integer The id of the new image.

addImageObject() public method

Adds an Ansel_Image object to this gallery.
public addImageObject ( Ansel_Image $image, boolean $default = false ) : integer
$image Ansel_Image The ansel image object to add
$default boolean Set this image as the gallery's key image.
return integer The new image id

canDownload() public method

Checks if the user can download the full photo
public canDownload ( ) : boolean
return boolean Whether or not user can download full photos

clearStacks() public method

Clear all of this gallery's key image stacks from the VFS and the gallery's data store.
public clearStacks ( )

clearThumbs() public method

Removes all generated and cached thumbnails for this gallery.
public clearThumbs ( )

clearViews() public method

Removes all generated and cached views for this gallery.
public clearViews ( )

copyImagesTo() public method

Copy image and related data to specified gallery.
public copyImagesTo ( array $images, Ansel_Gallery $gallery ) : integer
$images array An array of image ids.
$gallery Ansel_Gallery The gallery to copy images to.
return integer The number of images copied

countChildren() public method

public countChildren ( $user, $perm = Horde_Perms::SHOW, $allLevels = true )

countGalleryChildren() public method

Return the count of this gallery's children
public countGalleryChildren ( integer $perm = Horde_Perms::SHOW, boolean $galleries_only = false, boolean $noauto = true ) : integer
$perm integer The permissions to require.
$galleries_only boolean Only include galleries, no images.
$noauto boolean Do not auto drill down into gallery tree.
return integer The count of this gallery's children.

countImages() public method

Returns the number of images in this gallery and, optionally, all sub-galleries.
public countImages ( boolean $subgalleries = false ) : integer
$subgalleries boolean Determines whether subgalleries should be counted or not.
return integer number of images in this gallery

get() public method

Get a gallery property
public get ( string $property ) : mixed
$property string The property to return.
return mixed The value.

getChildren() public method

Get all children of this share.
public getChildren ( string $user, integer $perm = Horde_Perms::SHOW, boolean $allLevels = true ) : array
$user string The user to use for checking perms
$perm integer Horde_Perms::* constant. If NULL will return all shares regardless of permissions.
$allLevels boolean Return all levels.
return array An array of Ansel_Gallery objects

getDate() public method

public getDate ( )

getGalleryChildren() public method

Get the children of this gallery.
public getGalleryChildren ( integer $perm = Horde_Perms::SHOW, integer $from, integer $to, boolean $noauto = true ) : A
$perm integer The permissions to limit to.
$from integer The child to start at.
$to integer The child to end with.
$noauto boolean Prevent auto
return A mixed array of Ansel_Gallery and Ansel_Image objects that are children of this gallery.

getGalleryCrumbData() public method

Get an array describing where this gallery is in a breadcrumb trail.
public getGalleryCrumbData ( ) : An
return An array of 'title' and 'navdata' hashes with the [0] element being the deepest part.

getIdentity() public method

Returns this share's owner's Identity object.
public getIdentity ( ) : Horde_Prefs_Identity
return Horde_Prefs_Identity object for the owner of this gallery.

getImage() public method

Returns the image in this gallery corresponding to the given id.
public getImage ( integer $id ) : Ansel_Image
$id integer The ID of the image to retrieve.
return Ansel_Image The image object corresponding to the given id.

getImages() public method

Gets a slice of the images in this gallery.
public getImages ( integer $from, integer $count )
$from integer The image to start fetching.
$count integer The numer of images to return.

getKeyImage() public method

Returns the key image for this gallery.
public getKeyImage ( Ansel_Style $style = null ) : mixed
$style Ansel_Style Force the use of this style, if it's available otherwise use whatever style is choosen for this gallery. If prettythumbs are not available then we always use ansel_default style.
return mixed The image_id of the key image or false.

getParent() public method

public getParent ( ) : Ansel_Gallery
return Ansel_Gallery

getParents() public method

public getParents ( ) : array
return array An array of Ansel_Gallery objects.

getPermission() public method

Returns the permission of this share.
public getPermission ( ) : Horde_Perms_Permission
return Horde_Perms_Permission Permission object that represents the permissions on this share.

getRecentImages() public method

Return the most recently added images in this gallery.
public getRecentImages ( integer $limit = 10 ) : array
$limit integer The maximum number of images to return.
return array An array of Ansel_Image objects

getShare() public method

Get the gallery's share object.
public getShare ( ) : Horde_Share_Object
return Horde_Share_Object

getStyle() public method

Return the style definition for this gallery.
public getStyle ( ) : Ansel_Style
return Ansel_Style The style definition array.

getTags() public method

Returns this gallery's tags.
public getTags ( ) : array
return array of tag info

getTile() public method

Output the HTML for this gallery's tile.
public getTile ( Ansel_Gallery $parent = null, Ansel_Style $style = null, boolean $mini = false, array $params = [] ) : Ansel_Tile_Gallery
$parent Ansel_Gallery The parent Ansel_Gallery object
$style Ansel_Style A style object to use.
$mini boolean Force the use of a mini thumbnail?
$params array Any additional parameters the Ansel_Tile object may need.
return Ansel_Tile_Gallery

hasFeature() public method

Check for special capabilities of this gallery.
public hasFeature ( string $feature ) : boolean
$feature string The feature to check for.
return boolean

hasPasswd() public method

Determine if we need to unlock a password protected gallery
public hasPasswd ( ) : boolean
return boolean

hasPermission() public method

Checks to see if a user has a given permission.
public hasPermission ( string $userid, integer $permission, string $creator = null ) : boolean
$userid string The userid of the user.
$permission integer A Horde_Perms::* constant to test for.
$creator string The creator of the event.
return boolean Whether or not $userid has $permission.

hasSubGalleries() public method

Checks if the gallery has any subgallery
public hasSubGalleries ( ) : boolean
return boolean

isOldEnough() public method

Check user age limtation
public isOldEnough ( ) : boolean
return boolean

listImages() public method

Lists a slice of the image ids in this gallery.
public listImages ( integer $from, integer $count ) : array
$from integer The image to start listing.
$count integer The numer of images to list.
return array An array of image_ids

moveImagesTo() public method

Move images from this gallery to a new gallery.
public moveImagesTo ( array $images, Ansel_Gallery $gallery ) : integer
$images array An array of image ids.
$gallery Ansel_Gallery The gallery to move the images to.
return integer The number of images moved.

removeImage() public method

Remove the given image from this gallery.
public removeImage ( mixed $image, boolean $isStack = false )
$image mixed Image to delete. Can be an Ansel_Image or an image ID.
$isStack boolean Indicates if this image represents a stack image.

removeTag() public method

Remove a single tag from this gallery's tag collection
public removeTag ( string $tag )
$tag string The tag name to remove.

resetKeyImage() public method

Reset the gallery's key image. This will force Ansel to attempt to fetch a new key image the next time one is requested.
public resetKeyImage ( )

save() public method

Saves any changes to this object to the backend permanently.
public save ( )

serialize() public method

Serialize this object.
public serialize ( ) : string
return string The serialized data.

set() public method

Sets an attribute value in this object.
public set ( string $attribute, mixed $value, boolean $update = false )
$attribute string The attribute to set.
$value mixed The value for $attribute.
$update boolean Commit only this change to storage.

setDate() public method

public setDate ( $date )

setImageOrder() public method

Set the order of an image in this gallery.
public setImageOrder ( integer $imageId, integer $pos )
$imageId integer The image to sort.
$pos integer The sort position of the image.

setParent() public method

Sets this gallery's parent gallery.
public setParent ( mixed $parent )
$parent mixed An Ansel_Gallery or a gallery_id.

setPermission() public method

public setPermission ( Horde_Perms_Permission $permission, $update = true )
$permission Horde_Perms_Permission

setTags() public method

Set/replace this gallery's tags.
public setTags ( array $tags, $replace = true )
$tags array An array of tag names to associate with this image.

toArray() public method

public toArray ( )

toJson() public method

Returns a json representation of this gallery.
public toJson ( boolean $full = false ) : StdClass
$full boolean Return all information (subgalleries and images)?
return StdClass An object describing the gallery
'id' - gallery id
'p'  - gallery's parent's id (null if top level)
'pn' - gallery's parent's name (null if top level)
'n'  - gallery name
'dc' - date created
'dm' - date modified
'd'  - description
'ki' - key image
'sg' - an object with the following properties:
     'n'  - gallery name
     'dc' - date created
     'dm' - date modified
     'd'  - description
     'ki' - key image

 'imgs' - an array of image objects with the following properties:
     'id'  - the image id
     'url' - the image url

unserialize() public method

public unserialize ( $data )

updateImageCount() public method

Update the gallery image count.
public updateImageCount ( integer $images, boolean $add = true )
$images integer Number of images in action
$add boolean True if adding, false if removing

Property Details

$_modeHelper protected_oe property

The gallery mode helper
protected Ansel_GalleryMode_ $_modeHelper
return Ansel_GalleryMode_

$_share protected_oe property

The share object for this gallery.
protected Horde_Share_Object $_share
return Horde_Share_Object