public function doAction() { //get storage object $fs = new FilesStorage(); $files_job = $fs->getOriginalFilesForJob($this->id_job, $this->id_file, $this->password); $output_content = array(); foreach ($files_job as $file) { $id_file = $file['id_file']; $output_content[$id_file]['filename'] = $file['filename']; $output_content[$id_file]['contentPath'] = $file['originalFilePath']; } if ($this->download_type == 'all') { if (count($output_content) > 1) { $this->_filename = $this->fname; $pathinfo = pathinfo($this->fname); if ($pathinfo['extension'] != 'zip') { $this->_filename = $pathinfo['basename'] . ".zip"; } $this->content = $this->composeZip($output_content); //add zip archive content here; } elseif (count($output_content) == 1) { $this->setContent($output_content); } } else { $this->setContent($output_content); } }
public function doAction() { //get storage object $fs = new FilesStorage(); $files_job = $fs->getOriginalFilesForJob($this->id_job, $this->id_file, $this->password); //take the project ID and creation date, array index zero is good, all id are equals $this->id_project = $files_job[0]['id_project']; $this->project_date = $files_job[0]['create_date']; $output_content = array(); foreach ($files_job as $file) { $id_file = $file['id_file']; $zipPathInfo = ZipArchiveExtended::zipPathInfo($file['filename']); if (is_array($zipPathInfo)) { $output_content[$id_file]['output_filename'] = $zipPathInfo['zipfilename']; $output_content[$id_file]['input_filename'] = $fs->getOriginalZipPath($this->project_date, $this->id_project, $zipPathInfo['zipfilename']); } else { $output_content[$id_file]['output_filename'] = $file['filename']; $output_content[$id_file]['input_filename'] = $file['originalFilePath']; } } /* * get Unique file zip because there are more than one file in the zip * array_unique compares items using a string comparison. * * From the docs: * Note: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. * In words: when the string representation is the same. The first element will be used. */ $output_content = array_map('unserialize', array_unique(array_map('serialize', $output_content))); foreach ($output_content as $key => $iFile) { $output_content[$key] = new ZipContentObject($iFile); } if ($this->download_type == 'all') { if (count($output_content) > 1) { $this->_filename = $this->fname; $pathInfo = FilesStorage::pathinfo_fix($this->fname); if ($pathInfo['extension'] != 'zip') { $this->_filename = $pathInfo['basename'] . ".zip"; } $this->content = self::composeZip($output_content); //add zip archive content here; } elseif (count($output_content) == 1) { $this->setContent($output_content); } } else { $this->setContent($output_content); } }