function tft_install in Taxonomy File Tree 7.2
Same name and namespace in other branches
- 7 tft.install \tft_install()
Implements hook_install().
File
- ./
tft.install, line 11 - Module install logic.
Code
function tft_install() {
$vocabulary = taxonomy_vocabulary_machine_name_load('tft_tree');
if (empty($vocabulary)) {
$vocabulary = (object) array(
'name' => "Opigno file tree",
'machine_name' => 'tft_tree',
);
taxonomy_vocabulary_save($vocabulary);
}
variable_set('tft_vocabulary_vid', $vocabulary->vid);
$type = node_type_load('tft_file');
if (empty($type)) {
$type = node_type_set_defaults(array(
'type' => 'tft_file',
'name' => st('File'),
'base' => 'node_content',
'description' => '',
'custom' => 1,
'modified' => 1,
'locked' => 1,
'promoted' => 0,
));
node_type_save($type);
node_add_body_field($type);
}
// Add the quiz weight field.
$field = field_info_field('tft_file');
if (empty($field)) {
field_create_field(array(
'field_name' => 'tft_file',
'type' => 'file',
));
}
$field = field_info_field('tft_folder');
if (empty($field)) {
field_create_field(array(
'cardinality' => 1,
'field_name' => 'tft_folder',
'foreign keys' => array(
'tid' => array(
'columns' => array(
'tid' => 'tid',
),
'table' => 'taxonomy_term_data',
),
),
'indexes' => array(
'tid' => array(
0 => 'tid',
),
),
'locked' => 0,
'module' => 'taxonomy',
'settings' => array(
'allowed_values' => array(
0 => array(
'vocabulary' => 'tft_tree',
'parent' => 0,
),
),
),
'translatable' => 0,
'type' => 'taxonomy_term_reference',
));
}
$instance = field_info_instance('node', 'tft_file', 'tft_file');
if (empty($instance)) {
field_create_instance(array(
'field_name' => 'tft_file',
'entity_type' => 'node',
'bundle' => 'tft_file',
'label' => "File",
'required' => 1,
'settings' => array(
'file_extensions' => 'jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps odt ods odp',
),
));
}
$instance = field_info_instance('node', 'tft_folder', 'tft_file');
if (empty($instance)) {
field_create_instance(array(
'bundle' => 'tft_file',
'description' => '',
'entity_type' => 'node',
'field_name' => 'tft_folder',
'label' => 'Folder',
'required' => 0,
'widget' => array(
'active' => 1,
'module' => 'options',
'settings' => array(),
'type' => 'options_select',
'weight' => -2,
),
));
}
}