![Marton Kiss](/assets/img/avatar_default.png)
Add a custom chartjs module to integrate chart.js with Drupal. Extend the membership report by a bar chart, and the membership history report by a line chart. Change-Id: Ifb134b632e593c88d81b44e97cb1a2c73626f0a8
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Install, update, and uninstall functions for the chartjs module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_requirements().
|
|
*/
|
|
function chartjs_requirements($phase) {
|
|
$requirements = array();
|
|
|
|
if ($phase == 'runtime') {
|
|
$libraries = array(
|
|
'chartjs' => 'Chart.js',
|
|
);
|
|
foreach ($libraries as $lib => $label) {
|
|
$requirements['chartjs_' . $lib] = array(
|
|
'title' => t('Chart.js: @library library', array('@library' => $label)),
|
|
'value' => t('The @library library is not present', array('@library' => $label)),
|
|
'severity' => REQUIREMENT_ERROR,
|
|
);
|
|
if (function_exists('libraries_detect')) {
|
|
if (($library = libraries_detect($lib)) && !empty($library['installed'])) {
|
|
$requirements['chartjs_' . $lib]['value'] = t('@version (@variant)', array(
|
|
'@version' => $library['version'],
|
|
'@variant' => TRUE
|
|
));
|
|
$requirements['chartjs_' . $lib]['severity'] = REQUIREMENT_OK;
|
|
}
|
|
elseif (!empty($library['error'])) {
|
|
$requirements['chartjs_' . $lib]['description'] = $library['error message'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return $requirements;
|
|
} |