@@ -4,197 +4,197 @@ discard block |
||
4 | 4 | * Determine context major branch version. |
5 | 5 | */ |
6 | 6 | function context_features_get_version() { |
7 | - if (function_exists('context_context_plugins')) { |
|
7 | + if (function_exists('context_context_plugins')) { |
|
8 | 8 | return 3; |
9 | - } |
|
10 | - return 2; |
|
9 | + } |
|
10 | + return 2; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Implementation of hook_features_api(). |
15 | 15 | */ |
16 | 16 | function context_features_api() { |
17 | - $api = array('context' => array()); |
|
18 | - // 3.x |
|
19 | - if (context_features_get_version() === 3) { |
|
17 | + $api = array('context' => array()); |
|
18 | + // 3.x |
|
19 | + if (context_features_get_version() === 3) { |
|
20 | 20 | $api['context'] = array( |
21 | - 'api' => 'context', |
|
22 | - 'current_version' => 3, |
|
23 | - 'module' => 'context', |
|
24 | - 'default_file' => FEATURES_DEFAULTS_CUSTOM, |
|
25 | - 'default_filename' => 'context', |
|
21 | + 'api' => 'context', |
|
22 | + 'current_version' => 3, |
|
23 | + 'module' => 'context', |
|
24 | + 'default_file' => FEATURES_DEFAULTS_CUSTOM, |
|
25 | + 'default_filename' => 'context', |
|
26 | 26 | ); |
27 | - } |
|
28 | - // 2.x |
|
29 | - $api['context'] += array( |
|
27 | + } |
|
28 | + // 2.x |
|
29 | + $api['context'] += array( |
|
30 | 30 | 'name' => 'Contexts', |
31 | 31 | 'feature_source' => TRUE, |
32 | 32 | 'default_hook' => 'context_default_contexts' |
33 | - ); |
|
34 | - return $api; |
|
33 | + ); |
|
34 | + return $api; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Implementation of hook_features_export_options(); |
39 | 39 | */ |
40 | 40 | function context_features_export_options() { |
41 | - // 3.x |
|
42 | - if (context_features_get_version() === 3) { |
|
41 | + // 3.x |
|
42 | + if (context_features_get_version() === 3) { |
|
43 | 43 | return ctools_component_features_export_options('context'); |
44 | - } |
|
45 | - // 2.x |
|
46 | - $contexts = context_enabled_contexts(); |
|
47 | - $options = array(); |
|
48 | - foreach ($contexts as $identifier => $context) { |
|
44 | + } |
|
45 | + // 2.x |
|
46 | + $contexts = context_enabled_contexts(); |
|
47 | + $options = array(); |
|
48 | + foreach ($contexts as $identifier => $context) { |
|
49 | 49 | $options[$identifier] = "{$context->namespace} > {$context->attribute} > {$context->value}"; |
50 | - } |
|
51 | - return $options; |
|
50 | + } |
|
51 | + return $options; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Implementation of hook_features_export(). |
56 | 56 | */ |
57 | 57 | function context_features_export($data, &$export, $module_name = '') { |
58 | - // 3.x |
|
59 | - if (context_features_get_version() === 3) { |
|
58 | + // 3.x |
|
59 | + if (context_features_get_version() === 3) { |
|
60 | 60 | $pipe = ctools_component_features_export('context', $data, $export, $module_name); |
61 | 61 | |
62 | 62 | $contexts = context_load(); |
63 | 63 | foreach ($data as $identifier) { |
64 | - if (isset($contexts[$identifier])) { |
|
64 | + if (isset($contexts[$identifier])) { |
|
65 | 65 | $context = $contexts[$identifier]; |
66 | 66 | // Conditions. |
67 | 67 | // Currently only node and views conditions are supported. |
68 | 68 | // @TODO: Should this be delegated to a method on the plugin? |
69 | 69 | foreach (array('node', 'views') as $key) { |
70 | - if (!empty($context->conditions{$key}['values'])) { |
|
70 | + if (!empty($context->conditions{$key}['values'])) { |
|
71 | 71 | foreach ($context->conditions{$key}['values'] as $item) { |
72 | - // Special pipe for views |
|
73 | - if ($key === 'views') { |
|
72 | + // Special pipe for views |
|
73 | + if ($key === 'views') { |
|
74 | 74 | $split = explode(':', $item); |
75 | 75 | $view_name = array_shift($split); |
76 | 76 | $pipe[$key][$view_name] = $view_name; |
77 | - } |
|
78 | - else { |
|
77 | + } |
|
78 | + else { |
|
79 | 79 | $pipe[$key][$item] = $item; |
80 | - } |
|
80 | + } |
|
81 | + } |
|
81 | 82 | } |
82 | - } |
|
83 | 83 | } |
84 | 84 | // Reactions. |
85 | 85 | if (!empty($context->reactions['block']['blocks'])) { |
86 | - foreach ($context->reactions['block']['blocks'] as $block) { |
|
86 | + foreach ($context->reactions['block']['blocks'] as $block) { |
|
87 | 87 | $block = (array) $block; |
88 | 88 | $bid = "{$block['module']}-{$block['delta']}"; |
89 | 89 | $pipe['block'][$bid] = $bid; |
90 | - } |
|
90 | + } |
|
91 | + } |
|
91 | 92 | } |
92 | - } |
|
93 | 93 | } |
94 | 94 | return $pipe; |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | - // 2.x |
|
98 | - $export['dependencies']['context'] = 'context'; |
|
97 | + // 2.x |
|
98 | + $export['dependencies']['context'] = 'context'; |
|
99 | 99 | |
100 | - // Collect a context to module map |
|
101 | - $map = features_get_default_map('context', NULL, 'context_features_identifier_2'); |
|
102 | - $pipe = array(); |
|
103 | - $contexts = context_enabled_contexts(); |
|
104 | - foreach ($data as $identifier) { |
|
100 | + // Collect a context to module map |
|
101 | + $map = features_get_default_map('context', NULL, 'context_features_identifier_2'); |
|
102 | + $pipe = array(); |
|
103 | + $contexts = context_enabled_contexts(); |
|
104 | + foreach ($data as $identifier) { |
|
105 | 105 | // If this context is already provided by another module, add it |
106 | 106 | // as a dependency and prevent it from becoming a duplicate export. |
107 | 107 | if (isset($map[$identifier]) && $map[$identifier] != $module_name) { |
108 | - if (isset($export['features']['context'][$identifier])) { |
|
108 | + if (isset($export['features']['context'][$identifier])) { |
|
109 | 109 | unset($export['features']['context'][$identifier]); |
110 | - } |
|
111 | - $module = $map[$identifier]; |
|
112 | - $export['dependencies'][$module] = $module; |
|
110 | + } |
|
111 | + $module = $map[$identifier]; |
|
112 | + $export['dependencies'][$module] = $module; |
|
113 | 113 | } |
114 | 114 | // Otherwise, export it. |
115 | 115 | else if (!empty($contexts[$identifier])) { |
116 | - $export['features']['context'][$identifier] = $identifier; |
|
116 | + $export['features']['context'][$identifier] = $identifier; |
|
117 | 117 | |
118 | - $context = $contexts[$identifier]; |
|
118 | + $context = $contexts[$identifier]; |
|
119 | 119 | |
120 | - foreach (array('node', 'menu') as $key) { |
|
120 | + foreach (array('node', 'menu') as $key) { |
|
121 | 121 | if (!empty($context->{$key})) { |
122 | - if (is_array($context->{$key})) { |
|
122 | + if (is_array($context->{$key})) { |
|
123 | 123 | foreach ($context->{$key} as $item) { |
124 | - $pipe[$key][$item] = $item; |
|
124 | + $pipe[$key][$item] = $item; |
|
125 | 125 | } |
126 | - } |
|
127 | - else { |
|
126 | + } |
|
127 | + else { |
|
128 | 128 | $item = $context->{$key}; |
129 | 129 | $pipe[$key][$item] = $item; |
130 | - } |
|
130 | + } |
|
131 | + } |
|
131 | 132 | } |
132 | - } |
|
133 | 133 | |
134 | - // Special pipe for views |
|
135 | - if (!empty($context->views) && is_array($context->views)) { |
|
134 | + // Special pipe for views |
|
135 | + if (!empty($context->views) && is_array($context->views)) { |
|
136 | 136 | foreach ($context->views as $view_name) { |
137 | - $split = explode(':', $view_name); |
|
138 | - $view_name = array_shift($split); |
|
139 | - $pipe['views'][$view_name] = $view_name; |
|
137 | + $split = explode(':', $view_name); |
|
138 | + $view_name = array_shift($split); |
|
139 | + $pipe['views'][$view_name] = $view_name; |
|
140 | + } |
|
140 | 141 | } |
141 | - } |
|
142 | 142 | |
143 | - // Special pipe for blocks |
|
144 | - if (!empty($context->block)) { |
|
143 | + // Special pipe for blocks |
|
144 | + if (!empty($context->block)) { |
|
145 | 145 | foreach ($context->block as $block) { |
146 | - $block = (array) $block; |
|
147 | - $bid = "{$block['module']}-{$block['delta']}"; |
|
148 | - $pipe['block'][$bid] = $bid; |
|
146 | + $block = (array) $block; |
|
147 | + $bid = "{$block['module']}-{$block['delta']}"; |
|
148 | + $pipe['block'][$bid] = $bid; |
|
149 | + } |
|
149 | 150 | } |
150 | - } |
|
151 | 151 | } |
152 | - } |
|
153 | - return $pipe; |
|
152 | + } |
|
153 | + return $pipe; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Implementation of hook_features_export_render(). |
158 | 158 | */ |
159 | 159 | function context_features_export_render($module, $data) { |
160 | - // 3.x |
|
161 | - if (context_features_get_version() === 3) { |
|
160 | + // 3.x |
|
161 | + if (context_features_get_version() === 3) { |
|
162 | 162 | return ctools_component_features_export_render('context', $module, $data); |
163 | - } |
|
164 | - // 2.x |
|
165 | - $code = array(); |
|
166 | - $code[] = ' $items = array();'; |
|
167 | - $code[] = ''; |
|
163 | + } |
|
164 | + // 2.x |
|
165 | + $code = array(); |
|
166 | + $code[] = ' $items = array();'; |
|
167 | + $code[] = ''; |
|
168 | 168 | |
169 | - foreach ($data as $identifier) { |
|
169 | + foreach ($data as $identifier) { |
|
170 | 170 | $contexts = context_enabled_contexts(); |
171 | 171 | $context = $contexts[$identifier]; |
172 | 172 | |
173 | 173 | // prune system specific information and cast for Drupal's AOP (array oriented programming) |
174 | 174 | $prune = array('cid', 'status', 'system', 'type'); |
175 | 175 | foreach ($prune as $key) { |
176 | - if (isset($context->{$key})) { |
|
176 | + if (isset($context->{$key})) { |
|
177 | 177 | unset($context->{$key}); |
178 | - } |
|
178 | + } |
|
179 | 179 | } |
180 | 180 | $context = (array) $context; |
181 | 181 | |
182 | 182 | // clean up blocks |
183 | 183 | if (!empty($context['block'])) { |
184 | - foreach ($context['block'] as $bid => $block) { |
|
184 | + foreach ($context['block'] as $bid => $block) { |
|
185 | 185 | unset($block->bid); |
186 | 186 | $context['block'][$bid] = (array) $block; |
187 | - } |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $context_identifier = context_var_export($identifier); |
191 | 191 | $context_export = context_var_export($context, ' '); |
192 | 192 | $code[] = " \$items[{$context_identifier}] = {$context_export};"; |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - $code[] = ' return $items;'; |
|
196 | - $code = implode("\n", $code); |
|
197 | - return array('context_default_contexts' => $code); |
|
195 | + $code[] = ' return $items;'; |
|
196 | + $code = implode("\n", $code); |
|
197 | + return array('context_default_contexts' => $code); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -204,28 +204,28 @@ discard block |
||
204 | 204 | * name of module to revert content for |
205 | 205 | */ |
206 | 206 | function context_features_revert($module = NULL) { |
207 | - // 3.x |
|
208 | - if (context_features_get_version() === 3) { |
|
207 | + // 3.x |
|
208 | + if (context_features_get_version() === 3) { |
|
209 | 209 | $return = ctools_component_features_revert('context', $module); |
210 | 210 | context_invalidate_cache(); |
211 | 211 | return $return; |
212 | - } |
|
213 | - // 2.x |
|
214 | - if ($default_contexts = features_get_default('context', $module)) { |
|
212 | + } |
|
213 | + // 2.x |
|
214 | + if ($default_contexts = features_get_default('context', $module)) { |
|
215 | 215 | foreach($default_contexts as $default_context) { |
216 | - $current_context = new StdClass(); |
|
217 | - $current_context->namespace = $default_context['namespace']; |
|
218 | - $current_context->attribute = $default_context['attribute']; |
|
219 | - $current_context->value = $default_context['value']; |
|
220 | - $context_to_delete = context_load_context($current_context); |
|
221 | - context_delete_context($context_to_delete); |
|
222 | - } |
|
223 | - } |
|
216 | + $current_context = new StdClass(); |
|
217 | + $current_context->namespace = $default_context['namespace']; |
|
218 | + $current_context->attribute = $default_context['attribute']; |
|
219 | + $current_context->value = $default_context['value']; |
|
220 | + $context_to_delete = context_load_context($current_context); |
|
221 | + context_delete_context($context_to_delete); |
|
222 | + } |
|
223 | + } |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
227 | 227 | * 2.x: Callback for generating the context exportable identifier. |
228 | 228 | */ |
229 | 229 | function context_features_identifier_2($object) { |
230 | - return isset($object->namespace, $object->attribute, $object->value) ? "{$object->namespace}-{$object->attribute}-{$object->value}" : FALSE; |
|
230 | + return isset($object->namespace, $object->attribute, $object->value) ? "{$object->namespace}-{$object->attribute}-{$object->value}" : FALSE; |
|
231 | 231 | } |
@@ -4,97 +4,97 @@ discard block |
||
4 | 4 | * Implementation of hook_features_api(). |
5 | 5 | */ |
6 | 6 | function fieldgroup_features_api() { |
7 | - return array( |
|
7 | + return array( |
|
8 | 8 | 'fieldgroup' => array( |
9 | - 'name' => t('Fieldgroup'), |
|
10 | - 'default_hook' => 'fieldgroup_default_groups', |
|
11 | - 'default_file' => FEATURES_DEFAULTS_INCLUDED, |
|
9 | + 'name' => t('Fieldgroup'), |
|
10 | + 'default_hook' => 'fieldgroup_default_groups', |
|
11 | + 'default_file' => FEATURES_DEFAULTS_INCLUDED, |
|
12 | 12 | ), |
13 | - ); |
|
13 | + ); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Implementation of hook_features_export(). |
18 | 18 | */ |
19 | 19 | function fieldgroup_features_export($data, &$export, $module_name = '') { |
20 | - features_include_defaults('fieldgroup'); |
|
21 | - $pipe = array(); |
|
20 | + features_include_defaults('fieldgroup'); |
|
21 | + $pipe = array(); |
|
22 | 22 | |
23 | - // The hook_fieldgroup_default_groups() hook integration is provided by the |
|
24 | - // features module so we need to add it as a dependency. |
|
25 | - $export['dependencies']['features'] = 'features'; |
|
23 | + // The hook_fieldgroup_default_groups() hook integration is provided by the |
|
24 | + // features module so we need to add it as a dependency. |
|
25 | + $export['dependencies']['features'] = 'features'; |
|
26 | 26 | |
27 | - // Collect a group to module map |
|
28 | - $map = features_get_default_map('fieldgroup', NULL, 'fieldgroup_features_identifier'); |
|
29 | - foreach ($data as $instance) { |
|
27 | + // Collect a group to module map |
|
28 | + $map = features_get_default_map('fieldgroup', NULL, 'fieldgroup_features_identifier'); |
|
29 | + foreach ($data as $instance) { |
|
30 | 30 | // If this group is already provided by another module, remove the group |
31 | 31 | // and add the other module as a dependency. |
32 | 32 | if (isset($map[$instance]) && $map[$instance] != $module_name) { |
33 | - if (isset($export['features']['fieldgroup'][$instance])) { |
|
33 | + if (isset($export['features']['fieldgroup'][$instance])) { |
|
34 | 34 | unset($export['features']['fieldgroup'][$instance]); |
35 | - } |
|
36 | - $module = $map[$instance]; |
|
37 | - $export['dependencies'][$module] = $module; |
|
35 | + } |
|
36 | + $module = $map[$instance]; |
|
37 | + $export['dependencies'][$module] = $module; |
|
38 | 38 | } |
39 | 39 | // If the group has not yet been exported, add it. |
40 | 40 | else { |
41 | - $split = explode('-', $instance); |
|
42 | - $type_name = $split[0]; |
|
43 | - $group_name = $split[1]; |
|
44 | - $groups = fieldgroup_groups($type_name, FALSE, TRUE); |
|
41 | + $split = explode('-', $instance); |
|
42 | + $type_name = $split[0]; |
|
43 | + $group_name = $split[1]; |
|
44 | + $groups = fieldgroup_groups($type_name, FALSE, TRUE); |
|
45 | 45 | |
46 | - if (isset($groups[$group_name]) && $group = $groups[$group_name]) { |
|
46 | + if (isset($groups[$group_name]) && $group = $groups[$group_name]) { |
|
47 | 47 | $export['features']['fieldgroup'][$instance] = $instance; |
48 | 48 | $export['dependencies']['fieldgroup'] = 'fieldgroup'; |
49 | - } |
|
49 | + } |
|
50 | + } |
|
50 | 51 | } |
51 | - } |
|
52 | 52 | |
53 | - return $pipe; |
|
53 | + return $pipe; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Implementation of hook_features_export_render(). |
58 | 58 | */ |
59 | 59 | function fieldgroup_features_export_render($module, $data) { |
60 | - $translatables = $code = array(); |
|
60 | + $translatables = $code = array(); |
|
61 | 61 | |
62 | - $code[] = ' $groups = array();'; |
|
63 | - $code[] = ''; |
|
64 | - foreach ($data as $instance) { |
|
62 | + $code[] = ' $groups = array();'; |
|
63 | + $code[] = ''; |
|
64 | + foreach ($data as $instance) { |
|
65 | 65 | $instance = explode('-', $instance); |
66 | 66 | $type_name = $instance[0]; |
67 | 67 | $group_name = $instance[1]; |
68 | 68 | $groups = fieldgroup_groups($type_name, FALSE, TRUE); |
69 | 69 | if (isset($groups[$group_name]) && $group = $groups[$group_name]) { |
70 | - // Clean up the fields to only list the names. |
|
71 | - $group['fields'] = array_keys((array) $group['fields']); |
|
70 | + // Clean up the fields to only list the names. |
|
71 | + $group['fields'] = array_keys((array) $group['fields']); |
|
72 | 72 | |
73 | - $group_identifier = features_var_export(fieldgroup_features_identifier($group)); |
|
74 | - $group_export = features_var_export($group, ' '); |
|
75 | - $code[] = " // Exported group: {$group_name}"; |
|
76 | - $code[] = " \$groups[{$group_identifier}] = {$group_export};"; |
|
77 | - $code[] = ""; |
|
73 | + $group_identifier = features_var_export(fieldgroup_features_identifier($group)); |
|
74 | + $group_export = features_var_export($group, ' '); |
|
75 | + $code[] = " // Exported group: {$group_name}"; |
|
76 | + $code[] = " \$groups[{$group_identifier}] = {$group_export};"; |
|
77 | + $code[] = ""; |
|
78 | 78 | |
79 | - // Add any labels to translatables array. |
|
80 | - if (!empty($group['label'])) { |
|
79 | + // Add any labels to translatables array. |
|
80 | + if (!empty($group['label'])) { |
|
81 | 81 | $translatables[] = $group['label']; |
82 | - } |
|
82 | + } |
|
83 | + } |
|
83 | 84 | } |
84 | - } |
|
85 | - if (!empty($translatables)) { |
|
85 | + if (!empty($translatables)) { |
|
86 | 86 | $code[] = features_translatables_export($translatables, ' '); |
87 | - } |
|
88 | - $code[] = ' return $groups;'; |
|
89 | - $code = implode("\n", $code); |
|
90 | - return array('fieldgroup_default_groups' => $code); |
|
87 | + } |
|
88 | + $code[] = ' return $groups;'; |
|
89 | + $code = implode("\n", $code); |
|
90 | + return array('fieldgroup_default_groups' => $code); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Implementation of hook_features_revert(). |
95 | 95 | */ |
96 | 96 | function fieldgroup_features_revert($module) { |
97 | - fieldgroup_features_rebuild($module); |
|
97 | + fieldgroup_features_rebuild($module); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,57 +102,57 @@ discard block |
||
102 | 102 | * Rebuilds CCK fieldgroup definitions from code defaults. |
103 | 103 | */ |
104 | 104 | function fieldgroup_features_rebuild($module) { |
105 | - if ($groups = features_get_default('fieldgroup', $module)) { |
|
105 | + if ($groups = features_get_default('fieldgroup', $module)) { |
|
106 | 106 | content_clear_type_cache(TRUE); |
107 | 107 | |
108 | 108 | foreach ($groups as $group) { |
109 | - $type_name = $group['type_name']; |
|
110 | - $group_name = $group['group_name']; |
|
111 | - $groups = fieldgroup_groups($type_name, FALSE, TRUE); |
|
109 | + $type_name = $group['type_name']; |
|
110 | + $group_name = $group['group_name']; |
|
111 | + $groups = fieldgroup_groups($type_name, FALSE, TRUE); |
|
112 | 112 | |
113 | - if (isset($groups[$group_name])) { |
|
113 | + if (isset($groups[$group_name])) { |
|
114 | 114 | $existing_group = $groups[$group_name]; |
115 | 115 | // Only field names are exported in fieldgroup_features_export_render(), so we |
116 | 116 | // update the existing group to match. |
117 | 117 | $existing_group['fields'] = array_keys($existing_group['fields']); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - // No need to rebuild if the group already exists and is identical. |
|
121 | - if ($existing_group != $group) { |
|
120 | + // No need to rebuild if the group already exists and is identical. |
|
121 | + if ($existing_group != $group) { |
|
122 | 122 | // Update each field from this group. |
123 | 123 | foreach ($group['fields'] as $field_name) { |
124 | - if ($field = content_fields($field_name, $type_name)) { |
|
124 | + if ($field = content_fields($field_name, $type_name)) { |
|
125 | 125 | $field['group'] = $group_name; |
126 | 126 | fieldgroup_update_fields($field); |
127 | - } |
|
127 | + } |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // Look in the old group for any fields that have been removed. |
131 | 131 | if ($existing_group && !empty($existing_group['fields'])) { |
132 | - foreach($existing_group['fields'] as $field_name) { |
|
132 | + foreach($existing_group['fields'] as $field_name) { |
|
133 | 133 | // We only want to update the field if the field no longer exists in the group |
134 | 134 | // and the field's existing group name matches the group currently being rebuilt. |
135 | 135 | if ( |
136 | - !in_array($field_name, $group['fields']) && |
|
136 | + !in_array($field_name, $group['fields']) && |
|
137 | 137 | _fieldgroup_field_get_group($type_name, $field_name) == $group_name && |
138 | 138 | $field = content_fields($field_name, $type_name) |
139 | 139 | ) { |
140 | - $field['group'] = ''; |
|
141 | - fieldgroup_update_fields($field); |
|
140 | + $field['group'] = ''; |
|
141 | + fieldgroup_update_fields($field); |
|
142 | + } |
|
142 | 143 | } |
143 | - } |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | fieldgroup_save_group($type_name, $group); |
147 | 147 | variable_set('menu_rebuild_needed', TRUE); |
148 | - } |
|
148 | + } |
|
149 | + } |
|
149 | 150 | } |
150 | - } |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Callback for generating an identifier for a fieldgroup. |
155 | 155 | */ |
156 | 156 | function fieldgroup_features_identifier($object) { |
157 | - return isset($object['type_name'], $object['group_name']) ? "{$object['type_name']}-{$object['group_name']}" : FALSE; |
|
157 | + return isset($object['type_name'], $object['group_name']) ? "{$object['type_name']}-{$object['group_name']}" : FALSE; |
|
158 | 158 | } |
@@ -4,143 +4,143 @@ discard block |
||
4 | 4 | * Display feature component info |
5 | 5 | */ |
6 | 6 | function template_preprocess_features_admin_components(&$vars) { |
7 | - drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
8 | - $form = $vars['form']; |
|
7 | + drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
8 | + $form = $vars['form']; |
|
9 | 9 | |
10 | - // Basic info |
|
11 | - $vars['name'] = $form['#info']['name']; |
|
12 | - $vars['description'] = isset($form['#info']['description']) ? $form['#info']['description'] : ''; |
|
10 | + // Basic info |
|
11 | + $vars['name'] = $form['#info']['name']; |
|
12 | + $vars['description'] = isset($form['#info']['description']) ? $form['#info']['description'] : ''; |
|
13 | 13 | |
14 | - // Legend/key |
|
15 | - $vars['key'] = array(); |
|
14 | + // Legend/key |
|
15 | + $vars['key'] = array(); |
|
16 | 16 | |
17 | - // Dependencies |
|
18 | - $rows = array(); |
|
19 | - $modules = features_get_info(); |
|
20 | - foreach ($form['#dependencies'] as $dependency => $status) { |
|
17 | + // Dependencies |
|
18 | + $rows = array(); |
|
19 | + $modules = features_get_info(); |
|
20 | + foreach ($form['#dependencies'] as $dependency => $status) { |
|
21 | 21 | $rows[] = array( |
22 | - array( |
|
22 | + array( |
|
23 | 23 | 'data' => isset($modules[$dependency]->info['name']) ? $modules[$dependency]->info['name'] : $dependency, |
24 | 24 | 'class' => 'component' |
25 | - ), |
|
26 | - theme('features_module_status', $status), |
|
25 | + ), |
|
26 | + theme('features_module_status', $status), |
|
27 | 27 | ); |
28 | - } |
|
29 | - $vars['dependencies'] = theme('table', array(t('Dependency'), t('Status')), $rows); |
|
30 | - |
|
31 | - // Components |
|
32 | - $rows = array(); |
|
33 | - $components = features_get_components(); |
|
34 | - $conflicts = features_get_conflicts(); |
|
35 | - if (!module_exists($form['module']['#value']) && isset($form['module']['#value']) && !empty($conflicts[$form['module']['#value']])) { |
|
28 | + } |
|
29 | + $vars['dependencies'] = theme('table', array(t('Dependency'), t('Status')), $rows); |
|
30 | + |
|
31 | + // Components |
|
32 | + $rows = array(); |
|
33 | + $components = features_get_components(); |
|
34 | + $conflicts = features_get_conflicts(); |
|
35 | + if (!module_exists($form['module']['#value']) && isset($form['module']['#value']) && !empty($conflicts[$form['module']['#value']])) { |
|
36 | 36 | $module_conflicts = $conflicts[$form['module']['#value']]; |
37 | 37 | $conflicts = array(); |
38 | 38 | foreach ($module_conflicts as $conflict) { |
39 | - $conflicts = array_merge_recursive($conflict, $conflicts); |
|
39 | + $conflicts = array_merge_recursive($conflict, $conflicts); |
|
40 | 40 | } |
41 | - } |
|
42 | - else { |
|
41 | + } |
|
42 | + else { |
|
43 | 43 | $conflicts = array(); |
44 | - } |
|
45 | - // Display key for conflicting elements. |
|
46 | - if (!empty($conflicts)) { |
|
44 | + } |
|
45 | + // Display key for conflicting elements. |
|
46 | + if (!empty($conflicts)) { |
|
47 | 47 | $vars['key'][] = array( |
48 | - 'title' => theme('features_storage_link', FEATURES_CONFLICT, t('Conflicts with another feature')), |
|
49 | - 'html' => TRUE, |
|
48 | + 'title' => theme('features_storage_link', FEATURES_CONFLICT, t('Conflicts with another feature')), |
|
49 | + 'html' => TRUE, |
|
50 | 50 | ); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - if (!empty($form['#info']['features'])) { |
|
53 | + if (!empty($form['#info']['features'])) { |
|
54 | 54 | foreach ($form['#info']['features'] as $component => $items) { |
55 | - if (!empty($items)) { |
|
55 | + if (!empty($items)) { |
|
56 | 56 | $header = $data = array(); |
57 | 57 | if (element_children($form['revert'])) { |
58 | - $header[] = array( |
|
58 | + $header[] = array( |
|
59 | 59 | 'data' => isset($form['revert'][$component]) ? drupal_render($form['revert'][$component]) : '', |
60 | 60 | 'header' => TRUE |
61 | - ); |
|
61 | + ); |
|
62 | 62 | } |
63 | 63 | $header[] = array( |
64 | - 'data' => isset($components[$component]['name']) ? $components[$component]['name'] : $component, |
|
65 | - 'header' => TRUE |
|
64 | + 'data' => isset($components[$component]['name']) ? $components[$component]['name'] : $component, |
|
65 | + 'header' => TRUE |
|
66 | 66 | ); |
67 | 67 | $header[] = array( |
68 | - 'data' => drupal_render($form['components'][$component]), |
|
69 | - 'header' => TRUE |
|
68 | + 'data' => drupal_render($form['components'][$component]), |
|
69 | + 'header' => TRUE |
|
70 | 70 | ); |
71 | 71 | $rows[] = $header; |
72 | 72 | |
73 | 73 | if (element_children($form['revert'])) { |
74 | - $data[] = ''; |
|
74 | + $data[] = ''; |
|
75 | 75 | } |
76 | 76 | $component_conflicts = isset($conflicts[$component]) ? $conflicts[$component] : array(); |
77 | 77 | $data[] = array( |
78 | - 'data' => theme('features_component_list', $items, $items, $component_conflicts), |
|
79 | - 'colspan' => 2, |
|
80 | - 'class' => 'component' |
|
78 | + 'data' => theme('features_component_list', $items, $items, $component_conflicts), |
|
79 | + 'colspan' => 2, |
|
80 | + 'class' => 'component' |
|
81 | 81 | ); |
82 | 82 | $rows[] = $data; |
83 | - } |
|
83 | + } |
|
84 | + } |
|
84 | 85 | } |
85 | - } |
|
86 | - $vars['components'] = theme('table', array(), $rows); |
|
86 | + $vars['components'] = theme('table', array(), $rows); |
|
87 | 87 | |
88 | - // Other elements |
|
89 | - $vars['buttons'] = drupal_render($form['buttons']); |
|
90 | - $vars['form'] = drupal_render($form); |
|
88 | + // Other elements |
|
89 | + $vars['buttons'] = drupal_render($form['buttons']); |
|
90 | + $vars['form'] = drupal_render($form); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Preprocessor for theme('features_form'). |
95 | 95 | */ |
96 | 96 | function template_preprocess_features_form(&$vars) { |
97 | - drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
98 | - drupal_add_js(drupal_get_path('module', 'features') .'/features.js'); |
|
99 | - |
|
100 | - $first = TRUE; |
|
101 | - $package_links = array(); |
|
102 | - $packages = element_children($vars['form']); |
|
103 | - sort($packages); |
|
104 | - foreach ($packages as $package) { |
|
97 | + drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
98 | + drupal_add_js(drupal_get_path('module', 'features') .'/features.js'); |
|
99 | + |
|
100 | + $first = TRUE; |
|
101 | + $package_links = array(); |
|
102 | + $packages = element_children($vars['form']); |
|
103 | + sort($packages); |
|
104 | + foreach ($packages as $package) { |
|
105 | 105 | if (!empty($vars['form'][$package]['status'])) { |
106 | - $package_links[$package] = array( |
|
106 | + $package_links[$package] = array( |
|
107 | 107 | 'title' => $vars['form'][$package]['#title'], |
108 | 108 | 'href' => $_GET['q'], |
109 | 109 | 'fragment' => $package, |
110 | - ); |
|
111 | - $class = $first ? "$package features-package-active" : $package; |
|
112 | - $package_links[$package]['attributes'] = $first ? array('class' => 'features-package-active') : array(); |
|
113 | - $vars['packages'][$class] = $vars['form'][$package]; |
|
110 | + ); |
|
111 | + $class = $first ? "$package features-package-active" : $package; |
|
112 | + $package_links[$package]['attributes'] = $first ? array('class' => 'features-package-active') : array(); |
|
113 | + $vars['packages'][$class] = $vars['form'][$package]; |
|
114 | 114 | |
115 | - unset($vars['form'][$package]); |
|
116 | - $first = FALSE; |
|
115 | + unset($vars['form'][$package]); |
|
116 | + $first = FALSE; |
|
117 | + } |
|
117 | 118 | } |
118 | - } |
|
119 | - $vars['package_links'] = $package_links; |
|
119 | + $vars['package_links'] = $package_links; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Themes a module status display. |
124 | 124 | */ |
125 | 125 | function theme_features_module_status($status, $module = NULL) { |
126 | - switch ($status) { |
|
126 | + switch ($status) { |
|
127 | 127 | case FEATURES_MODULE_ENABLED: |
128 | 128 | $text = !empty($module) ? $module : t('Enabled'); |
129 | - return "<span class='admin-enabled'>{$text}</span>"; |
|
129 | + return "<span class='admin-enabled'>{$text}</span>"; |
|
130 | 130 | case FEATURES_MODULE_DISABLED: |
131 | 131 | $text = !empty($module) ? $module : t('Disabled'); |
132 | - return "<span class='admin-disabled'>{$text}</span>"; |
|
132 | + return "<span class='admin-disabled'>{$text}</span>"; |
|
133 | 133 | case FEATURES_MODULE_MISSING: |
134 | 134 | $text = !empty($module) ? $module : t('Missing'); |
135 | - return "<span class='admin-missing'>{$text}</span>"; |
|
136 | - } |
|
135 | + return "<span class='admin-missing'>{$text}</span>"; |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Themes a module status display. |
141 | 141 | */ |
142 | 142 | function theme_features_storage_link($storage, $text = NULL, $path = NULL, $options = array()) { |
143 | - $classes = array( |
|
143 | + $classes = array( |
|
144 | 144 | FEATURES_OVERRIDDEN => 'admin-overridden', |
145 | 145 | FEATURES_DEFAULT => 'admin-default', |
146 | 146 | FEATURES_NEEDS_REVIEW => 'admin-needs-review', |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | FEATURES_REBUILDABLE => 'admin-rebuilding', |
149 | 149 | FEATURES_CONFLICT => 'admin-conflict', |
150 | 150 | FEATURES_DISABLED => 'admin-disabled', |
151 | - ); |
|
152 | - $default_text = array( |
|
151 | + ); |
|
152 | + $default_text = array( |
|
153 | 153 | FEATURES_OVERRIDDEN => t('Overridden'), |
154 | 154 | FEATURES_DEFAULT => t('Default'), |
155 | 155 | FEATURES_NEEDS_REVIEW => t('Needs review'), |
@@ -157,46 +157,46 @@ discard block |
||
157 | 157 | FEATURES_REBUILDABLE => t('Rebuilding'), |
158 | 158 | FEATURES_CONFLICT => t('Conflict'), |
159 | 159 | FEATURES_DISABLED => t('Disabled'), |
160 | - ); |
|
161 | - $text = isset($text) ? $text : $default_text[$storage]; |
|
162 | - if ($path) { |
|
160 | + ); |
|
161 | + $text = isset($text) ? $text : $default_text[$storage]; |
|
162 | + if ($path) { |
|
163 | 163 | $options['attributes']['class'] = $classes[$storage] . ' features-storage'; |
164 | 164 | return l($text, $path, $options); |
165 | - } |
|
166 | - else { |
|
165 | + } |
|
166 | + else { |
|
167 | 167 | return "<span class='{$classes[$storage]} features-storage'>{$text}</span>"; |
168 | - } |
|
168 | + } |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Theme function for displaying form buttons |
173 | 173 | */ |
174 | 174 | function theme_features_form_buttons($element) { |
175 | - drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
175 | + drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
176 | 176 | |
177 | - $output = drupal_render($element); |
|
178 | - return !empty($output) ? "<div class='buttons clear-block'>{$output}</div>" : ''; |
|
177 | + $output = drupal_render($element); |
|
178 | + return !empty($output) ? "<div class='buttons clear-block'>{$output}</div>" : ''; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Theme for features management form. |
183 | 183 | */ |
184 | 184 | function theme_features_form_package($form) { |
185 | - drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
186 | - drupal_add_js(drupal_get_path('module', 'features') .'/features.js'); |
|
185 | + drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
186 | + drupal_add_js(drupal_get_path('module', 'features') .'/features.js'); |
|
187 | 187 | |
188 | - $output = ''; |
|
188 | + $output = ''; |
|
189 | 189 | |
190 | - $header = array('', t('Feature'), t('Signature')); |
|
191 | - if (isset($form['state'])) { |
|
190 | + $header = array('', t('Feature'), t('Signature')); |
|
191 | + if (isset($form['state'])) { |
|
192 | 192 | $header[] = t('State'); |
193 | - } |
|
194 | - if (isset($form['actions'])) { |
|
193 | + } |
|
194 | + if (isset($form['actions'])) { |
|
195 | 195 | $header[] = t('Actions'); |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - $rows = array(); |
|
199 | - foreach (element_children($form['status']) as $element) { |
|
198 | + $rows = array(); |
|
199 | + foreach (element_children($form['status']) as $element) { |
|
200 | 200 | // Yank title & description fields off the form element for |
201 | 201 | // rendering in their own cells. |
202 | 202 | $name = "<div class='feature'>"; |
@@ -210,32 +210,32 @@ discard block |
||
210 | 210 | $class = $form['status'][$element]['#default_value'] ? 'enabled' : 'disabled'; |
211 | 211 | |
212 | 212 | $row = array( |
213 | - 'status' => array('data' => drupal_render($form['status'][$element]), 'class' => 'status'), |
|
214 | - 'name' => array('data' => $name, 'class' => 'name'), |
|
215 | - 'sign' => array('data' => drupal_render($form['sign'][$element]), 'class' => 'sign'), |
|
213 | + 'status' => array('data' => drupal_render($form['status'][$element]), 'class' => 'status'), |
|
214 | + 'name' => array('data' => $name, 'class' => 'name'), |
|
215 | + 'sign' => array('data' => drupal_render($form['sign'][$element]), 'class' => 'sign'), |
|
216 | 216 | ); |
217 | 217 | if (isset($form['state'])) { |
218 | - $row['state'] = array('data' => drupal_render($form['state'][$element]), 'class' => 'state'); |
|
218 | + $row['state'] = array('data' => drupal_render($form['state'][$element]), 'class' => 'state'); |
|
219 | 219 | } |
220 | 220 | if (isset($form['actions'])) { |
221 | - $row['actions'] = array('data' => drupal_render($form['actions'][$element]), 'class' => 'actions'); |
|
221 | + $row['actions'] = array('data' => drupal_render($form['actions'][$element]), 'class' => 'actions'); |
|
222 | 222 | } |
223 | 223 | $rows[] = array('data' => $row, 'class' => $class); |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | - if (empty($rows)) { |
|
226 | + if (empty($rows)) { |
|
227 | 227 | $rows[] = array('', array('data' => t('No features available.'), 'colspan' => count($header))); |
228 | - } |
|
228 | + } |
|
229 | 229 | |
230 | - $class = count($header) > 3 ? 'features features-admin' : 'features features-manage'; |
|
231 | - $output .= theme('table', $header, $rows, array('id' => 'features-form-table', 'class' => $class)); |
|
230 | + $class = count($header) > 3 ? 'features features-admin' : 'features features-manage'; |
|
231 | + $output .= theme('table', $header, $rows, array('id' => 'features-form-table', 'class' => $class)); |
|
232 | 232 | |
233 | - // Prevent section from being rendered by drupal_render(). |
|
234 | - unset($form['features']); |
|
233 | + // Prevent section from being rendered by drupal_render(). |
|
234 | + unset($form['features']); |
|
235 | 235 | |
236 | - $output .= drupal_render($form['buttons']); |
|
237 | - $output .= drupal_render($form); |
|
238 | - return $output; |
|
236 | + $output .= drupal_render($form['buttons']); |
|
237 | + $output .= drupal_render($form); |
|
238 | + return $output; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -246,102 +246,102 @@ discard block |
||
246 | 246 | * Export selection / display for features export form. |
247 | 247 | */ |
248 | 248 | function theme_features_form_export($form) { |
249 | - drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
250 | - drupal_add_js(drupal_get_path('module', 'features') .'/features.js'); |
|
251 | - |
|
252 | - $output = ''; |
|
253 | - $output .= "<div class='clear-block features-components'>"; |
|
254 | - $output .= "<div class='column'>". drupal_render($form['components']) . drupal_render($form['sources']) ."</div>"; |
|
255 | - $output .= "<div class='column'>". drupal_render($form['features']) ."</div>"; |
|
256 | - $output .= "</div>"; |
|
257 | - $output .= drupal_render($form); |
|
258 | - return $output; |
|
249 | + drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
250 | + drupal_add_js(drupal_get_path('module', 'features') .'/features.js'); |
|
251 | + |
|
252 | + $output = ''; |
|
253 | + $output .= "<div class='clear-block features-components'>"; |
|
254 | + $output .= "<div class='column'>". drupal_render($form['components']) . drupal_render($form['sources']) ."</div>"; |
|
255 | + $output .= "<div class='column'>". drupal_render($form['features']) ."</div>"; |
|
256 | + $output .= "</div>"; |
|
257 | + $output .= drupal_render($form); |
|
258 | + return $output; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Theme a set of features export components. |
263 | 263 | */ |
264 | 264 | function theme_features_form_components($form) { |
265 | - $output = ''; |
|
266 | - foreach (element_children($form) as $key) { |
|
265 | + $output = ''; |
|
266 | + foreach (element_children($form) as $key) { |
|
267 | 267 | unset($form[$key]['#title']); |
268 | 268 | $output .= "<div class='features-select features-select-{$key}'>". drupal_render($form[$key]) ."</div>"; |
269 | - } |
|
270 | - return $output; |
|
269 | + } |
|
270 | + return $output; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
274 | 274 | * Theme a set of features export components. |
275 | 275 | */ |
276 | 276 | function theme_features_components($info, $sources = array()) { |
277 | - $output = ''; |
|
278 | - $rows = array(); |
|
279 | - $components = features_get_components(); |
|
280 | - if (!empty($info['features']) || !empty($info['dependencies']) || !empty($sources)) { |
|
277 | + $output = ''; |
|
278 | + $rows = array(); |
|
279 | + $components = features_get_components(); |
|
280 | + if (!empty($info['features']) || !empty($info['dependencies']) || !empty($sources)) { |
|
281 | 281 | $export = array_unique(array_merge( |
282 | - array_keys($info['features']), |
|
283 | - array_keys($sources), |
|
284 | - array('dependencies') |
|
282 | + array_keys($info['features']), |
|
283 | + array_keys($sources), |
|
284 | + array('dependencies') |
|
285 | 285 | )); |
286 | 286 | foreach ($export as $component) { |
287 | - if ($component === 'dependencies') { |
|
287 | + if ($component === 'dependencies') { |
|
288 | 288 | $feature_items = isset($info[$component]) ? $info[$component] : array(); |
289 | - } |
|
290 | - else { |
|
289 | + } |
|
290 | + else { |
|
291 | 291 | $feature_items = isset($info['features'][$component]) ? $info['features'][$component] : array(); |
292 | - } |
|
293 | - $source_items = isset($sources[$component]) ? $sources[$component] : array(); |
|
294 | - if (!empty($feature_items) || !empty($source_items)) { |
|
292 | + } |
|
293 | + $source_items = isset($sources[$component]) ? $sources[$component] : array(); |
|
294 | + if (!empty($feature_items) || !empty($source_items)) { |
|
295 | 295 | $rows[] = array(array( |
296 | - 'data' => isset($components[$component]['name']) ? $components[$component]['name'] : $component, |
|
297 | - 'header' => TRUE |
|
296 | + 'data' => isset($components[$component]['name']) ? $components[$component]['name'] : $component, |
|
297 | + 'header' => TRUE |
|
298 | 298 | )); |
299 | 299 | $rows[] = array(array( |
300 | - 'data' => theme('features_component_list', $feature_items, $source_items), |
|
301 | - 'class' => 'component' |
|
300 | + 'data' => theme('features_component_list', $feature_items, $source_items), |
|
301 | + 'class' => 'component' |
|
302 | 302 | )); |
303 | - } |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | $output .= theme('table', array(), $rows); |
306 | 306 | $output .= theme('features_component_key'); |
307 | - } |
|
308 | - return $output; |
|
307 | + } |
|
308 | + return $output; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Theme individual components in a component list. |
313 | 313 | */ |
314 | 314 | function theme_features_component_list($components, $source = array(), $conflicts = array()) { |
315 | - $list = array(); |
|
316 | - foreach ($components as $component) { |
|
315 | + $list = array(); |
|
316 | + foreach ($components as $component) { |
|
317 | 317 | // If component is not in source list, it was autodetected |
318 | 318 | if (!in_array($component, $source)) { |
319 | - $list[] = "<span class='features-detected'>". check_plain($component) ."</span>"; |
|
319 | + $list[] = "<span class='features-detected'>". check_plain($component) ."</span>"; |
|
320 | 320 | } |
321 | 321 | elseif (is_array($conflicts) && in_array($component, $conflicts)) { |
322 | - $list[] = "<span class='features-conflict'>". check_plain($component) ."</span>"; |
|
322 | + $list[] = "<span class='features-conflict'>". check_plain($component) ."</span>"; |
|
323 | 323 | } |
324 | 324 | else { |
325 | - $list[] = "<span class='features-source'>". check_plain($component) ."</span>"; |
|
325 | + $list[] = "<span class='features-source'>". check_plain($component) ."</span>"; |
|
326 | 326 | } |
327 | - } |
|
328 | - foreach ($source as $component) { |
|
327 | + } |
|
328 | + foreach ($source as $component) { |
|
329 | 329 | // If a source component is no longer in the items, it was removed because |
330 | 330 | // it is provided by a dependency. |
331 | 331 | if (!in_array($component, $components)) { |
332 | - $list[] = "<span class='features-dependency'>". check_plain($component) ."</span>"; |
|
332 | + $list[] = "<span class='features-dependency'>". check_plain($component) ."</span>"; |
|
333 | + } |
|
333 | 334 | } |
334 | - } |
|
335 | - return "<span class='features-component-list'>". implode(' ', $list) ."</span>"; |
|
335 | + return "<span class='features-component-list'>". implode(' ', $list) ."</span>"; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Provide a themed key for a component list. |
340 | 340 | */ |
341 | 341 | function theme_features_component_key() { |
342 | - $list = array(); |
|
343 | - $list[] = "<span class='features-source'>" . t('Normal') . "</span>"; |
|
344 | - $list[] = "<span class='features-detected'>" . t('Auto-detected') . "</span>"; |
|
345 | - $list[] = "<span class='features-dependency'>" . t('Provided by dependency') . "</span>"; |
|
346 | - return "<span class='features-component-list features-component-key'>". implode(' ', $list) ."</span>"; |
|
342 | + $list = array(); |
|
343 | + $list[] = "<span class='features-source'>" . t('Normal') . "</span>"; |
|
344 | + $list[] = "<span class='features-detected'>" . t('Auto-detected') . "</span>"; |
|
345 | + $list[] = "<span class='features-dependency'>" . t('Provided by dependency') . "</span>"; |
|
346 | + return "<span class='features-component-list features-component-key'>". implode(' ', $list) ."</span>"; |
|
347 | 347 | } |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * Implementation of hook_menu(). |
61 | 61 | */ |
62 | 62 | function features_menu() { |
63 | - $items = array(); |
|
64 | - $items['admin/build/features'] = array( |
|
63 | + $items = array(); |
|
64 | + $items['admin/build/features'] = array( |
|
65 | 65 | 'title' => 'Features', |
66 | 66 | 'description' => 'Manage features.', |
67 | 67 | 'page callback' => 'drupal_get_form', |
68 | 68 | 'page arguments' => array('features_admin_form'), |
69 | 69 | 'type' => MENU_NORMAL_ITEM, |
70 | 70 | 'file' => 'features.admin.inc', |
71 | - ); |
|
72 | - $items['admin/build/features/cleanup'] = array( |
|
71 | + ); |
|
72 | + $items['admin/build/features/cleanup'] = array( |
|
73 | 73 | 'title' => 'Cleanup', |
74 | 74 | 'description' => 'Detect and disable any orphaned feature dependencies.', |
75 | 75 | 'page callback' => 'drupal_get_form', |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | 'type' => MENU_CALLBACK, |
78 | 78 | 'file' => 'features.admin.inc', |
79 | 79 | 'weight' => 1, |
80 | - ); |
|
81 | - $items['admin/build/features/manage'] = array( |
|
80 | + ); |
|
81 | + $items['admin/build/features/manage'] = array( |
|
82 | 82 | 'title' => 'Manage', |
83 | 83 | 'description' => 'Enable and disable features.', |
84 | 84 | 'page callback' => 'drupal_get_form', |
85 | 85 | 'page arguments' => array('features_admin_form'), |
86 | 86 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
87 | 87 | 'file' => 'features.admin.inc', |
88 | - ); |
|
89 | - $items['admin/build/features/create'] = array( |
|
88 | + ); |
|
89 | + $items['admin/build/features/create'] = array( |
|
90 | 90 | 'title' => 'Create feature', |
91 | 91 | 'description' => 'Create a new feature.', |
92 | 92 | 'page callback' => 'drupal_get_form', |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | 'type' => MENU_LOCAL_TASK, |
97 | 97 | 'file' => "features.admin.inc", |
98 | 98 | 'weight' => 10, |
99 | - ); |
|
100 | - $items['admin/build/features/export/populate'] = array( |
|
99 | + ); |
|
100 | + $items['admin/build/features/export/populate'] = array( |
|
101 | 101 | 'title' => 'Populate feature', |
102 | 102 | 'description' => 'AHAH callback to populate a feature from selected components.', |
103 | 103 | 'page callback' => 'features_export_build_form_populate', |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | 'access arguments' => array('administer features'), |
107 | 107 | 'type' => MENU_CALLBACK, |
108 | 108 | 'file' => "features.admin.inc", |
109 | - ); |
|
110 | - $items['admin/build/features/%feature'] = array( |
|
109 | + ); |
|
110 | + $items['admin/build/features/%feature'] = array( |
|
111 | 111 | 'title callback' => 'features_get_feature_title', |
112 | 112 | 'title arguments' => array(3), |
113 | 113 | 'description' => 'Display components of a feature.', |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | 'access arguments' => array('administer features'), |
118 | 118 | 'type' => MENU_CALLBACK, |
119 | 119 | 'file' => 'features.admin.inc', |
120 | - ); |
|
121 | - $items['admin/build/features/%feature/view'] = array( |
|
120 | + ); |
|
121 | + $items['admin/build/features/%feature/view'] = array( |
|
122 | 122 | 'title' => 'View', |
123 | 123 | 'description' => 'Display components of a feature.', |
124 | 124 | 'access callback' => 'user_access', |
125 | 125 | 'access arguments' => array('administer features'), |
126 | 126 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
127 | 127 | 'weight' => -10, |
128 | - ); |
|
129 | - $items['admin/build/features/%feature/recreate'] = array( |
|
128 | + ); |
|
129 | + $items['admin/build/features/%feature/recreate'] = array( |
|
130 | 130 | 'title' => 'Recreate', |
131 | 131 | 'description' => 'Recreate an existing feature.', |
132 | 132 | 'page callback' => 'drupal_get_form', |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | 'type' => MENU_LOCAL_TASK, |
137 | 137 | 'file' => "features.admin.inc", |
138 | 138 | 'weight' => 11, |
139 | - ); |
|
140 | - if (module_exists('diff')) { |
|
139 | + ); |
|
140 | + if (module_exists('diff')) { |
|
141 | 141 | $items['admin/build/features/%feature/diff'] = array( |
142 | - 'title' => 'Review overrides', |
|
143 | - 'description' => 'Compare default and current feature.', |
|
144 | - 'page callback' => 'features_feature_diff', |
|
145 | - 'page arguments' => array(3, 5), |
|
146 | - 'access callback' => 'features_access_override_actions', |
|
147 | - 'access arguments' => array(3), |
|
148 | - 'type' => MENU_LOCAL_TASK, |
|
149 | - 'file' => 'features.admin.inc', |
|
142 | + 'title' => 'Review overrides', |
|
143 | + 'description' => 'Compare default and current feature.', |
|
144 | + 'page callback' => 'features_feature_diff', |
|
145 | + 'page arguments' => array(3, 5), |
|
146 | + 'access callback' => 'features_access_override_actions', |
|
147 | + 'access arguments' => array(3), |
|
148 | + 'type' => MENU_LOCAL_TASK, |
|
149 | + 'file' => 'features.admin.inc', |
|
150 | 150 | ); |
151 | - } |
|
152 | - $items['admin/build/features/%feature/status'] = array( |
|
151 | + } |
|
152 | + $items['admin/build/features/%feature/status'] = array( |
|
153 | 153 | 'title' => 'Status', |
154 | 154 | 'description' => 'Javascript status call back.', |
155 | 155 | 'page callback' => 'features_feature_status', |
@@ -158,102 +158,102 @@ discard block |
||
158 | 158 | 'access arguments' => array('administer features'), |
159 | 159 | 'type' => MENU_CALLBACK, |
160 | 160 | 'file' => 'features.admin.inc', |
161 | - ); |
|
162 | - foreach ($items as $path => $item) { |
|
161 | + ); |
|
162 | + foreach ($items as $path => $item) { |
|
163 | 163 | if (!isset($item['access callback'])) { |
164 | - $items[$path]['access callback'] = 'user_access'; |
|
165 | - $items[$path]['access arguments'] = array('manage features'); |
|
164 | + $items[$path]['access callback'] = 'user_access'; |
|
165 | + $items[$path]['access arguments'] = array('manage features'); |
|
166 | 166 | } |
167 | - } |
|
168 | - return $items; |
|
167 | + } |
|
168 | + return $items; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Implementation of hook_theme(). |
173 | 173 | */ |
174 | 174 | function features_theme() { |
175 | - $base = array( |
|
175 | + $base = array( |
|
176 | 176 | 'path' => drupal_get_path('module', 'features') .'/theme', |
177 | 177 | 'file' => 'theme.inc', |
178 | - ); |
|
179 | - |
|
180 | - $items = array(); |
|
181 | - $items['features_components'] = |
|
182 | - $items['features_component_key'] = |
|
183 | - $items['features_component_list'] = |
|
184 | - $items['features_form_buttons'] = |
|
185 | - $items['features_form_components'] = |
|
186 | - $items['features_form_export'] = |
|
187 | - $items['features_form_package'] = |
|
188 | - $items['features_module_status'] = |
|
189 | - $items['features_storage_link'] = $base; |
|
190 | - |
|
191 | - $items['features_admin_components'] = array( |
|
178 | + ); |
|
179 | + |
|
180 | + $items = array(); |
|
181 | + $items['features_components'] = |
|
182 | + $items['features_component_key'] = |
|
183 | + $items['features_component_list'] = |
|
184 | + $items['features_form_buttons'] = |
|
185 | + $items['features_form_components'] = |
|
186 | + $items['features_form_export'] = |
|
187 | + $items['features_form_package'] = |
|
188 | + $items['features_module_status'] = |
|
189 | + $items['features_storage_link'] = $base; |
|
190 | + |
|
191 | + $items['features_admin_components'] = array( |
|
192 | 192 | 'arguments' => array('form' => NULL), |
193 | 193 | 'template' => 'features-admin-components', |
194 | - ) + $base; |
|
194 | + ) + $base; |
|
195 | 195 | |
196 | - $items['features_form'] = array( |
|
196 | + $items['features_form'] = array( |
|
197 | 197 | 'arguments' => array('form' => NULL), |
198 | 198 | 'template' => 'features-form', |
199 | - ) + $base; |
|
199 | + ) + $base; |
|
200 | 200 | |
201 | - return $items; |
|
201 | + return $items; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Implementation of hook_flush_caches(). |
206 | 206 | */ |
207 | 207 | function features_flush_caches() { |
208 | - features_rebuild(); |
|
209 | - features_get_modules(NULL, TRUE); |
|
210 | - return array(); |
|
208 | + features_rebuild(); |
|
209 | + features_get_modules(NULL, TRUE); |
|
210 | + return array(); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | 214 | * Implementation of hook_form(). |
215 | 215 | */ |
216 | 216 | function features_form($node, $form_state) { |
217 | - return node_content_form($node, $form_state); |
|
217 | + return node_content_form($node, $form_state); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Implemenation of hook_access() |
222 | 222 | */ |
223 | 223 | function features_access($op, $node, $account) { |
224 | - return node_content_access($op, $node, $account); |
|
224 | + return node_content_access($op, $node, $account); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
228 | 228 | * Implementation of hook_perm(). |
229 | 229 | */ |
230 | 230 | function features_perm() { |
231 | - $perms = array('administer features', 'manage features'); |
|
232 | - // Generate permissions for any default node types provided by features. |
|
233 | - foreach (node_get_types() as $type) { |
|
231 | + $perms = array('administer features', 'manage features'); |
|
232 | + // Generate permissions for any default node types provided by features. |
|
233 | + foreach (node_get_types() as $type) { |
|
234 | 234 | if ($type->module == 'features') { |
235 | - $name = check_plain($type->type); |
|
236 | - $perms[] = 'create '. $name .' content'; |
|
237 | - $perms[] = 'delete own '. $name .' content'; |
|
238 | - $perms[] = 'delete any '. $name .' content'; |
|
239 | - $perms[] = 'edit own '. $name .' content'; |
|
240 | - $perms[] = 'edit any '. $name .' content'; |
|
241 | - } |
|
242 | - } |
|
243 | - return $perms; |
|
235 | + $name = check_plain($type->type); |
|
236 | + $perms[] = 'create '. $name .' content'; |
|
237 | + $perms[] = 'delete own '. $name .' content'; |
|
238 | + $perms[] = 'delete any '. $name .' content'; |
|
239 | + $perms[] = 'edit own '. $name .' content'; |
|
240 | + $perms[] = 'edit any '. $name .' content'; |
|
241 | + } |
|
242 | + } |
|
243 | + return $perms; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Implementation of hook_help(). |
248 | 248 | */ |
249 | 249 | function features_help($path, $arg) { |
250 | - switch ($path) { |
|
250 | + switch ($path) { |
|
251 | 251 | case 'admin/help#features': |
252 | 252 | $output = file_get_contents(drupal_get_path('module', 'features') .'/README.txt'); |
253 | - return module_exists('markdown') ? filter_xss_admin(module_invoke('markdown', 'filter', 'process', 0, -1, $output)) : '<pre>'. check_plain($output) .'</pre>'; |
|
253 | + return module_exists('markdown') ? filter_xss_admin(module_invoke('markdown', 'filter', 'process', 0, -1, $output)) : '<pre>'. check_plain($output) .'</pre>'; |
|
254 | 254 | case 'admin/build/features': |
255 | 255 | return '<p>'. t('A "Feature" is a certain type of Drupal module with contains a package of configuration that, when enabled, provides a new set of functionality for your Drupal site. Enable features by selecting the checkboxes below and clicking the Save configuration button. If the configuration of the feature has been changed its "State" will be either "overridden" or "needs review", otherwise it will be "default", indicating that the configuration has not been changed. Click on the state to see more details about the feature and its components.') .'</p>'; |
256 | - } |
|
256 | + } |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | * load includes for those provided by features. |
262 | 262 | */ |
263 | 263 | function features_include($reset = FALSE) { |
264 | - static $once; |
|
265 | - if (!isset($once) || $reset) { |
|
264 | + static $once; |
|
265 | + if (!isset($once) || $reset) { |
|
266 | 266 | $once = TRUE; |
267 | 267 | |
268 | 268 | // Check for implementing modules and make necessary inclusions. |
269 | 269 | foreach (module_implements('features_api') as $module) { |
270 | - $info = module_invoke($module, 'features_api'); |
|
271 | - foreach ($info as $component) { |
|
270 | + $info = module_invoke($module, 'features_api'); |
|
271 | + foreach ($info as $component) { |
|
272 | 272 | if (isset($component['file'])) { |
273 | - require_once $component['file']; |
|
273 | + require_once $component['file']; |
|
274 | + } |
|
274 | 275 | } |
275 | - } |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | // Features provides integration on behalf of these modules. |
@@ -281,14 +281,14 @@ discard block |
||
281 | 281 | $modules = array('features', 'block', 'content', 'context', 'fieldgroup', 'filter', 'imagecache', 'menu', 'node', 'taxonomy', 'user', 'views', 'ctools'); |
282 | 282 | |
283 | 283 | foreach (array_filter($modules, 'module_exists') as $module) { |
284 | - if (!module_hook($module, 'features_api')) { |
|
284 | + if (!module_hook($module, 'features_api')) { |
|
285 | 285 | module_load_include('inc', 'features', "includes/features.$module"); |
286 | - } |
|
286 | + } |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | // Clear static cache, since we've now included new implementers. |
290 | 290 | module_implements('features_api', FALSE, TRUE); |
291 | - } |
|
291 | + } |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -296,58 +296,58 @@ discard block |
||
296 | 296 | * collecting defaults. |
297 | 297 | */ |
298 | 298 | function features_include_defaults($components = NULL, $reset = FALSE) { |
299 | - static $included = array(); |
|
300 | - static $include_components; |
|
299 | + static $included = array(); |
|
300 | + static $include_components; |
|
301 | 301 | |
302 | - // Build an array of components that require inclusion: |
|
303 | - // Views, CTools components and those using FEATURES_DEFAULTS_INCLUDED. |
|
304 | - if (!isset($include_components) || $reset) { |
|
302 | + // Build an array of components that require inclusion: |
|
303 | + // Views, CTools components and those using FEATURES_DEFAULTS_INCLUDED. |
|
304 | + if (!isset($include_components) || $reset) { |
|
305 | 305 | $include_components = features_get_components(); |
306 | 306 | foreach ($include_components as $component => $info) { |
307 | - if ($component !== 'views' && !isset($info['api']) && (!isset($info['default_file']) || $info['default_file'] !== FEATURES_DEFAULTS_INCLUDED)) { |
|
307 | + if ($component !== 'views' && !isset($info['api']) && (!isset($info['default_file']) || $info['default_file'] !== FEATURES_DEFAULTS_INCLUDED)) { |
|
308 | 308 | unset($include_components[$component]); |
309 | - } |
|
309 | + } |
|
310 | + } |
|
310 | 311 | } |
311 | - } |
|
312 | 312 | |
313 | - // If components are specified, only include for the specified components. |
|
314 | - if (isset($components)) { |
|
313 | + // If components are specified, only include for the specified components. |
|
314 | + if (isset($components)) { |
|
315 | 315 | $components = is_array($components) ? $components : array($components); |
316 | - } |
|
317 | - // Use all include components if none are explicitly specified. |
|
318 | - else { |
|
316 | + } |
|
317 | + // Use all include components if none are explicitly specified. |
|
318 | + else { |
|
319 | 319 | $components = $include_components; |
320 | - } |
|
321 | - foreach ($components as $component) { |
|
320 | + } |
|
321 | + foreach ($components as $component) { |
|
322 | 322 | if (isset($include_components[$component]) && (!isset($included[$component]) || $reset)) { |
323 | - $info = $include_components[$component]; |
|
324 | - // Inclusion of defaults for Views. |
|
325 | - if ($component === 'views') { |
|
323 | + $info = $include_components[$component]; |
|
324 | + // Inclusion of defaults for Views. |
|
325 | + if ($component === 'views') { |
|
326 | 326 | views_include('view'); |
327 | 327 | views_include_default_views(); |
328 | - } |
|
329 | - // Inclusion of defaults for CTools. |
|
330 | - else if (isset($info['api'], $info['module'], $info['current_version'])) { |
|
328 | + } |
|
329 | + // Inclusion of defaults for CTools. |
|
330 | + else if (isset($info['api'], $info['module'], $info['current_version'])) { |
|
331 | 331 | ctools_include('plugins'); |
332 | 332 | ctools_plugin_api_include($info['module'], $info['api'], $info['current_version'], $info['current_version']); |
333 | - } |
|
334 | - // Inclusion of defaults for components using FEATURES_DEFAULTS_INCLUDED. |
|
335 | - else { |
|
333 | + } |
|
334 | + // Inclusion of defaults for components using FEATURES_DEFAULTS_INCLUDED. |
|
335 | + else { |
|
336 | 336 | $features = isset($features) ? $features : features_get_features(NULL, $reset); |
337 | 337 | foreach ($features as $feature) { |
338 | - module_load_include('inc', $feature->name, "{$feature->name}.features.{$component}"); |
|
338 | + module_load_include('inc', $feature->name, "{$feature->name}.features.{$component}"); |
|
339 | 339 | } |
340 | - } |
|
341 | - $included[$component] = TRUE; |
|
340 | + } |
|
341 | + $included[$component] = TRUE; |
|
342 | + } |
|
342 | 343 | } |
343 | - } |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * Feature object loader. |
348 | 348 | */ |
349 | 349 | function feature_load($name, $reset = FALSE) { |
350 | - return features_get_features($name, $reset); |
|
350 | + return features_get_features($name, $reset); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * module is requested info for all modules is returned. |
365 | 365 | */ |
366 | 366 | function features_get_modules($name = NULL, $reset = FALSE) { |
367 | - return features_get_info('module', $name, $reset); |
|
367 | + return features_get_info('module', $name, $reset); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -375,35 +375,35 @@ discard block |
||
375 | 375 | * @return An array of component labels keyed by the component names. |
376 | 376 | */ |
377 | 377 | function features_get_components($feature_source = FALSE, $reset = FALSE) { |
378 | - features_include(); |
|
379 | - static $components_all; |
|
380 | - static $components_source; |
|
381 | - if (!isset($components_all) || $reset) { |
|
378 | + features_include(); |
|
379 | + static $components_all; |
|
380 | + static $components_source; |
|
381 | + if (!isset($components_all) || $reset) { |
|
382 | 382 | $components_all = $components_source = array(); |
383 | 383 | foreach (module_implements('features_api') as $module) { |
384 | - $info = module_invoke($module, 'features_api'); |
|
385 | - foreach ($info as $k => $v) { |
|
384 | + $info = module_invoke($module, 'features_api'); |
|
385 | + foreach ($info as $k => $v) { |
|
386 | 386 | $components_all[$k] = $v; |
387 | 387 | if (!empty($v['feature_source'])) { |
388 | - $components_source[$k] = $v; |
|
388 | + $components_source[$k] = $v; |
|
389 | 389 | } |
390 | - } |
|
390 | + } |
|
391 | + } |
|
391 | 392 | } |
392 | - } |
|
393 | - return $feature_source ? $components_source : $components_all; |
|
393 | + return $feature_source ? $components_source : $components_all; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Invoke a component callback. |
398 | 398 | */ |
399 | 399 | function features_invoke($component, $callback) { |
400 | - $args = func_get_args(); |
|
401 | - unset($args[0], $args[1]); |
|
402 | - // Append the component name to the arguments. |
|
403 | - $args[] = $component; |
|
404 | - if ($function = features_hook($component, $callback)) { |
|
400 | + $args = func_get_args(); |
|
401 | + unset($args[0], $args[1]); |
|
402 | + // Append the component name to the arguments. |
|
403 | + $args[] = $component; |
|
404 | + if ($function = features_hook($component, $callback)) { |
|
405 | 405 | return call_user_func_array($function, $args); |
406 | - } |
|
406 | + } |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | * The function implementing the hook, or FALSE. |
414 | 414 | */ |
415 | 415 | function features_hook($component, $hook, $reset = FALSE) { |
416 | - static $info; |
|
416 | + static $info; |
|
417 | 417 | |
418 | - if (!isset($info) || $reset) { |
|
418 | + if (!isset($info) || $reset) { |
|
419 | 419 | $info = module_invoke_all('features_api'); |
420 | - } |
|
421 | - // Determine the function callback base. |
|
422 | - $base = isset($info[$component]['base']) ? $info[$component]['base'] : $component; |
|
423 | - return function_exists($base . '_' . $hook) ? $base . '_' . $hook : FALSE; |
|
420 | + } |
|
421 | + // Determine the function callback base. |
|
422 | + $base = isset($info[$component]['base']) ? $info[$component]['base'] : $component; |
|
423 | + return function_exists($base . '_' . $hook) ? $base . '_' . $hook : FALSE; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -434,30 +434,30 @@ discard block |
||
434 | 434 | * Clear the module info cache. |
435 | 435 | */ |
436 | 436 | function features_install_modules($modules) { |
437 | - module_load_include('inc', 'features', 'features.export'); |
|
438 | - $files = module_rebuild_cache(); |
|
437 | + module_load_include('inc', 'features', 'features.export'); |
|
438 | + $files = module_rebuild_cache(); |
|
439 | 439 | |
440 | - // Build maximal list of dependencies. |
|
441 | - $install = array(); |
|
442 | - foreach ($modules as $name) { |
|
440 | + // Build maximal list of dependencies. |
|
441 | + $install = array(); |
|
442 | + foreach ($modules as $name) { |
|
443 | 443 | if ($file = $files[$name]) { |
444 | - $install[] = $name; |
|
445 | - if (!empty($file->info['dependencies'])) { |
|
444 | + $install[] = $name; |
|
445 | + if (!empty($file->info['dependencies'])) { |
|
446 | 446 | $install = array_merge($install, _features_export_maximize_dependencies($file->info['dependencies'])); |
447 | - } |
|
447 | + } |
|
448 | + } |
|
448 | 449 | } |
449 | - } |
|
450 | 450 | |
451 | - // Filter out enabled modules. |
|
452 | - $enabled = array_filter($install, 'module_exists'); |
|
453 | - $install = array_diff($install, $enabled); |
|
451 | + // Filter out enabled modules. |
|
452 | + $enabled = array_filter($install, 'module_exists'); |
|
453 | + $install = array_diff($install, $enabled); |
|
454 | 454 | |
455 | - if (!empty($install)) { |
|
455 | + if (!empty($install)) { |
|
456 | 456 | // Make sure the install API is available. |
457 | 457 | $install = array_unique($install); |
458 | 458 | include_once './includes/install.inc'; |
459 | 459 | drupal_install_modules($install); |
460 | - } |
|
460 | + } |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -465,55 +465,55 @@ discard block |
||
465 | 465 | * of module info objects that are features. |
466 | 466 | */ |
467 | 467 | function features_get_features($name = NULL, $reset = FALSE) { |
468 | - return features_get_info('feature', $name, $reset); |
|
468 | + return features_get_info('feature', $name, $reset); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Helper for retrieving info from system table. |
473 | 473 | */ |
474 | 474 | function features_get_info($type = 'module', $name = NULL, $reset = FALSE) { |
475 | - static $cache; |
|
476 | - if (!isset($cache)) { |
|
475 | + static $cache; |
|
476 | + if (!isset($cache)) { |
|
477 | 477 | $cache = cache_get('features_module_info'); |
478 | - } |
|
479 | - if (empty($cache) || $reset) { |
|
478 | + } |
|
479 | + if (empty($cache) || $reset) { |
|
480 | 480 | $data = array(); |
481 | 481 | $ignored = variable_get('features_ignored_orphans', array()); |
482 | 482 | $result = db_query("SELECT filename, name, type, status, throttle, schema_version FROM {system} WHERE type = 'module' ORDER BY name ASC"); |
483 | 483 | while ($row = db_fetch_object($result)) { |
484 | - // If module is no longer enabled, remove it from the ignored orphans list. |
|
485 | - if (in_array($row->name, $ignored, TRUE) && !$row->status) { |
|
484 | + // If module is no longer enabled, remove it from the ignored orphans list. |
|
485 | + if (in_array($row->name, $ignored, TRUE) && !$row->status) { |
|
486 | 486 | $key = array_search($row->name, $ignored, TRUE); |
487 | 487 | unset($ignored[$key]); |
488 | - } |
|
488 | + } |
|
489 | 489 | |
490 | - // Parse and allow modules to alter the info file if necessary. |
|
491 | - $row->info = drupal_parse_info_file(dirname($row->filename) .'/'. $row->name .'.info'); |
|
492 | - if (!empty($row->info)) { |
|
490 | + // Parse and allow modules to alter the info file if necessary. |
|
491 | + $row->info = drupal_parse_info_file(dirname($row->filename) .'/'. $row->name .'.info'); |
|
492 | + if (!empty($row->info)) { |
|
493 | 493 | drupal_alter('system_info', $row->info, $row); |
494 | 494 | if (!empty($row->info['features'])) { |
495 | - $data['feature'][$row->name] = $row; |
|
495 | + $data['feature'][$row->name] = $row; |
|
496 | 496 | } |
497 | 497 | $data['module'][$row->name] = $row; |
498 | - } |
|
498 | + } |
|
499 | 499 | } |
500 | 500 | variable_set('features_ignored_orphans', $ignored); |
501 | 501 | cache_set("features_module_info", $data); |
502 | 502 | $cache = new stdClass(); |
503 | 503 | $cache->data = $data; |
504 | - } |
|
505 | - if (!empty($name)) { |
|
504 | + } |
|
505 | + if (!empty($name)) { |
|
506 | 506 | return !empty($cache->data[$type][$name]) ? $cache->data[$type][$name] : FALSE; |
507 | - } |
|
508 | - return !empty($cache->data[$type]) ? $cache->data[$type] : array(); |
|
507 | + } |
|
508 | + return !empty($cache->data[$type]) ? $cache->data[$type] : array(); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
512 | 512 | * Generate an array of feature dependencies that have been orphaned. |
513 | 513 | */ |
514 | 514 | function features_get_orphans($reset = FALSE) { |
515 | - static $orphans; |
|
516 | - if (!isset($orphans) || $reset) { |
|
515 | + static $orphans; |
|
516 | + if (!isset($orphans) || $reset) { |
|
517 | 517 | module_load_include('inc', 'features', 'features.export'); |
518 | 518 | $orphans = array(); |
519 | 519 | |
@@ -521,10 +521,10 @@ discard block |
||
521 | 521 | $dependencies = array('enabled' => array(), 'disabled' => array()); |
522 | 522 | $features = features_get_features(); |
523 | 523 | foreach ($features as $feature) { |
524 | - $key = module_exists($feature->name) ? 'enabled' : 'disabled'; |
|
525 | - if (!empty($feature->info['dependencies'])) { |
|
524 | + $key = module_exists($feature->name) ? 'enabled' : 'disabled'; |
|
525 | + if (!empty($feature->info['dependencies'])) { |
|
526 | 526 | $dependencies[$key] = array_merge($dependencies[$key], _features_export_maximize_dependencies($feature->info['dependencies'])); |
527 | - } |
|
527 | + } |
|
528 | 528 | } |
529 | 529 | $dependencies['enabled'] = array_unique($dependencies['enabled']); |
530 | 530 | $dependencies['disabled'] = array_unique($dependencies['disabled']); |
@@ -541,17 +541,17 @@ discard block |
||
541 | 541 | _module_build_dependencies($modules); |
542 | 542 | |
543 | 543 | foreach ($orphaned as $module) { |
544 | - if (!empty($modules[$module]->info['dependents'])) { |
|
544 | + if (!empty($modules[$module]->info['dependents'])) { |
|
545 | 545 | // Determine whether any dependents are actually enabled. |
546 | 546 | $dependents = array_intersect($modules[$module]->info['dependents'], $enabled); |
547 | 547 | if (empty($dependents)) { |
548 | - $info = features_get_modules($module); |
|
549 | - $orphans[$module] = $info; |
|
548 | + $info = features_get_modules($module); |
|
549 | + $orphans[$module] = $info; |
|
550 | 550 | } |
551 | - } |
|
551 | + } |
|
552 | + } |
|
552 | 553 | } |
553 | - } |
|
554 | - return $orphans; |
|
554 | + return $orphans; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -559,81 +559,81 @@ discard block |
||
559 | 559 | * identical components. |
560 | 560 | */ |
561 | 561 | function features_get_conflicts($reset = FALSE) { |
562 | - $conflicts = array(); |
|
563 | - $component_info = features_get_components(); |
|
564 | - $map = features_get_component_map(NULL, $reset); |
|
562 | + $conflicts = array(); |
|
563 | + $component_info = features_get_components(); |
|
564 | + $map = features_get_component_map(NULL, $reset); |
|
565 | 565 | |
566 | - foreach ($map as $type => $components) { |
|
566 | + foreach ($map as $type => $components) { |
|
567 | 567 | // Only check conflicts for components we know about. |
568 | 568 | if (isset($component_info[$type])) { |
569 | - foreach ($components as $component => $modules) { |
|
569 | + foreach ($components as $component => $modules) { |
|
570 | 570 | if (isset($component_info[$type]['duplicates']) && $component_info[$type]['duplicates'] == FEATURES_DUPLICATES_ALLOWED) { |
571 | - continue; |
|
571 | + continue; |
|
572 | 572 | } |
573 | 573 | else if (count($modules) > 1) { |
574 | - foreach ($modules as $module) { |
|
574 | + foreach ($modules as $module) { |
|
575 | 575 | if (!isset($conflicts[$module])) { |
576 | - $conflicts[$module] = array(); |
|
576 | + $conflicts[$module] = array(); |
|
577 | 577 | } |
578 | 578 | foreach ($modules as $m) { |
579 | - if ($m != $module) { |
|
579 | + if ($m != $module) { |
|
580 | 580 | $conflicts[$module][$m][$type][] = $component; |
581 | - } |
|
581 | + } |
|
582 | 582 | } |
583 | - } |
|
583 | + } |
|
584 | + } |
|
584 | 585 | } |
585 | - } |
|
586 | 586 | } |
587 | - } |
|
587 | + } |
|
588 | 588 | |
589 | - return $conflicts; |
|
589 | + return $conflicts; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
593 | 593 | * Provide a component to feature map. |
594 | 594 | */ |
595 | 595 | function features_get_component_map($key = NULL, $reset = FALSE) { |
596 | - static $map; |
|
597 | - if (!isset($map) || $reset) { |
|
596 | + static $map; |
|
597 | + if (!isset($map) || $reset) { |
|
598 | 598 | $map = array(); |
599 | 599 | $features = features_get_features(NULL, $reset); |
600 | 600 | foreach ($features as $feature) { |
601 | - foreach ($feature->info['features'] as $type => $components) { |
|
601 | + foreach ($feature->info['features'] as $type => $components) { |
|
602 | 602 | if (!isset($map[$type])) { |
603 | - $map[$type] = array(); |
|
603 | + $map[$type] = array(); |
|
604 | 604 | } |
605 | 605 | foreach ($components as $component) { |
606 | - $map[$type][$component][] = $feature->name; |
|
606 | + $map[$type][$component][] = $feature->name; |
|
607 | + } |
|
607 | 608 | } |
608 | - } |
|
609 | 609 | } |
610 | - } |
|
611 | - if (isset($key)) { |
|
610 | + } |
|
611 | + if (isset($key)) { |
|
612 | 612 | return isset($map[$key]) ? $map[$key] : array(); |
613 | - } |
|
614 | - return $map; |
|
613 | + } |
|
614 | + return $map; |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
618 | 618 | * Simple wrapper returns the status of a module. |
619 | 619 | */ |
620 | 620 | function features_get_module_status($module) { |
621 | - if (module_exists($module)) { |
|
621 | + if (module_exists($module)) { |
|
622 | 622 | return FEATURES_MODULE_ENABLED; |
623 | - } |
|
624 | - else if (features_get_modules($module)) { |
|
623 | + } |
|
624 | + else if (features_get_modules($module)) { |
|
625 | 625 | return FEATURES_MODULE_DISABLED; |
626 | - } |
|
627 | - else { |
|
626 | + } |
|
627 | + else { |
|
628 | 628 | return FEATURES_MODULE_MISSING; |
629 | - } |
|
629 | + } |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
633 | 633 | * Menu title callback. |
634 | 634 | */ |
635 | 635 | function features_get_feature_title($feature) { |
636 | - return $feature->info['name']; |
|
636 | + return $feature->info['name']; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -641,70 +641,70 @@ discard block |
||
641 | 641 | * override actions for a given feature. |
642 | 642 | */ |
643 | 643 | function features_access_override_actions($feature) { |
644 | - if (user_access('administer features')) { |
|
644 | + if (user_access('administer features')) { |
|
645 | 645 | static $access = array(); |
646 | 646 | if (!isset($access[$feature->name])) { |
647 | - // Set a value first. We may get called again from within features_detect_overrides(). |
|
648 | - $access[$feature->name] = FALSE; |
|
647 | + // Set a value first. We may get called again from within features_detect_overrides(). |
|
648 | + $access[$feature->name] = FALSE; |
|
649 | 649 | |
650 | - features_include(); |
|
651 | - module_load_include('inc', 'features', 'features.export'); |
|
652 | - $access[$feature->name] = in_array(features_get_storage($feature->name), array(FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW)) && user_access('administer features'); |
|
650 | + features_include(); |
|
651 | + module_load_include('inc', 'features', 'features.export'); |
|
652 | + $access[$feature->name] = in_array(features_get_storage($feature->name), array(FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW)) && user_access('administer features'); |
|
653 | 653 | } |
654 | 654 | return $access[$feature->name]; |
655 | - } |
|
656 | - return FALSE; |
|
655 | + } |
|
656 | + return FALSE; |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | /** |
660 | 660 | * Implementation of hook_form_alter() for system_modules form. |
661 | 661 | */ |
662 | 662 | function features_form_system_modules_alter(&$form) { |
663 | - features_rebuild(); |
|
663 | + features_rebuild(); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
667 | 667 | * Restore the specified modules to the default state. |
668 | 668 | */ |
669 | 669 | function _features_restore($op, $items = array()) { |
670 | - // Since we can't ensure that users will run update.php immediately after |
|
671 | - // updating the features codebase, we must check the schema version explicitly |
|
672 | - // to ensure that we will not blow away any overrides. |
|
673 | - module_load_install('features'); |
|
674 | - if (drupal_get_installed_schema_version('features', TRUE) < 6101) { |
|
670 | + // Since we can't ensure that users will run update.php immediately after |
|
671 | + // updating the features codebase, we must check the schema version explicitly |
|
672 | + // to ensure that we will not blow away any overrides. |
|
673 | + module_load_install('features'); |
|
674 | + if (drupal_get_installed_schema_version('features', TRUE) < 6101) { |
|
675 | 675 | return; |
676 | - } |
|
676 | + } |
|
677 | 677 | |
678 | - module_load_include('inc', 'features', 'features.export'); |
|
679 | - features_include(); |
|
678 | + module_load_include('inc', 'features', 'features.export'); |
|
679 | + features_include(); |
|
680 | 680 | |
681 | - switch ($op) { |
|
681 | + switch ($op) { |
|
682 | 682 | case 'revert': |
683 | 683 | $restore_states = array(FEATURES_OVERRIDDEN, FEATURES_REBUILDABLE, FEATURES_NEEDS_REVIEW); |
684 | - $restore_hook = 'features_revert'; |
|
685 | - $log_action = 'Revert'; |
|
686 | - break; |
|
684 | + $restore_hook = 'features_revert'; |
|
685 | + $log_action = 'Revert'; |
|
686 | + break; |
|
687 | 687 | case 'rebuild': |
688 | 688 | $restore_states = array(FEATURES_REBUILDABLE); |
689 | - $restore_hook = 'features_rebuild'; |
|
690 | - $log_action = 'Rebuild'; |
|
691 | - break; |
|
692 | - } |
|
689 | + $restore_hook = 'features_rebuild'; |
|
690 | + $log_action = 'Rebuild'; |
|
691 | + break; |
|
692 | + } |
|
693 | 693 | |
694 | - if (empty($items)) { |
|
694 | + if (empty($items)) { |
|
695 | 695 | $states = features_get_component_states(); |
696 | 696 | foreach ($states as $module_name => $components) { |
697 | - foreach ($components as $component => $state) { |
|
697 | + foreach ($components as $component => $state) { |
|
698 | 698 | if (in_array($state, $restore_states)) { |
699 | - $items[$module_name][] = $component; |
|
699 | + $items[$module_name][] = $component; |
|
700 | + } |
|
700 | 701 | } |
701 | - } |
|
702 | 702 | } |
703 | - } |
|
703 | + } |
|
704 | 704 | |
705 | - foreach ($items as $module_name => $components) { |
|
705 | + foreach ($items as $module_name => $components) { |
|
706 | 706 | foreach ($components as $component) { |
707 | - if (features_hook($component, $restore_hook)) { |
|
707 | + if (features_hook($component, $restore_hook)) { |
|
708 | 708 | // Set a semaphore to prevent other instances of the same script from running concurrently. |
709 | 709 | watchdog('features', '@actioning @module_name / @component.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name)); |
710 | 710 | features_semaphore('set', $component); |
@@ -714,23 +714,23 @@ discard block |
||
714 | 714 | features_semaphore('del', $component); |
715 | 715 | features_set_signature($module_name, $component); |
716 | 716 | watchdog('features', '@action completed for @module_name / @component.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name)); |
717 | - } |
|
717 | + } |
|
718 | + } |
|
718 | 719 | } |
719 | - } |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | /** |
723 | 723 | * Wrapper around _features_restore(). |
724 | 724 | */ |
725 | 725 | function features_revert($revert = array()) { |
726 | - return _features_restore('revert', $revert); |
|
726 | + return _features_restore('revert', $revert); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
730 | 730 | * Wrapper around _features_restore(). |
731 | 731 | */ |
732 | 732 | function features_rebuild($rebuild = array()) { |
733 | - return _features_restore('rebuild', $rebuild); |
|
733 | + return _features_restore('rebuild', $rebuild); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -741,15 +741,15 @@ discard block |
||
741 | 741 | * Represent the current state of permissions as a role name to role/perm array. |
742 | 742 | */ |
743 | 743 | function _features_get_roles() { |
744 | - $roles = array(); |
|
745 | - $result = db_query("SELECT r.rid, r.name, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid ORDER BY r.name"); |
|
746 | - while ($row = db_fetch_object($result)) { |
|
744 | + $roles = array(); |
|
745 | + $result = db_query("SELECT r.rid, r.name, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid ORDER BY r.name"); |
|
746 | + while ($row = db_fetch_object($result)) { |
|
747 | 747 | $roles[$row->name] = array( |
748 | - 'rid' => $row->rid, |
|
749 | - 'perm' => explode(', ', $row->perm), |
|
748 | + 'rid' => $row->rid, |
|
749 | + 'perm' => explode(', ', $row->perm), |
|
750 | 750 | ); |
751 | - } |
|
752 | - return $roles; |
|
751 | + } |
|
752 | + return $roles; |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -761,26 +761,26 @@ discard block |
||
761 | 761 | * The severity of the message: status, warning or error. |
762 | 762 | */ |
763 | 763 | function features_log($message, $severity = 'status') { |
764 | - if (function_exists('drush_verify_cli')) { |
|
764 | + if (function_exists('drush_verify_cli')) { |
|
765 | 765 | $message = strip_tags($message); |
766 | 766 | if ($severity == 'status') { |
767 | - $severity = 'ok'; |
|
767 | + $severity = 'ok'; |
|
768 | 768 | } |
769 | 769 | elseif ($severity == 'error') { |
770 | - drush_set_error($message); |
|
771 | - return; |
|
770 | + drush_set_error($message); |
|
771 | + return; |
|
772 | 772 | } |
773 | 773 | drush_log($message, $severity); |
774 | 774 | return; |
775 | - } |
|
776 | - drupal_set_message($message, $severity, FALSE); |
|
775 | + } |
|
776 | + drupal_set_message($message, $severity, FALSE); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
780 | 780 | * Targeted form_alter for vocabulary edit pages. |
781 | 781 | */ |
782 | 782 | function features_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) { |
783 | - module_load_include('inc', 'features', "includes/features.taxonomy"); |
|
784 | - _features_form_taxonomy_form_vocabulary_alter($form, $form_state); |
|
783 | + module_load_include('inc', 'features', "includes/features.taxonomy"); |
|
784 | + _features_form_taxonomy_form_vocabulary_alter($form, $form_state); |
|
785 | 785 | } |
786 | 786 |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | * are declared "dynamically" or are part of a family of components. |
43 | 43 | */ |
44 | 44 | function hook_features_api() { |
45 | - return array( |
|
45 | + return array( |
|
46 | 46 | 'mycomponent' => array( |
47 | - 'default_hook' => 'mycomponent_defaults', |
|
48 | - 'default_file' => FEATURES_DEFAULTS_INCLUDED, |
|
49 | - 'features_source' => TRUE, |
|
50 | - 'file' => drupal_get_path('module', 'mycomponent') .'/mycomponent.features.inc', |
|
47 | + 'default_hook' => 'mycomponent_defaults', |
|
48 | + 'default_file' => FEATURES_DEFAULTS_INCLUDED, |
|
49 | + 'features_source' => TRUE, |
|
50 | + 'file' => drupal_get_path('module', 'mycomponent') .'/mycomponent.features.inc', |
|
51 | 51 | ), |
52 | - ); |
|
52 | + ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * The pipe array of further processors that should be called. |
102 | 102 | */ |
103 | 103 | function hook_features_export($data, &$export, $module_name) { |
104 | - // The following is the simplest implementation of a straight object export |
|
105 | - // with no further export processors called. |
|
106 | - foreach ($data as $component) { |
|
104 | + // The following is the simplest implementation of a straight object export |
|
105 | + // with no further export processors called. |
|
106 | + foreach ($data as $component) { |
|
107 | 107 | $export['mycomponent'][$component] = $component; |
108 | - } |
|
109 | - return array(); |
|
108 | + } |
|
109 | + return array(); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | * checkboxes element. |
122 | 122 | */ |
123 | 123 | function hook_features_export_options() { |
124 | - $options = array(); |
|
125 | - foreach (mycomponent_load() as $mycomponent) { |
|
124 | + $options = array(); |
|
125 | + foreach (mycomponent_load() as $mycomponent) { |
|
126 | 126 | $options[$mycomponent->name] = $mycomponent->title; |
127 | - } |
|
128 | - return $options; |
|
127 | + } |
|
128 | + return $options; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | * of the module, e.g. the key for `hook_example` should simply be `example`. |
150 | 150 | */ |
151 | 151 | function hook_features_export_render($module_name, $data, $export = NULL) { |
152 | - $code = array(); |
|
153 | - $code[] = '$mycomponents = array();'; |
|
154 | - foreach ($data as $name) { |
|
152 | + $code = array(); |
|
153 | + $code[] = '$mycomponents = array();'; |
|
154 | + foreach ($data as $name) { |
|
155 | 155 | $code[] = " \$mycomponents['{$name}'] = " . features_var_export(mycomponent_load($name)) .";"; |
156 | - } |
|
157 | - $code[] = "return \$mycomponents;"; |
|
158 | - $code = implode("\n", $mycomponents); |
|
159 | - return array('mycomponent_defaults' => $code); |
|
156 | + } |
|
157 | + $code[] = "return \$mycomponents;"; |
|
158 | + $code = implode("\n", $mycomponents); |
|
159 | + return array('mycomponent_defaults' => $code); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | * TRUE or FALSE for whether the components were successfully reverted. |
173 | 173 | */ |
174 | 174 | function hook_features_revert($module_name) { |
175 | - $mycomponents = module_invoke_all($module_name, 'mycomponent_defaults'); |
|
176 | - if (!empty($$mycomponents)) { |
|
175 | + $mycomponents = module_invoke_all($module_name, 'mycomponent_defaults'); |
|
176 | + if (!empty($$mycomponents)) { |
|
177 | 177 | foreach ($mycomponents as $mycomponent) { |
178 | - mycomponent_delete($mycomponent); |
|
178 | + mycomponent_delete($mycomponent); |
|
179 | + } |
|
179 | 180 | } |
180 | - } |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | * The name of the feature module whose components should be rebuilt. |
199 | 199 | */ |
200 | 200 | function hook_features_export_rebuild($module_name) { |
201 | - $mycomponents = module_invoke_all($module_name, 'mycomponent_defaults'); |
|
202 | - if (!empty($$mycomponents)) { |
|
201 | + $mycomponents = module_invoke_all($module_name, 'mycomponent_defaults'); |
|
202 | + if (!empty($$mycomponents)) { |
|
203 | 203 | foreach ($mycomponents as $mycomponent) { |
204 | - mycomponent_save($mycomponent); |
|
204 | + mycomponent_save($mycomponent); |
|
205 | + } |
|
205 | 206 | } |
206 | - } |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | * The name of the feature module to be generated. |
218 | 218 | */ |
219 | 219 | function hook_features_export_alter(&$export, $module_name) { |
220 | - // Example: do not allow the page content type to be exported, ever. |
|
221 | - if (!empty($export['features']['node']['page'])) { |
|
220 | + // Example: do not allow the page content type to be exported, ever. |
|
221 | + if (!empty($export['features']['node']['page'])) { |
|
222 | 222 | unset($export['features']['node']['page']); |
223 | - } |
|
223 | + } |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -14,76 +14,76 @@ discard block |
||
14 | 14 | * An associative array describing your command(s). |
15 | 15 | */ |
16 | 16 | function features_drush_command() { |
17 | - $items = array(); |
|
17 | + $items = array(); |
|
18 | 18 | |
19 | - $items['features-list'] = array( |
|
19 | + $items['features-list'] = array( |
|
20 | 20 | 'description' => "List all the available features for your site.", |
21 | 21 | 'drupal dependencies' => array('features'), |
22 | 22 | 'aliases' => array('fl', 'features'), |
23 | - ); |
|
24 | - $items['features-export'] = array( |
|
23 | + ); |
|
24 | + $items['features-export'] = array( |
|
25 | 25 | 'description' => "Export a feature from your site into a module.", |
26 | 26 | 'arguments' => array( |
27 | - 'feature' => 'Feature name to export.', |
|
27 | + 'feature' => 'Feature name to export.', |
|
28 | 28 | ), |
29 | 29 | 'drupal dependencies' => array('features'), |
30 | 30 | 'aliases' => array('fe'), |
31 | - ); |
|
32 | - $items['features-update'] = array( |
|
31 | + ); |
|
32 | + $items['features-update'] = array( |
|
33 | 33 | 'description' => "Update a feature module on your site.", |
34 | 34 | 'arguments' => array( |
35 | - 'feature' => 'A space delimited list of features.', |
|
35 | + 'feature' => 'A space delimited list of features.', |
|
36 | 36 | ), |
37 | 37 | 'drupal dependencies' => array('features'), |
38 | 38 | 'aliases' => array('fu'), |
39 | - ); |
|
40 | - $items['features-update-all'] = array( |
|
39 | + ); |
|
40 | + $items['features-update-all'] = array( |
|
41 | 41 | 'description' => "Update all feature modules on your site.", |
42 | 42 | 'arguments' => array( |
43 | - 'feature_exclude' => 'A space-delimited list of features to exclude from being updated.', |
|
43 | + 'feature_exclude' => 'A space-delimited list of features to exclude from being updated.', |
|
44 | 44 | ), |
45 | 45 | 'drupal dependencies' => array('features'), |
46 | 46 | 'aliases' => array('fu-all', 'fua'), |
47 | - ); |
|
48 | - $items['features-revert'] = array( |
|
47 | + ); |
|
48 | + $items['features-revert'] = array( |
|
49 | 49 | 'description' => "Revert a feature module on your site.", |
50 | 50 | 'arguments' => array( |
51 | - 'feature' => 'A space delimited list of features.', |
|
51 | + 'feature' => 'A space delimited list of features.', |
|
52 | 52 | ), |
53 | 53 | 'options' => array( |
54 | - '--force' => "Force revert even if Features assumes components' state are default.", |
|
54 | + '--force' => "Force revert even if Features assumes components' state are default.", |
|
55 | 55 | ), |
56 | 56 | 'drupal dependencies' => array('features'), |
57 | 57 | 'aliases' => array('fr'), |
58 | - ); |
|
59 | - $items['features-revert-all'] = array( |
|
58 | + ); |
|
59 | + $items['features-revert-all'] = array( |
|
60 | 60 | 'description' => "Revert all enabled feature module on your site.", |
61 | 61 | 'arguments' => array( |
62 | - 'feature_exclude' => 'A space-delimited list of features to exclude from being reverted.', |
|
62 | + 'feature_exclude' => 'A space-delimited list of features to exclude from being reverted.', |
|
63 | 63 | ), |
64 | 64 | 'options' => array( |
65 | - '--force' => "Force revert even if Features assumes components' state are default.", |
|
65 | + '--force' => "Force revert even if Features assumes components' state are default.", |
|
66 | 66 | ), |
67 | 67 | 'drupal dependencies' => array('features'), |
68 | 68 | 'aliases' => array('fr-all', 'fra'), |
69 | - ); |
|
70 | - $items['features-diff'] = array( |
|
69 | + ); |
|
70 | + $items['features-diff'] = array( |
|
71 | 71 | 'description' => "Show the difference between the default and overridden state of a feature.", |
72 | 72 | 'arguments' => array( |
73 | - 'feature' => 'The feature in question.', |
|
73 | + 'feature' => 'The feature in question.', |
|
74 | 74 | ), |
75 | 75 | 'drupal dependencies' => array('features', 'diff'), |
76 | 76 | 'aliases' => array('fd'), |
77 | - ); |
|
77 | + ); |
|
78 | 78 | |
79 | - return $items; |
|
79 | + return $items; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Implementation of hook_drush_help(). |
84 | 84 | */ |
85 | 85 | function features_drush_help($section) { |
86 | - switch ($section) { |
|
86 | + switch ($section) { |
|
87 | 87 | case 'drush:features': |
88 | 88 | return dt("List all the available features for your site."); |
89 | 89 | case 'drush:features-export': |
@@ -100,100 +100,100 @@ discard block |
||
100 | 100 | return dt("Revert a feature module on your site."); |
101 | 101 | case 'drush:features-diff': |
102 | 102 | return dt("Show a diff of a feature module."); |
103 | - } |
|
103 | + } |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get a list of all feature modules. |
108 | 108 | */ |
109 | 109 | function drush_features_list() { |
110 | - module_load_include('inc', 'features', 'features.export'); |
|
111 | - $rows = array(array(dt('Name'), dt('Feature'), dt('Status'), dt('State'))); |
|
112 | - foreach (features_get_features(NULL, TRUE) as $k => $m) { |
|
110 | + module_load_include('inc', 'features', 'features.export'); |
|
111 | + $rows = array(array(dt('Name'), dt('Feature'), dt('Status'), dt('State'))); |
|
112 | + foreach (features_get_features(NULL, TRUE) as $k => $m) { |
|
113 | 113 | switch (features_get_storage($m->name)) { |
114 | - case FEATURES_DEFAULT: |
|
114 | + case FEATURES_DEFAULT: |
|
115 | 115 | case FEATURES_REBUILDABLE: |
116 | 116 | $storage = ''; |
117 | 117 | break; |
118 | - case FEATURES_OVERRIDDEN: |
|
118 | + case FEATURES_OVERRIDDEN: |
|
119 | 119 | $storage = dt('Overridden'); |
120 | 120 | break; |
121 | - case FEATURES_NEEDS_REVIEW: |
|
121 | + case FEATURES_NEEDS_REVIEW: |
|
122 | 122 | $storage = dt('Needs review'); |
123 | 123 | break; |
124 | 124 | } |
125 | 125 | $rows[] = array( |
126 | - $m->info['name'], |
|
127 | - $m->name, |
|
128 | - $m->status ? dt('Enabled') : dt('Disabled'), |
|
129 | - $storage |
|
126 | + $m->info['name'], |
|
127 | + $m->name, |
|
128 | + $m->status ? dt('Enabled') : dt('Disabled'), |
|
129 | + $storage |
|
130 | 130 | ); |
131 | - } |
|
132 | - drush_print_table($rows, TRUE); |
|
131 | + } |
|
132 | + drush_print_table($rows, TRUE); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Create a feature module based on a list of components. |
137 | 137 | */ |
138 | 138 | function drush_features_export() { |
139 | - $args = func_get_args(); |
|
139 | + $args = func_get_args(); |
|
140 | 140 | |
141 | - if (count($args) == 1) { |
|
141 | + if (count($args) == 1) { |
|
142 | 142 | // Assume that the user intends to create a module with the same name as the |
143 | 143 | // "value" of the component. |
144 | 144 | list($source, $component) = explode(':', $args[0]); |
145 | 145 | $stub = array($source => array($component)); |
146 | 146 | _drush_features_export($stub, $component); |
147 | - } |
|
148 | - elseif (count($args) > 1) { |
|
147 | + } |
|
148 | + elseif (count($args) > 1) { |
|
149 | 149 | // Assume that the user intends to create a new module based on a list of |
150 | 150 | // components. First argument is assumed to be the name. |
151 | 151 | $name = array_shift($args); |
152 | 152 | $stub = array(); |
153 | 153 | foreach ($args as $v) { |
154 | - list($source, $component) = explode(':', $v); |
|
155 | - $stub[$source][] = $component; |
|
154 | + list($source, $component) = explode(':', $v); |
|
155 | + $stub[$source][] = $component; |
|
156 | 156 | } |
157 | 157 | _drush_features_export($stub, array(), $name); |
158 | - } |
|
159 | - else { |
|
158 | + } |
|
159 | + else { |
|
160 | 160 | $rows = array(array(dt('Available sources'))); |
161 | 161 | foreach (features_get_components(TRUE) as $component => $info) { |
162 | - if ($options = features_invoke($component, 'features_export_options')) { |
|
162 | + if ($options = features_invoke($component, 'features_export_options')) { |
|
163 | 163 | foreach ($options as $key => $value) { |
164 | - $rows[] = array($component .':'. $key); |
|
164 | + $rows[] = array($component .':'. $key); |
|
165 | + } |
|
165 | 166 | } |
166 | - } |
|
167 | 167 | } |
168 | 168 | drush_print_table($rows, TRUE); |
169 | - } |
|
169 | + } |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Update an existing feature module. |
174 | 174 | */ |
175 | 175 | function drush_features_update() { |
176 | - if ($args = func_get_args()) { |
|
176 | + if ($args = func_get_args()) { |
|
177 | 177 | foreach ($args as $module) { |
178 | - if (($feature = feature_load($module, TRUE)) && module_exists($module)) { |
|
178 | + if (($feature = feature_load($module, TRUE)) && module_exists($module)) { |
|
179 | 179 | _drush_features_export($feature->info['features'], $feature->info['dependencies'], $feature->name, dirname($feature->filename)); |
180 | - } |
|
181 | - else if ($feature) { |
|
180 | + } |
|
181 | + else if ($feature) { |
|
182 | 182 | _features_drush_set_error($module, 'FEATURES_FEATURE_NOT_ENABLED'); |
183 | - } |
|
184 | - else { |
|
183 | + } |
|
184 | + else { |
|
185 | 185 | _features_drush_set_error($module); |
186 | - } |
|
186 | + } |
|
187 | 187 | } |
188 | - } |
|
189 | - else { |
|
188 | + } |
|
189 | + else { |
|
190 | 190 | // By default just show contexts that are available. |
191 | 191 | $rows = array(array(dt('Available features'))); |
192 | 192 | foreach (features_get_features(NULL, TRUE) as $name => $info) { |
193 | - $rows[] = array($name); |
|
193 | + $rows[] = array($name); |
|
194 | 194 | } |
195 | 195 | drush_print_table($rows, TRUE); |
196 | - } |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,22 +201,22 @@ discard block |
||
201 | 201 | * exclude from being updated. |
202 | 202 | */ |
203 | 203 | function drush_features_update_all() { |
204 | - $features_to_update = array(); |
|
205 | - $features_to_exclude = func_get_args(); |
|
206 | - foreach (features_get_features() as $module) { |
|
204 | + $features_to_update = array(); |
|
205 | + $features_to_exclude = func_get_args(); |
|
206 | + foreach (features_get_features() as $module) { |
|
207 | 207 | if ($module->status && !in_array($module->name, $features_to_exclude)) { |
208 | - $features_to_update[] = $module->name; |
|
208 | + $features_to_update[] = $module->name; |
|
209 | + } |
|
209 | 210 | } |
210 | - } |
|
211 | - drush_print(dt('The following modules will be updated: !modules', array('!modules' => implode(', ', $features_to_update)))); |
|
212 | - if (drush_confirm(dt('Do you really want to continue?'))) { |
|
211 | + drush_print(dt('The following modules will be updated: !modules', array('!modules' => implode(', ', $features_to_update)))); |
|
212 | + if (drush_confirm(dt('Do you really want to continue?'))) { |
|
213 | 213 | foreach ($features_to_update as $module_name) { |
214 | - drush_invoke_process(drush_sitealias_get_record('@self'), 'features-update', array($module_name)); |
|
214 | + drush_invoke_process(drush_sitealias_get_record('@self'), 'features-update', array($module_name)); |
|
215 | 215 | } |
216 | - } |
|
217 | - else { |
|
216 | + } |
|
217 | + else { |
|
218 | 218 | drush_die('Aborting.'); |
219 | - } |
|
219 | + } |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -228,102 +228,102 @@ discard block |
||
228 | 228 | * Optional. The name for the exported module. |
229 | 229 | */ |
230 | 230 | function _drush_features_export($stub, $dependencies, $module_name = NULL, $directory = NULL) { |
231 | - $root = drush_get_option(array('r', 'root'), drush_locate_root()); |
|
232 | - if ($root) { |
|
231 | + $root = drush_get_option(array('r', 'root'), drush_locate_root()); |
|
232 | + if ($root) { |
|
233 | 233 | $directory = isset($directory) ? $directory : 'sites/all/modules/' . $module_name; |
234 | 234 | if (is_dir($directory)) { |
235 | - drush_print(dt('Module appears to already exist in !dir', array('!dir' => $directory))); |
|
236 | - if (!drush_confirm(dt('Do you really want to continue?'))) { |
|
235 | + drush_print(dt('Module appears to already exist in !dir', array('!dir' => $directory))); |
|
236 | + if (!drush_confirm(dt('Do you really want to continue?'))) { |
|
237 | 237 | drush_die('Aborting.'); |
238 | - } |
|
238 | + } |
|
239 | 239 | } |
240 | 240 | else { |
241 | - drush_op('mkdir', $directory); |
|
241 | + drush_op('mkdir', $directory); |
|
242 | 242 | } |
243 | 243 | if (is_dir($directory)) { |
244 | - drupal_flush_all_caches(); |
|
245 | - module_load_include('inc', 'features', 'features.export'); |
|
246 | - $export = features_populate($stub, $dependencies, $module_name); |
|
247 | - if (!feature_load($module_name)) { |
|
244 | + drupal_flush_all_caches(); |
|
245 | + module_load_include('inc', 'features', 'features.export'); |
|
246 | + $export = features_populate($stub, $dependencies, $module_name); |
|
247 | + if (!feature_load($module_name)) { |
|
248 | 248 | $export['name'] = $module_name; |
249 | - } |
|
250 | - $files = features_export_render($export, $module_name, TRUE); |
|
251 | - foreach ($files as $extension => $file_contents) { |
|
249 | + } |
|
250 | + $files = features_export_render($export, $module_name, TRUE); |
|
251 | + foreach ($files as $extension => $file_contents) { |
|
252 | 252 | if (!in_array($extension, array('module', 'info'))) { |
253 | - $extension .= '.inc'; |
|
253 | + $extension .= '.inc'; |
|
254 | 254 | } |
255 | 255 | drush_op('file_put_contents', "{$directory}/{$module_name}.$extension", $file_contents); |
256 | - } |
|
257 | - drush_log(dt("Created module: !module in !directory", array('!module' => $module_name, '!directory' => $directory)), 'ok'); |
|
256 | + } |
|
257 | + drush_log(dt("Created module: !module in !directory", array('!module' => $module_name, '!directory' => $directory)), 'ok'); |
|
258 | 258 | } |
259 | 259 | else { |
260 | - drush_die(dt('Couldn\'t create directory !directory', array('!directory' => $directory))); |
|
260 | + drush_die(dt('Couldn\'t create directory !directory', array('!directory' => $directory))); |
|
261 | 261 | } |
262 | - } |
|
263 | - else { |
|
262 | + } |
|
263 | + else { |
|
264 | 264 | drush_die(dt('Couldn\'t locate site root')); |
265 | - } |
|
265 | + } |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Revert a feature to it's code definition. |
270 | 270 | */ |
271 | 271 | function drush_features_revert() { |
272 | - if ($args = func_get_args()) { |
|
272 | + if ($args = func_get_args()) { |
|
273 | 273 | module_load_include('inc', 'features', 'features.export'); |
274 | 274 | features_include(); |
275 | 275 | |
276 | 276 | // Determine if revert should be forced. |
277 | 277 | $force = drush_get_option('force'); |
278 | 278 | foreach ($args as $module) { |
279 | - if (($feature = feature_load($module, TRUE)) && module_exists($module)) { |
|
279 | + if (($feature = feature_load($module, TRUE)) && module_exists($module)) { |
|
280 | 280 | |
281 | 281 | $components = array(); |
282 | 282 | // Forcefully revert all components of a feature. |
283 | 283 | if ($force) { |
284 | - foreach (array_keys($feature->info['features']) as $component) { |
|
284 | + foreach (array_keys($feature->info['features']) as $component) { |
|
285 | 285 | if (features_hook($component, 'features_revert')) { |
286 | - $components[] = $component; |
|
286 | + $components[] = $component; |
|
287 | + } |
|
287 | 288 | } |
288 | - } |
|
289 | 289 | } |
290 | 290 | // Only revert components that are detected to be Overridden/Needs review. |
291 | 291 | else { |
292 | - $states = features_get_component_states(array($feature->name), FALSE); |
|
293 | - foreach ($states[$feature->name] as $component => $state) { |
|
292 | + $states = features_get_component_states(array($feature->name), FALSE); |
|
293 | + foreach ($states[$feature->name] as $component => $state) { |
|
294 | 294 | if (in_array($state, array(FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW)) && features_hook($component, 'features_revert')) { |
295 | - $components[] = $component; |
|
295 | + $components[] = $component; |
|
296 | + } |
|
296 | 297 | } |
297 | - } |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | if (empty($components)) { |
301 | - drush_log(dt('Current state already matches defaults, aborting.'), 'ok'); |
|
301 | + drush_log(dt('Current state already matches defaults, aborting.'), 'ok'); |
|
302 | 302 | } |
303 | 303 | else { |
304 | - foreach ($components as $component) { |
|
304 | + foreach ($components as $component) { |
|
305 | 305 | if (drush_confirm(dt('Do you really want to revert !component?', array('!component' => $component)))) { |
306 | - features_revert(array($module => array($component))); |
|
307 | - drush_log(dt('Reverted !component.', array('!component' => $component)), 'ok'); |
|
306 | + features_revert(array($module => array($component))); |
|
307 | + drush_log(dt('Reverted !component.', array('!component' => $component)), 'ok'); |
|
308 | 308 | } |
309 | 309 | else { |
310 | - drush_log(dt('Skipping !component.', array('!component' => $component)), 'ok'); |
|
310 | + drush_log(dt('Skipping !component.', array('!component' => $component)), 'ok'); |
|
311 | + } |
|
311 | 312 | } |
312 | - } |
|
313 | 313 | } |
314 | - } |
|
315 | - else if ($feature) { |
|
314 | + } |
|
315 | + else if ($feature) { |
|
316 | 316 | _features_drush_set_error($module, 'FEATURES_FEATURE_NOT_ENABLED'); |
317 | - } |
|
318 | - else { |
|
317 | + } |
|
318 | + else { |
|
319 | 319 | _features_drush_set_error($module); |
320 | - } |
|
320 | + } |
|
321 | 321 | } |
322 | - } |
|
323 | - else { |
|
322 | + } |
|
323 | + else { |
|
324 | 324 | drush_features_list(); |
325 | 325 | return; |
326 | - } |
|
326 | + } |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -331,95 +331,95 @@ discard block |
||
331 | 331 | * a list of features to exclude from being reverted. |
332 | 332 | */ |
333 | 333 | function drush_features_revert_all() { |
334 | - $features_to_revert = array(); |
|
335 | - $features_to_exclude = func_get_args(); |
|
336 | - $force = drush_get_option('force'); |
|
337 | - foreach (features_get_features() as $module) { |
|
334 | + $features_to_revert = array(); |
|
335 | + $features_to_exclude = func_get_args(); |
|
336 | + $force = drush_get_option('force'); |
|
337 | + foreach (features_get_features() as $module) { |
|
338 | 338 | if ($module->status && !in_array($module->name, $features_to_exclude)) { |
339 | - $features_to_revert[] = $module->name; |
|
339 | + $features_to_revert[] = $module->name; |
|
340 | 340 | } |
341 | - } |
|
342 | - drush_print(dt('The following modules will be reverted: !modules', array('!modules' => implode(', ', $features_to_revert)))); |
|
343 | - if (drush_confirm(dt('Do you really want to continue?'))) { |
|
341 | + } |
|
342 | + drush_print(dt('The following modules will be reverted: !modules', array('!modules' => implode(', ', $features_to_revert)))); |
|
343 | + if (drush_confirm(dt('Do you really want to continue?'))) { |
|
344 | 344 | foreach ($features_to_revert as $module_name) { |
345 | - drush_invoke_process(drush_sitealias_get_record('@self'), 'features-revert', array($module_name), array('force' => $force, '#integrate' => TRUE)); |
|
345 | + drush_invoke_process(drush_sitealias_get_record('@self'), 'features-revert', array($module_name), array('force' => $force, '#integrate' => TRUE)); |
|
346 | + } |
|
346 | 347 | } |
347 | - } |
|
348 | - else { |
|
348 | + else { |
|
349 | 349 | drush_die('Aborting.'); |
350 | - } |
|
350 | + } |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Show the diff of a feature module. |
355 | 355 | */ |
356 | 356 | function drush_features_diff() { |
357 | - if (!$args = func_get_args()) { |
|
357 | + if (!$args = func_get_args()) { |
|
358 | 358 | drush_features_list(); |
359 | 359 | return; |
360 | - } |
|
361 | - $module = $args[0]; |
|
362 | - $feature = feature_load($module); |
|
363 | - if (!module_exists($module)) { |
|
360 | + } |
|
361 | + $module = $args[0]; |
|
362 | + $feature = feature_load($module); |
|
363 | + if (!module_exists($module)) { |
|
364 | 364 | drush_log(dt('No such feature is enabled: ' . $module), 'error'); |
365 | 365 | return; |
366 | - } |
|
367 | - module_load_include('inc', 'features', 'features.export'); |
|
368 | - $overrides = features_detect_overrides($feature); |
|
369 | - if (empty($overrides)) { |
|
366 | + } |
|
367 | + module_load_include('inc', 'features', 'features.export'); |
|
368 | + $overrides = features_detect_overrides($feature); |
|
369 | + if (empty($overrides)) { |
|
370 | 370 | drush_log(dt('Feature is in its default state. No diff needed.'), 'ok'); |
371 | 371 | return; |
372 | - } |
|
373 | - module_load_include('php', 'diff', 'DiffEngine'); |
|
372 | + } |
|
373 | + module_load_include('php', 'diff', 'DiffEngine'); |
|
374 | 374 | |
375 | - if (!class_exists('DiffFormatter')) { |
|
375 | + if (!class_exists('DiffFormatter')) { |
|
376 | 376 | if (drush_confirm(dt('It seems that the Diff module is not available. Would you like to download and enable it?'))) { |
377 | - // Download it if it's not already here. |
|
378 | - $project_info = drush_get_projects(); |
|
379 | - if (empty($project_info['diff']) && !drush_invoke_process(drush_sitealias_get_record('@self'), 'dl', array('diff'), array('#integrate' => TRUE))) { |
|
377 | + // Download it if it's not already here. |
|
378 | + $project_info = drush_get_projects(); |
|
379 | + if (empty($project_info['diff']) && !drush_invoke_process(drush_sitealias_get_record('@self'), 'dl', array('diff'), array('#integrate' => TRUE))) { |
|
380 | 380 | return drush_set_error(dt('Diff module could not be downloaded.')); |
381 | - } |
|
381 | + } |
|
382 | 382 | |
383 | - if (!drush_invoke_process(drush_sitealias_get_record('@self'), 'en', array('diff'), array('#integrate' => TRUE))) { |
|
383 | + if (!drush_invoke_process(drush_sitealias_get_record('@self'), 'en', array('diff'), array('#integrate' => TRUE))) { |
|
384 | 384 | return drush_set_error(dt('Diff module could not be enabled.')); |
385 | - } |
|
385 | + } |
|
386 | 386 | } |
387 | 387 | else { |
388 | - return drush_set_error(dt('Diff module is not enabled.')); |
|
388 | + return drush_set_error(dt('Diff module is not enabled.')); |
|
389 | 389 | } |
390 | 390 | // If we're still here, now we can include the DiffEngine again. |
391 | 391 | module_load_include('php', 'diff', 'DiffEngine'); |
392 | - } |
|
392 | + } |
|
393 | 393 | |
394 | - $formatter = new DiffFormatter(); |
|
395 | - $formatter->leading_context_lines = 2; |
|
396 | - $formatter->trailing_context_lines = 2; |
|
397 | - $formatter->show_header = FALSE; |
|
394 | + $formatter = new DiffFormatter(); |
|
395 | + $formatter->leading_context_lines = 2; |
|
396 | + $formatter->trailing_context_lines = 2; |
|
397 | + $formatter->show_header = FALSE; |
|
398 | 398 | |
399 | - foreach ($overrides as $component => $items) { |
|
399 | + foreach ($overrides as $component => $items) { |
|
400 | 400 | $diff = new Diff(explode("\n", $items['default']), explode("\n", $items['normal'])); |
401 | 401 | drush_print(); |
402 | 402 | drush_print(dt("Component: !component", array('!component' => $component))); |
403 | 403 | $rows = explode("\n", $formatter->format($diff)); |
404 | 404 | if (drush_get_context('DRUSH_NOCOLOR')) { |
405 | - $red = $green = "%s"; |
|
405 | + $red = $green = "%s"; |
|
406 | 406 | } |
407 | 407 | else { |
408 | - $red = "\033[31;40m\033[1m%s\033[0m"; |
|
409 | - $green = "\033[0;32;40m\033[1m%s\033[0m"; |
|
408 | + $red = "\033[31;40m\033[1m%s\033[0m"; |
|
409 | + $green = "\033[0;32;40m\033[1m%s\033[0m"; |
|
410 | 410 | } |
411 | 411 | foreach ($rows as $row) { |
412 | - if (strpos($row, '>') === 0) { |
|
412 | + if (strpos($row, '>') === 0) { |
|
413 | 413 | drush_print(sprintf($green, $row)); |
414 | - } |
|
415 | - elseif (strpos($row, '<') === 0) { |
|
414 | + } |
|
415 | + elseif (strpos($row, '<') === 0) { |
|
416 | 416 | drush_print(sprintf($red, $row)); |
417 | - } |
|
418 | - else { |
|
417 | + } |
|
418 | + else { |
|
419 | 419 | drush_print($row); |
420 | - } |
|
420 | + } |
|
421 | + } |
|
421 | 422 | } |
422 | - } |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -433,16 +433,16 @@ discard block |
||
433 | 433 | * FALSE. See drush_set_error(). |
434 | 434 | */ |
435 | 435 | function _features_drush_set_error($feature, $error = '') { |
436 | - $args = array('!feature' => $feature); |
|
436 | + $args = array('!feature' => $feature); |
|
437 | 437 | |
438 | - switch ($error) { |
|
438 | + switch ($error) { |
|
439 | 439 | case 'FEATURES_FEATURE_NOT_ENABLED': |
440 | 440 | $message = 'The feature !feature is not enabled.'; |
441 | - break; |
|
441 | + break; |
|
442 | 442 | default: |
443 | 443 | $error = 'FEATURES_FEATURE_NOT_FOUND'; |
444 | - $message = 'The feature !feature could not be found.'; |
|
445 | - } |
|
444 | + $message = 'The feature !feature could not be found.'; |
|
445 | + } |
|
446 | 446 | |
447 | - return drush_set_error($error, dt($message, $args)); |
|
447 | + return drush_set_error($error, dt($message, $args)); |
|
448 | 448 | } |
@@ -4,29 +4,29 @@ discard block |
||
4 | 4 | * Implementation of hook_content_default_fields(). |
5 | 5 | */ |
6 | 6 | function features_test_content_default_fields() { |
7 | - $fields = array(); |
|
7 | + $fields = array(); |
|
8 | 8 | |
9 | - // Exported field: field_features_test |
|
10 | - $fields['features_test-field_features_test'] = array( |
|
9 | + // Exported field: field_features_test |
|
10 | + $fields['features_test-field_features_test'] = array( |
|
11 | 11 | 'field_name' => 'field_features_test', |
12 | 12 | 'type_name' => 'features_test', |
13 | 13 | 'display_settings' => array( |
14 | - 'label' => array( |
|
14 | + 'label' => array( |
|
15 | 15 | 'format' => 'above', |
16 | 16 | 'exclude' => 0, |
17 | - ), |
|
18 | - 'teaser' => array( |
|
17 | + ), |
|
18 | + 'teaser' => array( |
|
19 | 19 | 'format' => 'default', |
20 | 20 | 'exclude' => 0, |
21 | - ), |
|
22 | - 'full' => array( |
|
21 | + ), |
|
22 | + 'full' => array( |
|
23 | 23 | 'format' => 'default', |
24 | 24 | 'exclude' => 0, |
25 | - ), |
|
26 | - '4' => array( |
|
25 | + ), |
|
26 | + '4' => array( |
|
27 | 27 | 'format' => 'default', |
28 | 28 | 'exclude' => 0, |
29 | - ), |
|
29 | + ), |
|
30 | 30 | ), |
31 | 31 | 'widget_active' => '1', |
32 | 32 | 'type' => 'text', |
@@ -39,60 +39,60 @@ discard block |
||
39 | 39 | 'allowed_values' => '', |
40 | 40 | 'allowed_values_php' => '', |
41 | 41 | 'widget' => array( |
42 | - 'rows' => 5, |
|
43 | - 'size' => '60', |
|
44 | - 'default_value' => array( |
|
42 | + 'rows' => 5, |
|
43 | + 'size' => '60', |
|
44 | + 'default_value' => array( |
|
45 | 45 | '0' => array( |
46 | - 'value' => '', |
|
47 | - '_error_element' => 'default_value_widget][field_features_test][0][value', |
|
48 | - ), |
|
49 | - ), |
|
50 | - 'default_value_php' => NULL, |
|
51 | - 'label' => 'Test', |
|
52 | - 'weight' => '21', |
|
53 | - 'description' => '', |
|
54 | - 'type' => 'text_textfield', |
|
55 | - 'module' => 'text', |
|
46 | + 'value' => '', |
|
47 | + '_error_element' => 'default_value_widget][field_features_test][0][value', |
|
48 | + ), |
|
49 | + ), |
|
50 | + 'default_value_php' => NULL, |
|
51 | + 'label' => 'Test', |
|
52 | + 'weight' => '21', |
|
53 | + 'description' => '', |
|
54 | + 'type' => 'text_textfield', |
|
55 | + 'module' => 'text', |
|
56 | 56 | ), |
57 | - ); |
|
57 | + ); |
|
58 | 58 | |
59 | - // Exported field: field_features_test_child_a |
|
60 | - $fields['features_test-field_features_test_child_a'] = array( |
|
59 | + // Exported field: field_features_test_child_a |
|
60 | + $fields['features_test-field_features_test_child_a'] = array( |
|
61 | 61 | 'field_name' => 'field_features_test_child_a', |
62 | 62 | 'type_name' => 'features_test', |
63 | 63 | 'display_settings' => array( |
64 | - 'label' => array( |
|
64 | + 'label' => array( |
|
65 | 65 | 'format' => 'above', |
66 | 66 | 'exclude' => 0, |
67 | - ), |
|
68 | - '5' => array( |
|
67 | + ), |
|
68 | + '5' => array( |
|
69 | 69 | 'format' => 'default', |
70 | 70 | 'exclude' => 0, |
71 | - ), |
|
72 | - 'teaser' => array( |
|
71 | + ), |
|
72 | + 'teaser' => array( |
|
73 | 73 | 'format' => 'default', |
74 | 74 | 'exclude' => 0, |
75 | - ), |
|
76 | - 'full' => array( |
|
75 | + ), |
|
76 | + 'full' => array( |
|
77 | 77 | 'format' => 'default', |
78 | 78 | 'exclude' => 0, |
79 | - ), |
|
80 | - '4' => array( |
|
79 | + ), |
|
80 | + '4' => array( |
|
81 | 81 | 'format' => 'default', |
82 | 82 | 'exclude' => 0, |
83 | - ), |
|
84 | - '2' => array( |
|
83 | + ), |
|
84 | + '2' => array( |
|
85 | 85 | 'format' => 'default', |
86 | 86 | 'exclude' => 0, |
87 | - ), |
|
88 | - '3' => array( |
|
87 | + ), |
|
88 | + '3' => array( |
|
89 | 89 | 'format' => 'default', |
90 | 90 | 'exclude' => 0, |
91 | - ), |
|
92 | - 'token' => array( |
|
91 | + ), |
|
92 | + 'token' => array( |
|
93 | 93 | 'format' => 'default', |
94 | 94 | 'exclude' => 0, |
95 | - ), |
|
95 | + ), |
|
96 | 96 | ), |
97 | 97 | 'widget_active' => '1', |
98 | 98 | 'type' => 'text', |
@@ -105,60 +105,60 @@ discard block |
||
105 | 105 | 'allowed_values' => '', |
106 | 106 | 'allowed_values_php' => '', |
107 | 107 | 'widget' => array( |
108 | - 'rows' => 5, |
|
109 | - 'size' => '60', |
|
110 | - 'default_value' => array( |
|
108 | + 'rows' => 5, |
|
109 | + 'size' => '60', |
|
110 | + 'default_value' => array( |
|
111 | 111 | '0' => array( |
112 | - 'value' => '', |
|
113 | - '_error_element' => 'default_value_widget][field_features_test_child_a][0][value', |
|
114 | - ), |
|
115 | - ), |
|
116 | - 'default_value_php' => NULL, |
|
117 | - 'label' => 'Test childfield', |
|
118 | - 'weight' => '31', |
|
119 | - 'description' => '', |
|
120 | - 'type' => 'text_textfield', |
|
121 | - 'module' => 'text', |
|
112 | + 'value' => '', |
|
113 | + '_error_element' => 'default_value_widget][field_features_test_child_a][0][value', |
|
114 | + ), |
|
115 | + ), |
|
116 | + 'default_value_php' => NULL, |
|
117 | + 'label' => 'Test childfield', |
|
118 | + 'weight' => '31', |
|
119 | + 'description' => '', |
|
120 | + 'type' => 'text_textfield', |
|
121 | + 'module' => 'text', |
|
122 | 122 | ), |
123 | - ); |
|
123 | + ); |
|
124 | 124 | |
125 | - // Exported field: field_features_test_child_b |
|
126 | - $fields['features_test-field_features_test_child_b'] = array( |
|
125 | + // Exported field: field_features_test_child_b |
|
126 | + $fields['features_test-field_features_test_child_b'] = array( |
|
127 | 127 | 'field_name' => 'field_features_test_child_b', |
128 | 128 | 'type_name' => 'features_test', |
129 | 129 | 'display_settings' => array( |
130 | - 'label' => array( |
|
130 | + 'label' => array( |
|
131 | 131 | 'format' => 'above', |
132 | 132 | 'exclude' => 0, |
133 | - ), |
|
134 | - '5' => array( |
|
133 | + ), |
|
134 | + '5' => array( |
|
135 | 135 | 'format' => 'default', |
136 | 136 | 'exclude' => 0, |
137 | - ), |
|
138 | - 'teaser' => array( |
|
137 | + ), |
|
138 | + 'teaser' => array( |
|
139 | 139 | 'format' => 'default', |
140 | 140 | 'exclude' => 0, |
141 | - ), |
|
142 | - 'full' => array( |
|
141 | + ), |
|
142 | + 'full' => array( |
|
143 | 143 | 'format' => 'default', |
144 | 144 | 'exclude' => 0, |
145 | - ), |
|
146 | - '4' => array( |
|
145 | + ), |
|
146 | + '4' => array( |
|
147 | 147 | 'format' => 'default', |
148 | 148 | 'exclude' => 0, |
149 | - ), |
|
150 | - '2' => array( |
|
149 | + ), |
|
150 | + '2' => array( |
|
151 | 151 | 'format' => 'default', |
152 | 152 | 'exclude' => 0, |
153 | - ), |
|
154 | - '3' => array( |
|
153 | + ), |
|
154 | + '3' => array( |
|
155 | 155 | 'format' => 'default', |
156 | 156 | 'exclude' => 0, |
157 | - ), |
|
158 | - 'token' => array( |
|
157 | + ), |
|
158 | + 'token' => array( |
|
159 | 159 | 'format' => 'default', |
160 | 160 | 'exclude' => 0, |
161 | - ), |
|
161 | + ), |
|
162 | 162 | ), |
163 | 163 | 'widget_active' => '1', |
164 | 164 | 'type' => 'text', |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | 'allowed_values' => '', |
172 | 172 | 'allowed_values_php' => '', |
173 | 173 | 'widget' => array( |
174 | - 'rows' => 5, |
|
175 | - 'size' => '60', |
|
176 | - 'default_value' => array( |
|
174 | + 'rows' => 5, |
|
175 | + 'size' => '60', |
|
176 | + 'default_value' => array( |
|
177 | 177 | '0' => array( |
178 | - 'value' => '', |
|
179 | - '_error_element' => 'default_value_widget][field_features_test_child_b][0][value', |
|
180 | - ), |
|
181 | - ), |
|
182 | - 'default_value_php' => NULL, |
|
183 | - 'label' => 'Test childfield', |
|
184 | - 'weight' => '32', |
|
185 | - 'description' => '', |
|
186 | - 'type' => 'text_textfield', |
|
187 | - 'module' => 'text', |
|
178 | + 'value' => '', |
|
179 | + '_error_element' => 'default_value_widget][field_features_test_child_b][0][value', |
|
180 | + ), |
|
181 | + ), |
|
182 | + 'default_value_php' => NULL, |
|
183 | + 'label' => 'Test childfield', |
|
184 | + 'weight' => '32', |
|
185 | + 'description' => '', |
|
186 | + 'type' => 'text_textfield', |
|
187 | + 'module' => 'text', |
|
188 | 188 | ), |
189 | - ); |
|
189 | + ); |
|
190 | 190 | |
191 | - // Translatables |
|
192 | - array( |
|
191 | + // Translatables |
|
192 | + array( |
|
193 | 193 | t('Test'), |
194 | 194 | t('Test childfield'), |
195 | - ); |
|
195 | + ); |
|
196 | 196 | |
197 | - return $fields; |
|
197 | + return $fields; |
|
198 | 198 | } |
@@ -4,51 +4,51 @@ |
||
4 | 4 | * Implementation of hook_imagecache_default_presets(). |
5 | 5 | */ |
6 | 6 | function features_test_imagecache_default_presets() { |
7 | - $items = array( |
|
7 | + $items = array( |
|
8 | 8 | 'features_test' => array( |
9 | - 'presetname' => 'features_test', |
|
10 | - 'actions' => array( |
|
9 | + 'presetname' => 'features_test', |
|
10 | + 'actions' => array( |
|
11 | 11 | '0' => array( |
12 | - 'weight' => '0', |
|
13 | - 'module' => 'imagecache', |
|
14 | - 'action' => 'imagecache_scale', |
|
15 | - 'data' => array( |
|
12 | + 'weight' => '0', |
|
13 | + 'module' => 'imagecache', |
|
14 | + 'action' => 'imagecache_scale', |
|
15 | + 'data' => array( |
|
16 | 16 | 'width' => '100%', |
17 | 17 | 'height' => '100%', |
18 | 18 | 'upscale' => 0, |
19 | - ), |
|
19 | + ), |
|
20 | + ), |
|
20 | 21 | ), |
21 | - ), |
|
22 | 22 | ), |
23 | - ); |
|
24 | - return $items; |
|
23 | + ); |
|
24 | + return $items; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Implementation of hook_node_info(). |
29 | 29 | */ |
30 | 30 | function features_test_node_info() { |
31 | - $items = array( |
|
31 | + $items = array( |
|
32 | 32 | 'features_test' => array( |
33 | - 'name' => t('Testing: Features'), |
|
34 | - 'module' => 'features', |
|
35 | - 'description' => t('Content type provided for Features tests.'), |
|
36 | - 'has_title' => '1', |
|
37 | - 'title_label' => t('Title'), |
|
38 | - 'has_body' => '1', |
|
39 | - 'body_label' => t('Body'), |
|
40 | - 'min_word_count' => '0', |
|
41 | - 'help' => '', |
|
33 | + 'name' => t('Testing: Features'), |
|
34 | + 'module' => 'features', |
|
35 | + 'description' => t('Content type provided for Features tests.'), |
|
36 | + 'has_title' => '1', |
|
37 | + 'title_label' => t('Title'), |
|
38 | + 'has_body' => '1', |
|
39 | + 'body_label' => t('Body'), |
|
40 | + 'min_word_count' => '0', |
|
41 | + 'help' => '', |
|
42 | 42 | ), |
43 | - ); |
|
44 | - return $items; |
|
43 | + ); |
|
44 | + return $items; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Implementation of hook_views_api(). |
49 | 49 | */ |
50 | 50 | function features_test_views_api() { |
51 | - return array( |
|
51 | + return array( |
|
52 | 52 | 'api' => '2', |
53 | - ); |
|
53 | + ); |
|
54 | 54 | } |
@@ -4,16 +4,16 @@ |
||
4 | 4 | * Implementation of hook_user_default_permissions(). |
5 | 5 | */ |
6 | 6 | function features_test_user_default_permissions() { |
7 | - $permissions = array(); |
|
7 | + $permissions = array(); |
|
8 | 8 | |
9 | - // Exported permission: create features_test content |
|
10 | - $permissions['create features_test content'] = array( |
|
9 | + // Exported permission: create features_test content |
|
10 | + $permissions['create features_test content'] = array( |
|
11 | 11 | 'name' => 'create features_test content', |
12 | 12 | 'roles' => array( |
13 | - '0' => 'anonymous user', |
|
14 | - '1' => 'authenticated user', |
|
13 | + '0' => 'anonymous user', |
|
14 | + '1' => 'authenticated user', |
|
15 | 15 | ), |
16 | - ); |
|
16 | + ); |
|
17 | 17 | |
18 | - return $permissions; |
|
18 | + return $permissions; |
|
19 | 19 | } |