source: Dev/branches/jQueryUI/client/pages_old/getInfo.php @ 254

Last change on this file since 254 was 249, checked in by hendrikvanantwerpen, 13 years ago

This one's for Subversion, because it's so close...

First widget (stripped down sequencer).
Seperated client and server code in two direcotry trees.

File size: 3.6 KB
Line 
1<?php
2
3require 'classes/master.php'; //should be at top of every page
4
5if (isset($_POST['uid']) && isset($_POST['type'])) {
6    if (!empty($_POST['uid']) && !empty($_POST['type'])) {
7        $uid = $_POST['uid'];
8        $type = $_POST['type'];
9    } else {
10//$errors[] = "No uid passed!";
11        return;
12    }
13} else {
14//$errors[] = "Wrong call, no uid property in POST data!";
15    return;
16}
17
18
19$results = $type::get(array("uid" => $uid));
20
21if (count($results) > 0) {      // check if DB object exists and assign it to variable
22    if ($results[0] != null) {
23        $returnString = "";
24        $result = $results[0];
25    } else
26        return;
27} else
28    return;
29
30// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31// Note: the next part needs to be converted to JSON operation, so that the javascript can easily handle any style changes to the information retrieved. This implementation is just silly.
32// Basic idea: return a JSON array of property: value pairs, then let javascript loop through these properties and format them suitably. This is both more flexible and easier to adjust, as well as resulting in smaller packets.
33// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
34
35switch ($type) {
36    case "Session":
37        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
38        $result->evaluate();
39        $returnString .= "<span class='property'>Created: </span><span class='value'>" . $result->creationdate->format("H:i:s, d-m-Y") . " by " . $result->creator->name . "</span>";
40        $cS = 0; $cD = 0; $cA = 0;
41        foreach ($result->pipeline as $step) {
42            switch (get_class($step)){
43                case "Survey":
44                    $cS++;
45                    break;
46                case "Application":
47                    $cA++;
48                    break;
49                case "Dashboard":
50                    $cD++;
51                    break;
52                default:
53                    //derp?
54                    break;
55            }
56        }
57        $returnString .= "<span class='property'>Number of steps: </span><span class='value'><ul style='list-style-type: none;'><li style='margin-left: -40px;'>$cS Surveys<li style='margin-left: -40px;'>$cA Applications<li style='margin-left: -40px;'>$cD Dashboards</ul></span>";
58        break;
59    case "Survey":
60        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
61        $returnString .= "<span class='property'>Creator: </span><span class='value'>LOLOL ME!!!</span>";
62        $qCount = 0;
63        $qCount = count($result->questions);
64        $returnString .= "<span class='property'>Questions: </span><span class='value'>$qCount</span>";
65        $returnString .= "<span class='property'>Description: </span><span class='value'>$result->description</span>";
66        break;
67    case "Application":
68        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
69        $returnString .= "<span class='property'>Path: </span><span class='value'>C:/folder_of_awesomeness/epicgame.exe</span>";
70        $returnString .= "<span class='property'>Description: </span><span class='value'>$result->description</span>";
71        break;
72    case "Dashboard":
73        break;
74    case "Respondent":
75        break;
76    case "Question":
77        break;
78    case "Answer":
79        break;
80    default:
81        break;
82}
83
84echo $returnString;
85?>
Note: See TracBrowser for help on using the repository browser.