eZPublish  3.9
eZImageAliasHandler Class Reference

Internal manager for the eZImage datatype. More...

Public Member Functions

 addImageAlias ($imageAlias)
 
 addImageAliases (&$imageAliasList)
 
 addImageAliasToXML (&$domTree, $imageAlias)
 
attribute ($attributeName)
 
attributeFromOriginal ($attributeName)
 
 attributes ()
 
 createImageInformationNode (&$imageNode, &$mimeData)
 
 directoryPath ()
 
 displayText ($alternativeText=null)
 
domTree ()
 
 eZImageAliasHandler (&$contentObjectAttribute)
 
 generateXMLData ()
 
 hasAttribute ($attributeName)
 
httpFile ($release=false)
 
imageAlias ($aliasName)
 
 imageName (&$contentObjectAttribute, &$contentVersion, $language=false)
 
 imageNameByNode (&$contentObjectAttribute, &$mainNode, $language=false)
 
 imagePath (&$contentObjectAttribute, &$contentVersion, $isImageOwner=null)
 
 imagePathByNode (&$contentObjectAttribute, &$mainNode)
 
 imageSerialNumber ()
 
 increaseImageSerialNumber ()
 
 initialize ($mimeData, $originalFilename, $imageAltText=false)
 
 initializeFromFile ($filename, $imageAltText=false, $originalFilename=false)
 
 initializeFromHTTPFile (&$httpFile, $imageAltText=false)
 
 isImageOwner ()
 
 isStorageRequired ()
 
originalAttributeData ()
 
 removeAliases (&$contentObjectAttribute)
 
 resetImageSerialNumber ()
 
 setAttribute ($attributeName, $attributeValue)
 
 setDOMTree (&$domTree)
 
 setHTTPFile (&$httpFile)
 
 setImageSerialNumber ($number)
 
 setOriginalAttributeData ($originalData)
 
 setOriginalAttributeDataFromAttribute (&$contentObjectAttribute)
 
 setOriginalAttributeDataValues ($attributeID, $attributeVersion, $attributeLanguage)
 
 setStorageRequired ($require=true)
 
 store (&$contentObjectAttribute)
 
 storeDOMTree (&$domTree, $storeAttribute, &$contentObjectAttributeRef)
 
 updateAliasPath ($dirpath, $name)
 

Static Public Member Functions

 normalizeImageName ($imageName)
 
 removeAllAliases (&$contentObjectAttribute)
 

Private Member Functions

aliasList ()
 
 createOriginalAttributeXMLData (&$originalNode, $originalData)
 
imageSerialNumberRaw ()
 
 parseInformationNode (&$imageInfoNode, &$imageInformation)
 
 recreateDOMTree ()
 

Private Attributes

 $ContentObjectAttribute
 Deprecated. Contains a reference to the object attribute. More...
 
 $ContentObjectAttributeData
 Contains a some eZContentObjectAttribute's attributes. More...
 

Detailed Description

Internal manager for the eZImage datatype.

Takes care of image conversion and serialization from and to the internal XML format.

Note
This handler was introduced in eZ publish 3.3 and will detect older eZImage structures and convert them on the fly.
The XML storage was improved in 3.8, from then it always stores the attribute ID, version and language in the <original> tag. This was required to get the new multi-language features to work.

Member Function Documentation

eZImageAliasHandler::addImageAlias (   $imageAlias)

Adds the image alias structure $imageAlias to the content object attribute.

eZImageAliasHandler::addImageAliases ( $imageAliasList)

Adds all the new image alias structures in $imageAliasList to the content object attribute.

Referenced by imageAlias().

eZImageAliasHandler::addImageAliasToXML ( $domTree,
  $imageAlias 
)

Adds the image alias structure $imageAlias to the XML DOM document $domTree.

Referenced by addImageAlias(), addImageAliases(), and recreateDOMTree().

& eZImageAliasHandler::aliasList ( )
private
Returns
A list of aliases structures for the current attribute.ezxml

The first this is called the XML data will be parsed into the internal structures. Subsequent calls will simply return the internal structure.

Referenced by directoryPath(), imageAlias(), recreateDOMTree(), removeAliases(), setAttribute(), and updateAliasPath().

& eZImageAliasHandler::attribute (   $attributeName)
Returns
the value of the attribute named $attributeName. See eZImageAliasHandler::attributes() for which attributes are available.

Referenced by attributeFromOriginal(), displayText(), imageName(), and imageNameByNode().

& eZImageAliasHandler::attributeFromOriginal (   $attributeName)
Returns
The value of the attribute named $attributeName from the 'original' image alias.

This is a quick way for extracting information from the 'original' image alias.

Referenced by attribute().

eZImageAliasHandler::attributes ( )

Lists all available image aliases as attributes as well as:

  • alternative_text - The alternative text input by the user, can be empty
  • original_filename - The name of image which it had on the users disk before it was uploaded
  • is_valid - A boolean which says if there is an image here or not.
