Index: Dev/trunk/classes/ApplicationConnector.php
===================================================================
--- Dev/trunk/classes/ApplicationConnector.php	(revision 142)
+++ Dev/trunk/classes/ApplicationConnector.php	(revision 144)
@@ -11,6 +11,6 @@
  * @author jkraaijeveld
  */
-class ApplicationConnector implements IConnector{
-    
+class ApplicationConnector implements IConnector {
+
     protected $model;
     protected $fileName = 'data/applications/applications.rdf';
@@ -19,11 +19,11 @@
      * Constructor for ApplicationConnector.
      */
-    public function __construct()
-    {
+    public function __construct() {
         //Ensure the required folder for this connector exists
-        if (!is_dir('data/applications/'))
-            mkdir('data/applications/');	
+        if (!is_dir('data/applications/')) {
+            mkdir('data/applications/', null, true);
+        }
     }
-    
+
     /**
      * function load()
@@ -33,10 +33,10 @@
         //Get the Memory Model from the ModelFactory
         $this->model = ModelFactory::getDefaultModel();
-        
+
         //Ensure the required file exists before loading
-        if(file_exists($this->fileName))
+        if (file_exists($this->fileName))
             $this->model->load($this->fileName);
     }
-    
+
     /**
      * function save()
@@ -44,7 +44,7 @@
      */
     public function save() {
-        $this->model->saveAs($this->fileName,'rdf'); 
+        $this->model->saveAs($this->fileName, 'rdf');
     }
-    
+
     /**
      * function get($arguments)
@@ -58,14 +58,17 @@
         $keys = array_keys($arguments);
         //Set default values for arguments
-        $uid = "?uid"; $title = "?title"; $description = "?description"; $style = "?style";
+        $uid = "?uid";
+        $title = "?title";
+        $description = "?description";
+        $style = "?style";
         //Set the arguments if they are supplied
-        if(in_array("uid", $keys))
-            $uid = "\"".$arguments["uid"]."\"";
-        if(in_array("title", $keys))
-            $title = '\''.$arguments["title"].'\'';
-        if(in_array("description", $keys))
-            $description = "\"".$arguments["description"]."\"";
-        if(in_array("style", $keys))
-            $style = "\"".$arguments["style"]."\"";    
+        if (in_array("uid", $keys))
+            $uid = "\"" . $arguments["uid"] . "\"";
+        if (in_array("title", $keys))
+            $title = '\'' . $arguments["title"] . '\'';
+        if (in_array("description", $keys))
+            $description = "\"" . $arguments["description"] . "\"";
+        if (in_array("style", $keys))
+            $style = "\"" . $arguments["style"] . "\"";
 
         //Create the querystring 
@@ -90,15 +93,13 @@
         $results = $this->model->sparqlQuery($querystring);
         $applications = array();
-        if(!empty($results))
-        {
+        if (!empty($results)) {
             //Run over all results and create appropriate Application objets
-            foreach($results as $result)
-            { 
-                    $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label);
+            foreach ($results as $result) {
+                $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label);
             }
         }
         return $applications;
     }
-    
+
     /**
      * function set()
@@ -107,8 +108,7 @@
      * @param type $rToolObject: The ResearchToolObject to be saved. 
      */
-    public function set($rToolObject)
-    {
+    public function set($rToolObject) {
         $this->load();
-        $resourceApplication = new Resource(APPLICATION.'/'.$rToolObject->uid);
+        $resourceApplication = new Resource(APPLICATION . '/' . $rToolObject->uid);
         //Remove the old value stored with the given id
         $this->model->subtract($this->model->find($resourceApplication, null, null));
@@ -117,24 +117,25 @@
         $resourceApplicationType = new Resource(APPLICATION);
         $predicateRType = new Resource(RTYPE);
-        $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
-		
+        $this->model->add(new Statement($resourceApplication, $predicateRType, $resourceApplicationType));
+
         $literalApplicationID = new Literal($rToolObject->uid);
         $predicateUniqueID = new Resource(UID);
-        $this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
+        $this->model->add(new Statement($resourceApplication, $predicateUniqueID, $literalApplicationID));
 
         $applicationTitle = new Literal($rToolObject->title);
-        $predicateTitle = new Resource(TITLE);	
-        $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));
+        $predicateTitle = new Resource(TITLE);
+        $this->model->add(new Statement($resourceApplication, $predicateTitle, $applicationTitle));
 
         $applicationDescription = new Literal($rToolObject->description);
         $predicateDescription = new Resource(DESCRIPTION);
-        $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));
+        $this->model->add(new Statement($resourceApplication, $predicateDescription, $applicationDescription));
 
         $applicationStyle = new Literal($rToolObject->style);
         $predicateStyle = new Resource(STYLE);
-        $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));
-		
-	$this->save();
+        $this->model->add(new Statement($resourceApplication, $predicateStyle, $applicationStyle));
+
+        $this->save();
     }
