- Timestamp:
- 11/22/11 18:10:47 (13 years ago)
- Location:
- Dev/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/Toolbox.php
r154 r165 20 20 <div class="title">Toolbox</div> 21 21 <p>Add new: </p> 22 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Survey'; SubmitToolbox();"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>22 <!-- <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Survey'; SubmitToolbox();"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div> 23 23 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Application'; SubmitToolbox();"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div> 24 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div> 24 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>--> 25 <div class="creationButton" onClick="SubmitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div> 26 <div class="creationButton" onClick="SubmitToolbox('Application');"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div> 27 <div class="creationButton" onClick="SubmitToolbox('Dashboard');"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div> 25 28 <input type="hidden" name="objectToCreate" /> 26 29 -
Dev/trunk/createObject.php
r163 r165 1 1 <?php 2 2 3 require 'classes/master.php'; //should be at top of every page 3 4 5 if (isset($_POST['objectToCreate'])) { 6 if (!empty($_POST['objectToCreate'])) { 7 $otc = $_POST['objectToCreate']; 8 } 9 else { 10 die ("Invalid arguments passed!"); 11 } 12 } 13 else { 14 die ("No arguments passed!"); 15 } 16 17 $dbi = new DatabaseInterface(); 18 $creator_results = $dbi->get("User", array("name"=>$_SESSION['username'])); 19 if (count($creator_results) > 0) { 20 $creator = $creator_results[0]; 21 } 22 else { 23 die ("Invalid creator, make sure you are logged in!"); 24 } 25 26 $uid = null; 27 switch (strtolower($otc)) { 28 case "application": 29 $newApp = new Application(null, "New application", "Default description", "Default style"); 30 $dbi->set($newApp); 31 $uid = $newApp->uid; 32 break; 33 case "survey": 34 $newSurvey = new Survey(null, "New Survey", "Default description", $creator, null); 35 $dbi->set($newSurvey); 36 $uid = $newSurvey->uid; 37 break; 38 case "dashboard": 39 //TODO 40 break; 41 default: 42 die ("Variable \$otc: $otc does not match a compatible object type!"); 43 break; 44 } 45 46 echo $uid; 4 47 5 48 ?> -
Dev/trunk/js/sequencerScripts.js
r164 r165 25 25 } 26 26 27 /* 27 28 function SubmitToolbox() { 28 29 document.forms['toolbox'].submit(); 30 } 31 */ 32 function SubmitToolbox(type) { 33 var c = "objectToCreate="+type; 34 var u = "createObject.php"; 35 var a = true; 36 var pipeline = document.getElementById("pipelineStringField"); 37 var pipelineType = document.getElementById("pipelineTypeField"); 38 var pipelineUpdated = document.getElementById("pipelineUpdatedField"); 39 40 newAjaxRequest(c, u, function(result){ 41 var resultUid = result.responseText; 42 console.log(resultUid); 43 console.log("lol"); 44 console.log(resultUid); 45 pipeline.value += ","+resultUid; 46 pipelineType += ","+type; 47 pipelineUpdated += ",0"; 48 updateSequencer(); 49 }, a); 29 50 } 30 51 … … 138 159 */ 139 160 140 function ajaxStepRequest(UIDS ) {161 function ajaxStepRequest(UIDS, types) { 141 162 var c = "uids="+UIDS; 163 if (types != "") { 164 c += "&types="+types; 165 } 142 166 var u = "returnStep.php"; 143 167 newAjaxRequest(c, u, function(result) { … … 158 182 var content = document.getElementById("seqContent"); 159 183 var pipeline = document.getElementById("pipelineStringField").value; 184 var pipelineTypes = document.getElementById("pipelineTypeField").value; 160 185 pipeline = pipeline.replace(/,/g , ",divider,"); //regex search for commas, global (repeat), to represent them with visual dividers. 161 ajaxStepRequest(pipeline); 186 pipelineTypes = pipelineTypes.replace(/,/g, ",divider,"); 187 ajaxStepRequest(pipeline, pipelineTypes); 162 188 } 163 189 … … 261 287 newUpdatedString += plUpdated[i]+","; 262 288 } 263 alert(newUpdatedString+": OLD");264 289 if (newUpdatedString.substring(newUpdatedString.length-1) == ",") { 265 290 newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1); 266 291 } 267 alert(newUpdatedString+": NEW!");292 268 293 269 294 document.getElementById("pipelineUpdatedField").value = newUpdatedString; -
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.