Index: Dev/trunk/classes/Logo.php
===================================================================
--- Dev/trunk/classes/Logo.php	(revision 150)
+++ Dev/trunk/classes/Logo.php	(revision 151)
@@ -15,7 +15,9 @@
     // hardcoded logo div, image is defined in stylesheet. (#logo background:"";)
     public function __construct() {
-        echo '
-            <div id="logo"><a href="index.php">Research Tool</a></div>
-';
+        echo '<div id="logo"><a href="index.php">Research Tool</a>';
+        if (isset($_SESSION['username'])) {
+            echo '<a href="logout.php" style="font-size: 12pt;">Log out</a>';
+        }
+        echo '</div>';
     
     }
Index: Dev/trunk/classes/PipelineSequencer_1.php
===================================================================
--- Dev/trunk/classes/PipelineSequencer_1.php	(revision 151)
+++ Dev/trunk/classes/PipelineSequencer_1.php	(revision 151)
@@ -0,0 +1,198 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Sequencer
+ *
+ * @author HP
+ */
+class PipelineSequencer {
+
+    // properties
+    private $pipeline = array();
+    private $name = "empty";
+    private $numStepsInArray = 0;
+    private $maxNumStepsInArray = 10;
+    private $selectedStep;
+
+    public function __construct($pipeline, $name, $id) {
+        $this->pipeline = $pipeline;
+        $this->name = $name;
+    }
+
+    public function init() {
+        ?>
+        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
+                <div class="title">Name: <?php echo $this->name; ?> </div>
+
+                <div class="seqContent">
+                    <?php $this->DrawSteps(); ?>          
+                </div>
+
+                <div id="controls">
+                    <input type="submit" name="moveSelectedLeft" value="< Move" class="surveyButton" />
+                    <input type="submit" name="moveSelectedRight" value="Move >" class="surveyButton" />
+                    <input type="submit" name="editSelected" value="Edit step" class="surveyButton" />
+                    <input type="submit" name="deleteSelected" value="Delete step" class="surveyButton" />
+                    <input type="submit" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/>
+                    <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
+                    <input type="hidden" name="selectedStep" />
+                </div>
+            </fieldset>
+        </form>
+        <?php
+    }
+
+    public function AddStep($newStep) {
+        $n = 1;
+        foreach ($this->pipeline as $existingStep) {
+            if ($existingStep->name == $newStep . " $n") {
+                $n++;
+            }
+        }
+
+        $this->pipeline[] = new Step($newStep, $newStep . " " . $n, count($this->pipeline) + 1);
+        //var_dump($this->pipeline);
+        ?>
+        <script type="text/javascript">
+            document.refresh();
+        </script>
+        <?php
+    }
+
+    public function RemoveStep($targetStep) {
+
+        $tempArray = array();
+        $removed = false;
+        foreach ($this->pipeline as $step) {
+            if ($step->id != $targetStep) {
+                $tempArray[] = $step;
+                if ($removed) {
+                    $step::AdjustID(-1);
+                }
+            } else {
+                $removed = true;
+            }
+        }
+        $this->pipeline = $tempArray;
+    }
+
+    public function GetPipeline() {
+        return $this->pipeline;
+    }
+
+    public function DrawSteps() {
+        //draw the actual icons in the container div.
+        if (!empty($this->pipeline)) {
+            foreach ($this->pipeline as $step) {
+                if ($this->numStepsInArray < $this->maxNumStepsInArray) {
+                    //var_dump($step);
+                    $step->init();
+                    $this->numStepsInArray++;
+                    if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->pipeline)) {
+                        echo "<div class='divider'></div>";
+                    }
+                }
+            }
+        }
+    }
+
+    public function MoveStep($direction) {
+        $key = array_search($this->selectedStep, $this->pipeline);
+        //echo $key;
+    }
+
+    private function MoveEntry(&$array, $key, $dir) {
+        if ($dir == -1) {   // move up
+            if ($key > 0) {
+                $reverseArray = array_reverse(array_slice($array, $key - 1, 2, true));   // make a reversed array of the two entries, preserving keys
+                array_splice($array, $key - 1, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
+            }
+        } else if ($dir == 1) {   // move down
+            if ($key < count($array) - 1) {
+                $reverseArray = array_reverse(array_slice($array, $key, 2, true));   // make a reversed array of the two entries, preserving keys
+                array_splice($array, $key, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
+            }
+        }
+    }
+
+    public function SetSelected($key) {
+
+        if ($key > 0 && $key < count($this->pipeline)) {
+            $this->selectedStep = $key;
+        }
+    }
+
+    public function GetName($name) {
+        if ($name && $name != "") {
+            $this->name = $name;
+        }
+    }
+
+    public function GetFromDB() {
+
+        $dbi = new DatabaseInterface();
+        $this->pipeline = $dbi->get("pipeline", array("uid"=>$uid));
+        //this doesn't actually work, the sequencer doesn't know what the uid is yet. This data should be POSTed upon refresh!
+        
+        
+        
+        if (isset($_POST['destroy'])) {
+            unset($_POST['destroy']);
+            unset($_SESSION['currentPipeline']);
+        }
+
+        if (isset($_POST['clearPipeline'])) {
+            $this->pipeline = array();
+            $_SESSION['currentPipeline'] = $this->pipeline;
+        }
+
+        if (isset($_SESSION['currentPipeline']) && !empty($_SESSION['currentPipeline'])) {      // take pipeline from session data
+            $this->pipeline = $_SESSION['currentPipeline'];
+        } else {
+            $pipeline = array();
+        }
+
+        if (isset($_POST['objectToCreate'])) {      // user clicked a button in the toolbox.
+            //$this->pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate'] . " NEW", null);
+            $this::AddStep($_POST['objectToCreate']);
+        }
+
+        if (isset($_POST['deleteSelected'])) {
+            if (isset($_POST['selectedStep'])) {
+                $this->RemoveStep($_POST['selectedStep']);
+            }
+        }
+
+        //var_dump($_POST);
+
+        if (isset($_POST['selectedStep'])) {
+            $this::SetSelected($_POST['selectedStep']);
+        }
+
+        $_SESSION['currentPipeline'] = $this->pipeline;
+    }
+
+    private function Javascript() {
+        ?>
+        <!-- 
+        Add JS code for selecting steps, highlighting them, reordering, etc.
+        Is a refresh of the page (with subsequent querying of database really necessary?
+        
+        -->
+        <script type="text/javascript">
+            function selectStep(step) {
+                step.addClass("selected");
+                document.sequencer.controls.selectedStep.value = step.name;
+            }
+        </script>
+
+
+        <?php
+    }
+
+}
+?>
Index: Dev/trunk/classes/SessionConnector.php
===================================================================
--- Dev/trunk/classes/SessionConnector.php	(revision 150)
+++ Dev/trunk/classes/SessionConnector.php	(revision 151)
@@ -186,6 +186,7 @@
 		$this->model->add(new Statement($resourceSession, $predicateTitle, $sessionTitle));
 
-		$sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp());
-		$predicateTimestamp = new Resource(DATETIME);
+		//$sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp());
+                $sessionTimestamp = new Literal($rToolObject->datetime);    // Edit of above function, allows for creation of session, but still results in errors...
+                $predicateTimestamp = new Resource(DATETIME);
 		$this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp));
 
