getDerivativeId(); $build['#contextual_links']['menu'] = array( 'route_parameters' => array('menu' => $menu_name), ); } /** * Implements hook_libraries_info(). */ function superfish_libraries_info() { $libraries['superfish'] = array( 'name' => 'superfish', 'vendor url' => 'http://github.com/mehrpadin/Superfish-for-Drupal', 'download url' => 'https://github.com/mehrpadin/Superfish-for-Drupal/zipball/2.x', 'version callback' => 'superfish_library_version', 'files' => array( 'js' => array( 'superfish.js', 'jquery.hoverIntent.minified.js', 'sfsmallscreen.js', 'sftouchscreen.js', 'supersubs.js', 'supposition.js' ), 'css' => array( 'css/superfish.css', 'style/black/black.css', 'style/blue/blue.css', 'style/coffee/coffee.css', 'style/default/default.css', 'style/white/white.css' ) ) ); return $libraries; } /** * Implements hook_library_info_build(). */ function superfish_library_info_build() { $libraries = []; if ($superfish_library_path = superfish_library_path()) { $superfish_library_path = '/' . $superfish_library_path; $libraries = [ 'superfish' => [ 'remote' => 'http://github.com/mehrpadin/Superfish-for-Drupal', 'version' => '2.0', 'license' => [ 'name' => 'MIT', 'gpl-compatible' => false, ], 'js' => [ 'js/superfish.js' => [], ], 'dependencies' => [ 'core/jquery', 'core/drupal', 'core/drupalSettings', 'core/jquery.once', ], ], 'init' => [ 'js' => [ $superfish_library_path . '/superfish.js' => [], ], 'css' => [ 'base' => [ $superfish_library_path . '/css/superfish.css' => [], ] ], ], 'superfish_hoverintent' => [ 'js' => [ $superfish_library_path . '/jquery.hoverIntent.minified.js' => [ 'minified' => true ], ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_smallscreen' => [ 'js' => [ $superfish_library_path . '/sfsmallscreen.js' => [], ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_touchscreen' => [ 'js' => [ $superfish_library_path . '/sftouchscreen.js' => [], ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_supersubs' => [ 'js' => [ $superfish_library_path . '/supersubs.js' => [], ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_supposition' => [ 'js' => [ $superfish_library_path . '/supposition.js' => [], ], 'dependencies' => [ 'superfish/init', ] ], 'superfish_style_black' => [ 'css' => [ 'theme' => [ $superfish_library_path . '/style/black/black.css' => [], ] ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_style_blue' => [ 'css' => [ 'theme' => [ $superfish_library_path . '/style/blue/blue.css' => [], ], ], 'dependencies' => [ 'superfish/init', ] ], 'superfish_style_coffee' => [ 'css' => [ 'theme' => [ $superfish_library_path . '/style/coffee/coffee.css' => [], ], ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_style_default' => [ 'css' => [ 'theme' => [ $superfish_library_path . '/style/default/default.css' => [], ], ], 'dependencies' => [ 'superfish/init', ], ], 'superfish_style_white' => [ 'css' => [ 'theme' => [ $superfish_library_path . '/style/white/white.css' => [] ], ], 'dependencies' => [ 'superfish/init', ], ], ]; if ($easing_library_path = superfish_library_path('easing')) { $easing_library_path = '/' . $easing_library_path; $libraries += [ 'superfish_easing' => [ 'js' => [ $easing_library_path . '/jquery.easing.js' => [], ], ], ]; } } return $libraries; } /** * Returns the Superfish library folder location. */ function superfish_library_path($library = 'superfish') { $directory = false; // Ensure the Libraries API module is installed and working. if (function_exists('libraries_get_path') && ($directory = libraries_get_path($library))) { return $directory; } // Otherwise use the default directory. if (file_exists('profiles/' . drupal_get_profile() . '/libraries/' . $library)) { $directory = 'profiles/' . drupal_get_profile() . '/libraries/' . $library; } elseif (file_exists('libraries/' . $library)) { $directory = 'libraries/' . $library; } elseif (file_exists('sites/all/libraries/' . $library)) { $directory = 'sites/all/libraries/' . $library; } return $directory; } /** * Verifies Superfish library is present. */ function superfish_library_check() { if (function_exists('libraries_get_libraries')) { $library = libraries_get_libraries(); if (isset($library['superfish'])) { return TRUE; } } elseif (($directory = superfish_library_path()) && file_exists($directory . '/superfish.js')) { return TRUE; } return FALSE; } /** * Checks Superfish library version. */ function superfish_library_version() { // Get the library version. if (($directory = superfish_library_path()) && file_exists($directory . '/VERSION')) { $version = file_get_contents($directory . '/VERSION'); // Removing blank lines and white spaces. $version = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", trim($version)); if (!empty($version)) { return $version; } return FALSE; } return FALSE; } /** * Generate a list of available slide-in effects. */ function superfish_effects() { $output = array( 'none' => '- ' . t('None') . ' -', 'vertical' => t('Vertical'), 'horizontal' => t('Horizontal'), 'diagonal' => t('Diagonal') ); if (superfish_library_path('easing')) { $easing_types = array( 'easeInSine_vertical' => 'easeInSine (' . t('Vertical') . ')', 'easeInSine_horizontal' => 'easeInSine (' . t('Horizontal') . ')', 'easeInSine_diagonal' => 'easeInSine (' . t('Diagonal') . ')', 'easeInQuint_vertical' => 'easeInQuint (' . t('Vertical') . ')', 'easeInQuint_horizontal' => 'easeInQuint (' . t('Horizontal') . ')', 'easeInQuint_diagonal' => 'easeInQuint (' . t('Diagonal') . ')', 'easeInQuart_vertical' => 'easeInQuart (' . t('Vertical') . ')', 'easeInQuart_horizontal' => 'easeInQuart (' . t('Horizontal') . ')', 'easeInQuart_diagonal' => 'easeInQuart (' . t('Diagonal') . ')', 'easeInQuad_vertical' => 'easeInQuad (' . t('Vertical') . ')', 'easeInQuad_horizontal' => 'easeInQuad (' . t('Horizontal') . ')', 'easeInQuad_diagonal' => 'easeInQuad (' . t('Diagonal') . ')', 'easeInExpo_vertical' => 'easeInExpo (' . t('Vertical') . ')', 'easeInExpo_horizontal' => 'easeInExpo (' . t('Horizontal') . ')', 'easeInExpo_diagonal' => 'easeInExpo (' . t('Diagonal') . ')', 'easeInElastic_vertical' => 'easeInElastic (' . t('Vertical') . ')', 'easeInElastic_horizontal' => 'easeInElastic (' . t('Horizontal') . ')', 'easeInElastic_diagonal' => 'easeInElastic (' . t('Diagonal') . ')', 'easeInCubic_vertical' => 'easeInCubic (' . t('Vertical') . ')', 'easeInCubic_horizontal' => 'easeInCubic (' . t('Horizontal') . ')', 'easeInCubic_diagonal' => 'easeInCubic (' . t('Diagonal') . ')', 'easeInCirc_vertical' => 'easeInCirc (' . t('Vertical') . ')', 'easeInCirc_horizontal' => 'easeInCirc (' . t('Horizontal') . ')', 'easeInCirc_diagonal' => 'easeInCirc (' . t('Diagonal') . ')', 'easeInBounce_vertical' => 'easeInBounce (' . t('Vertical') . ')', 'easeInBounce_horizontal' => 'easeInBounce (' . t('Horizontal') . ')', 'easeInBounce_diagonal' => 'easeInBounce (' . t('Diagonal') . ')', 'easeInBack_vertical' => 'easeInBack (' . t('Vertical') . ')', 'easeInBack_horizontal' => 'easeInBack (' . t('Horizontal') . ')', 'easeInBack_diagonal' => 'easeInBack (' . t('Diagonal') . ')' ); $output = array_merge($output, $easing_types); } return $output; } /** * Helper function to clean up arrays. */ function superfish_array_remove_empty($haystack) { foreach ($haystack as $key => $value) { if (is_array($value)) { $haystack[$key] = superfish_array_remove_empty($haystack[$key]); } elseif (empty($value) && is_bool($value) !== TRUE) { if ($haystack[$key] != '0') { unset($haystack[$key]); } } } return $haystack; } /** * Implements hook_theme(). */ function superfish_theme($existing, $type, $theme, $path) { return array( 'superfish' => array( 'render element' => 'element', 'file' => 'superfish.theme.inc', ), 'superfish_menu_items' => array( 'render element' => 'element', 'file' => 'superfish.theme.inc', ), 'superfish_help' => array( 'variables' => array( 'title' => NULL, 'content' => NULL, ), 'template' => 'superfish--help', ), ); } /** * Implements hook_help(). */ function superfish_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.superfish': $output = array( '#theme' => 'superfish_help', '#title' => t('About Superfish'), '#content' => t('Superfish module integrates jQuery Superfish plugin to your Drupal menu blocks. Please refer to the module documentation for more information.', array( '@url_library' => 'https://github.com/mehrpadin/Superfish-for-Drupal', '@url_module' => 'https://www.drupal.org/project/superfish', '@url_documentation' => 'https://www.drupal.org/node/1125896' ) ), ); return $output; } }