+
 }
 
Index: Dev/trunk/classes/DisplayStep.php
===================================================================
--- Dev/trunk/classes/DisplayStep.php	(revision 142)
+++ Dev/trunk/classes/DisplayStep.php	(revision 144)
@@ -18,24 +18,23 @@
     public $imageURL;
     public $selected = false;
-    public $name;
+    public $caption;
+    public $id;
 
-    public function __construct($t, $ref=null, $n) {
-        
+    public function __construct($t, $ref=null, $c, $id) {
+
         $this->type = $t;
         $this->reference = $ref;
-        $this->name = $n;
-        
+        $this->caption = $c;
+        $this->id = $id;
+
         switch ($this->type) {
             case "Questionnaire":
-                $this->imageURL = "images/icons/questionnaire2.png";
+                $this->imageURL = "images/icons/questionnaire.png";
                 break;
             case "Dashboard":
-                $this->imageURL = "images/icons/dashboard2.png";
+                $this->imageURL = "images/icons/dashboard.png";
                 break;
             case "Application":
-                $this->imageURL = "images/icons/application2.png";
-                break;
-            case "Notice":
-                $this->imageURL = "images/icons/notice2.png";
+                $this->imageURL = "images/icons/application.png";
                 break;
             default:
@@ -43,10 +42,8 @@
                 break;
         }
-        
+
         //output a display object
-        echo '<div class="displayStep" style="background-image: url(\'';
-        echo $this->imageURL;
-        echo '\');" ><p>'.$this->name.'</p></div>'."\n";
-        
+        //echo '<div class="displayStep"><div class="displayStepIcon" style="background-image: url('.$this->imageURL.');"></div>'.$this->caption.'</div>'."\n";
+        echo '<div class="displayStep"><div class="displayStepIcon"><img src="' . $this->imageURL . '" /></div>' . $this->caption . '</div>';
     }
 
Index: Dev/trunk/classes/Step.php
===================================================================
--- Dev/trunk/classes/Step.php	(revision 144)
+++ Dev/trunk/classes/Step.php	(revision 144)
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Placeholder class, for testing of pipelineEditor.php only.
+ * Will eventually be replaced by functioning Questionnaire, Notice, Dashboard and Application objects in array steps[].
+ *
+ * @author Thijs Schipper
+ */
+class Step {
+
+    public $type;
+    public $name;
+    public $id;
+
+    public function __construct($t, $n, $i) {
+
+        if (strtolower($t) == "application" || strtolower($t) == "dashboard" || strtolower($t) == "questionnaire") {
+            $this->name = $n;
+            $this->type = $t;
+            $this->id = $i;
+        }
+        else {
+            die("Invalid type given: ".$t."\n $n $i");
+        }
+    }
+
+}
+
+?>
Index: Dev/trunk/classes/Toolbox.php
===================================================================
--- Dev/trunk/classes/Toolbox.php	(revision 144)
+++ Dev/trunk/classes/Toolbox.php	(revision 144)
@@ -0,0 +1,33 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of ToolBox
+ *
+ * @author HP
+ */
+class Toolbox {
+
+    public function __construct() {
+        ?>
+
+        <br />
+        <form name="toolbox" action="pipelineEditor.php" method="POST">
+            <fieldset id="toolbox">
+                <div class="title">Toolbox</div>
+                <p>Add new: </p>
+                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Questionnaire'; SubmitToolbox();"><img src="images/icons/questionnaire.png" class="buttonIcon"/><p>Questionnaire</p></div>
+                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Application'; SubmitToolbox();"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div>
+                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>
+                <input type="hidden" name="objectToCreate" />
+
+            </fieldset>
+        </form>
+        <?php
+    }
+
+}
+?>
Index: Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- Dev/trunk/classes/pipelineSequencer.php	(revision 144)
+++ Dev/trunk/classes/pipelineSequencer.php	(revision 144)
@@ -0,0 +1,113 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Sequencer
+ *
+ * @author HP
+ */
+class pipelineSequencer {
+
+    // properties
+    private $steps;
+    private $title = "testSequencer";
+    private $id = 1;
+    private $numStepsInArray = 0;
+    private $maxNumStepsInArray = 8;
+    private $selectedStep;
+
+    public function __construct($steps) {
+        $this->steps = $steps;
+        $this->selectedStep = $this->steps[2];
+
+        $this->moveStep(1);
+
+//        echo '<br /><fieldset id="sequencer">'."\n\n";
+//        echo '<div class="title">Name: '.$this->title.'</div>';
+//        echo '<div class="seqContent">'."\n\n";
+//        echo '';
+//        echo '</div>';
+//        echo '</fieldset>';
+        ?>
+        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
+                <div class="title">Name: <?php echo $this->title; ?> </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="" disabled="true" />
+                    <input type="checkbox" name="confirmClear" />Really clear?
+                    <input type="hidden" name="selectedStep" />
+                </div>
+            </fieldset>
+        </form>
+        <?php
+    }
+
+    public function AddStep($step) {
+        $this->steps[] = $step;
+        ?>
+        <script type="text/javascript">
+            document.refresh();
+        </script>
+        <?php
+    }
+
+    public function RemoveStep($targetStep) {
+
+        $tempArray;
+        foreach ($this->steps as $step) {
+            if ($step != targetStep) {
+                $tempArray[] = $step;
+            }
+        }
+        $this->steps = $tempArray;
+    }
+
+    public function GetSteps() {
+        return $this->steps;
+    }
+
+    public function drawSteps() {
+        //draw the actual icons in the container div.
+        foreach ($this->steps as $step) {
+            if ($this->numStepsInArray < $this->maxNumStepsInArray) {
+                new DisplayStep($step->type, null, $step->name, $step->id);
+                $this->numStepsInArray++;
+                if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->steps)) {
+                    echo "<div class='divider'></div>";
+                }
+            }
+        }
+    }
+
+    public function moveStep($direction) {
+        $key = array_search($this->selectedStep, $this->steps);
+        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
+            }
+        }
+    }
+
+}
+?>
Index: Dev/trunk/css/awesome.css
===================================================================
--- Dev/trunk/css/awesome.css	(revision 142)
+++ Dev/trunk/css/awesome.css	(revision 144)
@@ -59,4 +59,5 @@
     background-image: url('../images/bg/blueishgridblock.png');
     height: 100%;
