parent
803f898499
commit
b4127bb330
@ -1,6 +1,3 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /php/public/
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
</IfModule>
|
||||
RewriteRule . index.php [L]
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/** PC IUT - PHP 8.1 */
|
||||
|
||||
/** Chargement config */
|
||||
require_once __DIR__ . '/src/config/config.php';
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
/** Configuration twig */
|
||||
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/templates');
|
||||
$twig = new \Twig\Environment($loader, [
|
||||
'cache' => false,
|
||||
'debug' => true
|
||||
]);
|
||||
$twig->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$cont = new \App\controleur\FrontControleur();
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
/** PC IUT - PHP 8.1 */
|
||||
|
||||
/** Chargement config */
|
||||
require_once __DIR__ . '/../src/config/config.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../src/TwigExtensions.php'; // utile pour les images à supprimer sinon
|
||||
|
||||
/** Configuration twig */
|
||||
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates');
|
||||
$twig = new \Twig\Environment($loader, [
|
||||
'cache' => false,
|
||||
'debug' => true
|
||||
]);
|
||||
$twig->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$cont = new \App\controleur\FrontControleur();
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
class TwigExtensions extends AbstractExtension
|
||||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new TwigFilter('base64', [$this, 'twig_base64_filter']),
|
||||
];
|
||||
}
|
||||
|
||||
public function twig_base64_filter($source)
|
||||
{
|
||||
if ($source !== null) {
|
||||
return base64_encode($source);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\gateway;
|
||||
|
||||
use App\metier\Image;
|
||||
use PDO;
|
||||
|
||||
class ImageGateway
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
/**
|
||||
* @param $con
|
||||
*/
|
||||
public function __construct(Connection $con)
|
||||
{
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
|
||||
public function insertImage(Image $img)
|
||||
{
|
||||
$query = "INSERT INTO Image (`nom`, `taille`, `type`, `blob`) VALUES ( :n, :t, :ty, :b)";
|
||||
$this->con->executeQuery($query, array(
|
||||
':n' => array($img->getName(), PDO::PARAM_STR),
|
||||
':t' => array($img->getTaille(), PDO::PARAM_STR),
|
||||
':ty' => array($img->getType(), PDO::PARAM_STR),
|
||||
':b' => array($img->getBlob(), PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
public function delete(int $id)
|
||||
{
|
||||
$query = 'DELETE FROM Image WHERE id=:i';
|
||||
$this->con->executeQuery($query, array(
|
||||
':i' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function getFromId(int $id) : array
|
||||
{
|
||||
$query = 'SELECT * FROM Image WHERE id=:i';
|
||||
$this->con->executeQuery($query, array(
|
||||
':i' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getNewId() : int
|
||||
{
|
||||
$query = 'SELECT MAX(id) FROM Image';
|
||||
$this->con->executeQuery($query);
|
||||
$res = $this->con->getResults();
|
||||
if ($res[0]['MAX(id)'] === null) {
|
||||
return 1;
|
||||
}
|
||||
return intval($res[0]['MAX(id)'])+1;
|
||||
|
||||
}
|
||||
|
||||
public function obtenirToutesImages()
|
||||
{
|
||||
$query = 'SELECT * FROM Image';
|
||||
$this->con->executeQuery($query);
|
||||
$res = $this->con->getResults();
|
||||
$array = [];
|
||||
foreach ($res as $r) {
|
||||
$array[] = new Image($this->getNewId(),$r['nom'], $r['taille'], $r['type'], $r['blob']);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\metier;
|
||||
|
||||
class Image
|
||||
{
|
||||
private int $id;
|
||||
private string $name;
|
||||
|
||||
private string $taille;
|
||||
|
||||
private string $type;
|
||||
|
||||
private string $blob;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string $taille
|
||||
* @param string $type
|
||||
* @param string $blob
|
||||
*/
|
||||
public function __construct(int $id, string $name, string $taille, string $type, string $blob)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->taille = $taille;
|
||||
$this->type = $type;
|
||||
$this->blob = $blob;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
public function getTaille(): string
|
||||
{
|
||||
return $this->taille;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getBlob(): string
|
||||
{
|
||||
return $this->blob;
|
||||
}
|
||||
|
||||
public function getId() : string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function toString() : string {
|
||||
return "Image : " . $this->name . " " . $this->taille . " " . $this->type . " blob " . $this->blob;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\modele;
|
||||
|
||||
use App\gateway\Connection;
|
||||
use App\metier\Image;
|
||||
use App\gateway\ImageGateway;
|
||||
class ImageModele
|
||||
{
|
||||
private ImageGateway $gw;
|
||||
public function __construct()
|
||||
{
|
||||
$this->gw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica","test","test"));
|
||||
}
|
||||
|
||||
public function publierImage(string $file) : Image
|
||||
{
|
||||
$img = new Image($this->gw->getNewId(),
|
||||
$_FILES[$file]["name"],
|
||||
$_FILES[$file]["size"],
|
||||
$_FILES[$file]["type"],
|
||||
file_get_contents($_FILES[$file]["tmp_name"]));
|
||||
|
||||
$this->insertImage($img);
|
||||
|
||||
return $img;
|
||||
}
|
||||
|
||||
public function insertImage(Image $img)
|
||||
{
|
||||
$this->gw->insertImage($img);
|
||||
}
|
||||
|
||||
public function obtenirParId(int $id)
|
||||
{
|
||||
$this->gw->getFromId($id);
|
||||
$res = $this->gw->getResults();
|
||||
return new Image($this->gw->getNewId(),$res[0]['nom'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']);
|
||||
}
|
||||
|
||||
public function obtenirToutesImages() : array
|
||||
{
|
||||
$this->gw->obtenirToutesImages();
|
||||
$res = $this->gw->getResults();
|
||||
foreach ($res as $r) {
|
||||
$array[] = new Image($this->gw->getNewId(),$r['nom'], $r['taille'], $r['type'], $r['blob']);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\modele;
|
||||
|
||||
use App\gateway\AlumniGateway;
|
||||
use App\gateway\Connection;
|
||||
use App\gateway\ImageGateway;
|
||||
use App\gateway\OffreGateway;
|
||||
use App\gateway\ProfilGateway;
|
||||
use App\metier\Alumni;
|
||||
use App\metier\Offre;
|
||||
use App\metier\Image;
|
||||
use mysql_xdevapi\Exception;
|
||||
|
||||
class OffreModele
|
||||
{
|
||||
private OffreGateway $offreGw;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test"));
|
||||
}
|
||||
|
||||
public function publishOffer(string $img, string $logo)
|
||||
{
|
||||
$desc = $_POST["description"];
|
||||
$descposte = $_POST["descriptPoste"];
|
||||
$nom = $_POST["name"];
|
||||
$ville = $_POST["ville"];
|
||||
$entreprise = $_POST["entreprise"];
|
||||
$profilRecherche = $_POST["profilRecherche"];
|
||||
$mail = $_POST["mail"];
|
||||
$num = $_POST["num"];
|
||||
$site = $_POST["site"];
|
||||
$exp = $_POST["choixExp"];
|
||||
$typeContrat = $_POST["typeContrat"];
|
||||
$niveauEtudes = $_POST["education"];
|
||||
$date = new \DateTime();
|
||||
|
||||
if(isset($_POST["fullRemote"]))
|
||||
{
|
||||
$remote = true;
|
||||
}
|
||||
else $remote = false;
|
||||
|
||||
// à la place de NULL passer id utilisateur créateur offre
|
||||
$offre = new Offre($this->offreGw->getNewId(),
|
||||
new Alumni("test.mail@icloud.fr","password","admin","prenom","nom"),
|
||||
$nom,
|
||||
$desc,
|
||||
$img,
|
||||
$logo,
|
||||
$typeContrat,
|
||||
$ville,
|
||||
$entreprise,
|
||||
$descposte,
|
||||
$profilRecherche,
|
||||
$exp,
|
||||
$niveauEtudes,
|
||||
$mail,
|
||||
$num,
|
||||
$site,
|
||||
$remote,
|
||||
$date);
|
||||
|
||||
$this->offreGw->addOffers($offre);
|
||||
|
||||
return $offre;
|
||||
|
||||
}
|
||||
public function getOffers() : array
|
||||
{
|
||||
$res = $this->offreGw->getOffers();
|
||||
$offers = $this->CreateOffersFromGw($res);
|
||||
return $offers;
|
||||
}
|
||||
|
||||
|
||||
public function getOfferFromId(int $id) : ?Offre
|
||||
{
|
||||
$res = $this->offreGw->getOfferFromId($id);
|
||||
if($res != null)
|
||||
return $this->CreateOffersFromGw($res)[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
public function CreateOffersFromGw($res) : array
|
||||
{
|
||||
$alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test"));
|
||||
|
||||
$offers=[];
|
||||
foreach ($res as $row)
|
||||
{
|
||||
$resal = $alGw->ObtenirById($row['offreur']);
|
||||
$profilGw = new ProfilGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "Dev", "Dev"));
|
||||
$resProfl = $profilGw->getProfilById($row['offreur']);
|
||||
|
||||
$alumni = new Alumni($resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role'],$resProfl[0]['nom'],$resProfl[0]["prenom"]);
|
||||
|
||||
$date = \DateTime::createFromFormat('Y-m-d', $row['date']);
|
||||
|
||||
$offers[]=new Offre(
|
||||
$row['id'],
|
||||
$alumni,
|
||||
$row['titre'],
|
||||
$row['description'],
|
||||
$row["image"],
|
||||
$row["logo"],
|
||||
$row['typeContrat'],
|
||||
$row['ville'],
|
||||
$row["entreprise"],
|
||||
$row['descriptifPoste'],
|
||||
$row['profil'],
|
||||
$row['experience'],
|
||||
$row['niveauEtudes'],
|
||||
$row['mailContact'],
|
||||
$row['numero'],
|
||||
$row['websiteURL'],
|
||||
$row['remote'],
|
||||
$date);
|
||||
}
|
||||
|
||||
|
||||
return $offers;
|
||||
}
|
||||
|
||||
public function getOfferLimit($start, $nbOffers): array
|
||||
{
|
||||
$res = $this->offreGw->getOfferLimit($start, $nbOffers);
|
||||
return $this->CreateOffersFromGw($res);
|
||||
}
|
||||
|
||||
public function getNbOffers() : int
|
||||
{
|
||||
return $this->offreGw->getNbOffers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getOffersWithFilters($params) : array
|
||||
{
|
||||
return $this->offreGw->getOffersWithFilters($params);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue