1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * This file holds the functions for the installing |
---|
6 | * and enabling of the openlayers_test module. |
---|
7 | * |
---|
8 | * @ingroup openlayers |
---|
9 | */ |
---|
10 | |
---|
11 | /** |
---|
12 | * Implementation of hook_install(). |
---|
13 | */ |
---|
14 | function openlayers_test_install() { |
---|
15 | // Create test content type to be used with CCK and Views. |
---|
16 | // Only do this if CCK and Views are installed. |
---|
17 | if (module_exists('content') && module_exists('views') && module_exists('content_copy')) { |
---|
18 | // Create content type first |
---|
19 | $node_type = array( |
---|
20 | 'type' => 'openlayers_test_type', |
---|
21 | 'name' => st('OpenLayers Test Type'), |
---|
22 | 'module' => 'node', |
---|
23 | 'description' => st('This is a test content type for OpenLayers.'), |
---|
24 | 'custom' => TRUE, |
---|
25 | 'modified' => TRUE, |
---|
26 | 'locked' => TRUE, |
---|
27 | ); |
---|
28 | |
---|
29 | $node_type = (object)_node_type_set_defaults($node_type); |
---|
30 | node_type_save($node_type); |
---|
31 | // Default to not promoted. |
---|
32 | variable_set('node_options_openlayers_test_type', array('status')); |
---|
33 | |
---|
34 | // The import process of CCK is not simply calling a function, |
---|
35 | // so we just feed the submit function the correct values |
---|
36 | module_load_include('inc', 'node', 'content_types.inc'); |
---|
37 | module_load_include('inc', 'content', 'includes/content.admin.inc'); |
---|
38 | module_load_include('inc', 'content', 'includes/content.crud'); |
---|
39 | module_load_include('module', 'content_copy', 'content_copy'); |
---|
40 | // Leverage macro making function |
---|
41 | $GLOBALS['content_copy']['submissions'] = _openlayers_test_content_definition(); |
---|
42 | $macro = content_copy_get_macro(); |
---|
43 | |
---|
44 | // Make form array |
---|
45 | $form = array(); |
---|
46 | $form_state = array( |
---|
47 | 'values' => array( |
---|
48 | 'type_name' => 'openlayers_test_type', |
---|
49 | 'macro' => $macro, |
---|
50 | ), |
---|
51 | ); |
---|
52 | |
---|
53 | // Call submit function |
---|
54 | content_copy_import_form_submit($form, $form_state); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * Implementation of hook_uninstall(). |
---|
60 | */ |
---|
61 | function openlayers_test_uninstall() { |
---|
62 | // Remove any added data |
---|
63 | node_type_delete('openlayers_test_type'); |
---|
64 | |
---|
65 | // Get module variables |
---|
66 | $results = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE '%s%%'", 'openlayers_test_'); |
---|
67 | // Remove variables |
---|
68 | while ($row = db_fetch_array($results)) { |
---|
69 | variable_del($row['name']); |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | /** |
---|
74 | * Get content type definition with fields. |
---|
75 | * |
---|
76 | * Retireives content type definition and fields |
---|
77 | * as exported from CCK. |
---|
78 | */ |
---|
79 | function _openlayers_test_content_definition() { |
---|
80 | $content['type'] = array( |
---|
81 | 'name' => 'OpenLayers Test Type', |
---|
82 | 'type' => 'openlayers_test_type', |
---|
83 | 'description' => 'This is a content type for testing OpenLayers functionality.', |
---|
84 | 'title_label' => 'Title', |
---|
85 | 'body_label' => 'Body', |
---|
86 | 'min_word_count' => '0', |
---|
87 | 'help' => '', |
---|
88 | 'node_options' => |
---|
89 | array( |
---|
90 | 'status' => TRUE, |
---|
91 | 'promote' => FALSE, |
---|
92 | 'sticky' => FALSE, |
---|
93 | 'revision' => FALSE, |
---|
94 | ), |
---|
95 | 'old_type' => 'openlayers_test_type', |
---|
96 | 'orig_type' => 'openlayers_test_type', |
---|
97 | 'module' => 'node', |
---|
98 | 'custom' => '1', |
---|
99 | 'modified' => '1', |
---|
100 | 'locked' => '1', |
---|
101 | 'comment' => 2, |
---|
102 | 'comment_default_mode' => 4, |
---|
103 | 'comment_default_order' => 1, |
---|
104 | 'comment_default_per_page' => 50, |
---|
105 | 'comment_controls' => 3, |
---|
106 | 'comment_anonymous' => 0, |
---|
107 | 'comment_subject_field' => 1, |
---|
108 | 'comment_preview' => 1, |
---|
109 | 'comment_form_location' => 0, |
---|
110 | ); |
---|
111 | $content['fields'] = array( |
---|
112 | 0 => |
---|
113 | array( |
---|
114 | 'label' => 'OpenLayers Test WKT', |
---|
115 | 'field_name' => 'field_openlayers_test_wkt', |
---|
116 | 'type' => 'openlayers_wkt', |
---|
117 | 'widget_type' => 'openlayers_wkt_widget', |
---|
118 | 'change' => 'Change basic information', |
---|
119 | 'weight' => '31', |
---|
120 | 'openlayers_cck_preset_map' => 'default', |
---|
121 | 'description' => 'This is some help text for this field.', |
---|
122 | 'default_value' => |
---|
123 | array( |
---|
124 | 0 => |
---|
125 | array( |
---|
126 | 'openlayers_wkt' => '', |
---|
127 | ), |
---|
128 | ), |
---|
129 | 'default_value_php' => '', |
---|
130 | 'default_value_widget' => NULL, |
---|
131 | 'group' => FALSE, |
---|
132 | 'required' => 0, |
---|
133 | 'multiple' => '0', |
---|
134 | 'openlayers_cck_feature_types' => |
---|
135 | array( |
---|
136 | 'point' => 'point', |
---|
137 | 'path' => 'path', |
---|
138 | 'polygon' => 'polygon', |
---|
139 | ), |
---|
140 | 'op' => 'Save field settings', |
---|
141 | 'module' => 'openlayers_cck', |
---|
142 | 'widget_module' => 'openlayers_cck', |
---|
143 | 'columns' => |
---|
144 | array( |
---|
145 | 'openlayers_wkt' => |
---|
146 | array( |
---|
147 | 'type' => 'text', |
---|
148 | 'size' => 'big', |
---|
149 | 'not null' => FALSE, |
---|
150 | 'sortable' => TRUE, |
---|
151 | 'views' => TRUE, |
---|
152 | ), |
---|
153 | ), |
---|
154 | 'display_settings' => |
---|
155 | array( |
---|
156 | 'label' => |
---|
157 | array( |
---|
158 | 'format' => 'above', |
---|
159 | 'exclude' => 0, |
---|
160 | ), |
---|
161 | 'teaser' => |
---|
162 | array( |
---|
163 | 'format' => 'default', |
---|
164 | 'exclude' => 0, |
---|
165 | ), |
---|
166 | 'full' => |
---|
167 | array( |
---|
168 | 'format' => 'default', |
---|
169 | 'exclude' => 0, |
---|
170 | ), |
---|
171 | 4 => |
---|
172 | array( |
---|
173 | 'format' => 'default', |
---|
174 | 'exclude' => 0, |
---|
175 | ), |
---|
176 | ), |
---|
177 | ), |
---|
178 | ); |
---|
179 | $content['extra'] = array( |
---|
180 | 'title' => '-5', |
---|
181 | 'body_field' => '0', |
---|
182 | 'revision_information' => '20', |
---|
183 | 'comment_settings' => '30', |
---|
184 | 'menu' => '-2', |
---|
185 | ); |
---|
186 | |
---|
187 | return $content; |
---|
188 | } |
---|