fix archive and layout

This commit is contained in:
Dennis Eichhorn 2020-06-07 22:24:01 +02:00
parent ff948c28d7
commit 324ccd739e
3 changed files with 50 additions and 32 deletions

View File

@ -150,8 +150,17 @@ final class BackendController extends Controller implements DashboardElementInte
$view->setTemplate('/Modules/News/Theme/Backend/news-archive'); $view->setTemplate('/Modules/News/Theme/Backend/news-archive');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000701001, $request, $response)); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000701001, $request, $response));
$articles = NewsArticleMapper::getNewest(50); if ($request->getData('ptype') === '-') {
$view->addData('articles', $articles); $view->setData('news',
NewsArticleMapper::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25)
);
} elseif ($request->getData('ptype') === '+') {
$view->setData('news',
NewsArticleMapper::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25)
);
} else {
$view->setData('news', NewsArticleMapper::getAfterPivot(0, null, 25));
}
return $view; return $view;
} }

View File

@ -12,50 +12,52 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use phpOMS\Uri\UriFactory;
use Modules\News\Models\NewsType;
/** @var \Modules\News\Models\NewsArticle[] $newsList */
$articles = $this->getData('news') ?? [];
$previous = empty($newsList) ? '{/prefix}news/archive' : '{/prefix}news/archive?{?}&id=' . \reset($newsList)->getId() . '&ptype=-';
$next = empty($newsList) ? '{/prefix}news/archive' : '{/prefix}news/archive?{?}&id=' . \end($newsList)->getId() . '&ptype=+';
/** /**
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
*/ */
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
$articles = $this->getData('articles');
echo $this->getData('nav')->render(); ?> echo $this->getData('nav')->render(); ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<div class="box wf-100"> <section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Archive') ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="newsArchiveList" class="default"> <table id="newsArchiveList" class="default">
<caption><?= $this->getHtml('Archive'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead> <thead>
<tr> <tr>
<td><?= $this->getHtml('Type') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Type') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td class="wf-100"><?= $this->getHtml('Title') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td class="wf-100"><?= $this->getHtml('Title') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Author') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Author') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Date') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Date') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tfoot> <tbody>
<tr> <?php $count = 0; foreach ($articles as $key => $news) : ++$count; $url = UriFactory::build('{/prefix}news/article?{?}&id=' . $news->getId());
<td colspan="4"> $color = 'darkred';
<tbody> if ($news->getType() === NewsType::ARTICLE) { $color = 'green'; }
<?php $count = 0; foreach ($articles as $key => $news) : ++$count; $url = \phpOMS\Uri\UriFactory::build('{/prefix}news/article?{?}&id=' . $news->getId()); elseif ($news->getType() === NewsType::HEADLINE) { $color = 'purple'; }
$color = 'darkred'; elseif ($news->getType() === NewsType::LINK) { $color = 'yellow'; }
if ($news->getType() === \Modules\News\Models\NewsType::ARTICLE) { $color = 'green'; } ?>
elseif ($news->getType() === \Modules\News\Models\NewsType::HEADLINE) { $color = 'purple'; } <tr data-href="<?= $url; ?>">
elseif ($news->getType() === \Modules\News\Models\NewsType::LINK) { $color = 'yellow'; } <td><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('TYPE' . $news->getType()) ?></span></a>
?> <td><a href="<?= $url; ?>"><?= $this->printHtml($news->getTitle()); ?></a>
<tr data-href="<?= $url; ?>"> <td><a href="<?= $url; ?>"><?= $this->printHtml($news->getCreatedBy()->getName1()); ?></a>
<td><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('TYPE' . $news->getType()) ?></span></a> <td><a href="<?= $url; ?>"><?= $this->printHtml($news->getPublish()->format('Y-m-d')); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getTitle()); ?></a> <?php endforeach; ?>
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getCreatedBy()->getName1()); ?></a> <?php if ($count === 0) : ?>
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getPublish()->format('Y-m-d')); ?></a> <tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endforeach; ?> <?php endif; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table> </table>
</div> <div class="portlet-foot">
<a class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
<a class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
</div>
</section>
</div> </div>
</div> </div>

View File

@ -34,6 +34,13 @@ echo $this->getData('nav')->render(); ?>
<h1><?= $this->printHtml($news->getTitle()); ?></h1> <h1><?= $this->printHtml($news->getTitle()); ?></h1>
<?= $news->getContent(); ?> <?= $news->getContent(); ?>
</article> </article>
<div class="portlet-foot">
<div class="overflowfix">
<?php $tags = $news->getTags(); foreach ($tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->getColor()); ?>"><?= $this->printHtml($tag->getTitle()); ?></span>
<?php endforeach; ?>
</div>
</div>
</section> </section>
</div> </div>
</div> </div>