diff --git a/public_html/modules/nodes/lookup.php b/public_html/modules/nodes/lookup.php new file mode 100644 index 0000000..f82640a --- /dev/null +++ b/public_html/modules/nodes/lookup.php @@ -0,0 +1,51 @@ +uParameters[1]; + +try +{ + $sNode = new Node($uUuid); + + $sProperties = array(); + + foreach(Property::CreateFromQuery("SELECT * FROM properties WHERE `NodeId` = :NodeId", array( + "NodeId" => $sNode->sId + )) as $sProperty) + { + $sProperties[] = array( + "name" => $sProperty->sName, + "value" => $sProperty->sValue, + "source" => $sProperty->sSource, + "reliability" => $sProperty->sReliability + ); + } + + $sData = array( + "contents" => NewTemplater::Render("nodes/lookup", $locale->strings, array( + "name" => $sNode->sName, + "notes" => $sNode->sNotes, + "properties" => $sProperties + )) + ); +} +catch (NotFoundException $e) +{ + $sUuid = htmlspecialchars($uUuid); + + $sData = array( + "contents" => "Could not find a node with ID {$sUuid}." + ); +} diff --git a/public_html/rewrite.php b/public_html/rewrite.php index 47c18bc..d80585f 100644 --- a/public_html/rewrite.php +++ b/public_html/rewrite.php @@ -33,6 +33,10 @@ $router->routes = array( 'target' => "modules/nodes/create.php", '_json' => true ), + "^/nodes/([0-9a-f-]{36})$" => array( + "target" => "modules/nodes/lookup.php", + "_json" => true + ), "^/autocomplete/search$" => array( "target" => "modules/autocomplete/search.php", "_json" => true @@ -46,8 +50,3 @@ if(!empty($router->uVariables['json'])) { echo(json_encode($sData)); } -/* -$sNode = new Node(1); -$sNode->uName = random_string(15); -$sNode->InsertIntoDatabase(); -*/ diff --git a/public_html/templates/nodes/lookup.tpl b/public_html/templates/nodes/lookup.tpl new file mode 100644 index 0000000..d5d06c4 --- /dev/null +++ b/public_html/templates/nodes/lookup.tpl @@ -0,0 +1,9 @@ +
+
+

{%?name}

+

+ {%?notes} +

+
+
test2
+