Mercurial > hg > rr-repo
view 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 |
line wrap: on
line source
<?php // $Id$ /** * @file * This is an example outlining how a module can be used to define RDF mappings. * We define mappings for a node type defined in this module. */ /** * Implements hook_rdf_mapping(). * * This hook should only be used to define the RDF mapping for an entity or * bundle that has been defined by this module. On installation, this mapping * will be saved to the database. To alter anything in this mapping after module * installation (or to alter bundles defined in another module), the RDF CRUD * functions should be used. */ function rdf_example_rdf_mapping() { return array( 'recipe' => array( 'type' => 'node', 'bundle' => 'recipe', 'mapping' => array( 'rdftype' => array('v:Recipe'), // We don't use the default bundle mapping for title. Instead, we add // the v:name property. We still want to use dc:title as well, though, // so we include it in the array. 'title' => array( 'predicates' => array('dc:title', 'v:name'), ), 'recipe_summary' => array( 'predicates' => array('v:summary'), ), // The photo URI isn't a string but instead points to a resource, so we // indicate that the attribute type is rel. If type isn't specified, it // defaults to property, which is used for string values. 'recipe_photo' => array( 'predicates' => array('v:photo'), 'type' => 'rel', ), 'recipe_nutrition' => array( 'predicates' => array('v:nutrition'), 'type' => 'rel', ), ), ), 'nutrition' => array( 'type' => 'field_collection_item', 'bundle' => 'recipe_nutrition', 'mapping' => array( 'rdftype' => array('v:Nutrition'), 'recipe_serving_size' => array( 'predicates' => array('v:servingSize'), ), 'recipe_calories' => array( 'predicates' => array('v:calories'), ), ), ), ); } /* * Implements hook_rdf_namespaces(). * * This hook should be used to define any prefixes used by this module that are * not already defined in core by rdf_rdf_namespaces. * * http://api.drupal.org/api/drupal/modules--rdf--rdf.api.php/function/hook_rdf_namespaces/7 */ function rdf_example_rdf_namespaces() { return array( // Google's namespace for their custom vocabularies. 'v' => 'http://rdf.data-vocabulary.org/#', ); }