|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CWP\CWP\PageTypes; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\ORM\DataList; |
|
6
|
|
|
use SilverStripe\ORM\PaginatedList; |
|
7
|
|
|
|
|
8
|
|
|
class NewsHolder extends DatedUpdateHolder |
|
9
|
|
|
{ |
|
10
|
|
|
private static $description = 'Container page for News Pages, provides news filtering and pagination'; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
private static $allowed_children = [ |
|
|
|
|
|
|
13
|
|
|
NewsPage::class, |
|
14
|
|
|
]; |
|
15
|
|
|
|
|
16
|
|
|
private static $default_child = NewsPage::class; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
private static $update_name = 'News'; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
private static $update_class = NewsPage::class; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
private static $icon_class = 'font-icon-news'; |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
private static $singular_name = 'News Holder'; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
private static $plural_name = 'News Holders'; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
private static $table_name = 'NewsHolder'; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Find all site's news items, based on some filters. |
|
32
|
|
|
* Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $className The name of the class to fetch. |
|
35
|
|
|
* @param int $parentID The ID of the holder to extract the news items from. |
|
36
|
|
|
* @param int $tagID The ID of the tag to filter the news items by. |
|
37
|
|
|
* @param string $dateFrom The beginning of a date filter range. |
|
38
|
|
|
* @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
39
|
|
|
* @param int $year Numeric value of the year to show. |
|
40
|
|
|
* @param int $monthNumber Numeric value of the month to show. |
|
41
|
|
|
* |
|
42
|
|
|
* @returns DataList|PaginatedList |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function AllUpdates( |
|
45
|
|
|
$className = NewsPage::class, |
|
46
|
|
|
$parentID = null, |
|
47
|
|
|
$tagID = null, |
|
48
|
|
|
$dateFrom = null, |
|
49
|
|
|
$dateTo = null, |
|
50
|
|
|
$year = null, |
|
51
|
|
|
$monthNumber = null |
|
52
|
|
|
) { |
|
53
|
|
|
return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber) |
|
54
|
|
|
->Sort('Date', 'DESC'); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|