Commit c22139e4 authored by Martin Gregor's avatar Martin Gregor
Browse files

uprava ak v systeme neexistuju vety

parent 0b36b303
......@@ -21,46 +21,48 @@ class HomepagePresenter extends BasePresenter
if (!isset($_POST['sentence_id']))
{
$count = $this->db->table('sentences')->count("*");
$this->sentence_id = (time() % $count) + 1;
$current_sentence_id = $this->sentence_id;
if ($count)
{
$this->sentence_id = (time() % $count) + 1;
$current_sentence_id = $this->sentence_id;
$sentenceIdSession = $this->getSession('sentenceIdSession');
$sentenceIdSession = $this->getSession('sentenceIdSession');
// inicializacia session
if (!is_array($sentenceIdSession->ids) || count($sentenceIdSession->ids) == $count)
{
$sentenceIdSession->ids = [];
}
// inicializacia session
if (!is_array($sentenceIdSession->ids) || count($sentenceIdSession->ids) == $count)
{
$sentenceIdSession->ids = [];
}
// vyhladanie nezobrazenej vety
while (in_array($current_sentence_id,$sentenceIdSession->ids))
{
$current_sentence_id = mt_rand(1, $count);
}
// vyhladanie nezobrazenej vety
while (in_array($current_sentence_id,$sentenceIdSession->ids))
{
$current_sentence_id = mt_rand(1, $count);
}
// ulozenie id vybranej vety a ziskanie vety z db
$sentenceIdSession->ids[] = $current_sentence_id;
$sentence = $this->db->table('sentences')->get($current_sentence_id);
// ulozenie id vybranej vety a ziskanie vety z db
$sentenceIdSession->ids[] = $current_sentence_id;
// else
// {
// $current_sentence_id = $this->sentence_id = $_POST['sentence_id'];
// }
$sentence = $this->db->table('sentences')->get($current_sentence_id);
// rozdelenie vety na slova a inicializacia pola duplicit
$this->words = explode(' ', $sentence->sentence);
// rozdelenie vety na slova a inicializacia pola duplicit
$this->words = explode(' ', $sentence->sentence);
// lematizacia skolskou sluzbou
$this->lematize($sentence->sentence);
// lematizacia skolskou sluzbou
$this->lematize($sentence->sentence);
// preklad kazdeho slova z vety
foreach ($this->words_lema as $word)
{
$this->en_words[] = $this->translate($word);
}
// preklad kazdeho slova z vety
foreach ($this->words_lema as $word)
$this->genTranslations();
$this->template->sentence = $sentence->sentence;
}
else
{
$this->en_words[] = $this->translate($word);
$this->template->sentence = null;
}
$this->genTranslations();
$this->template->sentence = $sentence->sentence;
}
}
......
......@@ -12,13 +12,21 @@
</div>
</div>
<div class="panel panel-primary center-block">
<div class="panel-heading">
<h2 class="panel-title">
<strong>Veta: </strong>{$sentence}
</h2>
</div>
<div class="panel-body">
{control translationForm}
</div>
{if $sentence}
<div class="panel-heading">
<h2 class="panel-title">
<strong>Veta: </strong>{$sentence}
</h2>
</div>
<div class="panel-body">
{control translationForm}
</div>
{else}
<div class="panel-heading">
<h2 class="panel-title">
<strong>V systéme sa nenachádzajú žiadne vety.</strong>
</h2>
</div>
{/if}
</div>
{/block}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment