Builds the arrays needed for js rendering and caching.
Parameters
bool $skip_alter: (Optional) If set to TRUE, this function skips calling drupal_alter() on js, useful for the aggressive cache.
Return value
array Array contains the 3 arrays used for javascript.
1 call to _advagg_build_js_arrays_for_rendering()
- _advagg_process_html in ./
advagg.module - Replacement for template_process_html().
File
-
./
advagg.module, line 1802
Code
function _advagg_build_js_arrays_for_rendering($skip_alter = FALSE) {
// Get the raw JS variable.
$javascript = drupal_add_js();
// Process and Sort JS.
$full_javascript = advagg_get_full_js($javascript, $skip_alter);
// Get scopes used in the js.
$scopes = advagg_get_js_scopes($full_javascript);
// Add JS to the header and footer of the page.
$js_scope_array = array();
$js_scope_settings_array = array();
foreach ($scopes as $scope => $use) {
if (!$use) {
// If the scope is not being used, skip it.
continue;
}
// advagg_get_js() will sort the JavaScript so that it appears in the
// correct order.
$scripts = advagg_get_js($scope, $full_javascript);
if (isset($scripts['#items']['settings'])) {
// Get the js settings.
$js_scope_settings_array[$scope]['settings'] = $scripts['#items']['settings'];
// Exclude JS Settings from the array; we'll add it back later.
$scripts['#items']['settings'] = array();
}
$js_scope_array[$scope] = $scripts;
}
// Fix settings; if more than 1 is set, use the largest one.
if (count($js_scope_settings_array) > 1) {
$max = -1;
$max_scope = '';
foreach ($js_scope_settings_array as $scope => $settings) {
$count = count($settings);
$max = max($max, $count);
if ($max == $count) {
$max_scope = $scope;
}
}
foreach ($js_scope_settings_array as $scope => $settings) {
if ($scope !== $max_scope) {
unset($js_scope_settings_array[$scope]);
}
}
}
return array(
$javascript,
$js_scope_settings_array,
$js_scope_array,
);
}