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); } } }
$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); $store->reset(); $data_file = $Config->{$dataset}->data; if (!is_file($data_file)) { throw new Exception("{$data_file} could not be found"); } $store->loadDataFile($data_file); // $store->loadData(file_get_contents($data_file)); // $this->createHierarchicalIndex(); } $types = $store->getTypes(); $query = getQuery(); $page = 1; $offset = isset($_GET['_page']) && ($page = $_GET['_page']) ? ($_GET['_page'] - 1) * 10 : 0; $showMap = strpos($query, '_near') !== false || isset($_GET['_near']) ? true : false; if (!empty($query)) { //query based title list($path, $value) = explode('=', $query); $value = curie($value); $title = local($value); if ($path == 'rdf:type') { $title = plural($title);
#!/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);