Same name in other branches
- 7.x-1.x advagg.module \advagg_get_js_scopes()
Get all javascript scopes set in the $javascript array.
Paramètres
array $javascript: An array with all JavaScript code.
Return value
array Array of scopes that are currently being used.
1 call to advagg_get_js_scopes()
- _advagg_build_js_arrays_for_rendering dans ./
advagg.module - Builds the arrays needed for js rendering and caching.
Fichier
-
./
advagg.module, line 3112
Code
function advagg_get_js_scopes(array $javascript) {
// Return if nothing given to us.
if (empty($javascript)) {
return array();
}
// Filter out elements of the given scope.
$scopes = array();
$js_settings_in_footer = FALSE;
foreach ($javascript as $name => $item) {
// Skip if the scope is not set.
if (!is_array($item) || empty($item['scope'])) {
continue;
}
if (!isset($scopes[$item['scope']])) {
$scopes[$item['scope']] = TRUE;
}
if ($name === 'settings' && $item['scope'] === 'footer') {
$js_settings_in_footer = TRUE;
}
}
// Default to header if nothing found.
if (empty($scopes)) {
$scopes['header'] = TRUE;
}
// Process header last.
if (isset($scopes['header']) && count($scopes) > 1) {
$temp = $scopes['header'];
unset($scopes['header']);
$scopes['header'] = $temp;
}
// Process footer last if everything has been moved to the footer.
if (isset($scopes['footer']) && count($scopes) > 1 && $js_settings_in_footer) {
$temp = $scopes['footer'];
unset($scopes['footer']);
$scopes['footer'] = $temp;
}
// Return the scopes.
return $scopes;
}