--- a/admin/timeline.php +++ b/admin/timeline.php @@ -1,1 +1,149 @@ +<?php +// START n=node(*) OPTIONAL MATCH n<-[r]-parent WITH n, count(parent) AS parents WHERE parents = 0 RETURN n, parents; +// no parents +// START n=node(*) OPTIONAL MATCH (n:Agency)-[r]->(child:Agency) WITH n, count(child) AS children WHERE children = 0 AND n:Agency RETURN n, children; +// no children + +// MATCH (n) WHERE has(n.start_date) and n.start_date < 18870000 RETURN n +// time slice +if (isset($_REQUEST['json'])) { + + /* echo '{ + "timeline": + { + "headline":"The Main Timeline Headline Goes here", + "type":"default", + "text":"<p>Intro body text goes here, some HTML is ok</p>", + "asset": { + "media":"http://yourdomain_or_socialmedialink_goes_here.jpg", + "credit":"Credit Name Goes Here", + "caption":"Caption text goes here" + }, + "date": [ + { + "startDate":"2011,12,10", + "endDate":"2011,12,11", + "headline":"Headline Goes Here", + "text":"<p>Body text goes here, some HTML is OK</p>", + "tag":"This is Optional", + "classname":"optionaluniqueclassnamecanbeaddedhere", + "asset": { + "media":"http://twitter.com/ArjunaSoriano/status/164181156147900416", + "thumbnail":"optional-32x32px.jpg", + "credit":"Credit Name Goes Here", + "caption":"Caption text goes here" + } + } + ], + "era": [ + { + "startDate":"2011,12,10", + "endDate":"2011,12,11", + "headline":"Headline Goes Here", + "text":"<p>Body text goes here, some HTML is OK</p>", + "tag":"This is Optional" + } + + ] + } +}'; */ + + // https://github.com/jadell/neo4jphp + spl_autoload_register(function ($className) { + $libPath = '../lib/neo4jphp/lib/'; + $classFile = str_replace('\\',DIRECTORY_SEPARATOR,$className).'.php'; + $classPath = $libPath.$classFile; + if (file_exists($classPath)) { + require($classPath); + } + }); + + +// Connecting to the default port 7474 on localhost + $client = new Everyman\Neo4j\Client(); +//$client = new Everyman\Neo4j\Client('192.168.1.127'); +//print_r($client->getServerInfo()); + + + + + //https://github.com/jadell/neo4jphp/wiki/Cypher-and-gremlin-queries + $queryString = "MATCH (n) where has(n.agency_no) RETURN n LIMIT 1000"; + $query = new Everyman\Neo4j\Cypher\Query($client, $queryString); + $dates = Array(); + $result = $query->getResultSet(); + foreach ($result as $row) { + //$dates[] = Array("startDate" =>"2011,12,10", "endDate"=>"2011,12,11", "headline"=>"Headline Goes Here", "text"=>"<p>Body text goes here, some HTML is OK</p>"); + $name = $row['x']->getProperty('name'); + $startDate = $row['x']->getProperty('start_date'); + $startDate = substr_replace($startDate, ",", 6, 0); + $startDate = substr_replace($startDate, ",", 4, 0); + $endDate = $row['x']->getProperty('end_date'); + if ($endDate == " ") $endDate = "20140101"; + $endDate = substr_replace($endDate, ",", 6, 0); + $endDate = substr_replace($endDate, ",", 4, 0); + + $dates[] = Array("startDate" =>$startDate, "endDate"=>$endDate, "headline"=>$name, "text"=>"<p>Body text goes here, some HTML is OK</p>"); + + } + + + + $timeline = Array( "headline"=>"The Main Timeline Headline Goes here", + "type"=>"default", + "text"=>"<p>Intro body text goes here, some HTML is ok</p>","date"=>$dates); + echo json_encode(Array("timeline" => $timeline)); + die(); +} +?> + + <!DOCTYPE html> + <html lang="en"><!-- + + 88888888888 d8b 888 d8b 888888 d8888b + 888 Y8P 888 Y8P 88b d88P Y88b + 888 888 888 Y88b + 888 888 88888b d88b d88b 888 888 88888b d88b 888 Y888b + 888 888 888 888 88b d8P Y8b 888 888 888 88b d8P Y8b 888 Y88b + 888 888 888 888 888 88888888 888 888 888 888 88888888 888 888 + 888 888 888 888 888 Y8b 888 888 888 888 Y8b 88P Y88b d88P + 888 888 888 888 888 Y8888 888 888 888 888 Y8888 888 Y8888P + d88P + d88P + 888P + --> + <head> + <title>Revolutionary User Interfaces</title> + <meta name="description" content="The human computer interface helps to define computing at any one time."> + <meta charset="utf-8"> + <meta name="apple-mobile-web-app-capable" content="yes"> + <meta name="apple-touch-fullscreen" content="yes"> + <!-- Style--> + <style> + html, body { + height:100%; + padding: 0px; + margin: 0px; + } + </style> + <link rel="stylesheet" type="text/css" href="http://cdn.knightlab.com/libs/timeline/latest/css/timeline.css"> + <!-- HTML5 shim, for IE6-8 support of HTML elements--><!--[if lt IE 9]> + <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> + </head> + <body> + <!-- BEGIN Timeline Embed --> + <div id="timeline-embed"></div> + <script type="text/javascript"> + var timeline_config = { + width: "100%", + height: "100%", + source: 'timeline.php?json=yes', + font: 'SansitaOne-Kameron' + } + </script> + <script type="text/javascript" src="http://cdn.knightlab.com/libs/timeline/latest/js/storyjs-embed.js"></script> + <!-- END Timeline Embed--> + + </body> + </html>