[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(); |
---|
[61] | 19 | ?> |
---|
[64] | 20 | |
---|
[61] | 21 | <div class="creation"> |
---|
[64] | 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> |
---|
[61] | 31 | </div> |
---|
| 32 | <?php |
---|
| 33 | } |
---|
| 34 | |
---|
[64] | 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(); |
---|
[66] | 44 | |
---|
[64] | 45 | init(); |
---|
[66] | 46 | |
---|
[64] | 47 | function init() { |
---|
| 48 | loadSurveys(); |
---|
| 49 | loadApplications(); |
---|
| 50 | } |
---|
[66] | 51 | |
---|
[64] | 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 | } |
---|
[66] | 64 | |
---|
[64] | 65 | function loadApplications() { |
---|
[66] | 66 | |
---|
[64] | 67 | } |
---|
[66] | 68 | |
---|
[64] | 69 | function Survey(title, id) |
---|
| 70 | { |
---|
| 71 | this.title = title; |
---|
| 72 | this.id = id; |
---|
| 73 | } |
---|
[66] | 74 | |
---|
[64] | 75 | // ============================================================= |
---|
[66] | 76 | |
---|
[64] | 77 | function addSurvey() { |
---|
[66] | 78 | var pipeline = document.getElementById("pipeline"); |
---|
| 79 | var surveysList = document.getElementById("surveysList"); |
---|
| 80 | |
---|
| 81 | var entry = document.createElement("option"); |
---|
| 82 | entry.setAttribute("value", surveys[surveysList.selectedIndex].id); |
---|
| 83 | entry.innerHTML = surveys[surveysList.selectedIndex].title; |
---|
| 84 | |
---|
| 85 | pipeline.appendChild(entry); |
---|
[64] | 86 | } |
---|
[66] | 87 | |
---|
[64] | 88 | </script> |
---|
| 89 | <?php |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | private function title() { |
---|
| 93 | if (isset($this->session->title)) |
---|
| 94 | $value = $this->session->title; |
---|
| 95 | else |
---|
| 96 | $value = 'Untitled Session'; |
---|
| 97 | ?> |
---|
| 98 | <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo $value; ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" /> |
---|
| 99 | <?php |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | private function description() { |
---|
| 103 | if (isset($this->session->description)) |
---|
| 104 | $value = $this->session->description; |
---|
| 105 | else |
---|
| 106 | $value = 'Write a description for this session here.'; |
---|
| 107 | ?> |
---|
| 108 | <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea> |
---|
| 109 | <?php |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | private function pipeline() { |
---|
| 113 | ?> |
---|
[65] | 114 | <div id="pipelineWrapper"> |
---|
| 115 | <h2 class="pipelineHead">Pipeline</h2> |
---|
| 116 | <?php $this->pipelineSelect(); ?> |
---|
| 117 | <div id="pipelineOptions"> |
---|
| 118 | <?php |
---|
| 119 | $this->addDashboardToPipelineButton(); |
---|
| 120 | ?> |
---|
| 121 | </div> |
---|
[64] | 122 | </div> |
---|
[65] | 123 | <div id="surveysApplicationsWrapper"> |
---|
| 124 | <div id="surveysForPipelineWrapper"> |
---|
| 125 | <h2 class="pipelineHead">Surveys</h2> |
---|
[66] | 126 | <?php |
---|
| 127 | $this->surveysSelect(); |
---|
| 128 | $this->addSurveyToPipelineButton() |
---|
| 129 | ?> |
---|
[65] | 130 | </div> |
---|
| 131 | <div id="applicationsForPipelineWrapper"> |
---|
| 132 | <h2 class="pipelineHead">Applications</h2> |
---|
[66] | 133 | <?php |
---|
| 134 | $this->applicationsSelect(); |
---|
| 135 | $this->addApplicationToPipelineButton(); |
---|
| 136 | ?> |
---|
[65] | 137 | </div> |
---|
| 138 | </div> |
---|
| 139 | <?php |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | private function pipelineSelect() { |
---|
| 143 | ?> |
---|
| 144 | <select id="pipeline" size="5"> |
---|
| 145 | |
---|
| 146 | </select> |
---|
| 147 | <?php |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | private function surveysSelect() { |
---|
| 151 | ?> |
---|
[66] | 152 | <select id="surveysList" size="5" class="width100p"> |
---|
[64] | 153 | <?php |
---|
[65] | 154 | foreach ($this->surveys as $survey) { |
---|
| 155 | ?> |
---|
| 156 | <option value="<?php echo $survey->id; ?>"> |
---|
| 157 | <?php echo $survey->title; ?> |
---|
| 158 | </option> |
---|
| 159 | <?php |
---|
| 160 | } |
---|
| 161 | ?> |
---|
| 162 | </select> |
---|
[64] | 163 | <?php |
---|
| 164 | } |
---|
| 165 | |
---|
[65] | 166 | private function applicationsSelect() { |
---|
| 167 | ?> |
---|
| 168 | <select size="5" class="width100p"> |
---|
| 169 | </select> |
---|
| 170 | <?php |
---|
| 171 | } |
---|
| 172 | |
---|
[64] | 173 | private function addSurveyToPipelineButton() { |
---|
| 174 | ?> |
---|
[66] | 175 | <input type="button" id="surveyToPipeline" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" onclick="addSurvey()"/> |
---|
[64] | 176 | <?php |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | private function addApplicationToPipelineButton() { |
---|
| 180 | ?> |
---|
[66] | 181 | <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" /> |
---|
[64] | 182 | <?php |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | private function addDashboardToPipelineButton() { |
---|
| 186 | ?> |
---|
| 187 | <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" /> |
---|
| 188 | <?php |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | private function makeSessionButton() { |
---|
| 192 | ?> |
---|
| 193 | <input type="submit" id="makeSessionButton" class="surveyButton" value="Make session" /> |
---|
| 194 | <?php |
---|
| 195 | } |
---|
| 196 | |
---|
[58] | 197 | } |
---|
| 198 | ?> |
---|