@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DAL;
|
|
||||||
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class AdminGateway
|
|
||||||
{
|
|
||||||
private $con;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $con
|
|
||||||
*/
|
|
||||||
public function __construct($con)
|
|
||||||
{
|
|
||||||
$this->con = $con;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function login(string $login):array
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
$query = 'SELECT password,mail FROM Admin WHERE name = :login;';
|
|
||||||
$this->con->executeQuery($query, array(':login' => array($login, PDO::PARAM_STR)));
|
|
||||||
return $this->con->getResults();
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new \Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace DAL;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use metier\Article;
|
|
||||||
use PDO;
|
|
||||||
class ArticleGateway
|
|
||||||
{
|
|
||||||
private $con;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $con
|
|
||||||
*/
|
|
||||||
public function __construct($con)
|
|
||||||
{
|
|
||||||
$this->con = $con;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function getAllArticles():array
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$query = 'SELECT * FROM Article;';
|
|
||||||
$this->con->executeQuery($query, array());
|
|
||||||
return $this->con->getResults();
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function addArticle(Article $article){
|
|
||||||
try {
|
|
||||||
$query = 'INSERT INTO Article VALUES (:id,:title,to_date(:date,"Dy, DD Mon YYYY"),:description,:guid,:link,:mediaContent,:provenance);';
|
|
||||||
$this->con->executeQuery($query, array(':id' => array($article->getId(), PDO::PARAM_STR),
|
|
||||||
':title' => array($article->getTitle(), PDO::PARAM_STR),
|
|
||||||
':date' => array($article->getDate(), PDO::PARAM_STR),
|
|
||||||
':description' => array($article->getDescription(), PDO::PARAM_STR),
|
|
||||||
':guid' => array($article->getGuid(), PDO::PARAM_STR),
|
|
||||||
':link' => array($article->getLink(), PDO::PARAM_STR),
|
|
||||||
':mediaContent' => array($article->getMediaContent(), PDO::PARAM_STR),
|
|
||||||
':provenance' => array($article->getProvenance(), PDO::PARAM_INT)));
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAllArticleForParser(){
|
|
||||||
try{
|
|
||||||
$query = 'DELETE FROM Article;';
|
|
||||||
$this->con->executeQuery($query);
|
|
||||||
}catch(\PDOException $p){
|
|
||||||
throw new Exception("Data is not delete.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DAL;
|
|
||||||
|
|
||||||
use metier\Flux;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class FluxGateway
|
|
||||||
{
|
|
||||||
private Connection $con;
|
|
||||||
|
|
||||||
public function __construct(Connection $con){
|
|
||||||
$this->con = $con;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFlux($flux){
|
|
||||||
try{
|
|
||||||
$query = 'INSERT INTO Flux VALUES (:flux);';
|
|
||||||
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new \Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFlux($flux){
|
|
||||||
try{
|
|
||||||
$query = 'DELETE FROM Flux WHERE flux = :flux;';
|
|
||||||
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new \Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findAllFlux(){
|
|
||||||
try{
|
|
||||||
$query = 'SELECT * FROM Flux;';
|
|
||||||
$this->con->executeQuery($query);
|
|
||||||
return $this->con->getResults();
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new \Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findFlux(Flux $flux){
|
|
||||||
return $this->findFluxBySrc($flux->getFlux());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findFluxBySrc(string $flux){
|
|
||||||
try{
|
|
||||||
$query = 'SELECT * FROM Flux WHERE flux = :flux;';
|
|
||||||
$this->con->executeQuery($query, array(':flux' => array($flux, PDO::PARAM_STR)));
|
|
||||||
return $this->con->getResults();
|
|
||||||
}catch (\PDOException $e){
|
|
||||||
throw new \Exception("PDO error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace model;
|
|
||||||
|
|
||||||
use DAL\{ArticleGateway, Connection};
|
|
||||||
use Exception;
|
|
||||||
use metier\Article;
|
|
||||||
|
|
||||||
class ArticleModel
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static function getArticles() : array
|
|
||||||
{
|
|
||||||
$gwArticle = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$tabArticle = array();
|
|
||||||
$res = $gwArticle->getAllArticles();
|
|
||||||
foreach($res as $row){
|
|
||||||
$tabArticle[] = new Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );
|
|
||||||
}
|
|
||||||
return $tabArticle;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace model;
|
|
||||||
|
|
||||||
use DAL\Connection;
|
|
||||||
use DAL\FluxGateway;
|
|
||||||
use metier\Flux;
|
|
||||||
require_once "config/config.php";
|
|
||||||
|
|
||||||
class FluxModel
|
|
||||||
{
|
|
||||||
public function FindAllFlux(){
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$data = array();
|
|
||||||
$result = $gateway->findAllFlux();
|
|
||||||
|
|
||||||
foreach ($result as $row){
|
|
||||||
$data[] = new Flux($row['$flux']);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFlux(Flux $flux){
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$data = $this->findFlux($flux);
|
|
||||||
if ($data == array()) {
|
|
||||||
$gateway->addFlux($flux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFluxBySrc(string $flux): Flux {
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$newFlux = new Flux($flux);
|
|
||||||
$gateway->addFlux($newFlux);
|
|
||||||
return $newFlux;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFlux(Flux $flux){
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$gateway->removeFlux($flux);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFluxBySrc(string $flux): Flux {
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$newFlux = new Flux($flux);
|
|
||||||
$gateway->removeFlux($newFlux);
|
|
||||||
return $newFlux;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findFlux(Flux $flux){
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$data = array();
|
|
||||||
$result = $gateway->findFlux($flux);
|
|
||||||
|
|
||||||
foreach ($result as $row){
|
|
||||||
$data[] = new Flux($row['$flux']);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findFluxBySrc(string $flux){
|
|
||||||
$gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
|
||||||
$data = array();
|
|
||||||
$result = $gateway->findFluxBySrc($flux);
|
|
||||||
|
|
||||||
foreach ($result as $row){
|
|
||||||
$data[] = new Flux($row['$flux']);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DAL;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class AdminGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $con
|
||||||
|
*/
|
||||||
|
public function __construct($con)
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(string $login):array
|
||||||
|
{
|
||||||
|
$query = 'SELECT password,mail FROM Admin WHERE name = :login;';
|
||||||
|
$this->con->executeQuery($query, array(':login' => array($login, PDO::PARAM_STR)));
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
namespace DAL;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use metier\Article;
|
||||||
|
use metier\Flux;
|
||||||
|
use PDO;
|
||||||
|
class ArticleGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $con
|
||||||
|
*/
|
||||||
|
public function __construct($con)
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getAllArticles():array
|
||||||
|
{
|
||||||
|
$query = 'SELECT * FROM Article;';
|
||||||
|
$this->con->executeQuery($query, array());
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function addArticle(Article $article){
|
||||||
|
$query = 'INSERT INTO Article VALUES (:id,:title,to_date(:date,"Dy, DD Mon YYYY"),:description,:guid,:link,:mediaContent,:provenance);';
|
||||||
|
$this->con->executeQuery($query, array(':id' => array($article->getId(), PDO::PARAM_STR),
|
||||||
|
':title' => array($article->getTitle(), PDO::PARAM_STR),
|
||||||
|
':datePub' => array($article->getDate(), PDO::PARAM_STR),
|
||||||
|
':description' => array($article->getDescription(), PDO::PARAM_STR),
|
||||||
|
':guid' => array($article->getGuid(), PDO::PARAM_STR),
|
||||||
|
':link' => array($article->getLink(), PDO::PARAM_STR),
|
||||||
|
':mediaContent' => array($article->getMediaContent(), PDO::PARAM_STR),
|
||||||
|
':provenance' => array($article->getProvenance(), PDO::PARAM_INT)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeAllArticleForParser(){
|
||||||
|
$query = 'DELETE FROM Article;';
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findArticleByFlux(int $flux){
|
||||||
|
$query = 'SELECT * FROM Article WHERE provenance = :flux;';
|
||||||
|
$this->con->executeQuery($query, array(':flux' => array($flux, PDO::PARAM_INT)));
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DAL;
|
||||||
|
|
||||||
|
use metier\Flux;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class FluxGateway
|
||||||
|
{
|
||||||
|
private Connection $con;
|
||||||
|
|
||||||
|
public function __construct(Connection $con){
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFlux(Flux $flux)
|
||||||
|
{
|
||||||
|
$query = 'INSERT INTO Flux VALUES (:flux);';
|
||||||
|
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeFlux(Flux $flux){
|
||||||
|
$query = 'DELETE FROM Flux WHERE flux = :flux;';
|
||||||
|
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAllFlux(){
|
||||||
|
|
||||||
|
$query = 'SELECT * FROM Flux;';
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findFlux(Flux $flux){
|
||||||
|
return $this->findFluxBySrc($flux->getFlux());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findFluxBySrc(string $flux){
|
||||||
|
$query = 'SELECT * FROM Flux WHERE flux = :flux;';
|
||||||
|
$this->con->executeQuery($query, array(':flux' => array($flux, PDO::PARAM_STR)));
|
||||||
|
return $this->con->getResults();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
namespace controleur;
|
||||||
|
|
||||||
|
use model\ArticleModel;
|
||||||
|
|
||||||
|
class UserControleur
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
global $twig; // nécessaire pour utiliser variables globales
|
||||||
|
session_start();
|
||||||
|
//debut
|
||||||
|
|
||||||
|
//on initialise un tableau d'erreur
|
||||||
|
$dVueEreur = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$action = $_REQUEST['action'] ?? null;
|
||||||
|
|
||||||
|
switch($action) {
|
||||||
|
//pas d'action, on réinitialise 1er appel
|
||||||
|
case null:
|
||||||
|
$this->Reinit();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'validationFormulaire':
|
||||||
|
$this->ValidationFormulaire($dVueEreur);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//mauvaise action
|
||||||
|
default:
|
||||||
|
$tabArticle[] = ArticleModel::getArticles();
|
||||||
|
$dVueEreur[] = "Erreur d'appel php";
|
||||||
|
$dataview = ['Article'=> $tabArticle];
|
||||||
|
echo $twig->render('listArticle.html', ['tabArticle' => $dataview, 'dVueErreur'=>$dVueEreur]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
//si erreur BD, pas le cas ici
|
||||||
|
$dVueEreur[] = 'Erreur PDO : ' . $e->getMessage();
|
||||||
|
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
|
||||||
|
} catch (\Exception $e2) {
|
||||||
|
$dVueEreur[] = 'Erreur : ' . $e2->getMessage();
|
||||||
|
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//fin
|
||||||
|
exit(0);
|
||||||
|
}//fin constructeur
|
||||||
|
|
||||||
|
public function Reinit()
|
||||||
|
{
|
||||||
|
global $twig; // nécessaire pour utiliser variables globales
|
||||||
|
$dVue = [
|
||||||
|
'nom' => '',
|
||||||
|
'age' => 0,
|
||||||
|
'data' => ArticleModel::getArticles()
|
||||||
|
];
|
||||||
|
echo $twig->render('listArticle.html', [
|
||||||
|
'dVue' => $dVue
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ValidationFormulaire(array $dVueEreur)
|
||||||
|
{
|
||||||
|
global $twig; // nécessaire pour utiliser variables globales
|
||||||
|
|
||||||
|
//si exception, ca remonte !!!
|
||||||
|
$nom = $_POST['txtNom']; // txtNom = nom du champ texte dans le formulaire
|
||||||
|
$age = $_POST['txtAge'];
|
||||||
|
\config\Validation::val_form($nom, $age, $dVueEreur);
|
||||||
|
|
||||||
|
/*
|
||||||
|
$model = new \metier\Simplemodel();
|
||||||
|
$data = $model->get_data();
|
||||||
|
*/
|
||||||
|
|
||||||
|
$dVue = [
|
||||||
|
'nom' => $nom,
|
||||||
|
'age' => $age,
|
||||||
|
//'data' => $data,
|
||||||
|
];
|
||||||
|
|
||||||
|
echo $twig->render('Connection.html', ['dVue' => $dVue, 'dVueEreur' => $dVueEreur]);
|
||||||
|
}
|
||||||
|
}//fin class
|
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use DAL\{ArticleGateway, Connection, FluxGateway};
|
||||||
|
use Exception;
|
||||||
|
use metier\Article;
|
||||||
|
use metier\Flux;
|
||||||
|
|
||||||
|
class ArticleModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function getArticles() : array
|
||||||
|
{
|
||||||
|
$gwArticle = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$tabArticle = array();
|
||||||
|
$res = $gwArticle->getAllArticles();
|
||||||
|
foreach($res as $row){
|
||||||
|
$tabArticle[] = new Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );
|
||||||
|
}
|
||||||
|
return $tabArticle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function findArticleByFlux(Flux $flux){
|
||||||
|
$con = new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp');
|
||||||
|
$gwArticle = new ArticleGateway($con);
|
||||||
|
$dicoFluxArticle = array();
|
||||||
|
$tabArticle = array();
|
||||||
|
$res = $gwArticle->findArticleByFlux($flux->getId());
|
||||||
|
|
||||||
|
foreach ($res as $row){
|
||||||
|
$tabArticle[] = new Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );
|
||||||
|
}
|
||||||
|
$dicoFluxArticle[] = [$flux,$tabArticle];
|
||||||
|
return $dicoFluxArticle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAllArticleByAllFlux(){
|
||||||
|
$con = new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp');
|
||||||
|
$gwFlux = new FluxGateway($con);
|
||||||
|
$tabFluxArticle = array();
|
||||||
|
$res = $gwFlux->findAllFlux();
|
||||||
|
|
||||||
|
foreach ($res as $row) {
|
||||||
|
$flux = new Flux($row['flux'], (int)($row['id']));
|
||||||
|
$tabFluxArticle[] = $this->findArticleByFluxAsStr($flux);
|
||||||
|
}
|
||||||
|
return $tabFluxArticle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findArticleByFluxAsStr(Flux $flux){
|
||||||
|
$con = new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp');
|
||||||
|
$gwArticle = new ArticleGateway($con);
|
||||||
|
$tabArticle = array();
|
||||||
|
$res = $gwArticle->findArticleByFlux($flux->getId());
|
||||||
|
|
||||||
|
foreach ($res as $row){
|
||||||
|
$article = new Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );
|
||||||
|
$tabArticle[] = (string)$article;
|
||||||
|
}
|
||||||
|
$dicoFluxArticle = [$flux,$tabArticle];
|
||||||
|
return $dicoFluxArticle;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use DAL\Connection;
|
||||||
|
use DAL\FluxGateway;
|
||||||
|
use metier\Flux;
|
||||||
|
|
||||||
|
class FluxModel
|
||||||
|
{
|
||||||
|
public function FindAllFlux(){
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$data = array();
|
||||||
|
$result = $gateway->findAllFlux();
|
||||||
|
|
||||||
|
foreach ($result as $row){
|
||||||
|
$data[] = new Flux((int)$row['id'],$row['$flux']);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFlux(Flux $flux){
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$data = $this->findFlux($flux);
|
||||||
|
if ($data == array()) {
|
||||||
|
$gateway->addFlux($flux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFluxBySrc(string $flux): Flux {
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$newFlux = new Flux($flux);
|
||||||
|
$gateway->addFlux($newFlux);
|
||||||
|
return $newFlux;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeFlux(Flux $flux){
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$gateway->removeFlux($flux);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeFluxBySrc(string $flux) {
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$gateway->removeFlux($flux);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findFlux(Flux $flux){
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$data = array();
|
||||||
|
$result = $gateway->findFlux($flux);
|
||||||
|
|
||||||
|
foreach ($result as $row){
|
||||||
|
$data[] = new Flux($row['$flux'],(int)$row['id']);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findFluxBySrc(string $flux){
|
||||||
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
||||||
|
$data = array();
|
||||||
|
$result = $gateway->findFluxBySrc($flux);
|
||||||
|
|
||||||
|
foreach ($result as $row){
|
||||||
|
$data[] = new Flux($row['$flux'],(int)$row['id']);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace test;
|
||||||
|
use DAL\ArticleGateway;
|
||||||
|
use DAL\Connection;
|
||||||
|
use DAL\FluxGateway;
|
||||||
|
use model\Parser;
|
||||||
|
|
||||||
|
require '../../vendor/autoload.php';
|
||||||
|
|
||||||
|
$gwArt = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
|
||||||
|
$gwFl = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
|
||||||
|
$pars = new Parser( $gwFl,$gwArt);
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>All Articles</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
admin
|
||||||
|
{% for value in dVue.data %}
|
||||||
|
<div>
|
||||||
|
{{ value.0.getFlux() }}
|
||||||
|
<form method="post" action="deleteFlux">
|
||||||
|
<input type="hidden" name="flux" value="{{ value.0 }}">
|
||||||
|
<button type="submit">Delete Flux</button>
|
||||||
|
</form>
|
||||||
|
{% for article in value.1 %}
|
||||||
|
<p>
|
||||||
|
{{article}}
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/">Vue user</a>
|
||||||
|
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/deconnection">Déconnection</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in new issue