|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZImageLayer class 00004 // 00005 // Created on: <03-Oct-2002 15:05:09 amos> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezimagelayer.php 00032 */ 00033 00034 /*! 00035 \class eZImageLayer ezimagelayer.php 00036 \ingroup eZImageObject 00037 \brief Defines a layer in a image object 00038 00039 */ 00040 00041 //include_once( 'lib/ezimage/classes/ezimageinterface.php' ); 00042 00043 class eZImageLayer extends eZImageInterface 00044 { 00045 /*! 00046 Constructor 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 A definition which tells the template engine which template to use 00058 for displaying the image. 00059 */ 00060 function templateData() 00061 { 00062 return array( 'type' => 'template', 00063 'template_variable_name' => 'layer', 00064 'uri' => $this->TemplateURI ); 00065 } 00066 00067 /*! 00068 Sets the URI of the template to use for displaying it using the template engine to \a $uri. 00069 */ 00070 function setTemplateURI( $uri ) 00071 { 00072 $this->TemplateURI = $uri; 00073 } 00074 00075 /*! 00076 \virtual 00077 Tries to merge the current layer with the layer \a $lastLayerData 00078 onto the image object \a $image. 00079 Different kinds of layer classes will merge layers differently. 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 $isTrueColor = $this->isTruecolor(); 00093 $image->cloneImage( $this->imageObject(), $this->width(), $this->height(), 00094 $isTrueColor ); 00095 } 00096 else 00097 { 00098 $image->mergeImage( $destinationImageObject, $imageObject, 00099 $x, $y, 00100 $this->width(), $this->height(), 0, 0, 00101 $image->getTransparencyPercent( $layerData['parameters'] ) ); 00102 } 00103 } 00104 else 00105 { 00106 $destinationImageObject = $image->imageObjectInternal(); 00107 $image->mergeImage( $destinationImageObject, $imageObject, 00108 $x, $y, 00109 $this->width(), $this->height(), 0, 0, 00110 $image->getTransparencyPercent( $layerData['parameters'] ) ); 00111 } 00112 } 00113 00114 /*! 00115 Creates a new file layer for the file \a $fileName in path \a $filePath. 00116 */ 00117 static function createForFile( $fileName, $filePath, $fileType = false ) 00118 { 00119 $layer = new eZImageLayer(); 00120 $layer->setStoredFile( $fileName, $filePath, $fileType ); 00121 $layer->process(); 00122 return $layer; 00123 } 00124 00125 /// \privatesection 00126 public $TemplateURI; 00127 } 00128 00129 ?>