PHP 클래스 Graphite

파일 보기 프로젝트 열기: cgutteridge/graphite 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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