Révision 6f57d8c7
Ajouté par Assos Assos il y a environ 9 ans
drupal7/sites/all/modules/views/plugins/views_plugin_cache.inc | ||
---|---|---|
206 | 206 |
// Slightly less simple for CSS: |
207 | 207 |
$css = drupal_add_css(); |
208 | 208 |
$css_start = isset($this->storage['css']) ? $this->storage['css'] : array(); |
209 |
$this->storage['css'] = $array_mapping_func($css, $css_start);
|
|
209 |
$this->storage['css'] = $this->assetDiff($css, $css_start, $array_mapping_func);
|
|
210 | 210 |
|
211 | 211 |
// Get javascript after/before views renders. |
212 | 212 |
$js = drupal_add_js(); |
213 | 213 |
$js_start = isset($this->storage['js']) ? $this->storage['js'] : array(); |
214 | 214 |
// If there are any differences between the old and the new javascript then |
215 | 215 |
// store them to be added later. |
216 |
$this->storage['js'] = $array_mapping_func($js, $js_start);
|
|
216 |
$this->storage['js'] = $this->assetDiff($js, $js_start, $array_mapping_func);
|
|
217 | 217 |
|
218 | 218 |
// Special case the settings key and get the difference of the data. |
219 | 219 |
$settings = isset($js['settings']['data']) ? $js['settings']['data'] : array(); |
... | ... | |
224 | 224 |
$this->storage['headers'] = $array_mapping_func(drupal_get_http_header(), $this->storage['headers']); |
225 | 225 |
} |
226 | 226 |
|
227 |
/** |
|
228 |
* Computes the differences between two JS/CSS asset arrays. |
|
229 |
* |
|
230 |
* @param array $assets |
|
231 |
* The current asset array. |
|
232 |
* @param array $start_assets |
|
233 |
* The original asset array. |
|
234 |
* @param string $diff_function |
|
235 |
* The function that should be used for computing the diff. |
|
236 |
* |
|
237 |
* @return array |
|
238 |
* A CSS or JS asset array that contains all entries that are new/different |
|
239 |
* in $assets. |
|
240 |
*/ |
|
241 |
protected function assetDiff(array $assets, array $start_assets, $diff_function) { |
|
242 |
$diff = $diff_function($assets, $start_assets); |
|
243 |
|
|
244 |
// Cleanup the resulting array since drupal_array_diff_assoc_recursive() can |
|
245 |
// leave half populated arrays behind. |
|
246 |
foreach ($diff as $key => $entry) { |
|
247 |
// If only the weight was different we can remove this entry. |
|
248 |
if (count($entry) == 1 && isset($entry['weight'])) { |
|
249 |
unset($diff[$key]); |
|
250 |
} |
|
251 |
// If there are other differences we override with the latest entry. |
|
252 |
elseif ($entry != $assets[$key]) { |
|
253 |
$diff[$key] = $assets[$key]; |
|
254 |
} |
|
255 |
} |
|
256 |
return $diff; |
|
257 |
} |
|
258 |
|
|
227 | 259 |
/** |
228 | 260 |
* Restore out of band data saved to cache. Copied from Panels. |
229 | 261 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules