@ -0,0 +1,13 @@
|
||||
{
|
||||
"require": {
|
||||
"twig/twig": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Controleu\\": "src/Controleur/",
|
||||
"config\\": "config/",
|
||||
"Model\\": "src/Model/",
|
||||
"Entity\\": "src/Entity/"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Autoload
|
||||
{
|
||||
private static $_instance = null;
|
||||
|
||||
public static function charger()
|
||||
{
|
||||
if(null !== self::$_instance) {
|
||||
throw new RuntimeException(sprintf('%s is already started', __CLASS__));
|
||||
}
|
||||
|
||||
self::$_instance = new self();
|
||||
|
||||
|
||||
if(!spl_autoload_register(array(self::$_instance, '_autoload'))) {
|
||||
throw RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__));
|
||||
}
|
||||
}
|
||||
|
||||
public static function shutDown()
|
||||
{
|
||||
if(null !== self::$_instance) {
|
||||
|
||||
if(!spl_autoload_unregister(array(self::$_instance, '_autoload'))) {
|
||||
throw new RuntimeException('Could not stop the autoload');
|
||||
}
|
||||
|
||||
self::$_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function _autoload($class)
|
||||
{
|
||||
global $rep;
|
||||
$filename = $class.'.php';
|
||||
$dir =array('models/','./','config/','controllers/');
|
||||
foreach ($dir as $d){
|
||||
$file=$rep.$d.$filename;
|
||||
//echo $file;
|
||||
if (file_exists($file))
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 269 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 826 B |
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
//chargement config
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
//twig
|
||||
$loader = new \Twig\Loader\FilesystemLoader('templates');
|
||||
$twig = new \Twig\Environment($loader, [
|
||||
'cache' => 'cache',
|
||||
]);
|
||||
|
||||
$cont = new FrontControleur();
|
||||
|
||||
?>
|
@ -1,27 +0,0 @@
|
||||
|
||||
<?php
|
||||
|
||||
#session_start();
|
||||
#require_once('../bd/connexionDB.php');
|
||||
#
|
||||
#if(isset($_GET['user'])){
|
||||
#$user = (String) trim($_GET['user']);
|
||||
#
|
||||
#$req = $DB->query("SELECT *
|
||||
# FROM utilisateur
|
||||
# WHERE nom LIKE ?
|
||||
# LIMIT 10",
|
||||
# array("$user%"));
|
||||
#
|
||||
#$req = $req->fetchALL();
|
||||
$req=query(array('nom'=>'nom1','prenom'=>'prenom1'),array('nom'=>'nom2','prenom'=>'prenom2'),array('nom'=>'nom3','prenom'=>'prenom3'));
|
||||
$req = $req->fetchALL();
|
||||
|
||||
foreach($req as $r){
|
||||
?>
|
||||
<div style="margin-top: 20px 0; border-bottom: 2px solid #ccc"><?= $r['nom'] . " " . $r['prenom'] ?></div><?php
|
||||
}
|
||||
|
||||
#}
|
||||
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
?>
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace controleur;
|
||||
|
||||
Class FrontControleur{
|
||||
|
||||
public function __construct(){
|
||||
global $twig;
|
||||
session_start();
|
||||
|
||||
$dVueEreur = [];
|
||||
|
||||
$router = new AltoRouter();
|
||||
|
||||
$router->map('GET', '/', 'FrontController');
|
||||
$router->map('GET', '/user/quote/[p1:param1]?', 'UserController');
|
||||
|
||||
$match = $routeur->match();
|
||||
if(!$match){
|
||||
$dVueEreur[] = "Requette introuvable";
|
||||
$this->vueErreur($dVueEreur);
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function vueErreur(array $dVueErreur){
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class CharacterEntity
|
||||
{
|
||||
|
||||
private int $id_character;
|
||||
|
||||
private string $name;
|
||||
|
||||
private string $img_path;
|
||||
|
||||
public function __construct(int $id_character, string $name, string $img_path)
|
||||
{
|
||||
$this -> id_character = $id_character;
|
||||
$this -> name = $name;
|
||||
$this -> img_path = $img_path;
|
||||
}
|
||||
|
||||
public function getIdCharacter() : int
|
||||
{
|
||||
return $this -> id_character;
|
||||
}
|
||||
public function getName() : string
|
||||
{
|
||||
return $this -> name;
|
||||
}
|
||||
public function getImgPath() : string
|
||||
{
|
||||
return $this -> img_path;
|
||||
}
|
||||
|
||||
public function setIdCharacter(int $id_character) : void
|
||||
{
|
||||
$this -> id_character = $id_character;
|
||||
}
|
||||
public function setName(string $name) : void
|
||||
{
|
||||
$this -> name = $name;
|
||||
}
|
||||
public function setImgPath(string $img_path) : void
|
||||
{
|
||||
$this -> img_path = $img_path;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class CommentaryEntity {
|
||||
|
||||
private int $id_comment;
|
||||
private string $comment;
|
||||
private string $date;
|
||||
|
||||
|
||||
public function __construct(int $id_comment, string $comment, string $date) {
|
||||
$this->id_comment = $id_comment;
|
||||
$this->comment = $comment;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function getIdComment(): int {
|
||||
return $this->id_comment;
|
||||
}
|
||||
public function getComment(): string {
|
||||
return $this->comment;
|
||||
}
|
||||
public function getDate(): string {
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setIdComment(int $id_comment): void {
|
||||
$this->id_comment = $id_comment;
|
||||
}
|
||||
|
||||
public function setComment(string $comment): void {
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
public function setDate(string $date): void {
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
class QuestionEntity
|
||||
{
|
||||
private int $id_question;
|
||||
private string $question;
|
||||
private string $answerA;
|
||||
private string $answerB;
|
||||
private string $answerC;
|
||||
private string $answerD;
|
||||
private string $cAnswer;
|
||||
|
||||
public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer)
|
||||
{
|
||||
$this -> id_question = $id_question;
|
||||
$this -> question = $question;
|
||||
$this -> answerA = $answerA;
|
||||
$this -> answerB = $answerB;
|
||||
$this -> answerC = $answerC;
|
||||
$this -> answerD = $answerD;
|
||||
$this -> cAnswer = $cAnswer;
|
||||
}
|
||||
|
||||
public function getIdQuestion() : int
|
||||
{
|
||||
return $this -> id_question;
|
||||
}
|
||||
|
||||
public function getQuestion() : string
|
||||
{
|
||||
return $this -> question;
|
||||
}
|
||||
|
||||
public function getAnswerA() : string
|
||||
{
|
||||
return $this -> answerA;
|
||||
}
|
||||
|
||||
public function getAnswerB() : string
|
||||
{
|
||||
return $this -> answerB;
|
||||
}
|
||||
|
||||
public function getAnswerC() : string
|
||||
{
|
||||
return $this -> answerC;
|
||||
}
|
||||
|
||||
public function getAnswerD() : string
|
||||
{
|
||||
return $this -> answerD;
|
||||
}
|
||||
|
||||
public function getCAnswer() : string
|
||||
{
|
||||
return $this -> cAnswer;
|
||||
}
|
||||
|
||||
public function setQuestion(string $newQuestion) : void
|
||||
{
|
||||
$this -> question = $question;
|
||||
}
|
||||
|
||||
public function setAnswerA(string $newAnswerA) : void
|
||||
{
|
||||
$this -> answerA = $newAnswerA;
|
||||
}
|
||||
|
||||
public function setAnswerB(string $newAnswerB) : void
|
||||
{
|
||||
$this -> answerB = $newAnswerB;
|
||||
}
|
||||
|
||||
public function setAnswerC(string $newAnswerC) : void
|
||||
{
|
||||
$this -> answerC = $newAnswerC;
|
||||
}
|
||||
|
||||
public function setAnswerD(string $newAnswerD) : void
|
||||
{
|
||||
$this -> answerD = $newAnswerD;
|
||||
}
|
||||
|
||||
public function setCAnswer(string $newCAnswer) : void
|
||||
{
|
||||
$this -> cAnswer = $newCAnswer;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
class Quote{
|
||||
|
||||
private int $id;
|
||||
private string $content;
|
||||
private string $carac;
|
||||
private string $imgPath;
|
||||
private string $titleSrc;
|
||||
private string $dateSrc;
|
||||
private int $like;
|
||||
private string $langue;
|
||||
|
||||
function __construct(int $id, string $content, string $carac, string $imgPath, string $titleSrc, string $dateSrc, int $like, string $langue) {
|
||||
$this->id = $id;
|
||||
$this->content = $content;
|
||||
$this->carac = $carac;
|
||||
$this->imgPath = $imgPath;
|
||||
$this->titleSrc = $titleSrc;
|
||||
$this->dateSrc = $dateSrc;
|
||||
$this->like = $like;
|
||||
$this->langue = $langue;
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function getContent() : string{
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function getCarac() : string{
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function getImgPath() : string{
|
||||
return $imgPath;
|
||||
}
|
||||
|
||||
public function getTitleSrc() : string{
|
||||
return $titleSrc;
|
||||
}
|
||||
|
||||
public function getDateSrc() : string{
|
||||
return $dateSrc;
|
||||
}
|
||||
|
||||
public function getLike() : int{
|
||||
return $like;
|
||||
}
|
||||
|
||||
public function getLangue() : string{
|
||||
return $langue;
|
||||
}
|
||||
|
||||
public function setId(int $id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function setContent(string $content){
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function setCarac(string $carac){
|
||||
$this->carac = $carac;
|
||||
}
|
||||
|
||||
public function setImgPath(string $imgPat){
|
||||
$this->imgPath = $imgPath;
|
||||
}
|
||||
|
||||
public function setTitleSrc(string $titleSrc){
|
||||
$this->titleSrc = $titleSrc;
|
||||
}
|
||||
|
||||
public function setDateSrc(string $dateSrc){
|
||||
$this->datesrc = $dateSrc;
|
||||
}
|
||||
|
||||
public function setLike(int $like){
|
||||
$this->like = $like;
|
||||
}
|
||||
|
||||
public function setlangue(string $langue){
|
||||
$this->langue = $langue;
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class SourceEntity
|
||||
{
|
||||
private int $id_source;
|
||||
|
||||
private string $title;
|
||||
|
||||
private string $date;
|
||||
|
||||
public function __construct(int $id_source, string $title, string $date)
|
||||
{
|
||||
$this -> id_source = $id_source ;
|
||||
$this -> title = $title ;
|
||||
$this -> date = $date;
|
||||
}
|
||||
|
||||
public function getIdSource() : int
|
||||
{
|
||||
return $this -> id_source ;
|
||||
}
|
||||
|
||||
public function getTitle() : string
|
||||
{
|
||||
return $this -> title ;
|
||||
}
|
||||
|
||||
public function getDate() : string
|
||||
{
|
||||
return $this -> date ;
|
||||
}
|
||||
|
||||
public function setIdSource(int $id_source) : void
|
||||
{
|
||||
$this -> id_source = $id_source ;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): void{
|
||||
$this -> title = $title ;
|
||||
}
|
||||
|
||||
public function setDate(string $date) : void
|
||||
{
|
||||
$this -> date = $date ;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
class User{
|
||||
|
||||
private string $id;
|
||||
private string $username;
|
||||
private string $passwd;
|
||||
private string $hidenPasswd;
|
||||
private string $img;
|
||||
private string $email;
|
||||
|
||||
function __construct(string $id, string $pseudo, string $password, string $image, string $mail) {
|
||||
$this->id = $id;
|
||||
$this->username = $pseudo;
|
||||
$this->passwd = $password;
|
||||
$this->hidenPasswd = hidenPassWd($password);
|
||||
$this->img = $image;
|
||||
$this->email = $mail;
|
||||
}
|
||||
|
||||
public function getId() : string{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUsername() : string{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function getPasswd() : string{
|
||||
return $this->passwd;
|
||||
}
|
||||
|
||||
public function getImg() : string{
|
||||
return $this->img;
|
||||
}
|
||||
|
||||
public function getEmail() : string{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setUsername(string $username){
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
public function setPasswd(string $passwd){
|
||||
$this->passwd = $passwd;
|
||||
$this->hidenPassWd = hidenPassWd($passwd);
|
||||
}
|
||||
|
||||
public function setImg(string $img){
|
||||
$this->img = $img;
|
||||
}
|
||||
|
||||
public function setEmail(string $email){
|
||||
$this->email = $email;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function hidenPassWd(string $passwd){
|
||||
if(strlen($passwd) >= 16) return str_repeat('*', 16);
|
||||
return str_repeat('*', strlen($passwd));
|
||||
}
|
||||
?>
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
class Connection extends PDO {
|
||||
|
||||
private $stmt;
|
||||
|
||||
public function __construct(string $dsn, string $username, string $password) {
|
||||
parent::__construct($dsn,$username,$password);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
/** * @param string $query
|
||||
* @param array $parameters *
|
||||
* @return bool Returns `true` on success, `false` otherwise
|
||||
*/
|
||||
|
||||
public function executeQuery(string $query, array $parameters = []) : bool{
|
||||
$this->stmt = parent::prepare($query);
|
||||
foreach ($parameters as $name => $value) {
|
||||
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||
}
|
||||
|
||||
return $this->stmt->execute();
|
||||
}
|
||||
|
||||
public function getResults() : array {
|
||||
return $this->stmt->fetchall();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
require_once "../public/script/Connection.php";
|
||||
require_once "characterEntity.php";
|
||||
|
||||
class CharacterGateway
|
||||
{
|
||||
|
||||
private Connection $co;
|
||||
|
||||
public function __construct(Connection $co)
|
||||
{
|
||||
$this -> co = $co;
|
||||
}
|
||||
|
||||
public function create(characterEntity $c) : bool
|
||||
{
|
||||
$query = "
|
||||
INSERT INTO Character
|
||||
VALUES(:id_character, :name, :img_path)
|
||||
";
|
||||
|
||||
return $this -> co -> executeQuery($query, [
|
||||
"id_character" => array($c -> getIdCharacter(), PDO::PARAM_INT),
|
||||
"name" => array($c -> getName(), PDO::PARAM_STR),
|
||||
"img_path" => array($c -> getImgPath(), PDO::PARAM_STR)
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function findById(int $id) : ?characterEntity
|
||||
{
|
||||
$query = "SELECT * FROM Character WHERE id_character = :id_c";
|
||||
|
||||
$this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
|
||||
$res = $this ->co -> getResults();
|
||||
|
||||
if($res)
|
||||
return new characterEntity(
|
||||
$res["id_character"],
|
||||
$res["name"],
|
||||
$res["img_path"]
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function findByName(string $name) : ?characterEntity
|
||||
{
|
||||
$query = "SELECT * FROM Character WHERE name = :n";
|
||||
|
||||
$this -> co -> executeQuery($query, ["n" => array($name, PDO::PARAM_STR)]);
|
||||
$res = $this ->co -> getResults();
|
||||
|
||||
if($res)
|
||||
return new characterEntity(
|
||||
$res["id_character"],
|
||||
$res["name"],
|
||||
$res["img_path"]
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function findAll() : array
|
||||
{
|
||||
$query = "SELECT * FROM Character";
|
||||
|
||||
$this -> co -> executeQuery($query);
|
||||
$res = $this ->co -> getResults();
|
||||
|
||||
$characters = [];
|
||||
|
||||
foreach ($res as $character)
|
||||
{
|
||||
$characters[] = new characterEntity(
|
||||
$character["id_character"],
|
||||
$character["name"],
|
||||
$character["img_path"]
|
||||
);
|
||||
}
|
||||
return $characters;
|
||||
}
|
||||
|
||||
public function delete(int $id) : bool
|
||||
{
|
||||
$query = "DELETE FROM Character WHERE id_character = :id_c";
|
||||
|
||||
return $this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
|
||||
}
|
||||
|
||||
public function update(characterEntity $c) : bool
|
||||
{
|
||||
$query = "
|
||||
UPDATE Character
|
||||
SET name = :n, img_path = :i
|
||||
WHERE id_character = :id_c
|
||||
";
|
||||
|
||||
return $this -> co -> executeQuery($query, [
|
||||
"id_c" => array($c -> getIdCharacter(), PDO::PARAM_INT),
|
||||
"name" => array($c -> getName(), PDO::PARAM_STR),
|
||||
"i" => array($c -> getImgPath(), PDO::PARAM_STR)
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
require_once "../public/script/Connection.php";
|
||||
require_once "commentaryEntity.php";
|
||||
|
||||
class CommentaryGateway {
|
||||
private Connection $co ;
|
||||
public function __construct(Connection $co) {
|
||||
$this->co = $co;
|
||||
}
|
||||
|
||||
public function create(commentaryEntity $c) :bool {
|
||||
|
||||
$query="INSERT INTO Commentary VALUES(:id_comment, :comment , :date)";
|
||||
|
||||
return $this -> co -> executeQuery($query, array(
|
||||
"id_comment" => array($c->getIdComment(), PDO::PARAM_INT),
|
||||
"comment" => array($c->getComment(), PDO::PARAM_STR),
|
||||
"date" => array($c->getDate(), PDO::PARAM_STR)));
|
||||
}
|
||||
|
||||
public function findById(int $id) : ?commentaryEntity {
|
||||
|
||||
$query="SELECT * FROM Commentary WHERE id_comment = :id_comment";
|
||||
|
||||
$this -> co -> executeQuery($query, array("id_comment" => $id));
|
||||
$res = $this -> co -> getResults();
|
||||
if($res)
|
||||
return new commentaryEntity($res["id_comment"], $res["comment"], $res["date"]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function findAll() : array {
|
||||
$query="SELECT * FROM Commentary";
|
||||
$this -> co -> executeQuery($query);
|
||||
$res = $this -> co -> getResults();
|
||||
|
||||
$comments = [];
|
||||
foreach ($res as $comment) {
|
||||
|
||||
$comments[] = new commentaryEntity(
|
||||
$comment["id_comment"],
|
||||
$comment["comment"],
|
||||
$comment["date"]
|
||||
);
|
||||
}
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
public function delete(int $id) : bool {
|
||||
$query="DELETE FROM Commentary WHERE id_comment = :id_comment";
|
||||
return $this -> co -> executeQuery($query, array("id_comment" => $id));
|
||||
|
||||
}
|
||||
|
||||
public function update(commentaryEntity $c) : bool {
|
||||
|
||||
$query="UPDATE Commentary SET comment = :comment WHERE id_comment = :id_comment";
|
||||
|
||||
return $this -> co -> executeQuery($query, array(
|
||||
"comment" => array($c->getComment(),PDO::PARAM_STR),
|
||||
"id_comment" => array($c->getIdComment(),PDO::PARAM_INT))
|
||||
);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
include('Connection.php');
|
||||
|
||||
Class QuoteGateway{
|
||||
private Connection $con;
|
||||
|
||||
public function __construct(Connection $con){
|
||||
$this->con=$con;
|
||||
}
|
||||
|
||||
public function searchQuote(string $quote,int $numpage,string $language):array{
|
||||
|
||||
//recherche par citation
|
||||
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE content LIKE '%:quote%' AND isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
|
||||
$this->con->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function searchSource(string $source,int $numpage,string $language):array{
|
||||
|
||||
//recherche par source
|
||||
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE s.title LIKE '%:source%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
|
||||
$this->con->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function searchPers(string $Carac,int $numpage,string $language):array{
|
||||
|
||||
//recherche par personnage
|
||||
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE c.caracter LIKE '%:pers%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
|
||||
$this->con->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getComment(int $id):array{
|
||||
|
||||
//obtention des commentaire d'une citation
|
||||
$query="SELECT c.id_comment u.username, u.imgPath, c.comment, c.date FROM Commentary c JOIN Quote q ON c.quote = q.id_quote JOIN User u ON u.id_user = c.user JOIN Image i ON i.id_img = u.img WHERE id_quote = :id;";
|
||||
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
require_once "../public/script/Connection.php";
|
||||
require_once "sourceEntity.php";
|
||||
class SourceGateway {
|
||||
|
||||
private Connection $co;
|
||||
|
||||
public function __construct(Connection $co)
|
||||
{
|
||||
$this -> co = $co;
|
||||
}
|
||||
|
||||
public function create(sourceEntity $s) : bool
|
||||
{
|
||||
$query = "
|
||||
INSERT INTO Source
|
||||
VALUES(:id_source, :title, :date)
|
||||
";
|
||||
|
||||
return $this -> co -> executeQuery($query, [
|
||||
"id_source" => array($s->getIdSource(), PDO::PARAM_INT),
|
||||
"title" => array($s->getTitle(), PDO::PARAM_STR),
|
||||
"date" => array($s->getDate(), PDO::PARAM_STR)
|
||||
]);
|
||||
}
|
||||
|
||||
public function findById(int $id) : ?sourceEntity
|
||||
{
|
||||
$query = "SELECT * FROM Source WHERE id_source = :id";
|
||||
|
||||
$this -> co -> executeQuery($query, array("id_source" => array($id, PDO::PARAM_INT)));
|
||||
$res = $this -> co -> getResults();
|
||||
|
||||
if ($res)
|
||||
return new sourceEntity(
|
||||
$res["id_source"],
|
||||
$res["title"],
|
||||
$res["date"]
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function findByTitle(string $t) : ?sourceEntity
|
||||
{
|
||||
$query = "SELECT * FROM Source WHERE title = :t";
|
||||
|
||||
$this -> co -> executeQuery($query, ["title" => array($t, PDO::PARAM_STR)]);
|
||||
$res = $this -> co -> getResults();
|
||||
|
||||
if ($res)
|
||||
return new sourceEntity(
|
||||
$res["id_source"],
|
||||
$res["title"],
|
||||
$res["date"]
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function findByDate(string $d) : ?sourceEntity
|
||||
{
|
||||
$query = "SELECT * FROM Source WHERE date = :d";
|
||||
|
||||
$this -> co -> executeQuery($query, ["date" => array($d, PDO::PARAM_STR)]);
|
||||
$res = $this -> co -> getResults();
|
||||
|
||||
if ($res)
|
||||
return new sourceEntity(
|
||||
$res["id_source"],
|
||||
$res["title"],
|
||||
$res["date"]
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function findAll() : array
|
||||
{
|
||||
$query = "SELECT * FROM Source";
|
||||
|
||||
$this -> co -> executeQuery($query);
|
||||
$res = $this -> co -> getResults();
|
||||
|
||||
$sources = [];
|
||||
|
||||
foreach ($res as $source) {
|
||||
$sources[] = new sourceEntity(
|
||||
$source["id_source"],
|
||||
$source["title"],
|
||||
$source["date"]
|
||||
);
|
||||
}
|
||||
return $sources;
|
||||
}
|
||||
|
||||
public function delete(int $id) : bool
|
||||
{
|
||||
$query = "DELETE FROM Source WHERE id_source = :id_s";
|
||||
|
||||
$this -> co -> executeQuery($query, ["id_s" => array($id, PDO::PARAM_INT)]);
|
||||
}
|
||||
|
||||
public function update(sourceEntity $s) : bool
|
||||
{
|
||||
$query = "
|
||||
UPDATE Source
|
||||
SET title = :t, date = :d
|
||||
WHERE id_source = :id_s
|
||||
";
|
||||
return $this->co->executeQuery($query, [
|
||||
"id_s" => array($s -> getIdSource(), PDO::PARAM_INT),
|
||||
"t" => array($s -> getTitle(), PDO::PARAM_STR),
|
||||
"d" => array($s -> getDate(), PDO::PARAM_STR)
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
include('Connection.php');
|
||||
|
||||
Class UserGateway{
|
||||
private Connection $con;
|
||||
|
||||
public function __construct(Connection $con){
|
||||
$this->con=$con;
|
||||
}
|
||||
|
||||
public function insert(string $username,string $email,string $passwd):string{
|
||||
|
||||
// récupération id
|
||||
$query='SELECT id_user FROM Users WHERE id_user >= ALL (SELECT id_user FROM Users);';
|
||||
$this->con->executeQuery($query);
|
||||
$result=$this->con->getResults();
|
||||
foreach($result as $row){
|
||||
$id=$row['id_user'] + 1;
|
||||
}
|
||||
// insertion user
|
||||
$query='INSERT INTO Users VALUES (:id,:username,:email,:passwd,CURRENT_DATE,false);';
|
||||
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR),':username' => array($u->username,PDO::PARAM_STR),':email' => array($u->email,PDO::PARAM_STR),':passwd' => array($u->passwd,PDO::PARAM_STR)));
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function delete(string $id) : bool{
|
||||
|
||||
// supretion user
|
||||
$query='DELETE FROM Users WHERE id_user = :id;';
|
||||
return $this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
|
||||
}
|
||||
|
||||
public function getFavorite(string $id):array{
|
||||
|
||||
//obtention favoris d'un user
|
||||
$query='SELECT * FROM Quote WHERE id_quote IN (SELECT id_quote IN Favorite f JOIN User u ON u.id_user = f.user WHERE id_user = :id);';
|
||||
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
require_once "characterEntity.php";
|
||||
require_once "characterGateway.php";
|
||||
|
||||
class CharacterModel
|
||||
{
|
||||
|
||||
private characterGateway $gateway;
|
||||
|
||||
public function __construct(characterGateway $gateway)
|
||||
{
|
||||
$this -> gateway = $gateway;
|
||||
}
|
||||
|
||||
public function createCharacter(int $id_character, string $name , string $img_path) : bool
|
||||
{
|
||||
$q = new CharacterEntity($id_character, $name, $img_path);
|
||||
|
||||
return $this -> gateway -> create($q);
|
||||
}
|
||||
public function getCharacterById(int $id_character) : ?CharacterEntity
|
||||
{
|
||||
return $this -> gateway -> findById($id_character);
|
||||
}
|
||||
|
||||
public function getCharacterByName(string $name) : ?CharacterEntity
|
||||
{
|
||||
return $this -> gateway -> findByName($name);
|
||||
}
|
||||
|
||||
public function getAllCharacters() : array
|
||||
{
|
||||
return $this -> gateway -> findAll();
|
||||
}
|
||||
|
||||
public function deleteCharacter(int $id_character) : bool
|
||||
{
|
||||
return $this -> gateway -> delete($id_character);
|
||||
}
|
||||
|
||||
public function updateCharacter(int $id_character, string $name, string $img_path) : bool
|
||||
{
|
||||
$q = $this -> gateway -> findById($id_character);
|
||||
|
||||
if($q){
|
||||
$q -> setName($name);
|
||||
$q -> setImgPath($img_path);
|
||||
return $this -> gateway -> update($q);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once "commentaryEntity.php";
|
||||
require_once "commentaryGateway.php";
|
||||
class CommentaryModel {
|
||||
|
||||
private commentaryGateway $gw;
|
||||
|
||||
function __construct(commentaryGateway $gw) {
|
||||
$this->gw = $gw;
|
||||
}
|
||||
|
||||
public function createComment(int $id_comment, string $comment, string $date): bool {
|
||||
|
||||
$c = new CommentaryEntity($id_comment, $comment, $date);
|
||||
return $this->gw->create($c);
|
||||
}
|
||||
|
||||
public function getComment(int $id_comment): ?commentaryEntity {
|
||||
return $this -> gw -> findById($id_comment);
|
||||
}
|
||||
|
||||
public function getComments(): array {
|
||||
return $this -> gw -> findAll();
|
||||
}
|
||||
|
||||
public function deleteComment(int $id_comment): bool {
|
||||
return $this -> gw -> delete($id_comment);
|
||||
}
|
||||
|
||||
public function updateComment(int $id_comment, string $comment): bool {
|
||||
|
||||
$c = $this -> gw -> findById($id_comment);
|
||||
|
||||
if($c){
|
||||
$c -> setComment($comment);
|
||||
return $this->gw -> update($c);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require_once($rep.$entity['quote']);
|
||||
require_once($rep.$gateway['quote']);
|
||||
|
||||
class QuoteModel
|
||||
{
|
||||
private QuoteGateway $gateway;
|
||||
|
||||
public function __construct(QuoteGateway $gate){
|
||||
$this->gateway = $gate;
|
||||
}
|
||||
|
||||
public function searchQuote(string $quote,int $numpage,string $language) : Quote{
|
||||
$res = $this->gateway->searchQuote($quote,$numpage,$language);
|
||||
return new Quote($res[0]['']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
require_once "sourceEntity.php";
|
||||
require_once "sourceGateway.php";
|
||||
|
||||
class SourceModel
|
||||
{
|
||||
|
||||
private sourceGateway $gateway;
|
||||
|
||||
public function __construct(SourceGateway $gateway)
|
||||
{
|
||||
$this -> gateway = $gateway;
|
||||
}
|
||||
|
||||
public function createSource(int $id_source, string $title, string $date) : bool
|
||||
{
|
||||
$q = new SourceEntity($id_source , $title, $date);
|
||||
|
||||
return $this -> gateway -> create($q);
|
||||
}
|
||||
|
||||
public function getSourceById(int $id_source) : ?SourceEntity
|
||||
{
|
||||
return $this -> gateway -> findById($id_source);
|
||||
}
|
||||
|
||||
public function getSourceByTitle(string $title) : ?SourceEntity
|
||||
{
|
||||
return $this -> gateway -> findByTitle($title);
|
||||
}
|
||||
|
||||
public function getSourceByDate(string $date) : ?SourceEntity
|
||||
{
|
||||
return $this -> gateway -> findByDate($date);
|
||||
}
|
||||
|
||||
public function getSources() : array
|
||||
{
|
||||
return $this -> gateway -> findAll();
|
||||
}
|
||||
|
||||
public function deleteSource(int $id_source) : bool
|
||||
{
|
||||
return $this -> gateway -> delete($id_source);
|
||||
}
|
||||
|
||||
public function updateSource(int $id_source, string $title, string $date) : bool
|
||||
{
|
||||
$q = $this -> gateway -> findById($id_source);
|
||||
|
||||
if ($q){
|
||||
$q -> setTitle($title);
|
||||
$q -> setDate($date);
|
||||
return $this -> gateway -> update($q);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require_once($rep.$entity['user']);
|
||||
require_once($rep.$entity['quote']);
|
||||
require_once($rep.$gateway['user']);
|
||||
|
||||
class UserModel
|
||||
{
|
||||
private UserGateway $gateway;
|
||||
|
||||
public function __construct(UserGateway $gate){
|
||||
$this->gateway = $gate;
|
||||
}
|
||||
|
||||
public function insertUser(string $username,string $email,string $passwd) : User{
|
||||
global $rep,$image;
|
||||
$id = $this->gateway->insert($username,$email,$passwd);
|
||||
$u = new User($id,$usename,$passwd,$rep.$image['default'],$email);
|
||||
}
|
||||
|
||||
public function deletUser(string $id) : bool{
|
||||
return $this->gateway->delete($id);
|
||||
}
|
||||
|
||||
// public function getFavoriteUser(string $id) : array{
|
||||
// $res = array();
|
||||
// $data = $this->gateway->getFavorite($id);
|
||||
// foreach ($data as $favoris) {
|
||||
// $res[] = new Quote();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
?>
|
@ -1,4 +0,0 @@
|
||||
TesteurFichier
|
||||
motDepasseFichier
|
||||
../images/imageProfil.png
|
||||
testeurFichier.compte@wikifantasy.com
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
class CitationView {
|
||||
|
||||
public static function display($citationDuJour, $suggestions) {
|
||||
echo "<div class='citations-section'>";
|
||||
|
||||
// Afficher la citation du jour
|
||||
if ($citationDuJour) {
|
||||
$quote = htmlspecialchars(trim(substr($citationDuJour[1], 1))); // Retirer le symbole µ
|
||||
$movie = htmlspecialchars(trim($citationDuJour[2]));
|
||||
$character = htmlspecialchars(trim($citationDuJour[3]));
|
||||
$year = htmlspecialchars(trim($citationDuJour[4]));
|
||||
$imagePath = htmlspecialchars(trim($citationDuJour[5]));
|
||||
|
||||
echo "<h2>Citation du jour</h2>";
|
||||
echo "<div class='citation-container citation-du-jour'>";
|
||||
echo "<img src='$imagePath' alt='$movie' class='citation-image'>";
|
||||
echo "<div class='text-content'>";
|
||||
echo "<p class='quote'>\"$quote\"</p>";
|
||||
echo "<p class='movie'>- $movie</p>";
|
||||
echo "<p class='character'>Personnage : $character</p>";
|
||||
echo "<p class='year'>Année : $year</p>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
} else {
|
||||
echo "<p class='error'>Aucune citation du jour n'a été trouvée.</p>";
|
||||
}
|
||||
|
||||
// Filtrer les suggestions pour éviter de reprendre la citation du jour
|
||||
$filteredSuggestions = array_filter($suggestions, function($suggestion) use ($citationDuJour) {
|
||||
// Vérifie que les deux citations ne sont pas identiques
|
||||
return isset($suggestion[0]) && trim($suggestion[0]) !== trim($citationDuJour[1]);
|
||||
});
|
||||
|
||||
// Afficher les suggestions
|
||||
if (!empty($filteredSuggestions)) {
|
||||
echo "<h2>Suggestions</h2>";
|
||||
echo "<div class='suggestions-container'>"; // Conteneur pour gérer les colonnes
|
||||
foreach ($filteredSuggestions as $suggestion) {
|
||||
// Vérifier si tous les éléments requis sont bien présents dans $suggestion
|
||||
$quote = isset($suggestion[0]) ? htmlspecialchars(trim($suggestion[0])) : '';
|
||||
$movie = isset($suggestion[1]) ? htmlspecialchars(trim($suggestion[1])) : '';
|
||||
$character = isset($suggestion[2]) ? htmlspecialchars(trim($suggestion[2])) : 'Inconnu';
|
||||
$year = isset($suggestion[3]) ? htmlspecialchars(trim($suggestion[3])) : 'Inconnue';
|
||||
$imagePath = isset($suggestion[4]) ? htmlspecialchars(trim($suggestion[4])) : 'images/default.jpg';
|
||||
|
||||
echo "<div class='citation-container suggestion'>";
|
||||
echo "<img src='$imagePath' alt='$movie' class='citation-image'>";
|
||||
echo "<div class='text-content'>";
|
||||
echo "<p class='quote'>\"$quote\"</p>";
|
||||
echo "<p class='movie'>- $movie</p>";
|
||||
echo "<p class='character'>- Personnage : $character</p>";
|
||||
echo "<p class='year'>- Année : $year</p>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
echo "</div>"; // Fin du conteneur suggestions
|
||||
}
|
||||
|
||||
echo "</div>"; // Fin de la section des citations
|
||||
echo "</body></html>"; // Clôture la structure HTML
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class HeaderView {
|
||||
|
||||
public static function display($theme) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Wiki Fantasy</title>
|
||||
<link id="favicon" rel="icon" href="../images/dark.svg" type="image/x-icon" />
|
||||
<script src="../script/truncateQuotes.js"></script>
|
||||
<link rel="stylesheet" href="<?php global $rep,$style; echo $rep.$style['accueil']; ?>"> <!-- Import de styleAccueil.css -->
|
||||
<script defer src="../script/theme-toggle.js"></script> <!-- Import du script -->
|
||||
</head>
|
||||
<body class="<?php echo htmlspecialchars($theme); ?>">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="nav">
|
||||
<a href="favorite.html"><img src="../../images/coeur.svg" alt="coeur" width="67px" height="67px" onmousedown="return false"></a>
|
||||
<img id="theme-icon" src="../images/dark.svg" alt="toggle theme" width="72px" height="37px" onmousedown="return false" onclick="toggleTheme()">
|
||||
<a href="quiz.html"><img src="../../images/quizz.svg" alt="quizz" width="51px" height="82px" onmousedown="return false"></a>
|
||||
</div>
|
||||
<div class="logo">
|
||||
<a href="accueil.html"><img src="../../images/WIKIFANTASY.png" alt="Logo" width="227px" height="106px" onmousedown="return false"></a>
|
||||
</div>
|
||||
<div class="user">
|
||||
<a href="profil.html"><img src="../../images/user_dark.png" alt="user" width="70px" height="70px" onmousedown="return false"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
require (__DIR__.'/HeaderView.php');
|
||||
//require ($rep.$vues['bandeau']);
|
||||
//require ($rep.$vues['citation']);
|
||||
?>
|