PHP Class Graphite

Afficher le fichier Open project: cgutteridge/graphite Class Usage Examples

Protected Properties

Свойство Type Description
$retriever Graphite_Retriever

Méthodes publiques

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 ( )

Private Methods

Méthode Description
generatePointsMap ( $points ) Functions to create an OpenStreetMap HTML page

Method Details

__construct() public méthode

@see ns() for how to specify a namespace map and a list of pre-declared namespaces.
public __construct ( $namespaces = [], $uri = null )

__set_state() public static méthode

public static __set_state ( $data )

addBnodePrefix() public méthode

Replace bnodes shorthand with configured bnodeprefix in URI
public addBnodePrefix ( string $uri )
$uri string

addCompressedTriple() public méthode

Add a single triple directly to the graph. Only addCompressedTriple accepts shortended URIs, eg foaf:name.
See also: addTriple
public addCompressedTriple ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] )

addLabelRelation() public méthode

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).
public addLabelRelation ( $addition )

addRDFXML() public méthode

As for addTurtle but load a string of RDF XML
See also: addTurtle
public addRDFXML ( $base, $data )

addTriple() public méthode

Add a single triple directly to the graph.
See also: addCompressedTriple
public addTriple ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] )

addTriples() public méthode

Add triples to the graph from an ARC2 datastrcture. This is the inverse of toArcTriples.
See also: ARC2
See also: toArcTriples
public addTriples ( $triples, $aliases = [], $map = [] )

addTurtle() public méthode

Take a base URI and a string of turtle RDF and load the new triples into the graph. Return the number of triples loaded.
public addTurtle ( $base, $data )

addURLMap() public méthode

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.
public addURLMap ( $fn )

addURLMapEarly() public méthode

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.
public addURLMapEarly ( $fn )

allObjects() public méthode

Return a list of all resources in the graph which are the object of at least one triple.
public allObjects ( )

allOfType() public méthode

Return a list of all resources loaded, with the rdf:type given. eg. $graph->allOfType( "foaf:Person" )
public allOfType ( $uri )

allSubjects() public méthode

Return a list of all resources in the graph which are the subject of at least one triple.
public allSubjects ( )

asString() public static méthode

public static asString ( $uri )

cacheDir() public méthode

$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.
public cacheDir ( $dir, $age = 86400 )

cleanURI() public méthode

public cleanURI ( $uri )

clearURLMap() public méthode

Clear the URI->URL mapping list.
public clearURLMap ( $fn )

dump() public méthode

$options is an optional array of flags to modify how dump() renders HTML. dumpText() does the same think with ASCII indention instead of HTML markup, and is intended for debugging command-line scripts. "label"=> 1 - add a label for the URI, and the rdf:type, to the top of each resource box, if the information is in the current graph. "labeluris"=> 1 - when listing the resources to which this URI relates, show them as a label, if possible, rather than a URI. Hovering the mouse will still show the URI.
"internallinks"=> 1 - instead of linking directly to the URI, link to that resource's dump on the current page (which may or may not be present). This can, for example, make bnode nests easier to figure out.
public dump ( $options = [] )

dumpText() public méthode

See also: dump()
public dumpText ( $options = [] )

expandURI() public méthode

IE: foaf:knows => http://xmlns.com/foaf/0.1/knows also expands "a" => http://www.w3.org/1999/02/22-rdf-syntax-ns#type
public expandURI ( $uri )

forceString() public méthode

Deprecation: All graphite objects should implement __toString()
public forceString ( &$uri )

freeze() public méthode

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.
public freeze ( $filename )

labelRelations() public méthode

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).
public labelRelations ( $new = null )

load() public méthode

Load the RDF from the given URI or URL. Return the number of triples loaded.
public load ( $uri, $aliases = [], $map = [] )

loadSPARQL() public méthode

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.
public loadSPARQL ( $endpoint, $query, $opts = [] )

loaded() public méthode

public loaded ( $uri )

mailtoIcon() public méthode

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.
public mailtoIcon ( $new = null )

ns() public méthode

Add an additional namespace alias to the Graphite instance.
See also: http://www.w3.org/TR/REC-xml-names/#ns-decl
public ns ( string $short, string $long )
$short string Must be a valid xmlns prefix. urn, http, doi, https, ftp, mail, xmlns, file and data are reserved.
$long string Must be either a valid URI or an empty string.

primaryTopic() public méthode

Utility method (shamelessly ripped off from EasyRDF). Returns the primary topic of the first URL that was loaded. Handy when working with FOAF.
public primaryTopic ( $uri = null )

removeFragment() public méthode

public removeFragment ( $uri )

resource() public méthode

Get the resource with given URI. $uri may be abbreviated to "namespace:value".
public resource ( $uri ) : Graphite_Resource
Résultat Graphite_Resource

serialize() public méthode

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.
public serialize ( $type = "RDFXML" )

setARC2Config() public méthode

public setARC2Config ( $config )

setDebug() public méthode

public setDebug ( $boolean )

setLang() public méthode

public setLang ( $lang )

setRetriever() public méthode

public setRetriever ( Graphite_Retriever $retriever )
$retriever Graphite_Retriever

shrinkURI() public méthode

IE: http://xmlns.com/foaf/0.1/knows => foaf:knows
public shrinkURI ( $uri )

t() public méthode

Alias for addCompressedTriple for more readable code.
See also: addTriple
public t ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] )

telIcon() public méthode

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.
public telIcon ( $new = null )

thaw() public static méthode

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.
public static thaw ( $filename )

toArcTriples() public méthode

Returns all triples of which this resource is the subject in Arc2's internal triples format.
public toArcTriples ( )

toIcs() public méthode

Returns a serialization of every temporal entity as an iCalendar file
public toIcs ( )

toKml() public méthode

Returns a serialization of every geo-locatable entity as KML
public toKml ( )

toOpenStreetMap() public méthode

public toOpenStreetMap ( )

Property Details

$retriever protected_oe property

protected Graphite_Retriever $retriever
Résultat Graphite_Retriever