source: Dev/trunk/returnObjectDisplay.php @ 191

Last change on this file since 191 was 191, checked in by fpvanagthoven, 13 years ago
  • Clean up van bestanden die niet meer gebruikt worden/niet nodig zijn/zijn gemerged met bestaande files.
  • Daarnaast question/survey editor nu grotendeels werkend (min save functie...)
  • Inloggen werkt nu op userUid ipv naam, werkt beter met het aanmaken van creators.
  • Bug in returnObjectDisplay gefixt, er stond nog een var_dump tussen de echoes. JSON houdt niet van HTML tags.
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   
23    //!!! DEZE SHIT MOET WEER TERUGGEDRAAID WORDEN ZODRA QUESTIONS WEER GEWOON UIDS HEBBEN IPV CODES!
24    if ($request->type == "Question"){
25    $results = $dbi->get($request->type, array("code" => $request->uid));
26    // Bottom line, werkt prima. Questions werken nu op ns1:question_code, accessible als question->code
27    }
28    else {
29        $results =  $dbi->get($request->type, array("uid"=>$request->uid));
30    }
31    if (isset($results) && !empty($results)) {
32        is_array($results) ? $object = $results[0] : $object = $results;
33    }
34    // We now have the targeted object loaded in memory
35    // First add all shared properties
36    $objectProperties = array(
37        "uid" => $object->uid,
38        "title" => $object->title,
39        "type" => get_class($object),
40        "description" => $object->description
41    );
42    // Then add object-specific properties? (E.G. pipeline for sessions, answertype for questions, age for respondents)
43    // Nothing so far, though, because data structure changes all the time...
44    // Then add the resulting array to the outputArray
45    $outputArray[] = $objectProperties;
46}
47
48
49// Encode the output array in JSON format, then send back to the client
50$output = json_encode($outputArray);
51
52die($output);
53?>
Note: See TracBrowser for help on using the repository browser.