+    font-size: 12px;
 }
 
@@ -586,6 +587,19 @@
 #sequencer {
     width: 100%;
-    margin: 0 auto auto auto;
-    background-image: url('../images/bg/sequencerBG.png');
+    margin: 0 auto 0 auto;
+    /*background-image: url('../images/bg/sequencerBG.png');*/
+    background-image: linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -o-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -moz-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -webkit-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -ms-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+
+    background-image: -webkit-gradient(
+	linear,
+	left top,
+	left bottom,
+	color-stop(0.21, #B0B0B0),
+	color-stop(0.8, #888888)
+    );
     background-position: bottom;
     background-repeat: repeat-x;
@@ -597,15 +611,28 @@
     margin-top:0.5em;
     margin-left: 1em;
-    font-size: 1.2em;
+    font-size: 1.25em;
     color: #FFF;
     
 }
 
-#sequencer #seqContent {
-    height: 10em;
+#sequencer .seqContent {
+    height: 9em;
+    overflow-x: scroll;
+    overflow-y: hidden;
     margin-bottom: 0.5em;
-    background-image: url('../images/bg/sequencerContentBG.png');
-    /*background-position: top;
-    background-color: #dddddd;*/
+    
+    background-image: linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -o-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -moz-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -webkit-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -ms-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -webkit-gradient(
+	linear,
+	left bottom,
+	left top,
+	color-stop(0.25, #B0B0B0),
+	color-stop(0.8, #888888)
+    );
+    
     border: 1px solid #ddd;
     -moz-border-radius: 0.5em;
@@ -620,7 +647,8 @@
 }
 
-#seqContent .displayStep {
+.seqContent .displayStep {
     /*height: 140px;*/
-    width: 100px;
+    width: 52px;
+    padding: 0;
     margin: 10px 0 0 0;
     background-repeat: no-repeat;
@@ -629,27 +657,59 @@
 }
 
-#seqContent .displayStep p{
-    margin-top: 105px;
+.seqContent .displayStep .displayStepIcon {
+    width: 50px;
+    height: 50px;
+    border: 2px solid #444444;
+    color: #FFF;
+    float: left;
+}
+
+.seqContent .displayStep p{
+    margin-top: 55px;
     font-weight: normal;
     font-size: 0.875em;
+    float: left;
     
 }
 
-#seqContent .divider {
+.seqContent .divider {
     width: 10px;
-    height: 100px;
-    margin: 10px 5px 0 10px;
+    height: 50px;
+    margin: 10px 15px 0 20px;
     background-image: url('../images/ui/sequencerDivider.png');
     float: left;
 }
 
+
+
+
+
+
 /*
-    Toolbox
+ *
+ *
+ *  TOOLBOX
+ *
+ *
 */
 
 #toolbox {
-    width: 40%;
-    float: left;
-    background-image: url('../images/bg/sequencerBG.png');
+    /*width: 40%;*/
+    float: left;
+    /*background-image: url('../images/bg/sequencerBG.png');*/
+    background-image: linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -o-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -moz-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -webkit-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+    background-image: -ms-linear-gradient(top, #B0B0B0 21%, #888888 80%);
+
+    background-image: -webkit-gradient(
+	linear,
+	left top,
+	left bottom,
+	color-stop(0.25, #B0B0B0),
+	color-stop(0.8, #888888)
+    );
+    
 }
 
@@ -659,19 +719,29 @@
     margin-top:0.5em;
     margin-left: 1em;
-    font-size: 1.2em;
+    font-size: 1.25em;
     color: #FFF;
 }
 
-#toolbox .displayStep {
-    height: 140px;
-    width: 100px;
-    margin: 0 5px 0 5px;
-    background-repeat: no-repeat;
-    float: left;
-    text-align: center;
-}
-
-#toolbox .displayStep p {
-    margin-top: 105px;
-    color: #FFF;
-}
+#toolbox .creationButton {
+    height: 50px;
+    margin: 0 0 5px 0;
+    border: 1px solid #000;
+    border-radius: 5px;
+    -moz-border-radius: 5px;
+}
+
+#toolbox .creationButton:hover {
+    border: 1px solid #FFF;
+    background: rgba(255, 255, 255, 0.2);
+}
+
+#toolbox .buttonIcon {
+    margin: 0 10px 0 5px;
+    float: left;
+}
+
+#toolbox .creationButton p {
+    margin: 15px 10px 0 0;
+    color: #444;
+    float: left;
+}
Index: Dev/trunk/js/editorScripts.js
===================================================================
--- Dev/trunk/js/editorScripts.js	(revision 144)
+++ Dev/trunk/js/editorScripts.js	(revision 144)
@@ -0,0 +1,28 @@
+/* 
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+function IsItemSelected(check, target) {
+    if (check.value) {
+        target.disabled = false;
+    }
+    else {
+        target.disabled = true;
+    }
+}
+
+function IsCheckEnabled(check, target) {
+    if (check.checked) {
+        target.disabled = false;
+    }
+    else {
+        target.disabled = true;
+    }
+}
+
+function SubmitToolbox() {
+    document.forms['toolbox'].submit();
+}
+
+
Index: Dev/trunk/pipelineEditor.php
===================================================================
--- Dev/trunk/pipelineEditor.php	(revision 142)
+++ Dev/trunk/pipelineEditor.php	(revision 144)
@@ -2,41 +2,26 @@
 require 'classes/master.php'; //should be at top of every page
 
-/*
-  if(isset($_SESSION['username'])){   //user is logged in
-  //get pipeline contents from database, and store in displayObject() array "pipelineSteps"
-  //nu nog even gewoon een hardcoded workaround
-  foreach ()
 
-  }
- * */
+$pipeline = $_SESSION['currentPipeline'];
 
