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