<?php
namespace App\Controller\ING;
use App\Controller\BaseController;
use Empire\Core\News;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class NewsController
* @package App\Controller\ING
* @Route("/iis")
*/
class NewsController extends BaseController
{
/**
* @param Request $request
* @param $page
* @param $type
* @return Response
* @Route("/{page}/{type}", requirements={"page"="\d+", "type"="\d+"}, defaults={"page"=1, "type"=News::NEWS_TYPE_INS}, name="ins.archive")
*/
public function archive(Request $request, $page, $type) {
$term = $request->get('s', '');
return $this->render('ins/archive.twig', [
'title' => $type == 1 ? 'IIS Archive' : 'IHS Archive',
'gejs' => ['ajax'],
'news' => News::getArchiveNews($page, $type, $term),
'pages' => max(ceil(News::getNewsCount($type, $term) / 10), 1),
'page' => $page,
'type' => $type,
'term' => $term,
]);
}
/**
* @param $article
* @return mixed
* @Route("/arcticle/{article}", name="ins.article", requirements={"article"="\d+"})
*/
public function article($article) {
$news = News::load([$article]);
if(null === $news) {
return $this->createNotFoundException('Article does not exist.');
}
return $this->render('/ins/main.twig', [
'title' => $news->title,
'gejs' => ['ajax'],
'news' => [$news],
'recent' => $recent = News::getLatestNews($news->newsType, 3),
]);
}
}