'recipe', 'name' => $t('Recipe'), 'base' => 'node_content', 'description' => $t('The recipe node is defined to demonstrate RDF mapping.'), ); // Set additional defaults and save the content type. $content_type = node_type_set_defaults($rdf_example); node_type_save($content_type); // Create all the fields we are adding to our content type. // http://api.drupal.org/api/function/field_create_field/7 foreach (_rdf_example_installed_fields() as $field) { field_create_field($field); } // Create all the instances for our fields. // http://api.drupal.org/api/function/field_create_instance/7 foreach (_rdf_example_installed_instances() as $instance) { $instance['entity_type'] = 'node'; $instance['bundle'] = $rdf_example['type']; field_create_instance($instance); } } /** * Return a structured array defining the fields created by this content type. * * @ingroup rdf_example */ function _rdf_example_installed_fields() { $t = get_t(); return array( 'recipe_photo' => array( 'field_name' => 'recipe_photo', 'cardinality' => 1, 'type' => 'image', ), 'recipe_summary' => array( 'field_name' => 'recipe_summary', 'cardinality' => 1, 'type' => 'text', 'settings' => array( 'max_length' => 500, ), ), ); } /** * Return a structured array defining the instances for this content type. * * @ingroup rdf_example */ function _rdf_example_installed_instances() { $t = get_t(); return array( 'recipe_photo' => array( 'field_name' => 'recipe_photo', 'label' => $t('Photo of the prepared dish'), ), 'recipe_summary' => array( 'field_name' => 'recipe_summary', 'label' => $t('Short summary describing the dish'), 'widget' => array( 'type' => 'text_textarea', ), ), ); } /** * Implements hook_uninstall(). * * @ingroup rdf_example */ function rdf_example_uninstall() { // Delete recipe content. $sql = 'SELECT nid FROM {node} n WHERE n.type = :type'; $result = db_query($sql, array(':type' => 'recipe')); $nids = array(); foreach ($result as $row) { $nids[] = $row->nid; } node_delete_multiple($nids); // Delete field instances for now. // Check status of http://drupal.org/node/1015846 $instances = field_info_instances('node', 'recipe'); foreach ($instances as $instance_name => $instance) { field_delete_instance($instance); } // Delete node type. node_type_delete('recipe'); field_purge_batch(1000); }