/**
  * @static
  * @return RepositoryManager
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Example #2
0
 public static function patchDiff($patchId)
 {
     $output = array();
     $patchFiles = RepositoryManager::getInstance()->getPatchFilesByID($patchId);
     foreach ($patchFiles as $patchFile) {
         $patchFile = new File($patchFile->lang, $patchFile->path . $patchFile->name);
         // file delimeter
         $output[] = 'Index: ' . $patchFile->lang . $patchFile->path . $patchFile->name;
         $output = array_merge($output, $patchFile->diff());
     }
     return $output;
 }
<?php

/***
* This script is intended to be placed in a cronjob.
* It must be run every Thursday, at 01hOO for example.
* On Unix, you can use crontab -e and place this :
* 00 01 * * 4 /path/php/binary /path/to/your/vcs/dir/doc-editor/scripts/cron/check_entities.php
****/
require_once dirname(__FILE__) . '/../../php/Conf.php';
require_once dirname(__FILE__) . '/../../php/LockFile.php';
require_once dirname(__FILE__) . '/../../php/ProjectManager.php';
require_once dirname(__FILE__) . '/../../php/RepositoryManager.php';
require_once dirname(__FILE__) . '/../../php/ToolsCheckEntities.php';
$rm = RepositoryManager::getInstance();
$pm = ProjectManager::getInstance();
$availableProject = $pm->getAvailableProject();
while (list($key, $project) = each($availableProject)) {
    if ($project['code'] != "php") {
        continue;
    }
    // Define it as a project
    $pm->setProject($project['code']);
    $lock = new LockFile('project_' . $project['code'] . '_lock_check_entities');
    if ($lock->lock()) {
        ToolsCheckEntities::getInstance()->startCheck();
        // Set lastUpdate date/time
        $info = array();
        $info['user'] = '******';
        $rm->setStaticValue('info', 'checkEntities', json_encode($info), true);
    }
    // Remove the lock File
 /**
  * 
  */
 public function setDirectAction()
 {
     $am = AccountManager::getInstance();
     if (!$am->isLogged()) {
         return JsonResponseBuilder::failure();
     }
     $action = $this->getRequestVariable('action');
     $patchID = $this->getRequestVariable('patchID');
     $idDB = $this->getRequestVariable('idDB');
     if ($action == 'putIntoMyPatches') {
         $r = RepositoryManager::getInstance()->moveToPatch($patchID, $idDB);
         if ($r === true) {
             return JsonResponseBuilder::success();
         } else {
             return JsonResponseBuilder::failure(array('err' => $r));
         }
     }
     if ($action == 'deleteThisChange') {
         $r = RepositoryManager::getInstance()->clearLocalChangeByModifiedID($idDB);
         if (is_array($r)) {
             return JsonResponseBuilder::success();
         } else {
             return JsonResponseBuilder::failure(array('err' => $r));
         }
     }
 }
 /**
  * Add a new Repository Manager
  * 
  * @param RepositoryManager $manager
  * @return void
  * @access public
  * @since 10/4/07
  */
 public function addManager(RepositoryManager $manager)
 {
     if (isset($this->context)) {
         $manager->assignOsidContext($this->context);
     }
     $this->managers[] = $manager;
 }
Example #6
0
 /**
  * Обновляет информацию о пакетах в известных репозиториях.
  *
  * Прокси метод вызывающий pm repository update
  */
 function cmdUpdate()
 {
     require_once 'commands/repository/RepositoryManager.php';
     $rm = new RepositoryManager('.', array('name' => 'repository', $this->commandsSeq));
     return $rm->cmdUpdate();
 }
 private function updateKarmaList()
 {
     $am = AccountManager::getInstance();
     $appConf = $am->appConf;
     $project = $am->project;
     $file = @file($appConf[$project]['vcs.karma.file']);
     $line_avail = array();
     $user = array();
     // We cleanUp the content of this file
     for ($i = 0; $i < count($file); $i++) {
         if (substr($file[$i], 0, 6) == 'avail|') {
             $line_avail[] = $file[$i];
             $t = explode("|", $file[$i]);
             $users = trim($t[1]);
             $karmas = isset($t[2]) ? trim($t[2]) : 'ALL';
             $users = explode(",", $users);
             $karmas = explode(",", $karmas);
             for ($j = 0; $j < count($users); $j++) {
                 if (isset($user[$users[$j]])) {
                     $user[$users[$j]]['karma'] = array_merge($karmas, $user[$users[$j]]['karma']);
                 } else {
                     $user[$users[$j]]['karma'] = $karmas;
                 }
             }
         }
     }
     // We store this value into DB as json string to retrieve it later
     $to_store = array("update_time" => time(), "data" => $user);
     RepositoryManager::setStaticValue('karma_list', '', json_encode($to_store));
 }
Example #8
0
     require_once dirname(__FILE__) . '/php/ProjectManager.php';
     // Set the project
     ProjectManager::getInstance()->setProject($_project);
     $_patch = explode('/', $patch);
     $fileName = $_patch[count($_patch) - 1];
     $filePath = substr($patch, 0, strlen($patch) - strlen($fileName));
     $jsVar = "\n" . 'var directAccess = {"link":"patch", "lang":"en", "path":"' . htmlspecialchars($filePath) . '", "name":"' . htmlspecialchars($fileName) . '", "project":"' . htmlspecialchars($_project) . '"},';
 } else {
     if (isset($_REQUEST['patchID'])) {
         $patchID = trim($_REQUEST['patchID'], '/ ');
         $_project = $_REQUEST['project'];
         require_once dirname(__FILE__) . '/php/ProjectManager.php';
         require_once dirname(__FILE__) . '/php/RepositoryManager.php';
         // Set the project
         ProjectManager::getInstance()->setProject($_project);
         $patchInfo = RepositoryManager::getInstance()->getPatchInfo($patchID);
         $jsVar = "\n" . 'var directAccess = {"link":"patchID", "lang":"en", "patchID":"' . htmlspecialchars($patchID) . '", "patchName":"' . htmlspecialchars($patchInfo->name) . '", "project":"' . htmlspecialchars($_project) . '"},';
     } else {
         if (isset($_REQUEST['action'])) {
             $_project = $_REQUEST['project'];
             $_action = $_REQUEST['action'];
             $_idDB = $_REQUEST['idDB'];
             require_once dirname(__FILE__) . '/php/ProjectManager.php';
             // Set the project
             ProjectManager::getInstance()->setProject($_project);
             $jsVar = "\n" . 'var directAccess = {
     "project":"' . htmlspecialchars($_project) . '",
     "action": "' . htmlspecialchars($_action) . '",
     "idDB": "' . htmlspecialchars($_idDB) . '"
 },';
         } else {
 /**
  * Compute summary of translation statistic and store it into DB
  *
  * @param $lang Can be either 'all' for all availables languages, or one specific language
  */
 public function computeSummary($lang = 'all')
 {
     $rm = RepositoryManager::getInstance();
     $nbFiles = $this->getFileCount($lang);
     $uptodate = $this->getTransFileCount($lang);
     $stale = $this->getStaleFileCount($lang);
     $missFiles = $this->getNoTransFileCount($lang);
     if ($lang == 'all') {
         $hereLang = $rm->getExistingLanguage();
     } else {
         $hereLang = array(0 => array("code" => $lang));
     }
     foreach ($hereLang as $lang) {
         $lang = $lang["code"];
         if ($lang == 'en') {
             continue;
         }
         $summary = array();
         $summary[0]['id'] = 1;
         $summary[0]['libel'] = 'Up to date files';
         $summary[0]['nbFiles'] = isset($uptodate[$lang]['total']) ? $uptodate[$lang]['total'] : 0;
         $summary[0]['percentFiles'] = isset($uptodate[$lang]['total']) ? round($uptodate[$lang]['total'] * 100 / $nbFiles[$lang]['total'], 2) : 0;
         $summary[0]['sizeFiles'] = !isset($uptodate[$lang]['total_size']) ? 0 : $uptodate[$lang]['total_size'];
         $summary[0]['percentSize'] = !isset($uptodate[$lang]['total_size']) ? 0 : round($uptodate[$lang]['total_size'] * 100 / $nbFiles[$lang]['total_size'], 2);
         $summary[1]['id'] = 2;
         $summary[1]['libel'] = 'Stale files';
         $summary[1]['nbFiles'] = isset($stale[$lang]['total']) ? $stale[$lang]['total'] : 0;
         $summary[1]['percentFiles'] = !isset($nbFiles[$lang]['total']) || !isset($stale[$lang]['total']) || $nbFiles[$lang]['total'] == 0 ? 0 : round($stale[$lang]['total'] * 100 / $nbFiles[$lang]['total'], 2);
         $summary[1]['sizeFiles'] = !isset($stale[$lang]['total_size']) || $stale[$lang]['total_size'] == '' ? 0 : $stale[$lang]['total_size'];
         $summary[1]['percentSize'] = !isset($stale[$lang]['total_size']) || $stale[$lang]['total_size'] == 0 ? 0 : round($stale[$lang]['total_size'] * 100 / $nbFiles[$lang]['total_size'], 2);
         $summary[2]['id'] = 3;
         $summary[2]['libel'] = 'Files available for translation';
         $summary[2]['nbFiles'] = isset($missFiles[$lang]['total']) ? $missFiles[$lang]['total'] : 0;
         $summary[2]['percentFiles'] = isset($missFiles[$lang]['total']) ? round($missFiles[$lang]['total'] * 100 / $nbFiles[$lang]['total'], 2) : 0;
         $summary[2]['sizeFiles'] = isset($missFiles[$lang]['total_size']) ? $missFiles[$lang]['total_size'] : 0;
         $summary[2]['percentSize'] = !isset($missFiles[$lang]['total_size']) || $missFiles[$lang]['total_size'] == 0 || $nbFiles[$lang]['total_size'] == 0 ? 0 : round($missFiles[$lang]['total_size'] * 100 / $nbFiles[$lang]['total_size'], 2);
         $summary[3]['id'] = 4;
         $summary[3]['libel'] = 'Total';
         $summary[3]['nbFiles'] = isset($nbFiles[$lang]['total']) ? $nbFiles[$lang]['total'] : 0;
         $summary[3]['percentFiles'] = '100%';
         $summary[3]['sizeFiles'] = isset($nbFiles[$lang]['total_size']) ? $nbFiles[$lang]['total_size'] : 0;
         $summary[3]['percentSize'] = '100%';
         // Save $summary into DB
         $rm->setStaticValue('translation_summary', $lang, json_encode($summary));
     }
 }
 /**
  * Compute statistics summary about translators and store it into DB
  *
  * @param $lang Can be either 'all' for all availables languages, or one specific language
  */
 public function computeSummary($lang = 'all')
 {
     $rm = RepositoryManager::getInstance();
     $translators = $this->getTranslators($lang);
     $uptodate = $this->getUptodateFileCount($lang);
     $stale = $this->getStaleFileCount($lang);
     $reviewedUptodate = $this->getReviewedUptodateFileCount($lang);
     $reviewedStale = $this->getReviewedStaleFileCount($lang);
     if ($lang == 'all') {
         $hereLang = $rm->getExistingLanguage();
     } else {
         $hereLang = array(0 => array("code" => $lang));
     }
     foreach ($hereLang as $lang) {
         $lang = $lang["code"];
         if ($lang == 'en') {
             continue;
         }
         $i = 0;
         $persons = array();
         if (isset($translators[$lang])) {
             foreach ($translators[$lang] as $nick => $data) {
                 $persons[$i] = $data;
                 $persons[$i]['nick'] = $nick;
                 $persons[$i]['uptodate'] = isset($uptodate[$lang][$nick]) ? $uptodate[$lang][$nick] : '0';
                 $persons[$i]['stale'] = isset($stale[$lang][$nick]) ? $stale[$lang][$nick] : '0';
                 $persons[$i]['sum'] = $persons[$i]['uptodate'] + $persons[$i]['stale'];
                 $persons[$i]['reviewedUptodate'] = isset($reviewedUptodate[$lang][$nick]) ? $reviewedUptodate[$lang][$nick] : '0';
                 $persons[$i]['reviewedStale'] = isset($reviewedStale[$lang][$nick]) ? $reviewedStale[$lang][$nick] : '0';
                 $persons[$i]['reviewedSum'] = $persons[$i]['reviewedUptodate'] + $persons[$i]['reviewedStale'];
                 $i++;
             }
             // Save $summary into DB
             $rm->setStaticValue('translator_summary', $lang, json_encode($persons));
         }
     }
 }