highcharttable.install in HighchartTable 7
highcharttable.install Install and uninstall functions for the HighchartTable module.
File
highcharttable.installView source
<?php
/**
* @file
* highcharttable.install
* Install and uninstall functions for the HighchartTable module.
*/
/**
* Implements hook_enable().
*/
function highcharttable_enable() {
drupal_set_message(st("Thank you for installing HighchartTable. When you have installed the required JS libraries (e.g., through Drush), then all you have to do next is create your <a href='@url'>chart decorations</a>. You can do this by hovering your mouse pointer above any table on your site and clicking the cogwheel.", array(
'@url' => url('admin/config/content/highcharttable'),
)));
$global_settings = array(
// Set contextual-links to the default, core-style.
'contextual-links' => '',
// To have all features use the patched version of jquery.highchartTable.js
'use-patched-library' => TRUE,
);
variable_set('highcharttable_global_settings', $global_settings);
}
/**
* Implements hook_requirements().
*/
function highcharttable_requirements($phase) {
$requirements = array();
if ($phase != 'runtime') {
return $requirements;
}
$global_settings = variable_get('highcharttable_global_settings', array());
$variant = empty($global_settings['use-patched-library']) ? NULL : 'patched';
$highcharts_lib = libraries_load('highcharts');
$highcharttable_lib = libraries_load('highcharttable', $variant);
// Is this required for the runtime phase?
$t = get_t();
$requirements['highcharttable'] = array(
'title' => $t('HighchartTable') . '<br/>' . $t('Library variant: %variant', array(
'%variant' => empty($variant) ? $t('original') : $t('patched'),
)),
'value' => '',
'severity' => REQUIREMENT_OK,
);
if ($highcharts_lib && empty($highcharts_lib['error'])) {
$requirements['highcharttable']['value'] .= $t('<strong>@name</strong> library version %version installed.', array(
'@name' => $highcharts_lib['name'],
'%version' => $highcharts_lib['version'],
));
}
else {
$requirements['highcharttable']['value'] .= empty($highcharts_lib['error message']) ? $t('Highcharts JS library not found.') : $highcharts_lib['error message'];
$requirements['highcharttable']['severity'] = REQUIREMENT_ERROR;
}
if ($highcharttable_lib && empty($highcharttable_lib['error'])) {
$requirements['highcharttable']['value'] .= '<br/>' . $t('<strong>@name</strong> library version %version installed.', array(
'@name' => $highcharttable_lib['name'],
'%version' => $highcharttable_lib['version'],
));
}
else {
$requirements['highcharttable']['value'] .= '<br/>' . (empty($highcharttable_lib['error message']) ? $t('HighchartTable JS library not found.') : $highcharttable_lib['error message']);
$requirements['highcharttable']['severity'] = REQUIREMENT_ERROR;
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function highcharttable_uninstall() {
variable_del('highcharttable_decorations');
variable_del('highcharttable_global_settings');
}
Functions
Name![]() |
Description |
---|---|
highcharttable_enable | Implements hook_enable(). |
highcharttable_requirements | Implements hook_requirements(). |
highcharttable_uninstall | Implements hook_uninstall(). |