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