1 | <!-- |
---|
2 | To change this template, choose Tools | Templates |
---|
3 | and open the template in the editor. |
---|
4 | --> |
---|
5 | <?php |
---|
6 | /* |
---|
7 | * Return the HTML markup for visualisation of an object in a pipeline, to be used in the PipelineSequencer.php |
---|
8 | * Called by PipelineSequencer, posting UID of the step in question. |
---|
9 | * TODO: Selection code. Onload doen of serverside? |
---|
10 | * Javascript voor selection scripts staat ook nog niet in de -onclick- property, eerst dat script uitzoeken, daarna pas invoegen. |
---|
11 | */ |
---|
12 | |
---|
13 | // Check if calling script actually passed a uid to use |
---|
14 | if (isset($_POST['uid'])) { |
---|
15 | if (!empty($_POST['uid'])) { |
---|
16 | $uid = $_POST['uid']; |
---|
17 | } else { |
---|
18 | echo "Invalid UID passed!"; |
---|
19 | } |
---|
20 | } else { |
---|
21 | echo "No UID passed!"; |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | $dbi = new DatabaseInterface(); |
---|
26 | //Check in order: survey, application, dashboard. |
---|
27 | $result = null; |
---|
28 | $resultType = null; |
---|
29 | $surveys = $dbi->get("Survey", array("uid" => $uid)); |
---|
30 | if (count($surveys) > 0) { |
---|
31 | if ($surveys[0] != null) { |
---|
32 | // A survey exists with the given UID! |
---|
33 | $result = $surveys[0]; |
---|
34 | $resultType = "Survey"; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | if (result != null) { |
---|
39 | $applications = $dbi->get("Application", array("uid" => $uid)); |
---|
40 | if (count($applications) > 0) { |
---|
41 | if ($applications[0] != null) { |
---|
42 | // An application exists with the given UID! |
---|
43 | $result = $applications[0]; |
---|
44 | $resultType = "Application"; |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | if (result != null) { |
---|
50 | $dashboards = $dbi->get("Dashboard", array("uid" => $uid)); |
---|
51 | if (count($dashboards) > 0) { |
---|
52 | if ($dashboards[0] != null) { |
---|
53 | // A dashboard exists with the given UID! |
---|
54 | $result = $dashboards[0]; |
---|
55 | $resultType = "Dashboard"; |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | // If result is still null at this point, the passed UID does not refer to an existing object! |
---|
61 | if ($result == null || $resultType == null) { |
---|
62 | echo "Non-existing UID passed!"; |
---|
63 | } else { |
---|
64 | |
---|
65 | // set relevant variables based on the type and properties of the step in question (currently stored in $result) |
---|
66 | switch (strtolower($resultType)) { |
---|
67 | case "questionnaire": |
---|
68 | $imageURL = "images/icons/questionnaire.png"; |
---|
69 | break; |
---|
70 | case "dashboard": |
---|
71 | $imageURL = "images/icons/dashboard.png"; |
---|
72 | break; |
---|
73 | case "application": |
---|
74 | $imageURL = "images/icons/application.png"; |
---|
75 | break; |
---|
76 | default: |
---|
77 | $imageURL = "images/icons/unknowntype.png"; |
---|
78 | break; |
---|
79 | } |
---|
80 | |
---|
81 | //echo out the HTML markup |
---|
82 | $response = '<div class="displayStep" id="' . $result->uid . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>'; |
---|
83 | echo $response; |
---|
84 | } |
---|
85 | ?> |
---|