Changeset 165


Ignore:
Timestamp:
11/22/11 18:10:47 (13 years ago)
Author:
fpvanagthoven
Message:
 
Location:
Dev/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/Toolbox.php

    r154 r165  
    2020                <div class="title">Toolbox</div>
    2121                <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>
    2323                <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>
    2528                <input type="hidden" name="objectToCreate" />
    2629
  • Dev/trunk/createObject.php

    r163 r165  
    11<?php
    22
     3require 'classes/master.php'; //should be at top of every page
    34
     5if (isset($_POST['objectToCreate'])) {
     6    if (!empty($_POST['objectToCreate'])) {
     7        $otc = $_POST['objectToCreate'];
     8    }
     9    else {
     10        die ("Invalid arguments passed!");
     11    }
     12}
     13else {
     14    die ("No arguments passed!");
     15}
     16
     17$dbi = new DatabaseInterface();
     18$creator_results = $dbi->get("User", array("name"=>$_SESSION['username']));
     19if (count($creator_results) > 0) {
     20    $creator = $creator_results[0];
     21}
     22else {
     23    die ("Invalid creator, make sure you are logged in!");
     24}
     25
     26$uid = null;
     27switch (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
     46echo $uid;
    447
    548?>
  • Dev/trunk/js/sequencerScripts.js

    r164 r165  
    2525}
    2626
     27/*
    2728function SubmitToolbox() {
    2829    document.forms['toolbox'].submit();
     30}
     31*/
     32function 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);
    2950}
    3051
     
    138159 */
    139160
    140 function ajaxStepRequest(UIDS) {
     161function ajaxStepRequest(UIDS, types) {
    141162    var c = "uids="+UIDS;
     163    if (types != "") {
     164        c += "&types="+types;
     165    }
    142166    var u = "returnStep.php";
    143167    newAjaxRequest(c, u, function(result) {
     
    158182    var content = document.getElementById("seqContent");
    159183    var pipeline = document.getElementById("pipelineStringField").value;
     184    var pipelineTypes = document.getElementById("pipelineTypeField").value;
    160185    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);
    162188}
    163189
     
    261287        newUpdatedString += plUpdated[i]+",";
    262288    }
    263     alert(newUpdatedString+": OLD");
    264289    if (newUpdatedString.substring(newUpdatedString.length-1) == ",") {
    265290        newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1);
    266291    }
    267     alert(newUpdatedString+": NEW!");
     292   
    268293   
    269294    document.getElementById("pipelineUpdatedField").value = newUpdatedString;
  • Dev/trunk/returnStep.php

    r163 r165  
    1212if (isset($_POST['uids'])) {
    1313    if (!empty($_POST['uids'])) {
    14         $uids = $_POST['uids'];
     14        $sUids = $_POST['uids'];    // string uids
    1515    } else {
    1616        echo "Invalid UIDs passed!";
     
    2121}
    2222
    23 $sUids = explode(",", $uids);
     23$sTypes = "unknown";    // string types
     24if (isset($_POST['types'])) {
     25    if (!empty($_POST['types'])) {
     26        $sTypes = $_POST['types'];
     27    }
     28}
     29
     30$uids = explode(",", $sUids);   // array uids
     31if ($sTypes != "unknown") {
     32    $types = explode(",", $sTypes);
     33}
    2434$response = "";
    2535$dbi = new DatabaseInterface();
    26 foreach ($sUids as $uid) {
    27     $response .= processUid($uid);
     36
     37if (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    }
    2845}
     46
     47
    2948
    3049echo $response;
     
    3655 */
    3756
     57function processUid($uid, $type = null) {
     58    $dbi = new DatabaseInterface();
    3859
     60    if ($uid == "divider") {    //a divider has been requested instead of a displaystep
     61        $responsePart = '<div class="divider"></div>';
     62        return $responsePart;
     63    }
    3964
    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";
    5694                }
    5795            }
     96        }
    5897
    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";
    67105                }
    68106            }
    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    }
    80109
    81110// If result is still null at this point, the passed UID does not refer to an existing object!
    82             if ($result == null || $resultType == null) {
    83                 echo "Non-existing UID passed!";
    84             } else {
     111    if ($result == null || $resultType == null) {
     112        echo "Non-existing UID passed!";
     113    } else {
    85114
    86                 // set relevant variables based on the type and properties of the step in question (currently stored in $result)
    87                 switch (strtolower($resultType)) {
    88                     case "survey":
    89                         $imageURL = "images/icons/survey.png";
    90                         break;
    91                     case "dashboard":
    92                         $imageURL = "images/icons/dashboard.png";
    93                         break;
    94                     case "application":
    95                         $imageURL = "images/icons/application.png";
    96                         break;
    97                     default:
    98                         $imageURL = "images/icons/unknowntype.png";
    99                         break;
    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        }
    101130
    102131//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    }
    108135}
    109136
Note: See TracChangeset for help on using the changeset viewer.