/** Get the data for reuse based off sparql endpoint * @access public * @return array $data * */ public function getInfo($identifier) { $key = md5($identifier . 'ocre'); $uri = self::CRRO . $identifier; if (!$this->getCache()->test($key)) { EasyRdf_Namespace::set('nm', 'http://nomisma.org/id/'); EasyRdf_Namespace::set('nmo', 'http://nomisma.org/ontology#'); EasyRdf_Namespace::set('skos', 'http://www.w3.org/2004/02/skos/core#'); EasyRdf_Namespace::set('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); $request = new EasyRdf_Http_Client(); $request->setUri($uri); $response = $request->request()->getStatus(); if ($response == 200) { $graph = new EasyRdf_Graph($uri); $graph->load(); $data = $graph->resource($uri); $this->getCache()->save($data); } else { $data = NULL; } } else { $data = $this->getCache()->load($key); } return $data; }
/** Get the data for rendering * @access public * @return * */ public function getData() { $key = md5($this->getUri()); if (!$this->getCache()->test($key)) { $request = new EasyRdf_Http_Client(); $request->setUri($this->getUri()); $response = $request->request()->getStatus(); if ($response == 200) { $graph = new EasyRdf_Graph($this->_uri); $graph->load(); $data = $graph->resource($this->_uri); } else { $data = NULL; } $this->getCache()->save($data); } else { $data = $this->getCache()->load($key); } return $data; }
<?php echo form_tag(); echo text_field_tag('uri', 'http://tomheath.com/id/me', array('size' => 50)); ?> <br /> <?php echo label_tag('accept', 'Accept Header: ') . select_tag('accept', $accept_options); echo submit_tag(); echo form_end_tag(); ?> <?php if (isset($_REQUEST['uri'])) { $client = new EasyRdf_Http_Client($_REQUEST['uri']); $client->setHeaders('Accept', $_REQUEST['accept']); $response = $client->request(); ?> <p class="status"> <b>Status</b>: <?php echo $response->getStatus(); ?> <br /> <b>Message</b>: <?php echo $response->getMessage(); ?> <br /> <b>Version</b>: HTTP/<?php echo $response->getVersion(); ?> <br />
public function testRequestNoUri() { $client = new EasyRdf_Http_Client(); $this->setExpectedException('EasyRdf_Exception', 'Set URI before calling EasyRdf_Http_Client->request()'); $client->request(); }
public function testRequestNoUri() { $client = new EasyRdf_Http_Client(); $this->setExpectedException('EasyRdf_Exception'); $client->request(); }