[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * PHPExcel_Worksheet_Drawing 5 * 6 * Copyright (c) 2006 - 2015 PHPExcel 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 * @category PHPExcel 23 * @package PHPExcel_Worksheet_Drawing 24 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) 25 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL 26 * @version ##VERSION##, ##DATE## 27 */ 28 class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable 29 { 30 /** 31 * Path 32 * 33 * @var string 34 */ 35 private $path; 36 37 /** 38 * Create a new PHPExcel_Worksheet_Drawing 39 */ 40 public function __construct() 41 { 42 // Initialise values 43 $this->path = ''; 44 45 // Initialize parent 46 parent::__construct(); 47 } 48 49 /** 50 * Get Filename 51 * 52 * @return string 53 */ 54 public function getFilename() 55 { 56 return basename($this->path); 57 } 58 59 /** 60 * Get indexed filename (using image index) 61 * 62 * @return string 63 */ 64 public function getIndexedFilename() 65 { 66 $fileName = $this->getFilename(); 67 $fileName = str_replace(' ', '_', $fileName); 68 return str_replace('.' . $this->getExtension(), '', $fileName) . $this->getImageIndex() . '.' . $this->getExtension(); 69 } 70 71 /** 72 * Get Extension 73 * 74 * @return string 75 */ 76 public function getExtension() 77 { 78 $exploded = explode(".", basename($this->path)); 79 return $exploded[count($exploded) - 1]; 80 } 81 82 /** 83 * Get Path 84 * 85 * @return string 86 */ 87 public function getPath() 88 { 89 return $this->path; 90 } 91 92 /** 93 * Set Path 94 * 95 * @param string $pValue File path 96 * @param boolean $pVerifyFile Verify file 97 * @throws PHPExcel_Exception 98 * @return PHPExcel_Worksheet_Drawing 99 */ 100 public function setPath($pValue = '', $pVerifyFile = true) 101 { 102 if ($pVerifyFile) { 103 if (file_exists($pValue)) { 104 $this->path = $pValue; 105 106 if ($this->width == 0 && $this->height == 0) { 107 // Get width/height 108 list($this->width, $this->height) = getimagesize($pValue); 109 } 110 } else { 111 throw new PHPExcel_Exception("File $pValue not found!"); 112 } 113 } else { 114 $this->path = $pValue; 115 } 116 return $this; 117 } 118 119 /** 120 * Get hash code 121 * 122 * @return string Hash code 123 */ 124 public function getHashCode() 125 { 126 return md5( 127 $this->path . 128 parent::getHashCode() . 129 __CLASS__ 130 ); 131 } 132 133 /** 134 * Implement PHP __clone to create a deep clone, not just a shallow copy. 135 */ 136 public function __clone() 137 { 138 $vars = get_object_vars($this); 139 foreach ($vars as $key => $value) { 140 if (is_object($value)) { 141 $this->$key = clone $value; 142 } else { 143 $this->$key = $value; 144 } 145 } 146 } 147 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |