/** * (Delegated) Implements hook_civicrm_angularModules(). * * Find any and return any files matching "ang/*.ang.php" * * Note: This hook only runs in CiviCRM 4.5+. * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules */ function _civigiftaid_civix_civicrm_angularModules(&$angularModules) { if (!is_dir(__DIR__ . '/ang')) { return; } $files = _civigiftaid_civix_glob(__DIR__ . '/ang/*.ang.php'); foreach ($files as $file) { $name = preg_replace(':\\.ang\\.php$:', '', basename($file)); $module = (include $file); if (empty($module['ext'])) { $module['ext'] = 'uk.co.compucorp.civicrm.giftaid'; } $angularModules[$name] = $module; } }
/** * Search directory tree for files which match a glob pattern * * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored. * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles() * * @param $dir string, base dir * @param $pattern string, glob pattern, eg "*.txt" * @return array(string) */ function _civigiftaid_civix_find_files($dir, $pattern) { if (is_callable(array('CRM_Utils_File', 'findFiles'))) { return CRM_Utils_File::findFiles($dir, $pattern); } $todos = array($dir); $result = array(); while (!empty($todos)) { $subdir = array_shift($todos); foreach (_civigiftaid_civix_glob("{$subdir}/{$pattern}") as $match) { if (!is_dir($match)) { $result[] = $match; } } if ($dh = opendir($subdir)) { while (FALSE !== ($entry = readdir($dh))) { $path = $subdir . DIRECTORY_SEPARATOR . $entry; if ($entry[0] == '.') { } elseif (is_dir($path)) { $todos[] = $path; } } closedir($dh); } } return $result; }