refactor 'search_term' to 'query'

This commit is contained in:
Thomas Rubini 2023-01-20 18:24:37 +01:00
parent 28810d0b7c
commit 7c6a5441a7
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
2 changed files with 6 additions and 6 deletions

View File

@ -66,14 +66,14 @@ final class RecipeController
private function searchView(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null) private function searchView(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
{ {
View::show("recipe/search", array("SEARCH_TERM" => null)); View::show("recipe/search", array("QUERY" => null));
} }
private function searchQueryView(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null) private function searchQueryView(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
{ {
$A_results = array(); $A_results = array();
View::show("recipe/search", array( View::show("recipe/search", array(
"SEARCH_TERM" => $A_getParams["query"], "QUERY" => $A_getParams["query"],
"RESULTS" => $A_results, "RESULTS" => $A_results,
)); ));
} }

View File

@ -1,6 +1,6 @@
<?php <?php
# Check presence of the search term query parameter, to avoid getting a warning as the input placeholder value # Check presence of the search term query parameter, to avoid getting a warning as the input placeholder value
$has_search_term = $A_view["SEARCH_TERM"] !== null; $has_query = $A_view["QUERY"] !== null;
?> ?>
<?php View::show("common/category_list") ?> <?php View::show("common/category_list") ?>
@ -8,13 +8,13 @@
<main> <main>
<!-- Inclure les catégories --> <!-- Inclure les catégories -->
<form method="GET" action="/recipe/search"> <form method="GET" action="/recipe/search">
<label for="search_term">Saisissez les termes à rechercher</label> <label for="query">Saisissez les termes à rechercher</label>
<input id="search_term" type="text" name="search_term" placeholder="<?= $has_search_term ? $A_view["SEARCH_TERM"] : "Votre recherche" ?>"> <input id="query" type="text" name="query" placeholder="<?= $has_query ? $A_view["QUERY"] : "Votre recherche" ?>">
<input type="submit" value="Rechercher"> <input type="submit" value="Rechercher">
</form> </form>
<section> <section>
<?php <?php
if ($has_search_term) { if ($has_query) {
$search_results = $A_view["RESULTS"]; $search_results = $A_view["RESULTS"];
if (empty($search_results)) { if (empty($search_results)) {
echo '<h2 class="no_results">Aucun résultat</h2>'; echo '<h2 class="no_results">Aucun résultat</h2>';