Méthode |
Description |
|
__construct ( $namespaces = [], $uri = null ) |
Create a new instance of Graphite. |
|
__set_state ( $data ) |
|
|
addBnodePrefix ( string $uri ) |
Replace bnodes shorthand with configured bnodeprefix in URI |
|
addCompressedTriple ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] ) |
Add a single triple directly to the graph. Only addCompressedTriple accepts shortended URIs, eg foaf:name. |
|
addLabelRelation ( $addition ) |
Return a list of the relations currently used for $resource->label(), if called with a parameter then this should be an array to replace the current list. To just add additonal relation types to use as labels, use addLabelRelation($relation). |
|
addRDFXML ( $base, $data ) |
As for addTurtle but load a string of RDF XML |
|
addTriple ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] ) |
Add a single triple directly to the graph. |
|
addTriples ( $triples, $aliases = [], $map = [] ) |
Add triples to the graph from an ARC2 datastrcture. This is the inverse of toArcTriples. |
|
addTurtle ( $base, $data ) |
Take a base URI and a string of turtle RDF and load the new triples into the graph. Return the number of triples loaded. |
|
addURLMap ( $fn ) |
Add a function to the end of the URI->URL mapping list
function should take a Graphite::Resource and return a URL
or null to defer. |
|
addURLMapEarly ( $fn ) |
Add a function to the start of the URI->URL mapping list
function should take a Graphite::Resource and return a URL
or null to defer. |
|
allObjects ( ) |
Return a list of all resources in the graph which are the object of at least one triple. |
|
allOfType ( $uri ) |
Return a list of all resources loaded, with the rdf:type given. eg. $graph->allOfType( "foaf:Person" ) |
|
allSubjects ( ) |
Return a list of all resources in the graph which are the subject of at least one triple. |
|
asString ( $uri ) |
|
|
cacheDir ( $dir, $age = 86400 ) |
$dir should be a directory the webserver has permission to read and write to. Any RDF/XML documents which graphite downloads will be saved here. If a cache exists and is newer than $age seconds then load() will use the document in the cache directory in preference to doing an HTTP request. $age defaults to 24*60*60 - 24 hours. This including this function can seriously improve graphite performance! If you want to always load certain documents, load them before setting the cache. |
|
cleanURI ( $uri ) |
|
|
clearURLMap ( $fn ) |
Clear the URI->URL mapping list. |
|
dump ( $options = [] ) |
Create a pretty HTML dump of the current resource. Handy for debugging halfway through hacking something. |
|
dumpText ( $options = [] ) |
|
|
expandURI ( $uri ) |
Translate a URI from the short form to any long version known. |
|
forceString ( &$uri ) |
|
|
freeze ( $filename ) |
Graphite uses ARC2 to parse RDF, which isn't as fast as using a compiled library. I may add support for RAP or something similar. When Graphite loads a triple it indexes it by both subject & object, which also takes a little time. To address this issue, freeze and thaw go some way to help speed things up. freeze takes a graph object, including all the namespaces set with ns() and saves it to disk as a serialised PHP object, which is much faster to load then a large RDF file. It's ideal in a situation where you want to build a site from a single RDF document which is updated occasionally. This example is a command line script you can modify to load and freeze a graph. |
|
labelRelations ( $new = null ) |
Return a list of the relations currently used for $resource->label(), if called with a parameter then this should be an array to replace the current list. To just add additonal relation types to use as labels, use addLabelRelation($relation). |
|
load ( $uri, $aliases = [], $map = [] ) |
Load the RDF from the given URI or URL. Return the number of triples loaded. |
|
loadSPARQL ( $endpoint, $query, $opts = [] ) |
This uses one or more SPARQL queries to the given endpoint to get all the triples required for the description. The return value is the total number of triples added to the graph. |
|
loaded ( $uri ) |
|
|
mailtoIcon ( $new = null ) |
Get or set the URL of the icon used for mailto: and tel: links in prettyLink(). If set to an empty string then no icon will be shown. |
|
ns ( string $short, string $long ) |
Add an additional namespace alias to the Graphite instance. |
|
primaryTopic ( $uri = null ) |
Utility method (shamelessly ripped off from EasyRDF). Returns the primary topic of the first URL that was loaded. Handy when working with FOAF. |
|
removeFragment ( $uri ) |
|
|
resource ( $uri ) : Graphite_Resource |
Get the resource with given URI. $uri may be abbreviated to "namespace:value". |
|
serialize ( $type = "RDFXML" ) |
Returns the serialization of the entire RDF graph in memory using one of Arc2's serializers. By default the RDF/XML serializer is used, but others (try passing "Turtle" or "NTriples") can be used - see the Arc2 documentation. |
|
setARC2Config ( $config ) |
|
|
setDebug ( $boolean ) |
|
|
setLang ( $lang ) |
|
|
setRetriever ( Graphite_Retriever $retriever ) |
|
|
shrinkURI ( $uri ) |
Translate a URI from the long form to any shorthand version known. |
|
t ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] ) |
Alias for addCompressedTriple for more readable code. |
|
telIcon ( $new = null ) |
Get or set the URL of the icon used for mailto: and tel: links in prettyLink(). If set to an empty string then no icon will be shown. |
|
thaw ( $filename ) |
Graphite uses ARC2 to parse RDF, which isn't as fast as using a compiled library. I may add support for RAP or something similar. When Graphite loads a triple it indexes it by both subject & object, which also takes a little time. To address this issue, freeze and thaw go some way to help speed things up. freeze takes a graph object, including all the namespaces set with ns() and saves it to disk as a serialised PHP object, which is much faster to load then a large RDF file. It's ideal in a situation where you want to build a site from a single RDF document which is updated occasionally. This example is a command line script you can modify to load and freeze a graph. |
|
toArcTriples ( ) |
Returns all triples of which this resource is the subject in Arc2's internal triples format. |
|
toIcs ( ) |
Returns a serialization of every temporal entity as an iCalendar file |
|
toKml ( ) |
Returns a serialization of every geo-locatable entity as KML |
|
toOpenStreetMap ( ) |
|
|