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