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

@@ -1,94 +1,94 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId; use App\Model\Database\Entity\Attributes\TId;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\DictionaryRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\DictionaryRepository")
* @ORM\Table(name="`dictionary`") * @ORM\Table(name="`dictionary`")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property String $name * @property String $name
* @property String $fullname * @property String $fullname
* @property Term $terms * @property Term $terms
* @property Language $lang1 * @property Language $lang1
* @property Language $lang2 * @property Language $lang2
*/ */
class Dictionary extends AbstractEntity class Dictionary extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($name,$fullname) public function __construct($name,$fullname)
{ {
$this->name = $name; $this->name = $name;
$this->fullName = $fullname; $this->fullName = $fullname;
$this->translations = new ArrayCollection(); $this->translations = new ArrayCollection();
} }
/** /**
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Translation", mappedBy="dictionary", cascade={"persist"}) * @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Translation", mappedBy="dictionary", cascade={"persist"})
* @var Collection&iterable<Translation> * @var Collection&iterable<Translation>
*/ */
protected Collection $translations; protected Collection $translations;
public function getTranslations() public function getTranslations()
{ {
return $this->translations; return $this->translations;
} }
/** /**
* @ORM\OnetoMany(targetEntity="\App\Model\Database\Entity\Term", mappedBy="dictionary") * @ORM\OnetoMany(targetEntity="\App\Model\Database\Entity\Term", mappedBy="dictionary")
* @var Collection&iterable<Term> * @var Collection&iterable<Term>
*/ */
protected Collection $terms; protected Collection $terms;
/** /**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries1") * @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries1")
* @ORM\JoinColumn(name="lang1_id", referencedColumnName="id") * @ORM\JoinColumn(name="lang1_id", referencedColumnName="id")
*/ */
protected ?Language $lang1; protected ?Language $lang1;
/** /**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries2") * @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries2")
* @ORM\JoinColumn(name="lang2_id", referencedColumnName="id") * @ORM\JoinColumn(name="lang2_id", referencedColumnName="id")
*/ */
protected ?Language $lang2; protected ?Language $lang2;
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $name; protected $name;
public function getName() public function getName()
{ {
return $this->name; return $this->name;
} }
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $fullName; protected $fullName;
public function setLang1($lang1) public function setLang1($lang1)
{ {
$this->lang1 = $lang1; $this->lang1 = $lang1;
return $this; return $this;
} }
public function setLang2($lang2) public function setLang2($lang2)
{ {
$this->lang2 = $lang2; $this->lang2 = $lang2;
return $this; return $this;
} }
} }
?> ?>

View File

@@ -1,65 +1,65 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId; use App\Model\Database\Entity\Attributes\TId;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\LanguageRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\LanguageRepository")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property String $name * @property String $name
* @property String $shortName * @property String $shortName
* @property Dictionary $dictionaries1 * @property Dictionary $dictionaries1
* @property Dictionary $dictionaries2 * @property Dictionary $dictionaries2
* *
*/ */
class Language extends AbstractEntity class Language extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($shortname,$name) public function __construct($shortname,$name)
{ {
$this->shortName = $shortname; $this->shortName = $shortname;
$this->name = $name; $this->name = $name;
} }
/** /**
* @ORM\Column(type="string",length=2, unique=true, options={"fixed" = true}) * @ORM\Column(type="string",length=2, unique=true, options={"fixed" = true})
*/ */
protected $shortName; protected $shortName;
public function getShortName() public function getShortName()
{ {
return $this->shortName; return $this->shortName;
} }
/** /**
* @ORM\Column(type="string",length=32) * @ORM\Column(type="string",length=32)
*/ */
protected $name; protected $name;
public function getName() public function getName()
{ {
return $this->name; return $this->name;
} }
/* /*
* @var Collection&iterable<Dictionary> * @var Collection&iterable<Dictionary>
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language") * @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
*/ */
protected Collection $dictionaries1; protected Collection $dictionaries1;
/* /*
* @var Collection&iterable<Dictionary> * @var Collection&iterable<Dictionary>
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language") * @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
*/ */
protected Collection $dictionaries2; protected Collection $dictionaries2;
} }
?> ?>

View File

@@ -1,85 +1,85 @@
<?php <?php
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId; use App\Model\Database\Entity\Attributes\TId;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\PronunciationRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\PronunciationRepository")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property Term $terms * @property Term $terms
* @property PronunciationType $type * @property PronunciationType $type
* @property String $ipa * @property String $ipa
* @property String $filename * @property String $filename
*/ */
class Pronunciation extends AbstractEntity class Pronunciation extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($type,$ipa,$filename=null) public function __construct($type,$ipa,$filename=null)
{ {
$this->type = $type; $this->type = $type;
$this->ipa = $ipa; $this->ipa = $ipa;
$this->filename = $filename; $this->filename = $filename;
$this->terms = new \Doctrine\Common\Collections\ArrayCollection(); $this->terms = new \Doctrine\Common\Collections\ArrayCollection();
} }
/** /**
* @ORM\ManyToMany(targetEntity="Term", mappedBy="pronunciations") * @ORM\ManyToMany(targetEntity="Term", mappedBy="pronunciations")
*/ */
private $terms; private $terms;
/** /**
* @ORM\ManyToOne(targetEntity="PronunciationType", inversedBy="pronunciations") * @ORM\ManyToOne(targetEntity="PronunciationType", inversedBy="pronunciations")
*/ */
protected $type; protected $type;
/** /**
* @ORM\Column(type="string",nullable=true) * @ORM\Column(type="string",nullable=true)
*/ */
protected $ipa; protected $ipa;
/** /**
* @ORM\Column(type="string", nullable=true) * @ORM\Column(type="string", nullable=true)
*/ */
protected $filename; protected $filename;
/** /**
* Get the value of filename * Get the value of filename
*/ */
public function getFilename() public function getFilename()
{ {
return $this->filename; return $this->filename;
} }
/** /**
* Get the value of terms * Get the value of terms
*/ */
public function getTerms() public function getTerms()
{ {
return $this->terms; return $this->terms;
} }
/** /**
* Get the value of ipa * Get the value of ipa
*/ */
public function getIpa() public function getIpa()
{ {
return $this->ipa; return $this->ipa;
} }
/** /**
* Get the value of type * Get the value of type
*/ */
public function getType() public function getType()
{ {
return $this->type; return $this->type;
} }
} }
?> ?>

View File

@@ -1,37 +1,37 @@
<?php <?php
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\Tid; use App\Model\Database\Entity\Attributes\Tid;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\PronunciationTypeRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\PronunciationTypeRepository")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property String $name * @property String $name
* @property String $fullName * @property String $fullName
*/ */
class PronunciationType extends AbstractEntity class PronunciationType extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($name,$fullName) public function __construct($name,$fullName)
{ {
$this->name = $name; $this->name = $name;
$this->fullName = $fullName; $this->fullName = $fullName;
} }
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $name; protected $name;
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $fullName; protected $fullName;
} }
?> ?>

View File

@@ -1,97 +1,97 @@
<?php <?php
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId; use App\Model\Database\Entity\Attributes\TId;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\TermFlagRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\TermFlagRepository")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property WordClass $class * @property WordClass $class
* @property Language $language * @property Language $language
* @property String $code * @property String $code
* @property String $description * @property String $description
*/ */
class TermFlag extends AbstractEntity class TermFlag extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($id,$class,$language,$code,$description) public function __construct($id,$class,$language,$code,$description)
{ {
$this->id = $id; $this->id = $id;
$this->class = $class; $this->class = $class;
$this->language = $language; $this->language = $language;
$this->code = $code; $this->code = $code;
$this->description = $description; $this->description = $description;
} }
/** /**
* @ORM\ManyToOne(targetEntity="WordClass", inversedBy="flags") * @ORM\ManyToOne(targetEntity="WordClass", inversedBy="flags")
*/ */
protected $class; protected $class;
public function getClass() public function getClass()
{ {
return $this->class; return $this->class;
} }
public function setClass($class) public function setClass($class)
{ {
$this->class = $class; $this->class = $class;
return $this; return $this;
} }
/** /**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="flags") * @ORM\ManyToOne(targetEntity="Language", inversedBy="flags")
*/ */
protected $language; protected $language;
public function getLanguage() public function getLanguage()
{ {
return $this->language; return $this->language;
} }
public function setLanguage($language) public function setLanguage($language)
{ {
$this->language = $language; $this->language = $language;
return $this; return $this;
} }
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $code; protected $code;
public function getCode() public function getCode()
{ {
return $this->code; return $this->code;
} }
public function setCode($code) public function setCode($code)
{ {
$this->code = $code; $this->code = $code;
return $this; return $this;
} }
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $description; protected $description;
public function getDescription() public function getDescription()
{ {
return $this->description; return $this->description;
} }
public function setDescription($description) public function setDescription($description)
{ {
$this->description = $description; $this->description = $description;
return $this; return $this;
} }
} }
?> ?>

