source: Dev/trunk/returnObjectDisplay.php @ 185

Last change on this file since 185 was 185, checked in by fpvanagthoven, 13 years ago
File size: 1.9 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    var_dump($request);
23    $results = $dbi->get(strtolower($request->type), array("uid" => $request->uid));
24   
25    /*
26     * Reden voor deze var dumps is dat de questions niet gevonden kunnen worden. De bovenstaande regel returnet geen question object, ook als deze zeker weten wel bestaat.
27     * Even aan Jos vragen wat hier fout gaat?
28     */
29   
30   
31   
32   
33    var_dump($results);
34    if (isset($results) && !empty($results)) {
35        is_array($results) ? $object = $results[0] : $object = $results;
36    }
37    // We now have the targeted object loaded in memory
38    // First add all shared properties
39    $objectProperties = array(
40        "uid" => $object->uid,
41        "title" => $object->title,
42        "type" => get_class($object),
43        "description" => $object->description
44    );
45    // Then add object-specific properties? (E.G. pipeline for sessions, answertype for questions, age for respondents)
46    // Nothing so far, though, because data structure changes all the time...
47    // Then add the resulting array to the outputArray
48    $outputArray[] = $objectProperties;
49}
50
51
52// Encode the output array in JSON format, then send back to the client
53$output = json_encode($outputArray);
54
55die($output);
56?>
Note: See TracBrowser for help on using the repository browser.