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 | private $dbi; |
---|
18 | |
---|
19 | public function __construct() { |
---|
20 | $this->dbi = new DatabaseInterface(); |
---|
21 | } |
---|
22 | |
---|
23 | public function init() { |
---|
24 | $stringPipeline = ""; |
---|
25 | $stringPipelineType = ""; |
---|
26 | $stringPipelineUpdated = ""; |
---|
27 | $numberOfSteps = 0; |
---|
28 | |
---|
29 | if (is_array($this->loadedSession->pipeline)) { |
---|
30 | foreach ($this->loadedSession->pipeline as $object) { |
---|
31 | $stringPipeline .= "$object->uid,"; |
---|
32 | $stringPipelineType .= get_class($object) . ","; |
---|
33 | $stringPipelineUpdated .= "0,"; |
---|
34 | $numberOfSteps++; |
---|
35 | } |
---|
36 | } else { |
---|
37 | $stringPipeline = $this->loadedSession->pipeline; |
---|
38 | $stringPipelineType = $_POST['pipelineTypes']; |
---|
39 | $stringPipelineUpdated = $_POST['pipelineUpdatedField']; |
---|
40 | } |
---|
41 | ?> |
---|
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"> |
---|
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; ?>" /> |
---|
69 | </div> |
---|
70 | </div> |
---|
71 | |
---|
72 | |
---|
73 | <?php |
---|
74 | } |
---|
75 | |
---|
76 | public function Javascript() { |
---|
77 | ?> |
---|
78 | <script type="text/javascript" src="js/generalScripts.js"></script> |
---|
79 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
80 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
81 | <script type="text/javascript"> |
---|
82 | $(document).ready(function() { |
---|
83 | loadSequencer(); // true means it is the first refresh of the page. |
---|
84 | }); |
---|
85 | </script> |
---|
86 | <?php |
---|
87 | } |
---|
88 | |
---|
89 | public function LoadSession($currentSession) { // Initialize variables on page load. |
---|
90 | if (!isset($currentSession)) { |
---|
91 | redirect("selectSession.php"); |
---|
92 | } |
---|
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)); |
---|
95 | |
---|
96 | if (count($sessionResults) > 0) { |
---|
97 | $_SESSION['localSessionCopy'] = $sessionResults[0]; |
---|
98 | unset($_SESSION['updateNeeded']); |
---|
99 | } else { |
---|
100 | die("No session with that UID found!"); |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { |
---|
105 | |
---|
106 | $this->loadedSession = $_SESSION['localSessionCopy']; |
---|
107 | unset($_SESSION['updateNeeded']); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
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'])) { |
---|
120 | $this->MoveStep($_POST['selectedStep'], -1); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | if (isset($_POST['moveSelectedRight'])) { |
---|
125 | if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) { |
---|
126 | $this->MoveStep($_POST['selectedStep'], 1); |
---|
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 | |
---|
148 | } |
---|
149 | ?> |
---|