1 | <?php |
---|
2 | /* |
---|
3 | * To change this template, choose Tools | Templates |
---|
4 | * and open the template in the editor. |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * A visual interface object for editing and viewing a session's pipeline. |
---|
9 | * |
---|
10 | * @author Tschipper |
---|
11 | */ |
---|
12 | class PipelineSequencer { |
---|
13 | |
---|
14 | // properties |
---|
15 | private $loadedSession; |
---|
16 | private $selectedStep; |
---|
17 | |
---|
18 | public function __construct() { |
---|
19 | //nothing yet |
---|
20 | } |
---|
21 | |
---|
22 | public function init() { |
---|
23 | $stringPipeline = ""; |
---|
24 | if (is_array($this->loadedSession->pipeline)){ |
---|
25 | foreach ($this->loadedSession->pipeline as $object) { |
---|
26 | $stringPipeline .= "$object->uid,"; |
---|
27 | } |
---|
28 | $stringPipeline = rtrim($stringPipeline, ","); |
---|
29 | } |
---|
30 | else { |
---|
31 | $stringPipeline = $this->loadedSession->pipeline; |
---|
32 | } |
---|
33 | ?> |
---|
34 | <br /><form name="sequencerForm" action="pipelineEditor.php" method="post"> |
---|
35 | <fieldset id="sequencer"> |
---|
36 | <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div> |
---|
37 | |
---|
38 | <div id="seqContent"></div> |
---|
39 | |
---|
40 | <div id="controls"> |
---|
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? |
---|
47 | </div> |
---|
48 | <div id="hiddenInputs"> |
---|
49 | <input type="hidden" name="selectedStep" id="selectedStepField" value="" /> |
---|
50 | <!-- <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456" /> --> |
---|
51 | <input type="hidden" name="pipelineString" id="pipelineStringField" value="<?php echo $stringPipeline; ?>" /> |
---|
52 | </div> |
---|
53 | </fieldset> |
---|
54 | </form> |
---|
55 | <?php |
---|
56 | } |
---|
57 | |
---|
58 | public function DrawSteps() { |
---|
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 |
---|
68 | } |
---|
69 | |
---|
70 | public function Javascript() { |
---|
71 | $pipelineString = "ERROR"; |
---|
72 | |
---|
73 | echo "<!--$pipelineString-->"; |
---|
74 | ?> |
---|
75 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
76 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
77 | <script type="text/javascript"> |
---|
78 | $(document).ready(function() { |
---|
79 | drawSteps(); |
---|
80 | }); |
---|
81 | </script> |
---|
82 | <?php |
---|
83 | } |
---|
84 | |
---|
85 | public function GetFromDB($currentSession) { // Initialize variables on page load. |
---|
86 | $dbi = new DatabaseInterface(); |
---|
87 | if (!isset($currentSession)) { |
---|
88 | $_SESSION['message'] = "No session set!"; |
---|
89 | redirect("selectSession.php"); |
---|
90 | } |
---|
91 | |
---|
92 | $sessionResults = $dbi->get("Session", array("uid" => $currentSession)); |
---|
93 | if (count($sessionResults) > 0) { |
---|
94 | $this->loadedSession = $sessionResults[0]; |
---|
95 | } else { //No session with that UID found in database! |
---|
96 | die("Invalid session!"); |
---|
97 | } |
---|
98 | var_dump($this->loadedSession->pipeline); |
---|
99 | } |
---|
100 | |
---|
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 | |
---|
154 | } |
---|
155 | ?> |
---|