-
Notifications
You must be signed in to change notification settings - Fork 333
/
RecentlyEditedReport.php
46 lines (38 loc) · 1.1 KB
/
RecentlyEditedReport.php
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
<?php
namespace SilverStripe\CMS\Reports;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\DataObject;
use SilverStripe\Reports\Report;
class RecentlyEditedReport extends Report
{
public function title()
{
return _t(__CLASS__.'.LAST2WEEKS', "Pages edited in the last 2 weeks");
}
public function group()
{
return _t(__CLASS__.'.ContentGroupTitle', "Content reports");
}
public function sort()
{
return 200;
}
public function sourceRecords($params = null)
{
$tableName = DataObject::singleton(SiteTree::class)->baseTable();
$threshold = strtotime('-14 days', DBDatetime::now()->getTimestamp());
return SiteTree::get()
->filter('LastEdited:GreaterThan', date("Y-m-d H:i:s", $threshold))
->orderBy("\"$tableName\".\"LastEdited\" DESC");
}
public function columns()
{
return [
"Title" => [
"title" => "Title", // todo: use NestedTitle(2)
"link" => true,
],
];
}
}