1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 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> |