cpf.module in CPF 8
Same filename and directory in other branches
Provides a CPF Field Type and a CPF Form Element for storing CPF number data.
File
cpf.moduleView source
<?php
/**
* @file
* Provides a CPF Field Type and a CPF Form Element for storing CPF number data.
*/
/**
* Implments hook_libraries_info().
*/
function cpf_libraries_info() {
$libraries['mask_plugin'] = [
'name' => 'jQuery Mask Plugin',
'vendor url' => 'https://igorescobar.github.io/jQuery-Mask-Plugin/',
'download url' => 'https://github.com/igorescobar/jQuery-Mask-Plugin',
'version arguments' => [
'file' => 'jquery.mask.min.js',
// e.g. jQuery Mask Plugin v1.14.10.
'pattern' => '/jQuery Mask Plugin v(\\d+\\.+\\d+(\\.+\\d+)?)/',
'lines' => 3,
],
'files' => [
'js' => [
'jquery.mask.min.js',
],
],
];
return $libraries;
}
/**
* Implements hook_library_info_alter().
*/
function cpf_library_info_alter(&$libraries, $extension) {
if ($extension == 'cpf' and isset($libraries['mask_plugin'])) {
$library_path = libraries_get_path('mask_plugin');
if (strpos($library_path, '/') !== 0) {
$library_path = '/' . $library_path;
}
// Set the correct path to where the library was downloaded.
$libraries['mask_plugin']['js'][$library_path . '/jquery.mask.min.js'] = $libraries['mask_plugin']['js']['jquery.mask.min.js'];
unset($libraries['mask_plugin']['js']['jquery.mask.min.js']);
}
}
Functions
Name | Description |
---|---|
cpf_libraries_info | Implments hook_libraries_info(). |
cpf_library_info_alter | Implements hook_library_info_alter(). |