/** 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; }
public function testResetParametersClearAll() { $this->_client->setMethod('POST'); $this->_client->setRawData('Foo Bar'); $this->_client->setHeaders('Content-Length', 7); $this->_client->setHeaders('Content-Type', 'text/plain'); $this->_client->setHeaders('Accept-Language', 'en'); $this->_client->resetParameters(true); $this->assertEquals('GET', $this->_client->getMethod()); $this->assertEquals(null, $this->_client->getRawData()); $this->assertEquals(null, $this->_client->getHeader('Content-Length')); $this->assertEquals(null, $this->_client->getHeader('Content-Type')); $this->assertEquals(null, $this->_client->getHeader('Accept-Language')); }
<body> <h1>Test EasyRdf_HTTP_Client Get</h1> <?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();
/** * Script to update test cases from rdfa.info * * @package EasyRdf * @copyright Copyright (c) 2012-2013 Nicholas J Humfrey * @license http://www.opensource.org/licenses/bsd-license.php */ set_include_path(get_include_path() . PATH_SEPARATOR . './lib/'); require_once "EasyRdf.php"; $RDFA_VERSION = 'rdfa1.1'; $HOST_LANGUAGE = 'xhtml5'; $REFERENCE_DISTILLER = 'http://www.w3.org/2012/pyRdfa/extract?format=nt&rdfagraph=output&uri='; $FIXTURE_DIR = dirname(__FILE__); EasyRdf_Namespace::set('test', 'http://www.w3.org/2006/03/test-description#'); EasyRdf_Namespace::set('rdfatest', 'http://rdfa.info/vocabs/rdfa-test#'); $client = new EasyRdf_Http_Client(); $manifest = EasyRdf_Graph::newAndLoad('http://rdfa.info/test-suite/manifest.ttl'); foreach ($manifest->allOfType('test:TestCase') as $test) { if (!in_array($RDFA_VERSION, $test->all('rdfatest:rdfaVersion'))) { continue; } if (!in_array($HOST_LANGUAGE, $test->all('rdfatest:hostLanguage'))) { continue; } if ($test->get('test:classification')->shorten() != 'test:required') { continue; } $id = $test->localName(); $title = $test->get('dc:title'); $escapedTitle = addcslashes($title, '\''); # Download the test input
public function testRequestNoUri() { $client = new EasyRdf_Http_Client(); $this->setExpectedException('EasyRdf_Exception'); $client->request(); }