Compare commits

..

4 Commits

Author SHA1 Message Date
bc4f849ff3 small fixes 2022-01-31 20:56:27 +01:00
a4b67569a4 Fix nette 3.0 2022-01-30 22:35:13 +01:00
7ecaa70768 refactor 2022-01-28 20:25:36 +01:00
9e6113b099 Refactor to multiple clasess start 2022-01-28 20:25:27 +01:00
16 changed files with 480 additions and 395 deletions

View File

@@ -3,8 +3,117 @@
namespace App\Modules\Front;
use App\Modules\Base\UnsecuredPresenter;
use Nette;
use Nette\Utils\Strings;
use Nette\Application\UI;
use Dict\OggResponse;
use Nette\Application\Responses\JsonResponse;
use AlesWita\VisualPaginator\VisualPaginator;
use AlesWita\VisualPaginator\VisualPaginatorFactory;
use App\Model\Database\EntityManager;
use App\Model\Database\Entity\Dictionary;
use App\Model\Database\Entity\Translation;
use App\Model\Database\Repository\TranslationRepository;
use App\Model\Database\Repository\TermsFullQuery;
use App\Model\Database\Repository\TermsQuickQuery;
use App\Model\Database\Facade\TermFacade;
abstract class BaseFrontPresenter extends UnsecuredPresenter
{
/** @inject @var EntityManager */
public EntityManager $em;
/** @inject */
public VisualPaginatorFactory $visualPaginatorFactory;
/** @inject */
public TermFacade $termFacade;
/** @persistent */
public $term;
/** @persistent */
public $slug;
public $translation;
public $translations;
public $dictionaries;
public $drsSelect;
public $slugs;
protected function startup()
{
$trs = $this->em->getRepository(Translation::class)->findBy([], ['id' => 'ASC', 'direction' => 'ASC']);
$drs = $this->em->getRepository(Dictionary::class)->findPairs('id', 'name');
$select = [];
$translations = [];
foreach ($trs as $t) {
$lang1 = $t->getLangName1();
$lang2 = $t->getLangName2();
$lang = mb_substr($lang1, 0, -1);
$lang .= "o-" . $lang2;
$slug = Strings::webalize($lang);
$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->slug= $translations[1]["slug"];
$this->translations = $translations;
$this->dictionaries = $drs;
$this->drsSelect = $select;
$this->slugs = $slugs;
parent::startup();
}
public function handleGetInfo($id)
{
$term = $this->repoTerms->find($id);
$termFlags = $this->repoTermFlags->findAssoc([], 'id');
$dictionary = $term->dictionary;
$query = new TermsFullQuery($dictionary, $term->string1, 1, false);
$result = $this->repoTerms->fetch($query);
$this->template->result = $result;
$this->template->termFlags = $termFlags;
$this->setView('info');
}
public function beforeRender()
{
$dicttypes = $this->em->getDictTypeRepository()->findAssoc([], 'id');
$this->template->dicttypes = $dicttypes;
$this->template->dictionaries = $this->dictionaries;
$this->template->translations = $this->translations;
// $this->template->paginator = $this->paginator;
}
protected function createComponentSearchForm()
{
$form = new UI\Form;
$form->addText('string', 'Výraz')
->setRequired('Zadajte výray');
$form->addSelect('translation', 'Preklad', $this->drsSelect)
->setDefaultValue(1)
->setRequired('Vyberte slovnik');
$form->addText('clen', 'Clen', 5);
$form->addSubmit('search', 'VyhaÄľadaj');
$form->onSuccess[] = array($this, 'searchFormSucceeded');
return $form;
}
public function searchFormSucceeded(UI\Form $form, $values)
{
$translation = $values->translation;
$clen = $values->clen;
$term = $values->string;
$this->redirect('Search:default',$translation,$term,$clen);
}
}

View File

@@ -0,0 +1,4 @@
{layout '../templates/@layout.latte'}
{block #content}
{block form}
{/block}

View File

@@ -21,118 +21,6 @@ use App\Model\Database\Facade\TermFacade;
final class HomePresenter extends BaseFrontPresenter
{
/** @inject @var EntityManager */
public EntityManager $em;
/** @inject */
public VisualPaginatorFactory $visualPaginatorFactory;
/** @inject */
public TermFacade $termFacade;
private $translations;
private $dictionaries;
private $drsSelect;
private $slugs;
public $translation;
/** @persistent */
public $term;
/** @persistent */
public $slug;
protected function startup()
{
$trs = $this->em->getRepository(Translation::class)->findBy([], ['id' => 'ASC', 'direction' => 'ASC']);
$drs = $this->em->getRepository(Dictionary::class)->findPairs('id', 'name');
$select = [];
foreach ($trs as $t) {
$lang1 = $t->getLangName1();
$lang2 = $t->getLangName2();
$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;
$slugs[$slug] = $t;
}
$this->translations = $translations;
$this->dictionaries = $drs;
$this->drsSelect = $select;
$this->slugs = $slugs;
parent::startup();
}
protected function doSearch($query, $translation, $term, $clen = null, $paginate = true)
{
$t = $this->em->getTranslationRepository()->find($translation);
if ($term) $this->term = $term;
if ($translation) $this->translation = $translation;
$this->slug = $this->translations[$translation]["slug"];
$this->termFacade->setDirection(1);
if ($paginate) {
$this["paginator"]->setItemCount(500);
$offset = $this["paginator"]->getOffset();
$itemsPerPage = $this['paginator']->getItemsPerPage();
}
$q = $this->termFacade->findByString($term, $t->dictionary, $clen);
$q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage);
$this->template->translation = $t;
return $q->getResult();
}
/**
* @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;
}
protected function createComponentSearchForm()
{
$form = new UI\Form;
$form->addText('string', 'Výraz')
->setRequired('Zadajte výray');
$form->addSelect('translation', 'Preklad', $this->drsSelect)
->setDefaultValue(1)
->setRequired('Vyberte slovnik');
$form->addText('clen', 'Clen', 5);
$form->addSubmit('search', 'VyhaÄľadaj');
$form->onSuccess[] = array($this, 'searchFormSucceeded');
return $form;
}
public function searchFormSucceeded(UI\Form $form, $values)
{
$translation = $values->translation;
$clen = $values->clen;
$term = $values->string;
$result = $this->doSearch('TermsQuery', $translation, $term, $clen);
$this->term = $term;
dump($result);
$this->template->result = $result;
}
public function searchFormSucceededIpa(UI\Form $form, $values)
{
$translation = $values->translation;
@@ -162,14 +50,6 @@ final class HomePresenter extends BaseFrontPresenter
return $this->sendResponse($oggResp);
}
public function beforeRender()
{
$dicttypes = $this->em->getDictTypeRepository()->findAssoc([], 'id');
$this->template->dicttypes = $dicttypes;
$this->template->dictionaries = $this->dictionaries;
$this->template->translations = $this->translations;
// $this->template->paginator = $this->paginator;
}
public function actionDefault()
{
@@ -179,7 +59,6 @@ final class HomePresenter extends BaseFrontPresenter
$result = $this->doSearch('TermsQuery',$t->id,$this->term);
if ($result) $this->template->result = $result;
} else {
//dumpe($this);
$this->term = $this['searchForm']['string']->getValue();
}
$this['searchForm']->onSuccess[] = array($this, 'searchFormSucceeded');
@@ -197,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);
@@ -213,21 +91,7 @@ final class HomePresenter extends BaseFrontPresenter
$this->setView('ipa');
}
public function handleGetInfo($id)
{
$term = $this->repoTerms->find($id);
$termFlags = $this->repoTermFlags->findAssoc([], 'id');
$dictionary = $term->dictionary;
$query = new TermsFullQuery($dictionary, $term->string1, 1, false);
$result = $this->repoTerms->fetch($query);
$this->template->result = $result;
$this->template->termFlags = $termFlags;
$this->setView('info');
}
public function renderDefault()
{
@@ -235,15 +99,8 @@ 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');
if ($this->term)
$this->redirect('Search:ipa',$this->translation,$this->term);
}
public function actionInteractive()

View File

@@ -1,75 +1 @@
{block head}
<script>
$( document ).ready(function() {
console.log( "ready!" );
$("tr[id*='term']").on("click",function () {
var id = this.id + '-info';
if ($('#' + id).length == 0) {
$(this).after('<tr id=' + '"' + id + '"></tr>');
console.log('Append ' + id);
$.ajax({
url: $(this).attr('data-url'),
context: $('#' + id)
}).done(function (response) {
console.log(response);
$(this).html("<td colspan='4'>" + response + "</td>");
$("img.ajax").on("click", function (event) {
event.preventDefault();
id = $(this).attr("data-sound-id");
var audioElement = document.createElement('audio');
var link = {link Home:play 1234567};
audioElement.setAttribute('src', link.replace('1234567',id));
console.log("Play sound:" + id);
audioElement.play();
});
});
}
});
});
</script>
{/block}
{block content}
<div id="content">
<h2>Zadaj vyhladavany vyraz.</h2>
<div class="boxes">
{form searchForm}
<table>
<tr>
<th>{label string /}</th><th>{label translation /}</th><th>{label clen /}</th>
</tr>
<tr>
<td>{input string}</td><td>{input translation}</td><td>{input clen}</td><td>{input search}</td>
</tr>
</table>
{ifset $result}
<table class="e-table" n:snippet="termsComnainer">
<tr>
<th>Vyraz</th><th>Preklad</th><th>Typ</th><th>Member</th>
</tr>
{foreach $result as $term}
<tr data-url="{link getInfo! $term->id}" n:snippet="term-$term->id">
{if $translation->getDirection() == 1}
<td>{$term->string1}{if $term->suffix1}&nbsp;{$term->suffix1->text}{/if}</td>
<td>{$term->string2}{if $term->suffix2}&nbsp;{$term->suffix2->text}{/if}</td>
{else}
<td>{$term->string2}{if $term->suffix2}&nbsp;{$term->suffix2->text}{/if}</td>
<td>{$term->string1}{if $term->suffix1}&nbsp;{$term->suffix1->text}{/if}</td>
{/if}
<td n:attr="title => $term->type ? $dicttypes[$term->type->id]->fullName : null">{$term->type ? $dicttypes[$term->type->id]->shortName : ''}</td>
<td>{$term->member}</td>
</tr>
{/foreach}
</table>
{control paginator}
{/ifset}
{/form}
</div>
{/block}
{block #content}

View File

@@ -1,106 +1 @@
{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');
audioElement.setAttribute('src', {link Home:play} + "/" + id);
console.log("Play sound:" + id);
audioElement.play();
});
$(function() {
var select_name = "string";
$("input[name=" + select_name + "]").autocomplete({
source: function( request, response ) {
$.ajax({
url: {!$presenter->link('autocomplete')},
data: {
whichData: select_name,
typedText: request.term,
translation: $("select[name=translation]").val()
},
success: function( data ) {
response( $.map( data, function( item ) {
return { label: item, value: item }
}));
}
});
},
minLength: 3,
open: function() {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function() {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
},
select: function(e, ui) {
$("#frm-searchForm-string").val(ui.item.value);
$("#frm-searchForm").submit();
}
});
});
});
</script>
{/block}
{block content}
<div id="content">
<h2>Zadaj vyhladavany vyraz.</h2>
<div class="boxes">
{form searchForm}
<table>
<tr>
<th>{label string /}</th><th>{label translation /}</th>
</tr>
<tr>
<td>{input string}</td><td>{input translation}</td><td>{input search}</td>
</tr>
</table>
{ifset $result}
<table id="searchBox">
</table>
<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>&nbsp;
{foreach $term->pronunciations as $pron}
<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>
{/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}
{/form}
{control paginator}
</div>
{/block}
{block #content}

View File

@@ -1,67 +1 @@
{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}
<div id="content">
<h2>Zadaj vyhladavany vyraz.</h2>
<div class="boxes">
{form searchForm}
<table>
<tr>
<th>{label string /}</th><th>{label translation /}</th><th>{label clen /}</th>
</tr>
<tr>
<td>{input string}</td><td>{input translation}</td><td>{input clen}</td><td>{input search}</td>
</tr>
</table>
{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>&nbsp;
{foreach $term->pronunciations as $pron}
<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>
{/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}
{/form}
{control paginator}
</div>
{/block}
{block #content}

View File

@@ -0,0 +1,85 @@
<?php //declare(strict_types = 1);
namespace App\Modules\Front\Search;
use App\Modules\Front\BaseFrontPresenter;
use Nette;
use Nette\Utils\Strings;
use Nette\Application\UI;
use Dict\OggResponse;
use Nette\Application\Responses\JsonResponse;
use AlesWita\VisualPaginator\VisualPaginator;
use AlesWita\VisualPaginator\VisualPaginatorFactory;
use App\Model\Database\EntityManager;
use App\Model\Database\Entity\Dictionary;
use App\Model\Database\Entity\Translation;
use App\Model\Database\Repository\TranslationRepository;
use App\Model\Database\Repository\TermsFullQuery;
use App\Model\Database\Repository\TermsQuickQuery;
use App\Model\Database\Facade\TermFacade;
class SearchPresenter extends BaseFrontPresenter
{
protected function doSearch($query, $translation, $term, $clen = null, $paginate = true)
{
$t = $this->em->getTranslationRepository()->find($translation);
if ($term) $this->term = $term;
if ($translation) $this->translation = $translation;
$this->slug = $this->translations[$translation]["slug"];
$this->termFacade->setDirection(1);
$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);
}
$this->template->translation = $t;
return $q->getResult();
}
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;
}
}
?>

View 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}">&laquo;</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">&hellip;</span>
</li>
{/if}
{/foreach}
<li n:class="$paginator->isLast() ? 'page-item disabled' : 'page-item'">
<a n:href="paginate!, page => $paginator->page + 1" class="{$linkClass}">&raquo;</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}

View File

@@ -0,0 +1,64 @@
{block head}
<script>
$( document ).ready(function() {
console.log( "ready!" );
$("tr[id*='term']").on("click",function () {
var id = this.id + '-info';
if ($('#' + id).length == 0) {
$(this).after('<tr id=' + '"' + id + '"></tr>');
console.log('Append ' + id);
$.ajax({
url: $(this).attr('data-url'),
context: $('#' + id)
}).done(function (response) {
console.log(response);
$(this).html("<td colspan='4'>" + response + "</td>");
$("img.ajax").on("click", function (event) {
event.preventDefault();
id = $(this).attr("data-sound-id");
var audioElement = document.createElement('audio');
var link = {link Home:play 1234567};
audioElement.setAttribute('src', link.replace('1234567',id));
console.log("Play sound:" + id);
audioElement.play();
});
});
}
});
});
</script>
{/block}
{block content}
<div class="boxes">
{ifset $result}
<table class="e-table" n:snippet="termsComnainer">
<tr>
<th>Vyraz</th><th>Preklad</th><th>Typ</th><th>Member</th>
</tr>
{foreach $result as $term}
<tr data-url="{link getInfo! $term->id}" n:snippet="term-$term->id">
{if $translation->getDirection() == 1}
<td>{$term->string1}{if $term->suffix1}&nbsp;{$term->suffix1->text}{/if}</td>
<td>{$term->string2}{if $term->suffix2}&nbsp;{$term->suffix2->text}{/if}</td>
{else}
<td>{$term->string2}{if $term->suffix2}&nbsp;{$term->suffix2->text}{/if}</td>
<td>{$term->string1}{if $term->suffix1}&nbsp;{$term->suffix1->text}{/if}</td>
{/if}
<td n:attr="title => $term->type ? $dicttypes[$term->type->id]->fullName : null">{$term->type ? $dicttypes[$term->type->id]->shortName : ''}</td>
<td>{$term->member}</td>
</tr>
{/foreach}
</table>
{control paginator}
{/ifset}
</div>
{/block}

View File

@@ -0,0 +1,104 @@
{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');
audioElement.setAttribute('src', {link Home:play} + "/" + id);
console.log("Play sound:" + id);
audioElement.play();
});
$(function() {
var select_name = "string";
$("input[name=" + select_name + "]").autocomplete({
source: function( request, response ) {
$.ajax({
url: {!$presenter->link('autocomplete')},
data: {
whichData: select_name,
typedText: request.term,
translation: $("select[name=translation]").val()
},
success: function( data ) {
response( $.map( data, function( item ) {
return { label: item, value: item }
}));
}
});
},
minLength: 3,
open: function() {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function() {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
},
select: function(e, ui) {
$("#frm-searchForm-string").val(ui.item.value);
$("#frm-searchForm").submit();
}
});
});
});
</script>
{/block}
{block content}
<div class="boxes">
{form searchForm}
<table>
<tr>
<th>{label string /}</th><th>{label translation /}</th>
</tr>
<tr>
<td>{input string}</td><td>{input translation}</td><td>{input search}</td>
</tr>
</table>
{ifset $result}
<table id="searchBox">
</table>
<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>&nbsp;
{foreach $term->pronunciations as $pron}
<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>
{/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}
{/form}
{control paginator}
</div>
{/block}

View File

@@ -0,0 +1,54 @@
{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}
{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>&nbsp;
{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}

View File

@@ -39,8 +39,22 @@
<h1 n:ifset="$title">{$title}</h1>
<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>
<div id="content">
{block form}
<h2>Zadaj vyhladavany vyraz.</h2>
{form searchForm}
<table>
<tr>
<th>{label string /}</th><th>{label translation /}</th><th>{label clen /}</th>
</tr>
<tr>
<td>{input string}</td><td>{input translation}</td><td>{input clen}</td><td>{input search}</td>
</tr>
</table>
{/form}
{/block}
{include content}
</div>
</article>
<section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB