[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) . ","; |
---|
[164] | 33 | $stringPipelineUpdated .= "1,"; |
---|
| 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"> |
---|
[152] | 44 | <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div> |
---|
[144] | 45 | |
---|
[154] | 46 | <div id="seqContent"></div> |
---|
[153] | 47 | |
---|
[144] | 48 | <div id="controls"> |
---|
[156] | 49 | <input type="submit" id="moveSelectedLeft" name="moveSelectedLeft" value="< Move" class="surveyButton" /> |
---|
| 50 | <input type="submit" id="moveSelectedRight" name="moveSelectedRight" value="Move >" class="surveyButton" /> |
---|
| 51 | <input type="submit" id="editSelected" name="editSelected" value="Edit step" class="surveyButton" /> |
---|
| 52 | <input type="submit" id="deleteSelected" name="deleteSelected" value="Delete step" class="surveyButton" /> |
---|
| 53 | <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/> |
---|
| 54 | <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear? |
---|
[164] | 55 | <input type="button" id="t_saveSession" name="t_saveSession" onClick="savePipeline();" value="t_Save_session!" /> |
---|
| 56 | <input type="button" id="t_setOOD" name="t_setOOD" onClick="t_setOutOfDate();" value="t_Set_OOD" /> |
---|
| 57 | <input type="button" id="t_updateSeq" name="t_updateSeq" onClick="updateSequencer();" value="t_Update_Seq" /> |
---|
[144] | 58 | </div> |
---|
[154] | 59 | <div id="hiddenInputs"> |
---|
[153] | 60 | <input type="hidden" name="selectedStep" id="selectedStepField" value="" /> |
---|
[155] | 61 | <input type="hidden" name="pipelineString" id="pipelineStringField" value="<?php echo $stringPipeline; ?>" /> |
---|
[164] | 62 | <input type="hidden" name="pipelineTypes" id="pipelineTypeField" value="<?php echo $stringPipelineType; ?>" /> |
---|
| 63 | <input type="hidden" name="pipelineUpDated" id="pipelineUpdatedField" value="<?php echo $stringPipelineUpdated; ?>" /> |
---|
| 64 | <input type="hidden" name="numSteps" id="numSteps" value="<?php echo $numberOfSteps; ?>" /> |
---|
[166] | 65 | <input type="hidden" name="session" id="sessionField" value="<?php echo $this->loadedSession->uid; ?>" /> |
---|
[153] | 66 | </div> |
---|
[144] | 67 | </fieldset> |
---|
| 68 | </form> |
---|
| 69 | <?php |
---|
| 70 | } |
---|
| 71 | |
---|
[146] | 72 | public function DrawSteps() { |
---|
[153] | 73 | // Use AJAX to draw visual representations of step objects in a pipeline |
---|
| 74 | // <TODO> Implement parameters such as screen size in the drawing of objects </TODO> |
---|
| 75 | ?> |
---|
| 76 | <script type="text/javascript"> |
---|
| 77 | drawSteps(); |
---|
| 78 | </script> |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | <?php |
---|
[146] | 82 | } |
---|
| 83 | |
---|
[153] | 84 | public function Javascript() { |
---|
| 85 | $pipelineString = "ERROR"; |
---|
[154] | 86 | |
---|
[153] | 87 | echo "<!--$pipelineString-->"; |
---|
[150] | 88 | ?> |
---|
[152] | 89 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
[153] | 90 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
| 91 | <script type="text/javascript"> |
---|
| 92 | $(document).ready(function() { |
---|
| 93 | drawSteps(); |
---|
| 94 | }); |
---|
| 95 | </script> |
---|
[150] | 96 | <?php |
---|
| 97 | } |
---|
| 98 | |
---|
[163] | 99 | public function LoadSession($currentSession) { // Initialize variables on page load. |
---|
[152] | 100 | if (!isset($currentSession)) { |
---|
| 101 | redirect("selectSession.php"); |
---|
[151] | 102 | } |
---|
[163] | 103 | 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 |
---|
| 104 | $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession)); |
---|
[166] | 105 | |
---|
[163] | 106 | if (count($sessionResults) > 0) { |
---|
| 107 | $_SESSION['localSessionCopy'] = $sessionResults[0]; |
---|
[164] | 108 | unset($_SESSION['updateNeeded']); |
---|
[163] | 109 | } else { |
---|
| 110 | die("No session with that UID found!"); |
---|
| 111 | } |
---|
[152] | 112 | } |
---|
[166] | 113 | |
---|
[163] | 114 | if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { |
---|
[166] | 115 | |
---|
[163] | 116 | $this->loadedSession = $_SESSION['localSessionCopy']; |
---|
| 117 | unset($_SESSION['updateNeeded']); |
---|
| 118 | } |
---|
[151] | 119 | } |
---|
| 120 | |
---|
[154] | 121 | public function HandlePostData() { |
---|
| 122 | if (isset($_POST['editSelected'])) { |
---|
| 123 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
| 124 | redirect("editredirect.php"); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | if (isset($_POST['moveSelectedLeft'])) { |
---|
| 129 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
[164] | 130 | $this->MoveStep($_POST['selectedStep'], -1); |
---|
[154] | 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | if (isset($_POST['moveSelectedRight'])) { |
---|
| 135 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
[164] | 136 | $this->MoveStep($_POST['selectedStep'], 1); |
---|
[154] | 137 | } |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | if (isset($_POST['objectToCreate']) && !empty($_POST['objectToCreate'])) { |
---|
| 141 | switch (strtolower($_POST['objectToCreate'])) { |
---|
| 142 | case "survey": |
---|
| 143 | redirect("createsurvey.php"); |
---|
| 144 | break; |
---|
| 145 | case "application": |
---|
| 146 | redirect("createapplication.php"); |
---|
| 147 | break; |
---|
| 148 | case "dashboard": |
---|
| 149 | redirect("createdashboard.php"); |
---|
| 150 | break; |
---|
| 151 | default: |
---|
| 152 | // Er is iets fout gegaan, want er is geen valid type meegegeven! |
---|
| 153 | break; |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | // Dit is een pure php versie. Deze slaat nog niet op in de Database, en reageert nog niet op |
---|
| 159 | public function MoveStep($uid, $direction) { |
---|
| 160 | $newSession = $this->loadedSession; |
---|
| 161 | |
---|
| 162 | for ($i = 0; $i < count($newSession->pipeline); $i++) { |
---|
[164] | 163 | if ($newSession->pipeline[$i]->uid == $uid) { |
---|
| 164 | $temp = $newSession->pipeline[$i]; |
---|
| 165 | $newSession->pipeline[$i] = $newSession->pipeline[$i + $direction]; |
---|
| 166 | $newSession->pipeline[$i + $direction] = $temp; |
---|
[154] | 167 | break; |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | $this->loadedSession = $newSession; |
---|
[164] | 172 | redirect("pipelineEditor.php"); |
---|
[154] | 173 | } |
---|
| 174 | |
---|
[144] | 175 | } |
---|
| 176 | ?> |
---|