1 <?php
2 class LastDoc_Controller extends ContentController {
3
4 static $dayCount = 30;
5 static $pageLimit = 10;
6
7 public static function DayCount($val = false) {
8 $val = (int) $val;
9 if ($val)
10 LastDoc_Controller::$dayCount = $val;
11 return LastDoc_Controller::$dayCount;
12 }
13
14 public static function PageLimit($val = false) {
15 $val = (int) $val;
16 if ($val)
17 LastDoc_Controller::$pageLimit = $val;
18 return LastDoc_Controller::$pageLimit;
19 }
20
21 function RelativeLink($action = null) {
22 return "lastdoc/$action";
23 }
24
25 function index() {
26 return $this->renderWith(array('LastDoc','Page'));
27 }
28
29
30 function LastDoc($limit = false) {
31 $start = (isset($_GET['start']) && $_GET['start'] > 0) ? (int) $_GET['start'] : 0;
32
33 $limit = ($limit) ? (int) $limit : LastDoc_Controller::$pageLimit;
34 $limit = ($limit > 0) ? $limit : 10;
35
36 $ds = DataObject::get(
37 'Page',
38 "(`ShowInSearch` = 1) and (`ClassName` != 'HomePage') and (`LastEdited` >= DATE_SUB(NOW(), interval ".LastDoc_Controller::$dayCount." day))",
39 'LastEdited DESC',
40 null,
41 "$start,$limit"
42 );
43
44 foreach ($ds->toArray() as $item) {
45 if (preg_match('/(Anons.*|Holder|Form)$/',$item->ClassName,$m))
46 $ds->remove($item);
47
48 }
49
50 return $ds;
51
52 }
53
54 function getClassName() {
55 return 'LastDoc';
56 }
57 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-