1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Description of SessionCreationTool |
---|
5 | * |
---|
6 | * @author fpvanagthoven |
---|
7 | */ |
---|
8 | class SessionCreationTool { |
---|
9 | |
---|
10 | private $session; |
---|
11 | private $surveys; |
---|
12 | |
---|
13 | public function __construct($session = null) { |
---|
14 | $this->session = $session; |
---|
15 | |
---|
16 | $this->init(); |
---|
17 | |
---|
18 | $this->javascript(); |
---|
19 | ?> |
---|
20 | |
---|
21 | <div class="creation"> |
---|
22 | <form id="sessionCreationForm" action="" method="post"> |
---|
23 | <?php |
---|
24 | $this->title(); |
---|
25 | $this->description(); |
---|
26 | $this->pipeline(); |
---|
27 | |
---|
28 | $this->makeSessionButton(); |
---|
29 | ?> |
---|
30 | </form> |
---|
31 | </div> |
---|
32 | <?php |
---|
33 | } |
---|
34 | |
---|
35 | private function init() { |
---|
36 | $this->surveys = Loader::loadSurveys(); |
---|
37 | } |
---|
38 | |
---|
39 | private function javascript() { |
---|
40 | ?> |
---|
41 | <script type="text/javascript" src="js/creation.js"></script> |
---|
42 | <script type="text/javascript"> |
---|
43 | var surveys = new Array(); |
---|
44 | |
---|
45 | init(); |
---|
46 | |
---|
47 | function init() { |
---|
48 | loadSurveys(); |
---|
49 | loadApplications(); |
---|
50 | } |
---|
51 | |
---|
52 | function loadSurveys() { |
---|
53 | <?php |
---|
54 | foreach ($this->surveys as $survey) { |
---|
55 | ?> |
---|
56 | var title = <?php echo "'" . $survey->title . "'"; ?>; |
---|
57 | var id = <?php echo "'" . $survey->id . "'"; ?>; |
---|
58 | var survey = new Survey(title, id); |
---|
59 | surveys.push(survey); |
---|
60 | <?php |
---|
61 | } |
---|
62 | ?> |
---|
63 | } |
---|
64 | |
---|
65 | function loadApplications() { |
---|
66 | |
---|
67 | } |
---|
68 | |
---|
69 | function Survey(title, id) |
---|
70 | { |
---|
71 | this.title = title; |
---|
72 | this.id = id; |
---|
73 | } |
---|
74 | |
---|
75 | // ============================================================= |
---|
76 | |
---|
77 | function addSurvey() { |
---|
78 | var surveyList = document.createElement("select"); |
---|
79 | surveyList.size = 1000; |
---|
80 | surveyList.style.height = "10em"; |
---|
81 | surveyList.style.width = "15em"; |
---|
82 | |
---|
83 | for (var i = 0; i < surveys.length; i++) |
---|
84 | { |
---|
85 | var option = document.createElement("option"); |
---|
86 | option.setAttribute("value", surveys[i].id); |
---|
87 | option.innerHTML = surveys[i].title; |
---|
88 | surveyList.appendChild(option); |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | var sessionCreation = document.getElementById("sessionCreationForm"); |
---|
94 | var pipelineOptions = document.getElementById("pipelineOptions"); |
---|
95 | |
---|
96 | sessionCreation.replaceChild(surveyList, pipelineOptions); |
---|
97 | } |
---|
98 | |
---|
99 | </script> |
---|
100 | <?php |
---|
101 | } |
---|
102 | |
---|
103 | private function title() { |
---|
104 | if (isset($this->session->title)) |
---|
105 | $value = $this->session->title; |
---|
106 | else |
---|
107 | $value = 'Untitled Session'; |
---|
108 | ?> |
---|
109 | <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" /> |
---|
110 | <?php |
---|
111 | } |
---|
112 | |
---|
113 | private function description() { |
---|
114 | if (isset($this->session->description)) |
---|
115 | $value = $this->session->description; |
---|
116 | else |
---|
117 | $value = 'Write a description for this session here.'; |
---|
118 | ?> |
---|
119 | <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea> |
---|
120 | <?php |
---|
121 | } |
---|
122 | |
---|
123 | private function pipeline() { |
---|
124 | ?> |
---|
125 | <div id="pipelineWrapper"> |
---|
126 | <h2 class="pipelineHead">Pipeline</h2> |
---|
127 | <?php $this->pipelineSelect(); ?> |
---|
128 | <div id="pipelineOptions"> |
---|
129 | <?php |
---|
130 | $this->addDashboardToPipelineButton(); |
---|
131 | ?> |
---|
132 | </div> |
---|
133 | </div> |
---|
134 | <div id="surveysApplicationsWrapper"> |
---|
135 | <div id="surveysForPipelineWrapper"> |
---|
136 | <h2 class="pipelineHead">Surveys</h2> |
---|
137 | <?php $this->surveysSelect(); ?> |
---|
138 | </div> |
---|
139 | <div id="applicationsForPipelineWrapper"> |
---|
140 | <h2 class="pipelineHead">Applications</h2> |
---|
141 | <?php $this->applicationsSelect(); ?> |
---|
142 | </div> |
---|
143 | </div> |
---|
144 | <?php |
---|
145 | } |
---|
146 | |
---|
147 | private function pipelineSelect() { |
---|
148 | ?> |
---|
149 | <select id="pipeline" size="5"> |
---|
150 | |
---|
151 | </select> |
---|
152 | <?php |
---|
153 | } |
---|
154 | |
---|
155 | private function surveysSelect() { |
---|
156 | ?> |
---|
157 | <select size="5" class="width100p"> |
---|
158 | <?php |
---|
159 | foreach ($this->surveys as $survey) { |
---|
160 | ?> |
---|
161 | <option value="<?php echo $survey->id; ?>"> |
---|
162 | <?php echo $survey->title; ?> |
---|
163 | </option> |
---|
164 | <?php |
---|
165 | } |
---|
166 | ?> |
---|
167 | </select> |
---|
168 | <?php |
---|
169 | } |
---|
170 | |
---|
171 | private function applicationsSelect() { |
---|
172 | ?> |
---|
173 | <select size="5" class="width100p"> |
---|
174 | </select> |
---|
175 | <?php |
---|
176 | } |
---|
177 | |
---|
178 | private function addSurveyToPipelineButton() { |
---|
179 | ?> |
---|
180 | <input type="button" id="surveyToPipeline" class="surveyButton pipelineButton leftAlign leftPadding1" value="+ Survey" onclick="addSurvey()"/> |
---|
181 | <?php |
---|
182 | } |
---|
183 | |
---|
184 | private function addApplicationToPipelineButton() { |
---|
185 | ?> |
---|
186 | <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="+ Application" /> |
---|
187 | <?php |
---|
188 | } |
---|
189 | |
---|
190 | private function addDashboardToPipelineButton() { |
---|
191 | ?> |
---|
192 | <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" /> |
---|
193 | <?php |
---|
194 | } |
---|
195 | |
---|
196 | private function makeSessionButton() { |
---|
197 | ?> |
---|
198 | <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" /> |
---|
199 | <?php |
---|
200 | } |
---|
201 | |
---|
202 | } |
---|
203 | ?> |
---|