10 |
10 |
use App\Utils\Form;
|
11 |
11 |
use App\Utils\Paginator;
|
12 |
12 |
use Nette\Application\UI\Control;
|
13 |
|
use Tracy\Debugger;
|
14 |
13 |
|
15 |
14 |
class TransliterationSearchResultList extends Control
|
16 |
15 |
{
|
... | ... | |
20 |
19 |
/** @var TransliterationRepository */
|
21 |
20 |
private $transliterationRepository;
|
22 |
21 |
|
23 |
|
/** @var PaginatorControl */
|
|
22 |
/** @var Paginator */
|
24 |
23 |
private $paginator;
|
25 |
24 |
|
26 |
25 |
/**
|
... | ... | |
66 |
65 |
{
|
67 |
66 |
$this->template->setFile(__DIR__ . '/TransliterationSearchResultList.latte');
|
68 |
67 |
|
69 |
|
$this->resultRows = $this->transliterationRepository->transliterationsFulltextSearch($this->searchTerms, $this->paginator->getOffset(), $this->paginator->getPageSize());
|
|
68 |
$this->resultRows = $this->transliterationRepository->transliterationsFulltextSearch($this->searchTerms, $this->paginator->getOffset(), $this->paginator->getPageSize())->fetchAll();
|
70 |
69 |
$this->paginator->setPageCount($this->totalCount);
|
|
70 |
$this->highlight();
|
71 |
71 |
|
72 |
72 |
$this->template->resultRows = $this->resultRows;
|
73 |
73 |
$this->template->paginator = $this->paginator;
|
74 |
74 |
$this->template->render();
|
75 |
75 |
}
|
76 |
76 |
|
|
77 |
public function highlight()
|
|
78 |
{
|
|
79 |
foreach ($this->resultRows as $resultRow)
|
|
80 |
{
|
|
81 |
$resultRow->transliteration = str_replace("<", "<", $resultRow->transliteration);
|
|
82 |
$resultRow->transliteration = str_replace(">", ">", $resultRow->transliteration);
|
|
83 |
|
|
84 |
$resultRow->transliteration = preg_replace(
|
|
85 |
"/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word1']) . "/",
|
|
86 |
"<span class='found'>$0</span>",
|
|
87 |
$resultRow->transliteration);
|
|
88 |
|
|
89 |
//TODO: dořešit označování slov, když se zadají slova co se překrývají tak se tagy mezi sebou ruší,
|
|
90 |
// viz např. vyhledávání slov 'šu' a 'as'
|
|
91 |
|
|
92 |
// if($this->searchTerms['word2_condition'] === ESearchFormOperators::AND || $this->searchTerms['word2_condition'] === ESearchFormOperators::OR )
|
|
93 |
// {
|
|
94 |
// $resultRow->transliteration = preg_replace(
|
|
95 |
// "/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word2']) . "/",
|
|
96 |
// "<span class='found'>$0</span>",
|
|
97 |
// $resultRow->transliteration);
|
|
98 |
// }
|
|
99 |
//
|
|
100 |
// if($this->searchTerms['word3_condition'] === ESearchFormOperators::AND || $this->searchTerms['word3_condition'] === ESearchFormOperators::OR )
|
|
101 |
// {
|
|
102 |
// $resultRow->transliteration = preg_replace(
|
|
103 |
// "/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word3']) . "/",
|
|
104 |
// "<span class='found'>$0</span>",
|
|
105 |
// $resultRow->transliteration);
|
|
106 |
// }
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
77 |
110 |
public function handleChangePage($page, $limit)
|
78 |
111 |
{
|
79 |
112 |
$this->paginator = new Paginator($page, $limit);
|
Re #7328 označování hledaných slov ve výsledcích