Index: Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- Dev/trunk/classes/pipelineSequencer.php	(revision 150)
+++ Dev/trunk/classes/pipelineSequencer.php	(revision 151)
@@ -6,12 +6,12 @@
 
 /**
- * Description of Sequencer
+ * A visual interface object for editing and viewing a session's pipeline.
  *
- * @author HP
+ * @author Tschipper
  */
 class PipelineSequencer {
 
     // properties
-    private $pipeline;
+    private $pipeline;      // array of UID strings.
     private $name = "empty";
     private $numStepsInArray = 0;
@@ -21,13 +21,14 @@
     public function __construct($uid) {
         $dbi = new DatabaseInterface();
-        $this->pipeline = $dbi->get("pipeline", array("uid"=>$uid));
+        $this->pipeline = $dbi->get("pipeline", array("uid" => $uid));
     }
 
     public function init() {
         ?>
-        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
+        <br /><form name="sequencer" action="pipelineEditor.php" method="post">
+            <fieldset id="sequencer">
                 <div class="title">Name: <?php echo $this->pipeline->name; ?> </div>
 
-                <div class="seqContent">
+                <div id="seqContent">
                     <?php $this->DrawSteps(); ?>          
                 </div>
@@ -41,4 +42,6 @@
                     <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
                     <input type="hidden" name="selectedStep" />
+                    <input type="hidden" name="numSteps" />
+                    <input type="hidden" name="pipeline" />
                 </div>
             </fieldset>
@@ -47,130 +50,6 @@
     }
 
-    public function AddStep($newStep) {
-        $n = 1;
-        foreach ($this->pipeline as $existingStep) {
-            if ($existingStep->name == $newStep . " $n") {
-                $n++;
-            }
-        }
-
-        $this->pipeline[] = new Step($newStep, $newStep . " " . $n, count($this->pipeline) + 1);
-        //var_dump($this->pipeline);
-        ?>
-        <script type="text/javascript">
-            document.refresh();
-        </script>
-        <?php
-    }
-
-    public function RemoveStep($targetStep) {
-
-        $tempArray = array();
-        $removed = false;
-        foreach ($this->pipeline as $step) {
-            if ($step->id != $targetStep) {
-                $tempArray[] = $step;
-                if ($removed) {
-                    $step::AdjustID(-1);
-                }
-            } else {
-                $removed = true;
-            }
-        }
-        $this->pipeline = $tempArray;
-    }
-
-    public function GetPipeline() {
-        return $this->pipeline;
-    }
-
     public function DrawSteps() {
-        //draw the actual icons in the container div.
-        if (!empty($this->pipeline)) {
-            foreach ($this->pipeline as $step) {
-                if ($this->numStepsInArray < $this->maxNumStepsInArray) {
-                    //var_dump($step);
-                    $step->init();
-                    $this->numStepsInArray++;
-                    if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->pipeline)) {
-                        echo "<div class='divider'></div>";
-                    }
-                }
-            }
-        }
-    }
-
-    public function MoveStep($direction) {
-        $key = array_search($this->selectedStep, $this->pipeline);
-        //echo $key;
-    }
-
-    private function MoveEntry(&$array, $key, $dir) {
-        if ($dir == -1) {   // move up
-            if ($key > 0) {
-                $reverseArray = array_reverse(array_slice($array, $key - 1, 2, true));   // make a reversed array of the two entries, preserving keys
-                array_splice($array, $key - 1, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
-            }
-        } else if ($dir == 1) {   // move down
-            if ($key < count($array) - 1) {
-                $reverseArray = array_reverse(array_slice($array, $key, 2, true));   // make a reversed array of the two entries, preserving keys
-                array_splice($array, $key, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
-            }
-        }
-    }
-
-    public function SetSelected($key) {
-
-        if ($key > 0 && $key < count($this->pipeline)) {
-            $this->selectedStep = $key;
-        }
-    }
-
-    public function GetName($name) {
-        if ($name && $name != "") {
-            $this->name = $name;
-        }
-    }
-
-    public function HandlePost() {
-
-        //this doesn't actually work, the sequencer doesn't know what the uid is yet. This data should be POSTed upon refresh!
         
-        
-        
-        if (isset($_POST['destroy'])) {
-            unset($_POST['destroy']);
-            unset($_SESSION['currentPipeline']);
-        }
-
-        if (isset($_POST['clearPipeline'])) {
-            $this->pipeline = array();
-            $_SESSION['currentPipeline'] = $this->pipeline;
-        }
-
-        if (isset($_SESSION['currentPipeline']) && !empty($_SESSION['currentPipeline'])) {      // take pipeline from session data
-            $this->pipeline = $_SESSION['currentPipeline'];
-        } else {
-            $pipeline = array();
-        }
-
-        if (isset($_POST['objectToCreate'])) {      // user clicked a button in the toolbox.
-            //$this->pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate'] . " NEW", null);
-            $this::AddStep($_POST['objectToCreate']);
-        }
-
-        if (isset($_POST['deleteSelected'])) {
-            if (isset($_POST['selectedStep'])) {
-                $this->RemoveStep($_POST['selectedStep']);
-            }
-        }
-
-        //var_dump($_POST);
-
-        if (isset($_POST['selectedStep'])) {
-            $this::SetSelected($_POST['selectedStep']);
-        }
-
-        $_SESSION['currentPipeline'] = $this->pipeline;
     }
 
@@ -180,11 +59,63 @@
         Add JS code for selecting steps, highlighting them, reordering, etc.
         Is a refresh of the page (with subsequent querying of database really necessary?
-        
+
         -->
         <script type="text/javascript">
-            function selectStep(step) {
-                step.addClass("selected");
-                document.sequencer.controls.selectedStep.value = step.name;
+            function selectStep(uid) {
+                document.getElementById(uid).addClass("selected");
+                document.sequencer.controls.selectedStep.value = uid;
             }
+                                                                            
+                                                                            
+            /*
+             * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
+             * Using ajax principle allows for editing of pipeline without constantly refreshing the page.
+             */
+                                                                            
+            function ajaxStepRequest(uid) {     
+                var xmlhttp;
+                if (window.XMLHttpRequest) {    // IE7+, FF, Chrome, Opera, Safari
+                    xmlhttp = new XMLHttpRequest();
+                }
+                else {  //IE 5, 6
+                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+                }
+                                                                                
+                xmlhttp.onreadystatechange = function () {
+                    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
+                        if (xmlhttp.responseText.length > 0) {
+                            var newDiv = xmlhttp.responseText;
+                            document.getElementById("seqContent").appendChild(newDiv);
+                        }   
+                    }
+                }
+                                        
+                xmlhttp.open("POST", "returnStep.php", true);
+                xmlhttp.send();
+            }
+                            
+            function drawSteps() {
+                var sequencer = document.getElementById("sequencer");
+                var seqContent = document.getElementById("seqContent");
+                
+                // first delete all current children of seqContent (to reset the sequencer).
+                while (seqContent.childNodes.length > 0) {
+                    var step = seqContent.childNodes[0];
+                    step.parentNode.removeChild(step);
+                }
+                
+                // get pipeline contents from hidden form inputs.
+                var pipeline = sequencer.controls.pipeline.value;
+                var pipeline = pipeline.split(", ");
+                
+                // then do an xmlhttp request for each step to be added to the sequencer
+                var numberOfSteps = pipeline.length;
+                for (var i = 0; i > numberOfSteps; i++) {
+                    ajaxStepRequest(pipeline[i]);
+                }
+                
+            }
+                                                                                
+                                                
         </script>
 
@@ -193,4 +124,12 @@
     }
 
+    public function GetDromDB() {   // Initialize variables on page load.
+        $dbi = new DatabaseInterface();
+        if (isset($_POST['currentSession'])) {
+            $currentSession = $dbi->get("Session", array("UID" => $uid));
+            $this->pipeline = $currentSession->pipeline;
+        }
+    }
+
 }
 ?>
