strFile; } /** * Getter. XHTML * * @access public */ public function getStrXHTML() { return $this->_xhtml; } /** * Getter. Output file * * @access public */ public function getStrOutputFile() { return $this->strOutputFile; } /** * Setter. File * * @access public */ public function setstrFile($file) { $this->strFile = $file; } /** * Setter. XHTML * * @access public */ public function setStrXHTML($strXHTML) { $this->_xhtml = $strXHTML; } /** * * @param string $outputFile */ public function setStrOutputFile($outputFile) { $this->strOutputFile = $outputFile; } /** * Return zip path * * @access public * @return string */ public function absoluteZipPath($path) { $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter( explode(DIRECTORY_SEPARATOR, $path), 'strlen' ); $arrAbsolutes = array(); foreach ($parts as $datParts) { if ('.' == $datParts) continue; if ('..' == $datParts) { array_pop($arrAbsolutes); } else { $arrAbsolutes[] = $datParts; } } return implode('/', $arrAbsolutes); } /** * Clean HTML * * @access public */ public function cleanXHTML() { $sectionOne = explode('
', $this->_xhtml); $sectionTwo = explode('', $this->_xhtml); $sectionTwo = str_replace( 'src="?image="', 'src="imagen_not_found.jpg"', $sectionTwo ); if (!isset($sectionTwo[1])) { $sectionTwo[1] = $this->_xhtml; } $this->_xhtml = $sectionOne[0] . '' . $sectionTwo[1]; } /** * Return file name * * @access public */ public function getFileName() { try { $partsFile = explode('/', $this->strFile); $divideFile = explode('.', array_pop($partsFile)); $fileName = array_shift($divideFile); } catch (Exception $e) { $fileName = 'file'; } return $fileName; } /** * Convert DOCX to XHTML * * @access public */ public function generateXHTML() { $package = new ZipArchive(); if (!$package->open($this->strFile)) { echo 'Unable to find the DOCX file'; exit(); } $relations = simplexml_load_string( $package->getFromName('_rels/.rels') ); foreach ($relations->Relationship as $rel) { if ($rel["Type"] == TransformDoc::SCHEMA_OFFICEDOCUMENT) { $xml = $package->getFromName( $this->absoluteZipPath( dirname($rel['Target']) . '/' . basename($rel['Target']) ) ); $xmlDOM = new DOMDocument(); $xml = str_replace('', '', $xml); $xml = preg_replace( '/(