Permalink
Browse files

Merge pull request #46 from arambalakjian/3.1

3.1
  • Loading branch information...
2 parents 84283a5 + 6500206 commit ddd904b2e9752f1a139738835d045541b82738f2 Aram Balakjian committed Dec 30, 2013
Showing with 10 additions and 17 deletions.
  1. +7 −14 code/Pages/DataObjectAsPageHolder.php
  2. +3 −3 composer.json
@@ -31,19 +31,13 @@ public function getSettingsFields()
/*
* Get Items which are to be displayed on this listing page
*/
- public function FetchItems($itemClass, $filter = '', $sort = Null, $joins = Null, $limit = Null)
+ public function FetchItems($itemClass, $filter = null, $sort = Null, $limit = Null)
{
- $results = $itemClass::get()->where($filter);
+ $results = $itemClass::get();
- if($joins)
+ if($filter)
{
- foreach($joins as $type => $join)
- {
- if($results->hasMethod($type))
- {
- $results = $results->$type($table, $join);
- }
- }
+ $results = $results->filter($filter);
}
if($sort)
@@ -101,7 +95,7 @@ class DataObjectAsPageHolder_Controller extends Page_Controller
private static $item_class = 'DataObjectAsPage';
private static $item_sort = 'Created DESC';
- public static $allowed_actions = array(
+ private static $allowed_actions = array(
'show'
);
@@ -112,13 +106,12 @@ public function Items($limit = null)
{
//Set custom filter
$where = ($this->hasMethod('getItemsWhere')) ? $this->getItemsWhere() : Null;
+
//Set custom sort
$sort = ($this->hasMethod('getItemsSort')) ? $this->getItemsSort() : $this->stat('item_sort');
- //Set custom join
- $join = ($this->hasMethod('getItemsJoin')) ? $this->getItemsJoin() : Null;
//QUERY
- $items = $this->FetchItems($this->Stat('item_class'), $where, $sort, $join, $limit);
+ $items = $this->FetchItems($this->Stat('item_class'), $where, $sort, $limit);
//Paginate the list
if(!$limit && $this->Paginate)
View
@@ -7,12 +7,12 @@
"authors": [
{
"name": "Aram Balakjian",
- "email": "aram@aabweb.co.uk"
+ "email": "aram@carboncrayon.com"
}
],
"require":
{
- "silverstripe/framework": "3.*",
- "silverstripe/cms": "3.*"
+ "silverstripe/framework": "3.1.*",
+ "silverstripe/cms": "3.1.*"
}
}

0 comments on commit ddd904b

Please sign in to comment.