public function doAction() { if (empty($this->id_project)) { $this->api_output['message'] = array(-1, "No id project provided"); return -1; } $_project_data = getProjectJobData($this->id_project); $passCheck = new AjaxPasswordCheck(); $access = $passCheck->grantProjectAccess($_project_data, $this->ppassword) || $passCheck->grantProjectJobAccessOnJobPass($_project_data, null, $this->jpassword); if (!$access) { $this->api_output['message'] = array(-10, "Wrong Password. Access denied"); return -1; } $analysisStatus = new Analysis_APIStatus($_project_data); $this->api_output = $analysisStatus->fetchData()->getResult(); }
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; }