-// generate a random array of pipeline contents
-$displaySteps = array();    // array containing a number of random-generated stings "$type", to fill up the sequencer
-$numSteps = 9;              // number of steps to random-generate for testing purposes.
-$maxNumSteps = 9;           // maximum number of steps that can be displayed in the sequencer (without scrollbars, at current)
+// generate a set array of pipeline contents, in lieue of working database interface
+//if (isset($pipeline)){
+//$pipeline = array(new Step("Questionnaire", "Questionnaire 1", 1), new Step("Dashboard", "Dashboard 1", 2), new Step("Application", "Application 1", 3));
+//}
+//else {
+    $pipeline = $_SESSION['currentPipeline'];
+//}
 
-for ($n = 1; $n <= $numSteps; $n++) {   // fill the array of types
-    $rnd = rand(1, 4);
-    switch ($rnd) {
-        case 1:
-            $type = "Dashboard";
-            break;
-        case 2:
-            $type = "Questionnaire";
-            break;
-        case 3:
-            $type = "Notice";
-            break;
-        case 4:
-            $type = "Application";
-            break;
-        default:
-            $type = "Questionnaire";
-            break;
-    }
-    $displaySteps[] = $type;
+if (isset($_POST['objectToCreate'])){
+    $pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate']." NEW", 4);
+    unset($_POST);
 }
 
+$_SESSION['currentPipeline'] = $pipeline;
+
+$pipelineCount = 3;
 $pipelineName = "Test pipeline";
+
+$dbi = new DatabaseInterface();       //mkdir error?!?!?!
 ?>
 
@@ -46,4 +31,5 @@
 -->
 <!DOCTYPE html>
+
 <html>
     <head>
@@ -53,7 +39,8 @@
         <script type="text/javascript" src="js/menu.js"></script>
         <script type="text/javascript" src="js/jquery.jps"></script>
+        <script type="text/javascript" src="js/editorScripts.js"></script>
     </head>
     <body>
-        <div id="logo">
+        <div id="header">
             <?php new Logo(); ?>
         </div>
@@ -61,46 +48,6 @@
         <div id="wrapper">
             <div id="content">
-                <form action="pipelineEditor.php" method="POST">
-                    
-                    <fieldset id="sequencer">
-                        
-                        <div class="title">Name: <?php echo $pipelineName; ?></div>
-
-                        <div id="seqContent">
-                            <?php
-                            $n = 0;
-                            foreach ($displaySteps as $displayStep) {
-                                if ($n <= $maxNumSteps) {
-                                    $n++;
-                                    new DisplayStep($displayStep, null, "Step " . $n);
-                                    if ($n != $numSteps){
-                                        echo "<div class='divider'></div>";
-                                    }
-                                }
-                            }
-                            ?>                                
-                        </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="hidden" name="selectedStep" />
-                        </div>
-
-                    </fieldset>
-                    
-                    <br />
-                    <fieldset id="toolbox">
-                        <div class="title">Toolbox</div>
-                        <?php
-                            new DisplayStep("Questionnaire", null, "Questionnaire");
-                            new DisplayStep("Notice", null, "Notice");
-                            new DisplayStep("Application", null, "Application");
-                            new DisplayStep("Dashboard", null, "Dashboard");
-                        ?>
-                    </fieldset>
-                </form>
+                <?php new pipelineSequencer($pipeline); ?>
+                <?php new Toolbox(); ?>
             </div>
     </body>
Index: Dev/trunk/pipelineEditor_1.php
===================================================================
--- Dev/trunk/pipelineEditor_1.php	(revision 144)
+++ Dev/trunk/pipelineEditor_1.php	(revision 144)
@@ -0,0 +1,224 @@
+<?php
+require 'classes/master.php'; //should be at top of every page
+
+/*  So far, the entire page works based on sessions.
+ *  We want it to load the database stuff into the session on user load, and only write back to database when you exit the page.
+ *  Is this possible with the current db model?
+ * 
+ */
+
+// Reset session, for debug purposes only!
+if (isset($_POST['resetSession'])) {
+    unset($_SESSION['steps']);
+    $_SESSION['selectedStep'] = null;
+}
+
+// Clear entire pipeline, confirm checkbox checked!
+if (isset($_POST['clearPipeline']) && isset($_POST['confirmClear'])) {
+    unset($_SESSION['steps']);
+    $_SESSION['steps'] = array();
+}
+
+// Upon first page load, generate a placeholder array of Steps. (Only string at the moment!)
+if (!isset($_SESSION['steps'])) {
+    $_SESSION['steps'] = array("Questionnaire 1", "Questionnaire 2", "Notice 1", "Application 1", "Dashboard 1");
+    $_SESSION['selectedStep'] = null;
+}
+
+// if user clicked "remove" button
+if (isset($_POST['removeStep'])) {
+    if (isset($_POST['pipelineContents'])) {        // if a step has been selected
+        $toBeRemoved = $_POST['pipelineContents'];
+        $tempArray = array();
+        foreach ($_SESSION['steps'] as $step) {
+            if ($step != $toBeRemoved) {
+                $tempArray[] = $step;
+            }
+        }
+        $_SESSION['steps'] = $tempArray;
+        unset($tempArray);
+        unset($toBeRemoved);
+        $_SESSION['selectedStep'] = null;
+    }
+}
+
+/*
+ * 
+ *  Object creating code
+ *  
+ */
+
+//  Questionnaire
+if (isset($_POST['createQuestionnaire'])) {
+    $n = 1;
+    while (in_array("Questionnaire $n", $_SESSION['steps'])) {
+        $n++;
+    }
+    $_SESSION['steps'][] = "Questionnaire $n";
+    $_SESSION['selectedStep'] = "Questionnaire $n";
+}
+
+//  Notice
+if (isset($_POST['createNotice'])) {
+    $n = 1;
+    while (in_array("Notice $n", $_SESSION['steps'])) {
+        $n++;
+    }
+    $_SESSION['steps'][] = "Notice $n";
+    $_SESSION['selectedStep'] = "Notice $n";
+}
+
+// Application
+if (isset($_POST['createApplication'])) {
+    $n = 1;
+    while (in_array("Application $n", $_SESSION['steps'])) {
+        $n++;
+    }
+    $_SESSION['steps'][] = "Application $n";
+    $_SESSION['selectedStep'] = "Application $n";
+}
+
+//  Dashboard
+if (isset($_POST['createDashboard'])) {
+    $n = 1;
+    while (in_array("Dashboard $n", $_SESSION['steps'])) {
+        $n++;
+    }
+    $_SESSION['steps'][] = "Dashboard $n";
+    $_SESSION['selectedStep'] = "Dashboard $n";
+}
+
+/*
+ * 
+ * Move up/down code
+ * 
+ */
+
+
+if (isset($_POST['moveUp'])) {          // if user clicked "Move up" button
+    if (isset($_POST['pipelineContents'])) {     // if user has selected a pipeline step
+        $arrayCopy = $_SESSION['steps'];     // copy session contents to local variable, to prevent messing up the session by accident
+        $key = array_search($_POST['pipelineContents'], $arrayCopy);     // find key of target entry in array
+        $_SESSION['selectedStep'] = $arrayCopy[$key];
+        moveEntry($arrayCopy, $key, -1);
+        $_SESSION['steps'] = $arrayCopy;
+    }
+}
+
+if (isset($_POST['moveDown'])) {          // if user clicked "Move up" button
+    if (isset($_POST['pipelineContents'])) {     // if user has selected a pipeline step
+        $arrayCopy = $_SESSION['steps'];     // copy session contents to local variable, to prevent messing up the session by accident
+        $key = array_search($_POST['pipelineContents'], $arrayCopy);     // find key of target entry in array
+        $_SESSION['selectedStep'] = $arrayCopy[$key];
+        moveEntry($arrayCopy, $key, 1);
+        $_SESSION['steps'] = $arrayCopy;
+    }
+}
+
+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
+        }
+    }
+}
+
+/*
+ * 
+ *  Edit code
+ * 
+ */
+
+if (isset($_POST['editStep'])) {
+    editStep($_POST['pipelineContents']);
+}
+
+function editStep($step) {
+    $_SESSION['activeStep'] = $step;
+    switch (strtolower(substr($step, 0, strlen($step) - 2))) {
+        case "questionnaire":
+            redirect("editQuestionnaire.php?UID=$step->uid");
+            break;
+        case "notice":
+            redirect("editNotice.php?UID=$step->uid");
+            break;
+        case "application":
+            redirect("editApplication.php?UID=$step->uid");
+            break;
+        case "dashboard":
+            redirect("editDashboard.php?UID=$step->uid");
+            break;
+        default:
+            die("Invalid or no step type selected!");
+            break;
+    }
+}
+?>
+<!--
+To change this template, choose Tools | Templates
+and open the template in the editor.
+-->
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title></title>
+        <?php new StyleSheet("awesome"); ?>
+        <script type="text/javascript" src="js/menu.js"></script>
+        <script type="text/javascript" src="js/jquery.js"></script>
+        <script type="text/javascript" src="js/editorScripts.js"></script>
+    </head>
+    <body onLoad="IsItemSelected(document.mainForm.pipelineContents, document.mainForm.editStep);">
+        <div id="header">
+            <?php new Logo(); ?>
+        </div>
+
+        <div id="wrapper">
+            <div id="content">
+                <form name ="mainForm" action="pipelineEditor_1.php" method="POST">
+                    <fieldset>
+                        <select name="pipelineContents" style="width: 300px;" size="8" onChange="IsItemSelected(this, document.mainForm.editStep);">
+                            <?php
+                            foreach ($_SESSION['steps'] as $step) {
+                                echo '<option value="' . $step . '" ';
+                                if ($step == $_SESSION['selectedStep']) {
+                                    echo 'selected ="selected"';
+                                }
+                                echo '>' . $step . '</option>' . "\n";
+                            }
+                            ?>
+
+
+                        </select>
+                        <input type="submit" name="editStep" value="Edit" disabled="true"/>
+                        <input type="submit" name="removeStep" value="Remove" />
+                        <input type="submit" name="moveUp" value="Move up" />
+                        <input type="submit" name="moveDown" value="Move down" />
+                        <input type="submit" name="clearPipeline" value="Clear pipeline" disabled="true"/>
+                        <input type="checkbox" name="confirmClear" onClick="IsCheckEnabled(this, document.mainForm.clearPipeline)"/> Really delete all?
+
+
+                    </fieldset>
+
+                    <fieldset>
+                        Add:
+                        <input type="submit" name="createQuestionnaire" value="Questionnaire" />
+                        <input type="submit" name ="createNotice" value="Notice" />
+                        <input type="submit" name="createApplication" value="Application" />
+                        <input type="submit" name="createDashboard" value="Dashboard" />
+                    </fieldset>
+
+                    <fieldset>
+                        <label>Debug</label>
+                        <input type="submit" name="resetSession" value="Reset Session" />
+                    </fieldset>
+                </form>
+            </div>
+    </body>
+</html>
Index: Dev/trunk/register.php
===================================================================
--- Dev/trunk/register.php	(revision 142)
+++ Dev/trunk/register.php	(revision 144)
@@ -6,5 +6,5 @@
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <title>Facilitator</title>
-        <?php new StyleSheet(); ?>
+        <?php new StyleSheet("awesome"); ?>
         <script type="text/javascript" src="js/menu.js"></script>
     </head>
