diff --git a/.idea/projet_programmation_web.iml b/.idea/projet_programmation_web.iml
index d05557a..929d910 100644
--- a/.idea/projet_programmation_web.iml
+++ b/.idea/projet_programmation_web.iml
@@ -6,5 +6,6 @@
+
\ No newline at end of file
diff --git a/ProjetProgWeb/api.php b/ProjetProgWeb/api.php
index b98fb45..d38c3bb 100644
--- a/ProjetProgWeb/api.php
+++ b/ProjetProgWeb/api.php
@@ -24,6 +24,8 @@ $json_object = match ($q) {
"theses" => dump::getTheses($search, $option, $offset),
"suggestion" => dump::getSuggestions($search, $option),
"count" => dump::getThesesCount($search, $option),
+ "years" => dump::getThesesYears($search, $option),
+ "disciplines" => dump::getThesesDisciplines($search, $option),
default => NULL,
};
diff --git a/ProjetProgWeb/app.js b/ProjetProgWeb/app.js
index 1c26646..45e3054 100644
--- a/ProjetProgWeb/app.js
+++ b/ProjetProgWeb/app.js
@@ -66,6 +66,7 @@ function apiRequestThese(search, offset) {
emptyResults(true)
pagesNumbers.innerHTML = ""
loader.style.display = "block"
+ pagesNumbersContainer.style.display = 'none'
searchString = sanitize(search)
fetch(`api.php?q=theses&search=${searchString}&option=${queryOption}&offset=${offset}`)
.then(response => response.json())
@@ -132,7 +133,6 @@ function displayResults(results, aCount) {
error.classList.remove("fade-out");
error.classList.add("fade-in");
errorMessage.innerHTML = results.message
- pagesNumbersContainer.style.display = 'none'
} else if (results.status === 200) {
count = aCount
resultsArray = []
diff --git a/ProjetProgWeb/class/dump.php b/ProjetProgWeb/class/dump.php
index 84f180d..3586ed4 100644
--- a/ProjetProgWeb/class/dump.php
+++ b/ProjetProgWeb/class/dump.php
@@ -49,7 +49,7 @@ class dump {
while ($obj = $stmt->fetchObject()) {
$theses_array[$i] = array();
foreach ($obj as $elem) {
- array_push($theses_array[$i], empty($elem) ? "Non définit" : $elem);
+ $theses_array[$i][] = empty($elem) ? "Non définit" : $elem;
}
$i++;
}
@@ -81,7 +81,7 @@ class dump {
while ($obj = $stmt->fetchObject()) {
foreach ($obj as $elem) {
- array_push($array, $elem);
+ $array[] = $elem;
}
}
@@ -116,13 +116,94 @@ class dump {
while ($obj = $stmt->fetchObject()) {
foreach ($obj as $elem) {
- array_push($array, $elem);
+ $array[] = $elem;
}
}
return $array;
}
+ public static function getThesesYears(string $search, string $option) : array {
+ $years_array = [];
+
+ $pdo_obj = new conf();
+ $pdo = $pdo_obj->getPDO();
+
+ $search = '%' . $search . '%';
+
+ $stmt = match ($option) {
+ 'auto' => $pdo->prepare("
+ SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date,
+ COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number
+ FROM `theses`
+ WHERE author LIKE :search
+ OR title LIKE :search
+ OR these_director LIKE :search
+ OR soutenance_establishment LIKE :search
+ GROUP BY Date
+ ORDER BY Date;
+ "),
+ 'author' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE author LIKE :search GROUP BY Date ORDER BY Date;"),
+ 'title' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE title LIKE :search GROUP BY Date ORDER BY Date;"),
+ 'director' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE these_director LIKE :search GROUP BY Date ORDER BY Date;"),
+ 'establishment' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE soutenance_establishment LIKE :search GROUP BY Date ORDER BY Date;"),
+ default => "",
+ };
+
+ $stmt->bindParam(':search', $search, PDO::PARAM_STR, 100);
+ $stmt->execute();
+
+ $i = 0;
+ while ($obj = $stmt->fetchObject()) {
+ $years_array[$i] = array();
+ $years_array[$i][$obj->Date] = $obj->Number;
+ $i++;
+ }
+
+ return $years_array;
+ }
+
+ public static function getThesesDisciplines(string $search, string $option) : array {
+ $disciplines_array = [];
+
+ $pdo_obj = new conf();
+ $pdo = $pdo_obj->getPDO();
+
+ $search = '%' . $search . '%';
+
+ $stmt = match ($option) {
+ 'auto' => $pdo->prepare("
+ SELECT discipline AS Discipline,
+ COUNT(discipline) AS Number
+ FROM `theses`
+ WHERE author LIKE :search
+ OR title LIKE :search
+ OR these_director LIKE :search
+ OR soutenance_establishment LIKE :search
+ GROUP BY Discipline
+ ORDER BY `Number` DESC
+ LIMIT 10
+ "),
+ 'author' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE author LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
+ 'title' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE title LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
+ 'director' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE these_director LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
+ 'establishment' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE soutenance_establishment LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
+ default => "",
+ };
+
+ $stmt->bindParam(':search', $search, PDO::PARAM_STR, 100);
+ $stmt->execute();
+
+ $i = 0;
+ while ($obj = $stmt->fetchObject()) {
+ $disciplines_array[$i] = array();
+ $disciplines_array[$i][$obj->Discipline] = $obj->Number;
+ $i++;
+ }
+
+ return $disciplines_array;
+ }
+
public function sendThese($pdo) {
$data = [
'author' => $this->these->getAuthor(),
@@ -147,4 +228,4 @@ class dump {
$stmt = $pdo->prepare($sql);
$stmt->execute($data);
}
-}
\ No newline at end of file
+}