|
@@ -14,6 +14,7 @@ class PostHandler
|
14
|
14
|
private $dao;
|
15
|
15
|
private $uploadBaseDir = '../uploaded_images/';
|
16
|
16
|
private $stockFile = "../data/stock-v2.json";
|
|
17
|
+ private $imageBaseUrl = "https://etud.insa-toulouse.fr/~proximo/uploaded_images/";
|
17
|
18
|
|
18
|
19
|
private $responseArray = array(
|
19
|
20
|
"status" => 0,
|
|
@@ -66,7 +67,7 @@ class PostHandler
|
66
|
67
|
$fp = fopen($this->stockFile, "w");
|
67
|
68
|
$array = array(
|
68
|
69
|
"types" => $this->dao->get_categories(),
|
69
|
|
- "articles" => $this->dao->get_articles(),
|
|
70
|
+ "articles" => $this->get_articles_json_list(),
|
70
|
71
|
);
|
71
|
72
|
fwrite($fp, json_encode($array));
|
72
|
73
|
fclose($fp);
|
|
@@ -75,6 +76,19 @@ class PostHandler
|
75
|
76
|
return $this->responseArray;
|
76
|
77
|
}
|
77
|
78
|
|
|
79
|
+ public function get_articles_json_list()
|
|
80
|
+ {
|
|
81
|
+ $articles = $this->dao->get_articles();
|
|
82
|
+ $formatted_articles = [];
|
|
83
|
+ foreach ($articles as $article) {
|
|
84
|
+ $article["type"] = $this->dao->get_categories_of_article($article["id"]);
|
|
85
|
+ $article["image"] = $this->imageBaseUrl . $article["id"] . ".jpg";
|
|
86
|
+ array_push($formatted_articles, $article);
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ return $formatted_articles;
|
|
90
|
+ }
|
|
91
|
+
|
78
|
92
|
private function save_image()
|
79
|
93
|
{
|
80
|
94
|
$success = true;
|