Skip to content

Commit

Permalink
fixes date filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
eshiol committed Oct 10, 2017
1 parent b13c4e1 commit 6ade43a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
20 changes: 14 additions & 6 deletions components/com_content/models/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ protected function populateState($ordering = 'ordering', $direction = 'ASC')
}

$this->setState('layout', $app->input->getString('layout'));

$this->setState('filter.date_filtering', $app->input->getString('date_filtering'));
$this->setState('filter.date_field', $app->input->getString('date_field'));
$this->setState('filter.start_date_range', $app->input->getString('start_date_range'));
$this->setState('filter.end_date_range', $app->input->getString('end_date_range'));
$this->setState('filter.relative_date', $app->input->getInt('relative_date'));
}

/**
Expand Down Expand Up @@ -450,12 +456,14 @@ protected function getListQuery()
switch ($dateFiltering)
{
case 'range':
$startDateRange = $db->quote($this->getState('filter.start_date_range', $nullDate));
$endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate));
$query->where(
'(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField .
' <= ' . $endDateRange . ')'
);
if ($startDateRange = $this->getState('filter.start_date_range'))
{
$query->where($dateField . ' >= ' . $db->quote($startDateRange));
}
if ($endDateRange = $this->getState('filter.end_date_range'))
{
$query->where($dateField . ' <= ' . $db->quote($endDateRange));
}
break;

case 'relative':
Expand Down
11 changes: 11 additions & 0 deletions components/com_content/models/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ protected function populateState($ordering = null, $direction = null)

// Set the featured articles state
$this->setState('filter.featured', $params->get('show_featured'));

$this->setState('filter.date_filtering', $app->input->getString('date_filtering'));
$this->setState('filter.date_field', $app->input->getString('date_field'));
$this->setState('filter.start_date_range', $app->input->getString('start_date_range'));
$this->setState('filter.end_date_range', $app->input->getString('end_date_range'));
$this->setState('filter.relative_date', $app->input->getInt('relative_date'));
}

/**
Expand Down Expand Up @@ -242,6 +248,11 @@ public function getItems()
$model->setState('list.direction', $this->getState('list.direction'));
$model->setState('list.filter', $this->getState('list.filter'));
$model->setState('filter.tag', $this->getState('filter.tag'));
$model->setState('filter.date_filtering', $this->getState('filter.date_filtering'));
$model->setState('filter.date_field', $this->getState('filter.date_field'));
$model->setState('filter.start_date_range', $this->getState('filter.start_date_range'));
$model->setState('filter.end_date_range', $this->getState('filter.end_date_range'));
$model->setState('filter.relative_date', $this->getState('filter.relative_date'));

// Filter.subcategories indicates whether to include articles from subcategories in the list or blog
$model->setState('filter.subcategories', $this->getState('filter.subcategories'));
Expand Down

0 comments on commit 6ade43a

Please sign in to comment.