source: Dev/trunk/returnStep.php @ 164

Last change on this file since 164 was 163, checked in by fpvanagthoven, 13 years ago
  • Basically alles gefixt om te werken met een local copy van de session, opgeslagen in $_SESSIONlocalSessionCopy?.
  • Flag $_SESSIONupdateNeeded? toegevoegd om aan te geven wanneer er een update uit de database nodig is in plaats van gewoon verder werken met de local copy.
  • '123'/'456' placeholder routine weggehaald uit returnStep.php
  • CreateObject? doet nog niets, maar dat komt volgende week! (AJAX-aangestuurd object creation, met als doel: pipeline editing zonder constante page refreshes).
File size: 3.9 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['uids'])) {
13    if (!empty($_POST['uids'])) {
14        $uids = $_POST['uids'];
15    } else {
16        echo "Invalid UIDs passed!";
17        return;
18    }
19} else {
20    echo "No UID passed!";
21}
22
23$sUids = explode(",", $uids);
24$response = "";
25$dbi = new DatabaseInterface();
26foreach ($sUids as $uid) {
27    $response .= processUid($uid);
28}
29
30echo $response;
31
32
33/*
34 * ProcessUid needs to be changed once all the object classes are fixed. The '123', '456' test cases are not functional and are for testing puroses only.
35 * Additional onclick events for selecting objects would need to be added as well.
36 */
37
38
39
40function processUid($uid) {
41        $dbi = new DatabaseInterface();
42        if ($uid == "divider") {    //a divider has been requested instead of a displaystep
43            $responsePart = '<div class="divider"></div>';
44            return $responsePart;
45        } else {        // an actual step has been requested.
46           
47//Check in order: survey, application, dashboard.
48            $result = null;
49            $resultType = null;
50            $surveys = $dbi->get("Survey", array("uid" => $uid));
51            if (count($surveys) > 0) {
52                if ($surveys[0] != null) {
53                    // A survey exists with the given UID!
54                    $result = $surveys[0];
55                    $resultType = "Survey";
56                }
57            }
58
59            if ($result == null) {
60                $applications = $dbi->get("Application", array("uid" => $uid));
61                if (count($applications) > 0) {
62                    if ($applications[0] != null) {
63                        // An application exists with the given UID!
64                        $result = $applications[0];
65                        $resultType = "Application";
66                    }
67                }
68            }
69
70            if ($result == null) {
71                $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
72                if (count($dashboards) > 0) {
73                    if ($dashboards[0] != null) {
74                        // A dashboard exists with the given UID!
75                        $result = $dashboards[0];
76                        $resultType = "Dashboard";
77                    }
78                }
79            }
80
81// If result is still null at this point, the passed UID does not refer to an existing object!
82            if ($result == null || $resultType == null) {
83                echo "Non-existing UID passed!";
84            } else {
85
86                // set relevant variables based on the type and properties of the step in question (currently stored in $result)
87                switch (strtolower($resultType)) {
88                    case "survey":
89                        $imageURL = "images/icons/survey.png";
90                        break;
91                    case "dashboard":
92                        $imageURL = "images/icons/dashboard.png";
93                        break;
94                    case "application":
95                        $imageURL = "images/icons/application.png";
96                        break;
97                    default:
98                        $imageURL = "images/icons/unknowntype.png";
99                        break;
100                }
101
102//echo out the HTML markup
103                $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->title . '</div>';
104                return $responsePart;
105            }
106        }
107   
108}
109
110?>
Note: See TracBrowser for help on using the repository browser.