[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 | ?> |
---|
[178] | 42 | <br /> |
---|
| 43 | |
---|
| 44 | <div id="sequencer" class="largeFrame"> |
---|
| 45 | <div class="largeTitle">Name <?php echo $this->loadedSession->title; ?></div> |
---|
| 46 | |
---|
| 47 | <div id="seqContent" class="innerLargeFrame"> |
---|
| 48 | <div id="seqContentWrapper"></div> |
---|
| 49 | </div> |
---|
| 50 | |
---|
| 51 | <div class="controls"> |
---|
| 52 | <input type="button" id="moveSelectedL" value="< Move" class="smallButton" onClick="moveStep(-1);" /> |
---|
| 53 | <input type="button" id="moveSelectedR" value="Move >" class="smallButton" onClick="moveStep(1);" /> |
---|
| 54 | <input type="button" id="editSelected" value="Edit step" class="smallButton" onClick="editStep();" /> |
---|
| 55 | <input type="button" id="deleteSelected" value="Delete step" class="smallButton" onClick="deleteStep();" /> |
---|
| 56 | <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="smallButton dis" disabled="true"/> |
---|
| 57 | <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear? |
---|
| 58 | <input type="button" value="debug_save" onClick="savePipeline(true);" /> |
---|
| 59 | </div> |
---|
| 60 | |
---|
| 61 | <div id="hiddenInputs"> |
---|
[181] | 62 | <input type="hidden" id="selectedStepField" value="" /> |
---|
| 63 | <input type="hidden" id="pipelineStringField" value="<?php echo $stringPipeline; ?>" /> |
---|
| 64 | <input type="hidden" id="pipelineTypeField" value="<?php echo $stringPipelineType; ?>" /> |
---|
| 65 | <input type="hidden" id="pipelineUpdatedField" value="<?php echo $stringPipelineUpdated; ?>" /> |
---|
| 66 | <input type="hidden" id="numSteps" value="<?php echo $numberOfSteps; ?>" /> |
---|
| 67 | <input type="hidden" id="sessionField" value="<?php echo $this->loadedSession->uid; ?>" /> |
---|
| 68 | <input type="hidden" id="sessionTitleField" value="<?php echo $this->loadedSession->title; ?>" /> |
---|
[178] | 69 | </div> |
---|
| 70 | </div> |
---|
| 71 | |
---|
[181] | 72 | |
---|
[144] | 73 | <?php |
---|
| 74 | } |
---|
| 75 | |
---|
[153] | 76 | public function Javascript() { |
---|
[150] | 77 | ?> |
---|
[181] | 78 | <script type="text/javascript" src="js/generalScripts.js"></script> |
---|
[152] | 79 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
[153] | 80 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
| 81 | <script type="text/javascript"> |
---|
| 82 | $(document).ready(function() { |
---|
[181] | 83 | loadSequencer(); // true means it is the first refresh of the page. |
---|
[153] | 84 | }); |
---|
| 85 | </script> |
---|
[150] | 86 | <?php |
---|
| 87 | } |
---|
| 88 | |
---|
[163] | 89 | public function LoadSession($currentSession) { // Initialize variables on page load. |
---|
[152] | 90 | if (!isset($currentSession)) { |
---|
| 91 | redirect("selectSession.php"); |
---|
[151] | 92 | } |
---|
[163] | 93 | 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 |
---|
| 94 | $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession)); |
---|
[166] | 95 | |
---|
[163] | 96 | if (count($sessionResults) > 0) { |
---|
| 97 | $_SESSION['localSessionCopy'] = $sessionResults[0]; |
---|
[164] | 98 | unset($_SESSION['updateNeeded']); |
---|
[163] | 99 | } else { |
---|
| 100 | die("No session with that UID found!"); |
---|
| 101 | } |
---|
[152] | 102 | } |
---|
[166] | 103 | |
---|
[163] | 104 | if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { |
---|
[166] | 105 | |
---|
[163] | 106 | $this->loadedSession = $_SESSION['localSessionCopy']; |
---|
| 107 | unset($_SESSION['updateNeeded']); |
---|
| 108 | } |
---|
[151] | 109 | } |
---|
| 110 | |
---|
[154] | 111 | public function HandlePostData() { |
---|
| 112 | if (isset($_POST['editSelected'])) { |
---|
| 113 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
| 114 | redirect("editredirect.php"); |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | if (isset($_POST['moveSelectedLeft'])) { |
---|
| 119 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
[164] | 120 | $this->MoveStep($_POST['selectedStep'], -1); |
---|
[154] | 121 | } |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | if (isset($_POST['moveSelectedRight'])) { |
---|
| 125 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
[164] | 126 | $this->MoveStep($_POST['selectedStep'], 1); |
---|
[154] | 127 | } |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | if (isset($_POST['objectToCreate']) && !empty($_POST['objectToCreate'])) { |
---|
| 131 | switch (strtolower($_POST['objectToCreate'])) { |
---|
| 132 | case "survey": |
---|
| 133 | redirect("createsurvey.php"); |
---|
| 134 | break; |
---|
| 135 | case "application": |
---|
| 136 | redirect("createapplication.php"); |
---|
| 137 | break; |
---|
| 138 | case "dashboard": |
---|
| 139 | redirect("createdashboard.php"); |
---|
| 140 | break; |
---|
| 141 | default: |
---|
| 142 | // Er is iets fout gegaan, want er is geen valid type meegegeven! |
---|
| 143 | break; |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | |
---|
[144] | 148 | } |
---|
| 149 | ?> |
---|