[144] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * To change this template, choose Tools | Templates |
---|
| 4 | * and open the template in the editor. |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | /** |
---|
[151] | 8 | * A visual interface object for editing and viewing a session's pipeline. |
---|
[144] | 9 | * |
---|
[151] | 10 | * @author Tschipper |
---|
[144] | 11 | */ |
---|
[146] | 12 | class PipelineSequencer { |
---|
[144] | 13 | |
---|
| 14 | // properties |
---|
[152] | 15 | private $loadedSession; |
---|
[144] | 16 | private $selectedStep; |
---|
[163] | 17 | private $dbi; |
---|
[144] | 18 | |
---|
[152] | 19 | public function __construct() { |
---|
[163] | 20 | $this->dbi = new DatabaseInterface(); |
---|
[146] | 21 | } |
---|
[144] | 22 | |
---|
[150] | 23 | public function init() { |
---|
[153] | 24 | $stringPipeline = ""; |
---|
[164] | 25 | $stringPipelineType = ""; |
---|
| 26 | $stringPipelineUpdated = ""; |
---|
| 27 | $numberOfSteps = 0; |
---|
[166] | 28 | |
---|
[163] | 29 | if (is_array($this->loadedSession->pipeline)) { |
---|
| 30 | foreach ($this->loadedSession->pipeline as $object) { |
---|
| 31 | $stringPipeline .= "$object->uid,"; |
---|
[166] | 32 | $stringPipelineType .= get_class($object) . ","; |
---|
[167] | 33 | $stringPipelineUpdated .= "0,"; |
---|
[164] | 34 | $numberOfSteps++; |
---|
[163] | 35 | } |
---|
| 36 | } else { |
---|
[156] | 37 | $stringPipeline = $this->loadedSession->pipeline; |
---|
[164] | 38 | $stringPipelineType = $_POST['pipelineTypes']; |
---|
| 39 | $stringPipelineUpdated = $_POST['pipelineUpdatedField']; |
---|
[156] | 40 | } |
---|
[144] | 41 | ?> |
---|
[154] | 42 | <br /><form name="sequencerForm" action="pipelineEditor.php" method="post"> |
---|
[151] | 43 | <fieldset id="sequencer"> |
---|
[167] | 44 | <div class="fieldsetTitle">Name: <?php echo $this->loadedSession->title; ?> </div> |
---|
[144] | 45 | |
---|
[167] | 46 | <div id="seqContent"> |
---|
| 47 | <div id="seqContentWrapper"></div> |
---|
| 48 | </div> |
---|
[153] | 49 | |
---|
[144] | 50 | <div id="controls"> |
---|
[167] | 51 | <input type="button" id="moveSelectedL" value="< Move" class="surveyButton" onClick="moveStep(-1);" /> |
---|
| 52 | <input type="button" id="moveSelectedR" value="Move >" class="surveyButton" onClick="moveStep(1);" /> |
---|
| 53 | <input type="button" id="editSelected" value="Edit step" class="surveyButton" /> |
---|
[156] | 54 | <input type="submit" id="deleteSelected" name="deleteSelected" value="Delete step" class="surveyButton" /> |
---|
| 55 | <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/> |
---|
| 56 | <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear? |
---|
[167] | 57 | <input type="button" id="t_saveSession" name="t_saveSession" onClick="savePipeline(true);" value="t_Save_session!" /> |
---|
[164] | 58 | <input type="button" id="t_setOOD" name="t_setOOD" onClick="t_setOutOfDate();" value="t_Set_OOD" /> |
---|
| 59 | <input type="button" id="t_updateSeq" name="t_updateSeq" onClick="updateSequencer();" value="t_Update_Seq" /> |
---|
[144] | 60 | </div> |
---|
[154] | 61 | <div id="hiddenInputs"> |
---|
[153] | 62 | <input type="hidden" name="selectedStep" id="selectedStepField" value="" /> |
---|
[155] | 63 | <input type="hidden" name="pipelineString" id="pipelineStringField" value="<?php echo $stringPipeline; ?>" /> |
---|
[164] | 64 | <input type="hidden" name="pipelineTypes" id="pipelineTypeField" value="<?php echo $stringPipelineType; ?>" /> |
---|
| 65 | <input type="hidden" name="pipelineUpDated" id="pipelineUpdatedField" value="<?php echo $stringPipelineUpdated; ?>" /> |
---|
| 66 | <input type="hidden" name="numSteps" id="numSteps" value="<?php echo $numberOfSteps; ?>" /> |
---|
[166] | 67 | <input type="hidden" name="session" id="sessionField" value="<?php echo $this->loadedSession->uid; ?>" /> |
---|
[153] | 68 | </div> |
---|
[144] | 69 | </fieldset> |
---|
| 70 | </form> |
---|
| 71 | <?php |
---|
| 72 | } |
---|
| 73 | |
---|
[146] | 74 | public function DrawSteps() { |
---|
[153] | 75 | // Use AJAX to draw visual representations of step objects in a pipeline |
---|
| 76 | // <TODO> Implement parameters such as screen size in the drawing of objects </TODO> |
---|
| 77 | ?> |
---|
| 78 | <script type="text/javascript"> |
---|
| 79 | drawSteps(); |
---|
| 80 | </script> |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | <?php |
---|
[146] | 84 | } |
---|
| 85 | |
---|
[153] | 86 | public function Javascript() { |
---|
[150] | 87 | ?> |
---|
[152] | 88 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
[153] | 89 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
| 90 | <script type="text/javascript"> |
---|
| 91 | $(document).ready(function() { |
---|
[167] | 92 | updateSequencer(); |
---|
[153] | 93 | }); |
---|
| 94 | </script> |
---|
[150] | 95 | <?php |
---|
| 96 | } |
---|
| 97 | |
---|
[163] | 98 | public function LoadSession($currentSession) { // Initialize variables on page load. |
---|
[152] | 99 | if (!isset($currentSession)) { |
---|
| 100 | redirect("selectSession.php"); |
---|
[151] | 101 | } |
---|
[163] | 102 | if (isset($_SESSION['updateNeeded'])) { // user has performed an operation that flags session to be reloaded from DB, or is first load of page for that session |
---|
| 103 | $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession)); |
---|
[166] | 104 | |
---|
[163] | 105 | if (count($sessionResults) > 0) { |
---|
| 106 | $_SESSION['localSessionCopy'] = $sessionResults[0]; |
---|
[164] | 107 | unset($_SESSION['updateNeeded']); |
---|
[163] | 108 | } else { |
---|
| 109 | die("No session with that UID found!"); |
---|
| 110 | } |
---|
[152] | 111 | } |
---|
[166] | 112 | |
---|
[163] | 113 | if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { |
---|
[166] | 114 | |
---|
[163] | 115 | $this->loadedSession = $_SESSION['localSessionCopy']; |
---|
| 116 | unset($_SESSION['updateNeeded']); |
---|
| 117 | } |
---|
[151] | 118 | } |
---|
| 119 | |
---|
[154] | 120 | public function HandlePostData() { |
---|
| 121 | if (isset($_POST['editSelected'])) { |
---|
| 122 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
| 123 | redirect("editredirect.php"); |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | if (isset($_POST['moveSelectedLeft'])) { |
---|
| 128 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
[164] | 129 | $this->MoveStep($_POST['selectedStep'], -1); |
---|
[154] | 130 | } |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | if (isset($_POST['moveSelectedRight'])) { |
---|
| 134 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
[164] | 135 | $this->MoveStep($_POST['selectedStep'], 1); |
---|
[154] | 136 | } |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | if (isset($_POST['objectToCreate']) && !empty($_POST['objectToCreate'])) { |
---|
| 140 | switch (strtolower($_POST['objectToCreate'])) { |
---|
| 141 | case "survey": |
---|
| 142 | redirect("createsurvey.php"); |
---|
| 143 | break; |
---|
| 144 | case "application": |
---|
| 145 | redirect("createapplication.php"); |
---|
| 146 | break; |
---|
| 147 | case "dashboard": |
---|
| 148 | redirect("createdashboard.php"); |
---|
| 149 | break; |
---|
| 150 | default: |
---|
| 151 | // Er is iets fout gegaan, want er is geen valid type meegegeven! |
---|
| 152 | break; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | // Dit is een pure php versie. Deze slaat nog niet op in de Database, en reageert nog niet op |
---|
| 158 | public function MoveStep($uid, $direction) { |
---|
| 159 | $newSession = $this->loadedSession; |
---|
| 160 | |
---|
| 161 | for ($i = 0; $i < count($newSession->pipeline); $i++) { |
---|
[164] | 162 | if ($newSession->pipeline[$i]->uid == $uid) { |
---|
| 163 | $temp = $newSession->pipeline[$i]; |
---|
| 164 | $newSession->pipeline[$i] = $newSession->pipeline[$i + $direction]; |
---|
| 165 | $newSession->pipeline[$i + $direction] = $temp; |
---|
[154] | 166 | break; |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | $this->loadedSession = $newSession; |
---|
[164] | 171 | redirect("pipelineEditor.php"); |
---|
[154] | 172 | } |
---|
| 173 | |
---|
[144] | 174 | } |
---|
| 175 | ?> |
---|