commit
7ca707374e
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/fluxRSS/DAL/ArticleGateway.php" dialect="PostgreSQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace DAL;
|
|
||||||
|
|
||||||
use metier\Article;
|
|
||||||
use PDO;
|
|
||||||
class ArticleGateway
|
|
||||||
{
|
|
||||||
private $con;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $con
|
|
||||||
*/
|
|
||||||
public function __construct($con)
|
|
||||||
{
|
|
||||||
$this->con = $con;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllArticles():array
|
|
||||||
{
|
|
||||||
$query = 'SELECT * FROM Article;';
|
|
||||||
$this->con->executeQuery($query, array());
|
|
||||||
return $this->con->getResults();
|
|
||||||
}
|
|
||||||
|
|
||||||
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),
|
|
||||||
':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)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +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){
|
|
||||||
$query = 'INSERT INTO Flux VALUES (:flux);';
|
|
||||||
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFlux($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,258 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "03e1f7c6d7574f3683225067dbb2becc",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-ctype",
|
||||||
|
"version": "v1.28.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||||
|
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
|
||||||
|
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-ctype": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-ctype": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.28-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Ctype\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Gert de Pagter",
|
||||||
|
"email": "BackEndTea@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for ctype functions",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"ctype",
|
||||||
|
"polyfill",
|
||||||
|
"portable"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-01-26T09:26:14+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-mbstring",
|
||||||
|
"version": "v1.28.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||||
|
"reference": "42292d99c55abe617799667f454222c54c60e229"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229",
|
||||||
|
"reference": "42292d99c55abe617799667f454222c54c60e229",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-mbstring": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.28-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for the Mbstring extension",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"mbstring",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-07-28T09:04:16+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "twig/twig",
|
||||||
|
"version": "v3.7.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
|
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||||
|
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2.5",
|
||||||
|
"symfony/polyfill-ctype": "^1.8",
|
||||||
|
"symfony/polyfill-mbstring": "^1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"psr/container": "^1.0|^2.0",
|
||||||
|
"symfony/phpunit-bridge": "^5.4.9|^6.3"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Twig\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com",
|
||||||
|
"homepage": "http://fabien.potencier.org",
|
||||||
|
"role": "Lead Developer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Twig Team",
|
||||||
|
"role": "Contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Armin Ronacher",
|
||||||
|
"email": "armin.ronacher@active-4.com",
|
||||||
|
"role": "Project Founder"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||||
|
"homepage": "https://twig.symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"templating"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
|
"source": "https://github.com/twigphp/Twig/tree/v3.7.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-08-28T11:09:02+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": {
|
||||||
|
"ext-pdo": "*",
|
||||||
|
"ext-dom": "*"
|
||||||
|
},
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace model;
|
|
||||||
|
|
||||||
use DAL;
|
|
||||||
use metier;
|
|
||||||
|
|
||||||
class ArticleModel
|
|
||||||
{
|
|
||||||
public static function getArticles() : array
|
|
||||||
{
|
|
||||||
$gwArticle = new DAL\ArticleGateway(new DAL\Connection( 'mysql:host = localhost; dbname = dbrorossetto', 'rorossetto','tpphp'));
|
|
||||||
$res = $gwArticle->getAllArticles();
|
|
||||||
foreach($res as $row){
|
|
||||||
$tabArticle[] = new metier\Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );
|
|
||||||
}
|
|
||||||
return $tabArticle;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace model;
|
|
||||||
|
|
||||||
use DAL\FluxGateway;
|
|
||||||
use metier\Flux;
|
|
||||||
|
|
||||||
class FluxModel
|
|
||||||
{
|
|
||||||
private FluxGateway $gateway;
|
|
||||||
|
|
||||||
public function __construct(FluxGateway $fluxGateway){
|
|
||||||
$this->gateway = $fluxGateway;
|
|
||||||
}
|
|
||||||
public function FindAllFlux(){
|
|
||||||
$data = array();
|
|
||||||
$result = $this->gateway->findAllFlux();
|
|
||||||
|
|
||||||
foreach ($result as $row){
|
|
||||||
$data[] = new Flux($row['$flux']);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFlux(Flux $flux)
|
|
||||||
{
|
|
||||||
$data = $this->findFlux($flux);
|
|
||||||
if ($data == array()) {
|
|
||||||
$this->gateway->addFlux($flux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFluxBySrc(string $flux): Flux {
|
|
||||||
$newFlux = new Flux($flux);
|
|
||||||
$this->gateway->addFlux($newFlux);
|
|
||||||
return $newFlux;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFlux(Flux $flux){
|
|
||||||
$this->gateway->removeFlux($flux);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFluxBySrc(string $flux): Flux {
|
|
||||||
$newFlux = new Flux($flux);
|
|
||||||
$this->gateway->removeFlux($newFlux);
|
|
||||||
return $newFlux;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findFlux(Flux $flux){
|
|
||||||
$data = array();
|
|
||||||
$result = $this->gateway->findFlux($flux);
|
|
||||||
|
|
||||||
foreach ($result as $row){
|
|
||||||
$data[] = new Flux($row['$flux']);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findFluxBySrc(string $flux){
|
|
||||||
$data = array();
|
|
||||||
$result = $this->gateway->findFluxBySrc($flux);
|
|
||||||
|
|
||||||
foreach ($result as $row){
|
|
||||||
$data[] = new Flux($row['$flux']);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DAL;
|
||||||
|
|
||||||
|
class AdminGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $con
|
||||||
|
*/
|
||||||
|
public function __construct($con)
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(string $login):array
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
$query = 'SELECT mdp,mail FROM Admin WHERE login = :login;';
|
||||||
|
$this->con->executeQuery($query, array(':flux' => array($login, PDO::PARAM_STR)));
|
||||||
|
return $this->con->getResults();
|
||||||
|
}catch (\PDOException $e){
|
||||||
|
throw new \Exception("PDO error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<?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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
<?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,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
//gen
|
//gen
|
||||||
$rep = __DIR__ . '/../';
|
$rep = __DIR__ . '/fluxRSS/';
|
||||||
|
|
||||||
// liste des modules à inclure
|
// liste des modules à inclure
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use metier\Admin;
|
||||||
|
|
||||||
|
class AdminModel
|
||||||
|
{
|
||||||
|
public function connection (string $username, string $mdp){
|
||||||
|
//Validation::validationLogin($login);
|
||||||
|
//Validation::validationMdp($mdp);
|
||||||
|
|
||||||
|
$gwArticle = new AdminGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
|
||||||
|
$lmdp = $gwArticle->login($username);
|
||||||
|
|
||||||
|
foreach ($lmdp as $motDePasse){
|
||||||
|
if (password_verify($mdp,$motDePasse['mdp'])){
|
||||||
|
$_SESSION['role'] = 'admin';
|
||||||
|
$_SESSION['pseudo'] = $username;
|
||||||
|
return new Admin($username,$motDePasse['mail']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
<?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,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>All Articles</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% for value in dVue.data %}
|
||||||
|
<p>
|
||||||
|
{% for article in value}
|
||||||
|
<p>
|
||||||
|
{{article}}
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>All Articles</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% for value in dataview.tabArticle.Article %}
|
|
||||||
<p>{{value}}</p>
|
|
||||||
{% endfor %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||||||
|
https://perso.limos.fr/~sesalva/files/php/Tp2A/tp1/projets.html
|
||||||
|
parser add article to the bd
|
||||||
|
X article par page lors de recherche
|
||||||
|
admin peut ajouter/suppr/modif flux rss, modif nb d'article par page
|
||||||
|
|
||||||
|
flux rss = fichier xml qui contient news
|
||||||
|
parser doit parser le flux rss pour créer un article
|
||||||
|
php inclut parser xml
|
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue