|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class NewsHolder extends DatedUpdateHolder { |
|
4
|
|
|
|
|
5
|
|
|
private static $description = 'Container page for News Pages, provides news filtering and pagination'; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
private static $allowed_children = array('NewsPage'); |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
private static $default_child = 'NewsPage'; |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
private static $update_name = 'News'; |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
private static $update_class = 'NewsPage'; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
private static $icon = 'cwp/images/icons/sitetree_images/news_listing.png'; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
public $pageIcon = 'images/icons/sitetree_images/news_listing.png'; |
|
18
|
|
|
|
|
19
|
|
|
private static $singular_name = 'News Holder'; |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
private static $plural_name = 'News Holders'; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Find all site's news items, based on some filters. |
|
25
|
|
|
* Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
|
|
|
|
|
26
|
|
|
* |
|
27
|
|
|
* @param $className The name of the class to fetch. |
|
28
|
|
|
* @param $parentID The ID of the holder to extract the news items from. |
|
29
|
|
|
* @param $tagID The ID of the tag to filter the news items by. |
|
30
|
|
|
* @param $dateFrom The beginning of a date filter range. |
|
31
|
|
|
* @param $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
32
|
|
|
* @param $year Numeric value of the year to show. |
|
33
|
|
|
* @param $monthNumber Numeric value of the month to show. |
|
34
|
|
|
* |
|
35
|
|
|
* @returns DataList | PaginatedList |
|
36
|
|
|
*/ |
|
37
|
|
|
public static function AllUpdates($className = 'NewsPage', $parentID = null, $tagID = null, $dateFrom = null, |
|
38
|
|
|
$dateTo = null, $year = null, $monthNumber = null) { |
|
39
|
|
|
|
|
40
|
|
|
return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)->Sort('Date', 'DESC'); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
class NewsHolder_Controller extends DatedUpdateHolder_Controller { |
|
45
|
|
|
private static $allowed_actions = array( |
|
|
|
|
|
|
46
|
|
|
'rss', |
|
47
|
|
|
'atom' |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
public function rss() { |
|
51
|
|
|
$rss = new RSSFeed( |
|
52
|
|
|
$this->Updates()->sort('Created DESC')->limit(20), |
|
53
|
|
|
$this->Link('rss'), |
|
54
|
|
|
$this->getSubscriptionTitle() |
|
55
|
|
|
); |
|
56
|
|
|
$rss->setTemplate('NewsHolder_rss'); |
|
57
|
|
|
return $rss->outputToBrowser(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function atom() { |
|
61
|
|
|
$atom = new CwpAtomFeed( |
|
62
|
|
|
$this->Updates()->sort('Created DESC')->limit(20), |
|
63
|
|
|
$this->Link('atom'), |
|
64
|
|
|
$this->getSubscriptionTitle() |
|
65
|
|
|
); |
|
66
|
|
|
$atom->setTemplate('NewsHolder_atom'); |
|
67
|
|
|
return $atom->outputToBrowser(); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|