Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Juan Montilla
/
TBW2223_equipo12
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e6d12607
authored
May 08, 2023
by
Juan Montilla
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Foto de perfil y recetas asociadas a usuarios
parent
b09851d8
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
376 additions
and
96 deletions
app/Config/Routes.php
app/Controllers/InsertRecipeController.php
app/Controllers/RecipesController.php
app/Controllers/User.php
app/Filters/AdminAuth.php
app/Filters/UserAuth.php
app/Models/RecipesIngredientModel.php
app/Models/RecipesModel.php
app/Models/UserModel.php
app/Views/pages/insertRecipe.php
app/Views/pages/profile_view.php
app/Views/pages/recipe_view.php
app/Views/pages/userRecipes.php
app/Views/templates/header.php
app/Views/user/list.php
app/Views/user/unauthorized.php
public/css/insert.css
app/Config/Routes.php
View file @
e6d12607
...
...
@@ -37,23 +37,38 @@ $routes->match(['get', 'post'], '/loginAjax', [User::class, 'loginAjax']);
$routes
->
match
([
'get'
,
'post'
],
'/registerAjax'
,
[
User
::
class
,
'registerAjax'
]);
$routes
->
match
([
'get'
],
'/home'
,
[
User
::
class
,
'user_ok'
]);
// Ruta para boorar una receta dada un id
$routes
->
get
(
'/recipes/delete/(:num)'
,
'RecipesController::delete/$1'
);
// Ruta cuando se cierra la sesión
$routes
->
get
(
'/logout'
,
'User::logout'
);
// Ruta para ver una receta
$routes
->
get
(
'/recipe/(:num)'
,
'RecipesController::view_recipe/$1'
);
// Ruta para obtener una imagen de una receta dado un id
$routes
->
get
(
'recipe/image/(:num)'
,
'RecipesController::show_image/$1'
);
// Ruta para obtener un nombre de usuario dado un email
$routes
->
get
(
'username/(:any)'
,
'User::show_name/$1'
);
// Rutas para formulario de ingresar recetas
$routes
->
get
(
'/insert_recipe'
,
'InsertRecipeController::index'
);
$routes
->
get
(
'/insert_recipe'
,
'InsertRecipeController::index'
,
[
'filter'
=>
'user_auth'
]
);
$routes
->
match
([
'get'
,
'post'
],
'/search_ingredient'
,
'InsertRecipeController::search_ingredient'
);
$routes
->
post
(
'/insert_recipe'
,
'InsertRecipeController::insert_recipe'
);
// Ruta para la búsqueda de recetas
$routes
->
match
([
'get'
,
'post'
],
'/search_recipe'
,
'RecipesController::search_recipe'
);
// Ruta para vista "Mis recetas"
$routes
->
get
(
'/myrecipes'
,
'User::personalRecipes'
,
[
'filter'
=>
'user_auth'
]);
// Ruta para vista "Mi perfil"
$routes
->
get
(
'/profile'
,
'User::myprofile'
,
[
'filter'
=>
'user_auth'
]);
$routes
->
post
(
'/cambiarFoto'
,
'User::changeProfilePhoto'
);
$routes
->
get
(
'login'
,
'Pages::viewLogin'
);
$routes
->
get
(
'users'
,
'User::list'
);
$routes
->
get
(
'users'
,
'User::list'
,
[
'filter'
=>
'admin_auth'
]
);
$routes
->
get
(
'home'
,
'Pages::prueba'
);
$routes
->
get
(
'(:segment)'
,
'Home::index'
);
...
...
app/Controllers/InsertRecipeController.php
View file @
e6d12607
...
...
@@ -28,7 +28,7 @@ class InsertRecipeController extends Controller
}
public
function
insert_recipe
()
{
{
// Cargar los modelos necesarios
$recipeModel
=
new
\App\Models\RecipesModel
();
$recipesIngredientModel
=
new
\App\Models\RecipesIngredientModel
();
...
...
@@ -47,6 +47,13 @@ class InsertRecipeController extends Controller
$recipeData
[
'photo'
]
=
$photoBlob
;
}
// Obtener el email del usuario de la sesión
$session
=
session
();
$userEmail
=
$session
->
get
(
'user'
)
->
email
;
// Agregar el email del usuario a los datos de la receta
$recipeData
[
'email_user'
]
=
$userEmail
;
// Insertar la receta en la tabla 'recipes'
$recipeId
=
$recipeModel
->
insert
(
$recipeData
);
...
...
@@ -59,8 +66,9 @@ class InsertRecipeController extends Controller
]);
}
// Redireccionar a la página principal (o cualquier otra página que desees)
// Redireccionar a la página principal
return
redirect
()
->
to
(
'/home'
);
}
}
}
app/Controllers/RecipesController.php
View file @
e6d12607
...
...
@@ -14,6 +14,13 @@ class RecipesController extends Controller
$recipe
=
$recipesModel
->
find
(
$recipe_id
);
$ingredients
=
$recipesModel
->
get_recipe_ingredients
(
$recipe_id
);
// Obtén el nombre de usuario a partir del correo electrónico
$userModel
=
new
\App\Models\UserModel
();
$email
=
$recipe
->
email_user
;
$user
=
$userModel
->
where
(
'email'
,
$email
)
->
first
();
$username
=
$user
->
username
;
$photo
=
$user
->
photo
;
if
(
$recipe
==
null
)
{
// Mostrar un mensaje de error si no se encuentra la receta
return
redirect
()
->
to
(
'/'
);
...
...
@@ -22,6 +29,8 @@ class RecipesController extends Controller
$data
=
[
'recipe'
=>
$recipe
,
'ingredients'
=>
$ingredients
,
'username'
=>
$username
,
'photoUser'
=>
$photo
,
];
return
view
(
'templates/header'
,
$data
)
...
...
@@ -52,4 +61,27 @@ class RecipesController extends Controller
$recipes
=
$recipesModel
->
searchRecipe
(
$query
);
return
$this
->
response
->
setJSON
(
$recipes
);
}
public
function
delete
(
$id
)
{
$recipeModel
=
new
RecipesModel
();
$recipeIngredientModel
=
new
RecipesIngredientModel
();
// Primero, borra todas las entradas de la tabla recipes_ingredient
if
(
$recipeIngredientModel
->
deleteRelation
(
$id
))
{
// Si se eliminaron las relaciones correctamente, borra la receta
if
(
$recipeModel
->
deleteRecipe
(
$id
))
{
// La receta se eliminó correctamente
return
redirect
()
->
to
(
'/users'
)
->
with
(
'message'
,
'Receta eliminada correctamente'
);
}
else
{
// Hubo un error al eliminar la receta
return
redirect
()
->
back
()
->
with
(
'error'
,
'No se pudo eliminar la receta'
);
}
}
else
{
// Hubo un error al eliminar las relaciones
return
redirect
()
->
back
()
->
with
(
'error'
,
'No se pudieron eliminar las relaciones de ingredientes de la receta'
);
}
}
}
\ No newline at end of file
app/Controllers/User.php
View file @
e6d12607
...
...
@@ -27,7 +27,8 @@ class User extends BaseController
}
public
function
loginAjax
(){
public
function
loginAjax
()
{
$validation
=
\Config\Services
::
validation
();
$rules
=
[
"email"
=>
[
...
...
@@ -77,12 +78,7 @@ class User extends BaseController
}
public
function
user_ok
()
{
$session
=
session
();
$usuario
=
$session
->
__get
(
'user'
);
$data
[
'usuario'
]
=
$usuario
;
$userModel
=
model
(
'UserModel'
);
return
view
(
'templates/header'
,
$data
)
return
view
(
'templates/header'
)
.
view
(
'pages/home'
)
.
view
(
'templates/footer'
);
}
...
...
@@ -90,7 +86,10 @@ class User extends BaseController
public
function
logout
()
{
# To Do.
$session
=
session
();
$session
->
destroy
();
return
redirect
()
->
to
(
'/login'
);
}
public
function
unauthorized
()
...
...
@@ -128,10 +127,13 @@ class User extends BaseController
$name
=
$this
->
request
->
getVar
(
'username'
);
$email
=
$this
->
request
->
getVar
(
'email'
);
$password
=
$this
->
request
->
getVar
(
'password'
);
$role
=
$this
->
request
->
getVar
(
'rol'
);
$userData
=
[
'username'
=>
$name
,
'email'
=>
$email
,
'password'
=>
password_hash
(
$password
,
PASSWORD_DEFAULT
),
'rol'
=>
$role
,
'photo'
=>
null
];
$userModel
->
saveUser
(
$email
,
$name
,
$password
);
$newUser
=
$userModel
->
authenticate
(
$email
,
$password
);
...
...
@@ -164,5 +166,49 @@ class User extends BaseController
}
public
function
show_name
(
$email
)
{
$userModel
=
new
\App\Models\UserModel
();
$user
=
$userModel
->
find
(
$email
);
if
(
$user
)
{
return
$user
->
username
;
}
return
false
;
}
public
function
personalRecipes
()
{
return
view
(
'templates/header'
)
.
view
(
'pages/userRecipes'
)
.
view
(
'templates/footer'
);
}
public
function
myprofile
()
{
return
view
(
'templates/header'
)
.
view
(
'pages/profile_view'
)
.
view
(
'templates/footer'
);
}
public
function
changeProfilePhoto
()
{
$session
=
\Config\Services
::
session
();
$email
=
$session
->
get
(
'user'
)
->
email
;
$userModel
=
new
UserModel
();
$photo
=
$this
->
request
->
getFile
(
'photo'
);
if
(
$photo
->
isValid
()
&&
!
$photo
->
hasMoved
())
{
$photoBlob
=
file_get_contents
(
$photo
->
getRealPath
());
$data
[
'photo'
]
=
$photoBlob
;
$userModel
->
update
(
$email
,
$data
);
}
return
redirect
()
->
to
(
'/perfil'
);
}
}
\ No newline at end of file
app/Filters/AdminAuth.php
View file @
e6d12607
...
...
@@ -11,7 +11,7 @@ class AdminAuth implements FilterInterface
{
if
(
!
session
(
'logged_in'
))
return
redirect
()
->
to
(
site_url
(
'/login'
));
elseif
((
session
(
'user'
)
->
rol
e
&
2
)
==
0
)
elseif
((
session
(
'user'
)
->
rol
&
2
)
==
0
)
return
redirect
()
->
to
(
site_url
(
'/unauthorized'
));
}
public
function
after
(
...
...
app/Filters/UserAuth.php
View file @
e6d12607
...
...
@@ -11,8 +11,6 @@ class UserAuth implements FilterInterface
{
if
(
!
session
(
'logged_in'
))
return
redirect
()
->
to
(
site_url
(
'/login'
));
else
if
((
session
(
'user'
)
->
role
&
1
)
==
0
)
return
redirect
()
->
to
(
site_url
(
'/unauthorized'
));
}
public
function
after
(
RequestInterface
$request
,
ResponseInterface
$response
,
...
...
app/Models/RecipesIngredientModel.php
View file @
e6d12607
...
...
@@ -30,5 +30,10 @@ class RecipesIngredientModel extends Model
return
$this
->
insert
(
$data
);
}
public
function
deleteRelation
(
$id_recipe
)
{
return
$this
->
where
(
'id_recipe'
,
$id_recipe
)
->
delete
();
}
}
\ No newline at end of file
app/Models/RecipesModel.php
View file @
e6d12607
...
...
@@ -11,7 +11,7 @@ class RecipesModel extends Model
protected
$returnType
=
'object'
;
# 'object' or 'array'
protected
$useSoftDeletes
=
false
;
# true if you expect to recover data
# Fields that can be set during save, insert, or update methods
protected
$allowedFields
=
[
'id'
,
'name'
,
'season'
,
'origin'
,
'photo'
,
'is_vegan'
,
'description'
,
'instructions'
,
'link'
];
protected
$allowedFields
=
[
'id'
,
'name'
,
'season'
,
'origin'
,
'photo'
,
'is_vegan'
,
'description'
,
'instructions'
,
'link'
,
'email_user'
];
protected
$useTimestamps
=
false
;
# no timestamps on inserts and updates
# Do not use validations rules (for the time being...)
protected
$validationRules
=
[];
...
...
@@ -19,7 +19,7 @@ class RecipesModel extends Model
protected
$skipValidation
=
false
;
public
function
saveRecipe
(
$id
,
$name
,
$season
,
$origin
,
$photo
,
$is_vegan
,
$description
,
$instructions
,
$link
)
public
function
saveRecipe
(
$id
,
$name
,
$season
,
$origin
,
$photo
,
$is_vegan
,
$description
,
$instructions
,
$link
,
$email_user
)
{
$data
=
[
'id'
=>
$id
,
...
...
@@ -31,6 +31,7 @@ class RecipesModel extends Model
'description'
=>
$description
,
'instructions'
=>
$instructions
,
'link'
=>
$link
,
'email_user'
=>
$email_user
];
return
$this
->
insert
(
$data
);
}
...
...
@@ -57,9 +58,9 @@ class RecipesModel extends Model
return
[];
}
public
function
deleteRecipe
(
$id
)
{
return
$this
->
delete
(
$id
);
}
}
\ No newline at end of file
app/Models/UserModel.php
View file @
e6d12607
...
...
@@ -11,7 +11,7 @@ class UserModel extends Model
protected
$returnType
=
'object'
;
# 'object' or 'array'
protected
$useSoftDeletes
=
false
;
# true if you expect to recover data
# Fields that can be set during save, insert, or update methods
protected
$allowedFields
=
[
'email'
,
'username'
,
'password'
];
protected
$allowedFields
=
[
'email'
,
'username'
,
'password'
,
'photo'
];
protected
$useTimestamps
=
false
;
# no timestamps on inserts and updates
# Do not use validations rules (for the time being...)
protected
$validationRules
=
[];
...
...
app/Views/pages/insertRecipe.php
View file @
e6d12607
...
...
@@ -62,7 +62,6 @@
</select>
</div>
</div>
<!-- Opción vegana -->
<div
class=
"form-group col-md-4"
>
...
...
@@ -73,6 +72,9 @@
</div>
</div>
</div>
<!-- Seleccionar ingredientes -->
<label>
Ingredientes:
</label>
<div
class=
"input-group my-form"
>
...
...
@@ -112,6 +114,10 @@
</div>
</div>
<!-- Añadir ingrediente -->
<h5>
¿No ves tu ingrediente en la lista?
<!-- Seleccionar enlace de video-->
<div
class=
"form-group"
>
<label
for=
"link"
>
Ingrese el enlace del video:
</label>
<input
type=
"text"
id=
"link"
name=
"link"
class=
"form-control"
...
...
app/Views/pages/profile_view.php
0 → 100644
View file @
e6d12607
<main
id=
"main"
class=
"main"
>
<section
class=
"section dashboard"
>
<?php
$session
=
session
();
?>
<div
style=
"display: flex; flex-direction: row; align-items: center;"
>
<?php
if
(
$session
->
has
(
'user'
)
&&
!
is_null
(
$session
->
get
(
'user'
)
->
photo
))
:
?>
<img
src=
"data:image/jpeg;base64,
<?=
base64_encode
(
$session
->
get
(
'user'
)
->
photo
)
?>
"
alt=
"Profile"
style=
"width: 100px; height: 100px; object-fit: cover; border-radius: 50%;"
>
<?php
else
:
?>
<img
src=
"
<?=
base_url
(
"imagenes/profile.png"
)
?>
"
style=
"width: 100px; height: 100px; object-fit: cover; border-radius: 50%;"
>
<?php
endif
;
?>
<div
style=
"display: flex; flex-direction: column; margin-left: 20px;"
>
<span
style=
"font-size: 18px; font-weight: bold;"
>
Nombre de usuario:
</span>
<span
style=
"font-size: 16px;"
>
<?=
$session
->
get
(
'user'
)
->
username
?>
</span>
<span
style=
"font-size: 18px; font-weight: bold;"
>
Correo:
</span>
<span
style=
"font-size: 16px;"
>
<?=
$session
->
get
(
'user'
)
->
email
?>
</span>
</div>
</div>
<a
href=
"#"
id=
"cambiar-foto-btn"
class=
"btn btn-primary"
>
Cambiar foto de perfil
</a>
<div
class=
"modal fade"
id=
"cambiar-foto-modal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
>
Cambiar foto de perfil
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
<form
id=
"cambiar-foto-form"
enctype=
"multipart/form-data"
>
<div
class=
"form-group"
>
<label
for=
"foto"
>
Selecciona una foto:
</label>
<input
type=
"file"
class=
"form-control-file"
id=
"foto"
name=
"foto"
>
</div>
</form>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Cancelar
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"guardar-foto-btn"
>
Guardar
</button>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- End #main -->
<script>
$
(
document
).
ready
(
function
()
{
$
(
'#cambiar-foto-btn'
).
click
(
function
()
{
$
(
'#cambiar-foto-modal'
).
modal
(
'show'
);
});
});
</script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
'#guardar-foto-btn'
).
click
(
function
()
{
var
formData
=
new
FormData
(
$
(
'#cambiar-foto-form'
)[
0
]);
$
.
ajax
({
url
:
'/cambiarFoto'
,
type
:
'POST'
,
data
:
formData
,
contentType
:
false
,
processData
:
false
,
success
:
function
(
data
)
{
window
.
location
.
href
=
'/perfil'
;
}
});
});
});
</script>
app/Views/pages/recipe_view.php
View file @
e6d12607
...
...
@@ -76,6 +76,12 @@ function getYoutubeVideoId($url)
width
:
100%
;
height
:
100%
;
}
#profile-pic
{
border-radius
:
10px
;
width
:
25px
;
height
:
25px
;
}
</style>
<main
id=
"main"
class=
"main"
>
...
...
@@ -94,6 +100,22 @@ function getYoutubeVideoId($url)
<?php
echo
$recipe
->
description
;
?>
</p>
<div
class=
"recipe-header"
>
<p>
Receta subida por:
<b>
<?=
$username
?>
<?php
if
(
empty
(
$photoUser
))
:
?>
<img
src=
"
<?=
base_url
(
"imagenes/profile.png"
)
?>
"
alt=
"Profile"
id=
"profile-pic"
>
<?php
else
:
?>
<img
src=
"data:image/jpeg;base64,
<?=
base64_encode
(
$photoUser
)
?>
"
alt=
"Profile"
id=
"profile-pic"
>
<?php
endif
;
?>
</b>
</p>
</div>
<h2>
Ingredientes
</h2>
<ul
class=
"ingredient-list"
>
<?php
foreach
(
$ingredients
as
$ingredient
)
{
?>
...
...
app/Views/pages/userRecipes.php
0 → 100644
View file @
e6d12607
<main
id=
"main"
class=
"main"
>
<section
class=
"section dashboard"
>
<h1>
Vista por hacer🤠
</h1>
</section>
</main>
<!-- End #main -->
\ No newline at end of file
app/Views/templates/header.php
View file @
e6d12607
...
...
@@ -2,6 +2,9 @@
<html
lang=
"en"
>
<head>
<!-- Sesión -->
<?php
$session
=
session
();
?>
<meta
charset=
"utf-8"
>
<meta
content=
"width=device-width, initial-scale=1.0"
name=
"viewport"
>
...
...
@@ -59,7 +62,7 @@
<div
class=
"search-bar"
>
<form
class=
"search-form d-flex align-items-center"
method=
"POST"
action=
"#"
>
<input
type=
"text"
id=
"search-query"
name=
"query"
placeholder=
"Buscar por receta..."
title=
"Enter search keyword"
>
title=
"Enter search keyword"
>
</form>
<ul
id=
"recipe_list"
class=
"ingredients-list list-unstyled"
></ul>
</div>
...
...
@@ -86,8 +89,12 @@
<li
class=
"nav-item dropdown pe-3"
>
<a
class=
"nav-link nav-profile d-flex align-items-center pe-0"
href=
"#"
data-bs-toggle=
"dropdown"
>
<img
src=
"
<?=
base_url
(
"imagenes/profile.png"
)
?>
"
alt=
"Profile"
class=
"rounded-circle"
>
<?php
if
(
$session
->
has
(
'user'
)
&&
!
is_null
(
$session
->
get
(
'user'
)
->
photo
))
:
?>
<img
src=
"data:image/jpeg;base64,
<?=
base64_encode
(
$session
->
get
(
'user'
)
->
photo
)
?>
"
alt=
"Profile"
class=
"rounded-circle"
>
<?php
else
:
?>
<img
src=
"
<?=
base_url
(
"imagenes/profile.png"
)
?>
"
alt=
"Profile"
class=
"rounded-circle"
>
<?php
endif
;
?>
<span
class=
"d-none d-md-block dropdown-toggle ps-2"
>
...
...
@@ -98,55 +105,67 @@
<ul
class=
"dropdown-menu dropdown-menu-end dropdown-menu-arrow profile"
>
<li
class=
"dropdown-header"
>
<h6>
<?php
if
(
isset
(
$usuario
))
{
echo
$usuario
->
username
;
}
else
{
echo
"Usuario sin registrar"
;
}
?>
<!-- Comprobar inicio de sesión-->
<?php
if
(
$session
->
has
(
'logged_in'
))
:
?>
<!-- Si usuario logueado -->
<p>
<?=
$session
->
get
(
'user'
)
->
username
;
?>
</p>
<?php
else
:
?>
<!-- Si usuario no logueado -->
<p>
Usuario sin registrar
</p>
<?php
endif
;
?>
</h6>
</li>
<li>
<hr
class=
"dropdown-divider"
>
</li>
<?php
if
(
$session
->
has
(
'logged_in'
))
:
?>
<!-- OPCIONES USUARIOS LOGUEADOS -->
<!-- COMPROBAR ADMIN -->
<?php
if
(
$session
->
get
(
'user'
)
->
rol
==
2
)
:
?>
<li>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"users-profile.html
"
>
<i
class=
"bi bi-person
"
></i>
<span>
Mi perfil
</span>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"/users
"
>
<i
class=
"bi bi-gear
"
></i>
<span>
Panel Administrador
</span>
</a>
</li>
<li>
<hr
class=
"dropdown-divider"
>
</li>
<?php
endif
;
?>
<!-- FIN OPCIÓN ADMIN -->
<li>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"users-profile.html
"
>
<i
class=
"bi bi-gear
"
></i>
<span>
Ajustes de cuenta
</span>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"/profile
"
>
<i
class=
"bi bi-person
"
></i>
<span>
Mi perfil
</span>
</a>
</li>
<li>
<li>
<hr
class=
"dropdown-divider"
>
</li>
<li>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"pages-faq.html
"
>
<i
class=
"bi bi-question-circle
"
></i>
<span>
¿Necesitas ayuda?
</span>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"/logout
"
>
<i
class=
"bi bi-box-arrow-right
"
></i>
<span>
Cerrar sesion
</span>
</a>
</li>
<li>
<hr
class=
"dropdown-divider"
>
</li>
<?php
else
:
?>
<!-- OPCIONES USUARIOS SIN REGISTRAR -->
<li>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"#
"
>
<i
class=
"bi bi-box-arrow-right
"
></i>
<span>
Cerrar sesió
n
</span>
<a
class=
"dropdown-item d-flex align-items-center"
href=
"login
"
>
<i
class=
"bi bi-question-circle
"
></i>
<span>
Registro/Logi
n
</span>
</a>
</li>
<?php
endif
;
?>
</ul>
<!-- End Profile Dropdown Items -->
</li>
<!-- End Profile Nav -->
...
...
@@ -157,12 +176,12 @@
</header>
<!-- End Header -->
<!-- ======= Sidebar ======= -->
<aside
id=
"sidebar"
class=
"sidebar"
>
<aside
id=
"sidebar"
class=
"sidebar"
>
<ul
class=
"sidebar-nav"
id=
"sidebar-nav"
>
<ul
class=
"sidebar-nav"
id=
"sidebar-nav"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link "
href=
"
index.html
"
>
<a
class=
"nav-link "
href=
"
/home
"
>
<i
class=
"bi bi-grid"
></i>
<span>
Recetas
</span>
</a>
...
...
@@ -182,7 +201,6 @@
<input
type=
"checkbox"
id=
"checkboxOne"
value=
"Order one"
>
<label
for=
"checkboxOne"
>
Recetas Veganas
</label>
</li>
</ul>
</ul>
</li>
<!-- Fin Filtro 1 -->
...
...
@@ -190,7 +208,7 @@
<!-- Filtro 1-->
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
data-bs-target=
"#tables-nav2"
data-bs-toggle=
"collapse"
href=
"#"
>
<i
class=
"bi bi-layout-text-window-reverse"
></i><span>
Filtro 2
</span><i
<i
class=
"bi bi-layout-text-window-reverse"
></i><span>
Filtro Origen
</span><i
class=
"bi bi-chevron-down ms-auto"
></i>
</a>
<ul
id=
"tables-nav2"
class=
"nav-content collapse "
data-bs-parent=
"#sidebar-nav"
>
...
...
@@ -238,12 +256,12 @@
</ul>
</li>
<!-- Fin Filtro 1
-->
</li>
<!-- Fin Filtro Origen
-->
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
data-bs-target=
"#tables-nav3"
data-bs-toggle=
"collapse"
href=
"#"
>
<i
class=
"bi bi-layout-text-window-reverse"
></i><span>
Estaciones
</span><i
<i
class=
"bi bi-layout-text-window-reverse"
></i><span>
Filtro Temporada
</span><i
class=
"bi bi-chevron-down ms-auto"
></i>
</a>
<ul
id=
"tables-nav3"
class=
"nav-content collapse "
data-bs-parent=
"#sidebar-nav"
>
...
...
@@ -276,41 +294,37 @@
</ul>
</ul>
</li>
<!-- Fin Filtro 1 -->
</li>
<!-- Fin Filtro Estaciones -->
<?php
if
(
$session
->
has
(
'logged_in'
))
:
?>
<!-- Si usuario logueado -->
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
href=
"/insert_recipe"
>
<i
class=
"bi bi-file-earmark"
></i>
<span>
Subir receta
</span>
</a>
</li>
<!-- End Profile Page Nav -->
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
href=
"https://www.instagram.com/salvaperfectti/
"
>
<i
class=
"bi bi-
envelope
"
></i>
<span>
Contacto
</span>
<a
class=
"nav-link collapsed"
href=
"/myrecipes
"
>
<i
class=
"bi bi-
card-list
"
></i>
<span>
Mis recetas
</span>
</a>
</li>
<!-- End Contact Page Nav -->
</li>
<?php
else
:
?>
<!-- Si usuario no logueado -->
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
href=
"/login"
>
<i
class=
"bi bi-box-arrow-in-right"
></i>
<span>
Registro/Login
</span>
</a>
</li>
<!-- End Login Page Nav -->
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
href=
"http://www.homerswebpage.com/"
>
<i
class=
"bi bi-dash-circle"
></i>
<span>
Error 404
</span>
</a>
</li>
<!-- End Error 404 Page Nav -->
</li>
<?php
endif
;
?>
</ul>
</ul>
</aside>
<!-- End Sidebar-->
\ No newline at end of file
</aside>
<!-- End Sidebar-->
\ No newline at end of file
app/Views/user/list.php
View file @
e6d12607
<h1>
Admin Page
</h1>
<h2>
Lista de usuarios
</h2>
<!-- LISTA DE USUARIOS -->
<?php
if
(
sizeof
(
$users
)
>
0
)
{
<main
id=
"main"
class=
"main"
>
<section
class=
"section dashboard"
>
<h2>
Usuarios
</h2>
<!-- LISTA DE USUARIOS -->
<?php
if
(
sizeof
(
$users
)
>
0
)
{
foreach
(
$users
as
$row
)
{
echo
$row
->
email
.
" - "
;
echo
$row
->
username
.
" - "
;
echo
$row
->
password
.
" "
;
echo
"<br/>"
;
}
}
else
{
}
else
{
echo
"No user"
;
}
?>
}
?>
<h2>
Recetas
</h2>
<!-- LISTA DE RECETAS -->
<?php
$recipesModel
=
new
\App\Models\RecipesModel
();
$recipes
=
$recipesModel
->
findAll
();
?>
<h2>
Recetas
</h2>
<!-- LISTA DE RECETAS -->
<?php
$recipesModel
=
new
\App\Models\RecipesModel
();
$recipes
=
$recipesModel
->
findAll
();
?>
<table
class=
"table"
>
<table
class=
"table"
>
<thead>
<tr>
<th>
ID
</th>
...
...
@@ -66,20 +68,23 @@ $recipes = $recipesModel->findAll();
<?=
mb_strimwidth
(
$row
->
instructions
,
0
,
10
,
"..."
);
?>
</td>
<td>
<?=
$row
->
link
;
?>
<?=
mb_strimwidth
(
$row
->
link
,
0
,
50
,
"..."
)
;
?>
</td>
<td>
<button
class=
"btn btn-danger"
onclick=
"deleteRecipe(
<?=
$row
->
id
;
?>
)
"
>
Borrar
</button>
<button
class=
"btn btn-danger"
onclick=
"window.location.href='
<?php
echo
base_url
(
'/recipes/delete/'
.
$row
->
id
);
?>
'
"
>
Borrar
</button>
</td>
</tr>
<?php
endforeach
;
?>
</tbody>
</table>
</table>
<script>
<script>
function
borrarReceta
(
recipeId
)
{
//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa
}
</script>
\ No newline at end of file
</script>
</section>
</main>
<!-- End #main -->
\ No newline at end of file
app/Views/user/unauthorized.php
View file @
e6d12607
public/css/insert.css
View file @
e6d12607
...
...
@@ -266,6 +266,38 @@ body {
width
:
32%
;
}
.form-group
{
margin-bottom
:
20px
;
}
.form-row
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
flex-wrap
:
wrap
;
margin-bottom
:
20px
;
}
.form-row
>
.form-group
{
flex
:
1
;
padding
:
0
15px
;
}
.form-row
>
.form-group
:first-child
{
padding-left
:
0
;
}
.form-row
>
.form-group
:last-child
{
padding-right
:
0
;
}
.label-centered
{
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
flex-direction
:
column
;
}
/* Estilos para el chip vegano */
.vegan-chip
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment