small fixes
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Model\Database\Entity\Attributes\TId;
|
|||||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\SuffixRepository")
|
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\SuffixRepository")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*
|
*
|
||||||
|
* @property int $id
|
||||||
* @property String $text
|
* @property String $text
|
||||||
*/
|
*/
|
||||||
class Suffix extends AbstractEntity
|
class Suffix extends AbstractEntity
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Model\Database\Entity\Attributes\TId;
|
|||||||
* @ORM\Table(name="`translation`")
|
* @ORM\Table(name="`translation`")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*
|
*
|
||||||
|
* @property int $id
|
||||||
* @property Dictionary $dictionary
|
* @property Dictionary $dictionary
|
||||||
* @property Language $lang1
|
* @property Language $lang1
|
||||||
* @property Language $lang2
|
* @property Language $lang2
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Model\Database\Facade;
|
namespace App\Model\Database\Facade;
|
||||||
|
|
||||||
|
use App\Model\Database\Entity\Dictionary;
|
||||||
use App\Model\Database\Entity\Term;
|
use App\Model\Database\Entity\Term;
|
||||||
|
use App\Model\Database\Entity\Translation;
|
||||||
use App\Model\Database\EntityManager;
|
use App\Model\Database\EntityManager;
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ class TermFacade
|
|||||||
/**
|
/**
|
||||||
* @param mixed[] $data
|
* @param mixed[] $data
|
||||||
*/
|
*/
|
||||||
public function findByString()
|
public function findByString(String $term,Dictionary $d,String $clen = null)
|
||||||
{
|
{
|
||||||
$query = $this->em->createQueryBuilder('t')->select('t')
|
$query = $this->em->createQueryBuilder('t')->select('t')
|
||||||
->addSelect('s1')
|
->addSelect('s1')
|
||||||
@@ -36,18 +38,18 @@ class TermFacade
|
|||||||
->leftJoin('t.suffix1','s1')
|
->leftJoin('t.suffix1','s1')
|
||||||
->leftJoin('t.suffix2','s2');
|
->leftJoin('t.suffix2','s2');
|
||||||
if ($this->direction == 1) {
|
if ($this->direction == 1) {
|
||||||
$query->where('t.string1 LIKE :str')->setParameter('str',"test"."%");
|
$query->where('t.string1 LIKE :str')->setParameter('str', $term."%");
|
||||||
$query->orderBy('t.string1,t.id','ASC');
|
$query->orderBy('t.string1,t.id','ASC');
|
||||||
} else if ($this->direction == 2) {
|
} else if ($this->direction == 2) {
|
||||||
$query->where('t.string2 LIKE :str')->setParameter('str', "test"."%");
|
$query->where('t.string2 LIKE :str')->setParameter('str', $term."%");
|
||||||
$query->orderBy('t.string2','ASC');
|
$query->orderBy('t.string2','ASC');
|
||||||
$query->addOrderBy('t.order2','ASC');
|
$query->addOrderBy('t.order2','ASC');
|
||||||
}
|
}
|
||||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',1);
|
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$d->id);
|
||||||
//if ($this->clen)
|
if ($clen)
|
||||||
// $query->andWhere('t.member LIKE :clen')->setParameter('clen','%'."".'%');
|
$query->andWhere('t.member LIKE :clen')->setParameter('clen','%'.$clen.'%');
|
||||||
|
|
||||||
return $query->getQuery()->getResult();
|
return $query->getQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,36 +70,25 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
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);
|
||||||
$result = $this->termFacade->findByString();
|
|
||||||
|
|
||||||
//$repo_query = "\\App\\Model\\Database\\Repository\\$query";
|
|
||||||
/*
|
|
||||||
if ($term) $this->term = $term;
|
|
||||||
if ($translation) $this->translation = $translation;
|
|
||||||
$this->slug = $this->translations[$translation]["slug"];
|
|
||||||
|
|
||||||
$query = new $repo_query($t->getDictionary(),$this->term,$t->getDirection());
|
|
||||||
|
|
||||||
if ($clen) $query->withClen($clen);
|
|
||||||
$result = $this->em->getTermRepository()->fetch($query)->setFetchJoinCollection(FALSE);
|
|
||||||
|
|
||||||
if ($paginate) {
|
if ($paginate) {
|
||||||
$this["paginator"]->setItemCount(count($result));
|
$this["paginator"]->setItemCount(500);
|
||||||
$result->applyPaginator($this['paginator']);
|
$offset = $this["paginator"]->getOffset();
|
||||||
$offset = $this['paginator']->getOffset();
|
|
||||||
$itemsPerPage = $this['paginator']->getItemsPerPage();
|
$itemsPerPage = $this['paginator']->getItemsPerPage();
|
||||||
}
|
}
|
||||||
*/
|
$q = $this->termFacade->findByString($term,$t->dictionary,$clen);
|
||||||
$t = $this->em->getTranslationRepository()->find($translation);
|
$q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage);
|
||||||
|
|
||||||
$this->template->translation = $t;
|
$this->template->translation = $t;
|
||||||
|
|
||||||
return $result;
|
return $q->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,6 +100,8 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
|
|
||||||
$paginator->ajax = false;
|
$paginator->ajax = false;
|
||||||
$paginator->canSetItemsPerPage = true;
|
$paginator->canSetItemsPerPage = true;
|
||||||
|
$paginator->setItemsPerPage(100);
|
||||||
|
|
||||||
//$paginator->templateFile = __DIR__ . '/my_awesome_template.latte';
|
//$paginator->templateFile = __DIR__ . '/my_awesome_template.latte';
|
||||||
|
|
||||||
return $paginator;
|
return $paginator;
|
||||||
@@ -131,7 +122,7 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user