diff --git a/charts.inc b/charts.inc index fcdee0af7a2daba692ba45bcd5cf8d99771cd2be..419c03790dfe994b45aad7ad9c68110c36e6d34e 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 0a76ad03eba2db17bbeb4f2b3417b3735ad2d941..27b59500acb9c3b2111501aa71db44fe7ba867a3 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 22f5e2cb8d48ffa9886afd864fc2612cf0d941cd..98154967cbb3cf09c0ccc26e8c2aea49146ca47a 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(). */