array( 'scope' => 'navigate-init' ), 'jquery.js' => array( 'title' => t('jQuery'), 'scope' => 'navigate-init', 'vendor url' => 'http://jquery.com/', 'download url' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', 'error_message' => t('Navigate does not use the packaged jQuery from Drupal, nor from the jQuery Update module. Instead, Navigate relies on using a no-conflict version of jQuery. This ensures that jQuery is updated to the latest version and that it works completely with Navigate and any installed plugins.', array('!no-conflict' => 'http://api.jquery.com/jQuery.noConflict/')), ), 'jquery-ui.js' => array( 'title' => t('jQuery UI'), 'scope' => 'navigate-init', 'vendor url' => 'http://jqueryui.com/', 'download url' => 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js', 'error_message' => t('Drupal does not provide jQuery UI by default. If you have the jQuery UI module installed, Navigate does not use it. Instead, Navigate relies on using a no-conflict version of jQuery. This ensures that jQuery is updated to the latest version and that it works completely with Navigate and any installed plugins.', array('!no-conflict' => 'http://api.jquery.com/jQuery.noConflict/')), ), // Navigate Core Libraries 'navigate.core.js' => array(), 'jquery.cookie.js' => array( 'title' => t('jQuery Cookie'), 'vendor url' => 'https://github.com/carhartl/jquery-cookie', 'download url' => 'https://github.com/carhartl/jquery-cookie/raw/master/jquery.cookie.js', ), 'jquery.hotkeys.js' => array( 'title' => t('jQuery Hotkeys'), 'vendor url' => 'https://github.com/jeresig/jquery.hotkeys', 'download url' => 'https://github.com/jeresig/jquery.hotkeys/raw/master/jquery.hotkeys.js', ), 'jquery.hoverintent.js' => array( 'title' => t('jQuery hoverIntent'), 'vendor url' => 'http://cherne.net/brian/resources/jquery.hoverIntent.html', 'download url' => 'http://cherne.net/brian/resources/jquery.hoverIntent.minified.js', ), 'jquery.hoverintent.js' => array( 'title' => t('jQuery hoverIntent'), 'vendor url' => 'http://cherne.net/brian/resources/jquery.hoverIntent.html', 'download url' => 'http://cherne.net/brian/resources/jquery.hoverIntent.minified.js', ), 'jquery.mousewheel.js' => array( 'title' => t('jQuery Mousewheel'), 'vendor url' => 'https://github.com/brandonaaron/jquery-mousewheel', 'download url' => 'https://github.com/brandonaaron/jquery-mousewheel/raw/master/jquery.mousewheel.js', ), 'jquery.mwheelintent.js' => array( 'title' => t('jQuery Mousewheel Intent'), 'vendor url' => 'http://www.protofunc.com/scripts/jquery/mwheelIntent/index.html', 'download url' => array('http://jscrollpane.kelvinluck.com/script/mwheelIntent.js', 'http://www.protofunc.com/scripts/jquery/mwheelIntent/mwheelIntent.js'), ), 'jquery.pngFix.js' => array( 'title' => t('jQuery PNG Fix'), 'vendor url' => 'http://jquery.andreaseberhard.de/pngFix/index.html', 'download url' => 'http://jquery.andreaseberhard.de/pngFix/jquery.pngFix.js', ), 'jquery.shadowanimation.js' => array( 'title' => t('jQuery Shadow Animation'), 'vendor url' => 'http://www.bitstorm.org/jquery/shadow-animation/', 'download url' => 'http://www.bitstorm.org/jquery/shadow-animation/jquery.animate-shadow.js', ), 'jquery.tokeninput.js' => array( 'title' => t('jQuery Token Input'), 'vendor url' => 'https://github.com/markcarver/jQuery-Tokenizing-Autocomplete-Plugin', 'download url' => 'https://github.com/markcarver/jQuery-Tokenizing-Autocomplete-Plugin/raw/master/src/jquery.tokeninput.js', ), 'xregexp.js' => array( 'title' => t('XRegExp'), 'vendor url' => 'http://xregexp.com/', 'download url' => 'http://xregexp.com/xregexp.js', ), ); // Load plugin libraries foreach ($_navigate['hooks']['libraries'] as $plugin) { $function = $plugin .'_navigate_libraries'; if (function_exists($function)) { $plugin_libraries = (array) $function(); foreach ($plugin_libraries as $name => $properties) { if (isset($libraries[$name])) { if (!isset($properties['overwrite']) || $properties['overwrite'] === FALSE) { unset($plugin_libraries[$name]); continue; } } if (!isset($plugin_libraries[$name]['plugin'])) { $plugin_libraries[$name]['plugin'] = $plugin; } } $libraries = array_merge($libraries, $plugin_libraries); } } // Load defaults for libraries $library_paths = navigate_library_paths(); foreach ($libraries as $library => $properties) { $libraries[$library] += array( 'author' => '', 'version' => '', 'vendor url' => '', 'download url' => '', 'library path' => '', 'plugin' => 'navigate', 'optional' => FALSE, ); $library_path = &$libraries[$library]['library path']; if (empty($library_path)) { foreach($library_paths as $path) { $path = $path . '/' . $library; if (file_exists($path)) { $library_path = $path; $libraries[$library]['installed'] = TRUE; break; } } } else { if (file_exists($library_path)) { $libraries[$library]['installed'] = TRUE; } } if (!empty($library_path)) { $contents = file_get_contents($library_path); // Only get the first comment block close to the beginning of file if (preg_match("/(\/\*.+\*\/)/s", $contents, $match)) { $pos = strpos($match[1], '*/') + 2; $libraries[$library]['details'] = substr($match[1], 0, $pos); } } if (!isset($libraries[$library]['installed']) && $libraries[$library]['optional'] == FALSE) { $libraries[$library]['error'] = t('This library could not be detected.'); if (isset($libraries[$library]['error_message'])) { $libraries[$library]['error'] .= '

' . $libraries[$library]['error_message'] . '

'; } } } return $libraries; } function navigate_admin_libraries_check() { include_once './includes/install.inc'; navigate_add_js('navigate.admin.js'); navigate_add_css('navigate.admin.css'); $form = array(); $description = t('Navigate uses many JavaScript libraries to function properly. The table below will indicate the status of each library. Drupal only allows third-party applications with GPL 2+ and compatible licenses to be packaged. Not all of the required/optional libraries may be available upon initial installation of Navigate and may require extra steps to configure.'); $form['description'] = array( '#value' => $description, ); $form['paths'] = array( '#type' => 'fieldset', '#title' => t('Library Lookup Paths'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => 'The following paths are the locations where Navigate looks for the supported libraries:', ); $libraries = navigate_libraries(TRUE); $status = array(); foreach ($libraries as $name => $library) { // Only process those with titles if (isset($library['title'])) { $info = array(); $plugin = $library['plugin']; $title = t('@library', array('@library' => $library['title'])) . (!empty($library['version']) ? ' (' . $library['version'] . ')' : ''); $homepage = ($library['vendor url'] ? t('Library homepage: !vendor-url', array('!vendor-url' => $library['vendor url'])) : ''); $status[$plugin][$name] = array( 'severity' => (isset($library['error']) ? REQUIREMENT_ERROR : ($library['installed'] ? REQUIREMENT_OK : REQUIREMENT_WARNING)), 'title' => $title, 'value' => (isset($library['installed']) ? t('Installed') : ($library['download url'] && !isset($library['installed']) ? t(($library['optional'] ? t('Optional') : t('Required')) . ' | Install', array('!install-url' => url('admin/settings/navigate/libraries/install/' . $name))) : '')), 'description' => (isset($library['error']) ? $library['error'] : ''), ); // Create more information section if (!empty($library['library path'])) { $info['Installed Path'] = $library['library path']; } // Parse file details using doxygen info if (!empty($library['details'])) { // Parse authoring (and email) information if (preg_match('/(@author|author|by)\s*[:\-|=]?\s*([\w\s]+)\s*[:\-|=]?\s*?/i', $library['details'], $match)) { $author = trim($match[2]); $email = FALSE; if (isset($match[3])) { $email = trim($match[3]); $author .= ' <' . $email . '>'; } if (!empty($author)) { $info['Author'] = $author; } } // Parse version information if (preg_match('/(' . $library['title'] . '|@version|version|ver|v):?\s*([0-9.]+)/i', $library['details'], $match)) { $version = $match[2]; $info['Version'] = $version; $status[$plugin][$name]['value'] = $version; } } if (!empty($library['vendor url'])) { $info['Website'] = t('!vendor-url', array('!vendor-url' => $library['vendor url'])); } if (!empty($library['details'])) { $info['Show Details'] = '
' . htmlspecialchars($library['details']) . '
'; } $description = ''; if (count($info) > 0) { $description = '
'; foreach ($info as $label => $value) { if ($label == 'Show Details') { $description .= "
$label
$value
"; } else { $description .= "
$label:
$value
"; } } $description .= '
'; $status[$plugin][$name]['title'] .= ' - More Information'; $status[$plugin][$name]['description'] .= $description; } } } foreach ($status as $plugin => $report) { if ($plugin == 'navigate') { $title = t('Navigate'); } else { $function = $plugin . '_navigate_plugin'; if (function_exists($function)) { $title = $function('name'); } else { $title = t('Unknown Plugin: ' . $plugin); } } $form['status'][$plugin] = array( '#title' => $title, '#type' => 'fieldset', '#value' => theme('status_report', $status[$plugin]) ); } return $form; } function navigate_admin_libraries_install($form_state, $name = FALSE) { $form = array(); $libraries = navigate_libraries(); if (isset($libraries[$name]) && isset($libraries[$name]['title'])) { $libraries[$name]['filename'] = $name; $form['library'] = array( '#type' => 'value', '#value' => $libraries[$name], ); $form = confirm_form( $form, t('Install library: %title?', array('%title' => $libraries[$name]['title'])), 'admin/settings/navigate/libraries', t('This will install the following library in: %path', array('%path' => file_directory_path() . '/navigate/libraries')), t('Install'), t('Cancel')); } else { drupal_goto('admin/settings/navigate/libraries'); } return $form; } function navigate_admin_libraries_install_submit($form, &$form_state) { $library = $form_state['values']['library']; $source = $library['download url']; if (!empty($source)) { $file = file_directory_path() . '/navigate/libraries/' . $library['filename']; if (ob_get_level()) { ob_end_clean(); } $content = ''; // Transfer file in 1024 byte chunks to save memory usage. if ($fd = fopen($source, 'rb')) { while (!feof($fd)) { $content .= fread($fd, 1024); } fclose($fd); file_save_data($content, $file, FILE_EXISTS_REPLACE); } else { drupal_set_message('Could not install library, download url no longer valid: !url', array('!url' => $source), 'error'); } } $form_state['redirect'] = 'admin/settings/navigate/libraries'; } function navigate_libraries_check($refresh = FALSE) { $libraries = navigate_libraries($refresh); $passed = TRUE; foreach($libraries as $name => $library) { if (!(isset($library['installed'])) && $library['optional'] === FALSE) { global $firebug; $firebug->log($library, $name); $passed = FALSE; break; } } return $passed; } function navigate_library_paths($base_path = FALSE) { global $_navigate; if ($base_path) { $base_path = base_path(); } // Include Navigate defaults $paths = array( ($base_path ? $base_path : '') . drupal_get_path('module', 'navigate') . '/js', ($base_path ? $base_path : '') . drupal_get_path('module', 'navigate') . '/libraries', ); // Include all plugin defaults foreach ($_navigate['hooks']['plugin'] as $plugin) { if (module_exists($plugin)) { $plugin_path = drupal_get_path('module', $plugin); $paths = array_merge($paths, array( ($base_path ? $base_path : '') . drupal_get_path('module', $plugin) . '/js', ($base_path ? $base_path : '') . drupal_get_path('module', $plugin) . '/libraries', )); } } // Include specific plugin library paths foreach ($_navigate['hooks']['libraries'] as $plugin) { $function = $plugin .'_navigate_libraries'; if (function_exists($function)) { $library_paths = (array) $function(TRUE); if ($base_path) { foreach ($library_paths as $key => $value) { $library_paths[$key] = $base_path . $value; } } $paths = array_merge($paths, $library_paths); } } // Include Navigate file libraries, all sites libraries, specific site libraries and theme libraries $files_path = file_directory_path() . '/navigate'; file_check_directory($files_path, TRUE); $files_path = file_directory_path() . '/navigate/libraries'; file_check_directory($files_path, TRUE); $paths = array_merge($paths, array( ($base_path ? $base_path : '') . $files_path, ($base_path ? $base_path : '') . 'sites/all/libraries/navigate', ($base_path ? $base_path : '') . conf_path() . '/libraries/navigate', ($base_path ? $base_path : '') . path_to_theme() . '/libraries/navigate', )); return $paths; }