View File

@@ -1,87 +1,87 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId; use App\Model\Database\Entity\Attributes\TId;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\TranslationRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\TranslationRepository")
* @ORM\Table(name="`translation`") * @ORM\Table(name="`translation`")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property Dictionary $dictionary * @property Dictionary $dictionary
* @property Language $lang1 * @property Language $lang1
* @property Language $lang2 * @property Language $lang2
* @property int $direction * @property int $direction
*/ */
class Translation extends AbstractEntity class Translation extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($dictionary,$lang1,$lang2,$lang_name1,$lang_name2,$direction) public function __construct($dictionary,$lang1,$lang2,$lang_name1,$lang_name2,$direction)
{ {
$this->dictionary = $dictionary; $this->dictionary = $dictionary;
$this->lang1 = $lang1; $this->lang1 = $lang1;
$this->lang2 = $lang2; $this->lang2 = $lang2;
$this->lang_name1 = $lang_name1; $this->lang_name1 = $lang_name1;
$this->lang_name2 = $lang_name2; $this->lang_name2 = $lang_name2;
$this->direction = $direction; $this->direction = $direction;
} }
/** /**
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Dictionary", inversedBy="translations") * @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Dictionary", inversedBy="translations")
*/ */
protected $dictionary; protected $dictionary;
public function getDictionary() public function getDictionary()
{ {
return $this->dictionary; return $this->dictionary;
} }
/** /**
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations1") * @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations1")
*/ */
protected $lang1; protected $lang1;
/** /**
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations2") * @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations2")
*/ */
protected $lang2; protected $lang2;
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $lang_name1; protected $lang_name1;
public function getLangName1(): String public function getLangName1(): String
{ {
return $this->lang_name1; return $this->lang_name1;
} }
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $lang_name2; protected $lang_name2;
public function getLangName2(): String public function getLangName2(): String
{ {
return $this->lang_name2; return $this->lang_name2;
} }
/** /**
* @ORM\Column(type="smallint") * @ORM\Column(type="smallint")
*/ */
protected $direction; protected $direction;
public function getDirection() : int public function getDirection() : int
{ {
return $this->direction; return $this->direction;
} }
} }
?> ?>

View File

