Changeset 69
- Timestamp:
- 08/03/11 19:31:24 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/Session.php
r57 r69 8 8 class Session { 9 9 10 private $name; 11 private $description; 12 private $date; 13 private $application; 14 private $pipeline; 10 public $title; 11 public $description; 12 public $pipeline; 13 public $count; 15 14 16 public function __construct() { 15 public function __construct($title, $description) { 16 $this->title = $title; 17 $this->description = $description; 18 $this->count = 0; 17 19 20 $this->pipeline = array(); 21 } 22 23 public static function getSession($info) 24 { 25 if (!empty($info)) 26 { 27 $title = $info['sessionTitle']; 28 $description = $info['sessionDescription']; 29 $session = new Session($title, $description); 30 $session->count = $info['pipelineCount']; 31 32 $pipelineCount = 1; 33 for ($i = 1; $i < $session->count + 1; $i++) 34 { 35 if (isset($info[$i . 's'])) 36 { 37 $session->pipeline[$i . 's'] = $info[$i . 's']; 38 } 39 else if (isset($info[$i . 'd'])) 40 { 41 $session->pipeline[$i . 'd'] = $info[$i . 'd']; 42 } 43 else if (isset($info[$i . 'a'])) 44 { 45 $session->pipeline[$i . 'a'] = $info[$i . 'a']; 46 } 47 48 $pipelineCount++; 49 } 50 51 return $session; 52 } 53 else 54 return null; 18 55 } 19 56 -
Dev/trunk/classes/SessionCreationTool.php
r68 r69 17 17 18 18 $this->javascript(); 19 var_dump($session); 19 20 var_dump($_POST); 20 21 ?> … … 26 27 $this->description(); 27 28 $this->pipeline(); 29 $this->surveysApplications(); 28 30 29 31 $this->makeSessionButton(); … … 32 34 </div> 33 35 <?php 36 $this->populatePipeline(); 34 37 } 35 38 … … 43 46 <script type="text/javascript"> 44 47 var pipelineCount = 0; 45 var surveys = new Array(); 46 47 init(); 48 49 // ============================================================= 50 51 function addSurvey(surveyID) { 52 pipelineCount++; 48 53 49 function init() {50 loadSurveys();51 loadApplications();52 }53 54 function loadSurveys() {55 <?php56 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 <?php63 }64 ?>65 }66 67 function loadApplications() {68 69 }70 71 function Survey(title, id)72 {73 this.title = title;74 this.id = id;75 }76 77 // =============================================================78 79 function addSurvey() {80 pipelineCount++;81 82 54 var pipeline = document.getElementById("pipeline"); 83 55 var surveysList = document.getElementById("surveysList"); 84 56 85 57 var entry = document.createElement("option"); 86 entry.setAttribute("value", surveys[surveysList.selectedIndex].id); 58 59 if (surveyID != null) 60 { 61 entry.setAttribute("value", surveyID); 62 entry.innerHTML = pipelineCount + ". " + surveysList.options.namedItem(surveyID).innerHTML; 63 } 64 else 65 { 66 entry.setAttribute("value", surveysList.options[surveysList.selectedIndex].value); 67 68 entry.innerHTML = pipelineCount + ". " + surveysList.options[surveysList.selectedIndex].innerHTML; 69 70 } 87 71 entry.style.backgroundColor = "#0090ac"; 88 entry.innerHTML = pipelineCount + ". " + surveys[surveysList.selectedIndex].title;89 72 entry.name = pipelineCount + "s"; 90 73 entry.entryType = "s"; 74 91 75 pipeline.appendChild(entry); 92 76 } 93 77 94 78 function addDashboard() { 95 79 pipelineCount++; 96 80 var pipeline = document.getElementById("pipeline"); 97 81 98 82 var entry = document.createElement("option"); 99 83 entry.setAttribute("value", "dashboard"); … … 102 86 entry.innerHTML = pipelineCount + ". " + "Dashboard"; 103 87 entry.name = pipelineCount + "d"; 104 88 entry.entryType = "d"; 89 105 90 pipeline.appendChild(entry); 106 91 } 107 92 93 function removeFromPipeline() { 94 var pipeline = document.getElementById("pipeline"); 95 if (pipeline.selectedIndex != null) 96 { 97 var index = pipeline.selectedIndex; 98 pipeline.remove(index); 99 100 for(var i = index; i < pipeline.length; i++) 101 { 102 var entry = pipeline.options[i]; 103 entry.name = "" + (i+1) + entry.entryType; 104 var htmlStr = entry.innerHTML; 105 var dotIndex = htmlStr.indexOf('.'); 106 entry.innerHTML = (i+1) + htmlStr.substr(dotIndex); 107 } 108 pipelineCount--; 109 } 110 } 111 108 112 function submitPipeline() 109 113 { 110 114 var form = document.getElementById("sessionCreationForm"); 111 115 112 116 var pipeline = document.getElementById("pipeline").options; 113 114 117 118 115 119 for (var i = 0; i < pipeline.length; i++) 116 120 { … … 119 123 pipelineElem.value = pipeline[i].value; 120 124 pipelineElem.type = "hidden"; 121 125 122 126 form.appendChild(pipelineElem); 123 127 } 124 128 129 var count = document.createElement("input"); 130 count.name = "pipelineCount"; 131 count.value = pipelineCount; 132 count.type = "hidden"; 133 134 form.appendChild(count); 125 135 } 126 136 </script> … … 156 166 <?php 157 167 $this->addDashboardToPipelineButton(); 168 $this->removeFromPipelineButton(); 158 169 ?> 159 170 </div> 160 171 </div> 172 <?php 173 } 174 175 private function surveysApplications() { 176 ?> 161 177 <div id="surveysApplicationsWrapper"> 162 178 <div id="surveysForPipelineWrapper"> … … 164 180 <?php 165 181 $this->surveysSelect(); 166 $this->addSurveyToPipelineButton() 182 $this->addSurveyToPipelineButton(); 167 183 ?> 168 184 </div> … … 180 196 private function pipelineSelect() { 181 197 ?> 182 <select id="pipeline" size="1000"> 183 184 </select> 198 <select id="pipeline" size="1000"></select> 185 199 <?php 186 200 } … … 192 206 foreach ($this->surveys as $survey) { 193 207 ?> 194 <option value="<?php echo $survey->id; ?>">208 <option name="<?php echo $survey->id; ?>" value="<?php echo $survey->id; ?>"> 195 209 <?php echo $survey->title; ?> 196 210 </option> … … 223 237 private function addDashboardToPipelineButton() { 224 238 ?> 225 <input type="button" class="surveyButton nextLine pipelineButton leftAlign leftPadding1" value="+ Dashboard" onclick="addDashboard()"/> 239 <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="+ Dashboard" onclick="addDashboard()"/> 240 <?php 241 } 242 243 private function removeFromPipelineButton() { 244 ?> 245 <input type="button" class="surveyButton" value="x" onclick="removeFromPipeline()"/> 226 246 <?php 227 247 } … … 231 251 <input type="submit" id="makeSessionButton" class="topRight surveyButton" value="Make session" /> 232 252 <?php 253 } 254 255 private function populatePipeline() { 256 257 if (isset($this->session)) { 258 for ($i = 1; $i < $this->session->count + 1; $i++) { 259 if (isset($this->session->pipeline[$i . 's'])) { 260 ?> 261 <script type="text/javascript"> 262 addSurvey(<?php echo "'" . $this->session->pipeline[$i . 's'] . "'"; ?>); 263 </script> 264 <?php 265 } else if (isset($this->session->pipeline[$i . 'd'])) { 266 ?> 267 <script type="text/javascript"> 268 addDashboard(); 269 </script> 270 <?php 271 } 272 } 273 } 233 274 } 234 275 -
Dev/trunk/classes/SurveyCreationTool.php
r68 r69 15 15 $this->survey = $survey; 16 16 $this->timeStamp = $timeStamp; 17 var_dump($_POST); 17 18 18 if (isset($this->survey->id)) 19 19 SurveyCreationTool::javascript($this->survey->id); -
Dev/trunk/sessioncreation.php
r61 r69 4 4 if (is_null($_SESSION['username'])) 5 5 redirect('index.php'); 6 7 $session = Session::getSession($_POST); 6 8 ?> 9 10 11 7 12 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 8 13 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> … … 22 27 <div id="content"> 23 28 <?php 24 new SessionCreationTool( );29 new SessionCreationTool($session); 25 30 ?> 26 31 </div>
Note: See TracChangeset
for help on using the changeset viewer.