예제 #1
0
파일: Log.php 프로젝트: jacksleight/chalk
 public function build(array $params = array())
 {
     $query = parent::build($params);
     $params = $params + ['entity' => null];
     if (isset($params['entity'])) {
         $query->andWhere("l.entity = :entity AND l.entityId = :entityId")->setParameter('entity', Chalk::info($entity)->name)->setParameter('entityId', $entity->id);
     }
     return $query;
 }
예제 #2
0
파일: User.php 프로젝트: jacksleight/chalk
 public function build(array $params = array())
 {
     $query = parent::build($params);
     $params = $params + ['emailAddress' => null, 'token' => null];
     if (isset($params['emailAddress'])) {
         $query->andWhere("u.emailAddress = :emailAddress")->setParameter('emailAddress', $params['emailAddress']);
     }
     if (isset($params['token'])) {
         $query->andWhere("u.token = :token AND u.tokenDate > UTC_TIMESTAMP()")->setParameter('token', $params['token']);
     }
     $this->searchable_modify($query, $params);
     return $query;
 }
예제 #3
0
파일: Node.php 프로젝트: jacksleight/chalk
 public function build(array $params = array())
 {
     $query = parent::build($params);
     $params = $params + ['structure' => null, 'children' => null, 'parents' => null, 'siblings' => null, 'depth' => null, 'isIncluded' => false, 'isVisible' => Chalk::isFrontend()];
     $query->addSelect("c")->leftJoin("n.content", "c");
     $depth = null;
     if (isset($params['structure'])) {
         $query->andWhere('n.structure = :structure')->setParameter('structure', $params['structure']);
     } else {
         if (isset($params['children'])) {
             $query->andWhere('n.structure = :structure AND n.left >= :left AND n.right <= :right')->setParameter('structure', $params['children']['structureId'])->setParameter('left', $params['children']['left'])->setParameter('right', $params['children']['right']);
             if (isset($params['depth'])) {
                 $query->andWhere('n.depth <= :depth')->setParameter('depth', $params['children']['depth'] + $params['depth']);
             }
             if (!$params['isIncluded']) {
                 $query->andWhere('n != :exclude')->setParameter('exclude', $params['children']['id']);
             }
         } else {
             if (isset($params['parents'])) {
                 $query->from($this->_entityName, 'nt')->andWhere('n.structure = :structure AND nt.left >= n.left AND nt.left <= n.right')->andWhere('nt = :node')->setParameter('structure', $params['parents']['structureId'])->setParameter('node', $params['parents']['id']);
                 if (isset($params['depth'])) {
                     $query->andWhere('n.depth >= :depth')->setParameter('depth', $params['parents']['depth'] - $params['depth']);
                 }
                 if (!$params['isIncluded']) {
                     $query->andWhere('n != :exclude')->setParameter('exclude', $params['parents']['id']);
                 }
             } else {
                 if (isset($params['siblings'])) {
                     $query->andWhere('n.parent = :parent')->setParameter('parent', $params['siblings']['parentId']);
                     if (!$params['isIncluded']) {
                         $query->andWhere('n != :exclude')->setParameter('exclude', $params['siblings']['id']);
                     }
                 }
             }
         }
     }
     if ($params['isVisible']) {
         $query->andWhere("n.isHidden = false");
     }
     $this->publishable_modify($query, $params, 'c');
     return $query;
 }
예제 #4
0
 public function build(array $params = array())
 {
     $query = parent::build($params);
     $params = $params + ['types' => null, 'subtypes' => null, 'tags' => null, 'createDateMin' => null, 'createDateMax' => null, 'modifyDateMin' => null, 'modifyDateMax' => null, 'createUsers' => null, 'statuses' => null];
     if (isset($params['types']) && count($params['types'])) {
         if ($params['types'] instanceof InfoList) {
             $types = [];
             foreach ($params['types'] as $filter) {
                 $types[$filter->class] = $filter->subtypes;
             }
         } else {
             $types = $params['types'];
         }
         $all = [];
         foreach ($types as $class => $subtypes) {
             $info = Chalk::info($class);
             $classes = array_merge([$info->class], $this->_em->getClassMetadata($info->class)->subClasses);
             foreach ($classes as $class) {
                 $all[$class] = $subtypes;
             }
         }
         $lines = [];
         $i = 0;
         foreach ($all as $class => $subtypes) {
             $line = "{$this->alias()} INSTANCE OF {$class}";
             if (isset($subtypes) && count($subtypes)) {
                 $line .= " AND {$this->alias()}.subtype IN (:types_{$i}_subtypes)";
                 $query->setParameter("types_{$i}_subtypes", $subtypes);
             }
             $lines[] = "({$line})";
             $i++;
         }
         $query->andWhere(implode(' OR ', $lines));
     }
     if (isset($params['subtypes']) && count($params['subtypes'])) {
         $query->andWhere("{$this->alias()}.subtype IN (:subtypes)")->setParameter('subtypes', $params['subtypes']);
     }
     if (isset($params['tags']) && count($params['tags'])) {
         $query->andWhere(":tags MEMBER OF {$this->alias()}.tags")->setParameter('tags', $params['tags']);
     }
     if (isset($params['createDateMin'])) {
         $createDateMin = $params['createDateMin'] instanceof DateTime ? $params['createDateMin'] : new DateTime($params['createDateMin']);
         $query->andWhere("{$this->alias()}.createDate >= :createDateMin")->setParameter('createDateMin', $createDateMin);
     }
     if (isset($params['createDateMax'])) {
         $createDateMax = $params['createDateMax'] instanceof DateTime ? $params['createDateMax'] : new DateTime($params['createDateMax']);
         $query->andWhere("{$this->alias()}.createDate <= :createDateMax")->setParameter('createDateMax', $createDateMax);
     }
     if (isset($params['modifyDateMin'])) {
         $modifyDateMin = $params['modifyDateMin'] instanceof DateTime ? $params['modifyDateMin'] : new DateTime($params['modifyDateMin']);
         $query->andWhere("{$this->alias()}.modifyDate >= :modifyDateMin")->setParameter('modifyDateMin', $modifyDateMin);
     }
     if (isset($params['modifyDateMax'])) {
         $modifyDateMax = $params['modifyDateMax'] instanceof DateTime ? $params['modifyDateMax'] : new DateTime($params['modifyDateMax']);
         $query->andWhere("{$this->alias()}.modifyDate <= :modifyDateMax")->setParameter('modifyDateMax', $modifyDateMax);
     }
     if (isset($params['createUsers'])) {
         $query->andWhere("{$this->alias()}.createUser IN (:createUsers)")->setParameter('createUsers', $params['createUsers']);
     }
     if (isset($params['statuses']) && count($params['statuses'])) {
         $query->andWhere("{$this->alias()}.status IN (:statuses)")->setParameter('statuses', $params['statuses']);
     }
     $query->addSelect("{$this->alias()}_tags")->leftJoin("{$this->alias()}.tags", "{$this->alias()}_tags");
     $this->publishable_modify($query, $params);
     $this->searchable_modify($query, $params);
     return $query;
 }
예제 #5
0
파일: Tag.php 프로젝트: jacksleight/chalk
 public function build(array $params = array())
 {
     $query = parent::build($params);
     $this->searchable_modify($query, $params);
     return $query;
 }
예제 #6
0
 public function build(array $params = array())
 {
     $query = parent::build($params);
     $query->addSelect("n", "c")->leftJoin("s.nodes", "n", "WITH", "n.left = 0")->leftJoin("n.content", "c");
     return $query;
 }