/**
  * @static
  * @return TranslatorStatistic
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
 /**
  * Commit modified files.
  */
 public function vcsCommit()
 {
     $am = AccountManager::getInstance();
     $rm = RepositoryManager::getInstance();
     if (!$am->isLogged()) {
         return JsonResponseBuilder::failure();
     }
     if (!$am->haveKarma) {
         return JsonResponseBuilder::failure();
     }
     $patchID = $this->getRequestVariable('patchID');
     $nodes = $this->getRequestVariable('nodes');
     $logMessage = stripslashes($this->getRequestVariable('logMessage'));
     $anode = json_decode(stripslashes($nodes));
     $commitResponse = $tmp = '';
     // We create a lock for this commit process
     $lock = new LockFile('project_' . $am->project . '_lock_' . $am->vcsLogin . '_commit');
     if ($lock->lock()) {
         $tmp = $rm->commitChanges($anode, $logMessage);
         $commitResponse = $tmp['commitResponse'];
         $anode = $tmp['anode'];
         $err = $tmp['err'];
         // Store the response into session to display later
         $_SESSION['commitResponse'] = $commitResponse;
         if (0 == $err) {
             // Start all process after the VCS commit (related to db changes)
             $nodes = RepositoryFetcher::getInstance()->getModifiesById($anode);
             // We need to provide a different treatment regarding the file's type...
             $existFiles = array();
             // Can be an updated file or a new file
             $deleteFiles = array();
             $j = 0;
             for ($i = 0; $i < count($nodes); $i++) {
                 if ($nodes[$i]['type'] == 'update' || $nodes[$i]['type'] == 'new') {
                     $existFiles[] = new File($nodes[$i]['lang'], $nodes[$i]['path'] . $nodes[$i]['name']);
                 }
                 if ($nodes[$i]['type'] == 'delete') {
                     $deleteFiles[$j]->lang = $nodes[$i]['lang'];
                     $deleteFiles[$j]->path = $nodes[$i]['path'];
                     $deleteFiles[$j]->name = $nodes[$i]['name'];
                     $j++;
                 }
             }
             // ... for existing Files (new or update)
             if (!empty($existFiles)) {
                 // Update revision & reviewed for all this files (LANG & EN)
                 $rm->updateFileInfo($existFiles);
                 // Remove all this files in work
                 $rm->delWork($existFiles);
             }
             // End of $existFiles stuff
             // ... for deleted Files
             if (!empty($deleteFiles)) {
                 // Remove this files from db
                 $rm->delFiles($deleteFiles);
                 // Remove all this files in work tables
                 $rm->delWork($deleteFiles);
             }
             // End of $deleteFiles stuff
             // We re-compute summary statistics for the global documentation & by translators
             $lang = AccountManager::getInstance()->vcsLang;
             $rm->updateTranslatorInfo();
             TranslationStatistic::getInstance()->computeSummary($lang);
             TranslatorStatistic::getInstance()->computeSummary($lang);
         }
     }
     // Manage log message (add new or ignore it if this message already exist for this user)
     LogManager::getInstance()->addCommitLog($logMessage);
     // We send an email only if this commit is from a patch
     if ($patchID) {
         $rm->postPatchCommit($patchID);
     }
     // Remove the lock File
     $lock->release();
     return JsonResponseBuilder::success(array('mess' => $commitResponse));
 }
        $lock->writeIntoLock('checkErrors');
        // Start checkErrors
        $rm->applyOnlyTools();
        // Write into the lock the update position
        $lock->writeIntoLock('notInEN');
        // Search for NotInEN Old Files
        $rm->updateNotInEN();
        // Write into the lock the update position
        $lock->writeIntoLock('updateTranslatorInfo');
        // Parse translators
        $rm->updateTranslatorInfo();
        // Write into the lock the update position
        $lock->writeIntoLock('ComputeAllStatistics');
        // Compute all summary
        TranslationStatistic::getInstance()->computeSummary('all');
        TranslatorStatistic::getInstance()->computeSummary('all');
        if ($project['code'] == 'php') {
            // Write into the lock the update position
            $lock->writeIntoLock('StaticRevcheck');
            $rm->applyStaticRevcheck();
        }
        // Store this update info
        $info = array();
        $info['user'] = '******';
        $rm->setStaticValue('info', 'updateData', json_encode($info), true);
        $lock->release();
    } else {
        echo 'Update in progress, can\'t do this action until the first finish' . PHP_EOL;
        continue;
    }
}