function getRafflesStore($load = false) { $dirname = __DIR__ . DIRECTORY_SEPARATOR . 'testdata'; $store = new \Raffles\RafflesStore($dirname); $store->indexPredicates = false; $store->reset(); if ($load) { $data = file_get_contents('specs/test.ttl'); $store->loadData($data); } return $store; }
function uploadData() { if (!empty($_FILES['data-file']['name'])) { if ($_FILES['data-file']['error']) { //handle error switch ($_FILES['data-file']['error']) { case 1: case 2: $errorMessage = 'The file uploaded is bigger than the upload_max_filesize directive in your php.ini file. Try making the value larger.'; break; case 3: $errorMessage = 'The uploaded file was only partially uploaded. '; break; case 4: $errorMessage = 'No file was uploaded'; break; case 5: case 6: $errorMessage = 'There is no temporary folder to write the file to.'; break; case 7: $errorMessage = 'Failed to write file to disk.'; break; case 8: $errorMessage = 'A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.'; break; } throw new SetupException($errorMessage); } else { $Store = new \Raffles\RafflesStore(RAFFLES_DATA_DIR); $Store->reset(); $Store->indexPredicates = false; $extension = false; if (strpos($_FILES['data-file']['name'], '.')) { $file_name_parts = explode('.', $_FILES['data-file']['name']); $extension = array_pop($file_name_parts); } $Store->loadDataFile($_FILES['data-file']['tmp_name'], $extension); } } }
<?php include 'vendor/autoload.php'; require 'helpers.php'; set_time_limit(0); define('RAFFLES_ROOT', __DIR__ . '/../vendor/kwijibo/raffles/'); require RAFFLES_ROOT . '/lib/rafflesstore.php'; $Store = new \Raffles\RafflesStore(RAFFLES_DATA_DIR); $Store->reset();
session_cache_limiter("public"); header("Cache-Control:public"); header("Etag: {$etag}"); $Config = json_decode(file_get_contents('config.json')); session_start(); if (isset($_GET['_dataset'])) { $dataset = $_GET['_dataset']; $_SESSION['_dataset'] = $dataset; } else { if (isset($_SESSION['_dataset'])) { $dataset = $_SESSION['_dataset']; } else { $dataset = 'climb'; } } $store = new \Raffles\RafflesStore('.' . DIRECTORY_SEPARATOR . $dataset); $prefixes = $Config->{$dataset}->prefixes; foreach ($prefixes as $prefix => $ns) { $store->addPrefix($prefix, $ns); } $prefixes = $store->prefixes; $namespaces = array_flip($prefixes); foreach ($Config->{$dataset}->index_predicates as $indexCurie) { $store->indexPredicates[] = curie_to_uri($indexCurie); } if (empty($Config->{$dataset}->index_predicates)) { $store->indexPredicates = false; } $title = ucwords($dataset); if (isset($_GET['_reload'])) { set_time_limit(0);
expect($results)->to_equal($expected); }); it("should let you get matching descriptions for a (* p o) triple pattern", function () { global $store; $results = $store->get(null, rdftype, biboBook); $expected = array(); expect(count(array_keys($results)))->to_equal(7); }); it("should let you query with an LDPath", function () { global $store; $results = $store->query("foaf:made/dct:date=1773"); $uris = array_keys($results); expect($uris[0])->to_equal('http://example.org/ecco-tcp/person/Mrs_(anna_Letitia)_Barbauld_1743-1825'); }); it("should let you query with simple LDPath rdf:type=foaf:Person", function () { global $store; $results = $store->query("rdf:type=foaf:Person"); $uris = array_keys($results); expect($uris[0])->to_equal('http://example.org/ecco-tcp/person/A_Alison'); }); it("should tell you what namespaces are used in the data", function () { $data = array(ex . 'people/tom' => array(ex . 'vocab/name' => array(array('value' => 'Tom', 'type' => 'literal')))); $store = new \Raffles\RafflesStore('testdata'); $store->reset(); $store->indexPredicates = false; $store->load($data); expect($store->Index->getSubjectNamespaces())->to_equal(array(ex . 'people/')); expect($store->getNamespaces())->to_equal(array(ex . 'people/' => 'r1', ex . 'vocab/' => 'r2')); }); }); \pecs\run();
#!/usr/bin/php <?php if (empty($argv[1]) or !is_file($argv[1])) { echo "\nUsage: php add-data.php mydata.ttl\n"; exit; } if (!is_readable($argv[1])) { echo "\nYou need to change the permissions on {$argv[1]} to make it readable\n"; } include 'vendor/autoload.php'; require 'helpers.php'; set_time_limit(0); define('RAFFLES_ROOT', __DIR__ . '/../vendor/kwijibo/raffles/'); require RAFFLES_ROOT . '/lib/rafflesstore.php'; $Store = new \Raffles\RafflesStore(RAFFLES_DATA_DIR); $Store->loadDataFile($argv[1]); chmod(RAFFLES_DATA_DIR, 0777);
<?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'])) {