Fix nette 3.0
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user