'Example library', 'vendor url' => 'http://example.com', 'download url' => 'http://example.com/download', // Optional: If, after extraction, the actual library files are contained in // 'sites/all/libraries/example/lib', specify the relative path here. 'path' => 'lib', // Optional: Define a custom version detection callback, if required. 'version callback' => 'mymodule_get_version', // Specify arguments for the version callback. By default, // libraries_get_version() takes a named argument array: 'version arguments' => array( 'file' => 'docs/CHANGELOG.txt', 'pattern' => '@version\s+([0-9a-zA-Z\.-]+)@', 'lines' => 5, 'cols' => 20, ), // Default list of files of the library to load. Important: Only specify // third-party files belonging to the library here, not integration files of // your module. 'files' => array( // 'js' and 'css' follow the syntax of hook_library(), but file paths are // relative to the library path. 'js' => array( 'exlib.js', 'gadgets/foo.js', ), 'css' => array( 'lib_style.css', 'skin/example.css', ), // For PHP libraries, specify include files here, still relative to the // library path. 'php' => array( 'exlib.php', 'exlib.inc', ), ), // Optional: Specify alternative variants of the library, if available. 'variants' => array( // All properties defined for 'minified' override top-level properties. 'minified' => array( 'files' => array( 'js' => array( 'exlib.min.js', 'gadgets/foo.min.js', ), 'css' => array( 'lib_style.css', 'skin/example.css', ), ), 'variant callback' => 'mymodule_check_variant', 'variant arguments' => array( 'variant' => 'minified', ), ), ), // Optional, but usually required: Override top-level properties for later // versions of the library. The properties of the minimum version that is // matched override the top-level properties. Note: // - When registering 'versions', it usually does not make sense to register // 'files', 'variants', and 'integration files' on the top-level, as most // of those likely need to be different per version and there are no // defaults. // - The array keys have to be strings, as PHP does not support floats for // array keys. 'versions' => array( '2' => array( 'files' => array( 'js' => array('exlib.js'), 'css' => array('exlib_style.css'), ), ), '3.0' => array( 'files' => array( 'js' => array('exlib.js'), 'css' => array('lib_style.css'), ), ), '3.2' => array( 'files' => array( 'js' => array( 'exlib.js', 'gadgets/foo.js', ), 'css' => array( 'lib_style.css', 'skin/example.css', ), ), ), ), // Optional: Register files to auto-load for your module. All files must be // keyed by module, and follow the syntax of the 'files' property. 'integration files' => array( 'mymodule' => array( 'js' => array('ex_lib.inc'), ), ), ); // A very simple library. No changing APIs (hence, no versions), no variants. // Expected to be extracted into 'sites/all/libraries/simple'. $libraries['simple'] = array( 'name' => 'Simple library', 'vendor url' => 'http://example.com/simple', 'download url' => 'http://example.com/simple', 'version arguments' => array( 'file' => 'readme.txt', // Best practice: Document the actual version strings for later reference. // 1.x: Version 1.0 'pattern' => '/Version (\d+)/', 'lines' => 5, ), 'files' => array( 'js' => array('simple.js'), ), ); // A library that (naturally) evolves over time with API changes. $libraries['tinymce'] = array( 'name' => 'TinyMCE', 'vendor url' => 'http://tinymce.moxiecode.com', 'download url' => 'http://tinymce.moxiecode.com/download.php', 'path' => 'jscripts/tiny_mce', // The regular expression catches two parts (the major and the minor // version), which libraries_get_version() doesn't allow. 'version callback' => 'tinymce_get_version', 'version arguments' => array( // It can be easier to parse the first characters of a minified file // instead of doing a multi-line pattern matching in a source file. See // 'lines' and 'cols' below. 'file' => 'jscripts/tiny_mce/tiny_mce.js', // Best practice: Document the actual version strings for later reference. // 2.x: this.majorVersion="2";this.minorVersion="1.3" // 3.x: majorVersion:'3',minorVersion:'2.0.1' 'pattern' => '@majorVersion[=:]["\'](\d).+?minorVersion[=:]["\']([\d\.]+)@', 'lines' => 1, 'cols' => 100, ), 'versions' => array( '2.1' => array( 'files' => array( 'js' => array('tiny_mce.js'), ), 'variants' => array( 'source' => array( 'files' => array( 'js' => array('tiny_mce_src.js'), ), ), ), 'integration files' => array( 'wysiwyg' => array( 'js' => array('editors/js/tinymce-2.js'), 'css' => array('editors/js/tinymce-2.css'), ), ), ), // Definition used if 3.1 or above is detected. '3.1' => array( // Does not support JS aggregation. 'files' => array( 'js' => array( 'tiny_mce.js' => array('preprocess' => FALSE), ), ), 'variants' => array( // New variant leveraging jQuery. Not stable yet; therefore not the // default variant. 'jquery' => array( 'files' => array( 'js' => array( 'tiny_mce_jquery.js' => array('preprocess' => FALSE), ), ), ), 'source' => array( 'files' => array( 'js' => array( 'tiny_mce_src.js' => array('preprocess' => FALSE), ), ), ), ), 'integration files' => array( 'wysiwyg' => array( 'js' => array('editors/js/tinymce-3.js'), 'css' => array('editors/js/tinymce-3.css'), ), ), ), ), ); return $libraries; } /** * Alter the library information before detection and caching takes place. * * The library definitions are passed by reference. A common use-case is adding * a module's integration files to the library array, so that the files are * loaded whenever the library is. As noted above, it is important to declare * integration files inside of an array, whose key is the module name. * * @see hook_libraries_info() */ function hook_libraries_info_alter(&$libraries) { $files = array( 'php' => array('example_module.php_spellchecker.inc'), ); $libraries['php_spellchecker']['integration files']['example_module'] = $files; } /** * Specify paths to look for library info files. * * Libraries API looks in the following directories for library info files by * default: * - libraries * - profiles/$profile/libraries * - sites/all/libraries * - sites/$site/libraries * This hook allows you to specify additional locations to look for library info * files. This should only be used for modules that declare many libraries. * Modules that only implement a few libraries should implement * hook_libraries_info(). * * @return * An array of paths. */ function hook_libraries_paths() { // Taken from the Libraries test module, which needs to specify the path to // the test library. return array(drupal_get_path('module', 'libraries_test') . '/example'); }