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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
39
app/modules/Front/Search/templates/bootstrap4.latte
Normal file
39
app/modules/Front/Search/templates/bootstrap4.latte
Normal file
@@ -0,0 +1,39 @@
|
||||
{templateType AlesWita\VisualPaginator\Template}
|
||||
|
||||
{php $linkClass = $ajax ? 'page-link ajax' : 'page-link'}
|
||||
|
||||
<ul class="pagination">
|
||||
<li n:class="$paginator->isFirst() ? 'page-item disabled' : 'page-item'">
|
||||
<a n:href="paginate!, page => $paginator->page - 1" class="{$linkClass}">«</a>
|
||||
</li>
|
||||
|
||||
{foreach $steps as $step}
|
||||
<li n:class="$step === $paginator->page ? 'page-item active' : 'page-item'">
|
||||
<a n:href="paginate!, page => $step" class="{$linkClass}">{$step}</a>
|
||||
</li>
|
||||
{if $iterator->nextValue > $step + 1}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">…</span>
|
||||
</li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<li n:class="$paginator->isLast() ? 'page-item disabled' : 'page-item'">
|
||||
<a n:href="paginate!, page => $paginator->page + 1" class="{$linkClass}">»</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{if $itemsPerPage}
|
||||
{form itemsPerPage, class => $ajax ? 'form-inline ajax' : 'form-inline'}
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="basic-addon1">{label itemsPerPage /}</span>
|
||||
</div>
|
||||
|
||||
{input itemsPerPage, class => "form-control"}
|
||||
<div class="input-group-append">
|
||||
{input send, class => "btn btn-outline-secondary"}
|
||||
</div>
|
||||
</div>
|
||||
{/form}
|
||||
{/if}
|
||||
@@ -56,7 +56,7 @@ $( document ).ready(function() {
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
{control paginator}
|
||||
{/ifset}
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
57
app/modules/Front/Search/templates/ipa.latte
Normal file
57
app/modules/Front/Search/templates/ipa.latte
Normal file
@@ -0,0 +1,57 @@
|
||||
{block title}Slovnik{/block}
|
||||
{block head}
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$("img.ajax").on("click", function (event) {
|
||||
event.preventDefault();
|
||||
id = $(this).attr("data-sound-id");
|
||||
var audioElement = document.createElement('audio');
|
||||
var link = {link Home:play 123456 };
|
||||
audioElement.setAttribute('src', link.replace('123456',id));
|
||||
console.log("Play sound:" + id);
|
||||
audioElement.play();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
|
||||
{block content}
|
||||
{block form}
|
||||
|
||||
{/block}
|
||||
{ifset $result}
|
||||
<table class="trans">
|
||||
<tr>
|
||||
<th>Preklad</th>
|
||||
</tr>
|
||||
{var $last = ''}
|
||||
{foreach $result as $term}
|
||||
{if ($last != $term->string1 && $last != '') }
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{if $last != $term->string1}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="term">{$term->string1}</span>
|
||||
{foreach $term->pronunciations as $pron}
|
||||
<span class="ipa-{$pron->type->id}">[{$pron->ipa}]</span>
|
||||
<img n:if="$pron->filename" class="sound-ipa ajax" src="/assets/images/sound.png" alt="Prehraj" style="vertical-align: middle;" data-sound-id="{$pron->id}" ></image>
|
||||
{/foreach}
|
||||
<br/>
|
||||
<div style="margin-left: 20px;" class="translations">
|
||||
{/if}
|
||||
{$last == $term->string1 && trim($last2) != '' && trim($term->string2) != '' ? ', ' : ''}{$term->string2}{**
|
||||
Nutne kvoli newline
|
||||
**}
|
||||
{var $last = $term->string1}
|
||||
{var $last2 = $term->string2}
|
||||
{/foreach}
|
||||
</table>
|
||||
{/ifset}
|
||||
{control paginator}
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
Reference in New Issue
Block a user