-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathVideoGroup.php
95 lines (87 loc) · 2.11 KB
/
VideoGroup.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Dynamic\HTML5Video\Pages;
use Page;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataList;
/**
* Class VideoGroup
* @package Dynamic\HTML5Video\Pages
*/
class VideoGroup extends Page
{
/**
* @var bool
*/
protected static $include_child_groups = true;
/**
* @var array
*/
private static $allowed_children = [
VideoGroup::class,
Video::class,
];
/**
* @var int
*/
private static $page_length = 12;
/**
* @var string
*/
private static $pagination_get_var = 's';
/**
* @var string
*/
private static $description = 'Videos Landing Page';
/**
* @var string
*/
private static $table_name = 'VideoGroup';
/**
* Method that returns a DataList of all
* Video pages in the current VideoGroup
* and all child VideoGroup pages.
* Note: this isn't recursive through child
* VideoGroup pages of the current VideoGroup
* page.
*
* @access public
* @param bool $all
*
* @return DataList
*/
public function getVideoList($all = false)
{
$groupIDS = $this->getVideoGroupIDS($all);
$groupIDS[] = $this->ID;
return Video::get()->filter('ParentID', $groupIDS);
}
/**
* Method that returns an array of ID's
* of the VideoGroup pages beneath the current one
*
* @access public
* @param bool $all
*
* @return array
*/
public function getVideoGroupIDs($all = false)
{
return $this->getChildGroups($all)->column('ID');
}
/**
* Method that returns child VideoGroup pages.
* By default it only shows those with ShowInMenus
* set to true, but can be overridden to show all
* VideoGroup children regardless of ShowInMenus.
*
* @param bool $all
*
* @return ArrayList|DataList
*/
public function getChildGroups($all = false)
{
return ($all === false)
? $this->Children()->filter('ClassName', VideoGroup::class)
: $this->AllChildren()->filter('ClassName', VideoGroup::class);
}
}