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