root / drupal7 / modules / rdf / rdf.api.php @ 76597ebf
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Hooks provided by the RDF module.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* @addtogroup hooks
|
10 |
* @{
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Allow modules to define RDF mappings for field bundles.
|
15 |
*
|
16 |
* Modules defining their own field bundles can specify which RDF semantics
|
17 |
* should be used to annotate these bundles. These mappings are then used for
|
18 |
* automatic RDFa output in the HTML code.
|
19 |
*
|
20 |
* @return
|
21 |
* A list of mapping structures, where each mapping is an associative array:
|
22 |
* - type: The name of an entity type (e.g., 'node', 'comment', and so on.)
|
23 |
* - bundle: The name of the bundle (e.g., 'page', 'blog', or
|
24 |
* RDF_DEFAULT_BUNDLE for default mappings.)
|
25 |
* - mapping: The mapping structure which applies to the entity type and
|
26 |
* bundle. A mapping structure is an array with keys corresponding to
|
27 |
* existing field instances in the bundle. Each field is then described in
|
28 |
* terms of the RDF mapping:
|
29 |
* - predicates: An array of RDF predicates which describe the relation
|
30 |
* between the bundle (RDF subject) and the value of the field (RDF
|
31 |
* object). This value is either some text, another bundle, or a URI in
|
32 |
* general.
|
33 |
* - datatype: Is used along with 'callback' to format data so that it is
|
34 |
* readable by machines. A typical example is a date which can be written
|
35 |
* in many different formats but should be translated into a uniform
|
36 |
* format for machine consumption.
|
37 |
* - callback: A function name to invoke for 'datatype'.
|
38 |
* - type: A string used to determine the type of RDFa markup which will be
|
39 |
* used in the final HTML output, depending on whether the RDF object is a
|
40 |
* literal text or another RDF resource.
|
41 |
* - rdftype: A special property used to define the type of the instance.
|
42 |
* Its value should be an array of RDF classes.
|
43 |
*
|
44 |
* @ingroup rdf
|
45 |
*/
|
46 |
function hook_rdf_mapping() { |
47 |
return array( |
48 |
array(
|
49 |
'type' => 'node', |
50 |
'bundle' => 'blog', |
51 |
'mapping' => array( |
52 |
'rdftype' => array('sioct:Weblog'), |
53 |
'title' => array( |
54 |
'predicates' => array('dc:title'), |
55 |
), |
56 |
'created' => array( |
57 |
'predicates' => array('dc:date', 'dc:created'), |
58 |
'datatype' => 'xsd:dateTime', |
59 |
'callback' => 'date_iso8601', |
60 |
), |
61 |
'body' => array( |
62 |
'predicates' => array('content:encoded'), |
63 |
), |
64 |
'uid' => array( |
65 |
'predicates' => array('sioc:has_creator'), |
66 |
'type' => 'rel', |
67 |
), |
68 |
'name' => array( |
69 |
'predicates' => array('foaf:name'), |
70 |
), |
71 |
), |
72 |
), |
73 |
); |
74 |
} |
75 |
|
76 |
/**
|
77 |
* Allow modules to define namespaces for RDF mappings.
|
78 |
*
|
79 |
* Many common namespace prefixes are defined in rdf_rdf_namespaces(). However,
|
80 |
* if a module implements hook_rdf_mapping() and uses a prefix that is not
|
81 |
* defined in rdf_rdf_namespaces(), this hook should be used to define the new
|
82 |
* namespace prefix.
|
83 |
*
|
84 |
* @return
|
85 |
* An associative array of namespaces where the key is the namespace prefix
|
86 |
* and the value is the namespace URI.
|
87 |
*
|
88 |
* @ingroup rdf
|
89 |
*/
|
90 |
function hook_rdf_namespaces() { |
91 |
return array( |
92 |
'content' => 'http://purl.org/rss/1.0/modules/content/', |
93 |
'dc' => 'http://purl.org/dc/terms/', |
94 |
'foaf' => 'http://xmlns.com/foaf/0.1/', |
95 |
'og' => 'http://ogp.me/ns#', |
96 |
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', |
97 |
'sioc' => 'http://rdfs.org/sioc/ns#', |
98 |
'sioct' => 'http://rdfs.org/sioc/types#', |
99 |
'skos' => 'http://www.w3.org/2004/02/skos/core#', |
100 |
'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
101 |
); |
102 |
} |
103 |
|
104 |
/**
|
105 |
* @} End of "addtogroup hooks".
|
106 |
*/
|