@@ -4,29 +4,29 @@ |
||
4 | 4 | * Implementation of hook_views_default_views(). |
5 | 5 | */ |
6 | 6 | function features_test_views_default_views() { |
7 | - $views = array(); |
|
7 | + $views = array(); |
|
8 | 8 | |
9 | - // Exported view: features_test |
|
10 | - $view = new view; |
|
11 | - $view->name = 'features_test'; |
|
12 | - $view->description = 'Test view provided by Features testing module.'; |
|
13 | - $view->tag = 'testing'; |
|
14 | - $view->view_php = ''; |
|
15 | - $view->base_table = 'node'; |
|
16 | - $view->is_cacheable = FALSE; |
|
17 | - $view->api_version = 2; |
|
18 | - $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ |
|
19 | - $handler = $view->new_display('default', 'Defaults', 'default'); |
|
20 | - $handler->override_option('access', array( |
|
9 | + // Exported view: features_test |
|
10 | + $view = new view; |
|
11 | + $view->name = 'features_test'; |
|
12 | + $view->description = 'Test view provided by Features testing module.'; |
|
13 | + $view->tag = 'testing'; |
|
14 | + $view->view_php = ''; |
|
15 | + $view->base_table = 'node'; |
|
16 | + $view->is_cacheable = FALSE; |
|
17 | + $view->api_version = 2; |
|
18 | + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ |
|
19 | + $handler = $view->new_display('default', 'Defaults', 'default'); |
|
20 | + $handler->override_option('access', array( |
|
21 | 21 | 'type' => 'none', |
22 | - )); |
|
23 | - $handler->override_option('cache', array( |
|
22 | + )); |
|
23 | + $handler->override_option('cache', array( |
|
24 | 24 | 'type' => 'none', |
25 | - )); |
|
26 | - $handler->override_option('title', 'Test'); |
|
27 | - $handler->override_option('row_plugin', 'node'); |
|
25 | + )); |
|
26 | + $handler->override_option('title', 'Test'); |
|
27 | + $handler->override_option('row_plugin', 'node'); |
|
28 | 28 | |
29 | - $views[$view->name] = $view; |
|
29 | + $views[$view->name] = $view; |
|
30 | 30 | |
31 | - return $views; |
|
31 | + return $views; |
|
32 | 32 | } |
@@ -4,63 +4,63 @@ |
||
4 | 4 | * Implementation of hook_fieldgroup_default_groups(). |
5 | 5 | */ |
6 | 6 | function features_test_fieldgroup_default_groups() { |
7 | - $groups = array(); |
|
7 | + $groups = array(); |
|
8 | 8 | |
9 | - // Exported group: group_features_test |
|
10 | - $groups['features_test-group_features_test'] = array( |
|
9 | + // Exported group: group_features_test |
|
10 | + $groups['features_test-group_features_test'] = array( |
|
11 | 11 | 'group_type' => 'standard', |
12 | 12 | 'type_name' => 'features_test', |
13 | 13 | 'group_name' => 'group_features_test', |
14 | 14 | 'label' => 'Test fieldgroup', |
15 | 15 | 'settings' => array( |
16 | - 'form' => array( |
|
16 | + 'form' => array( |
|
17 | 17 | 'style' => 'fieldset', |
18 | 18 | 'description' => '', |
19 | - ), |
|
20 | - 'display' => array( |
|
19 | + ), |
|
20 | + 'display' => array( |
|
21 | 21 | 'description' => '', |
22 | 22 | 'label' => 'above', |
23 | 23 | '5' => array( |
24 | - 'format' => 'fieldset', |
|
25 | - 'exclude' => 0, |
|
24 | + 'format' => 'fieldset', |
|
25 | + 'exclude' => 0, |
|
26 | 26 | ), |
27 | 27 | 'teaser' => array( |
28 | - 'format' => 'fieldset', |
|
29 | - 'exclude' => 0, |
|
28 | + 'format' => 'fieldset', |
|
29 | + 'exclude' => 0, |
|
30 | 30 | ), |
31 | 31 | 'full' => array( |
32 | - 'format' => 'fieldset', |
|
33 | - 'exclude' => 0, |
|
32 | + 'format' => 'fieldset', |
|
33 | + 'exclude' => 0, |
|
34 | 34 | ), |
35 | 35 | '4' => array( |
36 | - 'format' => 'fieldset', |
|
37 | - 'exclude' => 0, |
|
36 | + 'format' => 'fieldset', |
|
37 | + 'exclude' => 0, |
|
38 | 38 | ), |
39 | 39 | '2' => array( |
40 | - 'format' => 'fieldset', |
|
41 | - 'exclude' => 0, |
|
40 | + 'format' => 'fieldset', |
|
41 | + 'exclude' => 0, |
|
42 | 42 | ), |
43 | 43 | '3' => array( |
44 | - 'format' => 'fieldset', |
|
45 | - 'exclude' => 0, |
|
44 | + 'format' => 'fieldset', |
|
45 | + 'exclude' => 0, |
|
46 | 46 | ), |
47 | 47 | 'token' => array( |
48 | - 'format' => 'fieldset', |
|
49 | - 'exclude' => 0, |
|
48 | + 'format' => 'fieldset', |
|
49 | + 'exclude' => 0, |
|
50 | + ), |
|
50 | 51 | ), |
51 | - ), |
|
52 | 52 | ), |
53 | 53 | 'weight' => '35', |
54 | 54 | 'fields' => array( |
55 | - '0' => 'field_features_test_child_a', |
|
56 | - '1' => 'field_features_test_child_b', |
|
55 | + '0' => 'field_features_test_child_a', |
|
56 | + '1' => 'field_features_test_child_b', |
|
57 | 57 | ), |
58 | - ); |
|
58 | + ); |
|
59 | 59 | |
60 | - // Translatables |
|
61 | - array( |
|
60 | + // Translatables |
|
61 | + array( |
|
62 | 62 | t('Test fieldgroup'), |
63 | - ); |
|
63 | + ); |
|
64 | 64 | |
65 | - return $groups; |
|
65 | + return $groups; |
|
66 | 66 | } |
@@ -6,25 +6,25 @@ discard block |
||
6 | 6 | * @return |
7 | 7 | */ |
8 | 8 | function features_populate($items, $dependencies, $module_name) { |
9 | - // Sanitize items. |
|
10 | - $items = array_filter($items); |
|
11 | - $items['dependencies'] = drupal_map_assoc(array_filter($dependencies)); |
|
9 | + // Sanitize items. |
|
10 | + $items = array_filter($items); |
|
11 | + $items['dependencies'] = drupal_map_assoc(array_filter($dependencies)); |
|
12 | 12 | |
13 | - // Populate stub |
|
14 | - $stub = array('features' => array(), 'dependencies' => array(), 'conflicts' => array()); |
|
15 | - $export = _features_populate($items, $stub, $module_name); |
|
13 | + // Populate stub |
|
14 | + $stub = array('features' => array(), 'dependencies' => array(), 'conflicts' => array()); |
|
15 | + $export = _features_populate($items, $stub, $module_name); |
|
16 | 16 | |
17 | - // Allow other modules to alter the export. |
|
18 | - drupal_alter('features_export', $export, $module_name); |
|
17 | + // Allow other modules to alter the export. |
|
18 | + drupal_alter('features_export', $export, $module_name); |
|
19 | 19 | |
20 | - // Clean up and standardize order |
|
21 | - foreach (array_keys($export['features']) as $k) { |
|
20 | + // Clean up and standardize order |
|
21 | + foreach (array_keys($export['features']) as $k) { |
|
22 | 22 | ksort($export['features'][$k]); |
23 | - } |
|
24 | - ksort($export['features']); |
|
25 | - ksort($export['dependencies']); |
|
23 | + } |
|
24 | + ksort($export['features']); |
|
25 | + ksort($export['dependencies']); |
|
26 | 26 | |
27 | - return $export; |
|
27 | + return $export; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -41,39 +41,39 @@ discard block |
||
41 | 41 | * @return fully populated $export array. |
42 | 42 | */ |
43 | 43 | function _features_populate($pipe, &$export, $module_name = '') { |
44 | - features_include(); |
|
45 | - foreach ($pipe as $component => $data) { |
|
44 | + features_include(); |
|
45 | + foreach ($pipe as $component => $data) { |
|
46 | 46 | // Convert already defined items to dependencies. |
47 | 47 | _features_resolve_dependencies($data, $export, $module_name, $component); |
48 | 48 | if (!empty($data) && $function = features_hook($component, 'features_export')) { |
49 | - // Pass module-specific data and export array. |
|
50 | - // We don't use features_invoke() here since we need to pass $export by reference. |
|
51 | - $more = $function($data, $export, $module_name, $component); |
|
52 | - // Allow other modules to manipulate the pipe to add in additional modules. |
|
53 | - drupal_alter('features_pipe_' . $component, $more, $data, $export); |
|
54 | - // Allow for export functions to request additional exports. |
|
55 | - if (!empty($more)) { |
|
49 | + // Pass module-specific data and export array. |
|
50 | + // We don't use features_invoke() here since we need to pass $export by reference. |
|
51 | + $more = $function($data, $export, $module_name, $component); |
|
52 | + // Allow other modules to manipulate the pipe to add in additional modules. |
|
53 | + drupal_alter('features_pipe_' . $component, $more, $data, $export); |
|
54 | + // Allow for export functions to request additional exports. |
|
55 | + if (!empty($more)) { |
|
56 | 56 | _features_populate($more, $export, $module_name); |
57 | - } |
|
57 | + } |
|
58 | + } |
|
58 | 59 | } |
59 | - } |
|
60 | - return $export; |
|
60 | + return $export; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Iterates over data and convert to dependencies if already defined elsewhere. |
65 | 65 | */ |
66 | 66 | function _features_resolve_dependencies(&$data, &$export, $module_name, $component) { |
67 | - if ($map = features_get_default_map($component)) { |
|
67 | + if ($map = features_get_default_map($component)) { |
|
68 | 68 | foreach ($data as $key => $item) { |
69 | - // If the node type is provided by a different module, add the provider as |
|
70 | - // a dependency. |
|
71 | - if (isset($map[$item]) && $map[$item] != $module_name) { |
|
69 | + // If the node type is provided by a different module, add the provider as |
|
70 | + // a dependency. |
|
71 | + if (isset($map[$item]) && $map[$item] != $module_name) { |
|
72 | 72 | $export['dependencies'][$map[$item]] = $map[$item]; |
73 | 73 | unset($data[$key]); |
74 | - } |
|
74 | + } |
|
75 | + } |
|
75 | 76 | } |
76 | - } |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,115 +81,115 @@ discard block |
||
81 | 81 | * captured by other modules 'higher up'. |
82 | 82 | */ |
83 | 83 | function _features_export_minimize_dependencies($dependencies, $module_name = '') { |
84 | - // Ensure that the module doesn't depend upon itself |
|
85 | - if (!empty($module_name) && !empty($dependencies[$module_name])) { |
|
84 | + // Ensure that the module doesn't depend upon itself |
|
85 | + if (!empty($module_name) && !empty($dependencies[$module_name])) { |
|
86 | 86 | unset($dependencies[$module_name]); |
87 | - } |
|
88 | - |
|
89 | - // Do some cleanup: |
|
90 | - // - Remove modules required by Drupal core. |
|
91 | - // - Protect against direct circular dependencies. |
|
92 | - // - Remove "intermediate" dependencies. |
|
93 | - $required = drupal_required_modules(); |
|
94 | - foreach ($dependencies as $k => $v) { |
|
87 | + } |
|
88 | + |
|
89 | + // Do some cleanup: |
|
90 | + // - Remove modules required by Drupal core. |
|
91 | + // - Protect against direct circular dependencies. |
|
92 | + // - Remove "intermediate" dependencies. |
|
93 | + $required = drupal_required_modules(); |
|
94 | + foreach ($dependencies as $k => $v) { |
|
95 | 95 | if (empty($v) || in_array($v, $required)) { |
96 | - unset($dependencies[$k]); |
|
96 | + unset($dependencies[$k]); |
|
97 | 97 | } |
98 | 98 | else { |
99 | - $module = features_get_modules($v); |
|
100 | - if ($module && !empty($module->info['dependencies'])) { |
|
99 | + $module = features_get_modules($v); |
|
100 | + if ($module && !empty($module->info['dependencies'])) { |
|
101 | 101 | // If this dependency depends on the module itself, we have a circular dependency. |
102 | 102 | // Don't let it happen. Only you can prevent forest fires. |
103 | 103 | if (in_array($module_name, $module->info['dependencies'])) { |
104 | - unset($dependencies[$k]); |
|
104 | + unset($dependencies[$k]); |
|
105 | 105 | } |
106 | 106 | // Iterate through the dependency's dependencies and remove any dependencies |
107 | 107 | // that are captured by it. |
108 | 108 | else { |
109 | - foreach ($module->info['dependencies'] as $j => $dependency) { |
|
109 | + foreach ($module->info['dependencies'] as $j => $dependency) { |
|
110 | 110 | if (array_search($dependency, $dependencies) !== FALSE) { |
111 | - $position = array_search($dependency, $dependencies); |
|
112 | - unset($dependencies[$position]); |
|
111 | + $position = array_search($dependency, $dependencies); |
|
112 | + unset($dependencies[$position]); |
|
113 | + } |
|
113 | 114 | } |
114 | - } |
|
115 | 115 | } |
116 | - } |
|
116 | + } |
|
117 | 117 | } |
118 | - } |
|
119 | - return drupal_map_assoc(array_unique($dependencies)); |
|
118 | + } |
|
119 | + return drupal_map_assoc(array_unique($dependencies)); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Iterates over a list of dependencies and maximize the list of modules. |
124 | 124 | */ |
125 | 125 | function _features_export_maximize_dependencies($dependencies, $module_name = '', $maximized = array(), $first = TRUE) { |
126 | - foreach ($dependencies as $k => $v) { |
|
126 | + foreach ($dependencies as $k => $v) { |
|
127 | 127 | if (!in_array($v, $maximized)) { |
128 | - $maximized[] = $v; |
|
129 | - $module = features_get_modules($v); |
|
130 | - if ($module && !empty($module->info['dependencies'])) { |
|
128 | + $maximized[] = $v; |
|
129 | + $module = features_get_modules($v); |
|
130 | + if ($module && !empty($module->info['dependencies'])) { |
|
131 | 131 | $maximized = array_merge($maximized, _features_export_maximize_dependencies($module->info['dependencies'], $module_name, $maximized, FALSE)); |
132 | - } |
|
132 | + } |
|
133 | + } |
|
133 | 134 | } |
134 | - } |
|
135 | - return array_unique($maximized); |
|
135 | + return array_unique($maximized); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * Prepare a feature export array into a finalized info array. |
140 | 140 | */ |
141 | 141 | function features_export_prepare($export, $module_name, $reset = FALSE) { |
142 | - $existing = features_get_modules($module_name, $reset); |
|
142 | + $existing = features_get_modules($module_name, $reset); |
|
143 | 143 | |
144 | - // Prepare info string -- if module exists, merge into its existing info file |
|
145 | - $defaults = $existing ? $existing->info : array('core' => '6.x', 'package' => 'Features'); |
|
146 | - $export = array_merge($defaults, $export); |
|
144 | + // Prepare info string -- if module exists, merge into its existing info file |
|
145 | + $defaults = $existing ? $existing->info : array('core' => '6.x', 'package' => 'Features'); |
|
146 | + $export = array_merge($defaults, $export); |
|
147 | 147 | |
148 | - // Cleanup info array |
|
149 | - foreach ($export['features'] as $component => $data) { |
|
148 | + // Cleanup info array |
|
149 | + foreach ($export['features'] as $component => $data) { |
|
150 | 150 | $export['features'][$component] = array_keys($data); |
151 | - } |
|
152 | - if (isset($export['dependencies'])) { |
|
151 | + } |
|
152 | + if (isset($export['dependencies'])) { |
|
153 | 153 | $export['dependencies'] = array_values($export['dependencies']); |
154 | - } |
|
155 | - if (isset($export['conflicts'])) { |
|
154 | + } |
|
155 | + if (isset($export['conflicts'])) { |
|
156 | 156 | unset($export['conflicts']); |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | - // Order info array. |
|
160 | - $standard_info = array(); |
|
161 | - foreach (array('name', 'description', 'core', 'package', 'php', 'version', 'project', 'dependencies') as $item) { |
|
159 | + // Order info array. |
|
160 | + $standard_info = array(); |
|
161 | + foreach (array('name', 'description', 'core', 'package', 'php', 'version', 'project', 'dependencies') as $item) { |
|
162 | 162 | if (isset($export[$item])) { |
163 | - $standard_info[$item] = $export[$item]; |
|
163 | + $standard_info[$item] = $export[$item]; |
|
164 | + } |
|
164 | 165 | } |
165 | - } |
|
166 | 166 | |
167 | - $export = array_diff_assoc($export, $standard_info); |
|
168 | - ksort($export); |
|
169 | - return array_merge($standard_info, $export); |
|
167 | + $export = array_diff_assoc($export, $standard_info); |
|
168 | + ksort($export); |
|
169 | + return array_merge($standard_info, $export); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Generate an array of hooks and their raw code. |
174 | 174 | */ |
175 | 175 | function features_export_render_hooks($export, $module_name, $reset = FALSE) { |
176 | - features_include(); |
|
177 | - $code = array(); |
|
176 | + features_include(); |
|
177 | + $code = array(); |
|
178 | 178 | |
179 | - // Sort components to keep exported code consistent |
|
180 | - ksort($export['features']); |
|
179 | + // Sort components to keep exported code consistent |
|
180 | + ksort($export['features']); |
|
181 | 181 | |
182 | - foreach ($export['features'] as $component => $data) { |
|
182 | + foreach ($export['features'] as $component => $data) { |
|
183 | 183 | if (!empty($data)) { |
184 | - // Sort the items so that we don't generate different exports based on order |
|
185 | - asort($data); |
|
186 | - if (features_hook($component, 'features_export_render')) { |
|
184 | + // Sort the items so that we don't generate different exports based on order |
|
185 | + asort($data); |
|
186 | + if (features_hook($component, 'features_export_render')) { |
|
187 | 187 | $hooks = features_invoke($component, 'features_export_render', $module_name, $data, $export); |
188 | 188 | $code[$component] = $hooks; |
189 | - } |
|
189 | + } |
|
190 | 190 | } |
191 | - } |
|
192 | - return $code; |
|
191 | + } |
|
192 | + return $code; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -206,90 +206,90 @@ discard block |
||
206 | 206 | * @return array of info file and module file contents. |
207 | 207 | */ |
208 | 208 | function features_export_render($export, $module_name, $reset = FALSE) { |
209 | - $code = array(); |
|
209 | + $code = array(); |
|
210 | 210 | |
211 | - // Generate hook code |
|
212 | - $component_hooks = features_export_render_hooks($export, $module_name, $reset); |
|
213 | - $components = features_get_components(); |
|
211 | + // Generate hook code |
|
212 | + $component_hooks = features_export_render_hooks($export, $module_name, $reset); |
|
213 | + $components = features_get_components(); |
|
214 | 214 | |
215 | - // Group component code into their respective files |
|
216 | - foreach ($component_hooks as $component => $hooks) { |
|
215 | + // Group component code into their respective files |
|
216 | + foreach ($component_hooks as $component => $hooks) { |
|
217 | 217 | $file = array('name' => 'features'); |
218 | 218 | if (isset($components[$component]['default_file'])) { |
219 | - switch ($components[$component]['default_file']) { |
|
219 | + switch ($components[$component]['default_file']) { |
|
220 | 220 | case FEATURES_DEFAULTS_INCLUDED: |
221 | 221 | $file['name'] = "features.$component"; |
222 | - break; |
|
222 | + break; |
|
223 | 223 | case FEATURES_DEFAULTS_CUSTOM: |
224 | 224 | $file['name'] = $components[$component]['default_filename']; |
225 | - break; |
|
226 | - } |
|
225 | + break; |
|
226 | + } |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | if (!isset($code[$file['name']])) { |
230 | - $code[$file['name']] = array(); |
|
230 | + $code[$file['name']] = array(); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | foreach ($hooks as $hook_name => $hook_code) { |
234 | - $code[$file['name']][$hook_name] = features_export_render_defaults($module_name, $hook_name, $hook_code); |
|
234 | + $code[$file['name']][$hook_name] = features_export_render_defaults($module_name, $hook_name, $hook_code); |
|
235 | + } |
|
235 | 236 | } |
236 | - } |
|
237 | 237 | |
238 | - // Finalize strings to be written to files |
|
239 | - foreach ($code as $filename => $contents) { |
|
238 | + // Finalize strings to be written to files |
|
239 | + foreach ($code as $filename => $contents) { |
|
240 | 240 | $code[$filename] = "<?php\n\n". implode("\n\n", $contents) ."\n"; |
241 | - } |
|
241 | + } |
|
242 | 242 | |
243 | - // Generate info file output |
|
244 | - $export = features_export_prepare($export, $module_name, $reset); |
|
245 | - $code['info'] = features_export_info($export); |
|
243 | + // Generate info file output |
|
244 | + $export = features_export_prepare($export, $module_name, $reset); |
|
245 | + $code['info'] = features_export_info($export); |
|
246 | 246 | |
247 | - // Prepare the module |
|
248 | - // If module exists, let it be and include it in the files |
|
249 | - if ($existing = features_get_modules($module_name, TRUE)) { |
|
247 | + // Prepare the module |
|
248 | + // If module exists, let it be and include it in the files |
|
249 | + if ($existing = features_get_modules($module_name, TRUE)) { |
|
250 | 250 | $code['module'] = file_get_contents($existing->filename); |
251 | 251 | |
252 | 252 | // If the current module file does not reference the features.inc include, |
253 | 253 | // set a warning message. |
254 | 254 | if (isset($code['features']) && strpos($code['module'], "{$module_name}.features.inc") === FALSE) { |
255 | - features_log(t('@module does not appear to include the @include file.', array('@module' => "{$module_name}.module", '@include' => "{$module_name}.features.inc")), 'warning'); |
|
255 | + features_log(t('@module does not appear to include the @include file.', array('@module' => "{$module_name}.module", '@include' => "{$module_name}.features.inc")), 'warning'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | // Deprecated files. Display a message for any of these files letting the |
259 | 259 | // user know that they may be removed. |
260 | 260 | $deprecated = array( |
261 | - "{$module_name}.defaults", |
|
262 | - "{$module_name}.features.views", |
|
263 | - "{$module_name}.features.node" |
|
261 | + "{$module_name}.defaults", |
|
262 | + "{$module_name}.features.views", |
|
263 | + "{$module_name}.features.node" |
|
264 | 264 | ); |
265 | 265 | foreach (file_scan_directory(drupal_get_path('module', $module_name), '.*') as $file) { |
266 | - if (in_array($file->name, $deprecated, TRUE)) { |
|
266 | + if (in_array($file->name, $deprecated, TRUE)) { |
|
267 | 267 | features_log(t('The file @filename has been deprecated and can be removed.', array('@filename' => $file->basename)), 'status'); |
268 | - } |
|
269 | - elseif ($file->name === "{$module_name}.features" && empty($code['features'])) { |
|
268 | + } |
|
269 | + elseif ($file->name === "{$module_name}.features" && empty($code['features'])) { |
|
270 | 270 | $code['features'] = "<?php\n\n// This file is deprecated and can be removed.\n// Please remove include_once('{$module_name}.features.inc') in {$module_name}.module as well.\n"; |
271 | - } |
|
271 | + } |
|
272 | 272 | } |
273 | - } |
|
274 | - // Add a stub module to include the defaults |
|
275 | - else if (!empty($code['features'])) { |
|
273 | + } |
|
274 | + // Add a stub module to include the defaults |
|
275 | + else if (!empty($code['features'])) { |
|
276 | 276 | $code['module'] = "<?php\n\ninclude_once('{$module_name}.features.inc');\n"; |
277 | - } |
|
278 | - else { |
|
277 | + } |
|
278 | + else { |
|
279 | 279 | $code['module'] = "<?php\n\n// Drupal needs this blank file.\n"; |
280 | - } |
|
281 | - return $code; |
|
280 | + } |
|
281 | + return $code; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Detect differences between DB and code components of a feature. |
286 | 286 | */ |
287 | 287 | function features_detect_overrides($module) { |
288 | - static $cache; |
|
289 | - if (!isset($cache)) { |
|
288 | + static $cache; |
|
289 | + if (!isset($cache)) { |
|
290 | 290 | $cache = array(); |
291 | - } |
|
292 | - if (!isset($cache[$module->name])) { |
|
291 | + } |
|
292 | + if (!isset($cache[$module->name])) { |
|
293 | 293 | // Rebuild feature from .info file description and prepare an export from current DB state. |
294 | 294 | $export = features_populate($module->info['features'], $module->info['dependencies'], $module->name); |
295 | 295 | $export = features_export_prepare($export, $module->name); |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | |
303 | 303 | $compare = array('normal' => features_export_info($export), 'default' => features_export_info($module->info)); |
304 | 304 | if ($compare['normal'] !== $compare['default']) { |
305 | - $overridden['info'] = $compare; |
|
305 | + $overridden['info'] = $compare; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | // Collect differences at a per-component level |
309 | 309 | $states = features_get_component_states(array($module->name), FALSE); |
310 | 310 | foreach ($states[$module->name] as $component => $state) { |
311 | - if ($state != FEATURES_DEFAULT) { |
|
311 | + if ($state != FEATURES_DEFAULT) { |
|
312 | 312 | $normal = features_get_normal($component, $module->name); |
313 | 313 | $default = features_get_default($component, $module->name); |
314 | 314 | _features_sanitize($normal); |
@@ -316,50 +316,50 @@ discard block |
||
316 | 316 | |
317 | 317 | $compare = array('normal' => features_var_export($normal), 'default' => features_var_export($default)); |
318 | 318 | if (_features_linetrim($compare['normal']) !== _features_linetrim($compare['default'])) { |
319 | - $overridden[$component] = $compare; |
|
319 | + $overridden[$component] = $compare; |
|
320 | + } |
|
320 | 321 | } |
321 | - } |
|
322 | 322 | } |
323 | 323 | $cache[$module->name] = $overridden; |
324 | - } |
|
325 | - return $cache[$module->name]; |
|
324 | + } |
|
325 | + return $cache[$module->name]; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Gets the available default hooks keyed by components. |
330 | 330 | */ |
331 | 331 | function features_get_default_hooks($component = NULL, $reset = FALSE) { |
332 | - static $hooks; |
|
333 | - if (!isset($hooks) || $reset) { |
|
332 | + static $hooks; |
|
333 | + if (!isset($hooks) || $reset) { |
|
334 | 334 | $hooks = array(); |
335 | 335 | features_include(); |
336 | 336 | foreach (module_implements('features_api') as $module) { |
337 | - $info = module_invoke($module, 'features_api'); |
|
338 | - foreach ($info as $k => $v) { |
|
337 | + $info = module_invoke($module, 'features_api'); |
|
338 | + foreach ($info as $k => $v) { |
|
339 | 339 | if (isset($v['default_hook'])) { |
340 | - $hooks[$k] = $v['default_hook']; |
|
340 | + $hooks[$k] = $v['default_hook']; |
|
341 | 341 | } |
342 | - } |
|
342 | + } |
|
343 | + } |
|
343 | 344 | } |
344 | - } |
|
345 | - if (isset($component)) { |
|
345 | + if (isset($component)) { |
|
346 | 346 | return isset($hooks[$component]) ? $hooks[$component] : FALSE; |
347 | - } |
|
348 | - return $hooks; |
|
347 | + } |
|
348 | + return $hooks; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Return a code string representing an implementation of a defaults module hook. |
353 | 353 | */ |
354 | 354 | function features_export_render_defaults($module, $hook, $code) { |
355 | - $output = array(); |
|
356 | - $output[] = "/**"; |
|
357 | - $output[] = " * Implementation of hook_{$hook}()."; |
|
358 | - $output[] = " */"; |
|
359 | - $output[] = "function {$module}_{$hook}() {"; |
|
360 | - $output[] = $code; |
|
361 | - $output[] = "}"; |
|
362 | - return implode("\n", $output); |
|
355 | + $output = array(); |
|
356 | + $output[] = "/**"; |
|
357 | + $output[] = " * Implementation of hook_{$hook}()."; |
|
358 | + $output[] = " */"; |
|
359 | + $output[] = "function {$module}_{$hook}() {"; |
|
360 | + $output[] = $code; |
|
361 | + $output[] = "}"; |
|
362 | + return implode("\n", $output); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -374,23 +374,23 @@ discard block |
||
374 | 374 | * A code string ready to be written to a module's .info file. |
375 | 375 | */ |
376 | 376 | function features_export_info($info, $parents = array()) { |
377 | - $output = ''; |
|
378 | - if (is_array($info)) { |
|
377 | + $output = ''; |
|
378 | + if (is_array($info)) { |
|
379 | 379 | foreach ($info as $k => $v) { |
380 | - $child = $parents; |
|
381 | - $child[] = $k; |
|
382 | - $output .= features_export_info($v, $child); |
|
380 | + $child = $parents; |
|
381 | + $child[] = $k; |
|
382 | + $output .= features_export_info($v, $child); |
|
383 | 383 | } |
384 | - } |
|
385 | - else if (!empty($info) && count($parents)) { |
|
384 | + } |
|
385 | + else if (!empty($info) && count($parents)) { |
|
386 | 386 | $line = array_shift($parents); |
387 | 387 | foreach ($parents as $key) { |
388 | - $line .= is_numeric($key) ? "[]" : "[{$key}]"; |
|
388 | + $line .= is_numeric($key) ? "[]" : "[{$key}]"; |
|
389 | 389 | } |
390 | 390 | $line .= " = \"{$info}\"\n"; |
391 | 391 | return $line; |
392 | - } |
|
393 | - return $output; |
|
392 | + } |
|
393 | + return $output; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -405,81 +405,81 @@ discard block |
||
405 | 405 | * A string of the tar file contents. |
406 | 406 | */ |
407 | 407 | function features_tar_create($name, $contents) { |
408 | - $tar = ''; |
|
409 | - $binary_data_first = pack("a100a8a8a8a12A12", |
|
408 | + $tar = ''; |
|
409 | + $binary_data_first = pack("a100a8a8a8a12A12", |
|
410 | 410 | $name, |
411 | 411 | '100644 ', // File permissions |
412 | 412 | ' 765 ', // UID, |
413 | 413 | ' 765 ', // GID, |
414 | 414 | sprintf("%11s ", decoct(strlen($contents))), // Filesize, |
415 | 415 | sprintf("%11s", decoct(time())) // Creation time |
416 | - ); |
|
417 | - $binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", '', '', '', '', '', '', '', '', '', ''); |
|
416 | + ); |
|
417 | + $binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", '', '', '', '', '', '', '', '', '', ''); |
|
418 | 418 | |
419 | - $checksum = 0; |
|
420 | - for ($i = 0; $i < 148; $i++) { |
|
419 | + $checksum = 0; |
|
420 | + for ($i = 0; $i < 148; $i++) { |
|
421 | 421 | $checksum += ord(substr($binary_data_first, $i, 1)); |
422 | - } |
|
423 | - for ($i = 148; $i < 156; $i++) { |
|
422 | + } |
|
423 | + for ($i = 148; $i < 156; $i++) { |
|
424 | 424 | $checksum += ord(' '); |
425 | - } |
|
426 | - for ($i = 156, $j = 0; $i < 512; $i++, $j++) { |
|
425 | + } |
|
426 | + for ($i = 156, $j = 0; $i < 512; $i++, $j++) { |
|
427 | 427 | $checksum += ord(substr($binary_data_last, $j, 1)); |
428 | - } |
|
428 | + } |
|
429 | 429 | |
430 | - $tar .= $binary_data_first; |
|
431 | - $tar .= pack("a8", sprintf("%6s ", decoct($checksum))); |
|
432 | - $tar .= $binary_data_last; |
|
430 | + $tar .= $binary_data_first; |
|
431 | + $tar .= pack("a8", sprintf("%6s ", decoct($checksum))); |
|
432 | + $tar .= $binary_data_last; |
|
433 | 433 | |
434 | - $buffer = str_split($contents, 512); |
|
435 | - foreach ($buffer as $item) { |
|
434 | + $buffer = str_split($contents, 512); |
|
435 | + foreach ($buffer as $item) { |
|
436 | 436 | $tar .= pack("a512", $item); |
437 | - } |
|
438 | - return $tar; |
|
437 | + } |
|
438 | + return $tar; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
442 | 442 | * Export var function -- from Views. |
443 | 443 | */ |
444 | 444 | function features_var_export($var, $prefix = '', $init = TRUE) { |
445 | - if (is_object($var)) { |
|
445 | + if (is_object($var)) { |
|
446 | 446 | $output = method_exists($var, 'export') ? $var->export() : features_var_export((array) $var); |
447 | - } |
|
448 | - else if (is_array($var)) { |
|
447 | + } |
|
448 | + else if (is_array($var)) { |
|
449 | 449 | if (empty($var)) { |
450 | - $output = 'array()'; |
|
450 | + $output = 'array()'; |
|
451 | 451 | } |
452 | 452 | else { |
453 | - $output = "array(\n"; |
|
454 | - foreach ($var as $key => $value) { |
|
453 | + $output = "array(\n"; |
|
454 | + foreach ($var as $key => $value) { |
|
455 | 455 | $output .= " '$key' => " . features_var_export($value, ' ', FALSE) . ",\n"; |
456 | - } |
|
457 | - $output .= ')'; |
|
456 | + } |
|
457 | + $output .= ')'; |
|
458 | 458 | } |
459 | - } |
|
460 | - else if (is_bool($var)) { |
|
459 | + } |
|
460 | + else if (is_bool($var)) { |
|
461 | 461 | $output = $var ? 'TRUE' : 'FALSE'; |
462 | - } |
|
463 | - else if (is_string($var) && strpos($var, "\n") !== FALSE) { |
|
462 | + } |
|
463 | + else if (is_string($var) && strpos($var, "\n") !== FALSE) { |
|
464 | 464 | // Replace line breaks in strings with a token for replacement |
465 | 465 | // at the very end. This protects whitespace in strings from |
466 | 466 | // unintentional indentation. |
467 | 467 | $var = str_replace("\n", "***BREAK***", $var); |
468 | 468 | $output = var_export($var, TRUE); |
469 | - } |
|
470 | - else { |
|
469 | + } |
|
470 | + else { |
|
471 | 471 | $output = var_export($var, TRUE); |
472 | - } |
|
472 | + } |
|
473 | 473 | |
474 | - if ($prefix) { |
|
474 | + if ($prefix) { |
|
475 | 475 | $output = str_replace("\n", "\n$prefix", $output); |
476 | - } |
|
476 | + } |
|
477 | 477 | |
478 | - if ($init) { |
|
478 | + if ($init) { |
|
479 | 479 | $output = str_replace("***BREAK***", "\n", $output); |
480 | - } |
|
480 | + } |
|
481 | 481 | |
482 | - return $output; |
|
482 | + return $output; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -488,30 +488,30 @@ discard block |
||
488 | 488 | * export so that string extractors like potx can detect them. |
489 | 489 | */ |
490 | 490 | function features_translatables_export($translatables, $indent = '') { |
491 | - $output = ''; |
|
492 | - $translatables = array_filter(array_unique($translatables)); |
|
493 | - if (!empty($translatables)) { |
|
491 | + $output = ''; |
|
492 | + $translatables = array_filter(array_unique($translatables)); |
|
493 | + if (!empty($translatables)) { |
|
494 | 494 | $output .= "{$indent}// Translatables\n"; |
495 | 495 | $output .= "{$indent}// Included for use with string extractors like potx.\n"; |
496 | 496 | sort($translatables); |
497 | 497 | foreach ($translatables as $string) { |
498 | - $output .= "{$indent}t(" . features_var_export($string) . ");\n"; |
|
498 | + $output .= "{$indent}t(" . features_var_export($string) . ");\n"; |
|
499 | + } |
|
499 | 500 | } |
500 | - } |
|
501 | - return $output; |
|
501 | + return $output; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
505 | 505 | * Get a summary storage state for a feature. |
506 | 506 | */ |
507 | 507 | function features_get_storage($module_name) { |
508 | - // Get component states, and array_diff against array(FEATURES_DEFAULT). |
|
509 | - // If the returned array has any states that don't match FEATURES_DEFAULT, |
|
510 | - // return the highest state. |
|
511 | - $states = features_get_component_states(array($module_name), FALSE); |
|
512 | - $states = array_diff($states[$module_name], array(FEATURES_DEFAULT)); |
|
513 | - $storage = !empty($states) ? max($states) : FEATURES_DEFAULT; |
|
514 | - return $storage; |
|
508 | + // Get component states, and array_diff against array(FEATURES_DEFAULT). |
|
509 | + // If the returned array has any states that don't match FEATURES_DEFAULT, |
|
510 | + // return the highest state. |
|
511 | + $states = features_get_component_states(array($module_name), FALSE); |
|
512 | + $states = array_diff($states[$module_name], array(FEATURES_DEFAULT)); |
|
513 | + $storage = !empty($states) ? max($states) : FEATURES_DEFAULT; |
|
514 | + return $storage; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -520,233 +520,233 @@ discard block |
||
520 | 520 | * of a module's component. |
521 | 521 | */ |
522 | 522 | function features_get_signature($state = 'default', $module_name, $component, $reset = FALSE) { |
523 | - switch ($state) { |
|
523 | + switch ($state) { |
|
524 | 524 | case 'cache': |
525 | 525 | $codecache = variable_get('features_codecache', array()); |
526 | - return isset($codecache[$module_name][$component]) ? $codecache[$module_name][$component] : FALSE; |
|
526 | + return isset($codecache[$module_name][$component]) ? $codecache[$module_name][$component] : FALSE; |
|
527 | 527 | case 'default': |
528 | 528 | $objects = features_get_default($component, $module_name, TRUE, $reset); |
529 | - break; |
|
529 | + break; |
|
530 | 530 | case 'normal': |
531 | 531 | $objects = features_get_normal($component, $module_name, $reset); |
532 | - break; |
|
533 | - } |
|
534 | - if (!empty($objects)) { |
|
532 | + break; |
|
533 | + } |
|
534 | + if (!empty($objects)) { |
|
535 | 535 | $objects = (array) $objects; |
536 | 536 | _features_sanitize($objects); |
537 | 537 | return md5(_features_linetrim(features_var_export($objects))); |
538 | - } |
|
539 | - return FALSE; |
|
538 | + } |
|
539 | + return FALSE; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
543 | 543 | * Set the signature of a module/component pair in the codecache. |
544 | 544 | */ |
545 | 545 | function features_set_signature($module, $component, $signature = NULL) { |
546 | - $var_codecache = variable_get('features_codecache', array()); |
|
547 | - $signature = isset($signature) ? $signature : features_get_signature('default', $module, $component, TRUE); |
|
548 | - $var_codecache[$module][$component] = $signature; |
|
549 | - variable_set('features_codecache', $var_codecache); |
|
546 | + $var_codecache = variable_get('features_codecache', array()); |
|
547 | + $signature = isset($signature) ? $signature : features_get_signature('default', $module, $component, TRUE); |
|
548 | + $var_codecache[$module][$component] = $signature; |
|
549 | + variable_set('features_codecache', $var_codecache); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
553 | 553 | * Processing semaphore operations. |
554 | 554 | */ |
555 | 555 | function features_semaphore($op, $component) { |
556 | - // Note: we don't use variable_get() here as the inited variable |
|
557 | - // static cache may be stale. Retrieving directly from the DB narrows |
|
558 | - // the possibility of collision. |
|
559 | - $semaphore = db_result(db_query("SELECT value FROM {variable} WHERE name = 'features_semaphore'")); |
|
560 | - $semaphore = !empty($semaphore) ? unserialize($semaphore) : array(); |
|
556 | + // Note: we don't use variable_get() here as the inited variable |
|
557 | + // static cache may be stale. Retrieving directly from the DB narrows |
|
558 | + // the possibility of collision. |
|
559 | + $semaphore = db_result(db_query("SELECT value FROM {variable} WHERE name = 'features_semaphore'")); |
|
560 | + $semaphore = !empty($semaphore) ? unserialize($semaphore) : array(); |
|
561 | 561 | |
562 | - switch ($op) { |
|
562 | + switch ($op) { |
|
563 | 563 | case 'get': |
564 | 564 | return isset($semaphore[$component]) ? $semaphore[$component] : FALSE; |
565 | 565 | case 'set': |
566 | 566 | $semaphore[$component] = time(); |
567 | - variable_set('features_semaphore', $semaphore); |
|
568 | - break; |
|
567 | + variable_set('features_semaphore', $semaphore); |
|
568 | + break; |
|
569 | 569 | case 'del': |
570 | 570 | if (isset($semaphore[$component])) { |
571 | 571 | unset($semaphore[$component]); |
572 | 572 | variable_set('features_semaphore', $semaphore); |
573 | - } |
|
574 | - break; |
|
575 | - } |
|
573 | + } |
|
574 | + break; |
|
575 | + } |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
579 | 579 | * Get normal objects for a given module/component pair. |
580 | 580 | */ |
581 | 581 | function features_get_normal($component, $module_name, $reset = FALSE) { |
582 | - static $cache; |
|
583 | - if (!isset($cache) || $reset) { |
|
582 | + static $cache; |
|
583 | + if (!isset($cache) || $reset) { |
|
584 | 584 | $cache = array(); |
585 | - } |
|
586 | - if (!isset($cache[$module_name][$component])) { |
|
585 | + } |
|
586 | + if (!isset($cache[$module_name][$component])) { |
|
587 | 587 | features_include(); |
588 | 588 | $code = NULL; |
589 | 589 | $module = features_get_features($module_name); |
590 | 590 | |
591 | 591 | // Special handling for dependencies component. |
592 | 592 | if ($component === 'dependencies') { |
593 | - $cache[$module_name][$component] = isset($module->info['dependencies']) ? array_filter($module->info['dependencies'], 'module_exists') : array(); |
|
593 | + $cache[$module_name][$component] = isset($module->info['dependencies']) ? array_filter($module->info['dependencies'], 'module_exists') : array(); |
|
594 | 594 | } |
595 | 595 | // All other components. |
596 | 596 | else { |
597 | - $default_hook = features_get_default_hooks($component); |
|
598 | - if ($module && $default_hook && isset($module->info['features'][$component]) && features_hook($component, 'features_export_render')) { |
|
597 | + $default_hook = features_get_default_hooks($component); |
|
598 | + if ($module && $default_hook && isset($module->info['features'][$component]) && features_hook($component, 'features_export_render')) { |
|
599 | 599 | $code = features_invoke($component, 'features_export_render', $module_name, $module->info['features'][$component], NULL); |
600 | 600 | $cache[$module_name][$component] = isset($code[$default_hook]) ? eval($code[$default_hook]) : FALSE; |
601 | - } |
|
601 | + } |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | // Clear out vars for memory's sake. |
605 | 605 | unset($code); |
606 | 606 | unset($module); |
607 | - } |
|
608 | - return isset($cache[$module_name][$component]) ? $cache[$module_name][$component] : FALSE; |
|
607 | + } |
|
608 | + return isset($cache[$module_name][$component]) ? $cache[$module_name][$component] : FALSE; |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
612 | 612 | * Get defaults for a given module/component pair. |
613 | 613 | */ |
614 | 614 | function features_get_default($component, $module_name = NULL, $alter = TRUE, $reset = FALSE) { |
615 | - static $cache = array(); |
|
616 | - features_include(); |
|
617 | - features_include_defaults($component); |
|
618 | - $default_hook = features_get_default_hooks($component); |
|
619 | - $components = features_get_components(); |
|
620 | - |
|
621 | - // Collect defaults for all modules if no module name was specified. |
|
622 | - if (isset($module_name)) { |
|
615 | + static $cache = array(); |
|
616 | + features_include(); |
|
617 | + features_include_defaults($component); |
|
618 | + $default_hook = features_get_default_hooks($component); |
|
619 | + $components = features_get_components(); |
|
620 | + |
|
621 | + // Collect defaults for all modules if no module name was specified. |
|
622 | + if (isset($module_name)) { |
|
623 | 623 | $modules = array($module_name); |
624 | - } |
|
625 | - else { |
|
624 | + } |
|
625 | + else { |
|
626 | 626 | if ($component === 'dependencies') { |
627 | - $modules = array_keys(features_get_features()); |
|
627 | + $modules = array_keys(features_get_features()); |
|
628 | 628 | } |
629 | 629 | else { |
630 | - $modules = array(); |
|
631 | - foreach (features_get_component_map($component) as $component_modules) { |
|
630 | + $modules = array(); |
|
631 | + foreach (features_get_component_map($component) as $component_modules) { |
|
632 | 632 | $modules = array_merge($modules, $component_modules); |
633 | - } |
|
634 | - $modules = array_unique($modules); |
|
633 | + } |
|
634 | + $modules = array_unique($modules); |
|
635 | + } |
|
635 | 636 | } |
636 | - } |
|
637 | 637 | |
638 | - // Collect and cache information for each specified module. |
|
639 | - foreach ($modules as $m) { |
|
638 | + // Collect and cache information for each specified module. |
|
639 | + foreach ($modules as $m) { |
|
640 | 640 | if (!isset($cache[$component][$m]) || $reset) { |
641 | - // Special handling for dependencies component. |
|
642 | - if ($component === 'dependencies') { |
|
641 | + // Special handling for dependencies component. |
|
642 | + if ($component === 'dependencies') { |
|
643 | 643 | $module = features_get_features($m); |
644 | 644 | $cache[$component][$m] = isset($module->info['dependencies']) ? $module->info['dependencies'] : array(); |
645 | 645 | unset($module); |
646 | - } |
|
647 | - // All other components |
|
648 | - else { |
|
646 | + } |
|
647 | + // All other components |
|
648 | + else { |
|
649 | 649 | if ($default_hook && function_exists("{$m}_{$default_hook}")) { |
650 | - $cache[$component][$m] = call_user_func("{$m}_{$default_hook}"); |
|
651 | - if ($alter) { |
|
650 | + $cache[$component][$m] = call_user_func("{$m}_{$default_hook}"); |
|
651 | + if ($alter) { |
|
652 | 652 | drupal_alter($default_hook, $cache[$component][$m]); |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | else { |
656 | - $cache[$component][$m] = FALSE; |
|
656 | + $cache[$component][$m] = FALSE; |
|
657 | 657 | } |
658 | - } |
|
658 | + } |
|
659 | + } |
|
659 | 660 | } |
660 | - } |
|
661 | 661 | |
662 | - // A specific module was specified. Retrieve only its components. |
|
663 | - if (isset($module_name)) { |
|
662 | + // A specific module was specified. Retrieve only its components. |
|
663 | + if (isset($module_name)) { |
|
664 | 664 | return isset($cache[$component][$module_name]) ? $cache[$component][$module_name] : FALSE; |
665 | - } |
|
666 | - // No module was specified. Retrieve all components. |
|
667 | - $all_defaults = array(); |
|
668 | - if (isset($cache[$component])) { |
|
665 | + } |
|
666 | + // No module was specified. Retrieve all components. |
|
667 | + $all_defaults = array(); |
|
668 | + if (isset($cache[$component])) { |
|
669 | 669 | foreach (array_filter($cache[$component]) as $module_components) { |
670 | - $all_defaults = array_merge($all_defaults, $module_components); |
|
670 | + $all_defaults = array_merge($all_defaults, $module_components); |
|
671 | 671 | } |
672 | - } |
|
673 | - return $all_defaults; |
|
672 | + } |
|
673 | + return $all_defaults; |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
677 | 677 | * Get a map of components to their providing modules. |
678 | 678 | */ |
679 | 679 | function features_get_default_map($component, $attribute = NULL, $callback = NULL, $reset = FALSE) { |
680 | - static $map = array(); |
|
681 | - features_include(); |
|
682 | - features_include_defaults($component); |
|
683 | - if ((!isset($map[$component]) || $reset) && $default_hook = features_get_default_hooks($component)) { |
|
680 | + static $map = array(); |
|
681 | + features_include(); |
|
682 | + features_include_defaults($component); |
|
683 | + if ((!isset($map[$component]) || $reset) && $default_hook = features_get_default_hooks($component)) { |
|
684 | 684 | $map[$component] = array(); |
685 | 685 | foreach (module_implements($default_hook) as $module) { |
686 | - if ($defaults = features_get_default($component, $module)) { |
|
686 | + if ($defaults = features_get_default($component, $module)) { |
|
687 | 687 | foreach ($defaults as $key => $object) { |
688 | - if (isset($callback)) { |
|
688 | + if (isset($callback)) { |
|
689 | 689 | if ($object_key = $callback($object)) { |
690 | - $map[$component][$object_key] = $module; |
|
690 | + $map[$component][$object_key] = $module; |
|
691 | + } |
|
691 | 692 | } |
692 | - } |
|
693 | - elseif (isset($attribute)) { |
|
693 | + elseif (isset($attribute)) { |
|
694 | 694 | if (is_object($object) && isset($object->{$attribute})) { |
695 | - $map[$component][$object->{$attribute}] = $module; |
|
695 | + $map[$component][$object->{$attribute}] = $module; |
|
696 | 696 | } |
697 | 697 | elseif (is_array($object) && isset($object[$attribute])) { |
698 | - $map[$component][$object[$attribute]] = $module; |
|
698 | + $map[$component][$object[$attribute]] = $module; |
|
699 | 699 | } |
700 | - } |
|
701 | - elseif (!isset($attribute) && !isset($callback)) { |
|
700 | + } |
|
701 | + elseif (!isset($attribute) && !isset($callback)) { |
|
702 | 702 | if (!is_numeric($key)) { |
703 | - $map[$component][$key] = $module; |
|
703 | + $map[$component][$key] = $module; |
|
704 | + } |
|
704 | 705 | } |
705 | - } |
|
706 | - else { |
|
706 | + else { |
|
707 | 707 | return FALSE; |
708 | - } |
|
708 | + } |
|
709 | + } |
|
709 | 710 | } |
710 | - } |
|
711 | 711 | } |
712 | - } |
|
713 | - return isset($map[$component]) ? $map[$component] : FALSE; |
|
712 | + } |
|
713 | + return isset($map[$component]) ? $map[$component] : FALSE; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
717 | 717 | * Retrieve an array of features/components and their current states. |
718 | 718 | */ |
719 | 719 | function features_get_component_states($features = array(), $rebuild_only = TRUE, $reset = FALSE) { |
720 | - static $cache; |
|
721 | - if (!isset($cache) || $reset) { |
|
720 | + static $cache; |
|
721 | + if (!isset($cache) || $reset) { |
|
722 | 722 | $cache = array(); |
723 | - } |
|
723 | + } |
|
724 | 724 | |
725 | - $features = !empty($features) ? $features : array_keys(features_get_features()); |
|
725 | + $features = !empty($features) ? $features : array_keys(features_get_features()); |
|
726 | 726 | |
727 | - // Retrieve only rebuildable components if requested. |
|
728 | - features_include(); |
|
729 | - $components = array_keys(features_get_components()); |
|
730 | - if ($rebuild_only) { |
|
727 | + // Retrieve only rebuildable components if requested. |
|
728 | + features_include(); |
|
729 | + $components = array_keys(features_get_components()); |
|
730 | + if ($rebuild_only) { |
|
731 | 731 | foreach ($components as $k => $component) { |
732 | - if (!features_hook($component, 'features_rebuild')) { |
|
732 | + if (!features_hook($component, 'features_rebuild')) { |
|
733 | 733 | unset($components[$k]); |
734 | - } |
|
734 | + } |
|
735 | + } |
|
735 | 736 | } |
736 | - } |
|
737 | 737 | |
738 | - foreach ($features as $feature) { |
|
738 | + foreach ($features as $feature) { |
|
739 | 739 | $cache[$feature] = isset($cache[$feature]) ? $cache[$feature] : array(); |
740 | 740 | if (module_exists($feature)) { |
741 | - foreach ($components as $component) { |
|
741 | + foreach ($components as $component) { |
|
742 | 742 | if (!isset($cache[$feature][$component])) { |
743 | - $normal = features_get_signature('normal', $feature, $component, $reset); |
|
744 | - $default = features_get_signature('default', $feature, $component, $reset); |
|
745 | - $codecache = features_get_signature('cache', $feature, $component, $reset); |
|
746 | - $semaphore = features_semaphore('get', $component); |
|
743 | + $normal = features_get_signature('normal', $feature, $component, $reset); |
|
744 | + $default = features_get_signature('default', $feature, $component, $reset); |
|
745 | + $codecache = features_get_signature('cache', $feature, $component, $reset); |
|
746 | + $semaphore = features_semaphore('get', $component); |
|
747 | 747 | |
748 | - // DB and code states match, there is nothing more to check. |
|
749 | - if ($normal == $default) { |
|
748 | + // DB and code states match, there is nothing more to check. |
|
749 | + if ($normal == $default) { |
|
750 | 750 | $cache[$feature][$component] = FEATURES_DEFAULT; |
751 | 751 | |
752 | 752 | // Stale semaphores can be deleted. |
@@ -754,73 +754,73 @@ discard block |
||
754 | 754 | |
755 | 755 | // Update code cache if it is stale, clear out semaphore if it stale. |
756 | 756 | if ($default != $codecache) { |
757 | - features_set_signature($feature, $component, $default); |
|
757 | + features_set_signature($feature, $component, $default); |
|
758 | + } |
|
758 | 759 | } |
759 | - } |
|
760 | - // Component properly implements exportables. |
|
761 | - else if (!features_hook($component, 'features_rebuild')) { |
|
760 | + // Component properly implements exportables. |
|
761 | + else if (!features_hook($component, 'features_rebuild')) { |
|
762 | 762 | $cache[$feature][$component] = FEATURES_OVERRIDDEN; |
763 | - } |
|
764 | - // Component does not implement exportables. |
|
765 | - else { |
|
763 | + } |
|
764 | + // Component does not implement exportables. |
|
765 | + else { |
|
766 | 766 | if (empty($semaphore)) { |
767 | - // Exception for dependencies. Dependencies are always rebuildable. |
|
768 | - if ($component === 'dependencies') { |
|
767 | + // Exception for dependencies. Dependencies are always rebuildable. |
|
768 | + if ($component === 'dependencies') { |
|
769 | 769 | $cache[$feature][$component] = FEATURES_REBUILDABLE; |
770 | - } |
|
771 | - // All other rebuildable components require comparison. |
|
772 | - else { |
|
770 | + } |
|
771 | + // All other rebuildable components require comparison. |
|
772 | + else { |
|
773 | 773 | // Code has not changed, but DB does not match. User has DB overrides. |
774 | 774 | if ($codecache == $default) { |
775 | - $cache[$feature][$component] = FEATURES_OVERRIDDEN; |
|
775 | + $cache[$feature][$component] = FEATURES_OVERRIDDEN; |
|
776 | 776 | } |
777 | 777 | // DB has no modifications to prior code state (or this is initial install). |
778 | 778 | else if (empty($codecache) || $codecache == $normal) { |
779 | - $cache[$feature][$component] = FEATURES_REBUILDABLE; |
|
779 | + $cache[$feature][$component] = FEATURES_REBUILDABLE; |
|
780 | 780 | } |
781 | 781 | // None of the states match. Requires user intervention. |
782 | 782 | else if ($codecache != $default) { |
783 | - $cache[$feature][$component] = FEATURES_NEEDS_REVIEW; |
|
783 | + $cache[$feature][$component] = FEATURES_NEEDS_REVIEW; |
|
784 | + } |
|
784 | 785 | } |
785 | - } |
|
786 | 786 | } |
787 | 787 | else { |
788 | - // Semaphore is still within processing horizon. Do nothing. |
|
789 | - if ((time() - $semaphore) < FEATURES_SEMAPHORE_TIMEOUT) { |
|
788 | + // Semaphore is still within processing horizon. Do nothing. |
|
789 | + if ((time() - $semaphore) < FEATURES_SEMAPHORE_TIMEOUT) { |
|
790 | 790 | $cache[$feature][$component] = FEATURES_REBUILDING; |
791 | - } |
|
792 | - // A stale semaphore means a previous rebuild attempt did not complete. |
|
793 | - // Attempt to complete the rebuild. |
|
794 | - else { |
|
791 | + } |
|
792 | + // A stale semaphore means a previous rebuild attempt did not complete. |
|
793 | + // Attempt to complete the rebuild. |
|
794 | + else { |
|
795 | 795 | $cache[$feature][$component] = FEATURES_REBUILDABLE; |
796 | - } |
|
796 | + } |
|
797 | + } |
|
797 | 798 | } |
798 | - } |
|
799 | 799 | } |
800 | - } |
|
800 | + } |
|
801 | + } |
|
801 | 802 | } |
802 | - } |
|
803 | 803 | |
804 | - // Filter cached components on the way out to ensure that even if we have |
|
805 | - // cached more data than has been requested, the return value only reflects |
|
806 | - // the requested features/components. |
|
807 | - $return = $cache; |
|
808 | - $return = array_intersect_key($return, array_flip($features)); |
|
809 | - foreach ($return as $k => $v) { |
|
804 | + // Filter cached components on the way out to ensure that even if we have |
|
805 | + // cached more data than has been requested, the return value only reflects |
|
806 | + // the requested features/components. |
|
807 | + $return = $cache; |
|
808 | + $return = array_intersect_key($return, array_flip($features)); |
|
809 | + foreach ($return as $k => $v) { |
|
810 | 810 | $return[$k] = array_intersect_key($return[$k], array_flip($components)); |
811 | - } |
|
812 | - return $return; |
|
811 | + } |
|
812 | + return $return; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
816 | 816 | * Helper function to eliminate whitespace differences in code. |
817 | 817 | */ |
818 | 818 | function _features_linetrim($code) { |
819 | - $code = explode("\n", $code); |
|
820 | - foreach ($code as $k => $line) { |
|
819 | + $code = explode("\n", $code); |
|
820 | + foreach ($code as $k => $line) { |
|
821 | 821 | $code[$k] = trim($line); |
822 | - } |
|
823 | - return implode("\n", $code); |
|
822 | + } |
|
823 | + return implode("\n", $code); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
@@ -829,19 +829,19 @@ discard block |
||
829 | 829 | * - Remove any null or empty values for associative arrays (array_filter()). |
830 | 830 | */ |
831 | 831 | function _features_sanitize(&$array) { |
832 | - if (is_array($array)) { |
|
832 | + if (is_array($array)) { |
|
833 | 833 | $is_assoc = (array_keys($array) !== range(0, count($array) - 1)); |
834 | 834 | if ($is_assoc) { |
835 | - ksort($array); |
|
836 | - $array = array_filter($array); |
|
835 | + ksort($array); |
|
836 | + $array = array_filter($array); |
|
837 | 837 | } |
838 | 838 | else { |
839 | - sort($array); |
|
839 | + sort($array); |
|
840 | 840 | } |
841 | 841 | foreach ($array as $k => $v) { |
842 | - if (is_array($v)) { |
|
842 | + if (is_array($v)) { |
|
843 | 843 | _features_sanitize($array[$k]); |
844 | - } |
|
844 | + } |
|
845 | + } |
|
845 | 846 | } |
846 | - } |
|
847 | 847 | } |
@@ -4,26 +4,26 @@ discard block |
||
4 | 4 | * Form callback for features export form. Acts as a router based on the form_state. |
5 | 5 | */ |
6 | 6 | function features_export_form($form_state, $feature = NULL) { |
7 | - module_load_include('inc', 'features', 'features.export'); |
|
8 | - features_include(); |
|
7 | + module_load_include('inc', 'features', 'features.export'); |
|
8 | + features_include(); |
|
9 | 9 | |
10 | - $form = array( |
|
10 | + $form = array( |
|
11 | 11 | '#attributes' => array('class' => 'features-export-form'), |
12 | 12 | '#feature' => isset($feature) ? $feature : NULL, |
13 | - ); |
|
14 | - $form['info'] = array( |
|
13 | + ); |
|
14 | + $form['info'] = array( |
|
15 | 15 | '#type' => 'fieldset', |
16 | 16 | '#tree' => FALSE, |
17 | - ); |
|
18 | - $form['info']['name'] = array( |
|
17 | + ); |
|
18 | + $form['info']['name'] = array( |
|
19 | 19 | '#title' => t('Name'), |
20 | 20 | '#description' => t('Example: Image gallery'), |
21 | 21 | '#type' => 'textfield', |
22 | 22 | '#required' => TRUE, |
23 | 23 | '#default_value' => !empty($feature->info['name']) ? $feature->info['name'] : '', |
24 | 24 | '#attributes' => array('class' => 'feature-name'), |
25 | - ); |
|
26 | - $form['info']['module_name'] = array( |
|
25 | + ); |
|
26 | + $form['info']['module_name'] = array( |
|
27 | 27 | '#type' => 'textfield', |
28 | 28 | '#title' => t('Machine-readable name'), |
29 | 29 | '#description' => t('Example: image_gallery'). '<br/>' .t('May only contain lowercase letters, numbers and underscores. <strong>Try to avoid conflicts with the names of existing Drupal projects.</strong>'), |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | '#default_value' => !empty($feature->name) ? $feature->name : '', |
32 | 32 | '#attributes' => array('class' => 'feature-module-name'), |
33 | 33 | '#element_validate' => array('features_export_form_validate_field'), |
34 | - ); |
|
35 | - // If recreating this feature, disable machine name field and blank out |
|
36 | - // js-attachment classes to ensure the machine name cannot be changed. |
|
37 | - if (isset($feature)) { |
|
34 | + ); |
|
35 | + // If recreating this feature, disable machine name field and blank out |
|
36 | + // js-attachment classes to ensure the machine name cannot be changed. |
|
37 | + if (isset($feature)) { |
|
38 | 38 | $form['info']['module_name']['#value'] = $feature->name; |
39 | 39 | $form['info']['module_name']['#disabled'] = TRUE; |
40 | 40 | $form['info']['name']['#attributes'] = array(); |
41 | - } |
|
42 | - $form['info']['description'] = array( |
|
41 | + } |
|
42 | + $form['info']['description'] = array( |
|
43 | 43 | '#title' => t('Description'), |
44 | 44 | '#description' => t('Provide a short description of what users should expect when they enable your feature.'), |
45 | 45 | '#type' => 'textfield', |
46 | 46 | '#required' => TRUE, |
47 | 47 | '#default_value' => !empty($feature->info['description']) ? $feature->info['description'] : '', |
48 | - ); |
|
49 | - $form['info']['version'] = array( |
|
48 | + ); |
|
49 | + $form['info']['version'] = array( |
|
50 | 50 | '#title' => t('Version'), |
51 | 51 | '#description' => t('Examples: 6.x-1.0, 6.x-1.0-beta1'), |
52 | 52 | '#type' => 'textfield', |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | '#default_value' => !empty($feature->info['version']) ? $feature->info['version'] : '', |
55 | 55 | '#size' => 30, |
56 | 56 | '#element_validate' => array('features_export_form_validate_field'), |
57 | - ); |
|
58 | - $form['info']['project_status_url'] = array( |
|
57 | + ); |
|
58 | + $form['info']['project_status_url'] = array( |
|
59 | 59 | '#title' => t('URL of update XML'), |
60 | 60 | '#description' => t('Example: http://mywebsite.com/fserver'), |
61 | 61 | '#type' => 'textfield', |
@@ -63,168 +63,168 @@ discard block |
||
63 | 63 | '#default_value' => !empty($feature->info['project status url']) ? $feature->info['project status url'] : '', |
64 | 64 | '#size' => 30, |
65 | 65 | '#element_validate' => array('features_export_form_validate_field'), |
66 | - ); |
|
66 | + ); |
|
67 | 67 | |
68 | - // User-selected feature source components. |
|
69 | - $components = features_get_components(); |
|
70 | - uasort($components, 'features_compare_component_name'); |
|
68 | + // User-selected feature source components. |
|
69 | + $components = features_get_components(); |
|
70 | + uasort($components, 'features_compare_component_name'); |
|
71 | 71 | |
72 | - $form['export'] = array( |
|
72 | + $form['export'] = array( |
|
73 | 73 | '#type' => 'fieldset', |
74 | 74 | '#tree' => FALSE, |
75 | 75 | '#theme' => 'features_form_export', |
76 | - ); |
|
77 | - $form['export']['components'] = array( |
|
76 | + ); |
|
77 | + $form['export']['components'] = array( |
|
78 | 78 | '#title' => t('Edit components'), |
79 | 79 | '#type' => 'select', |
80 | 80 | '#options' => array('------'), |
81 | 81 | '#attributes' => array('class' => 'features-select-components'), |
82 | - ); |
|
83 | - $form['export']['sources'] = array( |
|
82 | + ); |
|
83 | + $form['export']['sources'] = array( |
|
84 | 84 | '#tree' => TRUE, |
85 | 85 | '#theme' => 'features_form_components', |
86 | - ); |
|
87 | - foreach ($components as $component => $component_info) { |
|
86 | + ); |
|
87 | + foreach ($components as $component => $component_info) { |
|
88 | 88 | $options = features_invoke($component, 'features_export_options'); |
89 | 89 | if ($component === 'dependencies') { |
90 | - $default_value = !empty($feature->info['dependencies']) ? $feature->info['dependencies'] : array(); |
|
90 | + $default_value = !empty($feature->info['dependencies']) ? $feature->info['dependencies'] : array(); |
|
91 | 91 | } |
92 | 92 | else { |
93 | - $default_value = !empty($feature->info['features'][$component]) ? $feature->info['features'][$component] : array(); |
|
93 | + $default_value = !empty($feature->info['features'][$component]) ? $feature->info['features'][$component] : array(); |
|
94 | 94 | } |
95 | 95 | if ($options) { |
96 | - // Find all default components that are not provided by this feature and |
|
97 | - // strip them out of the possible options. |
|
98 | - if ($map = features_get_default_map($component)) { |
|
96 | + // Find all default components that are not provided by this feature and |
|
97 | + // strip them out of the possible options. |
|
98 | + if ($map = features_get_default_map($component)) { |
|
99 | 99 | foreach ($map as $k => $v) { |
100 | - if (isset($options[$k]) && (!isset($feature->name) || $v !== $feature->name)) { |
|
100 | + if (isset($options[$k]) && (!isset($feature->name) || $v !== $feature->name)) { |
|
101 | 101 | unset($options[$k]); |
102 | - } |
|
102 | + } |
|
103 | 103 | } |
104 | - } |
|
105 | - // Ensure all options are stripped of potentially bad values. |
|
106 | - foreach ($options as $k => $v) { |
|
104 | + } |
|
105 | + // Ensure all options are stripped of potentially bad values. |
|
106 | + foreach ($options as $k => $v) { |
|
107 | 107 | $options[$k] = check_plain($v); |
108 | - } |
|
109 | - $label = (isset($component_info['name']) ? $component_info['name'] . ": " . $component : $component); |
|
110 | - $form['export']['components']['#options'][$component] = $label; |
|
111 | - if (!empty($options)) { |
|
108 | + } |
|
109 | + $label = (isset($component_info['name']) ? $component_info['name'] . ": " . $component : $component); |
|
110 | + $form['export']['components']['#options'][$component] = $label; |
|
111 | + if (!empty($options)) { |
|
112 | 112 | $form['export']['sources'][$component] = array( |
113 | - '#type' => 'checkboxes', |
|
114 | - '#options' => features_dom_encode_options($options), |
|
115 | - '#title' => $component, |
|
116 | - '#default_value' => features_dom_encode_options($default_value, FALSE), |
|
117 | - '#ahah' => array( |
|
113 | + '#type' => 'checkboxes', |
|
114 | + '#options' => features_dom_encode_options($options), |
|
115 | + '#title' => $component, |
|
116 | + '#default_value' => features_dom_encode_options($default_value, FALSE), |
|
117 | + '#ahah' => array( |
|
118 | 118 | 'path' => 'admin/build/features/export/populate', |
119 | 119 | 'wrapper' => 'features-export-populated', |
120 | - ), |
|
120 | + ), |
|
121 | 121 | ); |
122 | - } |
|
123 | - else { |
|
122 | + } |
|
123 | + else { |
|
124 | 124 | $form['export']['sources'][$component] = array( |
125 | - '#type' => 'item', |
|
126 | - '#title' => $component, |
|
127 | - '#value' => t('All components of this type are exported by other features or modules.'), |
|
125 | + '#type' => 'item', |
|
126 | + '#title' => $component, |
|
127 | + '#value' => t('All components of this type are exported by other features or modules.'), |
|
128 | 128 | ); |
129 | - } |
|
129 | + } |
|
130 | + } |
|
130 | 131 | } |
131 | - } |
|
132 | - $form['export']['features'] = array( |
|
132 | + $form['export']['features'] = array( |
|
133 | 133 | '#tree' => TRUE, |
134 | 134 | '#type' => 'markup', |
135 | 135 | '#prefix' => "<div id='features-export-populated'>", |
136 | 136 | '#suffix' => "</div>", |
137 | 137 | '#value' => !empty($feature->info) ? theme('features_components', $feature->info, $feature->info['features']) : "<div class='placeholder'></div>", |
138 | - ); |
|
138 | + ); |
|
139 | 139 | |
140 | - $form['buttons'] = array('#theme' => 'features_form_buttons', '#tree' => FALSE); |
|
141 | - $form['buttons']['submit'] = array( |
|
140 | + $form['buttons'] = array('#theme' => 'features_form_buttons', '#tree' => FALSE); |
|
141 | + $form['buttons']['submit'] = array( |
|
142 | 142 | '#type' => 'submit', |
143 | 143 | '#value' => t('Download feature'), |
144 | 144 | '#weight' => 10, |
145 | 145 | '#submit' => array('features_export_build_form_submit'), |
146 | - ); |
|
147 | - return $form; |
|
146 | + ); |
|
147 | + return $form; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | 151 | * Validation for project field. |
152 | 152 | */ |
153 | 153 | function features_export_form_validate_field($element, &$form_state) { |
154 | - switch ($element['#name']) { |
|
154 | + switch ($element['#name']) { |
|
155 | 155 | case 'module_name': |
156 | 156 | if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) { |
157 | 157 | form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.')); |
158 | - } |
|
159 | - // If user is filling out the feature name for the first time and uses |
|
160 | - // the name of an existing module throw an error. |
|
161 | - else if (empty($element['#default_value']) && features_get_info('module', $element['#value'])) { |
|
158 | + } |
|
159 | + // If user is filling out the feature name for the first time and uses |
|
160 | + // the name of an existing module throw an error. |
|
161 | + else if (empty($element['#default_value']) && features_get_info('module', $element['#value'])) { |
|
162 | 162 | form_error($element, t('A module by the name @name already exists on your site. Please choose a different name.', array('@name' => $element['#value']))); |
163 | - } |
|
164 | - break; |
|
163 | + } |
|
164 | + break; |
|
165 | 165 | case 'project_status_url': |
166 | 166 | if (!empty($element['#value']) && !valid_url($element['#value'])) { |
167 | 167 | form_error($element, t('The URL %url is invalid. Please enter a fully-qualified URL, such as http://www.example.com/feed.xml.', array('%url' => $element['#value']))); |
168 | - } |
|
169 | - break; |
|
168 | + } |
|
169 | + break; |
|
170 | 170 | case 'version': |
171 | 171 | preg_match('/^(?P<core>\d+\.x)-(?P<major>\d+)\.(?P<patch>\d+)-?(?P<extra>\w+)?$/', $element['#value'], $matches); |
172 | - if (!empty($element['#value']) && !isset($matches['core'], $matches['major'])) { |
|
172 | + if (!empty($element['#value']) && !isset($matches['core'], $matches['major'])) { |
|
173 | 173 | form_error($element, t('Please enter a valid version with core and major version number. Example: !example', array('!example' => '6.x-1.0'))); |
174 | - }; |
|
175 | - break; |
|
176 | - } |
|
174 | + }; |
|
175 | + break; |
|
176 | + } |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * Submit handler for features_export_form_build(). |
181 | 181 | */ |
182 | 182 | function features_export_build_form_submit($form, &$form_state) { |
183 | - module_load_include('inc', 'features', 'features.export'); |
|
184 | - features_include(); |
|
183 | + module_load_include('inc', 'features', 'features.export'); |
|
184 | + features_include(); |
|
185 | 185 | |
186 | - // Assemble the combined component list |
|
187 | - $stub = array(); |
|
188 | - $components = array_keys(features_get_components()); |
|
189 | - foreach ($components as $component) { |
|
186 | + // Assemble the combined component list |
|
187 | + $stub = array(); |
|
188 | + $components = array_keys(features_get_components()); |
|
189 | + foreach ($components as $component) { |
|
190 | 190 | // User-selected components take precedence. |
191 | 191 | if (!empty($form_state['values']['sources'][$component])) { |
192 | - $stub[$component] = features_dom_decode_options(array_filter($form_state['values']['sources'][$component])); |
|
192 | + $stub[$component] = features_dom_decode_options(array_filter($form_state['values']['sources'][$component])); |
|
193 | 193 | } |
194 | 194 | // Only fallback to an existing feature's values if there are no export options for the component. |
195 | 195 | else if (!empty($form['#feature']->info['features'][$component])) { |
196 | - $stub[$component] = $form['#feature']->info['features'][$component]; |
|
196 | + $stub[$component] = $form['#feature']->info['features'][$component]; |
|
197 | + } |
|
197 | 198 | } |
198 | - } |
|
199 | 199 | |
200 | - // Generate populated feature |
|
201 | - $module_name = $form_state['values']['module_name']; |
|
202 | - $export = features_populate($stub, $form_state['values']['sources']['dependencies'], $module_name); |
|
200 | + // Generate populated feature |
|
201 | + $module_name = $form_state['values']['module_name']; |
|
202 | + $export = features_populate($stub, $form_state['values']['sources']['dependencies'], $module_name); |
|
203 | 203 | |
204 | - // Directly copy the following attributes |
|
205 | - $attr = array('name', 'description'); |
|
206 | - foreach ($attr as $key) { |
|
204 | + // Directly copy the following attributes |
|
205 | + $attr = array('name', 'description'); |
|
206 | + foreach ($attr as $key) { |
|
207 | 207 | $export[$key] = isset($form_state['values'][$key]) ? $form_state['values'][$key] : NULL; |
208 | - } |
|
209 | - // If either update status-related keys are provided, add a project key |
|
210 | - // corresponding to the module name. |
|
211 | - if (!empty($form_state['values']['version']) || !empty($form_state['values']['project_status_url'])) { |
|
208 | + } |
|
209 | + // If either update status-related keys are provided, add a project key |
|
210 | + // corresponding to the module name. |
|
211 | + if (!empty($form_state['values']['version']) || !empty($form_state['values']['project_status_url'])) { |
|
212 | 212 | $export['project'] = $form_state['values']['module_name']; |
213 | - } |
|
214 | - if (!empty($form_state['values']['version'])) { |
|
213 | + } |
|
214 | + if (!empty($form_state['values']['version'])) { |
|
215 | 215 | $export['version'] = $form_state['values']['version']; |
216 | - } |
|
217 | - if (!empty($form_state['values']['project_status_url'])) { |
|
216 | + } |
|
217 | + if (!empty($form_state['values']['project_status_url'])) { |
|
218 | 218 | $export['project status url'] = $form_state['values']['project_status_url']; |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | - // Generate download |
|
222 | - if ($files = features_export_render($export, $module_name, TRUE)) { |
|
221 | + // Generate download |
|
222 | + if ($files = features_export_render($export, $module_name, TRUE)) { |
|
223 | 223 | $filename = (!empty($export['version']) ? "{$module_name}-{$export['version']}" : $module_name) . '.tar'; |
224 | 224 | |
225 | 225 | // Clear out output buffer to remove any garbage from tar output. |
226 | 226 | if (ob_get_level()) { |
227 | - ob_end_clean(); |
|
227 | + ob_end_clean(); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | drupal_set_header('Content-type: application/x-tar'); |
@@ -233,62 +233,62 @@ discard block |
||
233 | 233 | $tar = array(); |
234 | 234 | $filenames = array(); |
235 | 235 | foreach ($files as $extension => $file_contents) { |
236 | - if (!in_array($extension, array('module', 'info'))) { |
|
236 | + if (!in_array($extension, array('module', 'info'))) { |
|
237 | 237 | $extension .= '.inc'; |
238 | - } |
|
239 | - $filenames[] = "{$module_name}.$extension"; |
|
240 | - print features_tar_create("{$module_name}/{$module_name}.$extension", $file_contents); |
|
238 | + } |
|
239 | + $filenames[] = "{$module_name}.$extension"; |
|
240 | + print features_tar_create("{$module_name}/{$module_name}.$extension", $file_contents); |
|
241 | 241 | } |
242 | 242 | if (features_get_modules($module_name, TRUE)) { |
243 | - $module_path = drupal_get_path('module', $module_name); |
|
244 | - // file_scan_directory() can throw warnings when using PHP 5.3, messing |
|
245 | - // up the output of our file stream. Suppress errors in this one case in |
|
246 | - // order to produce valid output. |
|
247 | - foreach (@file_scan_directory($module_path, '.*') as $file) { |
|
243 | + $module_path = drupal_get_path('module', $module_name); |
|
244 | + // file_scan_directory() can throw warnings when using PHP 5.3, messing |
|
245 | + // up the output of our file stream. Suppress errors in this one case in |
|
246 | + // order to produce valid output. |
|
247 | + foreach (@file_scan_directory($module_path, '.*') as $file) { |
|
248 | 248 | $filename = substr($file->filename, strlen($module_path) + 1); |
249 | 249 | if (!in_array($filename, $filenames)) { |
250 | - // Add this file. |
|
251 | - $contents = file_get_contents($file->filename); |
|
252 | - print features_tar_create("{$module_name}/{$filename}", $contents); |
|
253 | - unset($contents); |
|
250 | + // Add this file. |
|
251 | + $contents = file_get_contents($file->filename); |
|
252 | + print features_tar_create("{$module_name}/{$filename}", $contents); |
|
253 | + unset($contents); |
|
254 | + } |
|
254 | 255 | } |
255 | - } |
|
256 | 256 | } |
257 | 257 | print pack("a1024",""); |
258 | 258 | exit; |
259 | - } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
263 | 263 | * AHAH handler for features_export_form_build(). |
264 | 264 | */ |
265 | 265 | function features_export_build_form_populate() { |
266 | - module_load_include('inc', 'features', 'features.export'); |
|
267 | - features_include(); |
|
266 | + module_load_include('inc', 'features', 'features.export'); |
|
267 | + features_include(); |
|
268 | 268 | |
269 | - $form_state = array(); |
|
270 | - $submitted = $_POST; |
|
269 | + $form_state = array(); |
|
270 | + $submitted = $_POST; |
|
271 | 271 | |
272 | - if ($form = form_get_cache($submitted['form_build_id'], $form_state)) { |
|
272 | + if ($form = form_get_cache($submitted['form_build_id'], $form_state)) { |
|
273 | 273 | $stub = array(); |
274 | 274 | |
275 | 275 | // Assemble the combined component list |
276 | 276 | $components = array_keys(features_get_components()); |
277 | 277 | foreach ($components as $component) { |
278 | - // User-selected components take precedence. |
|
279 | - if (!empty($submitted['sources'][$component])) { |
|
278 | + // User-selected components take precedence. |
|
279 | + if (!empty($submitted['sources'][$component])) { |
|
280 | 280 | // Validate and set the default value for each selected option. This |
281 | 281 | foreach ($submitted['sources'][$component] as $key => $value) { |
282 | - if (isset($form['export']['sources'][$component]['#options'][$key])) { |
|
282 | + if (isset($form['export']['sources'][$component]['#options'][$key])) { |
|
283 | 283 | $form['export']['sources'][$component]['#default_value'][$key] = $value; |
284 | - } |
|
284 | + } |
|
285 | 285 | } |
286 | 286 | $stub[$component] = features_dom_decode_options(array_filter($submitted['sources'][$component])); |
287 | - } |
|
288 | - // Only fallback to an existing feature's values if there are no export options for the component. |
|
289 | - else if (!isset($form['export']['sources'][$component]) && !empty($form['#feature']->info['features'][$component])) { |
|
287 | + } |
|
288 | + // Only fallback to an existing feature's values if there are no export options for the component. |
|
289 | + else if (!isset($form['export']['sources'][$component]) && !empty($form['#feature']->info['features'][$component])) { |
|
290 | 290 | $stub[$component] = $form['#feature']->info['features'][$component]; |
291 | - } |
|
291 | + } |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // Assemble dependencies |
@@ -308,59 +308,59 @@ discard block |
||
308 | 308 | |
309 | 309 | drupal_json(array('status' => TRUE, 'data' => $components_rendered . theme('status_messages'))); |
310 | 310 | exit; |
311 | - } |
|
312 | - drupal_json(array('status' => FALSE, 'data' => '')); |
|
313 | - exit; |
|
311 | + } |
|
312 | + drupal_json(array('status' => FALSE, 'data' => '')); |
|
313 | + exit; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * admin/build/features page callback. |
318 | 318 | */ |
319 | 319 | function features_admin_form($form_state) { |
320 | - // Load export functions to use in comparison. |
|
321 | - module_load_include('inc', 'features', 'features.export'); |
|
320 | + // Load export functions to use in comparison. |
|
321 | + module_load_include('inc', 'features', 'features.export'); |
|
322 | 322 | |
323 | - // Clear & rebuild key caches |
|
324 | - module_rebuild_cache(); |
|
325 | - features_rebuild(); |
|
323 | + // Clear & rebuild key caches |
|
324 | + module_rebuild_cache(); |
|
325 | + features_rebuild(); |
|
326 | 326 | |
327 | - features_get_info(NULL, NULL, TRUE); |
|
328 | - $modules = features_get_modules(); |
|
329 | - $features = features_get_features(); |
|
330 | - $conflicts = features_get_conflicts(); |
|
327 | + features_get_info(NULL, NULL, TRUE); |
|
328 | + $modules = features_get_modules(); |
|
329 | + $features = features_get_features(); |
|
330 | + $conflicts = features_get_conflicts(); |
|
331 | 331 | |
332 | - foreach ($modules as $key => $module) { |
|
332 | + foreach ($modules as $key => $module) { |
|
333 | 333 | if ($module->status && !empty($module->info['dependencies'])) { |
334 | - foreach ($module->info['dependencies'] as $dependent) { |
|
334 | + foreach ($module->info['dependencies'] as $dependent) { |
|
335 | 335 | if (isset($features[$dependent])) { |
336 | - $features[$dependent]->dependents[$key] = $module->info['name']; |
|
336 | + $features[$dependent]->dependents[$key] = $module->info['name']; |
|
337 | + } |
|
337 | 338 | } |
338 | - } |
|
339 | 339 | } |
340 | - } |
|
340 | + } |
|
341 | 341 | |
342 | - $form = array( |
|
342 | + $form = array( |
|
343 | 343 | '#features' => $features, |
344 | 344 | '#theme' => 'features_form', |
345 | - ); |
|
345 | + ); |
|
346 | 346 | |
347 | - // Generate features form. |
|
348 | - foreach ($features as $name => $module) { |
|
347 | + // Generate features form. |
|
348 | + foreach ($features as $name => $module) { |
|
349 | 349 | $package_title = !empty($module->info['package']) ? $module->info['package'] : t('Other'); |
350 | 350 | $package = strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $package_title)); |
351 | 351 | |
352 | 352 | // Set up package elements |
353 | 353 | if (!isset($form[$package])) { |
354 | - $form[$package] = array( |
|
354 | + $form[$package] = array( |
|
355 | 355 | '#tree' => FALSE, |
356 | 356 | '#title' => t($package_title), |
357 | 357 | '#theme' => 'features_form_package' |
358 | - ); |
|
359 | - $form[$package]['links'] = |
|
360 | - $form[$package]['version'] = |
|
361 | - $form[$package]['weight'] = |
|
362 | - $form[$package]['status'] = |
|
363 | - $form[$package]['action'] = array('#tree' => TRUE); |
|
358 | + ); |
|
359 | + $form[$package]['links'] = |
|
360 | + $form[$package]['version'] = |
|
361 | + $form[$package]['weight'] = |
|
362 | + $form[$package]['status'] = |
|
363 | + $form[$package]['action'] = array('#tree' => TRUE); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | $disabled = FALSE; |
@@ -368,238 +368,238 @@ discard block |
||
368 | 368 | |
369 | 369 | // Detect unmet dependencies |
370 | 370 | if (!empty($module->info['dependencies'])) { |
371 | - $unmet_dependencies = array(); |
|
372 | - $dependencies = _features_export_maximize_dependencies($module->info['dependencies']); |
|
373 | - foreach ($dependencies as $dependency) { |
|
371 | + $unmet_dependencies = array(); |
|
372 | + $dependencies = _features_export_maximize_dependencies($module->info['dependencies']); |
|
373 | + foreach ($dependencies as $dependency) { |
|
374 | 374 | if (empty($modules[$dependency])) { |
375 | - $unmet_dependencies[] = theme('features_module_status', FEATURES_MODULE_MISSING, $dependency); |
|
375 | + $unmet_dependencies[] = theme('features_module_status', FEATURES_MODULE_MISSING, $dependency); |
|
376 | 376 | } |
377 | - } |
|
378 | - if (!empty($unmet_dependencies)) { |
|
377 | + } |
|
378 | + if (!empty($unmet_dependencies)) { |
|
379 | 379 | $description .= "<div class='dependencies'>". t('Unmet dependencies: !dependencies', array('!dependencies' => implode(', ', $unmet_dependencies))) ."</div>"; |
380 | 380 | $disabled = TRUE; |
381 | - } |
|
381 | + } |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | if (!empty($module->dependents)) { |
385 | - $disabled = TRUE; |
|
386 | - $description .= "<div class='requirements'>". t('Required by: !dependents', array('!dependents' => implode(', ', $module->dependents))) ."</div>"; |
|
385 | + $disabled = TRUE; |
|
386 | + $description .= "<div class='requirements'>". t('Required by: !dependents', array('!dependents' => implode(', ', $module->dependents))) ."</div>"; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // Detect potential conflicts |
390 | 390 | if (!empty($conflicts[$name])) { |
391 | - $module_conflicts = array(); |
|
392 | - foreach (array_keys($conflicts[$name]) as $conflict) { |
|
391 | + $module_conflicts = array(); |
|
392 | + foreach (array_keys($conflicts[$name]) as $conflict) { |
|
393 | 393 | $module_conflicts[] = theme('features_module_status', FEATURES_MODULE_MISSING, $conflict); |
394 | 394 | // Only disable modules with conflicts if they are not already enabled. |
395 | 395 | // If they are already enabled, somehow the user got themselves into a |
396 | 396 | // bad situation and they need to be able to disable a conflicted module. |
397 | 397 | if (module_exists($conflict) && !module_exists($name)) { |
398 | - $disabled = TRUE; |
|
398 | + $disabled = TRUE; |
|
399 | 399 | } |
400 | - } |
|
401 | - $description .= "<div class='conflicts'>". t('Conflicts with: !conflicts', array('!conflicts' => implode(', ', $module_conflicts))) ."</div>"; |
|
400 | + } |
|
401 | + $description .= "<div class='conflicts'>". t('Conflicts with: !conflicts', array('!conflicts' => implode(', ', $module_conflicts))) ."</div>"; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | $form[$package]['status'][$name] = array( |
405 | - '#type' => 'checkbox', |
|
406 | - '#title' => $module->info['name'], |
|
407 | - '#description' => $description, |
|
408 | - '#default_value' => $module->status, |
|
409 | - '#disabled' => $disabled, |
|
405 | + '#type' => 'checkbox', |
|
406 | + '#title' => $module->info['name'], |
|
407 | + '#description' => $description, |
|
408 | + '#default_value' => $module->status, |
|
409 | + '#disabled' => $disabled, |
|
410 | 410 | ); |
411 | 411 | |
412 | 412 | if (!empty($module->info['project status url'])) { |
413 | - $uri = l(truncate_utf8($module->info['project status url'], 35, TRUE, TRUE), $module->info['project status url']); |
|
413 | + $uri = l(truncate_utf8($module->info['project status url'], 35, TRUE, TRUE), $module->info['project status url']); |
|
414 | 414 | } |
415 | 415 | else if (isset($module->info['project'], $module->info['version'], $module->info['datestamp'])) { |
416 | - $uri = l('http://drupal.org', 'http://drupal.org/project/'. $module->info['project']); |
|
416 | + $uri = l('http://drupal.org', 'http://drupal.org/project/'. $module->info['project']); |
|
417 | 417 | } |
418 | 418 | else { |
419 | - $uri = t('Unavailable'); |
|
419 | + $uri = t('Unavailable'); |
|
420 | 420 | } |
421 | 421 | $version = !empty($module->info['version']) ? $module->info['version'] : ''; |
422 | 422 | $version = !empty($version) ? "<div class='description'>$version</div>" : ''; |
423 | 423 | $form[$package]['sign'][$name] = array('#type' => 'markup', '#value' => "{$uri} {$version}"); |
424 | 424 | |
425 | 425 | if (user_access('administer features')) { |
426 | - // Add status link |
|
427 | - $href = "admin/build/features/{$name}"; |
|
428 | - if ($module->status) { |
|
426 | + // Add status link |
|
427 | + $href = "admin/build/features/{$name}"; |
|
428 | + if ($module->status) { |
|
429 | 429 | $state = '<span class="admin-loading features-storage">' . t('Checking...') . '</span>'; |
430 | 430 | $state .= l(t('Check'), "admin/build/features/{$name}/status", array('attributes' => array('class' => 'admin-check'))); |
431 | 431 | $state .= theme('features_storage_link', FEATURES_REBUILDING, NULL, $href); |
432 | 432 | $state .= theme('features_storage_link', FEATURES_NEEDS_REVIEW, NULL, $href); |
433 | 433 | $state .= theme('features_storage_link', FEATURES_OVERRIDDEN, NULL, $href); |
434 | 434 | $state .= theme('features_storage_link', FEATURES_DEFAULT, NULL, $href); |
435 | - } |
|
436 | - elseif (!empty($conflicts[$name])) { |
|
435 | + } |
|
436 | + elseif (!empty($conflicts[$name])) { |
|
437 | 437 | $state = theme('features_storage_link', FEATURES_CONFLICT, NULL, $href); |
438 | - } |
|
439 | - else { |
|
438 | + } |
|
439 | + else { |
|
440 | 440 | $state = theme('features_storage_link', FEATURES_DISABLED, NULL, $href); |
441 | - } |
|
442 | - $form[$package]['state'][$name] = array( |
|
441 | + } |
|
442 | + $form[$package]['state'][$name] = array( |
|
443 | 443 | '#type' => 'markup', |
444 | 444 | '#value' => !empty($state) ? $state : '', |
445 | - ); |
|
445 | + ); |
|
446 | 446 | |
447 | - // Add in recreate link |
|
448 | - $form[$package]['actions'][$name] = array( |
|
447 | + // Add in recreate link |
|
448 | + $form[$package]['actions'][$name] = array( |
|
449 | 449 | '#type' => 'markup', |
450 | 450 | '#value' => l(t('Recreate'), "admin/build/features/{$name}/recreate", array('attributes' => array('class' => 'admin-update'))), |
451 | - ); |
|
451 | + ); |
|
452 | + } |
|
452 | 453 | } |
453 | - } |
|
454 | 454 | |
455 | - $form['buttons'] = array( |
|
455 | + $form['buttons'] = array( |
|
456 | 456 | '#theme' => 'features_form_buttons', |
457 | - ); |
|
458 | - $form['buttons']['submit'] = array( |
|
457 | + ); |
|
458 | + $form['buttons']['submit'] = array( |
|
459 | 459 | '#type' => 'submit', |
460 | 460 | '#value' => t('Save settings'), |
461 | 461 | '#submit' => array('features_form_submit'), |
462 | 462 | '#validate' => array('features_form_validate'), |
463 | - ); |
|
464 | - return $form; |
|
463 | + ); |
|
464 | + return $form; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
468 | 468 | * Display the components of a feature. |
469 | 469 | */ |
470 | 470 | function features_admin_components($form_state, $feature) { |
471 | - module_load_include('inc', 'features', 'features.export'); |
|
472 | - $form = array(); |
|
473 | - |
|
474 | - // Store feature info for theme layer. |
|
475 | - $form['module'] = array('#type' => 'value', '#value' => $feature->name); |
|
476 | - $form['#info'] = $feature->info; |
|
477 | - $form['#dependencies'] = array(); |
|
478 | - if (!empty($feature->info['dependencies'])) { |
|
471 | + module_load_include('inc', 'features', 'features.export'); |
|
472 | + $form = array(); |
|
473 | + |
|
474 | + // Store feature info for theme layer. |
|
475 | + $form['module'] = array('#type' => 'value', '#value' => $feature->name); |
|
476 | + $form['#info'] = $feature->info; |
|
477 | + $form['#dependencies'] = array(); |
|
478 | + if (!empty($feature->info['dependencies'])) { |
|
479 | 479 | foreach ($feature->info['dependencies'] as $dependency) { |
480 | - $status = features_get_module_status($dependency); |
|
481 | - $form['#dependencies'][$dependency] = $status; |
|
480 | + $status = features_get_module_status($dependency); |
|
481 | + $form['#dependencies'][$dependency] = $status; |
|
482 | + } |
|
482 | 483 | } |
483 | - } |
|
484 | 484 | |
485 | - $review = $revert = FALSE; |
|
485 | + $review = $revert = FALSE; |
|
486 | 486 | |
487 | - // Iterate over components and retrieve status for display |
|
488 | - $states = features_get_component_states(array($feature->name), FALSE); |
|
489 | - $form['revert']['#tree'] = TRUE; |
|
490 | - foreach ($feature->info['features'] as $component => $items) { |
|
487 | + // Iterate over components and retrieve status for display |
|
488 | + $states = features_get_component_states(array($feature->name), FALSE); |
|
489 | + $form['revert']['#tree'] = TRUE; |
|
490 | + foreach ($feature->info['features'] as $component => $items) { |
|
491 | 491 | if (user_access('administer features') && in_array($states[$feature->name][$component], array(FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW))) { |
492 | - switch ($states[$feature->name][$component]) { |
|
492 | + switch ($states[$feature->name][$component]) { |
|
493 | 493 | case FEATURES_OVERRIDDEN: |
494 | 494 | $revert = TRUE; |
495 | - break; |
|
495 | + break; |
|
496 | 496 | case FEATURES_NEEDS_REVIEW: |
497 | 497 | $review = TRUE; |
498 | - break; |
|
499 | - } |
|
500 | - $form['revert'][$component] = array( |
|
498 | + break; |
|
499 | + } |
|
500 | + $form['revert'][$component] = array( |
|
501 | 501 | '#type' => 'checkbox', |
502 | 502 | '#default_value' => FALSE, |
503 | - ); |
|
503 | + ); |
|
504 | 504 | } |
505 | 505 | if (module_exists('diff')) { |
506 | - $item = menu_get_item("admin/build/features/{$feature->name}/diff/{$component}"); |
|
507 | - $path = ($item && $item['access']) ? $item['href'] : NULL; |
|
506 | + $item = menu_get_item("admin/build/features/{$feature->name}/diff/{$component}"); |
|
507 | + $path = ($item && $item['access']) ? $item['href'] : NULL; |
|
508 | 508 | } |
509 | 509 | else { |
510 | - $path = NULL; |
|
510 | + $path = NULL; |
|
511 | 511 | } |
512 | 512 | $form['components'][$component] = array( |
513 | - '#type' => 'markup', |
|
514 | - '#value' => theme('features_storage_link', $states[$feature->name][$component], NULL, $path), |
|
513 | + '#type' => 'markup', |
|
514 | + '#value' => theme('features_storage_link', $states[$feature->name][$component], NULL, $path), |
|
515 | 515 | ); |
516 | - } |
|
516 | + } |
|
517 | 517 | |
518 | - if ($review || $revert) { |
|
518 | + if ($review || $revert) { |
|
519 | 519 | $form['buttons'] = array('#theme' => 'features_form_buttons', '#tree' => TRUE); |
520 | 520 | if ($revert || $review) { |
521 | - $form['buttons']['revert'] = array( |
|
521 | + $form['buttons']['revert'] = array( |
|
522 | 522 | '#type' => 'submit', |
523 | 523 | '#value' => t('Revert components'), |
524 | 524 | '#submit' => array('features_admin_components_revert'), |
525 | - ); |
|
525 | + ); |
|
526 | 526 | } |
527 | 527 | if ($review) { |
528 | - $form['buttons']['review'] = array( |
|
528 | + $form['buttons']['review'] = array( |
|
529 | 529 | '#type' => 'submit', |
530 | 530 | '#value' => t('Mark as reviewed'), |
531 | 531 | '#submit' => array('features_admin_components_review'), |
532 | - ); |
|
532 | + ); |
|
533 | 533 | } |
534 | - } |
|
535 | - return $form; |
|
534 | + } |
|
535 | + return $form; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
539 | 539 | * Submit handler for revert form. |
540 | 540 | */ |
541 | 541 | function features_admin_components_revert(&$form, &$form_state) { |
542 | - module_load_include('inc', 'features', 'features.export'); |
|
543 | - features_include(); |
|
544 | - $module = $form_state['values']['module']; |
|
545 | - $revert = array(); |
|
546 | - foreach (array_filter($form_state['values']['revert']) as $component => $status) { |
|
542 | + module_load_include('inc', 'features', 'features.export'); |
|
543 | + features_include(); |
|
544 | + $module = $form_state['values']['module']; |
|
545 | + $revert = array(); |
|
546 | + foreach (array_filter($form_state['values']['revert']) as $component => $status) { |
|
547 | 547 | $revert[$module][] = $component; |
548 | 548 | drupal_set_message(t('Reverted all <strong>!component</strong> components for <strong>!module</strong>.', array('!component' => $component, '!module' => $module))); |
549 | - } |
|
550 | - features_revert($revert); |
|
551 | - $form_state['redirect'] = 'admin/build/features/'. $module; |
|
549 | + } |
|
550 | + features_revert($revert); |
|
551 | + $form_state['redirect'] = 'admin/build/features/'. $module; |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
555 | 555 | * Submit handler for revert form. |
556 | 556 | */ |
557 | 557 | function features_admin_components_review(&$form, &$form_state) { |
558 | - module_load_include('inc', 'features', 'features.export'); |
|
559 | - features_include(); |
|
560 | - $module = $form_state['values']['module']; |
|
561 | - $revert = array(); |
|
562 | - foreach (array_filter($form_state['values']['revert']) as $component => $status) { |
|
558 | + module_load_include('inc', 'features', 'features.export'); |
|
559 | + features_include(); |
|
560 | + $module = $form_state['values']['module']; |
|
561 | + $revert = array(); |
|
562 | + foreach (array_filter($form_state['values']['revert']) as $component => $status) { |
|
563 | 563 | features_set_signature($module, $component); |
564 | 564 | drupal_set_message(t('All <strong>!component</strong> components for <strong>!module</strong> reviewed.', array('!component' => $component, '!module' => $module))); |
565 | - } |
|
566 | - $form_state['redirect'] = 'admin/build/features/'. $module; |
|
565 | + } |
|
566 | + $form_state['redirect'] = 'admin/build/features/'. $module; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
570 | 570 | * Validate handler for the 'manage features' form. |
571 | 571 | */ |
572 | 572 | function features_form_validate(&$form, &$form_state) { |
573 | - include_once './includes/install.inc'; |
|
574 | - $conflicts = features_get_conflicts(); |
|
575 | - foreach ($form_state['values']['status'] as $module => $status) { |
|
573 | + include_once './includes/install.inc'; |
|
574 | + $conflicts = features_get_conflicts(); |
|
575 | + foreach ($form_state['values']['status'] as $module => $status) { |
|
576 | 576 | if ($status) { |
577 | - if (!empty($conflicts[$module])) { |
|
577 | + if (!empty($conflicts[$module])) { |
|
578 | 578 | foreach (array_keys($conflicts[$module]) as $conflict) { |
579 | - if (!empty($form_state['values']['status'][$conflict])) { |
|
579 | + if (!empty($form_state['values']['status'][$conflict])) { |
|
580 | 580 | form_set_error('status', t('The feature !module cannot be enabled because it conflicts with !conflict.', array('!module' => $module, '!conflict' => $conflict))); |
581 | - } |
|
581 | + } |
|
582 | + } |
|
582 | 583 | } |
583 | - } |
|
584 | - if (!drupal_check_module($module)) { |
|
584 | + if (!drupal_check_module($module)) { |
|
585 | 585 | form_set_error('status', t('The feature !module cannot be enabled because it has unmet requirements.', array('!module' => $module, '!conflict' => $conflict))); |
586 | - } |
|
586 | + } |
|
587 | + } |
|
587 | 588 | } |
588 | - } |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
592 | 592 | * Submit handler for the 'manage features' form |
593 | 593 | */ |
594 | 594 | function features_form_submit(&$form, &$form_state) { |
595 | - // Clear drupal caches after enabling a feature. We do this in a separate |
|
596 | - // page callback rather than as part of the submit handler as some modules |
|
597 | - // have includes/other directives of importance in hooks that have already |
|
598 | - // been called in this page load. |
|
599 | - $form_state['redirect'] = array('admin/build/features/cleanup/clear', array('token' => drupal_get_token())); |
|
600 | - |
|
601 | - $features = $form['#features']; |
|
602 | - if (!empty($features)) { |
|
595 | + // Clear drupal caches after enabling a feature. We do this in a separate |
|
596 | + // page callback rather than as part of the submit handler as some modules |
|
597 | + // have includes/other directives of importance in hooks that have already |
|
598 | + // been called in this page load. |
|
599 | + $form_state['redirect'] = array('admin/build/features/cleanup/clear', array('token' => drupal_get_token())); |
|
600 | + |
|
601 | + $features = $form['#features']; |
|
602 | + if (!empty($features)) { |
|
603 | 603 | $status = $form_state['values']['status']; |
604 | 604 | $install = array_keys(array_filter($status)); |
605 | 605 | $disable = array_diff(array_keys($status), $install); |
@@ -609,17 +609,17 @@ discard block |
||
609 | 609 | // be re-enabled. |
610 | 610 | module_disable($disable); |
611 | 611 | features_install_modules($install); |
612 | - } |
|
612 | + } |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
616 | 616 | * Form for disabling orphaned dependencies. |
617 | 617 | */ |
618 | 618 | function features_cleanup_form($form_state, $cache_clear = FALSE) { |
619 | - $form = array(); |
|
619 | + $form = array(); |
|
620 | 620 | |
621 | - // Clear caches if we're getting a post-submit redirect that requests it. |
|
622 | - if ($cache_clear && !empty($_GET['token']) && drupal_valid_token($_GET['token'])) { |
|
621 | + // Clear caches if we're getting a post-submit redirect that requests it. |
|
622 | + if ($cache_clear && !empty($_GET['token']) && drupal_valid_token($_GET['token'])) { |
|
623 | 623 | drupal_flush_all_caches(); |
624 | 624 | |
625 | 625 | // The following functions need to be run because drupal_flush_all_caches() |
@@ -627,52 +627,52 @@ discard block |
||
627 | 627 | // the menu is rebuilt, meaning that the menu tree is stale in certain |
628 | 628 | // circumstances after drupal_flush_all_caches(). We rebuild again. |
629 | 629 | menu_rebuild(); |
630 | - } |
|
631 | - |
|
632 | - // Retrieve orphaned modules and provide them as optional modules to be disabled. |
|
633 | - // Exclude any modules that have been added to the 'ignored' list. |
|
634 | - $options = array(); |
|
635 | - $orphans = features_get_orphans(); |
|
636 | - $ignored = variable_get('features_ignored_orphans', array()); |
|
637 | - if (!empty($orphans)) { |
|
630 | + } |
|
631 | + |
|
632 | + // Retrieve orphaned modules and provide them as optional modules to be disabled. |
|
633 | + // Exclude any modules that have been added to the 'ignored' list. |
|
634 | + $options = array(); |
|
635 | + $orphans = features_get_orphans(); |
|
636 | + $ignored = variable_get('features_ignored_orphans', array()); |
|
637 | + if (!empty($orphans)) { |
|
638 | 638 | foreach ($orphans as $module) { |
639 | - if (!in_array($module->name, $ignored, TRUE)) { |
|
639 | + if (!in_array($module->name, $ignored, TRUE)) { |
|
640 | 640 | $options[$module->name] = check_plain($module->info['name']); |
641 | - } |
|
641 | + } |
|
642 | + } |
|
642 | 643 | } |
643 | - } |
|
644 | 644 | |
645 | - if (!empty($options)) { |
|
645 | + if (!empty($options)) { |
|
646 | 646 | $form['orphans'] = array( |
647 | - '#title' => t('Orphaned dependencies'), |
|
648 | - '#description' => t('These modules are dependencies of features that have been disabled. They may be disabled without affecting other components of your website.'), |
|
649 | - '#type' => 'checkboxes', |
|
650 | - '#options' => $options, |
|
651 | - '#default_value' => array_keys($options), |
|
647 | + '#title' => t('Orphaned dependencies'), |
|
648 | + '#description' => t('These modules are dependencies of features that have been disabled. They may be disabled without affecting other components of your website.'), |
|
649 | + '#type' => 'checkboxes', |
|
650 | + '#options' => $options, |
|
651 | + '#default_value' => array_keys($options), |
|
652 | 652 | ); |
653 | 653 | $form['buttons'] = array('#tree' => TRUE, '#theme' => 'features_form_buttons'); |
654 | 654 | $form['buttons']['disable'] = array( |
655 | - '#type' => 'submit', |
|
656 | - '#value' => t('Disable selected modules'), |
|
657 | - '#submit' => array('features_cleanup_form_disable'), |
|
655 | + '#type' => 'submit', |
|
656 | + '#value' => t('Disable selected modules'), |
|
657 | + '#submit' => array('features_cleanup_form_disable'), |
|
658 | 658 | ); |
659 | 659 | $form['buttons']['ignore'] = array( |
660 | - '#type' => 'submit', |
|
661 | - '#value' => t('Leave enabled'), |
|
662 | - '#submit' => array('features_cleanup_form_ignore'), |
|
660 | + '#type' => 'submit', |
|
661 | + '#value' => t('Leave enabled'), |
|
662 | + '#submit' => array('features_cleanup_form_ignore'), |
|
663 | 663 | ); |
664 | - } |
|
665 | - else { |
|
664 | + } |
|
665 | + else { |
|
666 | 666 | drupal_goto('admin/build/features'); |
667 | - } |
|
668 | - return $form; |
|
667 | + } |
|
668 | + return $form; |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
672 | 672 | * Submit handler for disable action on features_cleanup_form(). |
673 | 673 | */ |
674 | 674 | function features_cleanup_form_disable(&$form, &$form_state) { |
675 | - if (!empty($form_state['values']['orphans'])) { |
|
675 | + if (!empty($form_state['values']['orphans'])) { |
|
676 | 676 | $disable = array_keys(array_filter($form_state['values']['orphans'])); |
677 | 677 | $ignored = array_diff(array_keys($form_state['values']['orphans']), $disable); |
678 | 678 | |
@@ -683,26 +683,26 @@ discard block |
||
683 | 683 | // Add enabled modules to ignored orphans list. |
684 | 684 | $ignored_orphans = variable_get('features_ignored_orphans', array()); |
685 | 685 | foreach ($ignored as $module) { |
686 | - $ignored_orphans[$module] = $module; |
|
686 | + $ignored_orphans[$module] = $module; |
|
687 | 687 | } |
688 | 688 | variable_set('features_ignored_orphans', $ignored_orphans); |
689 | - } |
|
690 | - $form_state['redirect'] = 'admin/build/features/cleanup'; |
|
689 | + } |
|
690 | + $form_state['redirect'] = 'admin/build/features/cleanup'; |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
694 | 694 | * Submit handler for ignore action on features_cleanup_form(). |
695 | 695 | */ |
696 | 696 | function features_cleanup_form_ignore(&$form, &$form_state) { |
697 | - if (!empty($form_state['values']['orphans'])) { |
|
697 | + if (!empty($form_state['values']['orphans'])) { |
|
698 | 698 | $ignored = array_keys($form_state['values']['orphans']); |
699 | 699 | $ignored_orphans = variable_get('features_ignored_orphans', array()); |
700 | 700 | foreach ($ignored as $module) { |
701 | - $ignored_orphans[$module] = $module; |
|
701 | + $ignored_orphans[$module] = $module; |
|
702 | 702 | } |
703 | 703 | variable_set('features_ignored_orphans', $ignored_orphans); |
704 | - } |
|
705 | - $form_state['redirect'] = 'admin/build/features/cleanup'; |
|
704 | + } |
|
705 | + $form_state['redirect'] = 'admin/build/features/cleanup'; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -717,52 +717,52 @@ discard block |
||
717 | 717 | * @return Themed display of what is different. |
718 | 718 | */ |
719 | 719 | function features_feature_diff($feature, $component = NULL) { |
720 | - drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
721 | - module_load_include('inc', 'features', 'features.export'); |
|
720 | + drupal_add_css(drupal_get_path('module', 'features') .'/features.css'); |
|
721 | + module_load_include('inc', 'features', 'features.export'); |
|
722 | 722 | |
723 | - $overrides = features_detect_overrides($feature); |
|
723 | + $overrides = features_detect_overrides($feature); |
|
724 | 724 | |
725 | - $output = ''; |
|
726 | - if (!empty($overrides)) { |
|
725 | + $output = ''; |
|
726 | + if (!empty($overrides)) { |
|
727 | 727 | // Filter overrides down to specified component. |
728 | 728 | if (isset($component) && isset($overrides[$component])) { |
729 | - $overrides = array($component => $overrides[$component]); |
|
729 | + $overrides = array($component => $overrides[$component]); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | module_load_include('php', 'diff', 'DiffEngine'); |
733 | 733 | $formatter = new DrupalDiffFormatter(); |
734 | 734 | $rows = array(); |
735 | 735 | foreach ($overrides as $component => $items) { |
736 | - $diff = new Diff(explode("\n", $items['default']), explode("\n", $items['normal'])); |
|
737 | - $rows[] = array(array('data' => $component, 'colspan' => 4, 'header' => TRUE)); |
|
738 | - $rows = array_merge($rows, $formatter->format($diff)); |
|
736 | + $diff = new Diff(explode("\n", $items['default']), explode("\n", $items['normal'])); |
|
737 | + $rows[] = array(array('data' => $component, 'colspan' => 4, 'header' => TRUE)); |
|
738 | + $rows = array_merge($rows, $formatter->format($diff)); |
|
739 | 739 | } |
740 | 740 | $header = array( |
741 | - array('data' => t('Default'), 'colspan' => 2), |
|
742 | - array('data' => t('Overrides'), 'colspan' => 2), |
|
741 | + array('data' => t('Default'), 'colspan' => 2), |
|
742 | + array('data' => t('Overrides'), 'colspan' => 2), |
|
743 | 743 | ); |
744 | 744 | $output .= theme('diff_table', $header, $rows, array('class' => 'diff features-diff')); |
745 | - } |
|
746 | - else { |
|
745 | + } |
|
746 | + else { |
|
747 | 747 | $output = "<div class='features-empty'>". t('No changes have been made to this feature.') ."</div>"; |
748 | - } |
|
749 | - $output = "<div class='features-comparison'>{$output}</div>"; |
|
750 | - return $output; |
|
748 | + } |
|
749 | + $output = "<div class='features-comparison'>{$output}</div>"; |
|
750 | + return $output; |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | /** |
754 | 754 | * Compare the component names. Used to sort alphabetically. |
755 | 755 | */ |
756 | 756 | function features_compare_component_name($a, $b) { |
757 | - return strcasecmp($a['name'], $b['name']); |
|
757 | + return strcasecmp($a['name'], $b['name']); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
761 | 761 | * Javascript call back that returns the status of a feature. |
762 | 762 | */ |
763 | 763 | function features_feature_status($feature) { |
764 | - module_load_include('inc', 'features', 'features.export'); |
|
765 | - return drupal_json(array('storage' => features_get_storage($feature->name))); |
|
764 | + module_load_include('inc', 'features', 'features.export'); |
|
765 | + return drupal_json(array('storage' => features_get_storage($feature->name))); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -771,19 +771,19 @@ discard block |
||
771 | 771 | * safely referenced by JS behaviors. |
772 | 772 | */ |
773 | 773 | function features_dom_encode_options($options = array(), $keys_only = TRUE) { |
774 | - $replacements = array( |
|
774 | + $replacements = array( |
|
775 | 775 | ':' => '__'. ord(':') .'__', |
776 | 776 | '/' => '__'. ord('/') .'__', |
777 | 777 | ',' => '__'. ord(',') .'__', |
778 | 778 | '.' => '__'. ord(',') .'__', |
779 | 779 | '<' => '__'. ord('<') .'__', |
780 | 780 | '>' => '__'. ord('>') .'__', |
781 | - ); |
|
782 | - $encoded = array(); |
|
783 | - foreach ($options as $key => $value) { |
|
781 | + ); |
|
782 | + $encoded = array(); |
|
783 | + foreach ($options as $key => $value) { |
|
784 | 784 | $encoded[strtr($key, $replacements)] = $keys_only ? $value : strtr($value, $replacements); |
785 | - } |
|
786 | - return $encoded; |
|
785 | + } |
|
786 | + return $encoded; |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -791,17 +791,17 @@ discard block |
||
791 | 791 | * features_dom_encode_options(). |
792 | 792 | */ |
793 | 793 | function features_dom_decode_options($options, $keys_only = FALSE) { |
794 | - $replacements = array_flip(array( |
|
794 | + $replacements = array_flip(array( |
|
795 | 795 | ':' => '__'. ord(':') .'__', |
796 | 796 | '/' => '__'. ord('/') .'__', |
797 | 797 | ',' => '__'. ord(',') .'__', |
798 | 798 | '.' => '__'. ord(',') .'__', |
799 | 799 | '<' => '__'. ord('<') .'__', |
800 | 800 | '>' => '__'. ord('>') .'__', |
801 | - )); |
|
802 | - $encoded = array(); |
|
803 | - foreach ($options as $key => $value) { |
|
801 | + )); |
|
802 | + $encoded = array(); |
|
803 | + foreach ($options as $key => $value) { |
|
804 | 804 | $encoded[strtr($key, $replacements)] = $keys_only ? $value : strtr($value, $replacements); |
805 | - } |
|
806 | - return $encoded; |
|
805 | + } |
|
806 | + return $encoded; |
|
807 | 807 | } |
@@ -16,71 +16,71 @@ discard block |
||
16 | 16 | * Implementation of hook_perm(). |
17 | 17 | */ |
18 | 18 | function panels_node_perm() { |
19 | - return array('create panel-nodes', 'edit any panel-nodes', 'edit own panel-nodes', 'administer panel-nodes', 'delete any panel-nodes', 'delete own panel-nodes'); |
|
19 | + return array('create panel-nodes', 'edit any panel-nodes', 'edit own panel-nodes', 'administer panel-nodes', 'delete any panel-nodes', 'delete own panel-nodes'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Implementation of hook_ctools_plugin_directory(). |
24 | 24 | */ |
25 | 25 | function panels_node_ctools_plugin_directory($module, $plugin) { |
26 | - if ($module == 'panels' && $plugin == 'panels_storage') { |
|
26 | + if ($module == 'panels' && $plugin == 'panels_storage') { |
|
27 | 27 | return 'plugins/' . $plugin; |
28 | - } |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Implementation of hook_menu(). |
33 | 33 | */ |
34 | 34 | function panels_node_menu() { |
35 | - // Safety: go away if CTools is not at an appropriate version. |
|
36 | - if (!defined('PANELS_REQUIRED_CTOOLS_API') || !module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) { |
|
35 | + // Safety: go away if CTools is not at an appropriate version. |
|
36 | + if (!defined('PANELS_REQUIRED_CTOOLS_API') || !module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) { |
|
37 | 37 | return array(); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - $items['admin/build/panels/settings/panel-node'] = array( |
|
40 | + $items['admin/build/panels/settings/panel-node'] = array( |
|
41 | 41 | 'title' => 'Panel nodes', |
42 | 42 | 'description' => 'Configure which content is available to add to panel node displays.', |
43 | 43 | 'access arguments' => array('administer panel-nodes'), |
44 | 44 | 'page callback' => 'panels_node_settings', |
45 | 45 | 'type' => MENU_LOCAL_TASK, |
46 | - ); |
|
46 | + ); |
|
47 | 47 | |
48 | - // Avoid some repetition on these: |
|
49 | - $base = array( |
|
48 | + // Avoid some repetition on these: |
|
49 | + $base = array( |
|
50 | 50 | 'access callback' => 'panels_node_edit_node', |
51 | 51 | 'access arguments' => array(1), |
52 | 52 | 'page arguments' => array(1), |
53 | 53 | 'type' => MENU_LOCAL_TASK, |
54 | - ); |
|
54 | + ); |
|
55 | 55 | |
56 | - $items['node/%node/panel_layout'] = array( |
|
56 | + $items['node/%node/panel_layout'] = array( |
|
57 | 57 | 'title' => 'Panel layout', |
58 | 58 | 'page callback' => 'panels_node_edit_layout', |
59 | 59 | 'weight' => 2, |
60 | - ) + $base; |
|
60 | + ) + $base; |
|
61 | 61 | |
62 | - $items['node/%node/panel_content'] = array( |
|
62 | + $items['node/%node/panel_content'] = array( |
|
63 | 63 | 'title' => 'Panel content', |
64 | 64 | 'page callback' => 'panels_node_edit_content', |
65 | 65 | 'weight' => 3, |
66 | - ) + $base; |
|
66 | + ) + $base; |
|
67 | 67 | |
68 | - $items['node/add/panel/choose-layout'] = array( |
|
68 | + $items['node/add/panel/choose-layout'] = array( |
|
69 | 69 | 'title' => 'Choose layout', |
70 | 70 | 'access arguments' => array('create panel-nodes'), |
71 | 71 | 'page callback' => 'panels_node_add', |
72 | 72 | 'type' => MENU_CALLBACK, |
73 | - ); |
|
73 | + ); |
|
74 | 74 | |
75 | - return $items; |
|
75 | + return $items; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | function panels_node_edit_node($node) { |
79 | - if (!isset($node->panels_node)) { |
|
79 | + if (!isset($node->panels_node)) { |
|
80 | 80 | return FALSE; |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - return node_access('update', $node); |
|
83 | + return node_access('update', $node); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // --------------------------------------------------------------------------- |
@@ -90,155 +90,155 @@ discard block |
||
90 | 90 | * Implementation of hook_node_info(). |
91 | 91 | */ |
92 | 92 | function panels_node_node_info() { |
93 | - // Safety: go away if CTools is not at an appropriate version. |
|
94 | - if (!defined('PANELS_REQUIRED_CTOOLS_API') || !module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) { |
|
93 | + // Safety: go away if CTools is not at an appropriate version. |
|
94 | + if (!defined('PANELS_REQUIRED_CTOOLS_API') || !module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) { |
|
95 | 95 | return array(); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - return array( |
|
98 | + return array( |
|
99 | 99 | 'panel' => array( |
100 | - 'name' => t('Panel'), |
|
101 | - 'module' => 'panels_node', |
|
102 | - 'body_label' => t('Teaser'), |
|
103 | - 'description' => t("A panel layout broken up into rows and columns."), |
|
100 | + 'name' => t('Panel'), |
|
101 | + 'module' => 'panels_node', |
|
102 | + 'body_label' => t('Teaser'), |
|
103 | + 'description' => t("A panel layout broken up into rows and columns."), |
|
104 | 104 | ), |
105 | - ); |
|
105 | + ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Implementation of hook_access(). |
110 | 110 | */ |
111 | 111 | function panels_node_access($op, $node, $account) { |
112 | - if (user_access('administer panel-nodes', $account)) { |
|
112 | + if (user_access('administer panel-nodes', $account)) { |
|
113 | 113 | return TRUE; |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | - if ($op == 'create' && user_access('create panel-nodes', $account)) { |
|
116 | + if ($op == 'create' && user_access('create panel-nodes', $account)) { |
|
117 | 117 | return TRUE; |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - if ($op == 'update' && (user_access('edit any panel-nodes', $account) || $node->uid == $account->uid && user_access('edit own panel-nodes', $account))) { |
|
120 | + if ($op == 'update' && (user_access('edit any panel-nodes', $account) || $node->uid == $account->uid && user_access('edit own panel-nodes', $account))) { |
|
121 | 121 | return TRUE; |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - if ($op == 'delete' && (user_access('delete any panel-nodes') || $node->uid == $account->uid && user_access('delete own panel-nodes'))) { |
|
125 | + if ($op == 'delete' && (user_access('delete any panel-nodes') || $node->uid == $account->uid && user_access('delete own panel-nodes'))) { |
|
126 | 126 | return TRUE; |
127 | - } |
|
127 | + } |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function panels_node_add() { |
131 | - $output = ''; |
|
131 | + $output = ''; |
|
132 | 132 | |
133 | - ctools_include('plugins', 'panels'); |
|
134 | - ctools_include('common', 'panels'); |
|
133 | + ctools_include('plugins', 'panels'); |
|
134 | + ctools_include('common', 'panels'); |
|
135 | 135 | |
136 | - $layouts = panels_common_get_allowed_layouts('panels_node'); |
|
137 | - return panels_common_print_layout_links($layouts, 'node/add/panel', array('query' => $_GET)); |
|
136 | + $layouts = panels_common_get_allowed_layouts('panels_node'); |
|
137 | + return panels_common_print_layout_links($layouts, 'node/add/panel', array('query' => $_GET)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Implementation of hook_form(). |
142 | 142 | */ |
143 | 143 | function panels_node_form(&$node, &$param) { |
144 | - ctools_include('plugins', 'panels'); |
|
144 | + ctools_include('plugins', 'panels'); |
|
145 | 145 | |
146 | - $form['panels_node']['#tree'] = TRUE; |
|
147 | - if (empty($node->nid) && arg(0) == 'node' && arg(1) == 'add') { |
|
146 | + $form['panels_node']['#tree'] = TRUE; |
|
147 | + if (empty($node->nid) && arg(0) == 'node' && arg(1) == 'add') { |
|
148 | 148 | // Grab our selected layout from the $node, If it doesn't exist, try arg(3) |
149 | 149 | // and if that doesn't work present them with a list to pick from. |
150 | 150 | $panel_layout = isset($node->panel_layout) ? $node->panel_layout : arg(3); |
151 | 151 | if (empty($panel_layout)) { |
152 | - $opts = $_GET; |
|
153 | - unset($opts['q']); |
|
154 | - return drupal_goto('node/add/panel/choose-layout', $opts); |
|
152 | + $opts = $_GET; |
|
153 | + unset($opts['q']); |
|
154 | + return drupal_goto('node/add/panel/choose-layout', $opts); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $layout = panels_get_layout($panel_layout); |
158 | 158 | if (empty($layout)) { |
159 | - return drupal_not_found(); |
|
159 | + return drupal_not_found(); |
|
160 | 160 | } |
161 | 161 | $form['panels_node']['layout'] = array( |
162 | - '#type' => 'value', |
|
163 | - '#value' => $panel_layout, |
|
162 | + '#type' => 'value', |
|
163 | + '#value' => $panel_layout, |
|
164 | 164 | ); |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - $type = node_get_types('type', $node); |
|
167 | + $type = node_get_types('type', $node); |
|
168 | 168 | |
169 | - $form['title'] = array( |
|
169 | + $form['title'] = array( |
|
170 | 170 | '#type' => 'textfield', |
171 | 171 | '#title' => check_plain($type->title_label), |
172 | 172 | '#required' => TRUE, |
173 | 173 | '#default_value' => $node->title, |
174 | - ); |
|
174 | + ); |
|
175 | 175 | |
176 | - if (!empty($type->body_label)) { |
|
176 | + if (!empty($type->body_label)) { |
|
177 | 177 | $form['body_field']['#prefix'] = '<div class="body-field-wrapper">'; |
178 | 178 | $form['body_field']['#suffix'] = '</div>'; |
179 | 179 | $form['body_field']['body'] = array( |
180 | - '#type' => 'textarea', |
|
181 | - '#title' => check_plain($type->body_label), |
|
182 | - '#rows' => 10, |
|
183 | - '#required' => TRUE, |
|
184 | - '#description' => t('The teaser is a piece of text to describe when the panel is listed (such as when promoted to front page); the actual content will only be displayed on the full node view.'), |
|
185 | - '#default_value' => $node->body, |
|
180 | + '#type' => 'textarea', |
|
181 | + '#title' => check_plain($type->body_label), |
|
182 | + '#rows' => 10, |
|
183 | + '#required' => TRUE, |
|
184 | + '#description' => t('The teaser is a piece of text to describe when the panel is listed (such as when promoted to front page); the actual content will only be displayed on the full node view.'), |
|
185 | + '#default_value' => $node->body, |
|
186 | 186 | ); |
187 | 187 | $form['body_field']['format'] = filter_form($node->format); // Now we can set the format! |
188 | - } |
|
188 | + } |
|
189 | 189 | |
190 | 190 | // drupal_set_message('<pre>' . check_plain(var_export($node, true)) . '</pre>'); |
191 | - $css_id = ''; |
|
192 | - if (!empty($node->panels_node['css_id'])) { |
|
191 | + $css_id = ''; |
|
192 | + if (!empty($node->panels_node['css_id'])) { |
|
193 | 193 | $css_id = $node->panels_node['css_id']; |
194 | - } |
|
194 | + } |
|
195 | 195 | |
196 | - $form['panels_node']['css_id'] = array( |
|
196 | + $form['panels_node']['css_id'] = array( |
|
197 | 197 | '#type' => 'textfield', |
198 | 198 | '#title' => t('CSS ID'), |
199 | 199 | '#size' => 30, |
200 | 200 | '#description' => t('An ID that can be used by CSS to style the panel.'), |
201 | 201 | '#default_value' => $css_id, |
202 | - ); |
|
202 | + ); |
|
203 | 203 | |
204 | - // Support for different rendering pipelines |
|
205 | - // Mostly borrowed from panel_context.inc |
|
206 | - $pipelines = panels_get_renderer_pipelines(); |
|
204 | + // Support for different rendering pipelines |
|
205 | + // Mostly borrowed from panel_context.inc |
|
206 | + $pipelines = panels_get_renderer_pipelines(); |
|
207 | 207 | |
208 | - // If there are no pipelines, that probably means we're operating in |
|
209 | - // legacy mode. |
|
210 | - if (empty($pipelines)) { |
|
208 | + // If there are no pipelines, that probably means we're operating in |
|
209 | + // legacy mode. |
|
210 | + if (empty($pipelines)) { |
|
211 | 211 | // We retain the original pipeline so we don't wreck things by installing |
212 | 212 | // old modules. |
213 | 213 | $form['panels_node']['pipeline'] = array( |
214 | - '#type' => 'value', |
|
215 | - '#value' => $node->panels_node['pipeline'], |
|
214 | + '#type' => 'value', |
|
215 | + '#value' => $node->panels_node['pipeline'], |
|
216 | 216 | ); |
217 | - } |
|
218 | - else { |
|
217 | + } |
|
218 | + else { |
|
219 | 219 | $options = array(); |
220 | 220 | foreach ($pipelines as $name => $pipeline) { |
221 | - $options[$name] = check_plain($pipeline->admin_title) . '<div class="description">' . check_plain($pipeline->admin_description) . '</div>'; |
|
221 | + $options[$name] = check_plain($pipeline->admin_title) . '<div class="description">' . check_plain($pipeline->admin_description) . '</div>'; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | $form['panels_node']['pipeline'] = array( |
225 | - '#type' => 'radios', |
|
226 | - '#options' => $options, |
|
227 | - '#title' => t('Renderer'), |
|
228 | - '#default_value' => !empty($node->panels_node['pipeline']) ? $node->panels_node['pipeline'] : 'standard', |
|
225 | + '#type' => 'radios', |
|
226 | + '#options' => $options, |
|
227 | + '#title' => t('Renderer'), |
|
228 | + '#default_value' => !empty($node->panels_node['pipeline']) ? $node->panels_node['pipeline'] : 'standard', |
|
229 | 229 | ); |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - return $form; |
|
232 | + return $form; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
236 | 236 | * Implementation of hook_validate(). |
237 | 237 | */ |
238 | 238 | function panels_node_validate($node) { |
239 | - if (!$node->nid && empty($node->panels_node['layout'])) { |
|
239 | + if (!$node->nid && empty($node->panels_node['layout'])) { |
|
240 | 240 | form_set_error('', t('Please select a layout.')); |
241 | - } |
|
241 | + } |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -249,90 +249,90 @@ discard block |
||
249 | 249 | * and that's going to be a LOT of data. |
250 | 250 | */ |
251 | 251 | function panels_node_load($node) { |
252 | - // We shortcut this because only in some really drastic corruption circumstance will this |
|
253 | - // not work. |
|
254 | - $additions['panels_node'] = db_fetch_array(db_query("SELECT * FROM {panels_node} WHERE nid = %d", $node->nid)); |
|
255 | - return $additions; |
|
252 | + // We shortcut this because only in some really drastic corruption circumstance will this |
|
253 | + // not work. |
|
254 | + $additions['panels_node'] = db_fetch_array(db_query("SELECT * FROM {panels_node} WHERE nid = %d", $node->nid)); |
|
255 | + return $additions; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Implementation of hook_insert(). |
260 | 260 | */ |
261 | 261 | function panels_node_insert(&$node) { |
262 | - // Create a new display and record that. |
|
263 | - $display = panels_new_display(); |
|
264 | - $display->layout = $node->panels_node['layout']; |
|
265 | - $display->storage_type = 'panels_node'; |
|
266 | - $display->storage_id = $node->nid; |
|
267 | - |
|
268 | - // Special handling for nodes being imported from an export.module data dump. |
|
269 | - if (!empty($node->export_display)) { |
|
262 | + // Create a new display and record that. |
|
263 | + $display = panels_new_display(); |
|
264 | + $display->layout = $node->panels_node['layout']; |
|
265 | + $display->storage_type = 'panels_node'; |
|
266 | + $display->storage_id = $node->nid; |
|
267 | + |
|
268 | + // Special handling for nodes being imported from an export.module data dump. |
|
269 | + if (!empty($node->export_display)) { |
|
270 | 270 | // This works by overriding the $display set above |
271 | 271 | eval($node->export_display); |
272 | 272 | unset($node->export_display); |
273 | - } |
|
273 | + } |
|
274 | 274 | |
275 | - panels_save_display($display); |
|
276 | - $css_id = $node->panels_node['css_id']; |
|
275 | + panels_save_display($display); |
|
276 | + $css_id = $node->panels_node['css_id']; |
|
277 | 277 | |
278 | - db_query("INSERT INTO {panels_node} (nid, did, css_id, pipeline) VALUES (%d, %d, '%s', '%s')", $node->nid, $display->did, $node->panels_node['css_id'], $node->panels_node['pipeline']); |
|
278 | + db_query("INSERT INTO {panels_node} (nid, did, css_id, pipeline) VALUES (%d, %d, '%s', '%s')", $node->nid, $display->did, $node->panels_node['css_id'], $node->panels_node['pipeline']); |
|
279 | 279 | |
280 | - $node->panels_node['did'] = $display->did; |
|
280 | + $node->panels_node['did'] = $display->did; |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Implementation of hook_delete(). |
285 | 285 | */ |
286 | 286 | function panels_node_delete(&$node) { |
287 | - db_query("DELETE FROM {panels_node} WHERE nid = %d", $node->nid); |
|
288 | - if (!empty($node->panels_node['did'])) { |
|
287 | + db_query("DELETE FROM {panels_node} WHERE nid = %d", $node->nid); |
|
288 | + if (!empty($node->panels_node['did'])) { |
|
289 | 289 | panels_delete_display($node->panels_node['did']); |
290 | - } |
|
290 | + } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Implementation of hook_update(). |
295 | 295 | */ |
296 | 296 | function panels_node_update($node) { |
297 | - db_query("UPDATE {panels_node} SET css_id = '%s', pipeline = '%s' WHERE nid = %d", $node->panels_node['css_id'], $node->panels_node['pipeline'], $node->nid); |
|
297 | + db_query("UPDATE {panels_node} SET css_id = '%s', pipeline = '%s' WHERE nid = %d", $node->panels_node['css_id'], $node->panels_node['pipeline'], $node->nid); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Implementation of hook_view(). |
302 | 302 | */ |
303 | 303 | function panels_node_view($node, $teaser = FALSE, $page = FALSE) { |
304 | - static $rendering = array(); |
|
304 | + static $rendering = array(); |
|
305 | 305 | |
306 | - // Prevent loops if someone foolishly puts the node inside itself: |
|
307 | - if (!empty($rendering[$node->nid])) { |
|
306 | + // Prevent loops if someone foolishly puts the node inside itself: |
|
307 | + if (!empty($rendering[$node->nid])) { |
|
308 | 308 | return $node; |
309 | - } |
|
309 | + } |
|
310 | 310 | |
311 | - $rendering[$node->nid] = TRUE; |
|
312 | - ctools_include('plugins', 'panels'); |
|
313 | - if ($teaser) { |
|
311 | + $rendering[$node->nid] = TRUE; |
|
312 | + ctools_include('plugins', 'panels'); |
|
313 | + if ($teaser) { |
|
314 | 314 | // Do the standard view for teaser. |
315 | 315 | $node = node_prepare($node, $teaser); |
316 | 316 | // Because our teasier is never the same as our content, *always* provide |
317 | 317 | // the read more flag. |
318 | 318 | $node->readmore = TRUE; |
319 | - } |
|
320 | - else { |
|
319 | + } |
|
320 | + else { |
|
321 | 321 | if (!empty($node->panels_node['did'])) { |
322 | - $display = panels_load_display($node->panels_node['did']); |
|
323 | - $display->css_id = $node->panels_node['css_id']; |
|
324 | - // TODO: Find a way to make sure this can't node_view. |
|
325 | - $display->context = panels_node_get_context($node); |
|
326 | - $renderer = panels_get_renderer($node->panels_node['pipeline'], $display); |
|
327 | - $node->content['body'] = array( |
|
322 | + $display = panels_load_display($node->panels_node['did']); |
|
323 | + $display->css_id = $node->panels_node['css_id']; |
|
324 | + // TODO: Find a way to make sure this can't node_view. |
|
325 | + $display->context = panels_node_get_context($node); |
|
326 | + $renderer = panels_get_renderer($node->panels_node['pipeline'], $display); |
|
327 | + $node->content['body'] = array( |
|
328 | 328 | '#value' => panels_render_display($display, $renderer), |
329 | 329 | '#weight' => 0, |
330 | - ); |
|
330 | + ); |
|
331 | + } |
|
331 | 332 | } |
332 | - } |
|
333 | 333 | |
334 | - unset($rendering[$node->nid]); |
|
335 | - return $node; |
|
334 | + unset($rendering[$node->nid]); |
|
335 | + return $node; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | // --------------------------------------------------------------------------- |
@@ -342,21 +342,21 @@ discard block |
||
342 | 342 | * Settings for panel nodes. |
343 | 343 | */ |
344 | 344 | function panels_node_settings() { |
345 | - ctools_include('common', 'panels'); |
|
346 | - return drupal_get_form('panels_common_settings', 'panels_node'); |
|
345 | + ctools_include('common', 'panels'); |
|
346 | + return drupal_get_form('panels_common_settings', 'panels_node'); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | 350 | * Implements hook_panels_ipe_access(). |
351 | 351 | */ |
352 | 352 | function panels_node_panels_ipe_access($display) { |
353 | - // We only care about Panels displays from panels_node. |
|
354 | - if (isset($display->context['panel-node'])) { |
|
353 | + // We only care about Panels displays from panels_node. |
|
354 | + if (isset($display->context['panel-node'])) { |
|
355 | 355 | // Only allow access to use the IPE if the user has 'update' access to |
356 | 356 | // the underlying node. |
357 | 357 | $node = $display->context['panel-node']->data; |
358 | 358 | return node_access('update', $node); |
359 | - } |
|
359 | + } |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | // --------------------------------------------------------------------------- |
@@ -367,10 +367,10 @@ discard block |
||
367 | 367 | */ |
368 | 368 | function panels_node_edit_layout($node) { |
369 | 369 | // ctools_include('plugins', 'panels'); |
370 | - ctools_include('context'); |
|
371 | - $display = panels_load_display($node->panels_node['did']); |
|
372 | - $display->context = panels_node_get_context($node); |
|
373 | - return panels_edit_layout($display, t('Save'), "node/$node->nid/panel_layout", 'panels_node'); |
|
370 | + ctools_include('context'); |
|
371 | + $display = panels_load_display($node->panels_node['did']); |
|
372 | + $display->context = panels_node_get_context($node); |
|
373 | + return panels_edit_layout($display, t('Save'), "node/$node->nid/panel_layout", 'panels_node'); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -378,27 +378,27 @@ discard block |
||
378 | 378 | */ |
379 | 379 | function panels_node_edit_content($node) { |
380 | 380 | // ctools_include('plugins', 'panels'); |
381 | - ctools_include('context'); |
|
382 | - $display = panels_load_display($node->panels_node['did']); |
|
383 | - $display->context = panels_node_get_context($node); |
|
384 | - ctools_include('common', 'panels'); |
|
385 | - $content_types = panels_common_get_allowed_types('panels_node', $display->context); |
|
386 | - |
|
387 | - // Print this with theme('page') so that blocks are disabled while editing a display. |
|
388 | - // This is important because negative margins in common block layouts (i.e, Garland) |
|
389 | - // messes up the drag & drop. |
|
390 | - print theme('page', panels_edit($display, "node/$node->nid/panel_content", $content_types), FALSE); |
|
381 | + ctools_include('context'); |
|
382 | + $display = panels_load_display($node->panels_node['did']); |
|
383 | + $display->context = panels_node_get_context($node); |
|
384 | + ctools_include('common', 'panels'); |
|
385 | + $content_types = panels_common_get_allowed_types('panels_node', $display->context); |
|
386 | + |
|
387 | + // Print this with theme('page') so that blocks are disabled while editing a display. |
|
388 | + // This is important because negative margins in common block layouts (i.e, Garland) |
|
389 | + // messes up the drag & drop. |
|
390 | + print theme('page', panels_edit($display, "node/$node->nid/panel_content", $content_types), FALSE); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Build the context to use for a panel node. |
395 | 395 | */ |
396 | 396 | function panels_node_get_context(&$node) { |
397 | - ctools_include('context'); |
|
398 | - $context = ctools_context_create('node', $node); |
|
399 | - $context->identifier = t('This node'); |
|
400 | - $context->keyword = 'node'; |
|
401 | - return array('panel-node' => $context); |
|
397 | + ctools_include('context'); |
|
398 | + $context = ctools_context_create('node', $node); |
|
399 | + $context->identifier = t('This node'); |
|
400 | + $context->keyword = 'node'; |
|
401 | + return array('panel-node' => $context); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -407,15 +407,15 @@ discard block |
||
407 | 407 | * Integrate with export.module for saving panel_nodes into code. |
408 | 408 | */ |
409 | 409 | function panels_node_export_node_alter(&$node, $original_node, $method) { |
410 | - if ($method == 'export') { |
|
410 | + if ($method == 'export') { |
|
411 | 411 | $node_export_omitted = variable_get('node_export_omitted', array()); |
412 | 412 | if (variable_get('node_export_method', '') != 'save-edit' && (array_key_exists('panel', $node_export_omitted) && !$node_export_omitted['panel'])) { |
413 | - drupal_set_message(t("NOTE: in order to import panel_nodes you must first set the export.module settings to \"Save as a new node then edit\", otherwise it won't work.")); |
|
413 | + drupal_set_message(t("NOTE: in order to import panel_nodes you must first set the export.module settings to \"Save as a new node then edit\", otherwise it won't work.")); |
|
414 | 414 | } |
415 | 415 | $display = panels_load_display($node->panels_node['did']); |
416 | 416 | $export = panels_export_display($display); |
417 | 417 | $node->export_display = $export; |
418 | - } |
|
418 | + } |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | * Adds panel nodes information to the Panels dashboard. |
425 | 425 | */ |
426 | 426 | function panels_node_panels_dashboard_blocks(&$vars) { |
427 | - $vars['links']['panels_node'] = array( |
|
427 | + $vars['links']['panels_node'] = array( |
|
428 | 428 | 'title' => l(t('Panel node'), 'node/add/panel'), |
429 | 429 | 'description' => t('Panel nodes are node content and appear in your searches, but are more limited than panel pages.'), |
430 | 430 | 'weight' => -1, |
431 | - ); |
|
431 | + ); |
|
432 | 432 | } |
@@ -7,19 +7,19 @@ |
||
7 | 7 | |
8 | 8 | // Plugin definition |
9 | 9 | $plugin = array( |
10 | - 'access callback' => 'panels_node_panels_storage_access', |
|
10 | + 'access callback' => 'panels_node_panels_storage_access', |
|
11 | 11 | ); |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Access callback for panels storage. |
15 | 15 | */ |
16 | 16 | function panels_node_panels_storage_access($storage_type, $storage_id, $op, $account) { |
17 | - if ($node = node_load($storage_id)) { |
|
17 | + if ($node = node_load($storage_id)) { |
|
18 | 18 | if ($op == 'read') { |
19 | - $op = 'view'; |
|
19 | + $op = 'view'; |
|
20 | 20 | } |
21 | 21 | return node_access($op, $node, $account); |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - return FALSE; |
|
24 | + return FALSE; |
|
25 | 25 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | * implementing this hook doesn't care about access for the given display. |
17 | 17 | */ |
18 | 18 | function hook_panels_ipe_access($panels_display) { |
19 | - // We only care about displays with the 'panelizer' context. |
|
20 | - if (!isset($display->context['panelizer'])) { |
|
19 | + // We only care about displays with the 'panelizer' context. |
|
20 | + if (!isset($display->context['panelizer'])) { |
|
21 | 21 | return NULL; |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - if ($display->context['panelizer']->type[0] == 'entity:node') { |
|
24 | + if ($display->context['panelizer']->type[0] == 'entity:node') { |
|
25 | 25 | // Allow or deny IPE access based on node type. |
26 | 26 | return $display->context['panelizer']->data->type == 'awesome_page'; |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - // Otherwise, deny access to everything! |
|
30 | - return FALSE; |
|
29 | + // Otherwise, deny access to everything! |
|
30 | + return FALSE; |
|
31 | 31 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $plugin = array( |
4 | - 'handler' => array( |
|
4 | + 'handler' => array( |
|
5 | 5 | 'class' => 'panels_renderer_ipe', |
6 | 6 | 'parent' => 'editor', |
7 | - ), |
|
7 | + ), |
|
8 | 8 | ); |
9 | 9 | \ No newline at end of file |
@@ -4,52 +4,52 @@ discard block |
||
4 | 4 | * Renderer class for all In-Place Editor (IPE) behavior. |
5 | 5 | */ |
6 | 6 | class panels_renderer_ipe extends panels_renderer_editor { |
7 | - // The IPE operates in normal render mode, not admin mode. |
|
8 | - var $admin = FALSE; |
|
7 | + // The IPE operates in normal render mode, not admin mode. |
|
8 | + var $admin = FALSE; |
|
9 | 9 | |
10 | - // Whether or not the user has access. |
|
11 | - var $access = NULL; |
|
10 | + // Whether or not the user has access. |
|
11 | + var $access = NULL; |
|
12 | 12 | |
13 | - function invoke_panels_ipe_access() { |
|
13 | + function invoke_panels_ipe_access() { |
|
14 | 14 | if (user_access('bypass access in place editing')) { |
15 | - return TRUE; |
|
15 | + return TRUE; |
|
16 | 16 | } |
17 | 17 | // Modules can return TRUE, FALSE or NULL, for allowed, disallowed, |
18 | 18 | // or don't care - respectively. On the first FALSE, we deny access, |
19 | 19 | // otherwise allow. |
20 | 20 | foreach (module_invoke_all('panels_ipe_access', $this->display) as $result) { |
21 | - if ($result === FALSE) { |
|
21 | + if ($result === FALSE) { |
|
22 | 22 | return FALSE; |
23 | - } |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | return TRUE; |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - function access() { |
|
28 | + function access() { |
|
29 | 29 | if (is_null($this->access)) { |
30 | - $this->access = $this->invoke_panels_ipe_access(); |
|
30 | + $this->access = $this->invoke_panels_ipe_access(); |
|
31 | 31 | } |
32 | 32 | return $this->access; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - function render() { |
|
35 | + function render() { |
|
36 | 36 | $output = parent::render(); |
37 | 37 | if ($this->access()) { |
38 | - return "<div id='panels-ipe-display-{$this->clean_key}' class='panels-ipe-display-container'>$output</div>"; |
|
38 | + return "<div id='panels-ipe-display-{$this->clean_key}' class='panels-ipe-display-container'>$output</div>"; |
|
39 | 39 | } |
40 | 40 | return $output; |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - function add_meta() { |
|
43 | + function add_meta() { |
|
44 | 44 | if (!$this->access()) { |
45 | - return parent::add_meta(); |
|
45 | + return parent::add_meta(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | ctools_include('display-edit', 'panels'); |
49 | 49 | ctools_include('content'); |
50 | 50 | |
51 | 51 | if (empty($this->display->cache_key)) { |
52 | - $this->cache = panels_edit_cache_get_default($this->display); |
|
52 | + $this->cache = panels_edit_cache_get_default($this->display); |
|
53 | 53 | } |
54 | 54 | // @todo we may need an else to load the cache, but I am not sure we |
55 | 55 | // actually need to load it if we already have our cache key, and doing |
@@ -69,73 +69,73 @@ discard block |
||
69 | 69 | ctools_add_css('panels_ipe', 'panels_ipe'); |
70 | 70 | |
71 | 71 | $settings = array( |
72 | - 'formPath' => url($this->get_url('save-form')), |
|
72 | + 'formPath' => url($this->get_url('save-form')), |
|
73 | 73 | ); |
74 | 74 | drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting'); |
75 | 75 | drupal_add_js(array('PanelsIPESettings' => array($this->clean_key => $settings)), 'setting'); |
76 | 76 | |
77 | 77 | jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.sortable')); |
78 | 78 | parent::add_meta(); |
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Override & call the parent, then pass output through to the dnd wrapper |
|
83 | - * theme function. |
|
84 | - * |
|
85 | - * @param $pane |
|
86 | - */ |
|
87 | - function render_pane(&$pane) { |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Override & call the parent, then pass output through to the dnd wrapper |
|
83 | + * theme function. |
|
84 | + * |
|
85 | + * @param $pane |
|
86 | + */ |
|
87 | + function render_pane(&$pane) { |
|
88 | 88 | $output = parent::render_pane($pane); |
89 | 89 | if (empty($output)) { |
90 | - return; |
|
90 | + return; |
|
91 | 91 | } |
92 | 92 | if (!$this->access()) { |
93 | - return $output; |
|
93 | + return $output; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if (empty($pane->IPE_empty)) { |
97 | - // Add an inner layer wrapper to the pane content before placing it into |
|
98 | - // draggable portlet |
|
99 | - $output = "<div class=\"panels-ipe-portlet-content\">$output</div>"; |
|
97 | + // Add an inner layer wrapper to the pane content before placing it into |
|
98 | + // draggable portlet |
|
99 | + $output = "<div class=\"panels-ipe-portlet-content\">$output</div>"; |
|
100 | 100 | } |
101 | 101 | else { |
102 | - $output = "<div class=\"panels-ipe-portlet-content panels-ipe-empty-pane\">$output</div>"; |
|
102 | + $output = "<div class=\"panels-ipe-portlet-content panels-ipe-empty-pane\">$output</div>"; |
|
103 | 103 | } |
104 | 104 | // Hand it off to the plugin/theme for placing draggers/buttons |
105 | 105 | $output = theme('panels_ipe_pane_wrapper', $output, $pane, $this->display, $this); |
106 | 106 | return "<div id=\"panels-ipe-paneid-{$pane->pid}\" class=\"panels-ipe-portlet-wrapper panels-ipe-portlet-marker\">" . $output . "</div>"; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - function render_pane_content(&$pane) { |
|
109 | + function render_pane_content(&$pane) { |
|
110 | 110 | $content = parent::render_pane_content($pane); |
111 | 111 | if (!$this->access()) { |
112 | - return $output; |
|
112 | + return $output; |
|
113 | 113 | } |
114 | 114 | if (!is_object($content)) { |
115 | - $content = new StdClass(); |
|
115 | + $content = new StdClass(); |
|
116 | 116 | } |
117 | 117 | // Ensure that empty panes have some content. |
118 | 118 | if (empty($content->content)) { |
119 | - // Get the administrative title. |
|
120 | - $content_type = ctools_get_content_type($pane->type); |
|
121 | - $title = ctools_content_admin_title($content_type, $pane->subtype, $pane->configuration, $this->display->context); |
|
119 | + // Get the administrative title. |
|
120 | + $content_type = ctools_get_content_type($pane->type); |
|
121 | + $title = ctools_content_admin_title($content_type, $pane->subtype, $pane->configuration, $this->display->context); |
|
122 | 122 | |
123 | - $content->content = t('Placeholder for empty "@title"', array('@title' => $title)); |
|
124 | - $pane->IPE_empty = TRUE; |
|
123 | + $content->content = t('Placeholder for empty "@title"', array('@title' => $title)); |
|
124 | + $pane->IPE_empty = TRUE; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $content; |
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Add an 'empty' pane placeholder above all the normal panes. |
|
132 | - * |
|
133 | - * @param $region_id |
|
134 | - * @param $panes |
|
135 | - */ |
|
136 | - function render_region($region_id, $panes) { |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Add an 'empty' pane placeholder above all the normal panes. |
|
132 | + * |
|
133 | + * @param $region_id |
|
134 | + * @param $panes |
|
135 | + */ |
|
136 | + function render_region($region_id, $panes) { |
|
137 | 137 | if (!$this->access()) { |
138 | - return parent::render_region($region_id, $panes); |
|
138 | + return parent::render_region($region_id, $panes); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Generate this region's 'empty' placeholder pane from the IPE plugin. |
@@ -152,28 +152,28 @@ discard block |
||
152 | 152 | $classes = 'panels-ipe-region'; |
153 | 153 | |
154 | 154 | return "<div id='panels-ipe-regionid-$region_id' class='panels-ipe-region'>$output</div>"; |
155 | - } |
|
155 | + } |
|
156 | 156 | |
157 | - function get_panels_storage_op_for_ajax($method) { |
|
157 | + function get_panels_storage_op_for_ajax($method) { |
|
158 | 158 | switch ($method) { |
159 | - case 'ajax_unlock_ipe': |
|
159 | + case 'ajax_unlock_ipe': |
|
160 | 160 | case 'ajax_save_form': |
161 | 161 | return 'update'; |
162 | - case 'ajax_change_layout': |
|
162 | + case 'ajax_change_layout': |
|
163 | 163 | case 'ajax_set_layout': |
164 | 164 | return 'change layout'; |
165 | 165 | } |
166 | 166 | |
167 | 167 | return parent::get_panels_storage_op_for_ajax($method); |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * AJAX entry point to create the controller form for an IPE. |
|
172 | - */ |
|
173 | - function ajax_save_form($break = NULL) { |
|
170 | + /** |
|
171 | + * AJAX entry point to create the controller form for an IPE. |
|
172 | + */ |
|
173 | + function ajax_save_form($break = NULL) { |
|
174 | 174 | ctools_include('form'); |
175 | 175 | if (!empty($this->cache->locked)) { |
176 | - if ($break != 'break') { |
|
176 | + if ($break != 'break') { |
|
177 | 177 | $account = user_load($this->cache->locked->uid); |
178 | 178 | $name = theme('username', $account); |
179 | 179 | $lock_age = format_interval(time() - $this->cache->locked->updated); |
@@ -181,127 +181,127 @@ discard block |
||
181 | 181 | $message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array('!user' => $name, '!age' => $lock_age)); |
182 | 182 | |
183 | 183 | $this->commands[] = array( |
184 | - 'command' => 'unlockIPE', |
|
185 | - 'message' => $message, |
|
186 | - 'break_path' => url($this->get_url('save-form', 'break')) |
|
184 | + 'command' => 'unlockIPE', |
|
185 | + 'message' => $message, |
|
186 | + 'break_path' => url($this->get_url('save-form', 'break')) |
|
187 | 187 | ); |
188 | 188 | return; |
189 | - } |
|
189 | + } |
|
190 | 190 | |
191 | - // Break the lock. |
|
192 | - panels_edit_cache_break_lock($this->cache); |
|
191 | + // Break the lock. |
|
192 | + panels_edit_cache_break_lock($this->cache); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $form_state = array( |
196 | - 'display' => &$this->display, |
|
197 | - 'content_types' => $this->cache->content_types, |
|
198 | - 'rerender' => FALSE, |
|
199 | - 'no_redirect' => TRUE, |
|
200 | - // Panels needs this to make sure that the layout gets callbacks |
|
201 | - 'layout' => $this->plugins['layout'], |
|
196 | + 'display' => &$this->display, |
|
197 | + 'content_types' => $this->cache->content_types, |
|
198 | + 'rerender' => FALSE, |
|
199 | + 'no_redirect' => TRUE, |
|
200 | + // Panels needs this to make sure that the layout gets callbacks |
|
201 | + 'layout' => $this->plugins['layout'], |
|
202 | 202 | ); |
203 | 203 | |
204 | 204 | $output = ctools_build_form('panels_ipe_edit_control_form', $form_state); |
205 | 205 | if ($output) { |
206 | - // At this point, we want to save the cache to ensure that we have a lock. |
|
207 | - panels_edit_cache_set($this->cache); |
|
208 | - $this->commands[] = array( |
|
206 | + // At this point, we want to save the cache to ensure that we have a lock. |
|
207 | + panels_edit_cache_set($this->cache); |
|
208 | + $this->commands[] = array( |
|
209 | 209 | 'command' => 'initIPE', |
210 | 210 | 'key' => $this->clean_key, |
211 | 211 | 'data' => $output, |
212 | - ); |
|
213 | - return; |
|
212 | + ); |
|
213 | + return; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | // no output == submit |
217 | 217 | if (!empty($form_state['clicked_button']['#save-display'])) { |
218 | - // Saved. Save the cache. |
|
219 | - panels_edit_cache_save($this->cache); |
|
218 | + // Saved. Save the cache. |
|
219 | + panels_edit_cache_save($this->cache); |
|
220 | 220 | } |
221 | 221 | else { |
222 | - // Cancelled. Clear the cache. |
|
223 | - panels_edit_cache_clear($this->cache); |
|
222 | + // Cancelled. Clear the cache. |
|
223 | + panels_edit_cache_clear($this->cache); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $this->commands[] = array( |
227 | - 'command' => 'endIPE', |
|
228 | - 'key' => $this->clean_key, |
|
229 | - 'data' => $output, |
|
227 | + 'command' => 'endIPE', |
|
228 | + 'key' => $this->clean_key, |
|
229 | + 'data' => $output, |
|
230 | 230 | ); |
231 | - } |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * Create a command array to redraw a pane. |
|
235 | - */ |
|
236 | - function command_update_pane($pid) { |
|
233 | + /** |
|
234 | + * Create a command array to redraw a pane. |
|
235 | + */ |
|
236 | + function command_update_pane($pid) { |
|
237 | 237 | if (is_object($pid)) { |
238 | - $pane = $pid; |
|
238 | + $pane = $pid; |
|
239 | 239 | } |
240 | 240 | else { |
241 | - $pane = $this->display->content[$pid]; |
|
241 | + $pane = $this->display->content[$pid]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->commands[] = ctools_ajax_command_replace("#panels-ipe-paneid-$pane->pid", $this->render_pane($pane)); |
245 | 245 | $this->commands[] = ctools_ajax_command_changed("#panels-ipe-display-{$this->clean_key}"); |
246 | - } |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Create a command array to add a new pane. |
|
250 | - */ |
|
251 | - function command_add_pane($pid) { |
|
248 | + /** |
|
249 | + * Create a command array to add a new pane. |
|
250 | + */ |
|
251 | + function command_add_pane($pid) { |
|
252 | 252 | if (is_object($pid)) { |
253 | - $pane = $pid; |
|
253 | + $pane = $pid; |
|
254 | 254 | } |
255 | 255 | else { |
256 | - $pane = $this->display->content[$pid]; |
|
256 | + $pane = $this->display->content[$pid]; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | $this->commands[] = ctools_ajax_command_append("#panels-ipe-regionid-{$pane->panel} div.panels-ipe-sort-container", $this->render_pane($pane)); |
260 | 260 | $this->commands[] = ctools_ajax_command_changed("#panels-ipe-display-{$this->clean_key}"); |
261 | - } |
|
261 | + } |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | 265 | * FAPI callback to create the Save/Cancel form for the IPE. |
266 | 266 | */ |
267 | 267 | function panels_ipe_edit_control_form(&$form_state) { |
268 | - $display = &$form_state['display']; |
|
269 | - // @todo -- this should be unnecessary as we ensure cache_key is set in add_meta() |
|
268 | + $display = &$form_state['display']; |
|
269 | + // @todo -- this should be unnecessary as we ensure cache_key is set in add_meta() |
|
270 | 270 | // $display->cache_key = isset($display->cache_key) ? $display->cache_key : $display->did; |
271 | 271 | |
272 | - // Annoyingly, theme doesn't have access to form_state so we have to do this. |
|
273 | - $form['#display'] = $display; |
|
272 | + // Annoyingly, theme doesn't have access to form_state so we have to do this. |
|
273 | + $form['#display'] = $display; |
|
274 | 274 | |
275 | - $layout = panels_get_layout($display->layout); |
|
276 | - $layout_panels = panels_get_regions($layout, $display); |
|
275 | + $layout = panels_get_layout($display->layout); |
|
276 | + $layout_panels = panels_get_regions($layout, $display); |
|
277 | 277 | |
278 | - $form['panel'] = array('#tree' => TRUE); |
|
279 | - $form['panel']['pane'] = array('#tree' => TRUE); |
|
278 | + $form['panel'] = array('#tree' => TRUE); |
|
279 | + $form['panel']['pane'] = array('#tree' => TRUE); |
|
280 | 280 | |
281 | - foreach ($layout_panels as $panel_id => $title) { |
|
281 | + foreach ($layout_panels as $panel_id => $title) { |
|
282 | 282 | // Make sure we at least have an empty array for all possible locations. |
283 | 283 | if (!isset($display->panels[$panel_id])) { |
284 | - $display->panels[$panel_id] = array(); |
|
284 | + $display->panels[$panel_id] = array(); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | $form['panel']['pane'][$panel_id] = array( |
288 | - // Use 'hidden' instead of 'value' so the js can access it. |
|
289 | - '#type' => 'hidden', |
|
290 | - '#default_value' => implode(',', (array) $display->panels[$panel_id]), |
|
288 | + // Use 'hidden' instead of 'value' so the js can access it. |
|
289 | + '#type' => 'hidden', |
|
290 | + '#default_value' => implode(',', (array) $display->panels[$panel_id]), |
|
291 | 291 | ); |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | - $form['buttons']['submit'] = array( |
|
294 | + $form['buttons']['submit'] = array( |
|
295 | 295 | '#type' => 'submit', |
296 | 296 | '#value' => t('Save'), |
297 | 297 | '#id' => 'panels-ipe-save', |
298 | 298 | '#submit' => array('panels_edit_display_form_submit'), |
299 | 299 | '#save-display' => TRUE, |
300 | - ); |
|
301 | - $form['buttons']['cancel'] = array( |
|
300 | + ); |
|
301 | + $form['buttons']['cancel'] = array( |
|
302 | 302 | '#type' => 'submit', |
303 | 303 | '#value' => t('Cancel'), |
304 | 304 | '#id' => 'panels-ipe-cancel', |
305 | - ); |
|
306 | - return $form; |
|
305 | + ); |
|
306 | + return $form; |
|
307 | 307 | } |