eZImageAliasHandler::createImageInformationNode ( $imageNode,
$mimeData 
)
eZImageAliasHandler::createOriginalAttributeXMLData ( $originalNode,
  $originalData 
)
private

Creates XML attributes containing information on the original image attribute.

The new attributes will be appended to $originalNode.

Referenced by initialize(), recreateDOMTree(), and setOriginalAttributeData().

eZImageAliasHandler::directoryPath ( )
Returns
The full directory path to the image, this includes the var and storage directory.
eZImageAliasHandler::displayText (   $alternativeText = null)
Returns
A text string which can be used as display for the image.

The text string will either contain the alternative text from the attribute or the parameter $alternativeText if it is set.

Referenced by aliasList(), imageAlias(), and setAttribute().

& eZImageAliasHandler::domTree ( )
Returns
the DOM tree for the current content object attribute.
Note
It will cache the result in the DataTypeCustom member variable of the content object attribute in the 'dom_tree' key.

Referenced by addImageAlias(), addImageAliases(), setOriginalAttributeData(), and store().

eZImageAliasHandler::eZImageAliasHandler ( $contentObjectAttribute)

Creates the handler and creates a reference to the contentobject attribute that created it.

eZImageAliasHandler::generateXMLData ( )

Fetches image information from the old 3.2 image system and creates new information.

Referenced by aliasList(), and domTree().

eZImageAliasHandler::hasAttribute (   $attributeName)
Returns
true if the attribute named $attributeName exists. See eZImageAliasHandler::attributes() for which attributes are available.
& eZImageAliasHandler::httpFile (   $release = false)
Returns
the stored HTTP file object or false if no object is previously stored.
See Also
setHTTPFile
& eZImageAliasHandler::imageAlias (   $aliasName)
Returns
The image alias structure for the alias named $aliasName.

This will create the image alias if it does not exist yet, this can involve running image operations to for instance scale the image.

Referenced by attribute().

eZImageAliasHandler::imageName ( $contentObjectAttribute,
$contentVersion,
  $language = false 
)
Returns
A normalized name for the image.

The image name will generated from the name of the current version. If this is empty it will use the object name or the alternative text.

This ensures that the image has a name which corresponds to the object it belongs to.

The normalization ensures that the name only contains filename and URL friendly characters.

Referenced by generateXMLData(), initializeFromFile(), and initializeFromHTTPFile().

eZImageAliasHandler::imageNameByNode ( $contentObjectAttribute,
$mainNode,
  $language = false 
)
Returns
A normalized name for the image based on a node.

Similar to imageName() but fetches name information from the node $mainNode.

The normalization ensures that the name only contains filename and URL friendly characters.

eZImageAliasHandler::imagePath ( $contentObjectAttribute,
$contentVersion,
  $isImageOwner = null 
)
Returns
The storage path for the image.

The path is calculated by using information from the current object and version. If the object is in the node tree it will contain a path that matches the node path, if not it will be placed in the versioned storage repository.

Referenced by generateXMLData(), initializeFromFile(), and initializeFromHTTPFile().

eZImageAliasHandler::imagePathByNode ( $contentObjectAttribute,
$mainNode 
)
Returns
The storage path for the image based on a node.

Similar to imagePath() but fetches name information from the node $mainNode.

eZImageAliasHandler::imageSerialNumber ( )
Returns
The current serial number, the value will be 1 or higher.

The serial number is used to create unique filenames for uploaded images, it will be increased each time an image is uploaded.

Note
This was required to get around the problem where browsers caches image information, if two images were uploaded in one version (e.g. a draft) the browser would not load the new image since it thought it had not changed.

Referenced by imageName().

& eZImageAliasHandler::imageSerialNumberRaw ( )
private
Returns
The internal serial number.

It will check if a serial number exists and return that, if not a new one will be created and returned.

Referenced by imageSerialNumber(), increaseImageSerialNumber(), resetImageSerialNumber(), and setImageSerialNumber().

eZImageAliasHandler::increaseImageSerialNumber ( )

Increases the serial by one.

Referenced by initializeFromFile(), and initializeFromHTTPFile().

eZImageAliasHandler::initialize (   $mimeData,
  $originalFilename,
  $imageAltText = false 
)

Makes sure the attribute contains the image file mentioned in $mimeData. This involves removing any previous image (and image aliases), increasing the image name counter, figuring out the image size and creating the internal XML structure.

Returns
true on success.

Referenced by initializeFromFile(), and initializeFromHTTPFile().

eZImageAliasHandler::initializeFromFile (   $filename,
  $imageAltText = false,
  $originalFilename = false 
)

Initializes the content object attribute $contentObjectAttribute with the filename $filename. Optionally you may also specify the alternative text in the parameter $imageAltText.

See Also
initialize
eZImageAliasHandler::initializeFromHTTPFile ( $httpFile,
  $imageAltText = false 
)

Initializes the content object attribute $contentObjectAttribute with the uploaded HTTP file $httpFile. Optionally you may also specify the alternative text in the parameter $imageAltText.

