rdf.api.php 3.6 KB

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