Fix nette 3.0
This commit is contained in:
@@ -41,6 +41,7 @@ abstract class BaseFrontPresenter extends UnsecuredPresenter
|
|||||||
|
|
||||||
protected function startup()
|
protected function startup()
|
||||||
{
|
{
|
||||||
|
|
||||||
$trs = $this->em->getRepository(Translation::class)->findBy([], ['id' => 'ASC', 'direction' => 'ASC']);
|
$trs = $this->em->getRepository(Translation::class)->findBy([], ['id' => 'ASC', 'direction' => 'ASC']);
|
||||||
$drs = $this->em->getRepository(Dictionary::class)->findPairs('id', 'name');
|
$drs = $this->em->getRepository(Dictionary::class)->findPairs('id', 'name');
|
||||||
$select = [];
|
$select = [];
|
||||||
@@ -52,10 +53,10 @@ abstract class BaseFrontPresenter extends UnsecuredPresenter
|
|||||||
$lang = mb_substr($lang1, 0, -1);
|
$lang = mb_substr($lang1, 0, -1);
|
||||||
$lang .= "o-" . $lang2;
|
$lang .= "o-" . $lang2;
|
||||||
$slug = Strings::webalize($lang);
|
$slug = Strings::webalize($lang);
|
||||||
$select[$drs[$t->getDictionary()->getId()]][$t->getId()] = $lang;
|
$select[$drs[$t->getDictionary()->id]][$t->id] = $lang;
|
||||||
$translations[$t->getId()]["slug"] = $slug;
|
$translations[$t->id]["slug"] = $slug;
|
||||||
$translations[$t->getId()]["lang"] = $lang;
|
$translations[$t->id]["lang"] = $lang;
|
||||||
$translations[$t->getId()]["t"] = $t;
|
$translations[$t->id]["t"] = $t;
|
||||||
$slugs[$slug] = $t;
|
$slugs[$slug] = $t;
|
||||||
}
|
}
|
||||||
$this->translations = $translations;
|
$this->translations = $translations;
|
||||||
|
|||||||
@@ -21,26 +21,6 @@ use App\Model\Database\Facade\TermFacade;
|
|||||||
final class HomePresenter extends BaseFrontPresenter
|
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)
|
public function searchFormSucceededIpa(UI\Form $form, $values)
|
||||||
{
|
{
|
||||||
$translation = $values->translation;
|
$translation = $values->translation;
|
||||||
@@ -96,7 +76,6 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
$id = $this['searchForm']['translation']->value;
|
$id = $this['searchForm']['translation']->value;
|
||||||
dump($id);
|
|
||||||
if (isset($this->translations[$id])) {
|
if (isset($this->translations[$id])) {
|
||||||
$t = $this->translations[$id];
|
$t = $this->translations[$id];
|
||||||
$this->redirect('Front:Home:select', $t["slug"], $this['searchForm']['string']->value);
|
$this->redirect('Front:Home:select', $t["slug"], $this['searchForm']['string']->value);
|
||||||
@@ -120,15 +99,7 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
|
|
||||||
public function actionIpa()
|
public function actionIpa()
|
||||||
{
|
{
|
||||||
if ($this->getRequest()->isMethod('GET')) {
|
$this->redirect('Search:ipa',$this->translation,$this->term);
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionInteractive()
|
public function actionInteractive()
|
||||||
|
|||||||
@@ -20,46 +20,65 @@ use App\Model\Database\Facade\TermFacade;
|
|||||||
|
|
||||||
class SearchPresenter extends BaseFrontPresenter
|
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)
|
protected function doSearch($query, $translation, $term, $clen = null, $paginate = true)
|
||||||
{
|
{
|
||||||
$t = $this->em->getTranslationRepository()->find($translation);
|
$t = $this->em->getTranslationRepository()->find($translation);
|
||||||
|
|
||||||
if ($term) $this->term = $term;
|
if ($term) $this->term = $term;
|
||||||
if ($translation) $this->translation = $translation;
|
if ($translation) $this->translation = $translation;
|
||||||
// $this->slug = $this->translations[$translation]["slug"];
|
$this->slug = $this->translations[$translation]["slug"];
|
||||||
|
|
||||||
$this->termFacade->setDirection(1);
|
$this->termFacade->setDirection(1);
|
||||||
|
$q = $this->termFacade->findByString($term, $t->dictionary, $clen);
|
||||||
|
|
||||||
/* if ($paginate) {
|
if ($paginate) {
|
||||||
$this["paginator"]->setItemCount(500);
|
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($q);
|
||||||
|
$count = count($paginator);
|
||||||
|
$this["paginator"]->setItemCount($count);
|
||||||
$offset = $this["paginator"]->getOffset();
|
$offset = $this["paginator"]->getOffset();
|
||||||
$itemsPerPage = $this['paginator']->getItemsPerPage();
|
$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;
|
$this->template->translation = $t;
|
||||||
|
|
||||||
return $q->getResult();
|
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['searchForm']['string']->setValue($this->term);
|
||||||
$this->template->result = $this->doSearch('TermQuery',$translation,$term,$clen,$paginate);
|
$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>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</table>
|
</table>
|
||||||
|
{control paginator}
|
||||||
{/ifset}
|
{/ifset}
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ $( document ).ready(function() {
|
|||||||
<span class="term">{$term->string1}</span>
|
<span class="term">{$term->string1}</span>
|
||||||
{foreach $term->pronunciations as $pron}
|
{foreach $term->pronunciations as $pron}
|
||||||
<span class="ipa-{$pron->type->id}">[{$pron->ipa}]</span>
|
<span class="ipa-{$pron->type->id}">[{$pron->ipa}]</span>
|
||||||
<img n:if="$pron->filename" class="sound-ipa ajax" src="/images/sound.png" alt="Prehraj" style="vertical-align: middle;" data-sound-id="{$pron->id}" ></image>
|
<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}
|
{/foreach}
|
||||||
<br/>
|
<br/>
|
||||||
<div style="margin-left: 20px;" class="translations">
|
<div style="margin-left: 20px;" class="translations">
|
||||||
@@ -51,7 +51,6 @@ $( document ).ready(function() {
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</table>
|
</table>
|
||||||
{/ifset}
|
{/ifset}
|
||||||
{/form}
|
|
||||||
{control paginator}
|
{control paginator}
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
BIN
www/assets/images/images/sound.png
Normal file
BIN
www/assets/images/images/sound.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
www/assets/images/images/spinner.gif
Normal file
BIN
www/assets/images/images/spinner.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 737 B |
BIN
www/assets/images/images/sprites.png
Normal file
BIN
www/assets/images/images/sprites.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user