00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 include_once( 'lib/ezimage/classes/ezimageinterface.php' );
00042
00043 class eZImageLayer extends eZImageInterface
00044 {
00045
00046
00047
00048 function eZImageLayer( $imageObjectRef = null, $imageObject = null,
00049 $width = false, $height = false, $font = false )
00050 {
00051 $this->eZImageInterface( $imageObjectRef, $imageObject, $width, $height );
00052 $this->setFont( $font );
00053 $this->TemplateURI = 'design:image/layer.tpl';
00054 }
00055
00056
00057
00058
00059
00060 function templateData()
00061 {
00062 return array( 'type' => 'template',
00063 'template_variable_name' => 'layer',
00064 'uri' => $this->TemplateURI );
00065 }
00066
00067
00068
00069
00070 function setTemplateURI( $uri )
00071 {
00072 $this->TemplateURI = $uri;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081 function mergeLayer( &$image, &$layerData, &$lastLayerData )
00082 {
00083 $position = $image->calculatePosition( $layerData['parameters'], $this->width(), $this->height() );
00084 $x = $position['x'];
00085 $y = $position['y'];
00086 $imageObject = $this->imageObject();
00087 if ( $lastLayerData === null )
00088 {
00089 $destinationImageObject = $image->imageObjectInternal( false );
00090 if ( $destinationImageObject === null )
00091 {
00092 $image->clone( $this );
00093 }
00094 else
00095 {
00096 $image->mergeImage( $destinationImageObject, $imageObject,
00097 $x, $y,
00098 $this->width(), $this->height(), 0, 0,
00099 $image->getTransparencyPercent( $layerData['parameters'] ) );
00100 }
00101 }
00102 else
00103 {
00104 $destinationImageObject = $image->imageObjectInternal();
00105 $image->mergeImage( $destinationImageObject, $imageObject,
00106 $x, $y,
00107 $this->width(), $this->height(), 0, 0,
00108 $image->getTransparencyPercent( $layerData['parameters'] ) );
00109 }
00110 }
00111
00112
00113
00114
00115 function &createForFile( $fileName, $filePath, $fileType = false )
00116 {
00117 $layer = new eZImageLayer();
00118 $layer->setStoredFile( $fileName, $filePath, $fileType );
00119 $layer->process();
00120 return $layer;
00121 }
00122
00123
00124 var $TemplateURI;
00125 }
00126
00127 ?>