function menu_minipanels_get_qtip_path in Menu Minipanels 6
Same name and namespace in other branches
- 7 menu_minipanels.module \menu_minipanels_get_qtip_path()
Check different paths to find the qTips JS file's path.
Return value
The path to the required qTips file relative to base_path() if found, FALSE if the file is not found.
1 call to menu_minipanels_get_qtip_path()
- menu_minipanels_init in ./
menu_minipanels.module - Implements hook_init().
File
- ./
menu_minipanels.module, line 100 - Allows an administrator to specify a minipanel to be associated with a Drupal menu item. When that menu item is hovered or clicked (as per config), the minipanel content will be shown using the qTip javascript library.
Code
function menu_minipanels_get_qtip_path() {
static $qtip_path = FALSE;
// Only proceed if the path wasn't compiled before.
if (empty($qtip_path)) {
$cid = 'menu_minipanels_qtip_path';
$cache = cache_get($cid);
// The path was previously cached, so just load that.
if (!empty($cache->data)) {
$qtip_path = $cache->data;
}
else {
$filename = 'jquery.qtip-1.0.0-rc3.min.js';
$module_path = drupal_get_path('module', 'menu_minipanels');
// An array of possible paths, in descending order of preference.
$possible_paths = array(
// Ideally should be stored here.
'sites/all/libraries/qtip',
// Legacy paths, including some possible incorrect ones, but the
// performance hit should be negligible.
$module_path . '/js/lib/qtip',
$module_path . '/js/lib',
$module_path . '/js/qtip',
$module_path . '/js',
$module_path . '/qtip',
$module_path,
);
// Proper Libraries API support.
if (function_exists('libraries_get_path')) {
$lib_path = libraries_get_path('qtip');
if (!empty($lib_path) && !in_array($lib_path, $possible_paths)) {
array_unshift($possible_paths, $lib_path);
}
}
// Check each of the paths.
foreach ($possible_paths as $path) {
// If the file exists, this is the one we'll use.
if (file_exists($path . '/' . $filename)) {
$qtip_path = $path . '/' . $filename;
break;
}
}
// Save the path for later.
if (!empty($qtip_path)) {
cache_set($cid, $qtip_path);
}
else {
watchdog('menu_minipanels', t('Menu Minipanels module is enabled, but the qTip library has not been downloaded. This module will not work without qTip! Please see README.txt for instructions on how to download qTip.'));
}
}
}
// Return the qTips JS file's path, or FALSE.
return $qtip_path;
}