1 |
cddd4e21
|
Filip Jani
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
namespace App\FrontModule\Components;
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
use App\Model\Repository\LineRepository;
|
8 |
|
|
use App\Model\Repository\LitReferenceRepository;
|
9 |
|
|
use App\Model\Repository\RevHistoryRepository;
|
10 |
|
|
use App\Model\Repository\TransliterationRepository;
|
11 |
|
|
use Nette\Application\UI\Control;
|
12 |
|
|
|
13 |
|
|
class TransliterationView extends Control
|
14 |
|
|
{
|
15 |
|
|
/**
|
16 |
|
|
* @var TransliterationRepository
|
17 |
|
|
*/
|
18 |
|
|
private $transliterationRepository;
|
19 |
|
|
/**
|
20 |
|
|
* @var LineRepository
|
21 |
|
|
*/
|
22 |
|
|
private $lineRepository;
|
23 |
|
|
/**
|
24 |
|
|
* @var LitReferenceRepository
|
25 |
|
|
*/
|
26 |
|
|
private $litReferenceRepository;
|
27 |
|
|
/**
|
28 |
|
|
* @var RevHistoryRepository
|
29 |
|
|
*/
|
30 |
|
|
private $revHistoryRepository;
|
31 |
|
|
|
32 |
|
|
public function __construct(TransliterationRepository $transliterationRepository,
|
33 |
|
|
LineRepository $lineRepository,
|
34 |
|
|
LitReferenceRepository $litReferenceRepository,
|
35 |
|
|
RevHistoryRepository $revHistoryRepository)
|
36 |
|
|
{
|
37 |
|
|
parent::__construct();
|
38 |
|
|
|
39 |
|
|
$this->transliterationRepository = $transliterationRepository;
|
40 |
|
|
$this->lineRepository = $lineRepository;
|
41 |
|
|
$this->litReferenceRepository = $litReferenceRepository;
|
42 |
|
|
$this->revHistoryRepository = $revHistoryRepository;
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
/**
|
46 |
|
|
* Vykreslení výsledků
|
47 |
|
|
*
|
48 |
|
|
* @param int $id : ID transliterace
|
49 |
|
|
* @param bool $showAll : zobrazení katalogu i transliterací
|
50 |
|
|
* @throws \Nette\Application\AbortException
|
51 |
|
|
*/
|
52 |
|
|
public function render(int $id, bool $showAll = TRUE)
|
53 |
|
|
{
|
54 |
|
|
$this->template->setFile(__DIR__ . '/TransliterationView.latte');
|
55 |
|
|
|
56 |
|
|
$transliteration = $this->transliterationRepository->getTransliterationDetail($id);
|
57 |
|
|
if (!$transliteration)
|
58 |
|
|
{
|
59 |
|
|
$this->presenter->flashMessage('Result was not found.');
|
60 |
|
|
$this->presenter->redirect($this->getPresenter()->getName());
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
// Zobrazujeme i data transliterace
|
64 |
|
|
if($showAll)
|
65 |
|
|
{
|
66 |
|
|
$lines = $this->lineRepository->getAllLinesForTransliteration($id);
|
67 |
|
|
$lineArray = [];
|
68 |
|
|
foreach ($lines as $line)
|
69 |
|
|
{
|
70 |
|
|
$lineArray[$line->object_type][$line->surface_type][] = array('transliteration' => $line->transliteration, 'line_number' => $line->line_number);
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
$this->template->lineArray = $lineArray;
|
74 |
|
|
$this->template->revisionHistory = $this->revHistoryRepository->findBy([RevHistoryRepository::COLUMN_TRANSLITERATION_ID => $id]);
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
$this->template->transliteration = $transliteration;
|
78 |
|
|
$this->template->litReferences = $this->litReferenceRepository->findBy([LitReferenceRepository::COLUMN_TRANSLITERATION_ID => $id]);
|
79 |
|
|
$this->template->showAll = $showAll;
|
80 |
|
|
|
81 |
|
|
$this->template->render();
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
interface ITransliterationViewFactory
|
86 |
|
|
{
|
87 |
|
|
/**
|
88 |
|
|
* @return TransliterationView
|
89 |
|
|
*/
|
90 |
|
|
public function create();
|
91 |
|
|
}
|