-
Notifications
You must be signed in to change notification settings - Fork 0
/
ding_item_viewer.install
90 lines (80 loc) · 1.88 KB
/
ding_item_viewer.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @file
*/
/**
* Implements hook_uninstall().
*/
function ding_item_viewer_uninstall() {
// Remove settings.
variable_del('ding_item_viewer_item_limit');
variable_del('ding_item_viewer_search_queries');
variable_del('ding_item_viewer_cache_ttl');
}
/**
* Implements hook_install().
*/
function ding_item_viewer_install() {
ding_item_viewer_update_7001();
}
/**
* Add 'More info' field.
*/
function ding_item_viewer_update_7001() {
field_cache_clear();
ding_item_viewer_create_field();
_ding_item_viewer_enable_modules();
}
function ding_item_viewer_create_field() {
$field_name = 'more_info';
$field = field_info_field($field_name);
if ($field) {
$instance = field_info_instance('ting_object', $field_name, 'ting_object');
field_purge_instance($instance);
field_purge_field($field);
}
$field = array(
'field_name' => $field_name,
'type' => 'ting_object_more_info',
'locked' => FALSE,
'default_widget' => 'hidden',
'no_ui' => TRUE,
'entity_types' => array('ting_object'),
'storage' => array(
'type' => 'virtual_field',
),
);
field_create_field($field);
$instance = array(
'field_name' => $field_name,
'label' => 'More info',
'bundle' => 'ting_object',
'entity_type' => 'ting_object',
'widget' => array(
'type' => 'hidden',
),
'formatter' => array(
'type' => 'ting_object_more_info_default',
),
'display' => array(
'ding_item_viewer_big' => array(
'label' => 'hidden',
),
),
);
field_create_instance($instance);
}
/**
* Enable required modules.
*/
function _ding_item_viewer_enable_modules() {
if (!module_exists('ding_entity_buttons_settings')) {
module_enable(array('ding_entity_buttons_settings'), TRUE);
}
}
/**
* Fix fields.
*/
function ding_item_viewer_update_7002() {
features_revert(array('ding_item_viewer' => 'field'));
}