ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
MemoryDrawing.php
Go to the documentation of this file.
1 <?php
30 if (!defined('PHPEXCEL_ROOT')) {
34  define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
35 }
36 
38 require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
39 
41 require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
42 
44 require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
45 
47 require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
48 
49 
58 {
59  /* Rendering functions */
60  const RENDERING_DEFAULT = 'imagepng';
61  const RENDERING_PNG = 'imagepng';
62  const RENDERING_GIF = 'imagegif';
63  const RENDERING_JPEG = 'imagejpeg';
64 
65  /* MIME types */
66  const MIMETYPE_DEFAULT = 'image/png';
67  const MIMETYPE_PNG = 'image/png';
68  const MIMETYPE_GIF = 'image/gif';
69  const MIMETYPE_JPEG = 'image/jpeg';
70 
76  private $_imageResource;
77 
84 
90  private $_mimeType;
91 
97  private $_uniqueName;
98 
102  public function __construct()
103  {
104  // Initialise values
105  $this->_imageResource = null;
106  $this->_renderingFunction = self::RENDERING_DEFAULT;
107  $this->_mimeType = self::MIMETYPE_DEFAULT;
108  $this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
109 
110  // Initialize parent
112  }
113 
119  public function getImageResource() {
120  return $this->_imageResource;
121  }
122 
129  public function setImageResource($value = null) {
130  $this->_imageResource = $value;
131 
132  if (!is_null($this->_imageResource)) {
133  // Get width/height
134  $this->_width = imagesx($this->_imageResource);
135  $this->_height = imagesy($this->_imageResource);
136  }
137  return $this;
138  }
139 
145  public function getRenderingFunction() {
147  }
148 
156  $this->_renderingFunction = $value;
157  return $this;
158  }
159 
165  public function getMimeType() {
166  return $this->_mimeType;
167  }
168 
176  $this->_mimeType = $value;
177  return $this;
178  }
179 
185  public function getIndexedFilename() {
186  $extension = strtolower($this->getMimeType());
187  $extension = explode('/', $extension);
188  $extension = $extension[1];
189 
190  return $this->_uniqueName . $this->getImageIndex() . '.' . $extension;
191  }
192 
198  public function getHashCode() {
199  return md5(
200  $this->_renderingFunction
201  . $this->_mimeType
202  . $this->_uniqueName
203  . parent::getHashCode()
204  . __CLASS__
205  );
206  }
207 
213  private $_hashIndex;
214 
223  public function getHashIndex() {
224  return $this->_hashIndex;
225  }
226 
235  public function setHashIndex($value) {
236  $this->_hashIndex = $value;
237  }
238 
242  public function __clone() {
243  $vars = get_object_vars($this);
244  foreach ($vars as $key => $value) {
245  if (is_object($value)) {
246  $this->$key = clone $value;
247  } else {
248  $this->$key = $value;
249  }
250  }
251  }
252 }