Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Marmiuton
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sofiane Lasri
Marmiuton
Commits
619e04bf
Commit
619e04bf
authored
Jan 8, 2022
by
Sofiane Lasri
Browse files
Options
Downloads
Patches
Plain Diff
+getUtilisateur()
parent
0647c40f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/controller/functions.php
+50
-6
50 additions, 6 deletions
core/controller/functions.php
pages/admin/viewRecettes.php
+2
-2
2 additions, 2 deletions
pages/admin/viewRecettes.php
pages/client/vitrine.php
+13
-6
13 additions, 6 deletions
pages/client/vitrine.php
with
65 additions
and
14 deletions
core/controller/functions.php
+
50
−
6
View file @
619e04bf
...
...
@@ -204,13 +204,13 @@ function getRecettes($search=""){
// On va récupérer les recettes selon la recherche
// Si $search est une liste, on va chercher selon son contenu
// $search["categoryId"], $search["name"], ["ingredientId"], ["difficult
y
"], ["time"], ["auteurId"]
// $search["categoryId"], $search["name"], ["ingredientId"], ["difficult
e
"], ["time"], ["auteurId"]
if
(
is_array
(
$search
)){
// https://stackoverflow.com/a/18603279
$categoryId
=
$search
[
"categoryId"
]
??
""
;
$name
=
$search
[
"name"
]
??
""
;
$ingredientId
=
$search
[
"ingredientId"
]
??
""
;
$difficult
y
=
$search
[
"difficult
y
"
]
??
""
;
$difficult
e
=
$search
[
"difficult
e
"
]
??
""
;
$tempsPreparation
=
$search
[
"tempsPreparation"
]
??
""
;
$auteurId
=
$search
[
"auteurId"
]
??
""
;
...
...
@@ -225,8 +225,8 @@ function getRecettes($search=""){
if
(
!
empty
(
$ingredientId
)){
$queryString
.
=
" AND ingredientId=:ingredientId"
;
}
if
(
!
empty
(
$difficult
y
)){
$queryString
.
=
" AND difficulte=:difficult
y
"
;
if
(
!
empty
(
$difficult
e
)){
$queryString
.
=
" AND difficulte=:difficult
e
"
;
}
if
(
!
empty
(
$tempsPreparation
)){
$queryString
.
=
" AND tempsPreparation=:tempsPreparation"
;
...
...
@@ -247,8 +247,8 @@ function getRecettes($search=""){
if
(
!
empty
(
$ingredientId
)){
$query
->
bindParam
(
':ingredientId'
,
$ingredientId
);
}
if
(
!
empty
(
$difficult
y
)){
$query
->
bindParam
(
':difficult
y
'
,
$difficult
y
);
if
(
!
empty
(
$difficult
e
)){
$query
->
bindParam
(
':difficult
e
'
,
$difficult
e
);
}
if
(
!
empty
(
$tempsPreparation
)){
$query
->
bindParam
(
':tempsPreparation'
,
$tempsPreparation
);
...
...
@@ -354,3 +354,47 @@ function getWebsiteSetting($setting){
$settingValue
=
$response
->
fetchColumn
();
return
$settingValue
;
// Retourne null si le paramètre n'existe pas
}
// Récupère les utilisateurs
function
getUtilisateur
(
$search
=
""
){
if
(
is_array
(
$search
)){
$userId
=
$search
[
"userId"
]
??
""
;
// Si l'id utilisateur passé en paramètre est vide, il s'agit du compte Marmiton
if
(
$userId
==
0
){
$userMarmiton
[
"username"
]
=
"Marmiton"
;
return
$userMarmiton
;
}
// S'arrête ici
$username
=
$search
[
"username"
]
??
""
;
$queryString
=
"SELECT * FROM m_utilisateur WHERE "
;
if
(
!
emmpty
(
$userId
)){
$queryString
.
=
"id=:userId"
;
}
if
(
!
emmpty
(
$username
)){
$queryString
.
=
"id LIKE :username"
;
}
// On la prépare
$query
=
Connexion
::
pdo
()
->
prepare
(
$queryString
.
" ORDER BY username"
);
// On rempli les paramètres
if
(
!
empty
(
$userId
)){
$query
->
bindParam
(
':userId'
,
$userId
);
}
if
(
!
empty
(
$username
)){
$query
->
bindParam
(
':username'
,
"%"
.
$username
.
"%"
);
}
// On exécute
$query
->
execute
();
// Et on retourne le résultat
return
$query
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
else
{
// Si $search n'est pas un array, on va chercher tous les utilisateurs
$query
=
Connexion
::
pdo
()
->
prepare
(
"SELECT * FROM m_utilisateur ORDER BY username"
);
$query
->
execute
();
return
$query
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pages/admin/viewRecettes.php
+
2
−
2
View file @
619e04bf
...
...
@@ -21,7 +21,7 @@
echo
(
'<div class="recette-card border rounded mx-1 my-1" style="background-image: url(\''
.
$recette
[
"image"
]
.
'\');">
<div class="recette-card-content p-2">
<span><strong>'
.
utf8_decode
(
$recette
[
"nom"
])
.
'</strong></span>
<a href="'
.
genPageLink
(
"/admin/editRecette/"
)
.
'?recetteId='
.
$recette
[
"id"
]
.
'" class="btn btn-sm btn-
brown
float-right">Modifier</a>
<a href="'
.
genPageLink
(
"/admin/editRecette/"
)
.
'?recetteId='
.
$recette
[
"id"
]
.
'" class="btn btn-sm btn-
orange
float-right">Modifier</a>
</div>
</div>'
);
}
...
...
This diff is collapsed.
Click to expand it.
pages/client/vitrine.php
+
13
−
6
View file @
619e04bf
...
...
@@ -83,16 +83,23 @@
<!-- Carte recette -->
<div
class=
"col-md-6"
>
<div
class=
"carte-recette"
>
<a
href=
"#"
>
<div
class=
"carte-recette-img"
style=
"background-image: url('/data/images/plat-delicieux1.jpg');"
></div>
<?php
$search
[
"difficulte"
]
=
1
;
$recettes
=
getRecettes
(
$search
);
foreach
(
$recettes
as
$recette
){
$utilisateur
=
getUtilisateur
(
$recette
[
"aurteurId"
]);
echo
(
'<div class="carte-recette">
<a href="'
.
genPageLink
(
"/recette/"
)
.
'?recetteId='
.
$recette
[
"id"
]
.
'">
<div class="carte-recette-img" style="background-image: url(\''
.
$recette
[
"image"
]
.
'\');"></div>
</a>
<div class="carte-recette-infos">
<h4><strong>
Recette 1
</strong></h4>
<h4><strong>
'
.
utf8_decode
(
$recette
[
"description"
])
.
'
</strong></h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quia.</p>
<i><a
href=
"#"
class=
"text-orange"
>
Marmiuton
</a>
<span
class=
"text-muted"
><i
class=
"far fa-stopwatch"
></i>
75 minutes
</span></i>
</div>
<i><a href="'
.
genPageLink
(
"/utilisateur/"
)
.
'?id='
.
$recette
[
"auteurId"
]
.
'" class="text-orange">'
.
$utilisateur
[
'username'
]
.
'</a> <span class="text-muted"><i class="far fa-stopwatch"></i> 75 minutes</span></i>
</div>
</div>'
);
}
?>
</div>
<!-- Fin -->
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment