mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-02-11 14:28:40 +00:00
fix archive and layout
This commit is contained in:
parent
ff948c28d7
commit
324ccd739e
|
|
@ -150,8 +150,17 @@ final class BackendController extends Controller implements DashboardElementInte
|
|||
$view->setTemplate('/Modules/News/Theme/Backend/news-archive');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000701001, $request, $response));
|
||||
|
||||
$articles = NewsArticleMapper::getNewest(50);
|
||||
$view->addData('articles', $articles);
|
||||
if ($request->getData('ptype') === '-') {
|
||||
$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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,50 +12,52 @@
|
|||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
$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(); ?>
|
||||
|
||||
<div class="row">
|
||||
<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">
|
||||
<caption><?= $this->getHtml('Archive'); ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<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><?= $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>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($articles as $key => $news) : ++$count; $url = \phpOMS\Uri\UriFactory::build('{/prefix}news/article?{?}&id=' . $news->getId());
|
||||
$color = 'darkred';
|
||||
if ($news->getType() === \Modules\News\Models\NewsType::ARTICLE) { $color = 'green'; }
|
||||
elseif ($news->getType() === \Modules\News\Models\NewsType::HEADLINE) { $color = 'purple'; }
|
||||
elseif ($news->getType() === \Modules\News\Models\NewsType::LINK) { $color = 'yellow'; }
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('TYPE' . $news->getType()) ?></span></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getTitle()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getCreatedBy()->getName1()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getPublish()->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($articles as $key => $news) : ++$count; $url = UriFactory::build('{/prefix}news/article?{?}&id=' . $news->getId());
|
||||
$color = 'darkred';
|
||||
if ($news->getType() === NewsType::ARTICLE) { $color = 'green'; }
|
||||
elseif ($news->getType() === NewsType::HEADLINE) { $color = 'purple'; }
|
||||
elseif ($news->getType() === NewsType::LINK) { $color = 'yellow'; }
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('TYPE' . $news->getType()) ?></span></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getTitle()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getCreatedBy()->getName1()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($news->getPublish()->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ echo $this->getData('nav')->render(); ?>
|
|||
<h1><?= $this->printHtml($news->getTitle()); ?></h1>
|
||||
<?= $news->getContent(); ?>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user