-
Notifications
You must be signed in to change notification settings - Fork 2
/
resource.php
91 lines (77 loc) · 2.81 KB
/
resource.php
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
<?
session_start();
require_once('vendor/init.php');
if($_SERVER['REQUEST_METHOD'] === "GET" || $_SERVER['REQUEST_METHOD'] === "HEAD"){
if(isset($_GET['resource'])){
$resource = $_GET['resource'];
$resource = str_replace(" ", "+", $resource); // pesky url decoding
$headers = apache_request_headers();
$ct = $headers["Accept"];
$result = get($ep, $resource, $ct);
$header = $result['header'];
$content = $result['content'];
}else{
$message["Beyond the final frontier"] = "You shouldn't be here.";
}
try {
if(!$content){
header($header);
echo $header;
}elseif(gettype($content) == "string"){
header($header);
echo $content;
}else{
// $content = $content->resource();
if(isset($_GET['debug'])){
echo "<hr/>".$content->dump();
}
$subject_properties = $content->properties($resource);
if(empty($subject_properties)){
$g = $content;
}else{
if($content->isA($content->resource(), "as:Arrive")){
// Temporary for checkins
$content->addLiteral($content->resource(), 'view:banality', 5);
$content->addLiteral($content->resource(), 'view:intimacy', 5);
$content->addLiteral($content->resource(), 'view:wanderlust', 4);
}
if($content->isA($content->resource(), "as:Travel")){
// Temporary for journeys
$content->addLiteral($content->resource(), 'view:banality', 3);
$content->addLiteral($content->resource(), 'view:intimacy', 5);
$content->addLiteral($content->resource(), 'view:wanderlust', 5);
}
if($content->isA($content->resource(), "asext:Consume") || $content->isA($content->resource(), "asext:Acquire")){
// Temporary for food logs
$content->addLiteral($content->resource(), 'view:banality', 5);
$content->addLiteral($content->resource(), 'view:intimacy', 3);
$content->addLiteral($content->resource(), 'view:tastiness', 5);
}
$tags = get_tags($ep);
// var_dump($content->toRdfPhp());
$resource = set_views($ep, $content->resource());
// var_dump($content->resource()->toRdfPhp());
$g = $resource->getGraph();
}
$resource = $g->toRdfPhp();
$scripts = get_values($resource, 'view:script');
$includes = array(view_router($resource).'.php');
include 'views/page_template.php';
}
}catch(Exception $e){
var_dump($e);
}
}elseif($_SERVER['REQUEST_METHOD'] === "POST"){
// Is this a container?
// Is the body rdf?
// post($ep, $body, $thisuri) to create new resource
// else Is this a resource?
// TODO
}elseif($_SERVER['REQUEST_METHOD'] === "DELETE"){
// TODO
}elseif($_SERVER['REQUEST_METHOD'] === "PUT"){
// TODO
}elseif($_SERVER['REQUEST_METHOD'] === "OPTIONS"){
// TODO
}
?>