/**
  * @param $zipFileName
  * @param $internalFiles ZipContentObject[]
  *
  * @return string
  */
 public function reBuildZipContent($zipFileName, $internalFiles)
 {
     $fs = new FilesStorage();
     $zipFile = $fs->getOriginalZipPath($this->jobInfo['create_date'], $this->jobInfo['id_project'], $zipFileName);
     $tmpFName = tempnam(INIT::$TMP_DOWNLOAD . '/' . $this->id_job . '/', "ZIP");
     copy($zipFile, $tmpFName);
     $zip = new ZipArchiveExtended();
     if ($zip->open($tmpFName)) {
         $zip->createTree();
         //rebuild the real name of files in the zip archive
         foreach ($zip->treeList as $filePath) {
             $realPath = str_replace(array(ZipArchiveExtended::INTERNAL_SEPARATOR, FilesStorage::pathinfo_fix($tmpFName, PATHINFO_BASENAME)), array(DIRECTORY_SEPARATOR, ""), $filePath);
             $realPath = ltrim($realPath, "/");
             //remove the tmx from the original zip ( we want not to be exported as preview )
             if (FilesStorage::pathinfo_fix($realPath, PATHINFO_EXTENSION) == 'tmx') {
                 $zip->deleteName($realPath);
                 continue;
             }
             //fix the file names inside the zip file, so we compare with our files
             // and if matches we can substitute them with the converted ones
             //                $fileName_fixed = array_pop( explode( DIRECTORY_SEPARATOR, str_replace( " ", "_", $realPath ) ) );
             foreach ($internalFiles as $index => $internalFile) {
                 //                    $__ourFileName = array_pop( explode( DIRECTORY_SEPARATOR, $internalFile->output_filename ) );
                 $_tmpRealPath = str_replace(array(" ", " "), "_", $realPath);
                 if ($internalFile->output_filename == $_tmpRealPath) {
                     $zip->deleteName($realPath);
                     if (FilesStorage::pathinfo_fix($realPath, PATHINFO_EXTENSION) == 'pdf') {
                         $realPath .= '.docx';
                     }
                     $zip->addFromString($realPath, $internalFile->getContent());
                 }
             }
         }
         $zip->close();
     }
     return $tmpFName;
 }