//before we can generate anything we need to determine whether to deal with a session session_start(); if( isset($_GET['targetTimeline']) && is_numeric($_GET['targetTimeline']) && $_GET['targetTimeline']>=1 ){ //they appear to have submitted a target $_SESSION['targetTimeline']=$_GET['targetTimeline']; } elseif( isset($_SESSION['targetTimeline']) ){ $targetTimeline=$_SESSION['targetTimeline']; } $pageTitle="Visualizations :: Timelines :: Manage Timelines"; include($_SERVER['DOCUMENT_ROOT'] . "/template/header.php"); function format_display_date($y, $m, $d){ //if the month and day are both 1 then we ONLY show the year if($m==1 && $d==1) return "$y"; //if the month is other than 1 and the day is one we dispay the month as well if($m>1 && $d==1) return date("M", mktime(0, 0, 0, $m, 1, 2005)) . " " .$y; //if the day is other than 1 we show the full date if($d>1) return date("M", mktime(0, 0, 0, $m, 1, 2005)) . " $d, $y"; return false; } function display_alert_box($displayString=false, $goodBad="bad"){ $goodBad=strtolower($goodBad); if($displayString && strlen($displayString)>=1 && ($goodBad=="good" || $goodBad=="bad")){ if($goodBad=="good"){ echo "
\n"; } else{ echo " \n"; } } else{ return false; } } //a boolean that decides whether any search results were found so we can determine whether to let them add to a timeline $searchResultsFound=false; ?> //we need to determine if the timeline they want to edit is legit and owned by them if(user_logged_in() && !$doingLogout){ $username=$_COOKIE['sclcr']; if( isset($_SESSION['targetTimeline']) ){ //check if this session is legit $mysqlQuery="SELECT title, contributor, id FROM Timelines WHERE id=" . $_SESSION['targetTimeline'] . " LIMIT 1"; $result=database_query($mysqlQuery); if($result && mysql_num_rows($result)==1){ //the timeline exists, lets check if this is the right author $myrow=mysql_fetch_row($result); if($myrow[1]==$username){ //this is the right author //we are good to go $targetTimelineName=$myrow[0]; //display_alert_box("Currently Editing Timeline: $myrow[0] (id: $myrow[2]) [edit a different timeline]", "good"); //echo "Currently Editing Timeline: $myrow[0] (id: $myrow[2]) [edit a different timeline]
\n"; } else{ //this is the wrong user, they can't edit this timeline display_alert_box("WRONG USER", "bad"); session_destroy(); } } else{ //the timeline id they suggest doesn't appear to exit display_alert_box("CAN'T FIND THE SUPPLIED ID", "bad"); session_destroy(); } } else{ //there is no targetTimeline session set echo "You are currently browsing timeline items. If you wish to add any of these items to a timeline click here.
\n"; session_destroy(); } } else{ //no one is logged in so we didn't bother even checking display_alert_box("NO ONE LOGGED IN - DIDN'T TRY", "bad"); session_destroy(); } ?>Create events to use on timelines
Create people to use on timelines
Create citations to use on timelines
//we only show this section if we are editing a timeline if($targetTimeline && $targetTimeline>0){ ?>Concepts
$sql="SELECT ConceptsBeta.concept, ConceptsBeta.year, ConceptsBeta.conception FROM ConceptsBeta, TimelineObjects WHERE TimelineObjects.type='C' AND TimelineObjects.objectID=ConceptsBeta.id AND TimelineObjects.timelineID=$targetTimeline";
$result=database_query($sql);
if($result){
if(mysql_num_rows($result)>=1){
while($myrow=mysql_fetch_row($result)){
echo "$myrow[0] ($myrow[1])
\n";
}
}
else{
echo "None Yet";
}
}
else{
//error in DB
echo "error in DB";
}
?>
People
$sql="SELECT TimelinePeople.name, TimelinePeople.description, YEAR(TimelinePeople.start) FROM TimelinePeople, TimelineObjects WHERE TimelineObjects.type='P' AND TimelineObjects.objectID=TimelinePeople.id AND TimelineObjects.timelineID=$targetTimeline";
$result=database_query($sql);
if($result){
if(mysql_num_rows($result)>=1){
while($myrow=mysql_fetch_row($result)){
echo "$myrow[0] ($myrow[2])
\n";
}
}
else{
echo "none";
}
}
else{
//error in DB
echo "error in DB";
}
?>
Events
$sql="SELECT TimelineEvents.title, TimelineEvents.description, YEAR(TimelineEvents.start) FROM TimelineEvents, TimelineObjects WHERE TimelineObjects.type='E' AND TimelineObjects.objectID=TimelineEvents.id AND TimelineObjects.timelineID=$targetTimeline";
$result=database_query($sql);
if($result){
if(mysql_num_rows($result)>=1){
while($myrow=mysql_fetch_row($result)){
echo "$myrow[0] ($myrow[2])
\n";
}
}
else{
echo "none";
}
}
else{
//error in DB
echo "error in DB";
}
?>
Citations
$sql="SELECT Citations.citation, Citations.description FROM Citations, TimelineObjects WHERE TimelineObjects.type='T' AND TimelineObjects.objectID=Citations.id AND TimelineObjects.timelineID=$targetTimeline";
$result=database_query($sql);
if($result){
if(mysql_num_rows($result)>=1){
while($myrow=mysql_fetch_row($result)){
echo "$myrow[0]
\n";
}
}
else{
echo "none";
}
}
else{
//error in DB
echo "error in DB";
}
?>