Ignore:
Timestamp:
01/13/12 13:57:41 (13 years ago)
Author:
fpvanagthoven
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/jos-branch/returnObjectDisplay.php

    r208 r233  
    33require 'classes/master.php';
    44
    5 /* 
     5/*
    66 * 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.
    77 * 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
     
    99
    1010
    11 if(isset($_POST['args']) && !empty($_POST['args'])) {
     11if (isset($_POST['args']) && !empty($_POST['args'])) {
    1212    // Get arguments and convert to object
    1313    $input = $_POST['args'];
     
    1717}
    1818
    19 $dbi = new DatabaseInterface();
    2019$outputArray = array();
    2120foreach ($requestArray as $request) {
     21
     22    $type = $request->type;
     23    $results = $type::get(array("uid" => $request->uid));
    2224   
    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     }
    3125    if (isset($results) && !empty($results)) {
    3226        is_array($results) ? $object = $results[0] : $object = $results;
     27        if ($object->evaluate()) {
     28            $object->ObjectType = $type;
     29            $outputArray[] = $object;
     30        }
    3331    }
    3432    // We now have the targeted object loaded in memory
    3533    // 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;
    4634}
    4735
    48 
    4936// Encode the output array in JSON format, then send back to the client
    50 $output = json_encode($outputArray);
    51 
    52 die($output);
     37if (!empty($outputArray)) {
     38    echo JSON_encode($outputArray);
     39}
    5340?>
Note: See TracChangeset for help on using the changeset viewer.