From 3564e1007595b31a6e192d0d39f0667db09ea5fb Mon Sep 17 00:00:00 2001 From: Bruno Massa <brmassa@67164.no-reply.drupal.org> Date: Fri, 15 May 2009 23:15:24 +0000 Subject: [PATCH] Improvements: * Functions moved from one file to other in order to improve performance --- charts.inc | 29 ++++++++++++++++++++++++++++ charts.install | 22 ++++++++++++++++++++++ charts.module | 51 -------------------------------------------------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/charts.inc b/charts.inc index fcdee0a..419c037 100644 --- a/charts.inc +++ b/charts.inc @@ -77,6 +77,35 @@ function _chart_series_attributes(&$data, &$value, &$settings) { } } +/** + * Even if the series have values with attributes, + * return only the numeric values of them. + * + * @param + * Array. A given data series with or without attributes. + * @return + * Array. A data series, but only with the values, without + * the attributes. + */ +function _charts_series_values($series) { + $data = array(); + + foreach ($series as $index => $value) { + if (!is_numeric($index)) { + continue; + } + + if (is_array($value)) { + $data[] = $value['#value']; + } + else { + $data[] = $value; + } + } + + return $data; +} + /** * Module settings page. Users can set the default layout * of their charts. diff --git a/charts.install b/charts.install index 0a76ad0..27b5950 100644 --- a/charts.install +++ b/charts.install @@ -12,3 +12,25 @@ function charts_uninstall() { variable_del('charts_settings'); } + +/** + * Implementation of hook_requirements(). + */ +function charts_requirements($phase) { + if ($phase == 'runtime' and !$modules = module_invoke_all('charts_info', 'list')) { + $requirements['charts']['title'] = t('Charts'); + $requirements['charts']['value'] = t('No Charts provider installed'); + $requirements['charts']['severity'] = REQUIREMENT_ERROR; + $requirements['charts']['description'] = t('Charts core module only provides a a common set of functions. You must install a Charts provider module to create charts.'); + + return $requirements; + } + elseif ($phase == 'runtime' and !$settings = variable_get('charts_settings', array())) { + $requirements['charts']['title'] = t('Charts'); + $requirements['charts']['value'] = t('Charts module not yet configured'); + $requirements['charts']['severity'] = REQUIREMENT_ERROR; + $requirements['charts']['description'] = t('Charts core module needs to get some default options in order to operate. You must go to <a href="!link">settings page</a> and configure it.', array('!link' => url('admin/settings/charts'))); + + return $requirements; + } +} diff --git a/charts.module b/charts.module index 22f5e2c..9815496 100644 --- a/charts.module +++ b/charts.module @@ -59,57 +59,6 @@ function charts_perm() { return array('set default settings for charts'); } -/** - * Implementation of hook_requirements(). - */ -function charts_requirements($phase) { - if ($phase == 'runtime' and !$modules = module_invoke_all('charts_info', 'list')) { - $requirements['charts']['title'] = t('Charts'); - $requirements['charts']['value'] = t('No Charts provider installed'); - $requirements['charts']['severity'] = REQUIREMENT_ERROR; - $requirements['charts']['description'] = t('Charts core module only provides a a common set of functions. You must install a Charts provider module to create charts.'); - - return $requirements; - } - elseif ($phase == 'runtime' and !$settings = variable_get('charts_settings', array())) { - $requirements['charts']['title'] = t('Charts'); - $requirements['charts']['value'] = t('Charts module not yet configured'); - $requirements['charts']['severity'] = REQUIREMENT_ERROR; - $requirements['charts']['description'] = t('Charts core module needs to get some default options in order to operate. You must go to <a href="!link">settings page</a> and configure it.', array('!link' => url('admin/settings/charts'))); - - return $requirements; - } -} - -/** - * Even if the series have values with attributes, - * return only the numeric values of them. - * - * @param - * Array. A given data series with or without attributes. - * @return - * Array. A data series, but only with the values, without - * the attributes. - */ -function _charts_series_values($series) { - $data = array(); - - foreach ($series as $index => $value) { - if (!is_numeric($index)) { - continue; - } - - if (is_array($value)) { - $data[] = $value['#value']; - } - else { - $data[] = $value; - } - } - - return $data; -} - /** * Implementation of hook_theme(). */ -- GitLab