affichage des articles

pull/16/head
maxime.point2 1 year ago
parent 1b3255f47f
commit cf797b360d

@ -51,7 +51,6 @@ class ArticleGateway
public function findArticleByFlux(int $flux){
$query = 'SELECT * FROM Article WHERE provenance = :flux;';
$this->con->executeQuery($query, array(':flux' => array($flux, PDO::PARAM_INT)));
$this->con->executeQuery($query);
return $this->con->getResults();
}
}

@ -13,12 +13,12 @@ class FluxGateway
$this->con = $con;
}
public function addFlux($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 removeFlux($flux){
public function removeFlux(Flux $flux){
$query = 'DELETE FROM Flux WHERE flux = :flux;';
$this->con->executeQuery($query, array(':flux' => array($flux->getFlux(), PDO::PARAM_STR)));
}

@ -4,26 +4,26 @@ 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;

@ -4,10 +4,10 @@ namespace metier;
class Flux
{
private string $id;
private int $id;
private string $flux;
public function __construct(string $id, string $flux){
public function __construct(string $flux, int $id=null){
$this->id =$id;
$this->flux = $flux;
}
@ -28,9 +28,14 @@ class Flux
}
/**
* @return string
* @return int
*/
public function getId(): string
public function getId(): int
{
return $this->id;
}
public function __toString(): string
{
return $this->id;
}

@ -47,9 +47,23 @@ class ArticleModel
$res = $gwFlux->findAllFlux();
foreach ($res as $row) {
$flux = new Flux(($row['id']), ($row['flux']));
$tabFluxArticle[] = $this->findArticleByFlux($flux);
$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;
}
}

@ -14,7 +14,7 @@ class FluxModel
$result = $gateway->findAllFlux();
foreach ($result as $row){
$data[] = new Flux($row['$flux']);
$data[] = new Flux((int)$row['id'],$row['$flux']);
}
return $data;
}
@ -39,11 +39,9 @@ class FluxModel
$gateway->removeFlux($flux);
}
public function removeFluxBySrc(string $flux): Flux {
public function removeFluxBySrc(string $flux) {
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
$newFlux = new Flux($flux);
$gateway->removeFlux($newFlux);
return $newFlux;
$gateway->removeFlux($flux);
}
public function findFlux(Flux $flux){
@ -52,7 +50,7 @@ class FluxModel
$result = $gateway->findFlux($flux);
foreach ($result as $row){
$data[] = new Flux($row['$flux']);
$data[] = new Flux($row['$flux'],(int)$row['id']);
}
return $data;
}
@ -62,7 +60,7 @@ class FluxModel
$result = $gateway->findFluxBySrc($flux);
foreach ($result as $row){
$data[] = new Flux($row['$flux']);
$data[] = new Flux($row['$flux'],(int)$row['id']);
}
return $data;
}

@ -7,15 +7,16 @@
<body>
{% for value in dVue.data %}
<p>
{{ value[0] }}
{% for article in value[1] %}
{{ value.0.getFlux() }}
{% for article in value.1 %}
<p>
{{article}}
</p>
{% endfor %}
</br>
</br>
</p>
{% endfor %}
user
{% if not isAdmin %}
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/connection">Connect</a>
{% else %}

@ -8,19 +8,18 @@
admin
{% for value in dVue.data %}
<div>
{{ value[0] }}
{{ value.0.getFlux() }}
<form method="post" action="deleteFlux">
<input type="hidden" name="flux" value="{{ value[0] }}">
<button type="submit">Delete Article</button>
<input type="hidden" name="flux" value="{{ value.0 }}">
<button type="submit">Delete Flux</button>
</form>
{% for article in value[1] %}
{% for article in value.1 %}
<p>
{{article}}
</p>
{% endfor %}
</div>
{% endfor %}
{% endfor %}
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/">Vue user</a>
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/deconnection">Déconnection</a>
</body>

Loading…
Cancel
Save