2021-11-26 15:05:38 +01:00
|
|
|
<?php
|
|
|
|
|
2022-07-03 02:25:01 +02:00
|
|
|
class LefInternet {
|
|
|
|
|
|
|
|
private $internet_id;
|
|
|
|
private $code = "internet";
|
|
|
|
private $evenementArray = array();
|
|
|
|
|
|
|
|
public function __construct($json_region) {
|
|
|
|
$this->pays_id = $json_region["id"];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function populate( $evenementParRegionMap) {
|
|
|
|
$pays_key = "id_".$this->pays_id;
|
|
|
|
if (array_key_exists($pays_key, $evenementParRegionMap)) {
|
|
|
|
$this->evenementArray = $evenementParRegionMap[$pays_key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toArray() {
|
|
|
|
|
|
|
|
return array("evenements" => $this->evenementArray, "total" => count($this->evenementArray));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-11-26 15:05:38 +01:00
|
|
|
class LefPays {
|
|
|
|
private $pays_id;
|
|
|
|
private $name = "";
|
|
|
|
private $code = "";
|
|
|
|
private $regions = array();
|
|
|
|
private $total_pays = 0;
|
|
|
|
private $lieuxnationaux;
|
|
|
|
private $key_array = array();
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct($json_region) {
|
|
|
|
$this->pays_id = $json_region["id"];
|
|
|
|
$this->code = $json_region["code"];
|
|
|
|
$this->name = $json_region["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function populate($json_regions, $evenementParRegionMap) {
|
|
|
|
$pays_key = "id_".$this->pays_id;
|
|
|
|
$this->key_array[] = $pays_key;
|
|
|
|
if (array_key_exists($pays_key, $evenementParRegionMap)) {
|
|
|
|
$evenementNationalArray = $evenementParRegionMap[$pays_key];
|
|
|
|
$total_national = count($evenementNationalArray);
|
|
|
|
$this->total_pays += $total_national;
|
|
|
|
$this->lieuxnationaux = new LefLieux($evenementNationalArray);
|
|
|
|
}
|
|
|
|
foreach($json_regions as $region) {
|
|
|
|
if ($region["region_id"] == $this->pays_id) {
|
|
|
|
$region_key = "id_".$region["id"];
|
|
|
|
$this->key_array[] = $region_key;
|
|
|
|
if (array_key_exists($region_key, $evenementParRegionMap)) {
|
|
|
|
$evenementParRegionArray = $evenementParRegionMap[$region_key];
|
|
|
|
$total_region = count($evenementParRegionArray);
|
|
|
|
$lieux = new LefLieux($evenementParRegionArray);
|
|
|
|
$region["evenements"] = $lieux->toArray();
|
|
|
|
$this->total_pays += $total_region;
|
|
|
|
$this->regions[] = $region;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTotal() {
|
|
|
|
return $this->total_pays;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getKeyArray() {
|
|
|
|
return $this->key_array;
|
|
|
|
}
|
|
|
|
|
2022-07-03 02:25:01 +02:00
|
|
|
public function getCode() {
|
|
|
|
return $this->code;
|
|
|
|
}
|
|
|
|
|
2021-11-26 15:05:38 +01:00
|
|
|
public function toArray() {
|
|
|
|
$evenementsnationaux;
|
2021-12-08 18:40:29 +01:00
|
|
|
$totalevenementsnationaux = 0;
|
2021-11-26 15:05:38 +01:00
|
|
|
if ($this->lieuxnationaux) {
|
|
|
|
$evenementsnationaux = $this->lieuxnationaux->toArray();
|
2021-12-08 18:40:29 +01:00
|
|
|
foreach($evenementsnationaux as $key => $array) {
|
|
|
|
$totalevenementsnationaux = $totalevenementsnationaux + count($array);
|
|
|
|
}
|
2021-11-26 15:05:38 +01:00
|
|
|
} else {
|
|
|
|
$evenementsnationaux = array();
|
|
|
|
}
|
2021-12-08 18:40:29 +01:00
|
|
|
return array("name" => $this->name, "code" => $this->code, "sousregions" => $this->regions, "evenementsnationaux" => $evenementsnationaux, "totalevenementsnationaux" => $totalevenementsnationaux);
|
2021-11-26 15:05:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class LefLieux {
|
|
|
|
|
|
|
|
public $lieux = array();
|
|
|
|
|
|
|
|
public function __construct($evenementArray) {
|
|
|
|
foreach($evenementArray as $evenement) {
|
|
|
|
$city = $evenement["city"];
|
|
|
|
if (!$city) {
|
|
|
|
$city = "";
|
|
|
|
}
|
|
|
|
$lieu = null;
|
|
|
|
if (array_key_exists($city, $this->lieux)) {
|
|
|
|
$lieu = $this->lieux[$city];
|
|
|
|
} else {
|
|
|
|
$lieu = new LefLieu($city);
|
|
|
|
$this->lieux[$city] = $lieu;
|
|
|
|
}
|
|
|
|
$lieu->addEvenement($evenement);
|
|
|
|
}
|
|
|
|
ksort($this->lieux);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toArray() {
|
|
|
|
$result = array();
|
|
|
|
foreach($this->lieux as $key => $lieu) {
|
|
|
|
$result[$lieu->name] = $lieu->evenementArray;
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class LefLieu {
|
|
|
|
|
|
|
|
public $name = "";
|
|
|
|
public $evenementArray = array();
|
|
|
|
|
|
|
|
public function __construct($name) {
|
|
|
|
$this->name = $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addEvenement($evenement) {
|
|
|
|
$this->evenementArray[] = $evenement;
|
|
|
|
}
|
|
|
|
}
|