1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
public function executeIndex(sfWebRequest $request)
{
$this->filters = new ArticleFormFilter($this->getFilters());
$this->articles = $this->buildQuery(Doctrine::getTable('article')
->getSortedArticles());
}
public function executeFilter(sfWebRequest $request)
{
// RESET
if ($request->hasParameter('_reset'))
{
$this->setFilters(array()); //reset, filtre vide
$this->forward('article','index');
}
$this->filters = new ArticleFormFilter($this->getFilters());
$this->filters->bind($request->getParameter($this->filters->getName()));
if ($this->filters->isValid())
{
$this->setFilters($this->filters->getValues());
$this->forward('article','index');
}
$this->setTemplate('index');
}
protected function getFilters()
{
return $this->getUser()->getAttribute('article.filters', array());
}
protected function setFilters(array $filters)
{
return $this->getUser()->setAttribute('article.filters', $filters, 'front_module');
}
protected function buildQuery($q)
{
if(!isset($this->filters))
$this->filters = $this->getFilters();
$this->filters->setQuery($q);
$query = $this->filters->buildQuery($this->getFilters());
return $query->execute();
} |
Partager