Mercurial > hg > rr-repo
comparison sites/all/modules/rdf_example/rdf_example.module @ 4:ce11bbd8f642
added modules
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 19 Sep 2013 10:38:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:b28be78d8160 | 4:ce11bbd8f642 |
---|---|
1 <?php | |
2 // $Id$ | |
3 | |
4 /** | |
5 * @file | |
6 * This is an example outlining how a module can be used to define RDF mappings. | |
7 * We define mappings for a node type defined in this module. | |
8 */ | |
9 | |
10 /** | |
11 * Implements hook_rdf_mapping(). | |
12 * | |
13 * This hook should only be used to define the RDF mapping for an entity or | |
14 * bundle that has been defined by this module. On installation, this mapping | |
15 * will be saved to the database. To alter anything in this mapping after module | |
16 * installation (or to alter bundles defined in another module), the RDF CRUD | |
17 * functions should be used. | |
18 */ | |
19 function rdf_example_rdf_mapping() { | |
20 return array( | |
21 'recipe' => array( | |
22 'type' => 'node', | |
23 'bundle' => 'recipe', | |
24 'mapping' => array( | |
25 'rdftype' => array('v:Recipe'), | |
26 // We don't use the default bundle mapping for title. Instead, we add | |
27 // the v:name property. We still want to use dc:title as well, though, | |
28 // so we include it in the array. | |
29 'title' => array( | |
30 'predicates' => array('dc:title', 'v:name'), | |
31 ), | |
32 'recipe_summary' => array( | |
33 'predicates' => array('v:summary'), | |
34 ), | |
35 // The photo URI isn't a string but instead points to a resource, so we | |
36 // indicate that the attribute type is rel. If type isn't specified, it | |
37 // defaults to property, which is used for string values. | |
38 'recipe_photo' => array( | |
39 'predicates' => array('v:photo'), | |
40 'type' => 'rel', | |
41 ), | |
42 'recipe_nutrition' => array( | |
43 'predicates' => array('v:nutrition'), | |
44 'type' => 'rel', | |
45 ), | |
46 ), | |
47 ), | |
48 'nutrition' => array( | |
49 'type' => 'field_collection_item', | |
50 'bundle' => 'recipe_nutrition', | |
51 'mapping' => array( | |
52 'rdftype' => array('v:Nutrition'), | |
53 'recipe_serving_size' => array( | |
54 'predicates' => array('v:servingSize'), | |
55 ), | |
56 'recipe_calories' => array( | |
57 'predicates' => array('v:calories'), | |
58 ), | |
59 ), | |
60 ), | |
61 ); | |
62 } | |
63 | |
64 /* | |
65 * Implements hook_rdf_namespaces(). | |
66 * | |
67 * This hook should be used to define any prefixes used by this module that are | |
68 * not already defined in core by rdf_rdf_namespaces. | |
69 * | |
70 * http://api.drupal.org/api/drupal/modules--rdf--rdf.api.php/function/hook_rdf_namespaces/7 | |
71 */ | |
72 function rdf_example_rdf_namespaces() { | |
73 return array( | |
74 // Google's namespace for their custom vocabularies. | |
75 'v' => 'http://rdf.data-vocabulary.org/#', | |
76 ); | |
77 } |