Projekt

Obecné

Profil

Stáhnout (3.6 KB) Statistiky
| Větev: | Tag: | Revize:
1 3416b114 Jan Šedivý
<?php
2
3
namespace App\FrontModule\Presenters;
4
5
6
7 f193cf94 Petr Lukašík
use App\FrontModule\Components\IKeyboard;
8 3416b114 Jan Šedivý
use App\FrontModule\Components\ITransliterationSearchFormFactory;
9 5dea830a Jan Šedivý
use App\FrontModule\Components\ITransliterationSearchResultListFactory;
10 8ef808c0 Jan Šedivý
use App\Model\Repository\LineRepository;
11
use App\Model\Repository\LitReferenceRepository;
12
use App\Model\Repository\RevHistoryRepository;
13 3416b114 Jan Šedivý
use App\Model\Repository\TransliterationRepository;
14
use App\Model\TransliterationSearchModel;
15
use Nette\Application\UI\Presenter;
16
17
class TransliterationPresenter extends Presenter
18
{
19
    /** @var ITransliterationSearchFormFactory */
20
    private $transliterationSearchFormFactory;
21
22
    /** @var TransliterationRepository */
23
    private $transliterationRepository;
24
25
    /** @var TransliterationSearchModel */
26
    private $transliterationSearchModel;
27
28 8ef808c0 Jan Šedivý
    /** @var LitReferenceRepository */
29
    private $litReferenceRepository;
30
31
    /** @var RevHistoryRepository */
32
    private $revHistoryRepository;
33
34
    /** @var LineRepository */
35
    private $lineRepository;
36
37 5dea830a Jan Šedivý
    /** @var ITransliterationSearchResultListFactory */
38
    private $transliterationSearchResultListFactory;
39
40 f193cf94 Petr Lukašík
    /** @var IKeyboard */
41
    private $keyboard;
42
43 3416b114 Jan Šedivý
    public function __construct(
44
        ITransliterationSearchFormFactory $transliterationSearchFormFactory,
45
        TransliterationRepository $transliterationRepository,
46 8ef808c0 Jan Šedivý
        TransliterationSearchModel $transliterationSearchModel,
47
        LitReferenceRepository $litReferenceRepository,
48
        RevHistoryRepository $revHistoryRepository,
49 5dea830a Jan Šedivý
        LineRepository $lineRepository,
50 f193cf94 Petr Lukašík
        ITransliterationSearchResultListFactory $transliterationSearchResultListFactory,
51
        IKeyboard $keyboard
52 3416b114 Jan Šedivý
    )
53
    {
54
        parent::__construct();
55
56
        $this->transliterationSearchFormFactory = $transliterationSearchFormFactory;
57
        $this->transliterationRepository = $transliterationRepository;
58
        $this->transliterationSearchModel = $transliterationSearchModel;
59 8ef808c0 Jan Šedivý
        $this->litReferenceRepository = $litReferenceRepository;
60
        $this->revHistoryRepository = $revHistoryRepository;
61
        $this->lineRepository = $lineRepository;
62 5dea830a Jan Šedivý
        $this->transliterationSearchResultListFactory = $transliterationSearchResultListFactory;
63 f193cf94 Petr Lukašík
        $this->keyboard = $keyboard;
64 3416b114 Jan Šedivý
    }
65
66 8ef808c0 Jan Šedivý
    public function actionView($id)
67
    {
68
        $transliteration = $this->transliterationRepository->getTransliterationDetail($id);
69
        if(!$transliteration)
70
        {
71
            $this->presenter->flashMessage('Transliteration not found');
72
            $this->redirect('Transliteration:search');
73
        }
74
        $lines = $this->lineRepository->getAllLinesForTransliteration($id);
75
        $lineArray = [];
76
        foreach ($lines as $line)
77
        {
78
            $lineArray[$line->object_type][$line->surface_type][] = array('transliteration' => $line->transliteration, 'line_number' => $line->line_number);
79
        }
80
81
        $this->template->transliteration = $transliteration;
82
        $this->template->litReferences = $this->litReferenceRepository->findBy([LitReferenceRepository::COLUMN_TRANSLITERATION_ID => $id]);
83
        $this->template->revisionHistory = $this->revHistoryRepository->findBy([RevHistoryRepository::COLUMN_TRANSLITERATION_ID => $id]);
84
        $this->template->lineArray = $lineArray;
85
    }
86
87 3416b114 Jan Šedivý
    public function createComponentTransliterationSearchForm()
88
    {
89
        return $this->transliterationSearchFormFactory->create();
90
    }
91 5dea830a Jan Šedivý
92
    public function createComponentTransliterationSearchResultList()
93
    {
94
        return $this->transliterationSearchResultListFactory->create();
95
    }
96 f193cf94 Petr Lukašík
97
    public function createComponentKeyboard()
98
    {
99
        return $this->keyboard->create();
100
    }
101 3416b114 Jan Šedivý
}