[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; |
---|
| 17 | |
---|
[152] | 18 | public function __construct() { |
---|
| 19 | //nothing yet |
---|
[146] | 20 | } |
---|
[144] | 21 | |
---|
[150] | 22 | public function init() { |
---|
[153] | 23 | $stringPipeline = ""; |
---|
[156] | 24 | if (is_array($this->loadedSession->pipeline)){ |
---|
[153] | 25 | foreach ($this->loadedSession->pipeline as $object) { |
---|
| 26 | $stringPipeline .= "$object->uid,"; |
---|
| 27 | } |
---|
| 28 | $stringPipeline = rtrim($stringPipeline, ","); |
---|
[156] | 29 | } |
---|
| 30 | else { |
---|
| 31 | $stringPipeline = $this->loadedSession->pipeline; |
---|
| 32 | } |
---|
[144] | 33 | ?> |
---|
[154] | 34 | <br /><form name="sequencerForm" action="pipelineEditor.php" method="post"> |
---|
[151] | 35 | <fieldset id="sequencer"> |
---|
[152] | 36 | <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div> |
---|
[144] | 37 | |
---|
[154] | 38 | <div id="seqContent"></div> |
---|
[153] | 39 | |
---|
[144] | 40 | <div id="controls"> |
---|
[156] | 41 | <input type="submit" id="moveSelectedLeft" name="moveSelectedLeft" value="< Move" class="surveyButton" /> |
---|
| 42 | <input type="submit" id="moveSelectedRight" name="moveSelectedRight" value="Move >" class="surveyButton" /> |
---|
| 43 | <input type="submit" id="editSelected" name="editSelected" value="Edit step" class="surveyButton" /> |
---|
| 44 | <input type="submit" id="deleteSelected" name="deleteSelected" value="Delete step" class="surveyButton" /> |
---|
| 45 | <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/> |
---|
| 46 | <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear? |
---|
[144] | 47 | </div> |
---|
[154] | 48 | <div id="hiddenInputs"> |
---|
[153] | 49 | <input type="hidden" name="selectedStep" id="selectedStepField" value="" /> |
---|
[155] | 50 | <!-- <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456" /> --> |
---|
| 51 | <input type="hidden" name="pipelineString" id="pipelineStringField" value="<?php echo $stringPipeline; ?>" /> |
---|
[153] | 52 | </div> |
---|
[144] | 53 | </fieldset> |
---|
| 54 | </form> |
---|
| 55 | <?php |
---|
| 56 | } |
---|
| 57 | |
---|
[146] | 58 | public function DrawSteps() { |
---|
[153] | 59 | // Use AJAX to draw visual representations of step objects in a pipeline |
---|
| 60 | // <TODO> Implement parameters such as screen size in the drawing of objects </TODO> |
---|
| 61 | ?> |
---|
| 62 | <script type="text/javascript"> |
---|
| 63 | drawSteps(); |
---|
| 64 | </script> |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | <?php |
---|
[146] | 68 | } |
---|
| 69 | |
---|
[153] | 70 | public function Javascript() { |
---|
| 71 | $pipelineString = "ERROR"; |
---|
[154] | 72 | |
---|
[153] | 73 | echo "<!--$pipelineString-->"; |
---|
[150] | 74 | ?> |
---|
[152] | 75 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
[153] | 76 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
| 77 | <script type="text/javascript"> |
---|
| 78 | $(document).ready(function() { |
---|
| 79 | drawSteps(); |
---|
| 80 | }); |
---|
| 81 | </script> |
---|
[150] | 82 | <?php |
---|
| 83 | } |
---|
| 84 | |
---|
[152] | 85 | public function GetFromDB($currentSession) { // Initialize variables on page load. |
---|
[151] | 86 | $dbi = new DatabaseInterface(); |
---|
[152] | 87 | if (!isset($currentSession)) { |
---|
| 88 | $_SESSION['message'] = "No session set!"; |
---|
| 89 | redirect("selectSession.php"); |
---|
[151] | 90 | } |
---|
[153] | 91 | |
---|
[152] | 92 | $sessionResults = $dbi->get("Session", array("uid" => $currentSession)); |
---|
| 93 | if (count($sessionResults) > 0) { |
---|
| 94 | $this->loadedSession = $sessionResults[0]; |
---|
[154] | 95 | } else { //No session with that UID found in database! |
---|
[152] | 96 | die("Invalid session!"); |
---|
| 97 | } |
---|
[156] | 98 | var_dump($this->loadedSession->pipeline); |
---|
[151] | 99 | } |
---|
| 100 | |
---|
[154] | 101 | public function HandlePostData() { |
---|
| 102 | if (isset($_POST['editSelected'])) { |
---|
| 103 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
| 104 | redirect("editredirect.php"); |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | if (isset($_POST['moveSelectedLeft'])) { |
---|
| 109 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
| 110 | MoveStep($_POST['selectedStep'], -1); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | if (isset($_POST['moveSelectedRight'])) { |
---|
| 115 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
| 116 | MoveStep($_POST['selectedStep'], 1); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | if (isset($_POST['objectToCreate']) && !empty($_POST['objectToCreate'])) { |
---|
| 121 | switch (strtolower($_POST['objectToCreate'])) { |
---|
| 122 | case "survey": |
---|
| 123 | redirect("createsurvey.php"); |
---|
| 124 | break; |
---|
| 125 | case "application": |
---|
| 126 | redirect("createapplication.php"); |
---|
| 127 | break; |
---|
| 128 | case "dashboard": |
---|
| 129 | redirect("createdashboard.php"); |
---|
| 130 | break; |
---|
| 131 | default: |
---|
| 132 | // Er is iets fout gegaan, want er is geen valid type meegegeven! |
---|
| 133 | break; |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | // Dit is een pure php versie. Deze slaat nog niet op in de Database, en reageert nog niet op |
---|
| 139 | public function MoveStep($uid, $direction) { |
---|
| 140 | $newSession = $this->loadedSession; |
---|
| 141 | |
---|
| 142 | for ($i = 0; $i < count($newSession->pipeline); $i++) { |
---|
| 143 | if ($newSession->pipeline[i]->uid == $uid) { |
---|
| 144 | $temp = $newSession->pipeline[i]; |
---|
| 145 | $newSession->pipeline[i] = $newSession->pipeline[i + $direction]; |
---|
| 146 | $newSession->pipeline[i + $direction] = $newSession->pipeline[i]; |
---|
| 147 | break; |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | $this->loadedSession = $newSession; |
---|
| 152 | } |
---|
| 153 | |
---|
[144] | 154 | } |
---|
| 155 | ?> |
---|