ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Drawing.php
Go to the documentation of this file.
1<?php
37{
43 private $_path;
44
48 public function __construct()
49 {
50 // Initialise values
51 $this->_path = '';
52
53 // Initialize parent
54 parent::__construct();
55 }
56
62 public function getFilename() {
63 return basename($this->_path);
64 }
65
71 public function getIndexedFilename() {
72 $fileName = $this->getFilename();
73 $fileName = str_replace(' ', '_', $fileName);
74 return str_replace('.' . $this->getExtension(), '', $fileName) . $this->getImageIndex() . '.' . $this->getExtension();
75 }
76
82 public function getExtension() {
83 $exploded = explode(".", basename($this->_path));
84 return $exploded[count($exploded) - 1];
85 }
86
92 public function getPath() {
93 return $this->_path;
94 }
95
104 public function setPath($pValue = '', $pVerifyFile = true) {
105 if ($pVerifyFile) {
106 if (file_exists($pValue)) {
107 $this->_path = $pValue;
108
109 if ($this->_width == 0 && $this->_height == 0) {
110 // Get width/height
111 list($this->_width, $this->_height) = getimagesize($pValue);
112 }
113 } else {
114 throw new PHPExcel_Exception("File $pValue not found!");
115 }
116 } else {
117 $this->_path = $pValue;
118 }
119 return $this;
120 }
121
127 public function getHashCode() {
128 return md5(
129 $this->_path
130 . parent::getHashCode()
131 . __CLASS__
132 );
133 }
134
138 public function __clone() {
139 $vars = get_object_vars($this);
140 foreach ($vars as $key => $value) {
141 if (is_object($value)) {
142 $this->$key = clone $value;
143 } else {
144 $this->$key = $value;
145 }
146 }
147 }
148}
An exception for terminatinating execution or to throw for unit testing.
getImageIndex()
Get image index.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
Definition: Drawing.php:138
getFilename()
Get Filename.
Definition: Drawing.php:62
getExtension()
Get Extension.
Definition: Drawing.php:82
getHashCode()
Get hash code.
Definition: Drawing.php:127
setPath($pValue='', $pVerifyFile=true)
Set Path.
Definition: Drawing.php:104
__construct()
Create a new PHPExcel_Worksheet_Drawing.
Definition: Drawing.php:48
getIndexedFilename()
Get indexed filename (using image index)
Definition: Drawing.php:71