function easychart_requirements in Easychart 7.2
File
- ./
easychart.install, line 19 - Easychart install file.
Code
function easychart_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'runtime') {
$highcharts = _get_lib_info('highcharts');
$easychart = _get_lib_info('easychart');
// regex
$re = "/[^0-9]/";
$subst = "";
$msg = '';
// available updates
$recommended_release = array();
$recommended_release['highcharts'] = (int) preg_replace($re, $subst, $highcharts['current_lib_info']['recommended']['version']);
$recommended_release['easychart'] = (int) preg_replace($re, $subst, $easychart['current_lib_info']['recommended']['version']);
$installed = array();
$severity = REQUIREMENT_ERROR;
$description = t('This module requires the <a href="' . $easychart['current_lib_info']['recommended']['uri'] . '">Easychart javascript library (v' . $easychart['current_lib_info']['recommended']['version'] . ')</a> and the <a href="' . $highcharts['current_lib_info']['recommended']['uri'] . '">Highcharts javascript library (v' . $highcharts['current_lib_info']['recommended']['version'] . ')</a> to be installed in the sites/all/libraries folder of your website.');
$description .= t('<br>Drush installation: Donwload and install or update these libraries through the \'<code>drush ec-dependencies -y</code>\' command in your terminal/command line.');
$installed['highcharts'] = (int) preg_replace($re, $subst, array_key_exists('version', $highcharts['current_lib_info']) ? $highcharts['current_lib_info']['version'] : 0);
$installed['easychart'] = (int) preg_replace($re, $subst, array_key_exists('version', $easychart['current_lib_info']) ? $easychart['current_lib_info']['version'] : 0);
$update_highchartsJS = $recommended_release['highcharts'] > $installed['highcharts'] ? true : false;
$update_easychartJS = $recommended_release['easychart'] > $installed['easychart'] ? true : false;
if ($highcharts['current_lib_info']['installed'] && $easychart['current_lib_info']['installed']) {
if ($update_highchartsJS && $update_easychartJS) {
// installed but not the latest/recommended version
$msg = t('Updates available for your Highcharts and Easychart libraries.');
}
elseif ($update_highchartsJS || $update_easychartJS) {
// installed but not the latest/recommended version
if ($update_highchartsJS) {
$msg = t('Updates available for your Highcharts library.<br>Your Easychart library is up to date.');
}
if ($update_easychartJS) {
$msg = t('Updates available for your Easychart library.<br>Your Highcharts library is up to date.');
}
}
else {
// latest/recommended version is installed
$severity = REQUIREMENT_OK;
$msg = t('Your Highcharts and Easychart javascript libraries are up to date.');
$description = '';
}
}
else {
// one of both libraries need to be installed
$severity = REQUIREMENT_ERROR;
if ($easychart['current_lib_info']['installed'] == false && $highcharts['current_lib_info']['installed'] == false) {
$msg = t('The required javascript libraries could not be found.');
$description .= t('<br>ATTENTION: Highcharts is free for personal, school or non-profit projects under the Creative Commons Attribution - Non Commercial 3.0 License. For commercial and governmental websites and projects, you need to buy a license. See <a href=\'http://shop.highsoft.com/highcharts.html\'>Highcharts License and Pricing</a>.');
}
else {
if (!$easychart['current_lib_info']['installed']) {
$msg = t('The required Easychart javascript library (v' . $easychart['current_lib_info']['recommended']['version'] . ') could not be found.');
}
else {
if ($update_easychartJS) {
$msg .= t('<br>Updates available for your Easychart library.');
}
else {
$msg .= t('<br>No updates available for your Easychart library.');
}
}
if (!$highcharts['current_lib_info']['installed']) {
$msg = t('The required Highcharts javascript library (v' . $highcharts['current_lib_info']['recommended']['version'] . ') could not be found.');
$description .= t('<br>ATTENTION: Highcharts is free for personal, school or non-profit projects under the Creative Commons Attribution - Non Commercial 3.0 License. For commercial and governmental websites and projects, you need to buy a license. See <a href=\'http://shop.highsoft.com/highcharts.html\'>Highcharts License and Pricing</a>.');
}
else {
if ($update_highchartsJS) {
$msg .= t('<br>Updates available for your Highcharts library.');
}
else {
$msg .= t('<br>No updates available for your Highcharts library.');
}
}
}
}
$requirements['easychart'] = array(
'title' => $t('Easychart'),
'description' => $description,
'value' => $msg,
'severity' => $severity,
);
}
return $requirements;
}