Changeset 151 for Dev/trunk/classes
- Timestamp:
- 11/08/11 17:02:55 (13 years ago)
- Location:
- Dev/trunk/classes
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/Logo.php
r142 r151 15 15 // hardcoded logo div, image is defined in stylesheet. (#logo background:"";) 16 16 public function __construct() { 17 echo ' 18 <div id="logo"><a href="index.php">Research Tool</a></div> 19 '; 17 echo '<div id="logo"><a href="index.php">Research Tool</a>'; 18 if (isset($_SESSION['username'])) { 19 echo '<a href="logout.php" style="font-size: 12pt;">Log out</a>'; 20 } 21 echo '</div>'; 20 22 21 23 } -
Dev/trunk/classes/SessionConnector.php
r149 r151 186 186 $this->model->add(new Statement($resourceSession, $predicateTitle, $sessionTitle)); 187 187 188 $sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp()); 189 $predicateTimestamp = new Resource(DATETIME); 188 //$sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp()); 189 $sessionTimestamp = new Literal($rToolObject->datetime); // Edit of above function, allows for creation of session, but still results in errors... 190 $predicateTimestamp = new Resource(DATETIME); 190 191 $this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp)); 191 192 -
Dev/trunk/classes/pipelineSequencer.php
r150 r151 6 6 7 7 /** 8 * Description of Sequencer8 * A visual interface object for editing and viewing a session's pipeline. 9 9 * 10 * @author HP10 * @author Tschipper 11 11 */ 12 12 class PipelineSequencer { 13 13 14 14 // properties 15 private $pipeline; 15 private $pipeline; // array of UID strings. 16 16 private $name = "empty"; 17 17 private $numStepsInArray = 0; … … 21 21 public function __construct($uid) { 22 22 $dbi = new DatabaseInterface(); 23 $this->pipeline = $dbi->get("pipeline", array("uid" =>$uid));23 $this->pipeline = $dbi->get("pipeline", array("uid" => $uid)); 24 24 } 25 25 26 26 public function init() { 27 27 ?> 28 <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer"> 28 <br /><form name="sequencer" action="pipelineEditor.php" method="post"> 29 <fieldset id="sequencer"> 29 30 <div class="title">Name: <?php echo $this->pipeline->name; ?> </div> 30 31 31 <div class="seqContent">32 <div id="seqContent"> 32 33 <?php $this->DrawSteps(); ?> 33 34 </div> … … 41 42 <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear? 42 43 <input type="hidden" name="selectedStep" /> 44 <input type="hidden" name="numSteps" /> 45 <input type="hidden" name="pipeline" /> 43 46 </div> 44 47 </fieldset> … … 47 50 } 48 51 49 public function AddStep($newStep) {50 $n = 1;51 foreach ($this->pipeline as $existingStep) {52 if ($existingStep->name == $newStep . " $n") {53 $n++;54 }55 }56 57 $this->pipeline[] = new Step($newStep, $newStep . " " . $n, count($this->pipeline) + 1);58 //var_dump($this->pipeline);59 ?>60 <script type="text/javascript">61 document.refresh();62 </script>63 <?php64 }65 66 public function RemoveStep($targetStep) {67 68 $tempArray = array();69 $removed = false;70 foreach ($this->pipeline as $step) {71 if ($step->id != $targetStep) {72 $tempArray[] = $step;73 if ($removed) {74 $step::AdjustID(-1);75 }76 } else {77 $removed = true;78 }79 }80 $this->pipeline = $tempArray;81 }82 83 public function GetPipeline() {84 return $this->pipeline;85 }86 87 52 public function DrawSteps() { 88 //draw the actual icons in the container div.89 if (!empty($this->pipeline)) {90 foreach ($this->pipeline as $step) {91 if ($this->numStepsInArray < $this->maxNumStepsInArray) {92 //var_dump($step);93 $step->init();94 $this->numStepsInArray++;95 if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->pipeline)) {96 echo "<div class='divider'></div>";97 }98 }99 }100 }101 }102 103 public function MoveStep($direction) {104 $key = array_search($this->selectedStep, $this->pipeline);105 //echo $key;106 }107 108 private function MoveEntry(&$array, $key, $dir) {109 if ($dir == -1) { // move up110 if ($key > 0) {111 $reverseArray = array_reverse(array_slice($array, $key - 1, 2, true)); // make a reversed array of the two entries, preserving keys112 array_splice($array, $key - 1, 2, $reverseArray); // replace the given range in the oldArray with the reversed Array113 }114 } else if ($dir == 1) { // move down115 if ($key < count($array) - 1) {116 $reverseArray = array_reverse(array_slice($array, $key, 2, true)); // make a reversed array of the two entries, preserving keys117 array_splice($array, $key, 2, $reverseArray); // replace the given range in the oldArray with the reversed Array118 }119 }120 }121 122 public function SetSelected($key) {123 124 if ($key > 0 && $key < count($this->pipeline)) {125 $this->selectedStep = $key;126 }127 }128 129 public function GetName($name) {130 if ($name && $name != "") {131 $this->name = $name;132 }133 }134 135 public function HandlePost() {136 137 //this doesn't actually work, the sequencer doesn't know what the uid is yet. This data should be POSTed upon refresh!138 53 139 140 141 if (isset($_POST['destroy'])) {142 unset($_POST['destroy']);143 unset($_SESSION['currentPipeline']);144 }145 146 if (isset($_POST['clearPipeline'])) {147 $this->pipeline = array();148 $_SESSION['currentPipeline'] = $this->pipeline;149 }150 151 if (isset($_SESSION['currentPipeline']) && !empty($_SESSION['currentPipeline'])) { // take pipeline from session data152 $this->pipeline = $_SESSION['currentPipeline'];153 } else {154 $pipeline = array();155 }156 157 if (isset($_POST['objectToCreate'])) { // user clicked a button in the toolbox.158 //$this->pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate'] . " NEW", null);159 $this::AddStep($_POST['objectToCreate']);160 }161 162 if (isset($_POST['deleteSelected'])) {163 if (isset($_POST['selectedStep'])) {164 $this->RemoveStep($_POST['selectedStep']);165 }166 }167 168 //var_dump($_POST);169 170 if (isset($_POST['selectedStep'])) {171 $this::SetSelected($_POST['selectedStep']);172 }173 174 $_SESSION['currentPipeline'] = $this->pipeline;175 54 } 176 55 … … 180 59 Add JS code for selecting steps, highlighting them, reordering, etc. 181 60 Is a refresh of the page (with subsequent querying of database really necessary? 182 61 183 62 --> 184 63 <script type="text/javascript"> 185 function selectStep( step) {186 step.addClass("selected");187 document.sequencer.controls.selectedStep.value = step.name;64 function selectStep(uid) { 65 document.getElementById(uid).addClass("selected"); 66 document.sequencer.controls.selectedStep.value = uid; 188 67 } 68 69 70 /* 71 * ajaxStepRequest gets the markup for displaying a step in the sequencer from returnStep.php 72 * Using ajax principle allows for editing of pipeline without constantly refreshing the page. 73 */ 74 75 function ajaxStepRequest(uid) { 76 var xmlhttp; 77 if (window.XMLHttpRequest) { // IE7+, FF, Chrome, Opera, Safari 78 xmlhttp = new XMLHttpRequest(); 79 } 80 else { //IE 5, 6 81 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 82 } 83 84 xmlhttp.onreadystatechange = function () { 85 if (xmlhttp.readyState==4 && xmlhttp.status==200) { 86 if (xmlhttp.responseText.length > 0) { 87 var newDiv = xmlhttp.responseText; 88 document.getElementById("seqContent").appendChild(newDiv); 89 } 90 } 91 } 92 93 xmlhttp.open("POST", "returnStep.php", true); 94 xmlhttp.send(); 95 } 96 97 function drawSteps() { 98 var sequencer = document.getElementById("sequencer"); 99 var seqContent = document.getElementById("seqContent"); 100 101 // first delete all current children of seqContent (to reset the sequencer). 102 while (seqContent.childNodes.length > 0) { 103 var step = seqContent.childNodes[0]; 104 step.parentNode.removeChild(step); 105 } 106 107 // get pipeline contents from hidden form inputs. 108 var pipeline = sequencer.controls.pipeline.value; 109 var pipeline = pipeline.split(", "); 110 111 // then do an xmlhttp request for each step to be added to the sequencer 112 var numberOfSteps = pipeline.length; 113 for (var i = 0; i > numberOfSteps; i++) { 114 ajaxStepRequest(pipeline[i]); 115 } 116 117 } 118 119 189 120 </script> 190 121 … … 193 124 } 194 125 126 public function GetDromDB() { // Initialize variables on page load. 127 $dbi = new DatabaseInterface(); 128 if (isset($_POST['currentSession'])) { 129 $currentSession = $dbi->get("Session", array("UID" => $uid)); 130 $this->pipeline = $currentSession->pipeline; 131 } 132 } 133 195 134 } 196 135 ?>
Note: See TracChangeset
for help on using the changeset viewer.