@@ -9,163 +9,163 @@ |
||
9 | 9 | class ScheduledShow |
10 | 10 | { |
11 | 11 | |
12 | - protected $show; |
|
13 | - protected $dj; |
|
14 | - protected $startingHour; |
|
15 | - protected $endingHour; |
|
16 | - protected $id; |
|
17 | - protected $dayOfWeek; |
|
18 | - |
|
19 | - public static function fromShowAndDJ($show, $dj) |
|
20 | - { |
|
21 | - $scheduledShow = new ScheduledShow(); |
|
22 | - |
|
23 | - $scheduledShow->show = $show; |
|
24 | - $scheduledShow->dj = $dj; |
|
25 | - |
|
26 | - return $scheduledShow; |
|
27 | - } |
|
28 | - |
|
29 | - public function dj() |
|
30 | - { |
|
31 | - return $this->dj->name; |
|
32 | - } |
|
33 | - |
|
34 | - public function djId() |
|
35 | - { |
|
36 | - return $this->dj->id; |
|
37 | - } |
|
38 | - |
|
39 | - public function show() |
|
40 | - { |
|
41 | - return $this->show->name; |
|
42 | - } |
|
43 | - |
|
44 | - public function showId() |
|
45 | - { |
|
46 | - return $this->show->id; |
|
47 | - } |
|
48 | - |
|
49 | - public function djPicture() |
|
50 | - { |
|
51 | - return $this->dj->picture; |
|
52 | - } |
|
53 | - |
|
54 | - public function showPicture() |
|
55 | - { |
|
56 | - return $this->show->show_picture; |
|
57 | - } |
|
58 | - |
|
59 | - public function sliderPicture() |
|
60 | - { |
|
61 | - return $this->show->slider_picture; |
|
62 | - } |
|
63 | - |
|
64 | - public function sliderStyle() |
|
65 | - { |
|
66 | - return $this->show->style; |
|
67 | - } |
|
68 | - |
|
69 | - public function startsAt($startingHour) |
|
70 | - { |
|
71 | - $this->startingHour = $startingHour; |
|
72 | - $this->endingHour = $startingHour; |
|
73 | - $this->extendShowByHour(); |
|
74 | - } |
|
75 | - |
|
76 | - public function start() |
|
77 | - { |
|
78 | - return $this->startingHour; |
|
79 | - } |
|
80 | - |
|
81 | - public function end() |
|
82 | - { |
|
83 | - return $this->endingHour; |
|
84 | - } |
|
85 | - |
|
86 | - public function extendShowByHour() |
|
87 | - { |
|
88 | - $this->endingHour++; |
|
89 | - } |
|
90 | - |
|
91 | - public function timespan() |
|
92 | - { |
|
93 | - $suffix = $this->endingHour < 12 || $this->endingHour > 24 ? 'AM' : 'PM'; |
|
94 | - $endingHour = $this->hourAdjusted($this->endingHour); |
|
95 | - $startingHour = $this->hourAdjusted($this->startingHour); |
|
96 | - return $startingHour . ' - ' . $endingHour . ' ' . $suffix; |
|
97 | - } |
|
98 | - |
|
99 | - private function hourAdjusted($hour) |
|
100 | - { |
|
101 | - while ($hour > 12) { |
|
102 | - $hour -= 12; |
|
103 | - } |
|
104 | - return $hour; |
|
105 | - } |
|
106 | - |
|
107 | - public function airsDayOfWeek($airsDayOfWeek) |
|
108 | - { |
|
109 | - $this->dayOfWeek = $airsDayOfWeek; |
|
110 | - } |
|
111 | - |
|
112 | - public function getAirDate() |
|
113 | - { |
|
114 | - return Weekday::display($this->dayOfWeek); |
|
115 | - } |
|
116 | - |
|
117 | - public function getRelativeAirDate() |
|
118 | - { |
|
119 | - $now = ScheduleTime::now(); |
|
120 | - if ($this->dayOfWeek == $now->dayOfWeek) |
|
121 | - { |
|
122 | - return 'Today'; |
|
123 | - } |
|
124 | - else if ($this->dayOfWeek == $now->addDay()->dayOfWeek) |
|
125 | - { |
|
126 | - return 'Tomorrow'; |
|
127 | - } |
|
128 | - else |
|
129 | - { |
|
130 | - return $this->getAirDate(); |
|
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - public function airDayOfWeek() |
|
136 | - { |
|
137 | - return $this->dayOfWeek; |
|
138 | - } |
|
139 | - |
|
140 | - public function showDescription() |
|
141 | - { |
|
142 | - return $this->show->description; |
|
143 | - } |
|
144 | - |
|
145 | - public function setId($id) |
|
146 | - { |
|
147 | - $this->id = $id; |
|
148 | - } |
|
149 | - |
|
150 | - public function id() |
|
151 | - { |
|
152 | - return $this->id; |
|
153 | - } |
|
154 | - |
|
155 | - public function nowPlaying() |
|
156 | - { |
|
157 | - $today = ScheduleTime::now(); |
|
158 | - |
|
159 | - if ($this->airDayOfWeek() != $today->dayOfWeek()) |
|
160 | - { |
|
161 | - return false; |
|
162 | - } |
|
163 | - |
|
164 | - if ($this->startingHour > $today->hour() || $this->endingHour <= $today->hour()) |
|
165 | - { |
|
166 | - return false; |
|
167 | - } |
|
168 | - |
|
169 | - return true; |
|
170 | - } |
|
12 | + protected $show; |
|
13 | + protected $dj; |
|
14 | + protected $startingHour; |
|
15 | + protected $endingHour; |
|
16 | + protected $id; |
|
17 | + protected $dayOfWeek; |
|
18 | + |
|
19 | + public static function fromShowAndDJ($show, $dj) |
|
20 | + { |
|
21 | + $scheduledShow = new ScheduledShow(); |
|
22 | + |
|
23 | + $scheduledShow->show = $show; |
|
24 | + $scheduledShow->dj = $dj; |
|
25 | + |
|
26 | + return $scheduledShow; |
|
27 | + } |
|
28 | + |
|
29 | + public function dj() |
|
30 | + { |
|
31 | + return $this->dj->name; |
|
32 | + } |
|
33 | + |
|
34 | + public function djId() |
|
35 | + { |
|
36 | + return $this->dj->id; |
|
37 | + } |
|
38 | + |
|
39 | + public function show() |
|
40 | + { |
|
41 | + return $this->show->name; |
|
42 | + } |
|
43 | + |
|
44 | + public function showId() |
|
45 | + { |
|
46 | + return $this->show->id; |
|
47 | + } |
|
48 | + |
|
49 | + public function djPicture() |
|
50 | + { |
|
51 | + return $this->dj->picture; |
|
52 | + } |
|
53 | + |
|
54 | + public function showPicture() |
|
55 | + { |
|
56 | + return $this->show->show_picture; |
|
57 | + } |
|
58 | + |
|
59 | + public function sliderPicture() |
|
60 | + { |
|
61 | + return $this->show->slider_picture; |
|
62 | + } |
|
63 | + |
|
64 | + public function sliderStyle() |
|
65 | + { |
|
66 | + return $this->show->style; |
|
67 | + } |
|
68 | + |
|
69 | + public function startsAt($startingHour) |
|
70 | + { |
|
71 | + $this->startingHour = $startingHour; |
|
72 | + $this->endingHour = $startingHour; |
|
73 | + $this->extendShowByHour(); |
|
74 | + } |
|
75 | + |
|
76 | + public function start() |
|
77 | + { |
|
78 | + return $this->startingHour; |
|
79 | + } |
|
80 | + |
|
81 | + public function end() |
|
82 | + { |
|
83 | + return $this->endingHour; |
|
84 | + } |
|
85 | + |
|
86 | + public function extendShowByHour() |
|
87 | + { |
|
88 | + $this->endingHour++; |
|
89 | + } |
|
90 | + |
|
91 | + public function timespan() |
|
92 | + { |
|
93 | + $suffix = $this->endingHour < 12 || $this->endingHour > 24 ? 'AM' : 'PM'; |
|
94 | + $endingHour = $this->hourAdjusted($this->endingHour); |
|
95 | + $startingHour = $this->hourAdjusted($this->startingHour); |
|
96 | + return $startingHour . ' - ' . $endingHour . ' ' . $suffix; |
|
97 | + } |
|
98 | + |
|
99 | + private function hourAdjusted($hour) |
|
100 | + { |
|
101 | + while ($hour > 12) { |
|
102 | + $hour -= 12; |
|
103 | + } |
|
104 | + return $hour; |
|
105 | + } |
|
106 | + |
|
107 | + public function airsDayOfWeek($airsDayOfWeek) |
|
108 | + { |
|
109 | + $this->dayOfWeek = $airsDayOfWeek; |
|
110 | + } |
|
111 | + |
|
112 | + public function getAirDate() |
|
113 | + { |
|
114 | + return Weekday::display($this->dayOfWeek); |
|
115 | + } |
|
116 | + |
|
117 | + public function getRelativeAirDate() |
|
118 | + { |
|
119 | + $now = ScheduleTime::now(); |
|
120 | + if ($this->dayOfWeek == $now->dayOfWeek) |
|
121 | + { |
|
122 | + return 'Today'; |
|
123 | + } |
|
124 | + else if ($this->dayOfWeek == $now->addDay()->dayOfWeek) |
|
125 | + { |
|
126 | + return 'Tomorrow'; |
|
127 | + } |
|
128 | + else |
|
129 | + { |
|
130 | + return $this->getAirDate(); |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + public function airDayOfWeek() |
|
136 | + { |
|
137 | + return $this->dayOfWeek; |
|
138 | + } |
|
139 | + |
|
140 | + public function showDescription() |
|
141 | + { |
|
142 | + return $this->show->description; |
|
143 | + } |
|
144 | + |
|
145 | + public function setId($id) |
|
146 | + { |
|
147 | + $this->id = $id; |
|
148 | + } |
|
149 | + |
|
150 | + public function id() |
|
151 | + { |
|
152 | + return $this->id; |
|
153 | + } |
|
154 | + |
|
155 | + public function nowPlaying() |
|
156 | + { |
|
157 | + $today = ScheduleTime::now(); |
|
158 | + |
|
159 | + if ($this->airDayOfWeek() != $today->dayOfWeek()) |
|
160 | + { |
|
161 | + return false; |
|
162 | + } |
|
163 | + |
|
164 | + if ($this->startingHour > $today->hour() || $this->endingHour <= $today->hour()) |
|
165 | + { |
|
166 | + return false; |
|
167 | + } |
|
168 | + |
|
169 | + return true; |
|
170 | + } |
|
171 | 171 | } |
@@ -4,25 +4,25 @@ |
||
4 | 4 | |
5 | 5 | abstract class Weekday { |
6 | 6 | const SUNDAY = 0; |
7 | - const MONDAY = 1; |
|
8 | - const TUESDAY = 2; |
|
9 | - const WEDNESDAY = 3; |
|
10 | - const THURSDAY = 4; |
|
11 | - const FRIDAY = 5; |
|
12 | - const SATURDAY = 6; |
|
7 | + const MONDAY = 1; |
|
8 | + const TUESDAY = 2; |
|
9 | + const WEDNESDAY = 3; |
|
10 | + const THURSDAY = 4; |
|
11 | + const FRIDAY = 5; |
|
12 | + const SATURDAY = 6; |
|
13 | 13 | |
14 | - protected static $days = [ |
|
15 | - Weekday::SUNDAY => 'Sunday', |
|
16 | - Weekday::MONDAY => 'Monday', |
|
17 | - Weekday::TUESDAY => 'Tuesday', |
|
18 | - Weekday::WEDNESDAY => 'Wednesday', |
|
19 | - Weekday::THURSDAY => 'Thursday', |
|
20 | - Weekday::FRIDAY => 'Friday', |
|
21 | - Weekday::SATURDAY => 'Saturday' |
|
22 | - ]; |
|
14 | + protected static $days = [ |
|
15 | + Weekday::SUNDAY => 'Sunday', |
|
16 | + Weekday::MONDAY => 'Monday', |
|
17 | + Weekday::TUESDAY => 'Tuesday', |
|
18 | + Weekday::WEDNESDAY => 'Wednesday', |
|
19 | + Weekday::THURSDAY => 'Thursday', |
|
20 | + Weekday::FRIDAY => 'Friday', |
|
21 | + Weekday::SATURDAY => 'Saturday' |
|
22 | + ]; |
|
23 | 23 | |
24 | - public static function display($weekday) |
|
25 | - { |
|
26 | - return static::$days[$weekday]; |
|
27 | - } |
|
24 | + public static function display($weekday) |
|
25 | + { |
|
26 | + return static::$days[$weekday]; |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | \ No newline at end of file |
@@ -7,90 +7,90 @@ |
||
7 | 7 | class WeeklySchedule extends Collection |
8 | 8 | { |
9 | 9 | |
10 | - public static function mergeFromTimeSlots(Collection $timeSlots) |
|
11 | - { |
|
12 | - $scheduledShows = new Collection(); |
|
13 | - $timeSlots = $timeSlots->reduce(function($scheduledShows, $timeslot) { |
|
14 | - $scheduledShow = $scheduledShows->last(); |
|
15 | - if (static::showContinuesIntoCurrentTimeslot($scheduledShow, $timeslot)) |
|
16 | - { |
|
17 | - $scheduledShow->extendShowByHour(); |
|
18 | - } |
|
19 | - else |
|
20 | - { |
|
21 | - $show = ScheduledShow::fromShowAndDJ($timeslot->showForTimeslot, $timeslot->djForTimeslot); |
|
22 | - $show->setId($timeslot->id); |
|
23 | - $show->startsAt($timeslot->hour); |
|
24 | - $show->airsDayOfWeek($timeslot->day); |
|
25 | - $scheduledShows->push($show); |
|
26 | - } |
|
27 | - return $scheduledShows; |
|
28 | - }, $scheduledShows); |
|
29 | - $weeklySchedule = new WeeklySchedule($timeSlots); |
|
10 | + public static function mergeFromTimeSlots(Collection $timeSlots) |
|
11 | + { |
|
12 | + $scheduledShows = new Collection(); |
|
13 | + $timeSlots = $timeSlots->reduce(function($scheduledShows, $timeslot) { |
|
14 | + $scheduledShow = $scheduledShows->last(); |
|
15 | + if (static::showContinuesIntoCurrentTimeslot($scheduledShow, $timeslot)) |
|
16 | + { |
|
17 | + $scheduledShow->extendShowByHour(); |
|
18 | + } |
|
19 | + else |
|
20 | + { |
|
21 | + $show = ScheduledShow::fromShowAndDJ($timeslot->showForTimeslot, $timeslot->djForTimeslot); |
|
22 | + $show->setId($timeslot->id); |
|
23 | + $show->startsAt($timeslot->hour); |
|
24 | + $show->airsDayOfWeek($timeslot->day); |
|
25 | + $scheduledShows->push($show); |
|
26 | + } |
|
27 | + return $scheduledShows; |
|
28 | + }, $scheduledShows); |
|
29 | + $weeklySchedule = new WeeklySchedule($timeSlots); |
|
30 | 30 | |
31 | - return $weeklySchedule; |
|
32 | - } |
|
31 | + return $weeklySchedule; |
|
32 | + } |
|
33 | 33 | |
34 | - public static function fromTimeSlots(Collection $timeSlots) |
|
35 | - { |
|
36 | - $timeSlots = $timeSlots->map(function($timeslot) { |
|
37 | - $show = ScheduledShow::fromShowAndDJ($timeslot->showForTimeslot, $timeslot->djForTimeslot); |
|
38 | - $show->setId($timeslot->id); |
|
39 | - $show->startsAt($timeslot->hour); |
|
40 | - $show->airsDayOfWeek($timeslot->day); |
|
41 | - return $show; |
|
42 | - }); |
|
34 | + public static function fromTimeSlots(Collection $timeSlots) |
|
35 | + { |
|
36 | + $timeSlots = $timeSlots->map(function($timeslot) { |
|
37 | + $show = ScheduledShow::fromShowAndDJ($timeslot->showForTimeslot, $timeslot->djForTimeslot); |
|
38 | + $show->setId($timeslot->id); |
|
39 | + $show->startsAt($timeslot->hour); |
|
40 | + $show->airsDayOfWeek($timeslot->day); |
|
41 | + return $show; |
|
42 | + }); |
|
43 | 43 | |
44 | - return new WeeklySchedule($timeSlots); |
|
45 | - } |
|
44 | + return new WeeklySchedule($timeSlots); |
|
45 | + } |
|
46 | 46 | |
47 | - private static function showContinuesIntoCurrentTimeslot($scheduledShow, $timeslot) |
|
48 | - { |
|
49 | - return $scheduledShow != null |
|
50 | - && $scheduledShow->djId() == $timeslot->djForTimeslot->id |
|
51 | - && $scheduledShow->showId() == $timeslot->showForTimeslot->id |
|
52 | - && $scheduledShow->airDayOfWeek() == $timeslot->day; |
|
53 | - } |
|
47 | + private static function showContinuesIntoCurrentTimeslot($scheduledShow, $timeslot) |
|
48 | + { |
|
49 | + return $scheduledShow != null |
|
50 | + && $scheduledShow->djId() == $timeslot->djForTimeslot->id |
|
51 | + && $scheduledShow->showId() == $timeslot->showForTimeslot->id |
|
52 | + && $scheduledShow->airDayOfWeek() == $timeslot->day; |
|
53 | + } |
|
54 | 54 | |
55 | - public function scheduleFor($weekday) |
|
56 | - { |
|
57 | - return $this->filter(function($timeslot) use ($weekday) { |
|
58 | - return $timeslot->airDayOfWeek() == $weekday; |
|
59 | - }); |
|
60 | - } |
|
55 | + public function scheduleFor($weekday) |
|
56 | + { |
|
57 | + return $this->filter(function($timeslot) use ($weekday) { |
|
58 | + return $timeslot->airDayOfWeek() == $weekday; |
|
59 | + }); |
|
60 | + } |
|
61 | 61 | |
62 | - public function getShowsForSlideshow() |
|
63 | - { |
|
64 | - $shows = new Collection(); |
|
65 | - $sortedShows = $this->getShowsInPlayOrder(); |
|
66 | - $shows->push($sortedShows->shift()); |
|
67 | - $nonPulseShows = $sortedShows->filter(function ($show) { |
|
68 | - return strtolower($show->show()) != 'the pulse of music'; |
|
69 | - }); |
|
62 | + public function getShowsForSlideshow() |
|
63 | + { |
|
64 | + $shows = new Collection(); |
|
65 | + $sortedShows = $this->getShowsInPlayOrder(); |
|
66 | + $shows->push($sortedShows->shift()); |
|
67 | + $nonPulseShows = $sortedShows->filter(function ($show) { |
|
68 | + return strtolower($show->show()) != 'the pulse of music'; |
|
69 | + }); |
|
70 | 70 | |
71 | - $shows = $shows->merge($nonPulseShows->take(2)); |
|
71 | + $shows = $shows->merge($nonPulseShows->take(2)); |
|
72 | 72 | |
73 | - do |
|
74 | - { |
|
75 | - $random = $nonPulseShows->random(); |
|
76 | - $exists = $shows->filter(function($show) use($random) { |
|
77 | - return $show->showId() == $random->showId(); |
|
78 | - }); |
|
79 | - } while(!$exists->isEmpty()); |
|
73 | + do |
|
74 | + { |
|
75 | + $random = $nonPulseShows->random(); |
|
76 | + $exists = $shows->filter(function($show) use($random) { |
|
77 | + return $show->showId() == $random->showId(); |
|
78 | + }); |
|
79 | + } while(!$exists->isEmpty()); |
|
80 | 80 | |
81 | - $shows->push($random); |
|
81 | + $shows->push($random); |
|
82 | 82 | |
83 | - return $shows; |
|
84 | - } |
|
83 | + return $shows; |
|
84 | + } |
|
85 | 85 | |
86 | - public function getShowsInPlayOrder() |
|
87 | - { |
|
88 | - $first = $this->first(function ($key, $show) { |
|
89 | - return $show->nowPlaying(); |
|
90 | - }); |
|
91 | - $firstKey = $this->search($first); |
|
92 | - $sorted = $this->slice($firstKey); |
|
93 | - $firstHalfSorted = $this->slice(0, $firstKey); |
|
94 | - return $sorted->merge($firstHalfSorted); |
|
95 | - } |
|
86 | + public function getShowsInPlayOrder() |
|
87 | + { |
|
88 | + $first = $this->first(function ($key, $show) { |
|
89 | + return $show->nowPlaying(); |
|
90 | + }); |
|
91 | + $firstKey = $this->search($first); |
|
92 | + $sorted = $this->slice($firstKey); |
|
93 | + $firstHalfSorted = $this->slice(0, $firstKey); |
|
94 | + return $sorted->merge($firstHalfSorted); |
|
95 | + } |
|
96 | 96 | } |
@@ -7,27 +7,27 @@ |
||
7 | 7 | class IcecastListeners extends Collection |
8 | 8 | { |
9 | 9 | |
10 | - protected $mounts; |
|
10 | + protected $mounts; |
|
11 | 11 | |
12 | - public static function forMounts($mounts) |
|
13 | - { |
|
14 | - $listeners = new IcecastListeners(); |
|
12 | + public static function forMounts($mounts) |
|
13 | + { |
|
14 | + $listeners = new IcecastListeners(); |
|
15 | 15 | |
16 | - $listeners->mounts = $mounts; |
|
16 | + $listeners->mounts = $mounts; |
|
17 | 17 | |
18 | - return $listeners; |
|
19 | - } |
|
18 | + return $listeners; |
|
19 | + } |
|
20 | 20 | |
21 | - public function getMounts() |
|
22 | - { |
|
23 | - return $this->mounts; |
|
24 | - } |
|
21 | + public function getMounts() |
|
22 | + { |
|
23 | + return $this->mounts; |
|
24 | + } |
|
25 | 25 | |
26 | - public function forMount($mount) |
|
27 | - { |
|
28 | - return $this->filter(function($listener) use($mount) { |
|
29 | - return $listener->mount == $mount; |
|
30 | - }); |
|
31 | - } |
|
26 | + public function forMount($mount) |
|
27 | + { |
|
28 | + return $this->filter(function($listener) use($mount) { |
|
29 | + return $listener->mount == $mount; |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
@@ -9,46 +9,46 @@ |
||
9 | 9 | class IcecastReader |
10 | 10 | { |
11 | 11 | |
12 | - protected $hostname; |
|
13 | - protected $credentials; |
|
14 | - protected $mounts; |
|
15 | - |
|
16 | - public function __construct($hostname, $credentials, $mounts) |
|
17 | - { |
|
18 | - $this->hostname = $hostname; |
|
19 | - $this->credentials = $credentials; |
|
20 | - $this->mounts = $mounts; |
|
21 | - } |
|
22 | - |
|
23 | - public function getMounts() |
|
24 | - { |
|
25 | - return $this->mounts; |
|
26 | - } |
|
27 | - |
|
28 | - public function get($studio) |
|
29 | - { |
|
30 | - $results = new Collection; |
|
31 | - |
|
32 | - $client = new Client(); |
|
12 | + protected $hostname; |
|
13 | + protected $credentials; |
|
14 | + protected $mounts; |
|
15 | + |
|
16 | + public function __construct($hostname, $credentials, $mounts) |
|
17 | + { |
|
18 | + $this->hostname = $hostname; |
|
19 | + $this->credentials = $credentials; |
|
20 | + $this->mounts = $mounts; |
|
21 | + } |
|
22 | + |
|
23 | + public function getMounts() |
|
24 | + { |
|
25 | + return $this->mounts; |
|
26 | + } |
|
27 | + |
|
28 | + public function get($studio) |
|
29 | + { |
|
30 | + $results = new Collection; |
|
31 | + |
|
32 | + $client = new Client(); |
|
33 | 33 | |
34 | - $listeners = IcecastListeners::forMounts($this->mounts[$studio]); |
|
35 | - foreach ($this->mounts[$studio] as $mount) |
|
36 | - { |
|
37 | - $response = $client->get($this->hostname . '/admin/listclients?mount=/'. $mount, [ |
|
38 | - 'auth' => $this->credentials |
|
39 | - ]); |
|
40 | - $xml = simplexml_load_string($response->getBody())->source->listener; |
|
41 | - foreach ($xml as $node) |
|
42 | - { |
|
43 | - $listener = new stdClass; |
|
44 | - $listener->hostname = gethostbyaddr($node->IP); |
|
45 | - $listener->minutesConnected = round($node->Connected / 60); |
|
46 | - $listener->userAgent = $node->UserAgent; |
|
47 | - $listener->mount = $mount; |
|
48 | - $listeners->push($listener); |
|
49 | - } |
|
50 | - } |
|
51 | - |
|
52 | - return $listeners; |
|
53 | - } |
|
34 | + $listeners = IcecastListeners::forMounts($this->mounts[$studio]); |
|
35 | + foreach ($this->mounts[$studio] as $mount) |
|
36 | + { |
|
37 | + $response = $client->get($this->hostname . '/admin/listclients?mount=/'. $mount, [ |
|
38 | + 'auth' => $this->credentials |
|
39 | + ]); |
|
40 | + $xml = simplexml_load_string($response->getBody())->source->listener; |
|
41 | + foreach ($xml as $node) |
|
42 | + { |
|
43 | + $listener = new stdClass; |
|
44 | + $listener->hostname = gethostbyaddr($node->IP); |
|
45 | + $listener->minutesConnected = round($node->Connected / 60); |
|
46 | + $listener->userAgent = $node->UserAgent; |
|
47 | + $listener->mount = $mount; |
|
48 | + $listeners->push($listener); |
|
49 | + } |
|
50 | + } |
|
51 | + |
|
52 | + return $listeners; |
|
53 | + } |
|
54 | 54 | } |
@@ -4,104 +4,104 @@ |
||
4 | 4 | |
5 | 5 | class Slide |
6 | 6 | { |
7 | - protected $show; |
|
8 | - protected $type; |
|
9 | - protected $playOrder; |
|
10 | - protected $index; |
|
11 | - |
|
12 | - public static function fromScheduledShow($show) |
|
13 | - { |
|
14 | - $slide = new Slide(); |
|
15 | - |
|
16 | - $slide->type = 'SHOW'; |
|
17 | - $slide->show = $show; |
|
18 | - |
|
19 | - return $slide; |
|
20 | - } |
|
21 | - |
|
22 | - public static function fromEvent($event) |
|
23 | - { |
|
24 | - $slide = new Slide(); |
|
25 | - |
|
26 | - $slide->type = 'EVENT'; |
|
27 | - $slide->event = $event; |
|
28 | - |
|
29 | - return $slide; |
|
30 | - } |
|
31 | - |
|
32 | - public function playOrder($playOrder) |
|
33 | - { |
|
34 | - $this->playOrder = $playOrder; |
|
35 | - } |
|
36 | - |
|
37 | - public function displayText() |
|
38 | - { |
|
39 | - if ($this->type == 'EVENT') |
|
40 | - { |
|
41 | - return; |
|
42 | - } |
|
43 | - |
|
44 | - if ($this->playOrder == 0) |
|
45 | - { |
|
46 | - return '► Now Playing'; |
|
47 | - } |
|
48 | - |
|
49 | - if ($this->playOrder == 1) |
|
50 | - { |
|
51 | - return 'Up Next:'; |
|
52 | - } |
|
53 | - |
|
54 | - return $this->show->getRelativeAirDate() . ' ' . $this->show->timespan(); |
|
55 | - } |
|
56 | - |
|
57 | - public function image() |
|
58 | - { |
|
59 | - if ($this->type == 'EVENT') |
|
60 | - { |
|
61 | - return $this->event->picture; |
|
62 | - } |
|
63 | - |
|
64 | - return $this->show->sliderPicture(); |
|
65 | - } |
|
66 | - |
|
67 | - public function textStyle() |
|
68 | - { |
|
69 | - if ($this->type != 'SHOW') |
|
70 | - { |
|
71 | - return; |
|
72 | - } |
|
7 | + protected $show; |
|
8 | + protected $type; |
|
9 | + protected $playOrder; |
|
10 | + protected $index; |
|
11 | + |
|
12 | + public static function fromScheduledShow($show) |
|
13 | + { |
|
14 | + $slide = new Slide(); |
|
15 | + |
|
16 | + $slide->type = 'SHOW'; |
|
17 | + $slide->show = $show; |
|
18 | + |
|
19 | + return $slide; |
|
20 | + } |
|
21 | + |
|
22 | + public static function fromEvent($event) |
|
23 | + { |
|
24 | + $slide = new Slide(); |
|
25 | + |
|
26 | + $slide->type = 'EVENT'; |
|
27 | + $slide->event = $event; |
|
28 | + |
|
29 | + return $slide; |
|
30 | + } |
|
31 | + |
|
32 | + public function playOrder($playOrder) |
|
33 | + { |
|
34 | + $this->playOrder = $playOrder; |
|
35 | + } |
|
36 | + |
|
37 | + public function displayText() |
|
38 | + { |
|
39 | + if ($this->type == 'EVENT') |
|
40 | + { |
|
41 | + return; |
|
42 | + } |
|
43 | + |
|
44 | + if ($this->playOrder == 0) |
|
45 | + { |
|
46 | + return '► Now Playing'; |
|
47 | + } |
|
48 | + |
|
49 | + if ($this->playOrder == 1) |
|
50 | + { |
|
51 | + return 'Up Next:'; |
|
52 | + } |
|
53 | + |
|
54 | + return $this->show->getRelativeAirDate() . ' ' . $this->show->timespan(); |
|
55 | + } |
|
56 | + |
|
57 | + public function image() |
|
58 | + { |
|
59 | + if ($this->type == 'EVENT') |
|
60 | + { |
|
61 | + return $this->event->picture; |
|
62 | + } |
|
63 | + |
|
64 | + return $this->show->sliderPicture(); |
|
65 | + } |
|
66 | + |
|
67 | + public function textStyle() |
|
68 | + { |
|
69 | + if ($this->type != 'SHOW') |
|
70 | + { |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - return $this->show->sliderStyle(); |
|
75 | - } |
|
76 | - |
|
77 | - public function url() |
|
78 | - { |
|
79 | - if ($this->type != 'EVENT') |
|
80 | - { |
|
81 | - return; |
|
82 | - } |
|
83 | - |
|
84 | - return $this->event->url; |
|
85 | - } |
|
86 | - |
|
87 | - public function type() |
|
88 | - { |
|
89 | - return $this->type; |
|
90 | - } |
|
91 | - |
|
92 | - public function index($index) |
|
93 | - { |
|
94 | - $this->index = $index; |
|
95 | - } |
|
96 | - |
|
97 | - public function displayIndex() |
|
98 | - { |
|
99 | - $display = [ |
|
100 | - 0 => 'first', |
|
101 | - 1 => 'second', |
|
102 | - 2 => 'third', |
|
103 | - 3 => 'fourth', |
|
104 | - ]; |
|
105 | - return $display[$this->index]; |
|
106 | - } |
|
74 | + return $this->show->sliderStyle(); |
|
75 | + } |
|
76 | + |
|
77 | + public function url() |
|
78 | + { |
|
79 | + if ($this->type != 'EVENT') |
|
80 | + { |
|
81 | + return; |
|
82 | + } |
|
83 | + |
|
84 | + return $this->event->url; |
|
85 | + } |
|
86 | + |
|
87 | + public function type() |
|
88 | + { |
|
89 | + return $this->type; |
|
90 | + } |
|
91 | + |
|
92 | + public function index($index) |
|
93 | + { |
|
94 | + $this->index = $index; |
|
95 | + } |
|
96 | + |
|
97 | + public function displayIndex() |
|
98 | + { |
|
99 | + $display = [ |
|
100 | + 0 => 'first', |
|
101 | + 1 => 'second', |
|
102 | + 2 => 'third', |
|
103 | + 3 => 'fourth', |
|
104 | + ]; |
|
105 | + return $display[$this->index]; |
|
106 | + } |
|
107 | 107 | } |
@@ -7,27 +7,27 @@ |
||
7 | 7 | class Slides extends Collection |
8 | 8 | { |
9 | 9 | |
10 | - public static function forShows($shows) |
|
11 | - { |
|
12 | - $slides = new Slides(); |
|
10 | + public static function forShows($shows) |
|
11 | + { |
|
12 | + $slides = new Slides(); |
|
13 | 13 | |
14 | - foreach ($shows as $key => $show) { |
|
15 | - $slide = Slide::fromScheduledShow($show); |
|
16 | - $slide->playOrder($key); |
|
17 | - $slide->index($key); |
|
18 | - $slides->push($slide); |
|
19 | - } |
|
14 | + foreach ($shows as $key => $show) { |
|
15 | + $slide = Slide::fromScheduledShow($show); |
|
16 | + $slide->playOrder($key); |
|
17 | + $slide->index($key); |
|
18 | + $slides->push($slide); |
|
19 | + } |
|
20 | 20 | |
21 | - return $slides; |
|
22 | - } |
|
21 | + return $slides; |
|
22 | + } |
|
23 | 23 | |
24 | - public function addEvent($event) |
|
25 | - { |
|
26 | - $this->pop(); |
|
27 | - $this->prepend(Slide::fromEvent($event)); |
|
28 | - $index = 0; |
|
29 | - foreach ($this as $value) { |
|
30 | - $value->index($index++); |
|
31 | - } |
|
32 | - } |
|
24 | + public function addEvent($event) |
|
25 | + { |
|
26 | + $this->pop(); |
|
27 | + $this->prepend(Slide::fromEvent($event)); |
|
28 | + $index = 0; |
|
29 | + foreach ($this as $value) { |
|
30 | + $value->index($index++); |
|
31 | + } |
|
32 | + } |
|
33 | 33 | } |
@@ -31,24 +31,24 @@ |
||
31 | 31 | */ |
32 | 32 | protected $hidden = ['password', 'remember_token']; |
33 | 33 | |
34 | - public $timestamps = false; |
|
34 | + public $timestamps = false; |
|
35 | 35 | |
36 | 36 | /** |
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function role() |
|
40 | - { |
|
41 | - return $this->belongsTo('WITR\Role', 'user_role', 'id'); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Does the user have a particular role? |
|
46 | - * |
|
47 | - * @param $name |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - public function hasRole($name) |
|
51 | - { |
|
52 | - return $this->role->name == $name; |
|
53 | - } |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function role() |
|
40 | + { |
|
41 | + return $this->belongsTo('WITR\Role', 'user_role', 'id'); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Does the user have a particular role? |
|
46 | + * |
|
47 | + * @param $name |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + public function hasRole($name) |
|
51 | + { |
|
52 | + return $this->role->name == $name; |
|
53 | + } |
|
54 | 54 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | public $timestamps = false; |
22 | 22 | |
23 | 23 | public function setUrlTagAttribute($value) |
24 | - { |
|
25 | - parse_str( parse_url( $value, PHP_URL_QUERY ), $params ); |
|
24 | + { |
|
25 | + parse_str( parse_url( $value, PHP_URL_QUERY ), $params ); |
|
26 | 26 | if (isset($params['v']) || array_key_exists('v', $params)) { |
27 | 27 | $this->attributes['url_tag'] = $params['v']; |
28 | 28 | } else { |
29 | 29 | $this->attributes['url_tag'] = $value; |
30 | 30 | } |
31 | - } |
|
31 | + } |
|
32 | 32 | } |