ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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
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 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 }