View source
<?php
require_once drupal_get_path('module', 'document') . '/document.inc';
function document_install() {
$t = get_t();
document_get_vocid();
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['document'], 'Abstract');
$vocab = document_get_vocab();
$field = array(
'field_name' => 'document_types',
'type' => 'taxonomy_term_reference',
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocab->machine_name,
'parent' => 0,
),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'document_types',
'entity_type' => 'node',
'label' => $t('Document type(s)'),
'bundle' => 'document',
'required' => true,
'widget' => array(
'type' => 'options_select',
),
'display' => array(
'default' => array(
'type' => 'hidden',
),
'teaser' => array(
'type' => 'hidden',
),
),
);
field_create_instance($instance);
}
function document_uninstall() {
variable_del('document_path');
variable_del('document_allow_external');
variable_del('document_allow_websearch');
variable_del('document_publish_email');
variable_del('document_publish_subject');
variable_del('document_publish_body');
variable_del('document_path');
variable_del('document_vocabulary');
$instance = field_info_instance('node', 'document_types', 'document');
field_delete_instance($instance, TRUE);
node_type_delete('document');
}
function document_schema() {
$schema['document'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'fid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 1024,
),
'author' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
),
'publish_year' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'size' => 'normal',
),
'keywords' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 1024,
),
'url' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 1024,
),
'external' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
),
),
'primary key' => array(
'vid',
),
);
return $schema;
}