From a4b67569a4709663557d1f62d949355e795fea43 Mon Sep 17 00:00:00 2001 From: Jaroslav Drzik Date: Sun, 30 Jan 2022 22:35:13 +0100 Subject: [PATCH] Fix nette 3.0 --- app/modules/Front/BaseFrontPresenter.php | 9 ++-- app/modules/Front/Home/HomePresenter.php | 31 +---------- app/modules/Front/Search/SearchPresenter.php | 51 ++++++++++++------ .../Front/Search/templates/bootstrap4.latte | 39 ++++++++++++++ .../Front/Search/templates/default.latte | 2 +- .../{Home => Search}/templates/ipa.latte | 3 +- www/assets/images/images/sound.png | Bin 0 -> 1269 bytes www/assets/images/images/spinner.gif | Bin 0 -> 737 bytes www/assets/images/images/sprites.png | Bin 0 -> 1774 bytes 9 files changed, 82 insertions(+), 53 deletions(-) create mode 100644 app/modules/Front/Search/templates/bootstrap4.latte rename app/modules/Front/{Home => Search}/templates/ipa.latte (87%) create mode 100644 www/assets/images/images/sound.png create mode 100644 www/assets/images/images/spinner.gif create mode 100644 www/assets/images/images/sprites.png diff --git a/app/modules/Front/BaseFrontPresenter.php b/app/modules/Front/BaseFrontPresenter.php index ae60553..9f477cf 100644 --- a/app/modules/Front/BaseFrontPresenter.php +++ b/app/modules/Front/BaseFrontPresenter.php @@ -41,6 +41,7 @@ abstract class BaseFrontPresenter extends UnsecuredPresenter protected function startup() { + $trs = $this->em->getRepository(Translation::class)->findBy([], ['id' => 'ASC', 'direction' => 'ASC']); $drs = $this->em->getRepository(Dictionary::class)->findPairs('id', 'name'); $select = []; @@ -52,10 +53,10 @@ abstract class BaseFrontPresenter extends UnsecuredPresenter $lang = mb_substr($lang1, 0, -1); $lang .= "o-" . $lang2; $slug = Strings::webalize($lang); - $select[$drs[$t->getDictionary()->getId()]][$t->getId()] = $lang; - $translations[$t->getId()]["slug"] = $slug; - $translations[$t->getId()]["lang"] = $lang; - $translations[$t->getId()]["t"] = $t; + $select[$drs[$t->getDictionary()->id]][$t->id] = $lang; + $translations[$t->id]["slug"] = $slug; + $translations[$t->id]["lang"] = $lang; + $translations[$t->id]["t"] = $t; $slugs[$slug] = $t; } $this->translations = $translations; diff --git a/app/modules/Front/Home/HomePresenter.php b/app/modules/Front/Home/HomePresenter.php index 0fa2216..c871921 100644 --- a/app/modules/Front/Home/HomePresenter.php +++ b/app/modules/Front/Home/HomePresenter.php @@ -21,26 +21,6 @@ use App\Model\Database\Facade\TermFacade; final class HomePresenter extends BaseFrontPresenter { - - - /** - * @return AlesWita\Components\VisualPaginator - */ - protected function createComponentPaginator(): VisualPaginator - { - $paginator = $this->visualPaginatorFactory->create(); - - $paginator->ajax = false; - $paginator->canSetItemsPerPage = true; - $paginator->setItemsPerPage(100); - - //$paginator->templateFile = __DIR__ . '/my_awesome_template.latte'; - - return $paginator; - } - - - public function searchFormSucceededIpa(UI\Form $form, $values) { $translation = $values->translation; @@ -96,7 +76,6 @@ final class HomePresenter extends BaseFrontPresenter } else { $id = $this['searchForm']['translation']->value; - dump($id); if (isset($this->translations[$id])) { $t = $this->translations[$id]; $this->redirect('Front:Home:select', $t["slug"], $this['searchForm']['string']->value); @@ -120,15 +99,7 @@ final class HomePresenter extends BaseFrontPresenter public function actionIpa() { - if ($this->getRequest()->isMethod('GET')) { - if ($this->term) { - $this['searchForm']['string']->setValue($this->term); - $result = $this->doSearch('TermsFullQuery', $this->slugs[$this->slug]->id, $this->term); - if ($result) $this->template->result = $result; - } - } - - $this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededIpa'); + $this->redirect('Search:ipa',$this->translation,$this->term); } public function actionInteractive() diff --git a/app/modules/Front/Search/SearchPresenter.php b/app/modules/Front/Search/SearchPresenter.php index 3a38a06..c352875 100644 --- a/app/modules/Front/Search/SearchPresenter.php +++ b/app/modules/Front/Search/SearchPresenter.php @@ -20,15 +20,7 @@ use App\Model\Database\Facade\TermFacade; class SearchPresenter extends BaseFrontPresenter { - /** @inject @var EntityManager */ - public EntityManager $em; - /** @inject */ - public TermFacade $termFacade; - - - /** @persistent */ - public $term; protected function doSearch($query, $translation, $term, $clen = null, $paginate = true) { @@ -36,30 +28,57 @@ class SearchPresenter extends BaseFrontPresenter if ($term) $this->term = $term; if ($translation) $this->translation = $translation; - // $this->slug = $this->translations[$translation]["slug"]; + $this->slug = $this->translations[$translation]["slug"]; $this->termFacade->setDirection(1); - -/* if ($paginate) { - $this["paginator"]->setItemCount(500); + $q = $this->termFacade->findByString($term, $t->dictionary, $clen); + + if ($paginate) { + $paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($q); + $count = count($paginator); + $this["paginator"]->setItemCount($count); $offset = $this["paginator"]->getOffset(); $itemsPerPage = $this['paginator']->getItemsPerPage(); + $q->setFirstResult($offset)->setMaxResults($itemsPerPage); } -*/ - $q = $this->termFacade->findByString($term, $t->dictionary, $clen); - //$q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage); + $this->template->translation = $t; return $q->getResult(); } - public function renderDefault($translation,$term,$clen,$paginate = false) + public function renderDefault($translation,$term,$clen = '',$paginate = true) { $this['searchForm']['string']->setValue($this->term); $this->template->result = $this->doSearch('TermQuery',$translation,$term,$clen,$paginate); } + public function renderIpa($translation,$term,$clen='',$paginate=true) + { + $this['searchForm']['string']->setValue($this->term); + $result = $this->doSearch('TermsFullQuery', $this->slugs[$this->slug]->id, $this->term); + if ($result) $this->template->result = $result; + + $this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededIpa'); + } + + + /** + * @return AlesWita\Components\VisualPaginator + */ + protected function createComponentPaginator(): VisualPaginator + { + $paginator = $this->visualPaginatorFactory->create(); + + $paginator->ajax = false; + $paginator->canSetItemsPerPage = true; + $paginator->setItemsPerPage(20); + + $paginator->templateFile = __DIR__.'/templates/bootstrap4.latte'; + + return $paginator; + } } diff --git a/app/modules/Front/Search/templates/bootstrap4.latte b/app/modules/Front/Search/templates/bootstrap4.latte new file mode 100644 index 0000000..bce43c0 --- /dev/null +++ b/app/modules/Front/Search/templates/bootstrap4.latte @@ -0,0 +1,39 @@ +{templateType AlesWita\VisualPaginator\Template} + +{php $linkClass = $ajax ? 'page-link ajax' : 'page-link'} + + + +{if $itemsPerPage} + {form itemsPerPage, class => $ajax ? 'form-inline ajax' : 'form-inline'} +
+
+ {label itemsPerPage /} +
+ + {input itemsPerPage, class => "form-control"} +
+ {input send, class => "btn btn-outline-secondary"} +
+
+ {/form} +{/if} diff --git a/app/modules/Front/Search/templates/default.latte b/app/modules/Front/Search/templates/default.latte index ecfb2b3..49d193f 100644 --- a/app/modules/Front/Search/templates/default.latte +++ b/app/modules/Front/Search/templates/default.latte @@ -56,7 +56,7 @@ $( document ).ready(function() { {/foreach} - + {control paginator} {/ifset} {/block} diff --git a/app/modules/Front/Home/templates/ipa.latte b/app/modules/Front/Search/templates/ipa.latte similarity index 87% rename from app/modules/Front/Home/templates/ipa.latte rename to app/modules/Front/Search/templates/ipa.latte index f943ac4..a49bff0 100644 --- a/app/modules/Front/Home/templates/ipa.latte +++ b/app/modules/Front/Search/templates/ipa.latte @@ -38,7 +38,7 @@ $( document ).ready(function() { {$term->string1}  {foreach $term->pronunciations as $pron} [{$pron->ipa}] - Prehraj + Prehraj {/foreach}
@@ -51,7 +51,6 @@ $( document ).ready(function() { {/foreach} {/ifset} - {/form} {control paginator}
{/block} diff --git a/www/assets/images/images/sound.png b/www/assets/images/images/sound.png new file mode 100644 index 0000000000000000000000000000000000000000..d3c1095a7e1ec74cf07b4f02a8afc7a9facd51c1 GIT binary patch literal 1269 zcmV3B&=C6vf6 z4~AU?p&LS2kPo6zFGZPQ6m%t`)E+bv>Lr4xh%%;-lIG$CXEY*jj7MiiJ)W64=R4oG zFFkytrcShAy=+*&y*BIrUt92>;dL0&0?b}`C(|cQW~u<&dxpQ;+c~Zj-EqvHAlzux zVicg%n&l5Y!sAb`XUVKqCWq@8o0eoWiGpV*ruqT_$Se(cPdJooNL zJTbME3B5xUN->EA=NukD2!s@fnvk%$hH;&3^lsY7uJd_zgQ$!G_POONcxlHT)?I+o zr3&TPVvWTaaP}G)C6HPoLy2straD_BcycYfj&<|S75E6)s~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