function _d3_list_library_versions_from_libraries in d3.js 7
Lists library versions nominally available in sites/all/libraries/d3/
1 call to _d3_list_library_versions_from_libraries()
- d3_config_form in ./
d3.admin.inc - D3 configuration form
File
- ./
d3.module, line 112 - D3 module file for creating visualizations with d3.js.
Code
function _d3_list_library_versions_from_libraries() {
$library_versions = array();
$path = libraries_get_path('d3');
if ($path) {
$files = array();
// In the repository the files might be named d3.js and d3.min.js.
$files += file_scan_directory($path, '/d3.js|d3.min.js/');
// They could also have the version # in the file name.
$files += file_scan_directory($path, '/d3.v[0-9]+(.min)?.js/');
foreach ($files as $file) {
$library_version = '';
// Assume files named d3.js or d3.min.js are version 3
if ($file->filename == 'd3.js' || $file->filename == 'd3.min.js') {
$library_version = 3;
}
elseif (preg_match('/d3.v([0-9]+)(.min)?.js/', $file->filename, $matches)) {
$library_version = $matches[1];
}
if ($library_version && !in_array($library_version, $library_versions)) {
$library_versions[] = "{$library_version}";
}
}
}
sort($library_versions, SORT_NUMERIC);
return $library_versions;
}