PHP Класс Graphite

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$retriever Graphite_Retriever

Открытые методы

Метод Описание
__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 ( )

Приватные методы

Метод Описание
generatePointsMap ( $points ) Functions to create an OpenStreetMap HTML page

Описание методов

__construct() публичный Метод

@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 __set_state ( $data )

addBnodePrefix() публичный Метод

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

addCompressedTriple() публичный Метод

Add a single triple directly to the graph. Only addCompressedTriple accepts shortended URIs, eg foaf:name.
См. также: addTriple
public addCompressedTriple ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] )

addLabelRelation() публичный Метод

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() публичный Метод

As for addTurtle but load a string of RDF XML
См. также: addTurtle
public addRDFXML ( $base, $data )

addTriple() публичный Метод

Add a single triple directly to the graph.
См. также: addCompressedTriple
public addTriple ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] )

addTriples() публичный Метод

Add triples to the graph from an ARC2 datastrcture. This is the inverse of toArcTriples.
См. также: ARC2
См. также: toArcTriples
public addTriples ( $triples, $aliases = [], $map = [] )

addTurtle() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

allOfType() публичный Метод

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

allSubjects() публичный Метод

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

asString() публичный статический Метод

public static asString ( $uri )

cacheDir() публичный Метод

$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 cleanURI ( $uri )

clearURLMap() публичный Метод

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

dump() публичный Метод

$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() публичный Метод

См. также: dump()
public dumpText ( $options = [] )

expandURI() публичный Метод

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() публичный Метод

Устаревший: All graphite objects should implement __toString()
public forceString ( &$uri )

freeze() публичный Метод

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() публичный Метод

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() публичный Метод

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

loadSPARQL() публичный Метод

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 loaded ( $uri )

mailtoIcon() публичный Метод

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() публичный Метод

Add an additional namespace alias to the Graphite instance.
См. также: 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() публичный Метод

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 removeFragment ( $uri )

resource() публичный Метод

Get the resource with given URI. $uri may be abbreviated to "namespace:value".
public resource ( $uri ) : Graphite_Resource
Результат Graphite_Resource

serialize() публичный Метод

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 setARC2Config ( $config )

setDebug() публичный Метод

public setDebug ( $boolean )

setLang() публичный Метод

public setLang ( $lang )

setRetriever() публичный Метод

public setRetriever ( Graphite_Retriever $retriever )
$retriever Graphite_Retriever

shrinkURI() публичный Метод

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

t() публичный Метод

Alias for addCompressedTriple for more readable code.
См. также: addTriple
public t ( $s, $p, $o, $o_datatype = null, $o_lang = null, $aliases = [] )

telIcon() публичный Метод

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() публичный статический Метод

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() публичный Метод

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

toIcs() публичный Метод

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

toKml() публичный Метод

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

toOpenStreetMap() публичный Метод

public toOpenStreetMap ( )

Описание свойств

$retriever защищенное свойство

protected Graphite_Retriever $retriever
Результат Graphite_Retriever