Révision 5a7e6170
Ajouté par Florent Torregrosa il y a environ 10 ans
drupal7/sites/all/modules/panels/includes/plugins.inc | ||
---|---|---|
173 | 173 |
$start = $this->js; |
174 | 174 |
$this->js = array(); |
175 | 175 |
|
176 |
// Use the advanced mapping function from Drupal >= 7.23 if available. |
|
177 |
$array_mapping_func = function_exists('drupal_array_diff_assoc_recursive') ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc'; |
|
178 |
|
|
176 | 179 |
// If there are any differences between the old and the new javascript then |
177 | 180 |
// store them to be added later. |
178 |
if ($diff = array_diff_assoc($js, $start)) { |
|
179 |
$this->js = $diff; |
|
180 |
} |
|
181 |
|
|
182 |
// Special case the settings key and get the difference of the data. |
|
183 |
if ($settings_diff = array_diff_assoc($js['settings']['data'], $start['settings']['data'])) { |
|
184 |
$this->js['settings'] = $settings_diff; |
|
181 |
if ($diff = $array_mapping_func($js, $start)) { |
|
182 |
// Iterate over the diff to ensure we keep the keys on merge and don't add |
|
183 |
// unnecessary items. |
|
184 |
foreach ($diff as $key => $diff_data) { |
|
185 |
// Special case the settings key and get the difference of the data. |
|
186 |
if ($key === 'settings') { |
|
187 |
// Iterate over the diff to ensure we keep the keys on merge and don't |
|
188 |
// add unnecessary items. |
|
189 |
if (isset($diff[$key]['data'])) { |
|
190 |
foreach ($diff[$key]['data'] as $settings_key => $settings_data) { |
|
191 |
// Merge the changes with the base to get a complete settings |
|
192 |
// array. |
|
193 |
$this->js[$key]['data'][] = drupal_array_merge_deep($settings_data, $diff[$key]['data'][$settings_key]); |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
else { |
|
198 |
$this->js[$key] = $diff_data; |
|
199 |
// Check if the key was present already and if so merge the changes |
|
200 |
// with the original data to get the full settings array. |
|
201 |
if (isset($start[$key])) { |
|
202 |
$this->js[$key] = drupal_array_merge_deep($start[$key], $this->js[$key]); |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
185 | 206 |
} |
186 | 207 |
|
187 | 208 |
// And for tokens: |
... | ... | |
213 | 234 |
drupal_add_js($args['data'], $args); |
214 | 235 |
} |
215 | 236 |
else { |
216 |
foreach ($args as $setting) { |
|
237 |
foreach ($args['data'] as $setting) {
|
|
217 | 238 |
drupal_add_js($setting, 'setting'); |
218 | 239 |
} |
219 | 240 |
} |
Formats disponibles : Unified diff
Update :