function _qtip_convert_libraries_to_library in qTip (Stylish jQuery Tooltips) 7.2
Converts a libraries module array to a hook_library array.
@todo Libraries API should automatically register all libraries in hook_library(). See https://drupal.org/node/1386368
Return value
Array Returns a standard Drupal library definition structure.
1 call to _qtip_convert_libraries_to_library()
- qtip_library in ./
qtip.module - Implements hook_library().
File
- ./
qtip.module, line 358
Code
function _qtip_convert_libraries_to_library($library, $options = array()) {
// If the library wasn't installed, don't bother converting it.
if (!$library['installed']) {
return array();
}
$converted = array();
$files = array();
// Get the library files from one of the installed variants.
if ($name = _qtip_libraries_get_preferred_variant_name($library)) {
$files = $library['variants'][$name]['files'];
}
// Define the library if files exist for it.
if (!empty($files)) {
// This is the basic structure expected by hook_library().
$converted = array(
'title' => $library['name'],
'website' => $library['vendor url'],
'version' => $library['version'],
);
foreach ($files as $type => $paths) {
foreach ($paths as $filename => $data) {
$converted[$type][$library['library path'] . '/' . $filename] = !empty($options[$type]) ? $options[$type] : array();
}
}
}
return $converted;
}