/**
  * @static
  * @return ToolsCheckEntities
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
/***
* 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
    $lock->release();
}
 /**
  * Get data about the CheckEntities's tools (ToolsCheckEntities's class).
  */
 public function getCheckEntitiesData()
 {
     if (!AccountManager::getInstance()->isLogged()) {
         return JsonResponseBuilder::failure();
     }
     $ToolsCheckEntities = new ToolsCheckEntities();
     $r = $ToolsCheckEntities->getData();
     return JsonResponseBuilder::success(array('nbItems' => $r['nb'], 'Items' => $r['node']));
 }
require_once dirname(__FILE__) . '/../../php/Conf.php';
require_once dirname(__FILE__) . '/../../php/AccountManager.php';
require_once dirname(__FILE__) . '/../../php/LogManager.php';
require_once dirname(__FILE__) . '/../../php/ProjectManager.php';
require_once dirname(__FILE__) . '/../../php/ToolsCheckEntities.php';
$pm = ProjectManager::getInstance();
$availableProject = $pm->getAvailableProject();
while (list($key, $project) = each($availableProject)) {
    // Actually, only PHP project support to be automatically checked for the build. Skip all others projects
    if ($project['code'] != "php") {
        continue;
    }
    echo "enter into " . $project['code'] . "\n";
    // Define it as a project
    $pm->setProject($project['code']);
    $ToolsCheckEntities = new ToolsCheckEntities();
    $r = $ToolsCheckEntities->getData();
    // We kip only UNKNOW_HOST & HTTP_NOT_FOUND
    $result['UNKNOWN_HOST'] = array();
    $result['HTTP_NOT_FOUND'] = array();
    for ($i = 0; $i < count($r['node']); $i++) {
        if ($r['node'][$i]['result'] == 'UNKNOWN_HOST') {
            $result['UNKNOWN_HOST'][] = $r['node'][$i];
        }
        if ($r['node'][$i]['result'] == 'HTTP_NOT_FOUND') {
            $result['HTTP_NOT_FOUND'][] = $r['node'][$i];
        }
    }
    echo "Is there some entities to send to the list ?\n";
    if (count($result['UNKNOWN_HOST']) > 0 || count($result['HTTP_NOT_FOUND']) > 0) {
        $msg = "Hello PHP Documentation team,\n\nBelow is a list of URL entities that are experiencing fatal errors:\n\n";