Skip to content

Commit

Permalink
Merge pull request #358 from hbaptiste/357
Browse files Browse the repository at this point in the history
Handling search by title and date in MediaRepository
  • Loading branch information
eric-chau committed May 7, 2015
2 parents b7304c2 + 63c1025 commit f8ac165
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions NestedNode/Repository/MediaRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,17 @@ public function getMedias(\BackBee\NestedNode\MediaFolder $mediafolder, $cond, $
if (null !== $searchField) {
$q->andWhere($q->expr()->like('mc._label', $q->expr()->literal('%'.$searchField.'%')));
}

$title = (isset($cond["mediaTitle"])) ? $cond["mediaTitle"] : null;
if (null !== $title) {
$q->andWhere($q->expr()->like('m._title', $q->expr()->literal('%'.$title.'%')));
}

$afterPubdateField = (isset($cond['afterPubdateField'])) ? $cond['afterPubdateField'] : null;
$afterPubdateField = (isset($cond['afterPubdateField']) && !empty($cond['afterPubdateField'])) ? $cond['afterPubdateField'] : null;
if (null !== $afterPubdateField) {
$q->andWhere('mc._modified > :afterPubdateField')->setParameter('afterPubdateField', date('Y/m/d', $afterPubdateField));
}

$beforePubdateField = (isset($cond['beforePubdateField'])) ? $cond['beforePubdateField'] : null;
$beforePubdateField = (isset($cond['beforePubdateField']) && !empty($cond['beforePubdateField'])) ? $cond['beforePubdateField'] : null;
if (null !== $beforePubdateField) {
$q->andWhere('mc._modified < :beforePubdateField')->setParameter('beforePubdateField', date('Y/m/d', $beforePubdateField));
}
Expand Down

0 comments on commit f8ac165

Please sign in to comment.