-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.php
More file actions
68 lines (59 loc) · 2.06 KB
/
browser.php
File metadata and controls
68 lines (59 loc) · 2.06 KB
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
<?php
include 'vendor/autoload.php';
require 'vendor/kwijibo/raffles/lib/rafflesstore.php';
require 'helpers.php';
$Config = getConfig();
if(empty($Config->name)) redirect('_setup');
$Store = new \Raffles\RafflesStore(RAFFLES_DATA_DIR);
$site_name = $Config->name;
$title='';
$showMap=false;
$types = $Store->getTypes();
$prefixes = getPrefixes($Config,$Store);
$namespaces = array_flip($prefixes);
$licenses = getLicenses();
$page = 1;
$pageSize = !empty($_GET['_pageSize'])? $_GET['_pageSize'] : 10;
$offset = (isset($_GET['_page']) && $page = $_GET['_page'])? ($_GET['_page']-1)*$pageSize : 0;
$data=array();
if($query = getQuery()){
$data = $Store->query($query, $pageSize, $offset);
} else if(!empty($_GET['_uri'])){
$data = $Store->get($_GET['_uri']);
} else if(!empty($_GET['_related'])){
$data = $Store->get(null,null,$_GET['_related'], $pageSize, $offset);
} else if(!empty($_GET['_search'])){
$data = $Store->search($_GET['_search'], false, $pageSize, $offset);
} else {
$documentUri = 'http://' .$_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI'];
$documentUri = array_shift(explode('?', $documentUri));
$data = $Store->get($documentUri);
}
$facets = $Store->getFacetsForLastQuery();
$resultCount = $Store->getResultsCountForLastQuery();
$showMap= (strpos($query,'_near')!==false || isset($_GET['_near']))? true : false ;
header("Access-Control-Allow-Origin: *");
$output = getOutputType();
if($output=='html'){
$innerTemplate = 'browser.html';
require 'templates/outer.html';
exit;
}
if ($output=='json' || $output =='turtle'){
require 'metadata.php';
$namespaces = $Store->getNamespaces();
$data = \Trilby\addMetadata($data, $Config, $types, $facets, $namespaces);
if($output=='json'){
header("Content-type: application/json");
echo json_encode($data);
exit;
} else {
require_once 'vendor/kwijibo/arc2/ARC2.php';
$conf=array('ns' => $prefixes );
$ser = ARC2::getTurtleSerializer($conf);
header("Content-type: text/plain");
echo $ser->getSerializedIndex($data);
exit;
}
}
?>