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\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $text
|
||||
*/
|
||||
class Suffix extends AbstractEntity
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Model\Database\Entity\Attributes\TId;
|
||||
* @ORM\Table(name="`translation`")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property Dictionary $dictionary
|
||||
* @property Language $lang1
|
||||
* @property Language $lang2
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Model\Database\Facade;
|
||||
|
||||
use App\Model\Database\Entity\Dictionary;
|
||||
use App\Model\Database\Entity\Term;
|
||||
use App\Model\Database\Entity\Translation;
|
||||
use App\Model\Database\EntityManager;
|
||||
|
||||
|
||||
@@ -27,7 +29,7 @@ class TermFacade
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function findByString()
|
||||
public function findByString(String $term,Dictionary $d,String $clen = null)
|
||||
{
|
||||
$query = $this->em->createQueryBuilder('t')->select('t')
|
||||
->addSelect('s1')
|
||||
@@ -36,18 +38,18 @@ class TermFacade
|
||||
->leftJoin('t.suffix1','s1')
|
||||
->leftJoin('t.suffix2','s2');
|
||||
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');
|
||||
} 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->addOrderBy('t.order2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',1);
|
||||
//if ($this->clen)
|
||||
// $query->andWhere('t.member LIKE :clen')->setParameter('clen','%'."".'%');
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$d->id);
|
||||
if ($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)
|
||||
{
|
||||
$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);
|
||||
$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) {
|
||||
$this["paginator"]->setItemCount(count($result));
|
||||
$result->applyPaginator($this['paginator']);
|
||||
$offset = $this['paginator']->getOffset();
|
||||
$this["paginator"]->setItemCount(500);
|
||||
$offset = $this["paginator"]->getOffset();
|
||||
$itemsPerPage = $this['paginator']->getItemsPerPage();
|
||||
}
|
||||
*/
|
||||
$t = $this->em->getTranslationRepository()->find($translation);
|
||||
$q = $this->termFacade->findByString($term,$t->dictionary,$clen);
|
||||
$q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage);
|
||||
|
||||
$this->template->translation = $t;
|
||||
|
||||
return $result;
|
||||
return $q->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +100,8 @@ final class HomePresenter extends BaseFrontPresenter
|
||||
|
||||
$paginator->ajax = false;
|
||||
$paginator->canSetItemsPerPage = true;
|
||||
$paginator->setItemsPerPage(100);
|
||||
|
||||
//$paginator->templateFile = __DIR__ . '/my_awesome_template.latte';
|
||||
|
||||
return $paginator;
|
||||
@@ -131,7 +122,7 @@ final class HomePresenter extends BaseFrontPresenter
|
||||
|
||||
public function searchFormSucceeded(UI\Form $form,$values)
|
||||
{
|
||||
$translation = $values->translation;
|
||||
$translation = $values->translation;
|
||||
$clen = $values->clen;
|
||||
$term = $values->string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user