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),
':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),
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 71%
rename from fluxRSS/DAL/FluxGateway.php
rename to fluxRSS/src/DAL/FluxGateway.php
index d9cb316..e4e628a 100755
--- a/fluxRSS/DAL/FluxGateway.php
+++ b/fluxRSS/src/DAL/FluxGateway.php
@@ -13,11 +13,26 @@ class FluxGateway
$this->con = $con;
}
- public function addFlux(Flux $flux){
+ 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 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 $flux){
$query = 'DELETE FROM Flux WHERE flux = :flux;';
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
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 100%
rename from fluxRSS/config/config.php
rename to fluxRSS/src/config/config.php
diff --git a/fluxRSS/src/controleur/Controleur.php b/fluxRSS/src/controleur/Controleur.php
new file mode 100755
index 0000000..7a488fe
--- /dev/null
+++ b/fluxRSS/src/controleur/Controleur.php
@@ -0,0 +1,86 @@
+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 91%
rename from fluxRSS/metier/Article.php
rename to fluxRSS/src/metier/Article.php
index ef25c27..6a2c8b2 100755
--- a/fluxRSS/metier/Article.php
+++ b/fluxRSS/src/metier/Article.php
@@ -23,7 +23,15 @@ class Article
* @param string $mediaContent
* @param int $provenance
*/
- public function __construct(int $id, string $title, string $date, string $description, string $guid, string $link, string $mediaContent, int $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 100%
rename from fluxRSS/metier/Flux.php
rename to fluxRSS/src/metier/Flux.php
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 98%
rename from fluxRSS/model/FluxModel.php
rename to fluxRSS/src/model/FluxModel.php
index bfe5a2a..fb7461b 100755
--- a/fluxRSS/model/FluxModel.php
+++ b/fluxRSS/src/model/FluxModel.php
@@ -57,6 +57,7 @@ class FluxModel
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){
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 13ad02f..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($base, $login, $mdpBd));
-$gwFl = new FluxGateway(new Connection($base, $login, $mdpBd));
-$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 @@
+
{% endfor %}
{% if not isAdmin %}
- Connect
+Connect
{% else %}
- Vue admin
+Vue admin
Déconnection
{% endif %}