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;
 }
 /**
  */
 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;
 }
Beispiel #3
0
 public function diff($optNbLine = 3, $optB = false, $optW = false)
 {
     // $optNbLine need to be an integer, >= 3
     $optNbLine = (int) $optNbLine;
     if ($optNbLine < 3) {
         $optNbLine = 3;
     }
     // $optB & $optW need to be a boolean
     $optB = $optB == 'true' ? true : false;
     $optW = $optW == 'true' ? true : false;
     $_optB = $optB == 'true' ? ' -b' : '';
     $_optW = $optW == 'true' ? ' -w' : '';
     /* Diff option (from man page) :
      * U : output NUM (default 3) lines of unified context
      * 
      * N : treat absent files as empty
      * 
      * b : ignore changes in the amount of white space
      * Ne pas tenir compte des différences concernant des espaces blancs.
      * 
      * w : ignore all white space
      * Ignorer les espaces blancs lors de la comparaison de lignes.
      * 
      */
     $commands = array(new ExecStatement('diff -uN -U ' . $optNbLine . ' ' . $_optB . $_optW . ' --label %s --label %s %s %s', array($this->lang . $this->path . $this->name, $this->lang . $this->path . $this->name, $this->full_path, $this->full_new_path)));
     $trial_threshold = 3;
     while ($trial_threshold-- > 0) {
         $output = array();
         SaferExec::execMulti($commands, $output);
         if (strlen(trim(implode('', $output))) != 0) {
             break;
         }
     }
     return $output;
 }
 public function applyStaticRevcheck()
 {
     $am = AccountManager::getInstance();
     $appConf = $am->appConf;
     $project = $am->project;
     $ExistingLanguage = $this->getExistingLanguage();
     foreach ($ExistingLanguage as $lang) {
         $lang = $lang["code"];
         if ($lang == 'en') {
             continue;
         }
         $commands = array(new ExecStatement('cd %s', array($appConf[$project]['vcs.path'])), new ExecStatement($appConf['GLOBAL_CONFIGURATION']['php.bin'] . ' doc-base/scripts/revcheck.php %s > %s 2>&1', array($lang, $appConf['GLOBAL_CONFIGURATION']['data.path'] . 'revcheck/' . $lang . '.html')));
         SaferExec::execMulti($commands);
     }
 }
 /**
  * Executes cvs commit
  *
  * @param $log Commit log
  * @param $create Array of files to be created
  * @param $update Array of files to be updated
  * @param $delete Array of files to be deleted
  * @return Array of stdout of cvs commit
  */
 public function commit($log, $create = false, $update = false, $delete = false)
 {
     $am = AccountManager::getInstance();
     $appConf = $am->appConf;
     $project = $am->project;
     $create_stack = array();
     for ($i = 0; $create && $i < count($create); $i++) {
         $create_stack[] = $create[$i]->lang . '/' . $create[$i]->path . '/' . $create[$i]->name;
     }
     $update_stack = array();
     for ($i = 0; $update && $i < count($update); $i++) {
         $p = $update[$i]->lang . '/' . $update[$i]->path . '/' . $update[$i]->name;
         $update_stack[] = $p;
         @copy($appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $p, $appConf[$project]['vcs.path'] . $p);
         @unlink($appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $p);
     }
     $delete_stack = array();
     for ($i = 0; $delete && $i < count($delete); $i++) {
         $delete_stack[] = $delete[$i]->lang . '/' . $delete[$i]->path . '/' . $delete[$i]->name;
     }
     // Buil the command line
     $cvsLogin = AccountManager::getInstance()->vcsLogin;
     $cvsPasswd = AccountManager::getInstance()->vcsPasswd;
     $commands = array(new ExecStatement('export CVS_PASSFILE=%s', array(realpath($appConf['GLOBAL_CONFIGURATION']['data.path']) . '/.cvspass')), new ExecStatement('cd %s', array($appConf[$project]['vcs.path'])), new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository login'));
     if (!empty($delete_stack)) {
         $commands[] = new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository -f remove -f' . str_repeat(' %s', count($delete_stack)), array($delete_stack));
     }
     if (!empty($create_stack)) {
         $commands[] = new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository -f add' . str_repeat(' %s', count($create_stack)), array($create_stack));
     }
     $args = array_merge(array($log), $create_stack, $update_stack, $delete_stack);
     $commands[] = new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository -f commit -l -m %s' . str_repeat(' %s', count($create_stack) + count($update_stack) + count($delete_stack)), $args);
     $output = array();
     SaferExec::execMulti($commands, $output);
     return $output;
 }