fileSupportsUnserializePHPPowerPoint($pFilename); } /** * Loads PHPPowerPoint Serialized file * * @param string $pFilename * @return PHPPowerPoint * @throws Exception */ public function load($pFilename) { // Check if file exists if (!file_exists($pFilename)) { throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); } // Unserialize... First make sure the file supports it! if (!$this->fileSupportsUnserializePHPPowerPoint($pFilename)) { throw new Exception("Invalid file format for PHPPowerPoint_Reader_Serialized: " . $pFilename . "."); } return $this->_loadSerialized($pFilename); } /** * Load PHPPowerPoint Serialized file * * @param string $pFilename * @return PHPPowerPoint */ private function _loadSerialized($pFilename) { $xmlData = simplexml_load_string(file_get_contents("zip://$pFilename#PHPPowerPoint.xml")); $excel = unserialize(base64_decode((string)$xmlData->data)); // Update media links for ($i = 0; $i < $excel->getSlideCount(); ++$i) { for ($j = 0; $j < $excel->getSlide($i)->getShapeCollection()->count(); ++$j) { if ($excel->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPExcl_Shape_BaseDrawing) { $imgTemp =& $excel->getSlide($i)->getShapeCollection()->offsetGet($j); $imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false); } } } return $excel; } /** * Does a file support UnserializePHPPowerPoint ? * * @param string $pFilename * @throws Exception * @return boolean */ public function fileSupportsUnserializePHPPowerPoint($pFilename = '') { // Check if file exists if (!file_exists($pFilename)) { throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); } // File exists, does it contain PHPPowerPoint.xml? return PHPPowerPoint_Shared_File::file_exists("zip://$pFilename#PHPPowerPoint.xml"); } }