0 ){ //the timelineID appears valid so grab it $timelineID= (integer) $_GET['id']; //now we decide whether to filter the items we show if( isset($_GET['people']) || isset($_GET['events']) || isset($_GET['citations']) || isset($_GET['conceptions']) ){ if( isset($_GET['people']) && $_GET['people']=="people" ){ $showPeople=true; } else { $showPeople=false; } if( isset($_GET['events']) && $_GET['events']=="events" ){ $showEvents=true; } else { $showEvents=false; } if( isset($_GET['citations']) && $_GET['citations']=="citations" ){ $showCitations=true; } else { $showCitations=false; } if( isset($_GET['conceptions']) && $_GET['conceptions']=="conceptions" ){ $showConceptions=true; } else { $showConceptions=false; } } //now that the ID *appears* to be valid let's try to grab the items that belong to this timeline $sqlQuery="SELECT title, description, contributor, CONCAT(MONTHNAME(created), ' ', DAY(created), ', ', YEAR(created)) FROM Timelines WHERE id=$timelineID LIMIT 1"; $result=database_query($sqlQuery); if($result && mysql_num_rows($result)==1){ //we got our row so store the info $myrow=mysql_fetch_row($result); $timelineTitle=$myrow[0]; $timelineDescription=$myrow[1]; $timelineContributor=$myrow[2]; $timelineCreated=$myrow[3]; /**************************************************** now we need to get all the objects for this timeline. ****************************************************/ /****** start with concepts ******/ if($showConceptions){ $sqlCitation="SELECT TimelineObjects.type, TimelineObjects.objectID, TimelineObjects.timelineID, ConceptsBeta.id, ConceptsBeta.concept, ConceptsBeta.year, ConceptsBeta.conception FROM TimelineObjects, ConceptsBeta WHERE ConceptsBeta.id=TimelineObjects.objectID AND TimelineObjects.timelineID=$timelineID AND TimelineObjects.type='C' ORDER BY ConceptsBeta.concept ASC"; $resultCitation=database_query($sqlCitation); if($resultCitation && mysql_num_rows($resultCitation)>=1){ //we found some citations to include while($myrow=mysql_fetch_row($resultCitation)){ //create a json entry into an array for this $jsonArray[] = "{ 'start': '$myrow[5]', 'title': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars($myrow[4], ENT_QUOTES)) . "', 'description': '" . trim(substr( preg_replace("/[\n\r]/", " ", htmlspecialchars(convertURLs($myrow[6], "_blank"), ENT_QUOTES)), 0, 500)) . "...', 'link': '/toolkit/conceptDatabase/viewConcept.php?id=$myrow[3]', 'durationEvent': false, 'icon': '/system_files/icons/document-icon-small.gif', 'color': '#000044' }"; $yearArray[] = $myrow[5]; } } } /****** now with citations ******/ if($showCitations){ $sqlCitation="SELECT TimelineObjects.type, TimelineObjects.objectID, TimelineObjects.timelineID, Citations.id, Citations.citation, Citations.date, Citations.description, YEAR(Citations.date) FROM TimelineObjects, Citations WHERE Citations.id=TimelineObjects.objectID AND TimelineObjects.timelineID=$timelineID AND TimelineObjects.type='T' ORDER BY Citations.citation ASC"; $resultCitation=database_query($sqlCitation); if($resultCitation && mysql_num_rows($resultCitation)>=1){ //we found some citations to include while($myrow=mysql_fetch_row($resultCitation)){ //create a json entry into an array for this $jsonArray[] = "{ 'start': '$myrow[5]', 'title': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars($myrow[4], ENT_QUOTES)) . "', 'description': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars(convertURLs($myrow[6], "_blank"), ENT_QUOTES)) . "', 'durationEvent': false, 'icon': '/system_files/icons/document-icon-small.gif', 'color': '#004400' }"; $yearArray[] = $myrow[7]; } } } /****** now we do the people ******/ if($showPeople){ $sqlPeople="SELECT TimelineObjects.type, TimelineObjects.objectID, TimelineObjects.timelineID, TimelinePeople.id, TimelinePeople.name, TimelinePeople.start, TimelinePeople.end, TimelinePeople.description, TimelinePeople.span, CONCAT(MONTHNAME(TimelinePeople.start), ' ', DAY(TimelinePeople.start), ', ', YEAR(TimelinePeople.start)) as startDate, CONCAT(MONTHNAME(TimelinePeople.end), ' ', DAY(TimelinePeople.end), ', ', YEAR(TimelinePeople.end)) as endDate, YEAR(TimelinePeople.start), YEAR(TimelinePeople.end) FROM TimelineObjects, TimelinePeople WHERE TimelinePeople.id=TimelineObjects.objectID AND TimelineObjects.timelineID=$timelineID AND TimelineObjects.type='P' ORDER BY TimelinePeople.name ASC"; $resultPeople=database_query($sqlPeople); if($resultPeople && mysql_num_rows($resultPeople)>=1){ //we found some people to include while($myrow=mysql_fetch_row($resultPeople)){ //create a json entry into an array for this if($myrow[8]){ //show birth and death $jsonArray[] = "{ 'start': '$myrow[5]', 'end': '$myrow[6]', 'title': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars($myrow[4], ENT_QUOTES)) . "', 'description': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars("$myrow[9] - $myrow[10]. " . convertURLs($myrow[7], "_blank"), ENT_QUOTES)) . "', 'durationEvent': true, 'icon': '/system_files/icons/person.gif', 'color': '#ff9999' }"; $yearArray[] = $myrow[11]; $yearArray[] = $myrow[12]; } else{ //just show birth and still alive today $jsonArray[] = "{ 'start': '$myrow[5]', 'end': '" . date("Y-m-d") . " 00:00:00', 'title': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars($myrow[4], ENT_QUOTES)) . "', 'description': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars("Born: $myrow[9]. " . convertURLs($myrow[7], "_blank"), ENT_QUOTES)) . "', 'durationEvent': true, 'icon': '/system_files/icons/person.gif', 'color': '#ff9999' }"; $yearArray[] = $myrow[11]; } } } } /****** now we do the events ******/ if($showEvents){ $sqlEvents="SELECT TimelineObjects.type, TimelineObjects.objectID, TimelineObjects.timelineID, TimelineEvents.id, TimelineEvents.title, TimelineEvents.start, TimelineEvents.end, TimelineEvents.description, TimelineEvents.span, CONCAT(MONTHNAME(TimelineEvents.start), ' ', DAY(TimelineEvents.start), ', ', YEAR(TimelineEvents.start)) as startDate, CONCAT(MONTHNAME(TimelineEvents.end), ' ', DAY(TimelineEvents.end), ', ', YEAR(TimelineEvents.end)) as endDate, YEAR(TimelineEvents.start), YEAR(TimelineEvents.end) FROM TimelineObjects, TimelineEvents WHERE TimelineEvents.id=TimelineObjects.objectID AND TimelineObjects.timelineID=$timelineID AND TimelineObjects.type='E' ORDER BY TimelineEvents.title ASC"; $resultEvents=database_query($sqlEvents); if($resultEvents && mysql_num_rows($resultEvents)>=1){ //we found some events to include while($myrow=mysql_fetch_row($resultEvents)){ //create a json entry into an array for this if($myrow[8]){ //show start and end $jsonArray[] = "{ 'start': '$myrow[5]', 'end': '$myrow[6]', 'title': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars($myrow[4], ENT_QUOTES)) . "', 'description': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars("$myrow[9] - $myrow[10]. " . convertURLs($myrow[7], "_blank"), ENT_QUOTES)) . "', 'durationEvent': true, 'icon': '/system_files/icons/calendar-10x10.jpg', 'color': '#000000' }"; $yearArray[] = $myrow[11]; $yearArray[] = $myrow[12]; } else{ //just show start as a non-duration event $jsonArray[] = "{ 'start': '$myrow[5]', 'title': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars($myrow[4], ENT_QUOTES)) . "', 'description': '" . preg_replace("/[\n\r]/", " ", htmlspecialchars("$myrow[9]. " . convertURLs($myrow[7], "_blank"), ENT_QUOTES)) . "', 'durationEvent': false, 'icon': '/system_files/icons/calendar-10x10.jpg', 'color': '#000000' }"; $yearArray[] = $myrow[11]; } } } } //now that we have all the dates lets get the arrays in order $sortTest=sort($yearArray); if($sortTest) $focusDate=$yearArray[count($yearArray)-1]; $earliestYear=$yearArray[0]; $latestYear=$yearArray[count($yearArray)-1]; } else{ //we couldn't find the timeline in the database $errorMessage[]="We could not find a timeline with the ID you supplied. Please check the ID and try again."; } } else{ //the timeline ID is invalid or bad $errorMessage[]="There appears to be an error in the timeline ID you submitted. Please double check and try it again."; } } else{ $errorMessage[]="You must supply a timeline ID so we know which timeline you wish to view. Please check the ID and try again."; } ?> <? if($timelineTitle){ echo "Timeline: " . $timelineTitle; } else { echo "Timeline Viewer"; } ?>
Timeline:
[Description] [Contribution]
Show:
/>People />Events />Citations />Concepts
Scroll ten years forward
Move to Timeline Item:
Earliest | Latest
"; foreach($errorMessage as $error){ echo "

$error

\n"; } echo "\n"; } ?>