Changeset 153


Ignore:
Timestamp:
11/15/11 11:01:31 (13 years ago)
Author:
fpvanagthoven
Message:
 
Location:
Dev/trunk
Files:
1 added
8 edited

Legend:

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

    r152 r153  
    2121
    2222    public function init() {
     23        $stringPipeline = "";
     24        foreach ($this->loadedSession->pipeline as $object) {
     25            $stringPipeline .= "$object->uid,";
     26        }
     27        $stringPipeline = rtrim($stringPipeline, ",");
    2328        ?>
    2429        <br /><form name="sequencer" action="pipelineEditor.php" method="post">
     
    2732
    2833                <div id="seqContent">
    29                     <?php $this->DrawSteps(); ?>         
     34
    3035                </div>
    3136
     
    3742                    <input type="submit" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/>
    3843                    <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
    39                     <input type="hidden" name="selectedStep" />
    40                     <input type="hidden" name="numSteps" />
    41                     <input type="hidden" name="pipeline" />
     44                </div>
     45                <div id="hiddeInputs">
     46                    <input type="hidden" name="selectedStep" id="selectedStepField" value="" />
     47                    <input type="hidden" name="pipelineString" id="pipelineStringField" value="123,456,123" />
    4248                </div>
    4349            </fieldset>
     
    4753
    4854    public function DrawSteps() {
    49        
     55        // Use AJAX to draw visual representations of step objects in a pipeline
     56        // <TODO> Implement parameters such as screen size in the drawing of objects </TODO>
     57        ?>
     58        <script type="text/javascript">
     59            drawSteps();
     60        </script>
     61
     62
     63        <?php
    5064    }
    5165
    52     private function Javascript() {
     66    public function Javascript() {
     67        $pipelineString = "ERROR";
     68       
     69        echo "<!--$pipelineString-->";
     70       
    5371        ?>
    5472        <script type="text/javascript" src="js/sequencerScripts.js"></script>
    55 
     73        <script type="text/javascript" src="js/jquery.js"></script>
     74        <script type="text/javascript">
     75            $(document).ready(function() {
     76                drawSteps();
     77            });
     78        </script>
    5679        <?php
    5780    }
     
    6386            redirect("selectSession.php");
    6487        }
    65        
     88
    6689        $sessionResults = $dbi->get("Session", array("uid" => $currentSession));
    6790        if (count($sessionResults) > 0) {
    6891            $this->loadedSession = $sessionResults[0];
    69         }
    70         else {
     92        } else {
    7193            die("Invalid session!");
    7294        }
  • Dev/trunk/css/awesome.css

    r150 r153  
    627627}
    628628
    629 #sequencer .seqContent {
     629#sequencer #seqContent {
    630630    height: 9em;
    631631    overflow-x: scroll;
     
    687687}
    688688
    689 .seqContent .divider {
     689#seqContent .divider {
    690690    width: 10px;
    691691    height: 50px;
  • Dev/trunk/js/sequencerScripts.js

    r152 r153  
    5151function selectStep(uid) {
    5252    document.getElementById(uid).addClass("selected");
    53     document.sequencer.controls.selectedStep.value = uid;
     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);
     61    }
     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    }
    5466}
    5567                                                                           
    5668                                                                           
    57 /*
    58  * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
    59  * Using ajax principle allows for editing of pipeline without constantly refreshing the page.
    60  */
    61 
    62 function ajaxStepRequest(UID) {
    63     var c = "uid="+UID;
    64     var u = "returnStep.php";
    65     newAjaxRequest(c, u, function(result) {
    66         var newDiv = result.responseText;
    67         document.getElementById("seqContent").appendChild(newDiv);
    68     });
    69 }
    70 
    71 function ajaxInfoRequest(id, el) {
    72     var uid = id;
    73     var c = "uid="+uid;
    74     var u = "getInfo.php";
    75     newAjaxRequest(c, u, function(result) {
    76         el.innerHTML = result.responseText;
    77     });
    78 }
    79 
    8069/*
    8170 * This function allows for simple use of AJAX requests.
     
    133122    xml.send(contentString);
    134123}
     124
     125/*
     126 * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
     127 * Using ajax principle allows for editing of pipeline without constantly refreshing the page.
     128 */
     129
     130function ajaxStepRequest(UID) {
     131    var c = "uid="+UID;
     132    var u = "returnStep.php";
     133    newAjaxRequest(c, u, function(result) {
     134        var newDiv = document.createElement("div");
     135        newDiv.innerHTML = result.responseText;
     136        document.getElementById("seqContent").appendChild(newDiv);
     137    });
     138}
     139
     140function ajaxInfoRequest(id, el) {
     141    var uid = id;
     142    var c = "uid="+uid;
     143    var u = "getInfo.php";
     144    newAjaxRequest(c, u, function(result) {
     145        el.innerHTML = result.responseText;
     146    });
     147}
    135148                           
    136149
     150
     151
     152
     153
     154
    137155function drawSteps() {
    138     var sequencer = document.getElementById("sequencer");
    139     var seqContent = document.getElementById("seqContent");
    140                
    141     // first delete all current children of seqContent (to reset the sequencer).
    142     while (seqContent.childNodes.length > 0) {
    143         var step = seqContent.childNodes[0];
    144         step.parentNode.removeChild(step);
    145     }
    146                
    147     // get pipeline contents from hidden form inputs.
    148     var pipeline = sequencer.controls.pipeline.value;
    149     var pipeline = pipeline.split(", ");
    150                
     156    var content = document.getElementById("seqContent");
     157    var pipeline = document.getElementById("pipelineStringField").value;
     158    var copy = pipeline;
     159    pipeline = copy.split(",");
     160   
    151161    // then do an xmlhttp request for each step to be added to the sequencer
    152162    var numberOfSteps = pipeline.length;
    153     for (var i = 0; i > numberOfSteps; i++) {
     163    for (var i = 0; i < numberOfSteps; i++) {
    154164        ajaxStepRequest(pipeline[i]);
     165        if (i < (numberOfSteps-1)) {
     166            ajaxStepRequest("divider");
     167        }
    155168    }
     169   
    156170               
    157171}
    158172
     173function updatePipelineHidden (pipelineString) {
     174   
     175}
     176
     177
  • Dev/trunk/pipelineEditor.php

    r152 r153  
    2121        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    2222        <title></title>
    23         <?php new StyleSheet("awesome"); ?>
    24         <script type="text/javascript" src="js/menu.js"></script>
    25         <script type="text/javascript" src="js/jquery.jps"></script>
    26         <script type="text/javascript" src="js/sequencerScripts.js"></script>
     23        <?php new StyleSheet("awesome");
     24        $sequencer->Javascript();
     25        ?>
     26       
    2727    </head>
    2828    <body>
     
    3636                <?php $toolbox = new Toolbox(); ?>
    3737            </div>
     38   
    3839    </body>
    3940</html>
  • 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?>
  • Dev/trunk/selectSession.php

    r152 r153  
    6464    </head>
    6565    <body>
    66         <form action="selectSession.php" method="POST">
    67             <fieldset name="selectionMenu">
    68                 <!-- onchange van volgende select linkt deze aan de ajax-based info panel, script staat in sequencerScripts.js -->
    69                 <select name="sessionUID" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('sessionDescription'));">
    70                     <?php
    71                     foreach ($sessions as $session) {
    72                         echo '<option value="' . $session->uid . '">' . $session->title . '</option>' . "\n";
    73                     }
    74                     ?>                   
    75                 </select>
    76                 <br /><br />
    77                 <input type="text" name="newSessionName" value="Name..." style="float: left;" /><br />
    78                 <input type="submit" name="createSession" value="Create new session" class="surveybutton" style="float: left;" />
    79                 <input type="submit" name="editSession" value="Edit session" class="surveybutton" style="float: left;" />
    80                 <input type="submit" name="deleteSession" value="Delete session" class="surveybutton" style="float: left;" />
    81                 <br /><br /><br />
    82                 <div id="errorDisplay"><?php
    83                     if (isset($errorMessage)) {
    84                         foreach ($errorMessage as $message) {
    85                             echo $message;
     66        <div id="header">
     67            <?php new Logo(); ?>
     68        </div>
     69
     70        <div id="wrapper">
     71            <div id="content">
     72            <form action="selectSession.php" method="POST">
     73                <fieldset name="selectionMenu">
     74                    <!-- onchange van volgende select linkt deze aan de ajax-based info panel, script staat in sequencerScripts.js -->
     75                    <select name="sessionUID" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('sessionDescription'));">
     76                        <?php
     77                        foreach ($sessions as $session) {
     78                            echo '<option value="' . $session->uid . '">' . $session->title . '</option>' . "\n";
    8679                        }
    87                     }
    88                     ?></div>
    89             </fieldset>
    90             <fieldset id="sessionDescription">
    91                 Info goes here:
    92             </fieldset>
    93         </form>
     80                        ?>                   
     81                    </select>
     82                    <br /><br />
     83                    <input type="text" name="newSessionName" value="Name..." style="float: left;" /><br />
     84                    <input type="submit" name="createSession" value="Create new session" class="surveybutton" style="float: left;" />
     85                    <input type="submit" name="editSession" value="Edit session" class="surveybutton" style="float: left;" />
     86                    <input type="submit" name="deleteSession" value="Delete session" class="surveybutton" style="float: left;" />
     87                    <br /><br /><br />
     88                    <div id="errorDisplay"><?php
     89                        if (isset($errorMessage)) {
     90                            foreach ($errorMessage as $message) {
     91                                echo $message;
     92                            }
     93                        }
     94                        ?></div>
     95                </fieldset>
     96                <fieldset id="sessionDescription">
     97                    Info goes here:
     98                </fieldset>
     99            </form>
     100        </div>
     101        </div>
    94102    </body>
    95103</html>
  • Dev/trunk/surveycreation.php

    r95 r153  
    55    redirect('index.php');
    66
    7 $savedSurvey = null;
    8 $timeStamp = null;
     7if (isset($_POST['submit'])) {
     8    if (isset($_POST['surveyName'])) {
     9        $survey = new Survey(null, $_POST['surveyName'], "Thijs", null);
     10        $dbi = new DatabaseInterface();
     11        $dbi->set($survey);
     12    }
     13}
    914
    1015
     16
     17
     18/*
     19  $savedSurvey = null;
     20  $timeStamp = null;
     21 */
     22
    1123/* LOAD SURVEY */
    12 if (isset($_POST['UID'])) {
    13     $surveyID = $_POST['UID'];
    14     $surveyDBI = new SurveyCreationDatabaseInterface($surveyID);
    15     $info = $surveyDBI->getSurveyInfo();
     24/*
     25  if (isset($_POST['UID'])) {
     26  $surveyID = $_POST['UID'];
     27  $surveyDBI = new SurveyCreationDatabaseInterface($surveyID);
     28  $info = $surveyDBI->getSurveyInfo();
    1629
    17     $savedSurvey = Survey::getSurvey($info);
    18 }
     30  $savedSurvey = Survey::getSurvey($info);
     31  }
     32 */
     33/* AUTOSAVE */
    1934
    20 /* AUTOSAVE */
    21 else if (isset($_POST['timeStamp'])) {
    22     $timeStamp = $_POST['timeStamp'];
     35/*
     36  else if (isset($_POST['timeStamp'])) {
     37  $timeStamp = $_POST['timeStamp'];
    2338
    24     echo 'This is what gets sent:';
    25     var_dump($_POST);
    26     echo '<br/><br/>';
    27     $surveyDBI = new SurveyCreationDatabaseInterface($_POST['surveyID']);
    28     $surveyDBI->setSurveyInfo($_POST,$_SESSION);
    29     $info = $surveyDBI->getSurveyInfo();
    30     echo '<br/><br/>';
    31     echo 'This is what I get back:';
    32     var_dump($info);
     39  echo 'This is what gets sent:';
     40  var_dump($_POST);
     41  echo '<br/><br/>';
     42  $surveyDBI = new SurveyCreationDatabaseInterface($_POST['surveyID']);
     43  $surveyDBI->setSurveyInfo($_POST,$_SESSION);
     44  $info = $surveyDBI->getSurveyInfo();
     45  echo '<br/><br/>';
     46  echo 'This is what I get back:';
     47  var_dump($info);
    3348
    34     $savedSurvey = Survey::getSurvey($info);
    35 }
     49  $savedSurvey = Survey::getSurvey($info);
     50  }
     51
     52 */
    3653?>
    3754
     
    4259    <head>
    4360        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    44             <title>Survey Creation</title>
    45             <?php new StyleSheet(); ?>
     61        <title>Survey Creation</title>
     62        <?php new StyleSheet("awesome"); ?>
    4663    </head>
    4764    <body>
     
    5269
    5370            <div id="content">
    54                 <?php
    55                 new SurveyCreationTool($savedSurvey, $timeStamp);
    56                 ?>
     71                <form action="surveycreation.php" method="post">
     72                    <fieldset>
     73                    Name: <input type="text" name="surveyName" /><br />
     74                    Uid: <input type="text" name="surveyID" /><br /><br />
     75                    <input type="submit" name="submit" value="Make fake survey!" />
     76                    </fieldset>
     77                </form>
    5778            </div>
    5879        </div>
Note: See TracChangeset for help on using the changeset viewer.