This repository has been archived by the owner on Apr 5, 2019. It is now read-only.
/
DirectionScreen.php
146 lines (136 loc) · 5.28 KB
/
DirectionScreen.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
* CampFire Manager is a scheduling tool predominently used at BarCamps to
* schedule talks based, mainly, on the number of people attending each talk
* receives.
*
* PHP version 5
*
* @category Default
* @package CampFireManager2
* @author Jon Spriggs <jon@sprig.gs>
* @license http://www.gnu.org/licenses/agpl.html AGPLv3
* @link https://github.com/CampFireManager/cfm2 Version Control Service
*/
/**
* This class collates all the objects needed to render a DirectionScreen Page
*
* @category Collection_DirectionScreen
* @package CampFireManager2
* @author Jon Spriggs <jon@sprig.gs>
* @license http://www.gnu.org/licenses/agpl.html AGPLv3
* @link https://github.com/CampFireManager/cfm2 Version Control Service
*/
class Collection_DirectionScreen extends Abstract_GenericCollection
{
/**
* Collect the data for this collection
*
* @param integer|null $screen The screen ID to return, or null to create a
* new screen and reload to that page.
*
* @return Collection_DirectionScreen
*/
protected function __construct($screen = null)
{
if ($screen != null) {
$objScreen = Object_Screen::brokerByID($screen);
}
if ($screen == null || $objScreen == false) {
$objScreen = new Object_Screen(true);
$objScreen->setKey('dtLastSeen', date('Y-m-d H:i:s'));
$objScreen->create();
Base_Response::redirectTo('directionscreen/' . $objScreen->getPrimaryKeyValue());
}
$objScreen->setKey('dtLastSeen', date('Y-m-d H:i:s'));
$objScreen->write();
$arrScreen = $objScreen->getSelf();
$arrRooms = Object_Room::brokerAll();
foreach ($arrRooms as $objRoom) {
$arrTalks['now'][$objRoom->getKey('intRoomID')] = null;
$arrTalks['next'][$objRoom->getKey('intRoomID')] = null;
}
list($now, $next) = Object_Slot::getNowAndNext();
$nowSlot = Object_Slot::brokerByID($now);
if (is_object($nowSlot)) {
$nowSlot->setFull(true);
$nowSlot = $nowSlot->getSelf();
}
$nextSlot = Object_Slot::brokerByID($next);
if (is_object($nextSlot)) {
$nextSlot->setFull(true);
$nextSlot = $nextSlot->getSelf();
}
$this->arrData = array('NowSlot' => $nowSlot, 'NextSlot' => $nextSlot);
$arrNTalks = Object_Talk::brokerByColumnSearch('intSlotID', $now);
if ($arrNTalks == false) {
$arrNTalks = array();
}
foreach ($arrNTalks as $objTalk) {
$objTalk->setFull(true);
$arrTalks['now'][$objTalk->getKey('intRoomID')] = $objTalk->getSelf();
}
$arrNTalks = Object_Talk::brokerByColumnSearch('intSlotID', $next);
if ($arrNTalks == false) {
$arrNTalks = array();
}
foreach ($arrNTalks as $objTalk) {
$objTalk->setFull(true);
$arrTalks['next'][$objTalk->getKey('intRoomID')] = $objTalk->getSelf();
}
foreach ($arrScreen['arrDirections'] as $strDirection => $arrDirections) {
ksort($arrDirections);
foreach ($arrDirections as $intRoomID => $objDirection) {
$this->arrData[$strDirection][$objDirection->getKey('intScreenDirectionID')] = array(
'strRoom' => $arrRooms[$intRoomID]->getKey('strRoom'),
'now' => $arrTalks['now'][$intRoomID],
'next' => $arrTalks['next'][$intRoomID]
);
}
}
// These values assum just the middle block is there.
$this->arrData['toprow'] = false;
$this->arrData['bottomrow'] = false;
$this->arrData['leftcolumn'] = false;
$this->arrData['rightcolumn'] = false;
$this->arrData['trheight'] = '100%';
$this->arrData['tdwidth'] = '100%';
foreach ($this->arrData as $direction => $dummy) {
$dummy = null;
if (substr($direction, 0, 2) == 'up') {
$this->arrData['toprow'] = true;
}
if (substr($direction, 0, 4) == 'down') {
$this->arrData['bottomrow'] = true;
}
if (substr($direction, -4) == 'left') {
$this->arrData['leftcolumn'] = true;
}
if (substr($direction, -5) == 'right') {
$this->arrData['rightcolumn'] = true;
}
}
if ($this->arrData['toprow'] && $this->arrData['bottomrow']) {
$this->arrData['trheight'] = '33%';
} elseif ($this->arrData['toprow'] || $this->arrData['bottomrow']) {
$this->arrData['trheight'] = '50%';
}
if ($this->arrData['leftcolumn'] && $this->arrData['rightcolumn']) {
$this->arrData['tdwidth'] = '33%';
} elseif ($this->arrData['leftcolumn'] || $this->arrData['rightcolumn']) {
$this->arrData['tdwidth'] = '50%';
}
return $this;
}
/**
* A mock up of the Object_ style of broker functions, for collections of data
*
* @param string $screen The screen ID to retrieve, or null to create a new one.
*
* @return array
*/
public static function brokerByID($screen = null)
{
return parent::brokerByID($screen);
}
}