@@ -8,12 +8,21 @@ use App\Model\Database\Entity\Attributes\TUpdatedAt;
use App\Model\Exception\Logic\InvalidArgumentException; use App\Model\Exception\Logic\InvalidArgumentException;
use App\Model\Security\Identity; use App\Model\Security\Identity;
use App\Model\Utils\DateTime; use App\Model\Utils\DateTime;
use App\Model\Utils\Strings;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\UserRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\UserRepository")
* @ORM\Table(name="`user`") * @ORM\Table(name="`user`")
* @ORM\HasLifecycleCallbacks * @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 class User extends AbstractEntity
{ {

View File

@@ -1,43 +1,43 @@
<?php <?php
namespace App\Model\Database\Entity; namespace App\Model\Database\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId; use App\Model\Database\Entity\Attributes\TId;
/** /**
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\WordClassRepository") * @ORM\Entity(repositoryClass="App\Model\Database\Repository\WordClassRepository")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* *
* @property int $id * @property int $id
* @property String $name * @property String $name
* *
*/ */
class WordClass extends AbstractEntity class WordClass extends AbstractEntity
{ {
use Tid; use Tid;
public function __construct($id,$name) public function __construct($id,$name)
{ {
$this->id = $id; $this->id = $id;
$this->name = $name; $this->name = $name;
} }
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $name; protected $name;
public function getName() public function getName()
{ {
return $this->id; return $this->id;
} }
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }
} }

View File

@@ -22,79 +22,79 @@ final class HomePresenter extends BaseFrontPresenter
{ {
/** @inject @var \App\Model\Database\EntityManager */ /** @inject @var EntityManager */
public $em; public EntityManager $em;
/** @inject */ /** @inject */
public VisualPaginatorFactory $visualPaginatorFactory; public VisualPaginatorFactory $visualPaginatorFactory;
/** @inject */ /** @inject */
public TermFacade $termFacade; public TermFacade $termFacade;
private $translations; private $translations;
private $dictionaries; private $dictionaries;
private $drsSelect; private $drsSelect;
private $slugs; private $slugs;
public $translation; public $translation;
/** @persistent */ /** @persistent */
public $term; public $term;
/** @persistent */
public $slug; /** @persistent */
public $slug;
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 = [];
foreach ($trs as $t) { foreach ($trs as $t) {
$lang1 = $t->getLangName1(); $lang1 = $t->getLangName1();
$lang2 = $t->getLangName2(); $lang2 = $t->getLangName2();
$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()->getId()]][$t->getId()] = $lang;
$translations[$t->getId()]["slug"] = $slug; $translations[$t->getId()]["slug"] = $slug;
$translations[$t->getId()]["lang"] = $lang; $translations[$t->getId()]["lang"] = $lang;
$translations[$t->getId()]["t"] = $t; $translations[$t->getId()]["t"] = $t;
$slugs[$slug] = $t; $slugs[$slug] = $t;
}
$this->translations = $translations;
$this->dictionaries = $drs;
$this->drsSelect = $select;
$this->slugs = $slugs;
parent::startup();
} }
$this->translations = $translations;
$this->dictionaries = $drs;
$this->drsSelect = $select;
$this->slugs = $slugs;
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); $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);
if ($paginate) { if ($paginate) {
$this["paginator"]->setItemCount(500); $this["paginator"]->setItemCount(500);
$offset = $this["paginator"]->getOffset(); $offset = $this["paginator"]->getOffset();
$itemsPerPage = $this['paginator']->getItemsPerPage(); $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); $q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage);
$this->template->translation = $t; $this->template->translation = $t;
return $q->getResult(); return $q->getResult();
} }
/** /**
* @return AlesWita\Components\VisualPaginator * @return AlesWita\Components\VisualPaginator
*/ */
protected function createComponentPaginator(): VisualPaginator protected function createComponentPaginator(): VisualPaginator
{ {
$paginator = $this->visualPaginatorFactory->create(); $paginator = $this->visualPaginatorFactory->create();
@@ -107,180 +107,178 @@ final class HomePresenter extends BaseFrontPresenter
return $paginator; return $paginator;
} }
protected function createComponentSearchForm() protected function createComponentSearchForm()
{ {
$form = new UI\Form; $form = new UI\Form;
$form->addText('string', 'Výraz') $form->addText('string', 'Výraz')
->setRequired('Zadajte výray'); ->setRequired('Zadajte výray');
$form->addSelect('translation', 'Preklad', $this->drsSelect) $form->addSelect('translation', 'Preklad', $this->drsSelect)
->setDefaultValue(1) ->setDefaultValue(1)
->setRequired('Vyberte slovnik'); ->setRequired('Vyberte slovnik');
$form->addText('clen','Clen',5); $form->addText('clen', 'Clen', 5);
$form->addSubmit('search', 'Vyhaľadaj'); $form->addSubmit('search', 'Vyhaľadaj');
return $form; $form->onSuccess[] = array($this, 'searchFormSucceeded');
} return $form;
}
public function searchFormSucceeded(UI\Form $form,$values) public function searchFormSucceeded(UI\Form $form, $values)
{ {
$translation = $values->translation; $translation = $values->translation;
$clen = $values->clen; $clen = $values->clen;
$term = $values->string; $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; $this->template->result = $result;
} }
public function searchFormSucceededIpa(UI\Form $form,$values) public function searchFormSucceededIpa(UI\Form $form, $values)
{ {
$translation = $values->translation; $translation = $values->translation;
$term = $values->string; $term = $values->string;
$clen = $values->clen; $clen = $values->clen;
$result = $this->doSearch('TermsFullQuery',$translation,$term,$clen); $result = $this->doSearch('TermsFullQuery', $translation, $term, $clen);
$this->template->result = $result; $this->template->result = $result;
} }
public function searchFormSucceededInteractive(UI\Form $form,$values) public function searchFormSucceededInteractive(UI\Form $form, $values)
{ {
$term = $values->string; $term = $values->string;
$translation = $values->translation; $translation = $values->translation;
$result = $this->doSearch('TermsFullQuery',$translation,$term,null); $result = $this->doSearch('TermsFullQuery', $translation, $term, null);
$this->template->result = $result; $this->template->result = $result;
} }
public function actionPlay($id = null) 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"; $basepath = $this->getHttpRequest()->url->basePath . "/media";
$oggResp = new OggResponse($id,$pron->filename); $oggResp = new OggResponse($id, $pron->filename);
return $this->sendResponse($oggResp); return $this->sendResponse($oggResp);
}
}
public function beforeRender() public function beforeRender()
{ {
$dicttypes = $this->em->getDictTypeRepository()->findAssoc([],'id'); $dicttypes = $this->em->getDictTypeRepository()->findAssoc([], 'id');
$this->template->dicttypes = $dicttypes; $this->template->dicttypes = $dicttypes;
$this->template->dictionaries = $this->dictionaries; $this->template->dictionaries = $this->dictionaries;
$this->template->translations = $this->translations; $this->template->translations = $this->translations;
// $this->template->paginator = $this->paginator; // $this->template->paginator = $this->paginator;
} }
public function actionDefault() public function actionDefault()
{ {
/*
if ($this->getRequest()->isMethod('GET') && $this->term) { if ($this->getRequest()->isMethod('GET') && $this->term) {
$this['searchForm']['string']->setValue($this->term); $this['searchForm']['string']->setValue($this->term);
$t = $this->slugs[$this->slug]; $t = $this->slugs[$this->slug];
$result = $this->doSearch('TermsQuery',$t->id,$this->term); $result = $this->doSearch('TermsQuery',$t->id,$this->term);
if ($result) $this->template->result = $result; if ($result) $this->template->result = $result;
} else {
//dumpe($this);
$this->term = $this['searchForm']['string']->getValue();
} }
*/
$this['searchForm']->onSuccess[] = array($this, 'searchFormSucceeded'); $this['searchForm']->onSuccess[] = array($this, 'searchFormSucceeded');
} }
public function actionSelect($slug,$term = null) public function actionSelect($slug, $term = null)
{ {
$this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededIpa'); $this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededIpa');
if ($this->getRequest()->isMethod('GET')) { if ($this->getRequest()->isMethod('GET')) {
if (isset($this->slugs[$slug])) { if (isset($this->slugs[$slug])) {
$t = $this->slugs[$slug]; $t = $this->slugs[$slug];
$this['searchForm']['translation']->setValue($t->id); $this['searchForm']['translation']->setValue($t->id);
$translation = $t; $translation = $t;
} }
} else { } else {
$id = $this['searchForm']['translation']->value; $id = $this['searchForm']['translation']->value;
dump($id); 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);
} }
} }
if ($term) { if ($term) {
$query = new TermsFullQuery($translation->dictionary,$term,$translation->direction); $query = new TermsFullQuery($translation->dictionary, $term, $translation->direction);
$result = $this->repoTerms->fetch($query); $result = $this->repoTerms->fetch($query);
$this->template->result = $result; $this->template->result = $result;
$this->template->translation = $translation; $this->template->translation = $translation;
} }
$this->setView('ipa'); $this->setView('ipa');
} }
public function handleGetInfo($id) public function handleGetInfo($id)
{ {
$term = $this->repoTerms->find($id); $term = $this->repoTerms->find($id);
$termFlags = $this->repoTermFlags->findAssoc([],'id'); $termFlags = $this->repoTermFlags->findAssoc([], 'id');
$dictionary = $term->dictionary; $dictionary = $term->dictionary;
$query = new TermsFullQuery($dictionary,$term->string1,1,false); $query = new TermsFullQuery($dictionary, $term->string1, 1, false);
$result = $this->repoTerms->fetch($query); $result = $this->repoTerms->fetch($query);
$this->template->result = $result; $this->template->result = $result;
$this->template->termFlags = $termFlags; $this->template->termFlags = $termFlags;
$this->setView('info'); $this->setView('info');
}
public function renderDefault()
{
}
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'); public function renderDefault()
} {
public function actionInteractive()
{
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, 'searchFormSucceededInteractive'); 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;
}
}
public function renderAutocomplete($whichData, $typedText = '',$translation = 1) $this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededIpa');
{ }
$translation = $this->repoTranslations->find($translation);
$query = new TermsQuickQuery($translation->dictionary,$typedText,$translation->direction); public function actionInteractive()
$result = $this->repoTerms->fetch($query); {
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;
}
}
$map = []; $this['searchForm']->onSuccess[] = array($this, 'searchFormSucceededInteractive');
foreach ($result as $str) { }
$map[] = $str["string1"];
}
return $this->sendResponse(new JsonResponse($map)); public function renderAutocomplete($whichData, $typedText = '', $translation = 1)
} {
$translation = $this->repoTranslations->find($translation);
public function renderIpa() $query = new TermsQuickQuery($translation->dictionary, $typedText, $translation->direction);
{ $result = $this->repoTerms->fetch($query);
} $map = [];
foreach ($result as $str) {
$map[] = $str["string1"];
}
public function renderMerge() return $this->sendResponse(new JsonResponse($map));
{ }
} public function renderIpa()
{
}
public function renderMerge()
{
}
} }