Changeset 144 for Dev/trunk/classes
- Timestamp:
- 11/03/11 10:30:40 (13 years ago)
- Location:
- Dev/trunk/classes
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/ApplicationConnector.php
r131 r144 11 11 * @author jkraaijeveld 12 12 */ 13 class ApplicationConnector implements IConnector {14 13 class ApplicationConnector implements IConnector { 14 15 15 protected $model; 16 16 protected $fileName = 'data/applications/applications.rdf'; … … 19 19 * Constructor for ApplicationConnector. 20 20 */ 21 public function __construct() 22 { 21 public function __construct() { 23 22 //Ensure the required folder for this connector exists 24 if (!is_dir('data/applications/')) 25 mkdir('data/applications/'); 23 if (!is_dir('data/applications/')) { 24 mkdir('data/applications/', null, true); 25 } 26 26 } 27 27 28 28 /** 29 29 * function load() … … 33 33 //Get the Memory Model from the ModelFactory 34 34 $this->model = ModelFactory::getDefaultModel(); 35 35 36 36 //Ensure the required file exists before loading 37 if (file_exists($this->fileName))37 if (file_exists($this->fileName)) 38 38 $this->model->load($this->fileName); 39 39 } 40 40 41 41 /** 42 42 * function save() … … 44 44 */ 45 45 public function save() { 46 $this->model->saveAs($this->fileName, 'rdf');46 $this->model->saveAs($this->fileName, 'rdf'); 47 47 } 48 48 49 49 /** 50 50 * function get($arguments) … … 58 58 $keys = array_keys($arguments); 59 59 //Set default values for arguments 60 $uid = "?uid"; $title = "?title"; $description = "?description"; $style = "?style"; 60 $uid = "?uid"; 61 $title = "?title"; 62 $description = "?description"; 63 $style = "?style"; 61 64 //Set the arguments if they are supplied 62 if (in_array("uid", $keys))63 $uid = "\"" .$arguments["uid"]."\"";64 if (in_array("title", $keys))65 $title = '\'' .$arguments["title"].'\'';66 if (in_array("description", $keys))67 $description = "\"" .$arguments["description"]."\"";68 if (in_array("style", $keys))69 $style = "\"" .$arguments["style"]."\"";65 if (in_array("uid", $keys)) 66 $uid = "\"" . $arguments["uid"] . "\""; 67 if (in_array("title", $keys)) 68 $title = '\'' . $arguments["title"] . '\''; 69 if (in_array("description", $keys)) 70 $description = "\"" . $arguments["description"] . "\""; 71 if (in_array("style", $keys)) 72 $style = "\"" . $arguments["style"] . "\""; 70 73 71 74 //Create the querystring … … 90 93 $results = $this->model->sparqlQuery($querystring); 91 94 $applications = array(); 92 if(!empty($results)) 93 { 95 if (!empty($results)) { 94 96 //Run over all results and create appropriate Application objets 95 foreach($results as $result) 96 { 97 $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label); 97 foreach ($results as $result) { 98 $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label); 98 99 } 99 100 } 100 101 return $applications; 101 102 } 102 103 103 104 /** 104 105 * function set() … … 107 108 * @param type $rToolObject: The ResearchToolObject to be saved. 108 109 */ 109 public function set($rToolObject) 110 { 110 public function set($rToolObject) { 111 111 $this->load(); 112 $resourceApplication = new Resource(APPLICATION .'/'.$rToolObject->uid);112 $resourceApplication = new Resource(APPLICATION . '/' . $rToolObject->uid); 113 113 //Remove the old value stored with the given id 114 114 $this->model->subtract($this->model->find($resourceApplication, null, null)); … … 117 117 $resourceApplicationType = new Resource(APPLICATION); 118 118 $predicateRType = new Resource(RTYPE); 119 $this->model->add(new Statement($resourceApplication, $predicateRType,$resourceApplicationType));120 119 $this->model->add(new Statement($resourceApplication, $predicateRType, $resourceApplicationType)); 120 121 121 $literalApplicationID = new Literal($rToolObject->uid); 122 122 $predicateUniqueID = new Resource(UID); 123 $this->model->add(new Statement($resourceApplication, $predicateUniqueID,$literalApplicationID));123 $this->model->add(new Statement($resourceApplication, $predicateUniqueID, $literalApplicationID)); 124 124 125 125 $applicationTitle = new Literal($rToolObject->title); 126 $predicateTitle = new Resource(TITLE); 127 $this->model->add(new Statement($resourceApplication, $predicateTitle,$applicationTitle));126 $predicateTitle = new Resource(TITLE); 127 $this->model->add(new Statement($resourceApplication, $predicateTitle, $applicationTitle)); 128 128 129 129 $applicationDescription = new Literal($rToolObject->description); 130 130 $predicateDescription = new Resource(DESCRIPTION); 131 $this->model->add(new Statement($resourceApplication, $predicateDescription,$applicationDescription));131 $this->model->add(new Statement($resourceApplication, $predicateDescription, $applicationDescription)); 132 132 133 133 $applicationStyle = new Literal($rToolObject->style); 134 134 $predicateStyle = new Resource(STYLE); 135 $this->model->add(new Statement($resourceApplication, $predicateStyle,$applicationStyle));136 137 135 $this->model->add(new Statement($resourceApplication, $predicateStyle, $applicationStyle)); 136 137 $this->save(); 138 138 } 139 139 140 } 140 141 -
Dev/trunk/classes/DisplayStep.php
r142 r144 18 18 public $imageURL; 19 19 public $selected = false; 20 public $name; 20 public $caption; 21 public $id; 21 22 22 public function __construct($t, $ref=null, $ n) {23 23 public function __construct($t, $ref=null, $c, $id) { 24 24 25 $this->type = $t; 25 26 $this->reference = $ref; 26 $this->name = $n; 27 27 $this->caption = $c; 28 $this->id = $id; 29 28 30 switch ($this->type) { 29 31 case "Questionnaire": 30 $this->imageURL = "images/icons/questionnaire 2.png";32 $this->imageURL = "images/icons/questionnaire.png"; 31 33 break; 32 34 case "Dashboard": 33 $this->imageURL = "images/icons/dashboard 2.png";35 $this->imageURL = "images/icons/dashboard.png"; 34 36 break; 35 37 case "Application": 36 $this->imageURL = "images/icons/application2.png"; 37 break; 38 case "Notice": 39 $this->imageURL = "images/icons/notice2.png"; 38 $this->imageURL = "images/icons/application.png"; 40 39 break; 41 40 default: … … 43 42 break; 44 43 } 45 44 46 45 //output a display object 47 echo '<div class="displayStep" style="background-image: url(\''; 48 echo $this->imageURL; 49 echo '\');" ><p>'.$this->name.'</p></div>'."\n"; 50 46 //echo '<div class="displayStep"><div class="displayStepIcon" style="background-image: url('.$this->imageURL.');"></div>'.$this->caption.'</div>'."\n"; 47 echo '<div class="displayStep"><div class="displayStepIcon"><img src="' . $this->imageURL . '" /></div>' . $this->caption . '</div>'; 51 48 } 52 49
Note: See TracChangeset
for help on using the changeset viewer.