-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_training_demo.inc
50 lines (42 loc) · 1.54 KB
/
islandora_training_demo.inc
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
<?php
/**
* @file This file will hold helper code for the training module.
*/
/*
* The following is helper code for RI searching.
* This is kinda a test bed for a new entry in islandora_fedora_api
* after this works nicely we can transplant and add the islandora_fedora_api
* as a dependency for this module
*/
function do_SPARQL_query($query, $count=FALSE) {
//get info for query
$limit = -1;
$offset = 0 ;
$lang = 'sparql';
$format = (($count)?("count"):("sparql"));
$query_url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
//run query
$query_url .= "?type=tuples&flush=TRUE" . (($limit > 0)?("&limit=$limit"):("")) . "&format=$format&offset=$offset&lang=$lang&query=" . urlencode($query);
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
drupal_set_message($query_url);
$query_return_string = do_curl($query_url);
return $query_return_string;
}
/**
*
* @author
* Adam
* @param unknown_type $query
* @param unknown_type $limit
* @param unknown_type $offset
* @return Ambigous <DOMDocument, mixed>
*/
function do_ITQL_query($query, $limit = -1, $offset = 0) {
$queryUrl = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$queryUrl .= "?type=tuples&flush=TRUE&format=Sparql" . (($limit > 0)?("&limit=$limit"):("")) . "&offset=$offset&lang=itql&stream=on&query=" . urlencode($query);
$doc = DOMDocument::loadXML(do_curl($queryUrl));
return ((!$doc)?(new DOMDocument()):($doc));
}
function do_RI_query() {
return;
}