=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; ?> $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(); } ?>

Editing Timeline:

=1){ //we got results so let's so the menu of options echo "\n"; echo "\n"; } else{ //this user has no timelines to edit echo "

You have not yet created any timelines.

\n"; } ?>

Contribute Timeline Items

Create events to use on timelines

Create people to use on timelines

Create citations to use on timelines

0){ ?>

Current Timeline Items

Concepts

=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

=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

=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

=1){ while($myrow=mysql_fetch_row($result)){ echo "$myrow[0]
\n"; } } else{ echo "none"; } } else{ //error in DB echo "error in DB"; } ?>

View Timeline

Search for Timeline Items to Add

People Events Citations Concepts
Terms submitted

\n"; $terms=trim($_POST['terms']); if( isset($_POST['people']) && $_POST['people']=="people" ){ $people=true; } else { $people=false; } if( isset($_POST['events']) && $_POST['events']=="events" ){ $events=true; } else { $events=false; } if( isset($_POST['citations']) && $_POST['citations']=="citations" ){ $citations=true; } else { $citations=false; } if( isset($_POST['concepts']) && $_POST['concepts']=="concepts" ){ $concepts=true; } else { $concepts=false; } $concepts=true; //validate the terms if( strlen($terms)>=2 && strlen($terms)<=255 ){ $terms=sanitize($terms); //time to generate the search queries //we will make expandable views with scroll bars echo "
\n"; if($concepts){ $conceptsQuery="SELECT id, concept, conception, year, MATCH(concept, conception) AGAINST ('$terms') AS score FROM ConceptsBeta WHERE MATCH(concept, conception) AGAINST ('$terms') ORDER BY score, concept DESC LIMIT 25"; $conceptsResult=database_query($conceptsQuery); if($conceptsResult){ if(mysql_num_rows($conceptsResult)>=1){ //display results $searchResultsFound=true; echo "

Concepts

\n"; echo "
\n"; while($myrow=mysql_fetch_row($conceptsResult)){ //get the description formatted if(strlen($myrow[2])>200){ $myrow[2]=substr(strip_tags($myrow[2]), 0, 200) . "..."; } echo "
\n"; if($targetTimeline){ echo "
\n"; echo "
Click to view this concept
\n"; echo "
\n"; } else{ echo "
Click to view this concept
\n"; echo "
\n"; } echo "" . ucfirst($myrow[1]) . "
"; //print year and description echo "(" . $myrow[3] . ") " . $myrow[2]; echo "\n"; echo "
\n"; echo "
\n"; } echo "
\n"; } else{ //no search results for people } } else{ //error running the search query for people $errorArray[]="databaseFailConcept"; } } if($people){ $peopleQuery="SELECT id, name, description, span, YEAR(start), MONTH(start), DAY(start), YEAR(end), MONTH(end), DAY(end), MATCH(name, description) AGAINST ('$terms') AS score FROM TimelinePeople WHERE MATCH(name, description) AGAINST ('$terms') ORDER BY score DESC LIMIT 25"; $peopleResult=database_query($peopleQuery); if($peopleResult){ if(mysql_num_rows($peopleResult)>=1){ //display results $searchResultsFound=true; echo "

People

\n"; echo "
\n"; while($myrow=mysql_fetch_row($peopleResult)){ //get the description formatted if(strlen($myrow[2])>200){ $myrow[2]=htmlentities( substr($myrow[2], 0, 200), ENT_QUOTES ) . "..."; } echo "
\n"; if($targetTimeline){ echo "
\n"; echo "
Click to view this person
\n"; echo "
\n"; } else{ echo "
Click to view this person
\n"; echo "
\n"; } echo "$myrow[1]
"; //print start date echo format_display_date($myrow[4], $myrow[5], $myrow[6]); echo " to "; if($myrow[3]==1){ //the person is dead echo format_display_date($myrow[7], $myrow[8], $myrow[9]); } else{ //the person is still alive echo "Present"; } echo "\n"; echo "
\n"; echo "
\n"; } echo "
\n"; } else{ //no search results for people } } else{ //error running the search query for people $errorArray[]="databaseFailPeople"; } } if($events){ $eventsQuery="SELECT id, title, description, span, YEAR(start), MONTH(start), DAY(start), YEAR(end), MONTH(end), DAY(end), MATCH(title, description) AGAINST ('$terms') AS score FROM TimelineEvents WHERE MATCH(title, description) AGAINST ('$terms') ORDER BY score DESC LIMIT 25"; $eventsResult=database_query($eventsQuery); if($eventsResult){ if(mysql_num_rows($eventsResult)>=1){ //display results $searchResultsFound=true; echo "

Events

\n"; echo "
\n"; while($myrow=mysql_fetch_row($eventsResult)){ //get the description formatted if(strlen($myrow[2])>200){ $myrow[2]=htmlentities( substr($myrow[2], 0, 200), ENT_QUOTES ) . "..."; } echo "
\n"; if($targetTimeline){ echo "
\n"; echo "
Click to view this event
\n"; echo "
\n"; } else{ echo "
View This Event
\n"; echo "
\n"; } echo "$myrow[1]
"; //print start date echo format_display_date($myrow[4], $myrow[5], $myrow[6]); if($myrow[3]==1){ //we are showing a span echo " to "; echo format_display_date($myrow[7], $myrow[8], $myrow[9]); } echo "\n"; echo "
\n"; echo "
\n"; } echo "
\n"; } else{ //no search results for events } } else{ //error running the search query for events $errorArray[]="databaseFailEvents"; } } if($citations){ $citationsQuery="SELECT id, citation, description, YEAR(date), MONTH(date), DAY(date), MATCH(citation, description) AGAINST ('$terms') AS score FROM Citations WHERE MATCH(citation, description) AGAINST ('$terms') AND date != '0000-00-00 00:00:00' ORDER BY score DESC LIMIT 25"; $citationsResult=database_query($citationsQuery); if($citationsResult){ if(mysql_num_rows($citationsResult)>=1){ //display results $searchResultsFound=true; echo "

Citations

\n"; echo "
\n"; while($myrow=mysql_fetch_row($citationsResult)){ //get the description formatted if(strlen($myrow[2])>200){ $myrow[2]=htmlentities( substr($myrow[2], 0, 200), ENT_QUOTES ) . "..."; } echo "
\n"; if($targetTimeline){ echo "
\n"; echo "
Click to view this citation
\n"; echo "
\n"; } else{ echo "
View This Citation
\n"; echo "
\n"; } echo "$myrow[1]
"; //print date and description echo "(" . format_display_date($myrow[3], $myrow[4], $myrow[5]) . ") " . $myrow[2]; echo "\n"; echo "
\n"; echo "
\n"; } } else{ //no search results for citations } } else{ //error running the search query for citations $errorArray[]="databaseFailCitations"; } } //close the expanding demo-show h3 echo "
\n"; } else{ //problem with the terms $errorArray[]="searchTermsError"; } } else{ //no terms supplied //echo "

NO SEARCH

\n"; } //let's decide whether to show a submit button if( $searchResultsFound && $targetTimeline ){ echo "

timeline.' name='addObjects' type='submit' value='Add Selected Items to Timeline: $targetTimelineName' />

\n"; } ?>
=1){ //echo "
\n"; //echo "
    \n"; foreach($errorArray as $e){ if($e=="noData"){ display_alert_box("No data was submitted.", "bad"); } elseif($e=="searchTermsError"){ display_alert_box("Something is wrong with your search terms. Your search must be at least 2 characters and less than 255 long avoiding punctuation.", "bad"); } elseif($e=="databaseFailConcept"){ display_alert_box("We experienced an error trying to run your search for concepts. Please try again in a few moments. (104) - $conceptsQuery", "bad"); } elseif($e=="databaseFailPeople"){ display_alert_box("We experienced an error trying to run your search for people. Please try again in a few moments. (101)", "bad"); } elseif($e=="databaseFailEvents"){ display_alert_box("We experienced an error trying to run your search for events. Please try again in a few moments. (102)", "bad"); } elseif($e=="databaseFailCitations"){ display_alert_box("We experienced an error trying to run your search for citations. Please try again in a few moments. (103)", "bad"); } else{ display_alert_box("There was a problem processing your submission. Please try again in a few moments. We apologize.", "bad"); } } } ?>