source: Dev/trunk/returnStep.php @ 153

Last change on this file since 153 was 153, checked in by fpvanagthoven, 13 years ago
File size: 3.7 KB
Line 
1<?php
2
3require 'classes/master.php'; //should be at top of every page
4/*
5 * Return the HTML markup for visualisation of an object in a pipeline, to be used in the PipelineSequencer.php
6 * Called by PipelineSequencer, posting UID of the step in question.
7 *  TODO: Selection code. Onload doen of serverside?
8 * Javascript voor selection scripts staat ook nog niet in de -onclick- property, eerst dat script uitzoeken, daarna pas invoegen.
9 */
10
11// Check if calling script actually passed a uid to use
12if (isset($_POST['uid'])) {
13    if (!empty($_POST['uid'])) {
14        $uid = $_POST['uid'];
15    } else {
16        echo "Invalid UID passed!";
17    }
18} else {
19    echo "No UID passed!";
20}
21
22
23
24if ($uid == "123") {        // test case for when steps aren't actually working
25    $imageURL = "images/icons/unknowntype.png";
26    $response = '<div class="displayStep" id="' . "123" . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';
27    echo $response;
28}
29else if($uid == '456') {
30    $imageURL = "images/icons/unknowntype.png";
31    $response = '<div class="displayStep" id="' . "456" . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';
32    echo $response;
33}
34else {
35   
36
37    if ($uid == "divider") {    //a divider has been requested instead of a displaystep
38        $response = '<div class="divider"></div>';
39        echo $response;
40    } else {        // an actual step has been requested.
41
42
43        $dbi = new DatabaseInterface();
44//Check in order: survey, application, dashboard.
45        $result = null;
46        $resultType = null;
47        $surveys = $dbi->get("Survey", array("uid" => $uid));
48        if (count($surveys) > 0) {
49            if ($surveys[0] != null) {
50                // A survey exists with the given UID!
51                $result = $surveys[0];
52                $resultType = "Survey";
53            }
54        }
55
56        if (result != null) {
57            $applications = $dbi->get("Application", array("uid" => $uid));
58            if (count($applications) > 0) {
59                if ($applications[0] != null) {
60                    // An application exists with the given UID!
61                    $result = $applications[0];
62                    $resultType = "Application";
63                }
64            }
65        }
66
67        if (result != null) {
68            $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
69            if (count($dashboards) > 0) {
70                if ($dashboards[0] != null) {
71                    // A dashboard exists with the given UID!
72                    $result = $dashboards[0];
73                    $resultType = "Dashboard";
74                }
75            }
76        }
77
78// If result is still null at this point, the passed UID does not refer to an existing object!
79        if ($result == null || $resultType == null) {
80            echo "Non-existing UID passed!";
81        } else {
82
83            // set relevant variables based on the type and properties of the step in question (currently stored in $result)
84            switch (strtolower($resultType)) {
85                case "questionnaire":
86                    $imageURL = "images/icons/questionnaire.png";
87                    break;
88                case "dashboard":
89                    $imageURL = "images/icons/dashboard.png";
90                    break;
91                case "application":
92                    $imageURL = "images/icons/application.png";
93                    break;
94                default:
95                    $imageURL = "images/icons/unknowntype.png";
96                    break;
97            }
98
99//echo out the HTML markup
100            $response = '<div class="displayStep" id="' . $result->uid . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
101            echo $response;
102        }
103    }
104}
105?>
Note: See TracBrowser for help on using the repository browser.