function _cloud_zoom_check_path in Cloud Zoom 8
Same name and namespace in other branches
- 7 cloud_zoom.module \_cloud_zoom_check_path()
Internal function for checking for the cloud zoom JS in a path
2 calls to _cloud_zoom_check_path()
- cloud_zoom_library in ./
cloud_zoom.module - Implements hook_library()
- _cloud_zoom_get_path in ./
cloud_zoom.module - Retrieve the expected path to the example library.
File
- ./
cloud_zoom.module, line 60 - This module integrates the Cloud Zoom JQuery library from: http://www.professorcloud.com/mainsite/cloud-zoom.htm
Code
function _cloud_zoom_check_path($path) {
// Use advanged static caching
static $cache;
if (!isset($cache)) {
$cache['paths'] =& drupal_static(__FUNCTION__);
}
// If this path hasn't been checked, check it now.
if (!isset($cache['paths'][$path])) {
// Scan the path for the file pattern
if ($file = file_scan_directory($path, '/cloud-zoom\\..+\\.min\\.js/')) {
// If found, shift the entry out of the single-item (hopefully) array.
$file = array_shift($file);
// Now parse the JS for version
$content = file_get_contents($file->uri);
preg_match('#Cloud Zoom V(?P<version>[0-9\\.]+)#', $content, $matches);
$file->cz_version = isset($matches['version']) ? $matches['version'] : FALSE;
// Store it in the cache
$cache['paths'][$path] = $file;
}
else {
// No JS foundm store false so its statically cached
$cache['paths'][$path] = FALSE;
}
}
// Return the item from the cache
return $cache['paths'][$path];
}