function magic_generate_exclude_full in Magic 7
Helper function to change magic keywords into the exclude array.
This helper function will remove kewords such as :contrib or :base-theme and change them into the paths that they represent.
Parameters
$exclude: An array of paths to remove.
Return value
array An array with 'exclude' and 'include' as the keys. Exclude contains a set of files to remove, while 'include' has the files to keep.
1 call to magic_generate_exclude_full()
- magic_extension_assets_theme_settings_form_submit in ./
magic.module - Submit handler for the theme settings form.
File
- includes/
magic.inc, line 20 - A file to contain functions for the magic module to abuse.
Code
function magic_generate_exclude_full($array) {
global $base_theme_info, $theme_info;
$return = array(
'exclude' => array(),
'include' => array(),
);
foreach ($array as $item) {
$invert = substr($item, 0, 1) == '~' ? TRUE : FALSE;
if ($invert) {
$item = substr($item, 1);
}
$items = array();
// We now check the string against a set of standard variables.
if ($item == ':all') {
$items[] = '*';
}
elseif ($item == ':core') {
// This is unique as there are several areas where core files might be.
$items = array(
'misc/*',
'modules/*',
'themes/*',
);
}
elseif ($item == ':contrib') {
$items[] = 'sites/all/modules/*';
}
elseif ($item == ':base-theme') {
if (empty($base_theme_info)) {
// We do not actually have a base theme.
continue;
}
$items[] = drupal_get_path('theme', $base_theme_info[0]->name) . '/*';
}
elseif ($item == ':current-theme') {
$items[] = drupal_get_path('theme', $theme_info->name) . '/*';
}
else {
$items[] = $item;
}
if ($invert) {
$return['include'] = array_merge($return['include'], $items);
}
else {
$return['exclude'] = array_merge($return['exclude'], $items);
}
}
return $return;
}