ajout des fonctions perdus

feature/gestionFlux
maxime.point2 1 year ago
parent 508ac40bc3
commit 64312ad5a6

@ -56,6 +56,10 @@ class AdminControleur
$this->ajoutFlux();
break;
case 'changeNbArticle':
$this->changeNbArticle();
break;
//mauvaise action
default:
$dVueEreur[] = "Erreur d'appel php";
@ -79,9 +83,12 @@ class AdminControleur
{
global $twig;
$articleModel = new ArticleModel();
$nbArticle = isset($_SESSION['nbArticle']) ? intval($_SESSION['nbArticle']) : 5;
$allArticles = $articleModel->getArticles();
$articles = array_slice($allArticles, 0, $nbArticle);
if (AdminModel::isAdmin()) {
$dVue = [
'data' => $articleModel->findAllArticleByAllFlux()
'data' => $articles
];
echo $twig->render('listArticleAdmin.html', [
'dVue' => $dVue,
@ -173,4 +180,13 @@ class AdminControleur
$this->connection();
}
}
public function changeNbArticle()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['nbArticle'])) {
$_SESSION['nbArticle'] = $_POST['nbArticle'];
unset($_POST['action']);
}
$this->init();
}
}

@ -3,7 +3,6 @@ namespace controleur;
use model\AdminModel;
use model\ArticleModel;
use model\Parser;
class UserControleur
{
@ -59,8 +58,11 @@ class UserControleur
{
global $twig;
$articleModel = new ArticleModel();
$nbArticle = isset($_SESSION['nbArticle']) ? intval($_SESSION['nbArticle']) : 5;
$allArticles = $articleModel->getArticles();
$articles = array_slice($allArticles, 0, $nbArticle);
$dVue = [
'data' => $articleModel->findAllArticleByAllFlux()
'data' => $articles
];
echo $twig->render('listArticle.html', [
'dVue' => $dVue,

@ -2,6 +2,8 @@
namespace metier;
use DateTime;
class Article
{
private int $id;
@ -128,4 +130,8 @@ class Article
return $this->title . $this->date . $this->description;
}
public function dateStr(): string{
$dateTime = new DateTime($this->date);
return $dateTime->format('d/m/y à H:i') . '';
}
}

@ -5,22 +5,16 @@
<title>All Articles</title>
</head>
<body>
{% for value in dVue.data %}
<p>
{{ value.0.getFlux() }}
{% for article in value.1 %}
<p>
{{article}}
</p>
{% endfor %}
</br>
</br>
</p>
{% for article in dVue.data %}
<p>
{{article.dateStr()}}
<a href="{{ article.getLink() }}" target="_blank">{{ article.getTitle() }}</a>
{{ article.getDescription() }}
</p>
{% endfor %}
{% if not isAdmin %}
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/connection">Connect</a>
{% else %}
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/">Vue admin</a>
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/user/deconnection">Déconnection</a>
{% endif %}
</body>

@ -5,22 +5,17 @@
<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>
<form method="POST" action="changeNbArticle">
<input name="nbArticle" type="number" min="0">
<button type="submit">Change number of articles</button>
</form>
{% for article in dVue.data %}
<p>
{{article.dateStr()}}
<a href="{{ article.getLink() }}" target="_blank">{{ article.getTitle() }}</a>
{{ article.getDescription() }}
</p>
{% endfor %}
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/">Vue user</a>
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/listFlux">Vue flux</a>
<a href="/~mapoint2/SAE/Php_RSS/fluxRSS/admin/deconnection">Déconnection</a>
</body>

Loading…
Cancel
Save