Ignore:
Timestamp:
11/15/11 11:01:31 (13 years ago)
Author:
fpvanagthoven
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/returnStep.php

    r151 r153  
    1 <!--
    2 To change this template, choose Tools | Templates
    3 and open the template in the editor.
    4 -->
    51<?php
     2
     3require 'classes/master.php'; //should be at top of every page
    64/*
    75 * Return the HTML markup for visualisation of an object in a pipeline, to be used in the PipelineSequencer.php
     
    2321
    2422
    25 $dbi = new DatabaseInterface();
     23
     24if ($uid == "123") {        // test case for when steps aren't actually working
     25    $imageURL = "images/icons/unknowntype.png";
     26    $response = '<div class="displayStep" id="' . "123" . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';
     27    echo $response;
     28}
     29else if($uid == '456') {
     30    $imageURL = "images/icons/unknowntype.png";
     31    $response = '<div class="displayStep" id="' . "456" . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';
     32    echo $response;
     33}
     34else {
     35   
     36
     37    if ($uid == "divider") {    //a divider has been requested instead of a displaystep
     38        $response = '<div class="divider"></div>';
     39        echo $response;
     40    } else {        // an actual step has been requested.
     41
     42
     43        $dbi = new DatabaseInterface();
    2644//Check in order: survey, application, dashboard.
    27 $result = null;
    28 $resultType = null;
    29 $surveys = $dbi->get("Survey", array("uid" => $uid));
    30 if (count($surveys) > 0) {
    31     if ($surveys[0] != null) {
    32         // A survey exists with the given UID!
    33         $result = $surveys[0];
    34         $resultType = "Survey";
    35     }
    36 }
     45        $result = null;
     46        $resultType = null;
     47        $surveys = $dbi->get("Survey", array("uid" => $uid));
     48        if (count($surveys) > 0) {
     49            if ($surveys[0] != null) {
     50                // A survey exists with the given UID!
     51                $result = $surveys[0];
     52                $resultType = "Survey";
     53            }
     54        }
    3755
    38 if (result != null) {
    39     $applications = $dbi->get("Application", array("uid" => $uid));
    40     if (count($applications) > 0) {
    41         if ($applications[0] != null) {
    42             // An application exists with the given UID!
    43             $result = $applications[0];
    44             $resultType = "Application";
     56        if (result != null) {
     57            $applications = $dbi->get("Application", array("uid" => $uid));
     58            if (count($applications) > 0) {
     59                if ($applications[0] != null) {
     60                    // An application exists with the given UID!
     61                    $result = $applications[0];
     62                    $resultType = "Application";
     63                }
     64            }
     65        }
     66
     67        if (result != null) {
     68            $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
     69            if (count($dashboards) > 0) {
     70                if ($dashboards[0] != null) {
     71                    // A dashboard exists with the given UID!
     72                    $result = $dashboards[0];
     73                    $resultType = "Dashboard";
     74                }
     75            }
     76        }
     77
     78// If result is still null at this point, the passed UID does not refer to an existing object!
     79        if ($result == null || $resultType == null) {
     80            echo "Non-existing UID passed!";
     81        } else {
     82
     83            // set relevant variables based on the type and properties of the step in question (currently stored in $result)
     84            switch (strtolower($resultType)) {
     85                case "questionnaire":
     86                    $imageURL = "images/icons/questionnaire.png";
     87                    break;
     88                case "dashboard":
     89                    $imageURL = "images/icons/dashboard.png";
     90                    break;
     91                case "application":
     92                    $imageURL = "images/icons/application.png";
     93                    break;
     94                default:
     95                    $imageURL = "images/icons/unknowntype.png";
     96                    break;
     97            }
     98
     99//echo out the HTML markup
     100            $response = '<div class="displayStep" id="' . $result->uid . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
     101            echo $response;
    45102        }
    46103    }
    47104}
    48 
    49 if (result != null) {
    50     $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
    51     if (count($dashboards) > 0) {
    52         if ($dashboards[0] != null) {
    53             // A dashboard exists with the given UID!
    54             $result = $dashboards[0];
    55             $resultType = "Dashboard";
    56         }
    57     }
    58 }
    59 
    60 // If result is still null at this point, the passed UID does not refer to an existing object!
    61 if ($result == null || $resultType == null) {
    62     echo "Non-existing UID passed!";
    63 } else {
    64 
    65     // set relevant variables based on the type and properties of the step in question (currently stored in $result)
    66     switch (strtolower($resultType)) {
    67         case "questionnaire":
    68             $imageURL = "images/icons/questionnaire.png";
    69             break;
    70         case "dashboard":
    71             $imageURL = "images/icons/dashboard.png";
    72             break;
    73         case "application":
    74             $imageURL = "images/icons/application.png";
    75             break;
    76         default:
    77             $imageURL = "images/icons/unknowntype.png";
    78             break;
    79     }
    80    
    81 //echo out the HTML markup
    82     $response = '<div class="displayStep" id="' . $result->uid . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
    83     echo $response;
    84 }
    85105?>
Note: See TracChangeset for help on using the changeset viewer.