function filedepot_install in filedepot 7
Same name and namespace in other branches
- 6 filedepot.install \filedepot_install()
Implements of hook_install().
File
- ./
filedepot.install, line 13 - filedepot.install filedepot: File Management Module developed by Nextide www.nextide.ca
Code
function filedepot_install() {
// During installation, the t() function is unavailable, so we use get_t()
// to store the name of the translation function.
$t = get_t();
$folder_def = array(
'name' => $t('Filedepot Folder'),
'type' => 'filedepot_folder',
'description' => $t('Filedepot Folder for storing documents'),
'title_label' => $t('Folder Name'),
'bundle' => 'filedepot',
'base' => 'node_content',
'min_word_count' => 0,
'help' => '',
'node_options' => array(
'status' => TRUE,
'promote' => FALSE,
'sticky' => FALSE,
'revision' => FALSE,
),
'custom' => TRUE,
'comment' => 1,
);
// Complete the node type definition by setting any defaults not explicitly
// declared above.
// http://api.drupal.org/api/function/node_type_set_defaults/7
$folder_type = node_type_set_defaults($folder_def);
// Save the content type
node_type_save($folder_type);
// Default to not promoted.
variable_set('node_options_filedepot_folder', array(
'status',
));
// Default to closed comments
//variable_set('comment_filedepot_folder', COMMENT_NODE_CLOSED);
variable_set('comment_filedepot_folder', 1);
// COMMENT_NODE_CLOSED
// Create all the fields we are adding to our content type.
// http://api.drupal.org/api/function/field_create_field/7
foreach (_filedepot_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 (_filedepot_installed_instances() as $instance) {
$instance['entity_type'] = 'node';
$instance['bundle'] = $folder_def['type'];
field_create_instance($instance);
}
/* Setup the default extension mapping so icons appear in the file listing */
$rawextensions = 'jpg=jpg.gif, gif=gif.gif, bmp=bmp.gif, doc=doc.gif, docx=doc.gif, xls=xls.gif, xlsx=xls.gif,';
$rawextensions .= 'ppt=ppt.gif, pptx=ppt.gif, mpp=mpp.gif, pdf=pdf.gif, txt=txt.gif, zip=zip.gif';
$extensionlines = preg_split('/\\r\\n|\\r|\\n/', $rawextensions);
foreach ($extensionlines as $line) {
if (!empty($line)) {
$records = explode(',', $line);
foreach ($records as $mapping) {
$data = explode('=', $mapping);
$ext = trim($data[0]);
$icon = trim($data[1]);
$extensiondata[$ext] = $icon;
}
}
}
variable_set('filedepot_extension_data', serialize($extensiondata));
}