Revize 395eced7
Přidáno uživatelem Jan Šedivý před asi 6 roky(ů)
app/FrontModule/component/Transliteration/TransliterationSearchForm.php | ||
---|---|---|
6 | 6 |
use App\Model\TransliterationSearchModel; |
7 | 7 |
use Nette\Application\UI\Control; |
8 | 8 |
use Nette\Application\UI\Form; |
9 |
use Nette\Utils\ArrayHash; |
|
9 | 10 |
|
10 | 11 |
class TransliterationSearchForm extends Control |
11 | 12 |
{ |
... | ... | |
50 | 51 |
|
51 | 52 |
public function formSuccess(Form $form) |
52 | 53 |
{ |
54 |
/** @var ArrayHash $values */ |
|
53 | 55 |
$values = $form->getValues(); |
54 | 56 |
$this->transliterationSearchModel->setSearchTerms($values); |
55 | 57 |
$this->presenter->redirect('Transliteration:searchResult'); |
app/FrontModule/presenters/TransliterationPresenter.php | ||
---|---|---|
11 | 11 |
use App\Model\Repository\TransliterationRepository; |
12 | 12 |
use App\Model\TransliterationSearchModel; |
13 | 13 |
use Nette\Application\UI\Presenter; |
14 |
use Nette\SmartObject; |
|
15 |
use Tracy\Debugger; |
|
16 | 14 |
|
17 | 15 |
class TransliterationPresenter extends Presenter |
18 | 16 |
{ |
app/model/TransliterationSearchModel.php | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use Nette\Http\Session; |
7 | 7 |
use Nette\Http\SessionSection; |
8 |
use Nette\Utils\ArrayHash; |
|
8 | 9 |
|
9 | 10 |
class TransliterationSearchModel |
10 | 11 |
{ |
... | ... | |
28 | 29 |
return $this->section; |
29 | 30 |
} |
30 | 31 |
|
31 |
public function setSearchTerms($searchTerms) |
|
32 |
public function setSearchTerms(ArrayHash $searchTerms)
|
|
32 | 33 |
{ |
33 | 34 |
$this->section->searchTerms = $searchTerms; |
34 | 35 |
} |
35 | 36 |
|
37 |
/** |
|
38 |
* @return null|ArrayHash |
|
39 |
*/ |
|
36 | 40 |
public function getSearchTerms() |
37 | 41 |
{ |
38 | 42 |
return $this->section->searchTerms; |
app/model/repository/TransliterationRepository.php | ||
---|---|---|
3 | 3 |
namespace App\Model\Repository; |
4 | 4 |
|
5 | 5 |
use App\Enum\ELogicalConditions; |
6 |
use Tracy\Debugger;
|
|
6 |
use Nette\Utils\ArrayHash;
|
|
7 | 7 |
|
8 | 8 |
/** |
9 | 9 |
* Repository pro práci s tabulkou `transliteration` |
... | ... | |
31 | 31 |
|
32 | 32 |
/** |
33 | 33 |
* Vyhledává texty podle slov v řádcích textu |
34 |
* @param $queryParams array podmínky pro hledaný text
|
|
34 |
* @param ArrayHash $queryParams objekt s podmínkami pro hledaný text
|
|
35 | 35 |
* @return \Nette\Database\ResultSet |
36 | 36 |
*/ |
37 |
public function transliterationsFulltextSearch($queryParams) |
|
37 |
public function transliterationsFulltextSearch(ArrayHash $queryParams)
|
|
38 | 38 |
{ |
39 | 39 |
$where = ''; |
40 | 40 |
$whereArgs = []; |
... | ... | |
93 | 93 |
return $this->context->queryArgs($query, $whereArgs); |
94 | 94 |
} |
95 | 95 |
|
96 |
private function prepareSearchRegExp($word) |
|
96 |
/** |
|
97 |
* Vytváří regulární výraz z hledaného slova, escapuje regexp znaky |
|
98 |
* @param $word string hledané slovo |
|
99 |
* @return string Regexp |
|
100 |
*/ |
|
101 |
private function prepareSearchRegExp(string $word) |
|
97 | 102 |
{ |
98 | 103 |
$splitWord = preg_split('//u',$word, -1, PREG_SPLIT_NO_EMPTY); |
104 |
foreach ($splitWord as &$char) |
|
105 |
{ |
|
106 |
$char = preg_quote($char); |
|
107 |
} |
|
99 | 108 |
$regex = implode("[\[\]⌈⌉?!><\.₁₂₃₄₅₆₇₈₉₀\-\s]*?", $splitWord); |
100 | 109 |
return $regex; |
101 | 110 |
} |
102 | 111 |
|
103 |
public function getTransliterationDetail($id) |
|
112 |
/** |
|
113 |
* @param int $id id transliterace |
|
114 |
* @return bool|\Nette\Database\IRow|\Nette\Database\Row |
|
115 |
*/ |
|
116 |
public function getTransliterationDetail(int $id) |
|
104 | 117 |
{ |
105 | 118 |
return $this->context->query( |
106 | 119 |
"SELECT |
Také k dispozici: Unified diff
Re #7327 regexp quote, datové typy u parametrů