This commit is contained in:
2022-01-27 22:20:25 +01:00
parent cddc8b970e
commit 500baf2878
10 changed files with 681 additions and 674 deletions

View File

@@ -8,12 +8,21 @@ use App\Model\Database\Entity\Attributes\TUpdatedAt;
use App\Model\Exception\Logic\InvalidArgumentException;
use App\Model\Security\Identity;
use App\Model\Utils\DateTime;
use App\Model\Utils\Strings;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\UserRepository")
* @ORM\Table(name="`user`")
* @ORM\HasLifecycleCallbacks
*
* @property int $id
* @property String $name
* @property String $surname
* @property String $email
* @property String $password
* @property String $role
* @property int $state
*/
class User extends AbstractEntity
{

View File

@@ -22,8 +22,8 @@ final class HomePresenter extends BaseFrontPresenter
{
/** @inject @var \App\Model\Database\EntityManager */
public $em;
/** @inject @var EntityManager */
public EntityManager $em;
/** @inject */
public VisualPaginatorFactory $visualPaginatorFactory;
/** @inject */
@@ -38,27 +38,27 @@ final class HomePresenter extends BaseFrontPresenter
/** @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');
$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;
$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;
@@ -68,7 +68,7 @@ final class HomePresenter extends BaseFrontPresenter
parent::startup();
}
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);
@@ -83,7 +83,7 @@ final class HomePresenter extends BaseFrontPresenter
$offset = $this["paginator"]->getOffset();
$itemsPerPage = $this['paginator']->getItemsPerPage();
}
$q = $this->termFacade->findByString($term,$t->dictionary,$clen);
$q = $this->termFacade->findByString($term, $t->dictionary, $clen);
$q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage);
$this->template->translation = $t;
@@ -115,54 +115,56 @@ final class HomePresenter extends BaseFrontPresenter
$form->addSelect('translation', 'Preklad', $this->drsSelect)
->setDefaultValue(1)
->setRequired('Vyberte slovnik');
$form->addText('clen','Clen',5);
$form->addText('clen', 'Clen', 5);
$form->addSubmit('search', 'Vyhaľadaj');
$form->onSuccess[] = array($this, 'searchFormSucceeded');
return $form;
}
public function searchFormSucceeded(UI\Form $form,$values)
public function searchFormSucceeded(UI\Form $form, $values)
{
$translation = $values->translation;
$clen = $values->clen;
$term = $values->string;
$result = $this->doSearch('TermsQuery',$translation,$term,$clen);
$result = $this->doSearch('TermsQuery', $translation, $term, $clen);
$this->term = $term;
dump($result);
$this->template->result = $result;
}
public function searchFormSucceededIpa(UI\Form $form,$values)
public function searchFormSucceededIpa(UI\Form $form, $values)
{
$translation = $values->translation;
$term = $values->string;
$clen = $values->clen;
$result = $this->doSearch('TermsFullQuery',$translation,$term,$clen);
$result = $this->doSearch('TermsFullQuery', $translation, $term, $clen);
$this->template->result = $result;
}
public function searchFormSucceededInteractive(UI\Form $form,$values)
public function searchFormSucceededInteractive(UI\Form $form, $values)
{
$term = $values->string;
$translation = $values->translation;
$result = $this->doSearch('TermsFullQuery',$translation,$term,null);
$result = $this->doSearch('TermsFullQuery', $translation, $term, null);
$this->template->result = $result;
}
public function actionPlay($id = null)
{
$pron = $this->em->getPronunciationRepository()->find(['id'=>$id]);
$pron = $this->em->getPronunciationRepository()->find(['id' => $id]);
$basepath = $this->getHttpRequest()->url->basePath . "/media";
$oggResp = new OggResponse($id,$pron->filename);
$oggResp = new OggResponse($id, $pron->filename);
return $this->sendResponse($oggResp);
}
public function beforeRender()
{
$dicttypes = $this->em->getDictTypeRepository()->findAssoc([],'id');
$dicttypes = $this->em->getDictTypeRepository()->findAssoc([], 'id');
$this->template->dicttypes = $dicttypes;
$this->template->dictionaries = $this->dictionaries;
$this->template->translations = $this->translations;
@@ -171,18 +173,19 @@ final class HomePresenter extends BaseFrontPresenter
public function actionDefault()
{
/*
if ($this->getRequest()->isMethod('GET') && $this->term) {
$this['searchForm']['string']->setValue($this->term);
$t = $this->slugs[$this->slug];
$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');
}
public function actionSelect($slug,$term = null)
public function actionSelect($slug, $term = null)
{
$this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededIpa');
if ($this->getRequest()->isMethod('GET')) {
@@ -197,12 +200,11 @@ final class HomePresenter extends BaseFrontPresenter
dump($id);
if (isset($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);
}
}
if ($term) {
$query = new TermsFullQuery($translation->dictionary,$term,$translation->direction);
$query = new TermsFullQuery($translation->dictionary, $term, $translation->direction);
$result = $this->repoTerms->fetch($query);
$this->template->result = $result;
@@ -214,11 +216,11 @@ final class HomePresenter extends BaseFrontPresenter
public function handleGetInfo($id)
{
$term = $this->repoTerms->find($id);
$termFlags = $this->repoTermFlags->findAssoc([],'id');
$termFlags = $this->repoTermFlags->findAssoc([], 'id');
$dictionary = $term->dictionary;
$query = new TermsFullQuery($dictionary,$term->string1,1,false);
$query = new TermsFullQuery($dictionary, $term->string1, 1, false);
$result = $this->repoTerms->fetch($query);
$this->template->result = $result;
@@ -236,7 +238,7 @@ final class HomePresenter extends BaseFrontPresenter
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);
$result = $this->doSearch('TermsFullQuery', $this->slugs[$this->slug]->id, $this->term);
if ($result) $this->template->result = $result;
}
}
@@ -249,7 +251,7 @@ final class HomePresenter extends BaseFrontPresenter
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);
$result = $this->doSearch('TermsFullQuery', $this->slugs[$this->slug]->id, $this->term);
if ($result) $this->template->result = $result;
}
}
@@ -257,11 +259,11 @@ final class HomePresenter extends BaseFrontPresenter
$this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededInteractive');
}
public function renderAutocomplete($whichData, $typedText = '',$translation = 1)
public function renderAutocomplete($whichData, $typedText = '', $translation = 1)
{
$translation = $this->repoTranslations->find($translation);
$query = new TermsQuickQuery($translation->dictionary,$typedText,$translation->direction);
$query = new TermsQuickQuery($translation->dictionary, $typedText, $translation->direction);
$result = $this->repoTerms->fetch($query);
$map = [];
@@ -274,13 +276,9 @@ final class HomePresenter extends BaseFrontPresenter
public function renderIpa()
{
}
public function renderMerge()
{
}
}