Changeset 165 for Dev/trunk/returnStep.php
- Timestamp:
- 11/22/11 18:10:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/returnStep.php
r163 r165 12 12 if (isset($_POST['uids'])) { 13 13 if (!empty($_POST['uids'])) { 14 $ uids = $_POST['uids'];14 $sUids = $_POST['uids']; // string uids 15 15 } else { 16 16 echo "Invalid UIDs passed!"; … … 21 21 } 22 22 23 $sUids = explode(",", $uids); 23 $sTypes = "unknown"; // string types 24 if (isset($_POST['types'])) { 25 if (!empty($_POST['types'])) { 26 $sTypes = $_POST['types']; 27 } 28 } 29 30 $uids = explode(",", $sUids); // array uids 31 if ($sTypes != "unknown") { 32 $types = explode(",", $sTypes); 33 } 24 34 $response = ""; 25 35 $dbi = new DatabaseInterface(); 26 foreach ($sUids as $uid) { 27 $response .= processUid($uid); 36 37 if (isset($types)) { 38 for ($i = 0; $i < count($uids); $i++) { 39 $response .= processUid($uids[$i], $types[$i]); 40 } 41 } else { 42 foreach ($uids as $uid) { 43 $response .= processUid($uid); 44 } 28 45 } 46 47 29 48 30 49 echo $response; … … 36 55 */ 37 56 57 function processUid($uid, $type = null) { 58 $dbi = new DatabaseInterface(); 38 59 60 if ($uid == "divider") { //a divider has been requested instead of a displaystep 61 $responsePart = '<div class="divider"></div>'; 62 return $responsePart; 63 } 39 64 40 function processUid($uid) { 41 $dbi = new DatabaseInterface(); 42 if ($uid == "divider") { //a divider has been requested instead of a displaystep 43 $responsePart = '<div class="divider"></div>'; 44 return $responsePart; 45 } else { // an actual step has been requested. 46 47 //Check in order: survey, application, dashboard. 48 $result = null; 49 $resultType = null; 50 $surveys = $dbi->get("Survey", array("uid" => $uid)); 51 if (count($surveys) > 0) { 52 if ($surveys[0] != null) { 53 // A survey exists with the given UID! 54 $result = $surveys[0]; 55 $resultType = "Survey"; 65 $result = null; 66 $resultType = null; 67 68 if ($type != null) { // Als er een type is gespecificeerd 69 $resultType = $type; 70 $results = $dbi->get($type, array("uid" => $uid)); 71 if (count($results) > 0) { 72 $result = $results[0]; 73 } 74 } 75 76 // Als er geen type is gespecificeerd, doorloop de queries in de volgorde: Survey, Application, Dashboard 77 else { 78 $surveys = $dbi->get("Survey", array("uid" => $uid)); 79 if (count($surveys) > 0) { 80 if ($surveys[0] != null) { 81 // A survey exists with the given UID! 82 $result = $surveys[0]; 83 $resultType = "Survey"; 84 } 85 } 86 87 if ($result == null) { 88 $applications = $dbi->get("Application", array("uid" => $uid)); 89 if (count($applications) > 0) { 90 if ($applications[0] != null) { 91 // An application exists with the given UID! 92 $result = $applications[0]; 93 $resultType = "Application"; 56 94 } 57 95 } 96 } 58 97 59 if ($result == null) { 60 $applications = $dbi->get("Application", array("uid" => $uid)); 61 if (count($applications) > 0) { 62 if ($applications[0] != null) { 63 // An application exists with the given UID! 64 $result = $applications[0]; 65 $resultType = "Application"; 66 } 98 if ($result == null) { 99 $dashboards = $dbi->get("Dashboard", array("uid" => $uid)); 100 if (count($dashboards) > 0) { 101 if ($dashboards[0] != null) { 102 // A dashboard exists with the given UID! 103 $result = $dashboards[0]; 104 $resultType = "Dashboard"; 67 105 } 68 106 } 69 70 if ($result == null) { 71 $dashboards = $dbi->get("Dashboard", array("uid" => $uid)); 72 if (count($dashboards) > 0) { 73 if ($dashboards[0] != null) { 74 // A dashboard exists with the given UID! 75 $result = $dashboards[0]; 76 $resultType = "Dashboard"; 77 } 78 } 79 } 107 } 108 } 80 109 81 110 // If result is still null at this point, the passed UID does not refer to an existing object! 82 83 84 111 if ($result == null || $resultType == null) { 112 echo "Non-existing UID passed!"; 113 } else { 85 114 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 115 // set relevant variables based on the type and properties of the step in question (currently stored in $result) 116 switch (strtolower($resultType)) { 117 case "survey": 118 $imageURL = "images/icons/survey.png"; 119 break; 120 case "dashboard": 121 $imageURL = "images/icons/dashboard.png"; 122 break; 123 case "application": 124 $imageURL = "images/icons/application.png"; 125 break; 126 default: 127 $imageURL = "images/icons/unknowntype.png"; 128 break; 129 } 101 130 102 131 //echo out the HTML markup 103 $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->title . '</div>'; 104 return $responsePart; 105 } 106 } 107 132 $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->title . '</div>'; 133 return $responsePart; 134 } 108 135 } 109 136
Note: See TracChangeset
for help on using the changeset viewer.