source: Dev/trunk/classes/SurveyRDFWriter.php @ 12

Last change on this file since 12 was 12, checked in by basvannuland, 14 years ago

Added RAP RDF API
Added RDF reader writer for save and load survey

File size: 1.3 KB
RevLine 
[12]1<?php
2
3// Include RAP Library to write RDF files
4define("RDFAPI_INCLUDE_DIR", "rdfapi/");
5include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
6
7class SurveyRDFWriter
8{
9        var $model;
10               
11        var $resourceSurvey;
12        var $resourceTitle;
13        var $resourceDescription;
14       
15    /**
16    * Use SurveyRDFWriter::getInstance() instead of this
17    * constructor.
18    */
19    public function __construct()
20    {
21        // Create empty MemModel
22                $factory = new ModelFactory();
23                $this->model = $factory->getDefaultModel();
24               
25                $this->initResources();
26    }
27
28        function initResources()
29        {
30                $resourceURI = 'http:/www.survey.tool/';
31               
32                $this->resourceSurvey = new Resource($resourceURI.'Survey');
33                $this->resourceTitle = new Resource($resourceURI.'Title');
34                $this->resourceDescription = new Resource($resourceURI.'Description');
35        }
36       
37        public function createSurvey($sTitle, $sDescription)
38        {               
39                $surveyTitle = new Literal($sTitle);
40                $this->model->add(new Statement($this->resourceSurvey,$this->resourceTitle,$surveyTitle));             
41               
42                $surveyDescription = new Literal($sDescription);
43                $this->model->add(new Statement($this->resourceSurvey,$this->resourceDescription,$surveyDescription)); 
44        }
45       
46        public function saveSurvey($sTitle)
47        {
48                $this->model->saveAs('surveys/'.$sTitle.'.rdf','rdf');
49               
50                return true;
51        }
52
53}
54
55?>
Note: See TracBrowser for help on using the repository browser.