Rev | Line | |
---|
[12] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | class SurveyRDFWriter
|
---|
| 4 | {
|
---|
| 5 | var $model;
|
---|
| 6 |
|
---|
| 7 | var $resourceSurvey;
|
---|
| 8 | var $resourceTitle;
|
---|
| 9 | var $resourceDescription;
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * Use SurveyRDFWriter::getInstance() instead of this
|
---|
| 13 | * constructor.
|
---|
| 14 | */
|
---|
| 15 | public function __construct()
|
---|
| 16 | {
|
---|
| 17 | // Create empty MemModel
|
---|
| 18 | $factory = new ModelFactory();
|
---|
| 19 | $this->model = $factory->getDefaultModel();
|
---|
| 20 |
|
---|
| 21 | $this->initResources();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | function initResources()
|
---|
| 25 | {
|
---|
| 26 |
|
---|
[14] | 27 | $this->resourceSurvey = new Resource(SURVEYTOOL_NAMESPACE.'Survey');
|
---|
| 28 | $this->resourceTitle = new Resource(TITLE);
|
---|
| 29 | $this->resourceDescription = new Resource(DESCRIPTION);
|
---|
[12] | 30 | }
|
---|
| 31 |
|
---|
| 32 | public function createSurvey($sTitle, $sDescription)
|
---|
| 33 | {
|
---|
| 34 | $surveyTitle = new Literal($sTitle);
|
---|
| 35 | $this->model->add(new Statement($this->resourceSurvey,$this->resourceTitle,$surveyTitle));
|
---|
| 36 |
|
---|
| 37 | $surveyDescription = new Literal($sDescription);
|
---|
| 38 | $this->model->add(new Statement($this->resourceSurvey,$this->resourceDescription,$surveyDescription));
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public function saveSurvey($sTitle)
|
---|
| 42 | {
|
---|
| 43 | $this->model->saveAs('surveys/'.$sTitle.'.rdf','rdf');
|
---|
| 44 |
|
---|
| 45 | return true;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.