public function getResult() { parent::getResult(); if ($this->result['errors']) { return $this->formatErrors(); } $outputContent = array(); /** * Every target language will be put in a separated txt file. * * Each row of this cycle is a target language, * * Every target language file will contain a report for single file and the total for the job. * */ foreach ($this->result['data']['jobs'] as $idJob => $chunksContainer) { foreach ($chunksContainer['chunks'] as $password => $filesContainer) { list($source, $target) = explode("|", $this->result['jobs']['langpairs'][$idJob . "-" . $password]); $outputContent[$idJob . "-" . $password] = null; foreach ($filesContainer as $idFile => $values) { $vector = array(); $vector['firstLine'] = str_pad("File: ", 23, " ", STR_PAD_RIGHT) . $idFile . "_" . $values['FILENAME']; $vector['source'] = $source; $vector['target'] = $target; $outputContent[$idJob . "-" . $password] .= $this->formatFile($values, $vector); } $outputContent[$idJob . "-" . $password] .= str_repeat("-", 80) . PHP_EOL . PHP_EOL; } foreach ($chunksContainer['totals'] as $password => $jobResume) { list($source, $target) = explode("|", $this->result['jobs']['langpairs'][$idJob . "-" . $password]); $vector = array(); $vector['firstLine'] = str_pad("Total: ", 23, " ", STR_PAD_RIGHT) . count($chunksContainer['chunks'][$password]) . " files"; $vector['source'] = $source; $vector['target'] = $target; $outputContent[$idJob . "-" . $password] .= $this->formatFile($chunksContainer['totals'][$password], $vector); } } return $outputContent; }