mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 11:43:16 +02:00
✨ Added back for disciplines and years charts
This commit is contained in:
Generated
+1
@@ -6,5 +6,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="highcharts.src" level="application" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -24,6 +24,8 @@ $json_object = match ($q) {
|
|||||||
"theses" => dump::getTheses($search, $option, $offset),
|
"theses" => dump::getTheses($search, $option, $offset),
|
||||||
"suggestion" => dump::getSuggestions($search, $option),
|
"suggestion" => dump::getSuggestions($search, $option),
|
||||||
"count" => dump::getThesesCount($search, $option),
|
"count" => dump::getThesesCount($search, $option),
|
||||||
|
"years" => dump::getThesesYears($search, $option),
|
||||||
|
"disciplines" => dump::getThesesDisciplines($search, $option),
|
||||||
default => NULL,
|
default => NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ function apiRequestThese(search, offset) {
|
|||||||
emptyResults(true)
|
emptyResults(true)
|
||||||
pagesNumbers.innerHTML = ""
|
pagesNumbers.innerHTML = ""
|
||||||
loader.style.display = "block"
|
loader.style.display = "block"
|
||||||
|
pagesNumbersContainer.style.display = 'none'
|
||||||
searchString = sanitize(search)
|
searchString = sanitize(search)
|
||||||
fetch(`api.php?q=theses&search=${searchString}&option=${queryOption}&offset=${offset}`)
|
fetch(`api.php?q=theses&search=${searchString}&option=${queryOption}&offset=${offset}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
@@ -132,7 +133,6 @@ function displayResults(results, aCount) {
|
|||||||
error.classList.remove("fade-out");
|
error.classList.remove("fade-out");
|
||||||
error.classList.add("fade-in");
|
error.classList.add("fade-in");
|
||||||
errorMessage.innerHTML = results.message
|
errorMessage.innerHTML = results.message
|
||||||
pagesNumbersContainer.style.display = 'none'
|
|
||||||
} else if (results.status === 200) {
|
} else if (results.status === 200) {
|
||||||
count = aCount
|
count = aCount
|
||||||
resultsArray = []
|
resultsArray = []
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class dump {
|
|||||||
while ($obj = $stmt->fetchObject()) {
|
while ($obj = $stmt->fetchObject()) {
|
||||||
$theses_array[$i] = array();
|
$theses_array[$i] = array();
|
||||||
foreach ($obj as $elem) {
|
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++;
|
$i++;
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ class dump {
|
|||||||
|
|
||||||
while ($obj = $stmt->fetchObject()) {
|
while ($obj = $stmt->fetchObject()) {
|
||||||
foreach ($obj as $elem) {
|
foreach ($obj as $elem) {
|
||||||
array_push($array, $elem);
|
$array[] = $elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,13 +116,94 @@ class dump {
|
|||||||
|
|
||||||
while ($obj = $stmt->fetchObject()) {
|
while ($obj = $stmt->fetchObject()) {
|
||||||
foreach ($obj as $elem) {
|
foreach ($obj as $elem) {
|
||||||
array_push($array, $elem);
|
$array[] = $elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $array;
|
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) {
|
public function sendThese($pdo) {
|
||||||
$data = [
|
$data = [
|
||||||
'author' => $this->these->getAuthor(),
|
'author' => $this->these->getAuthor(),
|
||||||
@@ -147,4 +228,4 @@ class dump {
|
|||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute($data);
|
$stmt->execute($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user