1 | <?php
|
---|
2 |
|
---|
3 | // Survey database interface class as intermediate for storing data from the site to the RDF database
|
---|
4 | require 'rdfConstants.php';
|
---|
5 |
|
---|
6 | // Include RAP Library to write RDF files
|
---|
7 | define("RDFAPI_INCLUDE_DIR", "rdfapi/");
|
---|
8 | include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 | class ApplicationDatabaseInterface
|
---|
13 | {
|
---|
14 | protected $applicationRDFWriter;
|
---|
15 | protected $applicationRDFReader;
|
---|
16 |
|
---|
17 |
|
---|
18 | public function __construct($surveyID)
|
---|
19 | {
|
---|
20 | if($surveyID == null)
|
---|
21 | $surveyUID = md5( uniqid(rand(), true) );
|
---|
22 | else
|
---|
23 | $surveyUID = $surveyID;
|
---|
24 |
|
---|
25 | $this->applicationRDFWriter = new ApplicationRDFWriter();
|
---|
26 | $this->applicationRDFReader = new ApplicationRDFReader();
|
---|
27 | }
|
---|
28 |
|
---|
29 | public function setApplicationInfo($application)
|
---|
30 | {
|
---|
31 | $aTitle = $application['applicationTitle'];
|
---|
32 | $aDescription = $application['applicationDescription'];
|
---|
33 | $aStyle = $application['applicationStyle'];
|
---|
34 |
|
---|
35 | $this->applicationRDFWriter->setApplicationInfo($aTitle, $aDescription, $aStyle)
|
---|
36 |
|
---|
37 | $this->applicationRDFWriter->saveApplications();
|
---|
38 | }
|
---|
39 |
|
---|
40 | public function getApplicationInfo()
|
---|
41 | {
|
---|
42 | $applicationInfo = array();
|
---|
43 |
|
---|
44 | $resultApplication = $this->applicationRDFReader->readAllApplications();
|
---|
45 |
|
---|
46 | for($aNumber = 0;$aNumber<=sizeof($resultApplication[0]);$aNumber++)
|
---|
47 | {
|
---|
48 | $applicationInfo['applicationID'] = substr($resultSurvey[0][$aNumber]['?uid'],9,strlen($resultSurvey[0][$aNumber]['?uid'])-11);
|
---|
49 | $applicationInfo['applicationTitle'] = substr($resultSurvey[1][$aNumber]['?title'],9,strlen($resultSurvey[0][$aNumber]['?title'])-11);
|
---|
50 | $applicationInfo['applicationDescription'] = substr($resultSurvey[2][$aNumber]['?description'],9,strlen($resultSurvey[0][$aNumber]['?description'])-11);
|
---|
51 | $applicationInfo['applicationStyle'] = substr($resultSurvey[3][$aNumber]['?style'],9,strlen($resultSurvey[0][$aNumber]['?style'])-11);
|
---|
52 | }
|
---|
53 |
|
---|
54 | return $applicationInfo;
|
---|
55 | }
|
---|
56 |
|
---|
57 | }
|
---|
58 | ?> |
---|