resolve
continuous-integration/drone/push Build is failing
Details
After Width: | Height: | Size: 46 KiB |
@ -0,0 +1,113 @@
|
|||||||
|
@startuml
|
||||||
|
skinparam classAttributeIconSize 0
|
||||||
|
package MLD{
|
||||||
|
entity "Athlète" as athlete {
|
||||||
|
{static} idAthlete
|
||||||
|
nom
|
||||||
|
prénom
|
||||||
|
email
|
||||||
|
sexe
|
||||||
|
taille
|
||||||
|
poids
|
||||||
|
motDePasse
|
||||||
|
dateNaissance
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Amitié" as friendship{
|
||||||
|
{static}# idAthlete1
|
||||||
|
{static}# idAthlete2
|
||||||
|
début
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Notification" as notif {
|
||||||
|
{static} idNotif
|
||||||
|
message
|
||||||
|
date
|
||||||
|
statut
|
||||||
|
urgence
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Coach" as coach {
|
||||||
|
{static} idCoach
|
||||||
|
// attributs spécifiques au coach
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Statistique" as stats {
|
||||||
|
{static} idStatistique
|
||||||
|
poids
|
||||||
|
fcMoyenne
|
||||||
|
fcMax
|
||||||
|
caloriesBrûléesMoy
|
||||||
|
date
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Entraînement" as training {
|
||||||
|
{static} idEntrainement
|
||||||
|
date
|
||||||
|
description
|
||||||
|
// Exercices
|
||||||
|
latitude
|
||||||
|
longitude
|
||||||
|
feedback
|
||||||
|
#coachId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Participe" as takepart {
|
||||||
|
{static} #athleteId
|
||||||
|
{static} #entrainementId
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity "SourceDonnée" as source {
|
||||||
|
{static} idSource
|
||||||
|
type
|
||||||
|
modèle
|
||||||
|
précision
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Activité" as activity {
|
||||||
|
{static} idActivité
|
||||||
|
type
|
||||||
|
date
|
||||||
|
heureDeDébut
|
||||||
|
heureDeFin
|
||||||
|
effortRessent
|
||||||
|
variabilité
|
||||||
|
variance
|
||||||
|
ecartType
|
||||||
|
moyenne
|
||||||
|
maximum
|
||||||
|
minimum
|
||||||
|
temperatureMoyenne
|
||||||
|
#athleteId
|
||||||
|
#sourceId
|
||||||
|
}
|
||||||
|
entity "FréquenceCardiaque" as fc {
|
||||||
|
{static} idFc
|
||||||
|
altitude
|
||||||
|
temps : time
|
||||||
|
température
|
||||||
|
bpm
|
||||||
|
longitude
|
||||||
|
latitude
|
||||||
|
#activitéId
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
activity --> athlete
|
||||||
|
activity --> source
|
||||||
|
activity <-- fc
|
||||||
|
coach --> athlete
|
||||||
|
athlete <-- source
|
||||||
|
stats --> athlete
|
||||||
|
takepart --> athlete
|
||||||
|
takepart --> training
|
||||||
|
friendship --> athlete
|
||||||
|
notif --> athlete
|
||||||
|
coach <-- training
|
||||||
|
athlete <-- friendship
|
||||||
|
@enduml
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 22 KiB |
@ -1,17 +0,0 @@
|
|||||||
# Activer la réécriture d'URL
|
|
||||||
RewriteEngine On
|
|
||||||
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
|
||||||
|
|
||||||
RewriteRule ^ index.php [QSA,L]
|
|
||||||
|
|
||||||
<Files *>
|
|
||||||
Order Allow,Deny
|
|
||||||
Deny from all
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
<Files .htaccess>
|
|
||||||
Order Allow,Deny
|
|
||||||
Deny from all
|
|
||||||
</Files>
|
|
@ -1,19 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// use Dotenv\Dotenv;
|
|
||||||
|
|
||||||
// $dotenv = Dotenv::createImmutable(__DIR__);
|
use Dotenv\Dotenv;
|
||||||
// $dotenv->load();
|
use Shared\Log;
|
||||||
|
|
||||||
|
$dotenv = Dotenv::createUnsafeImmutable(__DIR__,'.env');
|
||||||
|
$dotenv->safeLoad();
|
||||||
|
// apenrently getEnv is not a good thing cause
|
||||||
// const DB_HOST = $_ENV['DB_HOST'] ?? 'localhost';
|
// const DB_HOST = $_ENV['DB_HOST'] ?? 'localhost';
|
||||||
// const DB_DATABASE = $_ENV['DB_DATABASE'] ?? 'heartTrack';
|
// const DB_DATABASE = $_ENV['DB_DATABASE'] ?? 'heartTrack';
|
||||||
// const DB_USER = $_ENV['DB_USER'] ?? 'toto';
|
// const DB_USER = $_ENV['DB_USER'] ?? 'toto';
|
||||||
// const DB_PASSWORD = $_ENV['DB_PASSWORD'] ?? 'achanger';
|
// const DB_PASSWORD = $_ENV['DB_PASSWORD'] ?? 'achanger';
|
||||||
// const APP_ENV = $_ENV['APP_ENV'] ?? 'development';
|
define("APP_ENV", 'development');
|
||||||
const DB_HOST ='localhost';
|
|
||||||
|
const DB_HOST = 'localhost';
|
||||||
const DB_DATABASE = 'heartTrack';
|
const DB_DATABASE = 'heartTrack';
|
||||||
const DB_USER = 'toto';
|
const DB_USER = 'toto';
|
||||||
const DB_PASSWORD = 'achanger';
|
const DB_PASSWORD = 'achanger';
|
||||||
const APP_ENV = 'console';
|
|
||||||
|
|
||||||
const DSN = "mysql:host=" . DB_HOST . ";dbname=" . DB_DATABASE;
|
const DSN = "mysql:host=" . DB_HOST . ";dbname=" . DB_DATABASE;
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
index index.php;
|
||||||
|
root /var/www/public;
|
||||||
|
error_page 404 /index.php;
|
||||||
|
|
||||||
root /var/www/html;
|
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
|
||||||
index index.php index.html;
|
root /var/www/public;
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
include fastcgi_params;
|
fastcgi_pass web:9000; # service name defined in docker-compose.yml file like web
|
||||||
fastcgi_pass php:9000; # service name defined in docker-compose.yml file
|
fastcgi_param REQUEST_METHOD $request_method;
|
||||||
|
fastcgi_index index.php;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
}
|
}
|
||||||
|
location ~ /\. {
|
||||||
location ~ /\.ht {
|
|
||||||
deny all;
|
deny all;
|
||||||
|
access_log off;
|
||||||
|
log_not_found off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,15 +1,42 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
web:
|
|
||||||
|
nginx:
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "3000:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./public:/var/www/html
|
- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
- ./config/nginx.conf:/etc/nginx/conf.d
|
- .:/var/www
|
||||||
links:
|
depends_on:
|
||||||
- php
|
- mysql
|
||||||
php:
|
- web
|
||||||
image: php:7.4-fpm
|
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./config/Dockerfile
|
||||||
|
ports:
|
||||||
|
- 9000:9000
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/var/www/html
|
- .:/var/www
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
environment:
|
||||||
|
DB_HOST: mysql
|
||||||
|
DB_PORT: port
|
||||||
|
DB_DATABASE: test
|
||||||
|
DB_USER: user
|
||||||
|
DB_PASSWORD: pass
|
||||||
|
APP_ENV: development
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mysql:latest
|
||||||
|
container_name: my-mysql-container
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: pass
|
||||||
|
MYSQL_DATABASE: test
|
||||||
|
MYSQL_USER: user
|
||||||
|
MYSQL_PASSWORD: pass
|
||||||
|
ports:
|
||||||
|
- "3307:3306"
|
@ -0,0 +1,54 @@
|
|||||||
|
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||||
|
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||||
|
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||||
|
|
||||||
|
// Area Chart Example
|
||||||
|
var ctx = document.getElementById("myAreaChart");
|
||||||
|
var myLineChart = new Chart(ctx, {
|
||||||
|
type: 'line',
|
||||||
|
data: {
|
||||||
|
labels: ["Mar 1", "Mar 2", "Mar 3", "Mar 4", "Mar 5", "Mar 6", "Mar 7", "Mar 8", "Mar 9", "Mar 10", "Mar 11", "Mar 12", "Mar 13"],
|
||||||
|
datasets: [{
|
||||||
|
label: "Sessions",
|
||||||
|
lineTension: 0.3,
|
||||||
|
backgroundColor: "rgba(2,117,216,0.2)",
|
||||||
|
borderColor: "rgba(2,117,216,1)",
|
||||||
|
pointRadius: 5,
|
||||||
|
pointBackgroundColor: "rgba(2,117,216,1)",
|
||||||
|
pointBorderColor: "rgba(255,255,255,0.8)",
|
||||||
|
pointHoverRadius: 5,
|
||||||
|
pointHoverBackgroundColor: "rgba(2,117,216,1)",
|
||||||
|
pointHitRadius: 50,
|
||||||
|
pointBorderWidth: 2,
|
||||||
|
data: [10000, 30162, 26263, 18394, 18287, 28682, 31274, 33259, 25849, 24159, 32651, 31984, 38451],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
xAxes: [{
|
||||||
|
time: {
|
||||||
|
unit: 'date'
|
||||||
|
},
|
||||||
|
gridLines: {
|
||||||
|
display: false
|
||||||
|
},
|
||||||
|
ticks: {
|
||||||
|
maxTicksLimit: 7
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
yAxes: [{
|
||||||
|
ticks: {
|
||||||
|
min: 0,
|
||||||
|
max: 40000,
|
||||||
|
maxTicksLimit: 5
|
||||||
|
},
|
||||||
|
gridLines: {
|
||||||
|
color: "rgba(0, 0, 0, .125)",
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
display: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,46 @@
|
|||||||
|
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||||
|
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||||
|
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||||
|
|
||||||
|
// Bar Chart Example
|
||||||
|
var ctx = document.getElementById("myBarChart");
|
||||||
|
var myLineChart = new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: ["January", "February", "March", "April", "May", "June"],
|
||||||
|
datasets: [{
|
||||||
|
label: "Revenue",
|
||||||
|
backgroundColor: "rgba(2,117,216,1)",
|
||||||
|
borderColor: "rgba(2,117,216,1)",
|
||||||
|
data: [4215, 5312, 6251, 7841, 9821, 14984],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
xAxes: [{
|
||||||
|
time: {
|
||||||
|
unit: 'month'
|
||||||
|
},
|
||||||
|
gridLines: {
|
||||||
|
display: false
|
||||||
|
},
|
||||||
|
ticks: {
|
||||||
|
maxTicksLimit: 6
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
yAxes: [{
|
||||||
|
ticks: {
|
||||||
|
min: 0,
|
||||||
|
max: 15000,
|
||||||
|
maxTicksLimit: 5
|
||||||
|
},
|
||||||
|
gridLines: {
|
||||||
|
display: true
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
display: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,16 @@
|
|||||||
|
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||||
|
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||||
|
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||||
|
|
||||||
|
// Pie Chart Example
|
||||||
|
var ctx = document.getElementById("myPieChart");
|
||||||
|
var myPieChart = new Chart(ctx, {
|
||||||
|
type: 'pie',
|
||||||
|
data: {
|
||||||
|
labels: ["Blue", "Red", "Yellow", "Green"],
|
||||||
|
datasets: [{
|
||||||
|
data: [12.21, 15.58, 11.25, 8.32],
|
||||||
|
backgroundColor: ['#007bff', '#dc3545', '#ffc107', '#28a745'],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,4 @@
|
|||||||
|
// Call the dataTables jQuery plugin
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#dataTable').DataTable();
|
||||||
|
});
|
After Width: | Height: | Size: 784 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 972 B |
After Width: | Height: | Size: 924 B |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 553 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 831 B |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 552 KiB |
After Width: | Height: | Size: 576 KiB |
After Width: | Height: | Size: 540 KiB |
After Width: | Height: | Size: 538 B |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 453 B |
After Width: | Height: | Size: 359 B |
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Twig\Environment;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
use Twig\Error\RuntimeError;
|
||||||
|
use Twig\Extension\SandboxExtension;
|
||||||
|
use Twig\Markup;
|
||||||
|
use Twig\Sandbox\SecurityError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||||
|
use Twig\Source;
|
||||||
|
use Twig\Template;
|
||||||
|
|
||||||
|
/* /home/home.html.twig */
|
||||||
|
class __TwigTemplate_af3d9cd9f4ff4c44106fba71564d7af6059a69449e652f694cd80b0b5e237d82 extends Template
|
||||||
|
{
|
||||||
|
private $source;
|
||||||
|
private $macros = [];
|
||||||
|
|
||||||
|
public function __construct(Environment $env)
|
||||||
|
{
|
||||||
|
parent::__construct($env);
|
||||||
|
|
||||||
|
$this->source = $this->getSourceContext();
|
||||||
|
|
||||||
|
$this->blocks = [
|
||||||
|
'title' => [$this, 'block_title'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doGetParent(array $context)
|
||||||
|
{
|
||||||
|
// line 1
|
||||||
|
return "base.html.twig";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doDisplay(array $context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
$this->parent = $this->loadTemplate("base.html.twig", "/home/home.html.twig", 1);
|
||||||
|
$this->parent->display($context, array_merge($this->blocks, $blocks));
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 3
|
||||||
|
public function block_title($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
echo "Accueil - HearthTrack";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateName()
|
||||||
|
{
|
||||||
|
return "/home/home.html.twig";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isTraitable()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDebugInfo()
|
||||||
|
{
|
||||||
|
return array ( 46 => 3, 35 => 1,);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSourceContext()
|
||||||
|
{
|
||||||
|
return new Source("", "/home/home.html.twig", "/home/www/anpinagot/public_html/sae/Web/Sources/src/app/views/Templates/home/home.html.twig");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,214 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Twig\Environment;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
use Twig\Error\RuntimeError;
|
||||||
|
use Twig\Extension\SandboxExtension;
|
||||||
|
use Twig\Markup;
|
||||||
|
use Twig\Sandbox\SecurityError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||||
|
use Twig\Source;
|
||||||
|
use Twig\Template;
|
||||||
|
|
||||||
|
/* home.html */
|
||||||
|
class __TwigTemplate_16e6c0dcab0136c1f1e8ae28198d95d31cd5a976b1114c0dd185f5b3a7465074 extends Template
|
||||||
|
{
|
||||||
|
private $source;
|
||||||
|
private $macros = [];
|
||||||
|
|
||||||
|
public function __construct(Environment $env)
|
||||||
|
{
|
||||||
|
parent::__construct($env);
|
||||||
|
|
||||||
|
$this->source = $this->getSourceContext();
|
||||||
|
|
||||||
|
$this->parent = false;
|
||||||
|
|
||||||
|
$this->blocks = [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doDisplay(array $context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
// line 1
|
||||||
|
echo "<!DOCTYPE html>
|
||||||
|
<html lang=\"fr\">
|
||||||
|
<head>
|
||||||
|
<meta charset=\"utf-8\" />
|
||||||
|
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />
|
||||||
|
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\" />
|
||||||
|
<meta name=\"description\" content=\"Accueil\" />
|
||||||
|
<meta name=\"author\" content=\"PINAGOT Antoine\" />
|
||||||
|
<title>Accueil - HeartTrack</title>
|
||||||
|
<link href=\"https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.min.css\" rel=\"stylesheet\" />
|
||||||
|
<link href=\"../css/styles.css\" rel=\"stylesheet\" />
|
||||||
|
<script src=\"https://use.fontawesome.com/releases/v6.3.0/js/all.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
</head>
|
||||||
|
<body class=\"sb-nav-fixed\">
|
||||||
|
<nav class=\"sb-topnav navbar navbar-expand navbar-dark bg-dark\">
|
||||||
|
<!-- Navbar Brand-->
|
||||||
|
<img class=\"navbar-brand ps-3\" src=\"../../../public/assets/img/logo.png\">
|
||||||
|
<!-- Sidebar Toggle-->
|
||||||
|
<button class=\"btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0\" id=\"sidebarToggle\" href=\"#!\"><i class=\"fas fa-bars\"></i></button>
|
||||||
|
<!-- Navbar Search-->
|
||||||
|
<form class=\"d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0\">
|
||||||
|
<div class=\"input-group\">
|
||||||
|
<input class=\"form-control\" type=\"text\" placeholder=\"Rechercher...\" aria-label=\"Rechercher...\" aria-describedby=\"btnNavbarSearch\" />
|
||||||
|
<button class=\"btn btn-primary\" id=\"btnNavbarSearch\" type=\"button\"><i class=\"fas fa-search\"></i></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<!-- Navbar-->
|
||||||
|
<ul class=\"navbar-nav ms-auto ms-md-0 me-3 me-lg-4\">
|
||||||
|
<li class=\"nav-item dropdown\">
|
||||||
|
<a class=\"nav-link dropdown-toggle\" id=\"navbarDropdown\" href=\"#\" role=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\"><i class=\"fas fa-user fa-fw\"></i></a>
|
||||||
|
<ul class=\"dropdown-menu dropdown-menu-end\" aria-labelledby=\"navbarDropdown\">
|
||||||
|
<li><a class=\"dropdown-item\" href=\"#!\">Profile</a></li>
|
||||||
|
<li><a class=\"dropdown-item\" href=\"#!\">Paramètres</a></li>
|
||||||
|
<li><hr class=\"dropdown-divider\" /></li>
|
||||||
|
<li><a class=\"dropdown-item\" href=\"#!\">Déconnexion</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<div id=\"layoutSidenav\">
|
||||||
|
<div id=\"layoutSidenav_nav\">
|
||||||
|
<nav class=\"sb-sidenav accordion sb-sidenav-dark\" id=\"sidenavAccordion\">
|
||||||
|
<div class=\"sb-sidenav-menu\">
|
||||||
|
<div class=\"nav\">
|
||||||
|
<div class=\"sb-sidenav-menu-heading\">Menu</div>
|
||||||
|
<a class=\"nav-link\" href=\"home.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/house.png\"></div>
|
||||||
|
Accueil
|
||||||
|
</a>
|
||||||
|
<div class=\"sb-sidenav-menu-heading\">Activités</div>
|
||||||
|
<a class=\"nav-link\" href=\"exercice.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/sprinter.png\"></div>
|
||||||
|
Exercices
|
||||||
|
</a>
|
||||||
|
<a class=\"nav-link\" href=\"analyze.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><i class=\"fas fa-chart-area\"></i></div>
|
||||||
|
Analyses
|
||||||
|
</a>
|
||||||
|
<div class=\"sb-sidenav-menu-heading\">Social</div>
|
||||||
|
<a class=\"nav-link\" href=\"friend.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/group.png\"></div>
|
||||||
|
Amis
|
||||||
|
</a>
|
||||||
|
<a class=\"nav-link\" href=\"coaching.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/coaching.png\"></div>
|
||||||
|
Coaching
|
||||||
|
</a>
|
||||||
|
<a class=\"nav-link\" href=\"mail.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/letter.png\"></div>
|
||||||
|
Messagerie
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=\"sb-sidenav-footer\">
|
||||||
|
<div class=\"small\">Connecté en tant que:</div>
|
||||||
|
{user}
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<div id=\"layoutSidenav_content\">
|
||||||
|
<main>
|
||||||
|
<div class=\"container-fluid px-4\">
|
||||||
|
<h1 class=\"mt-4\">Accueil</h1>
|
||||||
|
<ol class=\"breadcrumb mb-4\">
|
||||||
|
<li class=\"breadcrumb-item active\">Vue d'ensemble</li>
|
||||||
|
</ol>
|
||||||
|
<div class=\"row\">
|
||||||
|
<div class=\"col-7\">
|
||||||
|
<div class=\"card mb-4\">
|
||||||
|
<div class=\"card-header\">
|
||||||
|
<i class=\"fas fa-chart-area me-1\"></i>
|
||||||
|
Stastiques globales
|
||||||
|
</div>
|
||||||
|
<div class=\"card-body\">
|
||||||
|
<canvas id=\"myAreaChart\" width=\"100%\" height=\"40\"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=\"col-5\">
|
||||||
|
<div class=\"card mb-4\">
|
||||||
|
<div class=\"card-header\">
|
||||||
|
<i class=\"fas fa-chart-bar me-1\"></i>
|
||||||
|
Résumé quotidien
|
||||||
|
</div>
|
||||||
|
<div class=\"card-body\">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=\"row\">
|
||||||
|
<div class=\"col-5\">
|
||||||
|
<div class=\"card mb-4\">
|
||||||
|
<div class=\"card-header\">
|
||||||
|
<i class=\"fas fa-chart-bar me-1\"></i>
|
||||||
|
Liste d'amis
|
||||||
|
</div>
|
||||||
|
<div class=\"card-body\">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=\"col-7\">
|
||||||
|
<div class=\"card mb-4\">
|
||||||
|
<div class=\"card-header\">
|
||||||
|
<i class=\"fas fa-chart-bar me-1\"></i>
|
||||||
|
Messagerie
|
||||||
|
</div>
|
||||||
|
<div class=\"card-body\">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer class=\"py-4 bg-light mt-auto\">
|
||||||
|
<div class=\"container-fluid px-4\">
|
||||||
|
<div class=\"d-flex align-items-center justify-content-between small\">
|
||||||
|
<div class=\"text-muted\">Copyright © HeartTrack 2023</div>
|
||||||
|
<div>
|
||||||
|
<a href=\"#\">Politique de confidentialité</a>
|
||||||
|
·
|
||||||
|
<a href=\"#\">Termes & Conditions d'utilisations</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
<script src=\"js/scripts.js\"></script>
|
||||||
|
<script src=\"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
<script src=\"assets/demo/chart-area-demo.js\"></script>
|
||||||
|
<script src=\"assets/demo/chart-bar-demo.js\"></script>
|
||||||
|
<script src=\"https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/umd/simple-datatables.min.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
<script src=\"js/datatables-simple-demo.js\"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateName()
|
||||||
|
{
|
||||||
|
return "home.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDebugInfo()
|
||||||
|
{
|
||||||
|
return array ( 37 => 1,);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSourceContext()
|
||||||
|
{
|
||||||
|
return new Source("", "home.html", "/home/www/anpinagot/public_html/sae/Web/Sources/src/app/views/Templates/home.html");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,215 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Twig\Environment;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
use Twig\Error\RuntimeError;
|
||||||
|
use Twig\Extension\SandboxExtension;
|
||||||
|
use Twig\Markup;
|
||||||
|
use Twig\Sandbox\SecurityError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||||
|
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||||
|
use Twig\Source;
|
||||||
|
use Twig\Template;
|
||||||
|
|
||||||
|
/* base.html.twig */
|
||||||
|
class __TwigTemplate_83f313b86da35998a96ccc25fa02176c3fca11644e117af297089ca4a85f55ab extends Template
|
||||||
|
{
|
||||||
|
private $source;
|
||||||
|
private $macros = [];
|
||||||
|
|
||||||
|
public function __construct(Environment $env)
|
||||||
|
{
|
||||||
|
parent::__construct($env);
|
||||||
|
|
||||||
|
$this->source = $this->getSourceContext();
|
||||||
|
|
||||||
|
$this->parent = false;
|
||||||
|
|
||||||
|
$this->blocks = [
|
||||||
|
'title' => [$this, 'block_title'],
|
||||||
|
'stylesheets' => [$this, 'block_stylesheets'],
|
||||||
|
'javascripts' => [$this, 'block_javascripts'],
|
||||||
|
'menu' => [$this, 'block_menu'],
|
||||||
|
'body' => [$this, 'block_body'],
|
||||||
|
'script' => [$this, 'block_script'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doDisplay(array $context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
// line 1
|
||||||
|
echo "<!DOCTYPE html>
|
||||||
|
<html lang=\"fr \">
|
||||||
|
<head>
|
||||||
|
<meta charset=\"UTF-8\">
|
||||||
|
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||||
|
<title>";
|
||||||
|
// line 6
|
||||||
|
$this->displayBlock('title', $context, $blocks);
|
||||||
|
echo "</title>
|
||||||
|
|
||||||
|
";
|
||||||
|
// line 8
|
||||||
|
$this->displayBlock('stylesheets', $context, $blocks);
|
||||||
|
// line 12
|
||||||
|
echo "
|
||||||
|
";
|
||||||
|
// line 13
|
||||||
|
$this->displayBlock('javascripts', $context, $blocks);
|
||||||
|
// line 16
|
||||||
|
echo "</head>
|
||||||
|
<body class=\"sb-nav-fixed\">
|
||||||
|
";
|
||||||
|
// line 18
|
||||||
|
$this->displayBlock('menu', $context, $blocks);
|
||||||
|
// line 85
|
||||||
|
echo "
|
||||||
|
";
|
||||||
|
// line 86
|
||||||
|
$this->displayBlock('body', $context, $blocks);
|
||||||
|
// line 87
|
||||||
|
echo "
|
||||||
|
";
|
||||||
|
// line 88
|
||||||
|
$this->displayBlock('script', $context, $blocks);
|
||||||
|
// line 97
|
||||||
|
echo "</body>
|
||||||
|
</html>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 6
|
||||||
|
public function block_title($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 8
|
||||||
|
public function block_stylesheets($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
// line 9
|
||||||
|
echo " <link href=\"../css/styles.css\" rel=\"stylesheet\" />
|
||||||
|
<link href=\"https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.min.css\" rel=\"stylesheet\" />
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 13
|
||||||
|
public function block_javascripts($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
// line 14
|
||||||
|
echo " <script src=\"https://use.fontawesome.com/releases/v6.3.0/js/all.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 18
|
||||||
|
public function block_menu($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
// line 19
|
||||||
|
echo " <nav class=\"sb-topnav navbar navbar-expand navbar-dark bg-dark\">
|
||||||
|
<!-- Navbar Brand-->
|
||||||
|
<img class=\"navbar-brand ps-3\" src=\"../../../public/assets/img/logo.png\">
|
||||||
|
<!-- Sidebar Toggle-->
|
||||||
|
<button class=\"btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0\" id=\"sidebarToggle\" href=\"#!\"><i class=\"fas fa-bars\"></i></button>
|
||||||
|
<!-- Navbar Search-->
|
||||||
|
<form class=\"d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0\">
|
||||||
|
<div class=\"input-group\">
|
||||||
|
<input class=\"form-control\" type=\"text\" placeholder=\"Rechercher...\" aria-label=\"Rechercher...\" aria-describedby=\"btnNavbarSearch\" />
|
||||||
|
<button class=\"btn btn-primary\" id=\"btnNavbarSearch\" type=\"button\"><i class=\"fas fa-search\"></i></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<!-- Navbar-->
|
||||||
|
<ul class=\"navbar-nav ms-auto ms-md-0 me-3 me-lg-4\">
|
||||||
|
<li class=\"nav-item dropdown\">
|
||||||
|
<a class=\"nav-link dropdown-toggle\" id=\"navbarDropdown\" href=\"#\" role=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\"><i class=\"fas fa-user fa-fw\"></i></a>
|
||||||
|
<ul class=\"dropdown-menu dropdown-menu-end\" aria-labelledby=\"navbarDropdown\">
|
||||||
|
<li><a class=\"dropdown-item\" href=\"#!\">Profile</a></li>
|
||||||
|
<li><a class=\"dropdown-item\" href=\"#!\">Paramètres</a></li>
|
||||||
|
<li><hr class=\"dropdown-divider\" /></li>
|
||||||
|
<li><a class=\"dropdown-item\" href=\"#!\">Déconnexion</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<div id=\"layoutSidenav\">
|
||||||
|
<div id=\"layoutSidenav_nav\">
|
||||||
|
<nav class=\"sb-sidenav accordion sb-sidenav-dark\" id=\"sidenavAccordion\">
|
||||||
|
<div class=\"sb-sidenav-menu\">
|
||||||
|
<div class=\"nav\">
|
||||||
|
<div class=\"sb-sidenav-menu-heading\">Menu</div>
|
||||||
|
<a class=\"nav-link\" href=\"home.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/house.png\"></div>
|
||||||
|
Accueil
|
||||||
|
</a>
|
||||||
|
<div class=\"sb-sidenav-menu-heading\">Activités</div>
|
||||||
|
<a class=\"nav-link\" href=\"exercice.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/sprinter.png\"></div>
|
||||||
|
Exercices
|
||||||
|
</a>
|
||||||
|
<a class=\"nav-link\" href=\"analyze.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><i class=\"fas fa-chart-area\"></i></div>
|
||||||
|
Analyses
|
||||||
|
</a>
|
||||||
|
<div class=\"sb-sidenav-menu-heading\">Social</div>
|
||||||
|
<a class=\"nav-link\" href=\"friend.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/group.png\"></div>
|
||||||
|
Amis
|
||||||
|
</a>
|
||||||
|
<a class=\"nav-link\" href=\"coaching.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/coaching.png\"></div>
|
||||||
|
Coaching
|
||||||
|
</a>
|
||||||
|
<a class=\"nav-link\" href=\"mail.html\">
|
||||||
|
<div class=\"sb-nav-link-icon\"><img src=\"assets/img/letter.png\"></div>
|
||||||
|
Messagerie
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=\"sb-sidenav-footer\">
|
||||||
|
<div class=\"small\">Connecté en tant que:</div>
|
||||||
|
{user}
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 86
|
||||||
|
public function block_body($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
}
|
||||||
|
|
||||||
|
// line 88
|
||||||
|
public function block_script($context, array $blocks = [])
|
||||||
|
{
|
||||||
|
$macros = $this->macros;
|
||||||
|
// line 89
|
||||||
|
echo " <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
<script src=\"js/scripts.js\"></script>
|
||||||
|
<script src=\"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
<script src=\"assets/demo/chart-area-demo.js\"></script>
|
||||||
|
<script src=\"assets/demo/chart-bar-demo.js\"></script>
|
||||||
|
<script src=\"https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/umd/simple-datatables.min.js\" crossorigin=\"anonymous\"></script>
|
||||||
|
<script src=\"js/datatables-simple-demo.js\"></script>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateName()
|
||||||
|
{
|
||||||
|
return "base.html.twig";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDebugInfo()
|
||||||
|
{
|
||||||
|
return array ( 191 => 89, 187 => 88, 181 => 86, 112 => 19, 108 => 18, 103 => 14, 99 => 13, 93 => 9, 89 => 8, 83 => 6, 78 => 97, 76 => 88, 73 => 87, 71 => 86, 68 => 85, 66 => 18, 62 => 16, 60 => 13, 57 => 12, 55 => 8, 50 => 6, 43 => 1,);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSourceContext()
|
||||||
|
{
|
||||||
|
return new Source("", "base.html.twig", "/home/www/anpinagot/public_html/sae/Web/Sources/src/app/views/Templates/base.html.twig");
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 27 KiB |
@ -1,9 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__ . '/../vendor/autoload.php';
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
require_once __DIR__ . '/../config/config.php';
|
require_once __DIR__ . '/../config/config.php';
|
||||||
if (APP_ENV === 'console') {
|
|
||||||
require_once __DIR__ . '/../src/console/Console.php';
|
use App\AppCreator;
|
||||||
}
|
use App\Router\Middleware\LoggingMiddleware;
|
||||||
elseif (APP_ENV === 'development') {
|
use App\Router\Request\RequestFactory;
|
||||||
require_once __DIR__ . 'index.html';
|
use Shared\ArgumentControllerResolver;
|
||||||
|
use Shared\IArgumentResolver;
|
||||||
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\FilesystemLoader;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
$appFactory = new AppCreator();
|
||||||
|
$appFactory->registerService(IArgumentResolver::class, ArgumentControllerResolver::class);
|
||||||
|
|
||||||
|
$appFactory->registerService(\Twig\Loader\LoaderInterface::class, function() {
|
||||||
|
return new FilesystemLoader(__DIR__ . '/../src/app/views/Templates');
|
||||||
|
});
|
||||||
|
|
||||||
|
$appFactory->registerService(\Twig\Environment::class,\Twig\Environment::class);
|
||||||
|
|
||||||
|
// Connexion à la base de données
|
||||||
|
// $databaseContext = DatabaseContext::getInstance();
|
||||||
|
|
||||||
|
$appFactory->AddControllers();
|
||||||
|
$app = $appFactory->create();
|
||||||
|
if (!is_null($app)){
|
||||||
|
// Ajout des Middleware
|
||||||
|
/*$app->use(new LoggingMiddleware());*/
|
||||||
|
|
||||||
|
$app->mapControllers();
|
||||||
|
$app->run(RequestFactory::createFromGlobals());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
window.addEventListener('DOMContentLoaded', event => {
|
||||||
|
// Simple-DataTables
|
||||||
|
// https://github.com/fiduswriter/Simple-DataTables/wiki
|
||||||
|
|
||||||
|
const datatablesSimple = document.getElementById('datatablesSimple');
|
||||||
|
if (datatablesSimple) {
|
||||||
|
new simpleDatatables.DataTable(datatablesSimple);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
document.getElementById('saveButton').addEventListener('click', function() {
|
||||||
|
var preferences = {
|
||||||
|
notifications: document.getElementById('notif').checked,
|
||||||
|
theme: document.getElementById('theme').value
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch('/index.php/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(preferences),
|
||||||
|
})
|
||||||
|
.catch((error) => console.error('Error:', error));
|
||||||
|
});
|
@ -0,0 +1,26 @@
|
|||||||
|
/*!
|
||||||
|
* Start Bootstrap - SB Admin v7.0.7 (https://startbootstrap.com/template/sb-admin)
|
||||||
|
* Copyright 2013-2023 Start Bootstrap
|
||||||
|
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE)
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Scripts
|
||||||
|
//
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', event => {
|
||||||
|
|
||||||
|
// Toggle the side navigation
|
||||||
|
const sidebarToggle = document.body.querySelector('#sidebarToggle');
|
||||||
|
if (sidebarToggle) {
|
||||||
|
// Uncomment Below to persist sidebar toggle between refreshes
|
||||||
|
// if (localStorage.getItem('sb|sidebar-toggle') === 'true') {
|
||||||
|
// document.body.classList.toggle('sb-sidenav-toggled');
|
||||||
|
// }
|
||||||
|
sidebarToggle.addEventListener('click', event => {
|
||||||
|
event.preventDefault();
|
||||||
|
document.body.classList.toggle('sb-sidenav-toggled');
|
||||||
|
localStorage.setItem('sb|sidebar-toggle', document.body.classList.contains('sb-sidenav-toggled'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use App\Controller\BaseController;
|
||||||
|
use App\Controller\FrontController;
|
||||||
|
use App\Router\Request\HttpRequest;
|
||||||
|
use App\Router\Middleware\IHttpMiddleware;
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
use App\Router\Route;
|
||||||
|
use App\Views\Directives\Navigate;
|
||||||
|
use Shared\Attributes\Route as RouteAttribute;
|
||||||
|
use App\Router\Router;
|
||||||
|
use App\Router\Session;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class App
|
||||||
|
{
|
||||||
|
private string $appName;
|
||||||
|
private int $version;
|
||||||
|
|
||||||
|
private ?IHttpMiddleware $middlewarePipeline = null;
|
||||||
|
|
||||||
|
private Container $container;
|
||||||
|
|
||||||
|
private Router $router;
|
||||||
|
|
||||||
|
private array $controllers = [];
|
||||||
|
|
||||||
|
private FrontController $frontController;
|
||||||
|
|
||||||
|
public function __construct(string $appName, int $version, \App\Container $diContainer)
|
||||||
|
{
|
||||||
|
$this->appName = $appName;
|
||||||
|
$this->version = $version;
|
||||||
|
$this->container = $diContainer;
|
||||||
|
$this->router = new Router("");
|
||||||
|
$this->frontController = new FrontController($this->router,$this->container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function use(IHttpMiddleware $middleware)
|
||||||
|
{
|
||||||
|
if ($this->middlewarePipeline === null) {
|
||||||
|
$this->middlewarePipeline = $middleware;
|
||||||
|
} else {
|
||||||
|
// Chain the new middleware to the end of the existing pipeline
|
||||||
|
$currentMiddleware = $this->middlewarePipeline;
|
||||||
|
while ($currentMiddleware->getNext() !== null) {
|
||||||
|
$currentMiddleware = $currentMiddleware->getNext();
|
||||||
|
}
|
||||||
|
$currentMiddleware->setNext($middleware);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAppName(): string
|
||||||
|
{
|
||||||
|
return $this->appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* public function twigConfigure(array $extensionClassNames = []): void
|
||||||
|
{
|
||||||
|
if (!$this->container->has(\Twig\Environment::class)) {
|
||||||
|
throw new \LogicException('You cannot use the "twigConfigure" method if the Twig Bundle is not available. Try running "composer require twig/twig".');
|
||||||
|
}
|
||||||
|
|
||||||
|
$twigEnvironment = $this->container->get(\Twig\Environment::class);
|
||||||
|
|
||||||
|
if (empty($extensionClassNames)) {
|
||||||
|
$twigEnvironment->addExtension(new Navigate($this->router));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
foreach ($extensionClassNames as $extensionClassName) {
|
||||||
|
if (class_exists($extensionClassName)) {
|
||||||
|
$extensionInstance = new $extensionClassName();
|
||||||
|
if ($extensionInstance instanceof \Twig\Extension\ExtensionInterface) {
|
||||||
|
$twigEnvironment->addExtension($extensionInstance);
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException("Class '$extensionClassName' does not implement Twig\Extension\ExtensionInterface.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException("Class '$extensionClassName' does not exist.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getVersion(): int
|
||||||
|
{
|
||||||
|
return $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(IRequest $request)
|
||||||
|
{
|
||||||
|
if ($this->middlewarePipeline == null) {
|
||||||
|
return $this->frontController->dispatch($request);
|
||||||
|
}
|
||||||
|
// Exécutez le middleware en utilisant le pipeline
|
||||||
|
return $this->middlewarePipeline->handle($request, function($request) {
|
||||||
|
// Logique de gestion principale de la requête ici
|
||||||
|
$this->frontController->dispatch($request);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \ReflectionException
|
||||||
|
*/
|
||||||
|
public function mapControllers(): void
|
||||||
|
{
|
||||||
|
$classes = $this->container->getAllRegisteredClassNames();
|
||||||
|
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
if ($this->isController($class)) {
|
||||||
|
$this->mapControllerRoutes($class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @throws \ReflectionException
|
||||||
|
*/
|
||||||
|
function mapControllerRoutes(string $controllerClass): void
|
||||||
|
{
|
||||||
|
$reflectionClass = new \ReflectionClass($controllerClass);
|
||||||
|
$attributes = $reflectionClass->getAttributes(RouteAttribute::class);
|
||||||
|
$prefix = '';
|
||||||
|
if (!empty($attributes)) {
|
||||||
|
|
||||||
|
$prefix = $attributes[0]->newInstance()->getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
|
||||||
|
|
||||||
|
foreach ($method->getAttributes(RouteAttribute::class) as $attribute) {
|
||||||
|
|
||||||
|
/** @var RouteAttribute $route */
|
||||||
|
$route = $attribute->newInstance();
|
||||||
|
|
||||||
|
$this->router->addControllerRoute(
|
||||||
|
implode('|', $route->getMethods()),
|
||||||
|
$prefix . $route->getPath(),
|
||||||
|
$controllerClass,
|
||||||
|
$method->getName(),
|
||||||
|
$route->getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isController(string $class): bool
|
||||||
|
{
|
||||||
|
$reflectionClass = new \ReflectionClass($class);
|
||||||
|
return $reflectionClass->isSubclassOf(BaseController::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use App\Controller\BaseController;
|
||||||
|
use Shared\Log;
|
||||||
|
use Twig\Loader\FilesystemLoader;
|
||||||
|
|
||||||
|
class AppCreator
|
||||||
|
{
|
||||||
|
private Container $container;
|
||||||
|
|
||||||
|
private array $services = [];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->container = new Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerService(string $serviceId, callable|string $service): self
|
||||||
|
{
|
||||||
|
$this->container->set($serviceId, $service);
|
||||||
|
$this->services[] = $serviceId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance or perform actions based on the current application environment.
|
||||||
|
*
|
||||||
|
* @return App|null An instance of the App class in the 'development' environment, or null in other environments.
|
||||||
|
*/
|
||||||
|
public function create(): ?App
|
||||||
|
{
|
||||||
|
// Check the application environment
|
||||||
|
switch (APP_ENV) {
|
||||||
|
case 'console':
|
||||||
|
// Load the Console.php file in case of the 'console' environment
|
||||||
|
require_once __DIR__ . '/../console/Console.php';
|
||||||
|
break;
|
||||||
|
case 'development':
|
||||||
|
// Create a new instance of the App class in the 'development' environment
|
||||||
|
return new App("HeartTrack", 1, $this->container);
|
||||||
|
break;
|
||||||
|
case 'html':
|
||||||
|
// Load the index.test.php file in case of the 'html' environment
|
||||||
|
require_once __DIR__ . '/index.test.php';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Handle other environment cases here, if necessary
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function AddControllers($namespacePrefix = 'App\Controller', $pathToControllers = __DIR__ . '/controller'): self
|
||||||
|
{
|
||||||
|
$controllerFiles = glob($pathToControllers . '/*.php');
|
||||||
|
|
||||||
|
foreach ($controllerFiles as $file) {
|
||||||
|
// Get class name from file name
|
||||||
|
$class = basename($file, '.php');
|
||||||
|
$fullClassName = $namespacePrefix . '\\' . $class;
|
||||||
|
if (!class_exists($fullClassName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use reflection to check if class extends BaseController
|
||||||
|
$reflectionClass = new \ReflectionClass($fullClassName);
|
||||||
|
if ($reflectionClass->isSubclassOf(BaseController::class)) {
|
||||||
|
// Register in DI container
|
||||||
|
$this->container->set($fullClassName, function () use ($fullClassName) {
|
||||||
|
$controllerInstance = new $fullClassName();
|
||||||
|
$controllerInstance->setContainer($this->container);
|
||||||
|
return $controllerInstance;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getServiceRegistered(): array
|
||||||
|
{
|
||||||
|
return $this->services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
use Shared\Log;
|
||||||
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\FilesystemLoader;
|
||||||
|
|
||||||
|
class Container implements ContainerInterface
|
||||||
|
{
|
||||||
|
private array $entries = [];
|
||||||
|
|
||||||
|
public function get(string $id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($this->has($id)) {
|
||||||
|
$entry = $this->entries[$id];
|
||||||
|
if (is_callable($entry)) {
|
||||||
|
|
||||||
|
return $entry($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->resolve($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function has(string $id): bool
|
||||||
|
{
|
||||||
|
return isset($this->entries[$id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set(string $id, callable|string $concrete): void
|
||||||
|
{
|
||||||
|
$this->entries[$id] = $concrete;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(string $id)
|
||||||
|
{
|
||||||
|
// 1. Inspect the class that we are trying to get from the container
|
||||||
|
try {
|
||||||
|
$reflectionClass = new \ReflectionClass($id);
|
||||||
|
} catch (\ReflectionException $e) {
|
||||||
|
throw new \Exception($e->getMessage(), $e->getCode(), $e);
|
||||||
|
}
|
||||||
|
if (!$reflectionClass->isInstantiable()) {
|
||||||
|
throw new \Exception('Class "' . $id . '" is not instantiable');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Inspect the constructor of the class
|
||||||
|
$constructor = $reflectionClass->getConstructor();
|
||||||
|
|
||||||
|
if (!$constructor) {
|
||||||
|
return new $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Inspect the constructor parameters (dependencies)
|
||||||
|
$parameters = $constructor->getParameters();
|
||||||
|
|
||||||
|
if (!$parameters) {
|
||||||
|
return new $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. If the constructor parameter is a class then try to resolve that class using the container
|
||||||
|
$dependencies = array_map(
|
||||||
|
function (\ReflectionParameter $param) use ($id) {
|
||||||
|
$name = $param->getName();
|
||||||
|
$type = $param->getType();
|
||||||
|
|
||||||
|
// Check for a default value
|
||||||
|
if ($param->isDefaultValueAvailable()) {
|
||||||
|
return $param->getDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$type) {
|
||||||
|
throw new \Exception(
|
||||||
|
'Failed to resolve class "' . $id . '" because param "' . $name . '" is missing a type hint'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type instanceof \ReflectionUnionType) {
|
||||||
|
throw new \Exception(
|
||||||
|
'Failed to resolve class "' . $id . '" because of union type for param "' . $name . '"'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
|
||||||
|
return $this->get($type->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \Exception(
|
||||||
|
'Failed to resolve class "' . $id . '" because invalid param "' . $name . '"'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
$parameters
|
||||||
|
);
|
||||||
|
|
||||||
|
return $reflectionClass->newInstanceArgs($dependencies);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllRegisteredClassNames(): array
|
||||||
|
{
|
||||||
|
return array_keys($this->entries);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// namespace App\Controller;
|
||||||
|
|
||||||
|
// use App\Container;
|
||||||
|
// use App\Router\Request\IRequest;
|
||||||
|
// use App\Router\Response\Response;
|
||||||
|
// use Shared\Attributes\Route;
|
||||||
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
|
// class AthleteController extends BaseController
|
||||||
|
// {
|
||||||
|
|
||||||
|
// #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
|
||||||
|
// public function searchUser(string $username, IRequest $req): Response
|
||||||
|
// {
|
||||||
|
// $taberror = [];
|
||||||
|
// $utiliArray = [
|
||||||
|
// [
|
||||||
|
// 'nom' => 'John',
|
||||||
|
// 'prenom' => 'Doe',
|
||||||
|
// 'img' => 'john_doe',
|
||||||
|
// 'username' => 'johndoe',
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'nom' => 'Alice',
|
||||||
|
// 'prenom' => 'Smith',
|
||||||
|
// 'img' => 'alice_smith',
|
||||||
|
// 'username' => 'alicesmith',
|
||||||
|
// ],
|
||||||
|
// ];
|
||||||
|
// // if(!Validation::val_string($name)){
|
||||||
|
// try {
|
||||||
|
// //code...
|
||||||
|
// // $model->userMgr->getUser($name);
|
||||||
|
// return $this->render('./page/addfriend.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => $utiliArray,
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => [],
|
||||||
|
// 'responce' => "Notification d'ajout envoyée à $username"
|
||||||
|
// ]);
|
||||||
|
// } catch (\Throwable $th) {
|
||||||
|
// //throw $th;
|
||||||
|
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route(path: '/analyses', name: 'analyses', methods: ['GET'])]
|
||||||
|
// public function analyses(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/analyze.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8
|
||||||
|
// public function exercice(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/exercice.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route(path: '/add-friend', name: 'add-friend', methods: ['POST'])]
|
||||||
|
// public function addFriend(string $username, IRequest $req): Response
|
||||||
|
// {
|
||||||
|
// $taberror = [];
|
||||||
|
// $utiliArray = [
|
||||||
|
// [
|
||||||
|
// 'nom' => 'John',
|
||||||
|
// 'prenom' => 'Doe',
|
||||||
|
// 'img' => 'john_doe',
|
||||||
|
// 'username' => 'johndoe',
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'nom' => 'Alice',
|
||||||
|
// 'prenom' => 'Smith',
|
||||||
|
// 'img' => 'alice_smith',
|
||||||
|
// 'username' => 'alicesmith',
|
||||||
|
// ],
|
||||||
|
// ];
|
||||||
|
// // if(!Validation::val_string($name)){
|
||||||
|
// try {
|
||||||
|
// //code...
|
||||||
|
// // $model->userMgr->addFriend($name);
|
||||||
|
// return $this->render('./page/addfriend.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => $utiliArray,
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => [],
|
||||||
|
// 'responce' => "Notification d'ajout envoyée à $username"
|
||||||
|
// ]);
|
||||||
|
// } catch (\Throwable $th) {
|
||||||
|
// //throw $th;
|
||||||
|
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route(path: '/delete-friend', name: 'delete-friend', methods: ['POST'])]
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/friend', name: 'friend', methods: ['GET'])]
|
||||||
|
// public function friend(): Response
|
||||||
|
// {
|
||||||
|
// $utiliArray = [
|
||||||
|
// [
|
||||||
|
// 'nom' => 'John',
|
||||||
|
// 'prenom' => 'Doe',
|
||||||
|
// 'img' => 'john_doe',
|
||||||
|
// 'username' => 'johndoe',
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'nom' => 'Alice',
|
||||||
|
// 'prenom' => 'Smith',
|
||||||
|
// 'img' => 'alice_smith',
|
||||||
|
// 'username' => 'alicesmith',
|
||||||
|
// ],
|
||||||
|
// ];
|
||||||
|
// // $this->Auth->getUser->role->getFriends
|
||||||
|
// return $this->render('./page/addfriend.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => $utiliArray,
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => [],
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// namespace App\Controller;
|
||||||
|
|
||||||
|
// use App\Container;
|
||||||
|
// use App\Router\Request\IRequest;
|
||||||
|
// use App\Router\Response\Response;
|
||||||
|
// use Shared\Attributes\Route;
|
||||||
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
|
// class AuthController extends BaseController
|
||||||
|
// {
|
||||||
|
// #[Route('/login', name: 'login')]
|
||||||
|
// public function login(?string $username, ?string $password ,IRequest $request): Response {
|
||||||
|
// // if user is already logged in, don't display the login page again
|
||||||
|
// if ($user) {
|
||||||
|
// return $this->redirectToRoute('blog_index');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // this statement solves an edge-case: if you change the locale in the login
|
||||||
|
// // page, after a successful login you are redirected to a page in the previous
|
||||||
|
// // locale. This code regenerates the referrer URL whenever the login page is
|
||||||
|
// // browsed, to ensure that its locale is always the current one.
|
||||||
|
// $this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index'));
|
||||||
|
|
||||||
|
// return $this->render('security/login.html.twig', [
|
||||||
|
// // last username entered by the user (if any)
|
||||||
|
// 'last_username' => $helper->getLastUsername(),
|
||||||
|
// // last authentication error (if any)
|
||||||
|
// 'error' => $helper->getLastAuthenticationError(),
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route('/login', name: 'login')]
|
||||||
|
// public function login(?string $username, ?string $password ,IRequest $request): Response {
|
||||||
|
// // if user is already logged in, don't display the login page again
|
||||||
|
// if ($user) {
|
||||||
|
// return $this->redirectToRoute('blog_index');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // this statement solves an edge-case: if you change the locale in the login
|
||||||
|
// // page, after a successful login you are redirected to a page in the previous
|
||||||
|
// // locale. This code regenerates the referrer URL whenever the login page is
|
||||||
|
// // browsed, to ensure that its locale is always the current one.
|
||||||
|
// $this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index'));
|
||||||
|
|
||||||
|
// return $this->render('security/login.html.twig', [
|
||||||
|
// // last username entered by the user (if any)
|
||||||
|
// 'last_username' => $helper->getLastUsername(),
|
||||||
|
// // last authentication error (if any)
|
||||||
|
// 'error' => $helper->getLastAuthenticationError(),
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// function inscription() {
|
||||||
|
// $model = new ModelVisitor();
|
||||||
|
// $log=Validation::clean_string($_POST['pseudo']);
|
||||||
|
// $mdp=Validation::clean_string($_POST['password']);
|
||||||
|
// if($model->createAUser($log,$mdp)){
|
||||||
|
// if(ModelUser::login($log, $mdp)){
|
||||||
|
// UserControler::displayView();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// function login() {
|
||||||
|
// $model = new ModelVisitor();
|
||||||
|
// if(!isset($_POST['pseudo']) || !isset($_POST['password'])) throw new Exception(" some wrong with credentials !!!!!");
|
||||||
|
// $log=Validation::clean_string($_POST['pseudo']);
|
||||||
|
// $mdp=Validation::clean_string($_POST['password']);
|
||||||
|
// if(ModelUser::login($log, $mdp)){
|
||||||
|
// UserControler::displayView();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Container;
|
||||||
|
use App\Router\Response\RedirectResponse;
|
||||||
|
use App\Router\Response\Response;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
|
||||||
|
abstract class BaseController
|
||||||
|
{
|
||||||
|
protected ContainerInterface $container;
|
||||||
|
|
||||||
|
public function setContainer(ContainerInterface $container)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderView(string $view, array $parameters = []): string
|
||||||
|
{
|
||||||
|
if (!$this->container->has(\Twig\Environment::class)) {
|
||||||
|
throw new \LogicException('You cannot use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->container->get(\Twig\Environment::class)->render($view, $parameters);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Renders a view.
|
||||||
|
*
|
||||||
|
* If an invalid form is found in the list of parameters, a 422 status code is returned.
|
||||||
|
* Forms found in parameters are auto-cast to form views.
|
||||||
|
*/
|
||||||
|
protected function render(string $view, array $parameters = [], Response $response = null): Response
|
||||||
|
{
|
||||||
|
$content = $this->renderView($view, $parameters);
|
||||||
|
$response ??= new Response();
|
||||||
|
|
||||||
|
/* if (200 === $response->getStatusCode()) {
|
||||||
|
foreach ($parameters as $v) {
|
||||||
|
if ($v instanceof FormInterface && $v->isSubmitted() && !$v->isValid()) {
|
||||||
|
$response->setStatusCode(422);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$response->setContent($content);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirect(string $url, int $status = 302): RedirectResponse
|
||||||
|
{
|
||||||
|
return new RedirectResponse($url, $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||||
|
{
|
||||||
|
return $this->redirect($this->generateUrl($route, $parameters), $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO : Should hanle ierror if the route is not existing
|
||||||
|
* */
|
||||||
|
protected function generateUrl(string $route, array $parameters = []): string
|
||||||
|
{
|
||||||
|
return $this->container->get(\App\Router\Router::class)->generate($route, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// namespace App\Controller;
|
||||||
|
|
||||||
|
// use App\Container;
|
||||||
|
// use App\Router\Request\IRequest;
|
||||||
|
// use App\Router\Response\Response;
|
||||||
|
// use App\Router\Response\IResponse;
|
||||||
|
|
||||||
|
// use Shared\Attributes\Route;
|
||||||
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/coach', name: 'coach')]
|
||||||
|
// class CoachController extends BaseController
|
||||||
|
// {
|
||||||
|
|
||||||
|
// private ICoachManager $coachManager;
|
||||||
|
// private $security;
|
||||||
|
|
||||||
|
// public function __construct(DataManager $dataManager, Security $security)
|
||||||
|
// {
|
||||||
|
// $this->coachManager = $dataManager->coachMgr;
|
||||||
|
// $this->security = $security;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route(path: '/', name: 'home', methods: ['GET'])]
|
||||||
|
// public function index(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/home.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route('/global-stats', name: 'coach_global_stats', methods: ['GET'])]
|
||||||
|
// public function globalStats(): Response
|
||||||
|
// {
|
||||||
|
// // Add logic to fetch and process global stats
|
||||||
|
// return $this->render('coach/global_stats.html.twig');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8
|
||||||
|
// public function exercice(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/exercice.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
|
||||||
|
// public function coaching(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/coaching.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route('/list-athletes', name: 'coach_list_athletes')]
|
||||||
|
// public function listAthletes(): Response
|
||||||
|
// {
|
||||||
|
// $coach = $this->security->getUser();
|
||||||
|
// $athletes = $this->coachManager->getAthletesForCoach($coach);
|
||||||
|
|
||||||
|
// return $this->render('coach/list_athletes.html.twig', [
|
||||||
|
// 'athletes' => $athletes,
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
// #[Route('/athlete-analysis/{athleteId}', name: 'coach_athlete_analysis', methods: ['GET'])]
|
||||||
|
// public function athleteAnalysis($athleteId): Response
|
||||||
|
// {
|
||||||
|
// // Fetch and process data specific to the athlete
|
||||||
|
// return $this->render('coach/athlete_analysis.html.twig', [
|
||||||
|
// 'athleteId' => $athleteId,
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[Route('/add-athlete/{athleteId}', name: 'coach_add_athlete', methods: ['POST'])]
|
||||||
|
// public function addAthlete(IRequest $request, $athleteId): IResponse
|
||||||
|
// {
|
||||||
|
// // Implement logic to add athlete
|
||||||
|
// // ...
|
||||||
|
|
||||||
|
// return $this->redirectToRoute('coach_list_athletes');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // #[Route('/remove-athlete', name: 'coach_remove_athlete', methods: ['POST'])]
|
||||||
|
// // public function removeAthlete(int $athleteId, IRequest $request): IResponse
|
||||||
|
// // {
|
||||||
|
|
||||||
|
// // return $this->redirectToRoute("/athletes");
|
||||||
|
// // }
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
@ -0,0 +1,592 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Container;
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
use App\Router\Response\Response;
|
||||||
|
use Shared\Attributes\Route;
|
||||||
|
use Twig\Environment;
|
||||||
|
use Data\Core\Preferences;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
// TODO : Remove this BaseClass
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
private Environment $twig;
|
||||||
|
private Preferences $preference;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
session_start();
|
||||||
|
$this->preference = new Preferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/', name: 'home', methods: ['GET'])]
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/home.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/analyses', name: 'analyses', methods: ['GET'])]
|
||||||
|
public function analyses(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/analyze.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/activity', name: 'activity', methods: ['GET'])]
|
||||||
|
public function activity(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/activity.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8
|
||||||
|
public function exercice(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/exercice.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8
|
||||||
|
public function exercices(String $type, String $intensite, String $date, IRequest $req): Response
|
||||||
|
{
|
||||||
|
$exercicesArray = [
|
||||||
|
[
|
||||||
|
'date' => $date,
|
||||||
|
'type' => $type,
|
||||||
|
'intensite' => $intensite,
|
||||||
|
'status' => 'A venur',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return $this->render('./page/exercice.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => $exercicesArray,
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
|
||||||
|
public function searchUser(string $username, IRequest $req): Response
|
||||||
|
{
|
||||||
|
$taberror = [];
|
||||||
|
// FILTER
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
// if(!Validation::val_string($name)){
|
||||||
|
try {
|
||||||
|
//code...
|
||||||
|
// $model->userMgr->addFriend($name);
|
||||||
|
return $this->render('./page/addfriend.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => $utiliArray,
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
'responce' => "Notification d'ajout envoyée à $username"
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
//throw $th;
|
||||||
|
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
|
||||||
|
public function searchMember(string $username, IRequest $req): Response
|
||||||
|
{
|
||||||
|
$taberror = [];
|
||||||
|
// FILTER
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
// if(!Validation::val_string($name)){
|
||||||
|
try {
|
||||||
|
//code...
|
||||||
|
// $model->userMgr->addFriend($name);
|
||||||
|
return $this->render('./page/addmember.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => $utiliArray,
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
'responce' => "Notification d'ajout envoyée à $username"
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
//throw $th;
|
||||||
|
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/add-member', name: 'add-member', methods: ['POST'])]
|
||||||
|
public function addmember(string $username, IRequest $req): Response
|
||||||
|
{
|
||||||
|
$taberror = [];
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
// if(!Validation::val_string($name)){
|
||||||
|
try {
|
||||||
|
//code...
|
||||||
|
// $model->userMgr->addFriend($name);
|
||||||
|
return $this->render('./page/addmember.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => $utiliArray,
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
'responce' => "Notification d'ajout envoyée à $username"
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
//throw $th;
|
||||||
|
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/member', name: 'member', methods: ['GET'])]
|
||||||
|
public function member(): Response
|
||||||
|
{
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return $this->render('./page/addmember.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => $utiliArray,
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/add-friend', name: 'add-friend', methods: ['POST'])]
|
||||||
|
public function addFriend(string $username, IRequest $req): Response
|
||||||
|
{
|
||||||
|
$taberror = [];
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
// if(!Validation::val_string($name)){
|
||||||
|
try {
|
||||||
|
//code...
|
||||||
|
// $model->userMgr->addFriend($name);
|
||||||
|
return $this->render('./page/addfriend.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => $utiliArray,
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
'responce' => "Notification d'ajout envoyée à $username"
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
//throw $th;
|
||||||
|
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/friend', name: 'friend', methods: ['GET'])]
|
||||||
|
public function friend(): Response
|
||||||
|
{
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return $this->render('./page/addfriend.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => $utiliArray,
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/friendlist', name: 'friendlist', methods: ['POST'])]
|
||||||
|
public function friendlist(string $username, IRequest $req): Response
|
||||||
|
{
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'john_doe',
|
||||||
|
'username' => 'johndoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'alice_smith',
|
||||||
|
'username' => 'alicesmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
/* TODO */
|
||||||
|
|
||||||
|
// -> Enlever ou bloquer un utilisateur en fonction de son username
|
||||||
|
|
||||||
|
return $this->render('./page/friend.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => $utiliArray,
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/friendlist', name: 'friendlist2', methods: ['GET'])]
|
||||||
|
public function friendlist2(): Response
|
||||||
|
{
|
||||||
|
$utiliArray = [
|
||||||
|
[
|
||||||
|
'nom' => 'John',
|
||||||
|
'prenom' => 'Doe',
|
||||||
|
'img' => 'test',
|
||||||
|
'status' => 'johndoe',
|
||||||
|
'username' => 'jdoe',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nom' => 'Alice',
|
||||||
|
'prenom' => 'Smith',
|
||||||
|
'img' => 'test2',
|
||||||
|
'status' => 'alicesmith',
|
||||||
|
'username' => 'asmith',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return $this->render('./page/friend.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => $utiliArray,
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
|
||||||
|
public function coaching(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/coaching.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
||||||
|
public function mail(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/mail.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/import', name: 'import', methods: ['GET'])]
|
||||||
|
public function import(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/import.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/settings', name: 'settings', methods: ['GET'])]
|
||||||
|
public function settings(IRequest $req): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/settings.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/profile', name: 'profile', methods: ['GET'])]
|
||||||
|
public function profile(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/profile.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/preferences', name: 'preferences', methods: ['POST'])]
|
||||||
|
public function preferences(string $theme, IRequest $req): Response
|
||||||
|
{
|
||||||
|
/*TODO*/
|
||||||
|
|
||||||
|
// VALIDER LES DONNEES
|
||||||
|
$this->preference->majCookie($theme);
|
||||||
|
|
||||||
|
return $this->render('./page/settings.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/psettings', name: 'psettings', methods: ['POST'])]
|
||||||
|
public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return $this->render('./page/settings.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => $prenom,
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/mdp', name: 'mdp', methods: ['POST'])]
|
||||||
|
public function mdp(string $ancienMotDePasse,string $nouveauMotDePasse,string $confirmerMotDePasse, IRequest $req): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
||||||
|
|
||||||
|
return $this->render('./page/settings.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Controller;
|
||||||
|
use App\Container;
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
use App\Router\Response\Response;
|
||||||
|
use App\Router\Router;
|
||||||
|
use Shared\Exception\NotFoundHttpException;
|
||||||
|
use Shared\Exception\NotImplementedException;
|
||||||
|
use Shared\IArgumentResolver;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class FrontController {
|
||||||
|
private Router $router;
|
||||||
|
|
||||||
|
private Container $container;
|
||||||
|
|
||||||
|
public function __construct(Router $router, Container $container) {
|
||||||
|
$this->router = $router;
|
||||||
|
$this->container = $container;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispatch(IRequest $request) {
|
||||||
|
try {
|
||||||
|
$match = $this->router->match($request);
|
||||||
|
if (!is_null($match)) {
|
||||||
|
$method = $match['target'];
|
||||||
|
|
||||||
|
$controller = $this->getController($match['target']);
|
||||||
|
$callable = array($controller,$method[1]);
|
||||||
|
$request->addToBody($match['params']);
|
||||||
|
|
||||||
|
if (!is_callable($callable)){
|
||||||
|
throw new NotImplementedException('Controller target is not callable' .'Handle when route target is not a callable : not handle');
|
||||||
|
}
|
||||||
|
$argumentResolver = $this->container->get(IArgumentResolver::class);
|
||||||
|
$arguments = $argumentResolver->getArguments($request, $callable);
|
||||||
|
|
||||||
|
// check role
|
||||||
|
$response = call_user_func_array($callable, $arguments);
|
||||||
|
|
||||||
|
// should handle response properly like if it's a HTML, STING, JSON,....
|
||||||
|
$response->send();
|
||||||
|
} else {
|
||||||
|
$this->handleError(404, "Page not found");
|
||||||
|
}
|
||||||
|
} catch (NotFoundHttpException $e) {
|
||||||
|
$this->handleError(404, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getController($controllerSpec) {
|
||||||
|
if (is_array($controllerSpec)) {
|
||||||
|
$controllerName = $controllerSpec[0];
|
||||||
|
} else {
|
||||||
|
$controllerName = $controllerSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->container->get($controllerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : Don't work need Antoine help
|
||||||
|
private function handleError(int $statusCode, $message) : void {
|
||||||
|
if (!$this->container->has(\Twig\Environment::class)) {
|
||||||
|
throw new \LogicException('You cannot use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new Response($this->container->get(\Twig\Environment::class)->render('./error/error.html.twig',['title'=> $message , "code" => $statusCode, "name" => $message, "descr" => $message ]),$statusCode);
|
||||||
|
$response->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// namespace App\Controller;
|
||||||
|
|
||||||
|
// use App\Container;
|
||||||
|
// use App\Router\Request\IRequest;
|
||||||
|
// use App\Router\Response\Response;
|
||||||
|
// use Shared\Attributes\Route;
|
||||||
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
|
// class HeartRateController extends BaseController
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/import', name: 'import', methods: ['GET'])]
|
||||||
|
// public function import(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/import.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
@ -0,0 +1,17 @@
|
|||||||
|
<!-- #[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
||||||
|
public function mail(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/mail.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
} -->
|
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// namespace App\Controller;
|
||||||
|
|
||||||
|
// use App\Container;
|
||||||
|
// use App\Router\Request\IRequest;
|
||||||
|
// use App\Router\Response\Response;
|
||||||
|
// use Shared\Attributes\Route;
|
||||||
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
|
// class UserController extends BaseController
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/', name: 'home', methods: ['GET'])]
|
||||||
|
// public function index(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/home.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/settings', name: 'settings', methods: ['GET'])]
|
||||||
|
// public function settings(IRequest $req): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/settings.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/preferences', name: 'preferences', methods: ['POST'])]
|
||||||
|
// public function preferences(string $theme, IRequest $req): Response
|
||||||
|
// {
|
||||||
|
// /*TODO*/
|
||||||
|
|
||||||
|
// // VALIDER LES DONNEES
|
||||||
|
// $this->preference->majCookie($theme);
|
||||||
|
|
||||||
|
// return $this->render('./page/settings.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
$listF= array (
|
||||||
|
"a" => array("img" => "test","nom" => "Kilou", "prenom" => "Clément", "status" => "En ligne"),
|
||||||
|
"b" => array("img" => "test2","nom" => "Kilou", "prenom" => "Frédérique", "status" => "En ligne"),
|
||||||
|
"c" => array("img" => "test3","nom" => "Kilou", "prenom" => "Hugo", "status" => "Hors ligne")
|
||||||
|
);
|
||||||
|
|
||||||
|
$listMe= array (
|
||||||
|
"a" => array("img" => "test","nom" => "Kilou", "prenom" => "Clément", "status" => "En ligne"),
|
||||||
|
"b" => array("img" => "test2","nom" => "Kilou", "prenom" => "Frédérique", "status" => "En ligne"),
|
||||||
|
"c" => array("img" => "test3","nom" => "Kilou", "prenom" => "Hugo", "status" => "Hors ligne")
|
||||||
|
);
|
||||||
|
|
||||||
|
$listA= array (
|
||||||
|
"a" => array("date" => "29/11/18","type" => "Nage", "bpm" => "116", "kmh" => "3.0","distance" => "0.6"),
|
||||||
|
"b" => array("date" => "27/11/18","type" => "Sprint", "bpm" => "143", "kmh" => "19.0","distance" => "4.2"),
|
||||||
|
"c" => array("date" => "23/11/18","type" => "Cyclisme", "bpm" => "126", "kmh" => "27.0","distance" => "30.0")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$listM= array (
|
||||||
|
"a" => array("lu" => "false","nom" => "Julien", "prenom" => "Clément", "message" => "Demande d'exercice"),
|
||||||
|
"b" => array("lu" => "true","nom" => "Ferdiloi", "prenom" => "Frédérique", "message" => "Coaching"),
|
||||||
|
"c" => array("lu" => "true","nom" => "Kuliqo", "prenom" => "Raphael", "message" => "Rendez-vous")
|
||||||
|
);
|
||||||
|
|
||||||
|
$listE= array (
|
||||||
|
"a" => array("date" => "20/10/23","type" => "Natation", "intensite" => "Fort", "status" => "Programmé"),
|
||||||
|
"b" => array("date" => "16/10/23","type" => "Boxe anglaise", "intensite" => "Moyen", "status" => "Fini"),
|
||||||
|
"c" => array("date" => "10/10/23","type" => "Cyclisme", "intensite" => "Moyen", "status" => "Fini")
|
||||||
|
);
|
||||||
|
|
||||||
|
$infoUser= array("img" => "test2", "nom"=>"Polika", "prenom" => "Amandine", "dateNaiss" => "24/05/1993", "favSport" => "Natation", "coach" => "M.Bastien", "description" => "Salut, c'est Frigiel");
|
||||||
|
|
||||||
|
$loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/views/Templates');
|
||||||
|
$twig = new \Twig\Environment($loader);
|
||||||
|
|
||||||
|
$template=$twig->load('./page/exercice.html.twig');
|
||||||
|
$template->display([
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Amandine",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => $listF,
|
||||||
|
'analyzes' => $listA,
|
||||||
|
'mails' => $listM,
|
||||||
|
'users' => $listF,
|
||||||
|
'infoUser' => $infoUser,
|
||||||
|
'exos' => $listE,
|
||||||
|
'member' => $listMe
|
||||||
|
]);
|
||||||
|
?>
|
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single route in the application.
|
||||||
|
*/
|
||||||
|
class Route
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the route.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private ?string $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path for the route.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callable to be executed when the route is matched.
|
||||||
|
*
|
||||||
|
* @var callable
|
||||||
|
*/
|
||||||
|
private $callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the Route.
|
||||||
|
*
|
||||||
|
* @param string $path The path for the route.
|
||||||
|
* @param callable $callable The callable to be executed for this route.
|
||||||
|
* @param array|null $params Optional parameters for the route.
|
||||||
|
* @param string|null $name Optional name for the route.
|
||||||
|
*/
|
||||||
|
public function __construct(string $path, callable $callable, array $params = null, string $name = null)
|
||||||
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
$this->callable = $callable;
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the route.
|
||||||
|
*
|
||||||
|
* @return string|null The name of the route.
|
||||||
|
*/
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the route.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name to set.
|
||||||
|
*/
|
||||||
|
public function setName(?string $name): void
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the callable associated with the route.
|
||||||
|
*
|
||||||
|
* @return callable The callable for this route.
|
||||||
|
*/
|
||||||
|
public function getCallable()
|
||||||
|
{
|
||||||
|
return $this->callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the path for the route.
|
||||||
|
*
|
||||||
|
* @return string The path for the route.
|
||||||
|
*/
|
||||||
|
public function getPath(): string
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the callable for the route.
|
||||||
|
*
|
||||||
|
* @param callable $callable The callable to set for this route.
|
||||||
|
*/
|
||||||
|
public function setCallable(callable $callable)
|
||||||
|
{
|
||||||
|
$this->callable = $callable;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Router;
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
/**
|
||||||
|
* Router class to manage a collection of routes in the application.
|
||||||
|
* It provides functionalities to add routes and check if a given URL matches any of the defined routes.
|
||||||
|
*/
|
||||||
|
class Router {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base path for routing.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of routes.
|
||||||
|
*
|
||||||
|
* @var \AltoRouter
|
||||||
|
*/
|
||||||
|
private \AltoRouter $routes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supported HTTP verbs.
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
public static $verbs = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Router.
|
||||||
|
*
|
||||||
|
* @param string $path The base path for the router.
|
||||||
|
*/
|
||||||
|
public function __construct(string $path = "/PHP/project/index.php") {
|
||||||
|
$this->path = $path;
|
||||||
|
$this->routes = new \AltoRouter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new Route to the collection.
|
||||||
|
*
|
||||||
|
* @param string $method The HTTP method.
|
||||||
|
* @param Route $route The route object.
|
||||||
|
* @throws \InvalidArgumentException If method is not supported.
|
||||||
|
*/
|
||||||
|
public function add(string $method, Route $route) {
|
||||||
|
if (!in_array($method, self::$verbs)) {
|
||||||
|
throw new \InvalidArgumentException("Method not supported");
|
||||||
|
}
|
||||||
|
$this->routes->map($method, $route->getPath(), $route->getCallable(), $route->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a route for a controller action.
|
||||||
|
*
|
||||||
|
* @param string $method The HTTP method.
|
||||||
|
* @param string $path The path for the route.
|
||||||
|
* @param mixed $controller The controller object.
|
||||||
|
* @param string $action The action method in the controller.
|
||||||
|
* @param string $name (Optional) The name of the route.
|
||||||
|
* @throws \InvalidArgumentException If method is not supported.
|
||||||
|
*/
|
||||||
|
public function addControllerRoute(string $method, string $path, $controller, string $action, string $name = '') {
|
||||||
|
if (!in_array($method, self::$verbs)) {
|
||||||
|
throw new \InvalidArgumentException("Method not supported");
|
||||||
|
}
|
||||||
|
$this->routes->map($method, $path, [$controller, $action], $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement the extractParams method.
|
||||||
|
// public function extractParams(string $path) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a GET route.
|
||||||
|
*
|
||||||
|
* @param string $path The path for the route.
|
||||||
|
* @param callable $callable The callback function.
|
||||||
|
* @param string $name The name of the route.
|
||||||
|
*/
|
||||||
|
public function get(string $path, callable $callable, $name) {
|
||||||
|
$this->routes->map('GET', $path, $callable, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Similar methods for post, put, etc. can be added here.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the request can be processed.
|
||||||
|
*
|
||||||
|
* @param IRequest $request The request object.
|
||||||
|
* @return array|null The matched route or null if no match.
|
||||||
|
*/
|
||||||
|
public function match(IRequest $request): ?array {
|
||||||
|
return $this->routes->match($request->getRequestUri(), $request->getMethod()) ?: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all routes.
|
||||||
|
*
|
||||||
|
* @return array The array of routes.
|
||||||
|
*/
|
||||||
|
public function getRoutes() {
|
||||||
|
return []; // TODO: Implement the actual logic to return routes.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function generate (string $routeName, array $params = array()): string
|
||||||
|
{
|
||||||
|
return $this->routes->generate($routeName,$params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Use the static method getInstance to get the object.
|
||||||
|
*/
|
||||||
|
namespace App\Router;
|
||||||
|
|
||||||
|
class Session
|
||||||
|
{
|
||||||
|
const SESSION_STARTED = TRUE;
|
||||||
|
const SESSION_NOT_STARTED = FALSE;
|
||||||
|
|
||||||
|
// The state of the session
|
||||||
|
private $sessionState = self::SESSION_NOT_STARTED;
|
||||||
|
|
||||||
|
// THE only instance of the class
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns THE instance of 'Session'.
|
||||||
|
* The session is automatically initialized if it wasn't.
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
**/
|
||||||
|
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if ( !isset(self::$instance))
|
||||||
|
{
|
||||||
|
self::$instance = new self;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$instance->startSession();
|
||||||
|
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Re)starts the session.
|
||||||
|
*
|
||||||
|
* @return bool TRUE if the session has been initialized, else FALSE.
|
||||||
|
**/
|
||||||
|
|
||||||
|
private function startSession()
|
||||||
|
{
|
||||||
|
if ( $this->sessionState == self::SESSION_NOT_STARTED )
|
||||||
|
{
|
||||||
|
$this->sessionState = session_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sessionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores datas in the session.
|
||||||
|
* Example: $instance->foo = 'bar';
|
||||||
|
*
|
||||||
|
* @param name Name of the datas.
|
||||||
|
* @param value Your datas.
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
|
||||||
|
public function __set( $name , $value )
|
||||||
|
{
|
||||||
|
$_SESSION[$name] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets datas from the session.
|
||||||
|
* Example: echo $instance->foo;
|
||||||
|
*
|
||||||
|
* @param name Name of the datas to get.
|
||||||
|
* @return mixed Datas stored in session.
|
||||||
|
**/
|
||||||
|
|
||||||
|
public function __get( string $name )
|
||||||
|
{
|
||||||
|
if ( isset($_SESSION[$name]))
|
||||||
|
{
|
||||||
|
return $_SESSION[$name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function __isset( $name )
|
||||||
|
{
|
||||||
|
return isset($_SESSION[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function __unset( $name )
|
||||||
|
{
|
||||||
|
unset( $_SESSION[$name] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the current session.
|
||||||
|
*
|
||||||
|
* @return bool TRUE is session has been deleted, else FALSE.
|
||||||
|
**/
|
||||||
|
|
||||||
|
public function destroy()
|
||||||
|
{
|
||||||
|
if ( $this->sessionState == self::SESSION_STARTED )
|
||||||
|
{
|
||||||
|
$this->sessionState = !session_destroy();
|
||||||
|
unset( $_SESSION );
|
||||||
|
|
||||||
|
return !$this->sessionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Middleware;
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
use Shared\Validation\Validator;
|
||||||
|
|
||||||
|
class RequestValidationMiddleware extends Middleware {
|
||||||
|
private $validator;
|
||||||
|
private $rules;
|
||||||
|
|
||||||
|
public function __construct(Validator $validator, array $rules) {
|
||||||
|
$this->validator = $validator;
|
||||||
|
$this->rules = $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(IRequest $request, callable $next) {
|
||||||
|
$this->validateRequest($request);
|
||||||
|
return parent::handle($request, $next);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateRequest(IRequest $request) {
|
||||||
|
foreach ($this->rules as $param => $ruleSet) {
|
||||||
|
foreach ($ruleSet as $rule) {
|
||||||
|
$this->validator->rule($param, $rule['callback'], $rule['message']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$requestData = array_merge($request->getQueryParameters(), $request->getRequestParameters());
|
||||||
|
$this->validator->assert($requestData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// $validationRules = [
|
||||||
|
// 'email' => [
|
||||||
|
// ['callback' => Validator::required(), 'message' => 'Email is required.'],
|
||||||
|
// ['callback' => Validator::email(), 'message' => 'Email must be a valid email address.']
|
||||||
|
// ],
|
||||||
|
// // Add more rules as needed
|
||||||
|
// ];
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Middleware;
|
||||||
|
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
|
||||||
|
interface IHttpMiddleware {
|
||||||
|
public function handle(IRequest $request, callable $next);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Middleware;
|
||||||
|
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
|
||||||
|
class LoggingMiddleware extends Middleware {
|
||||||
|
public function handle(IRequest $request, callable $next) {
|
||||||
|
// Logique de journalisation
|
||||||
|
echo "LoggingMiddleware: Log request - Method: {$request->getMethod()}, URI: {$request->getRequestUri()}\n";
|
||||||
|
return parent::handle($request, $next);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Router\Middleware;
|
||||||
|
|
||||||
|
use App\Router\Request\IRequest;
|
||||||
|
|
||||||
|
abstract class Middleware implements IHttpMiddleware {
|
||||||
|
protected $next;
|
||||||
|
|
||||||
|
public function setNext(IHttpMiddleware $nextMiddleware) {
|
||||||
|
$this->next = $nextMiddleware;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(IRequest $request, callable $next) {
|
||||||
|
if ($this->next !== null) {
|
||||||
|
return $this->next->handle($request, $next);
|
||||||
|
}
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Request;
|
||||||
|
|
||||||
|
interface ContentStrategy {
|
||||||
|
public function getContent(): array;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Request;
|
||||||
|
|
||||||
|
// should maybe change this
|
||||||
|
class ContentStrategyFactory {
|
||||||
|
private static $strategyMap = [
|
||||||
|
'application/json' => JsonContentStrategy::class,
|
||||||
|
// Format...
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function createContentStrategy(string $contentType, string $requestMethod): ContentStrategy {
|
||||||
|
foreach (self::$strategyMap as $type => $className) {
|
||||||
|
if ($contentType === $type || in_array($requestMethod, ['PUT', 'PATCH', 'DELETE'])) {
|
||||||
|
return new $className();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new FormContentStrategy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function registerStrategy(string $contentType, string $className): void {
|
||||||
|
self::$strategyMap[$contentType] = $className;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Request;
|
||||||
|
|
||||||
|
|
||||||
|
class FormContentStrategy implements ContentStrategy {
|
||||||
|
public function getContent(): array {
|
||||||
|
return $_POST;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Request;
|
||||||
|
|
||||||
|
class HttpRequest implements IRequest {
|
||||||
|
private $queryParameters;
|
||||||
|
private $requestParameters;
|
||||||
|
private $method;
|
||||||
|
private $requestUri;
|
||||||
|
private $headers;
|
||||||
|
|
||||||
|
private array $body;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
array $query,
|
||||||
|
array $server,
|
||||||
|
array $headers,
|
||||||
|
ContentStrategy $contentStrategy,
|
||||||
|
array $body
|
||||||
|
) {
|
||||||
|
$this->queryParameters = $query;
|
||||||
|
$this->requestUri = $server['REQUEST_URI'] ?? '';
|
||||||
|
$this->method = strtoupper($server['REQUEST_METHOD'] ?? 'GET');
|
||||||
|
$this->headers = $headers;
|
||||||
|
$this->requestParameters = $contentStrategy->getContent();
|
||||||
|
$this->body = $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryParameters(): array {
|
||||||
|
return $this->queryParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRequestParameters(): array {
|
||||||
|
return $this->requestParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMethod(): string {
|
||||||
|
return $this->method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRequestUri(): string {
|
||||||
|
return $this->requestUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeaders(): array {
|
||||||
|
return $this->headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBody(): array{
|
||||||
|
return $this->body;
|
||||||
|
}
|
||||||
|
public function addToBody(string|array $attributes){
|
||||||
|
$this->body[] = $attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Request;
|
||||||
|
|
||||||
|
|
||||||
|
interface IRequest
|
||||||
|
{
|
||||||
|
public function getRequestUri();
|
||||||
|
|
||||||
|
public function getBody();
|
||||||
|
public function addToBody(string|array $attributes);
|
||||||
|
|
||||||
|
public function getHeaders();
|
||||||
|
public function getMethod();
|
||||||
|
public function getQueryParameters(): array;
|
||||||
|
public function getRequestParameters(): array;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Router\Request;
|
||||||
|
|
||||||
|
class JsonContentStrategy implements ContentStrategy {
|
||||||
|
public function getContent(): array {
|
||||||
|
$rawContent = file_get_contents('php://input');
|
||||||
|
return json_decode($rawContent, true) ?? [];
|
||||||
|
}
|
||||||
|
}
|