Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
MAJOR, reversing the "from" filter logic.
Browse files Browse the repository at this point in the history
This is because the current implementation didn't make sense from
a user's perspective.
  • Loading branch information
Nathan Glasl committed Oct 16, 2017
1 parent 6a1affe commit 460d4bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [mediawesome](https://packagist.org/packages/nglasl/silverstripe-mediawesome)

_The current release is **2.0.7**_
_The current release is **3.0.0**_

> A module for SilverStripe which will allow creation of dynamic media holders/pages with CMS customisable types and attributes (blogs, events, news, publications).
Expand Down
23 changes: 11 additions & 12 deletions code/pages/MediaHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,19 @@ public function getPaginatedChildren($limit = 5, $sort = 'Date', $order = 'DESC'
}
}
if($valid) {

// This is used to determine the direction to filter, so it makes sense from a user's perspective.

if($order === 'DESC') {
$date[count($date) - 1]++;
$direction = '<';
}
else {
$direction = '>=';
}
$from = implode('-', $date);
$children = $children->where(array(
'Date >= ?' => $from
"Date {$direction} ?" => $from
));
}
}
Expand Down Expand Up @@ -552,17 +562,6 @@ public function getDateFilterForm() {
$request = $this->getRequest();
$form->loadDataFrom($request->getVars());

// Validate the date request filter, as this isn't captured on page request.

if($from = $request->getVar('from')) {
foreach(explode('-', $from) as $segment) {
if(!is_numeric($segment)) {
$date->setValue(null);
break;
}
}
}

// Remove validation if clear has been triggered.

if($request->getVar('action_clearFilters')) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"extra": {
"installer-name": "mediawesome",
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
},
"screenshots": [
"https://raw.githubusercontent.com/nglasl/silverstripe-mediawesome/master/images/mediawesome-types.png"
Expand Down

0 comments on commit 460d4bf

Please sign in to comment.