| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
//////////////////////////////////////////////////////////////////////////////
|
| 5 |
// Services API hooks
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Implementation of hook_service().
|
| 9 |
*/
|
| 10 |
function rdf_service() {
|
| 11 |
return array(
|
| 12 |
array(
|
| 13 |
'#method' => 'rdf.insert',
|
| 14 |
'#callback' => 'rdf_service_insert',
|
| 15 |
'#return' => 'boolean',
|
| 16 |
'#args' => array(
|
| 17 |
array('#name' => 'statement', '#type' => 'array', '#optional' => FALSE, '#description' => t('Subject, predicate, and object.')),
|
| 18 |
),
|
| 19 |
'#help' => t('Inserts a new statement into the database.'),
|
| 20 |
),
|
| 21 |
array(
|
| 22 |
'#method' => 'rdf.delete',
|
| 23 |
'#callback' => 'rdf_service_delete',
|
| 24 |
'#return' => 'boolean',
|
| 25 |
'#args' => array(
|
| 26 |
array('#name' => 'statement', '#type' => 'array', '#optional' => FALSE, '#description' => t('Subject, predicate, and object.')),
|
| 27 |
),
|
| 28 |
'#help' => t('Deletes an existing statement from the database.'),
|
| 29 |
),
|
| 30 |
array(
|
| 31 |
'#method' => 'rdf.query',
|
| 32 |
'#callback' => 'rdf_service_query',
|
| 33 |
'#return' => 'struct',
|
| 34 |
'#args' => array(
|
| 35 |
array('#name' => 'pattern', '#type' => 'array', '#optional' => TRUE, '#description' => t('Subject, predicate, and object.')),
|
| 36 |
),
|
| 37 |
'#help' => t('Finds all statements in the database matching a given triple pattern.'),
|
| 38 |
),
|
| 39 |
);
|
| 40 |
}
|
| 41 |
|
| 42 |
function rdf_service_insert(array $statement) {
|
| 43 |
return !!call_user_func_array('rdf_insert', $statement);
|
| 44 |
}
|
| 45 |
|
| 46 |
function rdf_service_delete(array $statement) {
|
| 47 |
return !!call_user_func_array('rdf_delete', $statement);
|
| 48 |
}
|
| 49 |
|
| 50 |
function rdf_service_query(array $pattern = array()) {
|
| 51 |
return rdf_deobjectify(rdf_normalize(call_user_func_array('rdf_query', $pattern)));
|
| 52 |
}
|