eZImageAliasHandler::isImageOwner ( )
Returns
true if this is considered to be owner of the image.

It will be considered an owner if attribute data is not a copy of another attribute. For instance each time a new image is uploaded this will return true.

Referenced by imagePath(), removeAliases(), and updateAliasPath().

eZImageAliasHandler::isStorageRequired ( )
Returns
true if the image alias handler is required to store it's contents.
See Also
setStorageRequired, store
eZImageAliasHandler::normalizeImageName (   $imageName)
static

Normalized the image name $imageName by removing all characters that are not considered filename or URL friendly. The filename will also be in non-capital letters.

Referenced by imageName(), and imageNameByNode().

& eZImageAliasHandler::originalAttributeData ( )
Returns
An array structure with information on which attribute originally created the current data.

This will only contain data if the attribute is a copy of another attribute, e.g in the case of a new version without an new image upload.

Referenced by imagePath(), imagePathByNode(), initialize(), isImageOwner(), and recreateDOMTree().

eZImageAliasHandler::parseInformationNode ( $imageInfoNode,
$imageInformation 
)
private

Parses the information node and generates the internal information structures.

The information node contains information from the image itself, for instance EXIF data from a JPEG or TIFF image.

Referenced by aliasList().

eZImageAliasHandler::recreateDOMTree ( )
private

Recreates the DOM tree from the internal array structures and stores the DOM tree in the 'data_text' field of the attribute.

Referenced by setAttribute(), and updateAliasPath().

eZImageAliasHandler::removeAliases ( $contentObjectAttribute)

Removes all the image aliases and their information.

The stored images will also be removed if the attribute is the owner of the images.

After the images are removed the attribute will contained an internal structures with empty data.

Note
Transaction unsafe.

Referenced by initializeFromFile(), and initializeFromHTTPFile().

eZImageAliasHandler::removeAllAliases ( $contentObjectAttribute)
static

Removes all image alias files which the attribute refers to.

If you want to remove the alias information use removeAliases().

Referenced by eZImageType\deleteStoredObjectAttribute().

eZImageAliasHandler::resetImageSerialNumber ( )

Resets the serial number to zero.

Referenced by updateAliasPath().

eZImageAliasHandler::setAttribute (   $attributeName,
  $attributeValue 
)

Sets the attribute named $attributeName to have the value $attributeValue.

The following attributes can be set:

  • alternative text
  • original_filename
eZImageAliasHandler::setDOMTree ( $domTree)

Sets the XML DOM document $domTree as the current DOM document.

Referenced by initialize(), recreateDOMTree(), and setOriginalAttributeDataFromAttribute().

eZImageAliasHandler::setHTTPFile ( $httpFile)

Sets the uploaded HTTP file object to $httpFile. This object is used to store information about the image file until the content object attribute is to be stored.

See Also
httpFile
eZImageAliasHandler::setImageSerialNumber (   $number)

Sets the serial number to $number.

Referenced by aliasList().

eZImageAliasHandler::setOriginalAttributeData (   $originalData)

Sets the information on which attribute the data was fetched from. See eZImageAliasHandler::originalAttributeData() for more information.

Referenced by aliasList(), setOriginalAttributeDataFromAttribute(), and setOriginalAttributeDataValues().

eZImageAliasHandler::setOriginalAttributeDataFromAttribute ( $contentObjectAttribute)

Sets the information on which attribute the data was fetched from.

Fetches data from the contentobject attribute $contentObjectAttribute and sets it using setOriginalAttributeData().

eZImageAliasHandler::setOriginalAttributeDataValues (   $attributeID,
  $attributeVersion,
  $attributeLanguage 
)

Sets the information on which attribute the data was fetched from.

Fetches data from the parameters and sets it using setOriginalAttributeData().

Referenced by initialize(), initializeFromFile(), initializeFromHTTPFile(), and setOriginalAttributeDataFromAttribute().

eZImageAliasHandler::setStorageRequired (   $require = true)

Sets whether storage of the image alias data is required or not.

See Also
isStorageRequired, store

Referenced by setAttribute(), and updateAliasPath().

eZImageAliasHandler::store ( $contentObjectAttribute)

Stores the data in the image alias handler to the content object attribute.

See Also
isStorageRequired, setStorageRequired
eZImageAliasHandler::storeDOMTree ( $domTree,
  $storeAttribute,
$contentObjectAttributeRef 
)

Stores the XML DOM document $domTree to the content object attribute.

Referenced by addImageAlias(), addImageAliases(), generateXMLData(), removeAliases(), and store().

eZImageAliasHandler::updateAliasPath (   $dirpath,
  $name 
)

Will update the path for images to point to the new path $dirpath and filename $name.

This is usually called when the object contain the image attribute is moved in the tree.

Member Data Documentation

eZImageAliasHandler::$ContentObjectAttribute
private

Deprecated. Contains a reference to the object attribute.


The documentation for this class was generated from the following file: