Changeset 154


Ignore:
Timestamp:
11/15/11 16:25:01 (13 years ago)
Author:
fpvanagthoven
Message:
Location:
Dev/trunk
Files:
2 added
5 deleted
6 edited

Legend:

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

    r144 r154  
    2020                <div class="title">Toolbox</div>
    2121                <p>Add new: </p>
    22                 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Questionnaire'; SubmitToolbox();"><img src="images/icons/questionnaire.png" class="buttonIcon"/><p>Questionnaire</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>
    2424                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>
  • Dev/trunk/classes/pipelineSequencer.php

    r153 r154  
    2727        $stringPipeline = rtrim($stringPipeline, ",");
    2828        ?>
    29         <br /><form name="sequencer" action="pipelineEditor.php" method="post">
     29        <br /><form name="sequencerForm" action="pipelineEditor.php" method="post">
    3030            <fieldset id="sequencer">
    3131                <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div>
    3232
    33                 <div id="seqContent">
    34 
    35                 </div>
     33                <div id="seqContent"></div>
    3634
    3735                <div id="controls">
     
    4341                    <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
    4442                </div>
    45                 <div id="hiddeInputs">
     43                <div id="hiddenInputs">
    4644                    <input type="hidden" name="selectedStep" id="selectedStepField" value="" />
    47                     <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456,123" />
     45                    <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456" />
    4846                </div>
    4947            </fieldset>
     
    6664    public function Javascript() {
    6765        $pipelineString = "ERROR";
    68        
     66
    6967        echo "<!--$pipelineString-->";
    70        
    7168        ?>
    7269        <script type="text/javascript" src="js/sequencerScripts.js"></script>
     
    9087        if (count($sessionResults) > 0) {
    9188            $this->loadedSession = $sessionResults[0];
    92         } else {
     89        } else {        //No session with that UID found in database!
    9390            die("Invalid session!");
    9491        }
    9592    }
    9693
     94    public function HandlePostData() {
     95        if (isset($_POST['editSelected'])) {
     96            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
     97                redirect("editredirect.php");
     98            }
     99        }
     100
     101        if (isset($_POST['moveSelectedLeft'])) {
     102            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
     103                MoveStep($_POST['selectedStep'], -1);
     104            }
     105        }
     106
     107        if (isset($_POST['moveSelectedRight'])) {
     108            if (isset($_POST['selectedStep']) && !empty($_POST['selectedStep'])) {
     109                MoveStep($_POST['selectedStep'], 1);
     110            }
     111        }
     112
     113        if (isset($_POST['objectToCreate']) && !empty($_POST['objectToCreate'])) {
     114            switch (strtolower($_POST['objectToCreate'])) {
     115                case "survey":
     116                    redirect("createsurvey.php");
     117                    break;
     118                case "application":
     119                    redirect("createapplication.php");
     120                    break;
     121                case "dashboard":
     122                    redirect("createdashboard.php");
     123                    break;
     124                default:
     125                    // Er is iets fout gegaan, want er is geen valid type meegegeven!
     126                    break;
     127            }
     128        }
     129    }
     130
     131    // Dit is een pure php versie. Deze slaat nog niet op in de Database, en reageert nog niet op
     132    public function MoveStep($uid, $direction) {
     133        $newSession = $this->loadedSession;
     134
     135        for ($i = 0; $i < count($newSession->pipeline); $i++) {
     136            if ($newSession->pipeline[i]->uid == $uid) {
     137                $temp = $newSession->pipeline[i];
     138                $newSession->pipeline[i] = $newSession->pipeline[i + $direction];
     139                $newSession->pipeline[i + $direction] = $newSession->pipeline[i];
     140                break;
     141            }
     142        }
     143
     144        $this->loadedSession = $newSession;
     145    }
     146
    97147}
    98148?>
  • Dev/trunk/css/awesome.css

    r153 r154  
    668668
    669669.displayStep.selected {
    670     background-color: rgba(255, 255, 255, 0.5);
     670    -moz-box-shadow: 0 0 50px #FFF;
     671    -webkit-box-shadow: 0 0 50px #FFF;
     672    box-shadow: 0 0 50px #FFF;
     673   
    671674}
    672675
  • Dev/trunk/js/sequencerScripts.js

    r153 r154  
    3232
    3333function hasClass(ele,cls) {
    34     return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
     34    if (ele.className)
     35        return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
    3536}
    3637 
     
    5051
    5152function selectStep(uid) {
    52     document.getElementById(uid).addClass("selected");
    53     var selectedInfo = document.getElementById("selectedStepField");
    54     if (selectedInfo == null) {     // This is the first time a step is selected after a reload of the page, therefore a hidden input field is not yet present.
    55         selectedInfo = document.createElement("input")
    56         selectedInfo.setAttribute("type","hidden");
    57         selectedInfo.setAttribute("id","selectedStepField");
    58         selectedInfo.setAttribute("value",uid);
    59         var hiddenInputFields = document.getElementById("hiddenInputs");
    60         hiddenInputFields.appendChild(selectedInfo);
     53    var nodes = document.getElementById("seqContent").childNodes;
     54    for (var i = 0; i < nodes.length; i++) {     //loop through childNodes. Skip first node (whitespace)
     55        //debugger;
     56        if (hasClass(nodes[i], "displayStep")) {    //check if current childNode is a displayStep, not divider or text.
     57            if (nodes[i].id == uid) {
     58                addClass(nodes[i], "selected");
     59            }
     60            else {
     61                removeClass(nodes[i], "selected");
     62            }
     63        }
    6164    }
    62     else {      // There already exists a hidden input field with id selectedStepField, therefore we only change the value of this field.
    63         var hiddenInput = document.getElementById("selectedStepField");
    64         hiddenInput.value = uid;
    65     }
     65   
     66    // Update selected step field with uid of currently selected step.
     67    var selectedStepField = document.getElementById("selectedStepField");
     68    selectedStepField.value = uid;
     69   
    6670}
    6771                                                                           
     
    123127}
    124128
     129
    125130/*
    126131 * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
     
    128133 */
    129134
    130 function ajaxStepRequest(UID) {
    131     var c = "uid="+UID;
     135function ajaxStepRequest(UIDS) {
     136    var c = "uids="+UIDS;
    132137    var u = "returnStep.php";
    133138    newAjaxRequest(c, u, function(result) {
    134         var newDiv = document.createElement("div");
    135         newDiv.innerHTML = result.responseText;
    136         document.getElementById("seqContent").appendChild(newDiv);
     139        document.getElementById("seqContent").innerHTML = result.responseText;
    137140    });
    138141}
     
    156159    var content = document.getElementById("seqContent");
    157160    var pipeline = document.getElementById("pipelineStringField").value;
    158     var copy = pipeline;
    159     pipeline = copy.split(",");
    160    
    161     // then do an xmlhttp request for each step to be added to the sequencer
    162     var numberOfSteps = pipeline.length;
    163     for (var i = 0; i < numberOfSteps; i++) {
    164         ajaxStepRequest(pipeline[i]);
    165         if (i < (numberOfSteps-1)) {
    166             ajaxStepRequest("divider");
    167         }
    168     }
    169    
    170                
     161    pipeline = pipeline.replace(/,/g , ",divider,");    //regex search for commas, global (repeat), to represent them with visual dividers.
     162    ajaxStepRequest(pipeline);
    171163}
    172164
     
    174166   
    175167}
    176 
    177 
  • Dev/trunk/pipelineEditor.php

    r153 r154  
    33
    44if (!isset($_SESSION['username'])) {
    5     $_SESSION['message'] = "You were redirected here because your session timed out or you used an invalid link.";
    65    redirect('index.php');
    76}
    87
    98$sequencer = new PipelineSequencer();
    10 $sequencer->GetFromDB($_SESSION['currentSession']);
     9$sequencer->GetFromDB($_SESSION['currentSession']); //load session into php part of the sequencer
     10$sequencer->HandlePostData();
    1111?>
    1212
  • Dev/trunk/returnStep.php

    r153 r154  
    1010
    1111// Check if calling script actually passed a uid to use
    12 if (isset($_POST['uid'])) {
    13     if (!empty($_POST['uid'])) {
    14         $uid = $_POST['uid'];
     12if (isset($_POST['uids'])) {
     13    if (!empty($_POST['uids'])) {
     14        $uids = $_POST['uids'];
    1515    } else {
    16         echo "Invalid UID passed!";
     16        echo "Invalid UIDs passed!";
    1717    }
    1818} else {
     
    2020}
    2121
     22$sUids = explode(",", $uids);
     23$response = "";
     24$dbi = new DatabaseInterface();
     25foreach ($sUids as $uid) {
     26    $response .= processUid($uid);
     27}
     28
     29echo $response;
    2230
    2331
    24 if ($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 }
    29 else 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 }
    34 else {
    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.
     32/*
     33 * ProcessUid needs to be changed once all the object classes are fixed. The '123', '456' test cases are not functional and are for testing puroses only.
     34 * Additional onclick events for selecting objects would need to be added as well.
     35 */
    4136
    4237
    43         $dbi = new DatabaseInterface();
     38
     39function processUid($uid) {
     40    if ($uid == "123") {        // test case for when steps aren't actually working
     41        $imageURL = "images/icons/unknowntype.png";
     42        $responsePart = '<div class="displayStep" id="' . "123" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';
     43        return $responsePart;
     44    } else if ($uid == '456') {
     45        $imageURL = "images/icons/unknowntype.png";
     46        $responsePart = '<div class="displayStep" id="' . "456" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';
     47        return $responsePart;
     48    } else {
     49
     50
     51        if ($uid == "divider") {    //a divider has been requested instead of a displaystep
     52            $responsePart = '<div class="divider"></div>';
     53            return $responsePart;
     54        } else {        // an actual step has been requested.
     55           
    4456//Check in order: survey, application, dashboard.
    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         }
    55 
    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";
     57            $result = null;
     58            $resultType = null;
     59            $surveys = $dbi->get("Survey", array("uid" => $uid));
     60            if (count($surveys) > 0) {
     61                if ($surveys[0] != null) {
     62                    // A survey exists with the given UID!
     63                    $result = $surveys[0];
     64                    $resultType = "Survey";
    6365                }
    6466            }
    65         }
    6667
    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";
     68            if (result != null) {
     69                $applications = $dbi->get("Application", array("uid" => $uid));
     70                if (count($applications) > 0) {
     71                    if ($applications[0] != null) {
     72                        // An application exists with the given UID!
     73                        $result = $applications[0];
     74                        $resultType = "Application";
     75                    }
    7476                }
    7577            }
    76         }
     78
     79            if (result != null) {
     80                $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
     81                if (count($dashboards) > 0) {
     82                    if ($dashboards[0] != null) {
     83                        // A dashboard exists with the given UID!
     84                        $result = $dashboards[0];
     85                        $resultType = "Dashboard";
     86                    }
     87                }
     88            }
    7789
    7890// 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 {
     91            if ($result == null || $resultType == null) {
     92                echo "Non-existing UID passed!";
     93            } else {
    8294
    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             }
     95                // set relevant variables based on the type and properties of the step in question (currently stored in $result)
     96                switch (strtolower($resultType)) {
     97                    case "survey":
     98                        $imageURL = "images/icons/survey.png";
     99                        break;
     100                    case "dashboard":
     101                        $imageURL = "images/icons/dashboard.png";
     102                        break;
     103                    case "application":
     104                        $imageURL = "images/icons/application.png";
     105                        break;
     106                    default:
     107                        $imageURL = "images/icons/unknowntype.png";
     108                        break;
     109                }
    98110
    99111//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;
     112                $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
     113                return $responsePart;
     114            }
    102115        }
    103116    }
    104117}
     118
    105119?>
Note: See TracChangeset for help on using the changeset viewer.