-
Notifications
You must be signed in to change notification settings - Fork 0
/
createRubric.php
79 lines (50 loc) · 1.47 KB
/
createRubric.php
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
69
70
71
72
73
74
75
76
77
78
79
<?php
include('config.php');
include_once('checkLogin.php');
include(ARC_DIR . 'ARC2.php');
require_once(CLASSES_DIR . 'Rubric.php');
require_once(CLASSES_DIR . 'Context.php');
$store = ARC2::getStore($config);
if (!$store->isSetUp()) {
$store->setUp();
}
$rjson = stripslashes($_POST['rJSON']) ;
$robj = json_decode( $rjson );
if($robj == null) {
echo 'fail rubric';
echo $rjson;
die();
}
$cjson = stripslashes($_POST['cJSON']) ;
$cobj = json_decode( $cjson );
if($cobj == null) {
echo 'fail context';
echo $cjson;
die();
}
$cURIs = array();
$newContextsGraph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $config);
foreach($cobj as $key=>$newContextObj) {
$newContext = new Context($newContextObj);
$newContext->buildPrivateGraph();
$newCURI = $newContext->uri;
$newContextsGraph->mergeResourceGraph($newContext->graph);
if(in_array($key, $robj->rubricMeta[4]->rContexts)) {
$cURIs[] = urldecode($newCURI);
}
}
foreach($robj->rubricMeta[4]->rContexts as $val) {
if(substr($val, 0, 3) != 'new' ) {
$cURIs[] = urldecode($val);
}
}
$robj->rubricMeta[4]->rContexts = $cURIs;
//build contexts if needed, and get an array of the context URIs to pass to Rubric
$newRubric = new Rubric($robj, $cURIs);
$newRubric->buildGraph();
//echo $newRubric->graph->toNTriples();
$q = 'INSERT INTO <> { ' . $newRubric->graph->toNTriples() . ' } ' ;
$rs = $store->query($q);
$q = 'INSERT INTO <> { ' . $newContextsGraph->toNTriples() . ' } ' ;
$rs = $store->query($q);
?>