function asaf_register_needed_files in Asaf (ajax submit for any form) 8
Same name and namespace in other branches
- 7 asaf.module \asaf_register_needed_files()
1 call to asaf_register_needed_files()
- asaf_prepare_form in ./
asaf.module - Attach ajax handlers to the specified buttons.
File
- ./
asaf.module, line 393 - Main module file.
Code
function asaf_register_needed_files(&$form_state, array $files) {
if (!isset($form_state['build_info']['files'])) {
$form_state['build_info']['files'] = array();
}
foreach ($files as $file) {
if (is_array($file) && isset($file['module']) || is_string($file) && file_exists($file)) {
$form_state['build_info']['files'][] = $file;
}
elseif (is_string($file) && module_exists($file)) {
// Loading all includes of the module
$path = drupal_get_path('module', $file);
$destination = DRUPAL_ROOT . '/' . $path;
$pattern = '/.inc$/';
$matches = array_keys(file_scan_directory($destination, $pattern));
if (is_array($matches)) {
foreach ($matches as $inc) {
$parts = explode(DRUPAL_ROOT . '/', $inc);
if (isset($parts[1]) && $parts[1]) {
$form_state['build_info']['files'][] = $parts[1];
}
}
}
}
}
}