diff --git a/.idea/sqldialects.xml~pre-master b/.idea/sqldialects.xml~pre-master
new file mode 100755
index 0000000..ff83d34
--- /dev/null
+++ b/.idea/sqldialects.xml~pre-master
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/fluxRSS/.idea/mvc_PSR4_twig.iml b/fluxRSS/.idea/mvc_PSR4_twig.iml
index e520f52..1323748 100755
--- a/fluxRSS/.idea/mvc_PSR4_twig.iml
+++ b/fluxRSS/.idea/mvc_PSR4_twig.iml
@@ -2,11 +2,14 @@
-
-
-
+
+
+
+
+
+
diff --git a/fluxRSS/composer.json b/fluxRSS/composer.json
index 2ef7dc7..c412f39 100755
--- a/fluxRSS/composer.json
+++ b/fluxRSS/composer.json
@@ -6,11 +6,12 @@
},
"autoload": {
"psr-4": {
- "controleur\\": "controleur/",
- "config\\": "config/",
- "model\\": "model/",
- "DAL\\": "DAL/",
- "metier\\": "metier/"
+ "src\\": "src/",
+ "controleur\\": "src/controleur/",
+ "config\\": "src/config/",
+ "model\\": "src/model/",
+ "DAL\\": "src/DAL/",
+ "metier\\": "src/metier/"
}
}
}
diff --git a/fluxRSS/index.php b/fluxRSS/index.php
index 1eb4352..e187b78 100755
--- a/fluxRSS/index.php
+++ b/fluxRSS/index.php
@@ -1,7 +1,7 @@
con->executeQuery($query, array(':id' => array($article->getId(), PDO::PARAM_STR),
+ $query = 'INSERT INTO Article VALUES (:id,:title,:datePub,:description,:guid,:link,:mediaContent,:provenance);';
+ $this->con->executeQuery($query, array(':id' => array($article->getId(), PDO::PARAM_INT),
':title' => array($article->getTitle(), PDO::PARAM_STR),
- ':date' => array($article->getDate(), 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),
@@ -54,7 +54,7 @@ class ArticleGateway
$query = 'DELETE FROM Article;';
$this->con->executeQuery($query);
}catch(\PDOException $p){
- throw new Exception("Data is not delete.");
+ throw new Exception("Data is not deleted.");
}
}
}
\ No newline at end of file
diff --git a/fluxRSS/DAL/Connection.php b/fluxRSS/src/DAL/Connection.php
similarity index 77%
rename from fluxRSS/DAL/Connection.php
rename to fluxRSS/src/DAL/Connection.php
index dc58de2..00952cf 100755
--- a/fluxRSS/DAL/Connection.php
+++ b/fluxRSS/src/DAL/Connection.php
@@ -42,10 +42,17 @@ class Connection extends PDO
foreach ($parameters as $name => $value) {
$this->stmt->bindValue($name, $value[0], $value[1]);
}
+ if($this->stmt->execute()){
+ return true;
+ } else {
+ $error = $this->stmt->errorInfo();
+ throw new Exception("PDO error: ".$error[2]);
+ }
- return $this->stmt->execute();
}catch (\PDOException $e){
- throw new Exception("PDO error");
+ throw new Exception("PDO error: ".$e->getMessage());
+ }catch (\Error $r){
+ throw new Error("executionQuery not possible : ".$r->getMessage());
}
}
diff --git a/fluxRSS/DAL/FluxGateway.php b/fluxRSS/src/DAL/FluxGateway.php
similarity index 90%
rename from fluxRSS/DAL/FluxGateway.php
rename to fluxRSS/src/DAL/FluxGateway.php
index 43bbe9f..87d27a9 100755
--- a/fluxRSS/DAL/FluxGateway.php
+++ b/fluxRSS/src/DAL/FluxGateway.php
@@ -13,6 +13,12 @@ class FluxGateway
$this->con = $con;
}
+ public function getId(): int
+ {
+
+ return $this->id;
+ }
+
public function addFlux($flux){
try{
$query = 'INSERT INTO Flux VALUES (:flux);';
@@ -35,7 +41,8 @@ class FluxGateway
try{
$query = 'SELECT * FROM Flux;';
$this->con->executeQuery($query);
- return $this->con->getResults();
+ $results = $this->con->getResults();
+ return $results;
}catch (\PDOException $e){
throw new \Exception("PDO error");
}
diff --git a/fluxRSS/config/.DS_Store b/fluxRSS/src/config/.DS_Store
similarity index 100%
rename from fluxRSS/config/.DS_Store
rename to fluxRSS/src/config/.DS_Store
diff --git a/fluxRSS/config/Validation.php b/fluxRSS/src/config/Validation.php
similarity index 100%
rename from fluxRSS/config/Validation.php
rename to fluxRSS/src/config/Validation.php
diff --git a/fluxRSS/config/config.php b/fluxRSS/src/config/config.php
similarity index 88%
rename from fluxRSS/config/config.php
rename to fluxRSS/src/config/config.php
index 50be0df..ce73183 100755
--- a/fluxRSS/config/config.php
+++ b/fluxRSS/src/config/config.php
@@ -1,7 +1,7 @@
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
diff --git a/fluxRSS/controleur/FrontControleur.php b/fluxRSS/src/controleur/FrontControleur.php
similarity index 97%
rename from fluxRSS/controleur/FrontControleur.php
rename to fluxRSS/src/controleur/FrontControleur.php
index 820cb13..6995f84 100755
--- a/fluxRSS/controleur/FrontControleur.php
+++ b/fluxRSS/src/controleur/FrontControleur.php
@@ -11,6 +11,9 @@ require 'AltoRouter.php';
class FrontControleur
{
public function __construct(){
+ $routeur = new AltoRouter();
+
+
global $twig;
$router = new AltoRouter();
@@ -50,4 +53,6 @@ class FrontControleur
}
}
}
+
+
}
\ No newline at end of file
diff --git a/fluxRSS/metier/Admin.php b/fluxRSS/src/metier/Admin.php
similarity index 100%
rename from fluxRSS/metier/Admin.php
rename to fluxRSS/src/metier/Admin.php
diff --git a/fluxRSS/metier/Article.php b/fluxRSS/src/metier/Article.php
similarity index 87%
rename from fluxRSS/metier/Article.php
rename to fluxRSS/src/metier/Article.php
index 809c3d1..6a2c8b2 100755
--- a/fluxRSS/metier/Article.php
+++ b/fluxRSS/src/metier/Article.php
@@ -4,26 +4,34 @@ namespace metier;
class Article
{
- private string $id;
+ private int $id;
private string $title;
private string $date;
private string $description;
private string $guid;
private string $link;
private string $mediaContent;
- private string $provenance;
+ private int $provenance;
/**
- * @param string $id
+ * @param int $id
* @param string $title
* @param string $date
* @param string $description
* @param string $guid
* @param string $link
* @param string $mediaContent
- * @param string $provenance
+ * @param int $provenance
*/
- public function __construct(string $id, string $title, string $date, string $description, string $guid, string $link, string $mediaContent, string $provenance)
+ public function __construct(
+ ?int $id,
+ string $title,
+ string $date,
+ string $description,
+ string $guid,
+ string $link,
+ string $mediaContent,
+ int $provenance)
{
$this->id = $id;
$this->title = $title;
diff --git a/fluxRSS/metier/Flux.php b/fluxRSS/src/metier/Flux.php
similarity index 58%
rename from fluxRSS/metier/Flux.php
rename to fluxRSS/src/metier/Flux.php
index a167fbe..70a07ad 100755
--- a/fluxRSS/metier/Flux.php
+++ b/fluxRSS/src/metier/Flux.php
@@ -4,9 +4,19 @@ namespace metier;
class Flux
{
- private string $id;
+ private int $id;
private string $flux;
+ /**
+ * @param int $id
+ * @param string $flux
+ */
+ public function __construct(int $id, string $flux)
+ {
+ $this->id = $id;
+ $this->flux = $flux;
+ }
+
/**
* @return string
*/
@@ -24,9 +34,9 @@ class Flux
}
/**
- * @return string
+ * @return int
*/
- public function getId(): string
+ public function getId(): int
{
return $this->id;
}
diff --git a/fluxRSS/model/AdminModel.php b/fluxRSS/src/model/AdminModel.php
similarity index 100%
rename from fluxRSS/model/AdminModel.php
rename to fluxRSS/src/model/AdminModel.php
diff --git a/fluxRSS/model/ArticleModel.php b/fluxRSS/src/model/ArticleModel.php
similarity index 100%
rename from fluxRSS/model/ArticleModel.php
rename to fluxRSS/src/model/ArticleModel.php
diff --git a/fluxRSS/model/FluxModel.php b/fluxRSS/src/model/FluxModel.php
similarity index 79%
rename from fluxRSS/model/FluxModel.php
rename to fluxRSS/src/model/FluxModel.php
index 5116de9..1cf740e 100755
--- a/fluxRSS/model/FluxModel.php
+++ b/fluxRSS/src/model/FluxModel.php
@@ -10,7 +10,7 @@ require_once "config/config.php";
class FluxModel
{
public function FindAllFlux(){
- $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
+ $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$data = array();
$result = $gateway->findAllFlux();
@@ -21,7 +21,7 @@ class FluxModel
}
public function addFlux(Flux $flux){
- $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
+ $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$data = $this->findFlux($flux);
if ($data == array()) {
$gateway->addFlux($flux);
@@ -29,26 +29,26 @@ class FluxModel
}
public function addFluxBySrc(string $flux): Flux {
- $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
+ $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 = 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'));
+ $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'));
+ $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$data = array();
$result = $gateway->findFlux($flux);
@@ -59,7 +59,7 @@ class FluxModel
}
public function findFluxBySrc(string $flux){
- $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp'));
+ $gateway = new FluxGateway(new Connection('mysql:host= londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$data = array();
$result = $gateway->findFluxBySrc($flux);
diff --git a/fluxRSS/model/Parser.php b/fluxRSS/src/model/Parser.php
similarity index 68%
rename from fluxRSS/model/Parser.php
rename to fluxRSS/src/model/Parser.php
index beb59f8..e2d75c1 100755
--- a/fluxRSS/model/Parser.php
+++ b/fluxRSS/src/model/Parser.php
@@ -23,24 +23,29 @@ class Parser
{
$dom = new DOMDocument();
$tabArticle = array();
-
if ($dom->load($flux->getFlux())){
$items = $dom->getElementsByTagName('item');
-
foreach ($items as $item) {
$title = $item->getElementsByTagName('title')[0]->nodeValue;
$date = $item->getElementsByTagName('pubDate')[0]->nodeValue;
$guid = $item->getElementsByTagName('guid')[0]->nodeValue;
$link = $item->getElementsByTagName('link')[0]->nodeValue;
$description = $item->getElementsByTagName('description')[0]->nodeValue;
-
$media = $item->getElementsByTagName('media:content');
$mediaUrl = null;
if ($media->length > 0){
$mediaUrl = $media->item(0)->getAttribute('url');
}
- $tabArticle[] = new Article((int)null, $title, $date, $description, $guid, $link, $mediaUrl, $flux->getId());
+ $tabArticle[] = new Article(
+ (int)null,
+ $title,
+ $date,
+ $description,
+ $guid,
+ $link,
+ ($mediaUrl !== null) ? (string)$mediaUrl : '',
+ $flux->getId());
}
return $tabArticle;
} else {
@@ -54,8 +59,11 @@ class Parser
* @throws Exception
*/
public function parseAll($fluxes){
+ $tabArticles = [];
foreach ($fluxes as $flux){
- $tabArticles[] =$this->parseArticles($flux);
+ $fluxx = new Flux($flux[0],$flux[1]);
+ $tabArticles[] = $this->parseArticles($fluxx);
+
}
return $tabArticles;
}
@@ -65,20 +73,27 @@ class Parser
*/
public function addAllArticles()
{
+ $tabFluxes = [];
$this->articleGateway->removeAllArticleForParser();
- $allFlux = $this->fluxGateway->findAllFlux();
- $allArticles = $this->parseAll($allFlux);
- foreach ($allArticles as $article) {
- $this->articleGateway->addArticle($article);
+ $allItemFlux = $this->fluxGateway->findAllFlux();
+ foreach ($allItemFlux as $ItemFlux){
+ $tabFluxes[] = $ItemFlux[1];
+ }
+ $allTabArticles = $this->parseAll($allItemFlux);
+
+ foreach ($allTabArticles as $tabArticle) {
+ foreach ($tabArticle as $item) {
+ $this->articleGateway->addArticle($item);
+ }
+
}
- return $allArticles;
}
}
-$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);
+
+
+
diff --git a/fluxRSS/src/test/test.php b/fluxRSS/src/test/test.php
new file mode 100755
index 0000000..ff5c34a
--- /dev/null
+++ b/fluxRSS/src/test/test.php
@@ -0,0 +1,13 @@
+
{% for value in dVue.data %}
-
- {% for article in value %}
-
- {{article}}
-
- {% endfor %}
-
+
+ {% for article in value %}
+
+ {{article}}
+
+{% endfor %}
+
{% endfor %}
user
{% if not isAdmin %}
- Connect
+Connect
{% else %}
- Vue admin
+Vue admin
Déconnection
{% endif %}
diff --git a/fluxRSS/vendor/composer/autoload_psr4.php b/fluxRSS/vendor/composer/autoload_psr4.php
index 1002bc1..4501883 100755
--- a/fluxRSS/vendor/composer/autoload_psr4.php
+++ b/fluxRSS/vendor/composer/autoload_psr4.php
@@ -6,12 +6,13 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
- 'model\\' => array($baseDir . '/model'),
- 'metier\\' => array($baseDir . '/metier'),
- 'controleur\\' => array($baseDir . '/controleur'),
- 'config\\' => array($baseDir . '/config'),
+ 'src\\' => array($baseDir . '/src'),
+ 'model\\' => array($baseDir . '/src/model'),
+ 'metier\\' => array($baseDir . '/src/metier'),
+ 'controleur\\' => array($baseDir . '/src/controleur'),
+ 'config\\' => array($baseDir . '/src/config'),
'Twig\\' => array($vendorDir . '/twig/twig/src'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
- 'DAL\\' => array($baseDir . '/DAL'),
+ 'DAL\\' => array($baseDir . '/src/DAL'),
);
diff --git a/fluxRSS/vendor/composer/autoload_static.php b/fluxRSS/vendor/composer/autoload_static.php
index 868aa69..eb5e51a 100755
--- a/fluxRSS/vendor/composer/autoload_static.php
+++ b/fluxRSS/vendor/composer/autoload_static.php
@@ -12,6 +12,10 @@ class ComposerStaticInita6287a55fe354aae4af95d1e4395c915
);
public static $prefixLengthsPsr4 = array (
+ 's' =>
+ array (
+ 'src\\' => 4,
+ ),
'm' =>
array (
'model\\' => 6,
@@ -38,21 +42,25 @@ class ComposerStaticInita6287a55fe354aae4af95d1e4395c915
);
public static $prefixDirsPsr4 = array (
+ 'src\\' =>
+ array (
+ 0 => __DIR__ . '/../..' . '/src',
+ ),
'model\\' =>
array (
- 0 => __DIR__ . '/../..' . '/model',
+ 0 => __DIR__ . '/../..' . '/src/model',
),
'metier\\' =>
array (
- 0 => __DIR__ . '/../..' . '/metier',
+ 0 => __DIR__ . '/../..' . '/src/metier',
),
'controleur\\' =>
array (
- 0 => __DIR__ . '/../..' . '/controleur',
+ 0 => __DIR__ . '/../..' . '/src/controleur',
),
'config\\' =>
array (
- 0 => __DIR__ . '/../..' . '/config',
+ 0 => __DIR__ . '/../..' . '/src/config',
),
'Twig\\' =>
array (
@@ -68,7 +76,7 @@ class ComposerStaticInita6287a55fe354aae4af95d1e4395c915
),
'DAL\\' =>
array (
- 0 => __DIR__ . '/../..' . '/DAL',
+ 0 => __DIR__ . '/../..' . '/src/DAL',
),
);
diff --git a/fluxRSS/vendor/composer/installed.php b/fluxRSS/vendor/composer/installed.php
index 965d59a..26f8284 100755
--- a/fluxRSS/vendor/composer/installed.php
+++ b/fluxRSS/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '74b55bc18906a4639884ce8f33bd06d1657149b3',
+ 'reference' => 'c00c0a1c491c44a1666572f040f9b9df34933d25',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '74b55bc18906a4639884ce8f33bd06d1657149b3',
+ 'reference' => 'c00c0a1c491c44a1666572f040f9b9df34933d25',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),