- Timestamp:
- 11/09/11 17:14:25 (13 years ago)
- Location:
- Dev/trunk
- Files:
-
- 1 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SessionConnector.php
r151 r152 60 60 $uid = ""; $title = ""; $datetime = ""; $applications = ""; $surveys = ""; $answersets = ""; 61 61 if(in_array("uid", $keys)) 62 $uid = 'predicates:uid \''.$argu ements["uid"].'\' ';62 $uid = 'predicates:uid \''.$arguments["uid"].'\' '; 63 63 if(in_array("title", $keys)) 64 64 $title = 'predicates:title \''.$arguments["title"].'\' '; -
Dev/trunk/classes/pipelineSequencer.php
r151 r152 13 13 14 14 // properties 15 private $pipeline; // array of UID strings. 16 private $name = "empty"; 17 private $numStepsInArray = 0; 18 private $maxNumStepsInArray = 10; 15 private $loadedSession; 19 16 private $selectedStep; 20 17 21 public function __construct($uid) { 22 $dbi = new DatabaseInterface(); 23 $this->pipeline = $dbi->get("pipeline", array("uid" => $uid)); 18 public function __construct() { 19 //nothing yet 24 20 } 25 21 … … 28 24 <br /><form name="sequencer" action="pipelineEditor.php" method="post"> 29 25 <fieldset id="sequencer"> 30 <div class="title">Name: <?php echo $this-> pipeline->name; ?> </div>26 <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div> 31 27 32 28 <div id="seqContent"> … … 56 52 private function Javascript() { 57 53 ?> 58 <!-- 59 Add JS code for selecting steps, highlighting them, reordering, etc. 60 Is a refresh of the page (with subsequent querying of database really necessary? 61 62 --> 63 <script type="text/javascript"> 64 function selectStep(uid) { 65 document.getElementById(uid).addClass("selected"); 66 document.sequencer.controls.selectedStep.value = uid; 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 120 </script> 121 54 <script type="text/javascript" src="js/sequencerScripts.js"></script> 122 55 123 56 <?php 124 57 } 125 58 126 public function Get DromDB() { // Initialize variables on page load.59 public function GetFromDB($currentSession) { // Initialize variables on page load. 127 60 $dbi = new DatabaseInterface(); 128 if (isset($_POST['currentSession'])) { 129 $currentSession = $dbi->get("Session", array("UID" => $uid)); 130 $this->pipeline = $currentSession->pipeline; 61 if (!isset($currentSession)) { 62 $_SESSION['message'] = "No session set!"; 63 redirect("selectSession.php"); 64 } 65 66 $sessionResults = $dbi->get("Session", array("uid" => $currentSession)); 67 if (count($sessionResults) > 0) { 68 $this->loadedSession = $sessionResults[0]; 69 } 70 else { 71 die("Invalid session!"); 131 72 } 132 73 } -
Dev/trunk/index.php
r151 r152 56 56 57 57 if (isset($_SESSION['username'])) { 58 redirect(' pipelineEditor.php');58 redirect('selectSession.php'); 59 59 } 60 60 ?> -
Dev/trunk/js/sequencerScripts.js
r150 r152 29 29 } 30 30 31 32 33 /*34 * Selection code35 *36 */37 38 function checkSelectedStep(number){39 document.sequencer.selectedStep.value = number;40 var step = document.getElementById("seqContent")41 document.refresh();42 }43 44 function highlightSelectedStep() {45 46 }47 48 49 50 51 52 53 54 55 56 57 31 // Class manipulation 58 32 59 33 function hasClass(ele,cls) { 60 34 return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); 61 35 } 62 36 63 37 function addClass(ele,cls) { 64 38 if (!this.hasClass(ele,cls)) ele.className += " "+cls; 65 39 } 66 40 67 41 function removeClass(ele,cls) { 68 69 70 71 42 if (hasClass(ele,cls)) { 43 var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); 44 ele.className=ele.className.replace(reg,' '); 45 } 72 46 } 73 47 48 //new scripts! 49 //start here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 50 51 function selectStep(uid) { 52 document.getElementById(uid).addClass("selected"); 53 document.sequencer.controls.selectedStep.value = uid; 54 } 55 56 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 80 /* 81 * This function allows for simple use of AJAX requests. 82 * Calling format: 83 * 84 * var c[] = "uid=123"; 85 * var c[] = "name=tschipper"; 86 * var u = "getResult.php"; 87 * newAjaxRequest(c, u, function(xml) { 88 * <!--Do something--> 89 * }); 90 * 91 * It is of course also possible to refer to an external function instead of 92 * defining function(xml){} in the call itself, as below: 93 * 94 * newAjaxRequest(c, u, externalFunction(xml)); 95 */ 96 97 function newAjaxRequest(c, u, cb) { 98 99 var xml; 100 var content = c; //an array of strings, in "key=value" format. 101 // assign a compatible request format 102 if (window.XMLHttpRequest) { //Not IE5, IE6 103 xml = new XMLHttpRequest(); 104 } 105 else { //IE5, IE6 106 xml = new ActiveXObject("Microsoft.XMLHTTP"); 107 } 108 // subscribe the callback function to a response event 109 xml.onreadystatechange = function() { 110 if (xml.readyState == 4 && xml.status == 200) { 111 //alert("Received!"); 112 cb(xml); 113 } 114 }; 115 // initialize XMLRequest 116 xml.open("POST", u, true); 117 xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 118 var contentString = ""; 119 //iterate through parameters passed in variable c 120 if (typeof(content)=='object'&&(input instanceof Array)) { // parameters were passed as an array of key=value strings 121 for (var i = 0; i < content.length; i++) { 122 contentString += content[i]; 123 if (i != (content.length - 1)) { 124 contentString += "&"; 125 } 126 } 127 } 128 else { // single parameter or string already formatted by calling function 129 contentString = content; 130 } 131 // finally send the formatted request 132 //alert(contentString); 133 xml.send(contentString); 134 } 135 136 137 function 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 151 // then do an xmlhttp request for each step to be added to the sequencer 152 var numberOfSteps = pipeline.length; 153 for (var i = 0; i > numberOfSteps; i++) { 154 ajaxStepRequest(pipeline[i]); 155 } 156 157 } 158 -
Dev/trunk/logout.php
r151 r152 6 6 require 'classes/master.php'; 7 7 8 unset($_SESSION['username']);8 session_destroy(); 9 9 redirect("index.php"); 10 10 ?> -
Dev/trunk/pipelineEditor.php
r151 r152 3 3 4 4 if (!isset($_SESSION['username'])) { 5 $_SESSION['message'] = "You were redirected here because your session timed out or you used an invalid link."; 5 6 redirect('index.php'); 6 7 } 7 8 8 $dbtemp = new DatabaseInterface(); 9 10 11 if (!isset($_SESSION['currentSession'])) { 12 redirect('selectSession.php'); 13 } 14 15 $dbi = new DatabaseInterface(); 16 $sessions = $dbi->get("session", array("user"=>$_SESSION['username'])); 17 18 19 20 21 22 if (isset($_SESSION['currentPipeline'])) { 23 $sequencer = new PipelineSequencer($_SESSION['currentPipeline'], "Test Pipeline #1", 1); 24 } else { 25 $sequencer = new PipelineSequencer(null, "Test Pipeline #1", 1); 26 } 27 28 $sequencer->HandlePost(); // doesn't actually currently get from db, uses session/post as a temporary alternative. 9 $sequencer = new PipelineSequencer(); 10 $sequencer->GetFromDB($_SESSION['currentSession']); 29 11 ?> 30 12 … … 39 21 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 40 22 <title></title> 41 <?php new StyleSheet("awesome"); ?>23 <?php new StyleSheet("awesome"); ?> 42 24 <script type="text/javascript" src="js/menu.js"></script> 43 25 <script type="text/javascript" src="js/jquery.jps"></script> … … 46 28 <body> 47 29 <div id="header"> 48 <?php new Logo(); ?>30 <?php new Logo(); ?> 49 31 </div> 50 32 51 33 <div id="wrapper"> 52 34 <div id="content"> 53 <?php $sequencer->init(); ?>54 <?php $toolbox = new Toolbox(); ?>35 <?php $sequencer->init(); ?> 36 <?php $toolbox = new Toolbox(); ?> 55 37 </div> 56 38 </body> -
Dev/trunk/selectSession.php
r151 r152 5 5 redirect("index.php"); 6 6 } 7 8 if (isset($_SESSION['message'])) { 9 echo $_SESSION['message']; 10 unset($_SESSION['message']); 11 } 12 7 13 $dbi = new DatabaseInterface(); 14 8 15 if (isset($_POST['createSession'])) { 9 16 //check if name is set … … 11 18 // check if name is available 12 19 if (!empty($_POST['newSessionName'])) { 13 $matching Names= $dbi->get("Session", array("title" => $_POST['newSessionName']));14 if (count($matching Names) == 0) {20 $matching = $dbi->get("Session", array("title" => $_POST['newSessionName'])); 21 if (count($matching) == 0) { 15 22 // make new session! 23 unset($matching); 16 24 $session = new Session(null, $_POST['newSessionName'], null, null, null); 17 25 $dbi->set($session); … … 25 33 } 26 34 35 if (isset($_POST['deleteSession'])) { 36 if (isset($_POST['sessionUID'])) { 37 //Kan de database al objecten verwijderen? 38 } 39 } 40 41 if (isset($_POST['editSession'])) { 42 if (isset($_POST['sessionUID'])) { 43 $matching = $dbi->get("SESSION", array("uid" => $_POST['sessionUID'])); 44 if (count($matching) == 1 && $matching[0] != null) { 45 $_SESSION['currentSession'] = $_POST['sessionUID']; 46 redirect("pipelineEditor.php"); 47 } 48 } 49 } 50 27 51 //Get available sessions for current user 28 //$sessions = $dbi->get("Session", array("creator"=>$_SESSION['username'])); // Dit werkt niet, SessionConnector/Session.php hebben nog geen creator property29 $sessions = $dbi->get("Session", array()); // In plaats daarvan maar gewoon alles laden dan... lol30 var_dump($sessions);52 //$sessions = $dbi->get("Session", array("creator"=>$_SESSION['username'])); //This does not work, session.php does not yet have a property 'creator' 53 $sessions = $dbi->get("Session", array()); // Let's just load everything then... 54 //var_dump($sessions); 31 55 ?> 32 56 … … 37 61 <title>Select a session</title> 38 62 <?php new StyleSheet("awesome"); ?> 63 <script type="text/javascript" src="js/sequencerScripts.js"></script> 39 64 </head> 40 65 <body> 41 66 <form action="selectSession.php" method="POST"> 42 67 <fieldset name="selectionMenu"> 43 <select name="sessionName" style="float: left;"> 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'));"> 44 70 <?php 45 71 foreach ($sessions as $session) { 46 echo '<option value="' . $session->uid . '">' . $session->title . '</option>' ;72 echo '<option value="' . $session->uid . '">' . $session->title . '</option>' . "\n"; 47 73 } 48 74 ?> … … 63 89 </fieldset> 64 90 <fieldset id="sessionDescription"> 65 91 Info goes here: 66 92 </fieldset> 67 93 </form>
Note: See TracChangeset
for help on using the changeset viewer.