source: Dev/trunk/returnObjectDisplay.php @ 188

Last change on this file since 188 was 188, checked in by fpvanagthoven, 13 years ago
File size: 1.7 KB
Line 
1<?php
2
3require 'classes/master.php';
4
5/*
6 * Note: do not try to implement info panel displays in this file as well, it passes and queries a lot of data that you really do not need.
7 * Since this function will be used so often, adding extra unneeded code to it will slow down the regular operation of the editor (refreshes, etc..) while not offering a significant advantage over the existing getInfo.php
8 */
9
10
11if(isset($_POST['args']) && !empty($_POST['args'])) {
12    // Get arguments and convert to object
13    $input = $_POST['args'];
14    $requestArray = json_decode($input);
15} else {
16    die('DOESNT WORK...');
17}
18
19$dbi = new DatabaseInterface();
20$outputArray = array();
21foreach ($requestArray as $request) {
22   
23    $results = $dbi->get($request->type, array("code" => $request->uid));
24    // Bottom line, werkt prima. Questions werken nu op ns1:question_code, accessible als question->code
25   
26    if (isset($results) && !empty($results)) {
27        is_array($results) ? $object = $results[0] : $object = $results;
28    }
29    // We now have the targeted object loaded in memory
30    // First add all shared properties
31    $objectProperties = array(
32        "uid" => $object->uid,
33        "title" => $object->title,
34        "type" => get_class($object),
35        "description" => $object->description
36    );
37    // Then add object-specific properties? (E.G. pipeline for sessions, answertype for questions, age for respondents)
38    // Nothing so far, though, because data structure changes all the time...
39    // Then add the resulting array to the outputArray
40    $outputArray[] = $objectProperties;
41}
42
43
44// Encode the output array in JSON format, then send back to the client
45$output = json_encode($outputArray);
46
47die($output);
48?>
Note: See TracBrowser for help on using the repository browser.