Exemplo n.º 1
0
 public function checkForError($xmlContent)
 {
     $am = AccountManager::getInstance();
     $appConf = $am->appConf;
     $project = $am->project;
     $this->xmlContent = $xmlContent;
     $this->saveInTmpFile();
     $this->XmlFileResult = tempnam(sys_get_temp_dir(), 'PhDOE_' . mt_rand());
     $cmd = new ExecStatement($appConf['GLOBAL_CONFIGURATION']['xmllint.bin'] . ' --noout %s > %s 2>&1', array($this->XmlFileName, $this->XmlFileResult));
     $trial_threshold = 3;
     while ($trial_threshold-- > 0) {
         $output = array();
         SaferExec::exec($cmd, $output);
         if (strlen(trim(implode('', $output))) != 0) {
             break;
         }
     }
     $this->rawErrors = file($this->XmlFileResult);
     $this->Errors = $this->parseResult();
     return $this->Errors;
 }
Exemplo n.º 2
0
 /**
  */
 private function makePreview()
 {
     $appConf = $this->am->appConf;
     $project = $this->am->project;
     $this->checkDir();
     // We clean the input output directory
     $commands = array(new ExecStatement('cd %s', array($this->outputDir)), new ExecStatement('rm -R *'));
     SaferExec::execMulti($commands, $output);
     $this->cleanCmd = implode('; ', $commands);
     $this->cleanLog = $output;
     $rename = 0;
     $t = time();
     // We are editing temporary file
     if (file_exists($this->fullNewPath)) {
         $rename = 1;
         rename($this->fullPath, $this->fullPath . $t);
         rename($this->fullNewPath, $this->fullPath);
     }
     // We start the build for this file
     $commands = array(new ExecStatement('cd %s', array($appConf[$project]['vcs.path'])), new ExecStatement($appConf['GLOBAL_CONFIGURATION']['php.bin'] . ' doc-base/configure.php --with-php=%s --generate=%s', array($appConf['GLOBAL_CONFIGURATION']['php.bin'], $this->path)), new ExecStatement($appConf['GLOBAL_CONFIGURATION']['phd.bin'] . ' --package PHP --format php --memoryindex -d doc-base/.manual.xml --output %s', array($this->outputDir)));
     SaferExec::execMulti($commands, $output);
     $this->buildCmd = implode('; ', $commands);
     $this->buildLog = $output;
     // Rename it back
     if ($rename) {
         rename($this->fullPath, $this->fullNewPath);
         rename($this->fullPath . $t, $this->fullPath);
     }
     // Only move the specific file we are generating
     $xmlID = $this->getOutputId();
     $filename = 'phdoe-' . time() . '-' . $xmlID . '.php';
     $cmd = new ExecStatement('mv %s %s', array($this->outputDir . 'php-web/' . $xmlID . '.php', $this->inputDir . $filename));
     SaferExec::exec($cmd, $output);
     $this->moveCmd = $cmd->__toString();
     $this->moveLog = $output;
     $this->previewUrl = $this->am->appConf[$this->am->project]['preview.baseURI'] . 'manual/en/' . $filename;
 }