From 777c844b9833d2fcd20c692e8e1837408c024a19 Mon Sep 17 00:00:00 2001 From: Bruno Massa <brmassa@67164.no-reply.drupal.org> Date: Fri, 3 Jul 2009 05:37:33 +0000 Subject: [PATCH] New features: * Initial Port to Drupal 7 --- charts.admin.inc | 6 +-- charts.hooks.inc | 64 +++++++++++++++++++++++++ charts.inc | 4 +- charts.info | 9 +++- charts.install | 2 +- charts.module | 57 ---------------------- charts_system/charts_system.hooks.inc | 47 ++++++++++++++++++ charts_system/charts_system.inc | 20 +++++--- charts_system/charts_system.info | 4 +- charts_system/charts_system.module | 46 ------------------ fusioncharts/fusioncharts.hooks.inc | 37 ++++++++++++++ fusioncharts/fusioncharts.inc | 4 +- fusioncharts/fusioncharts.info | 5 +- fusioncharts/fusioncharts.install | 4 +- fusioncharts/fusioncharts.module | 36 -------------- google_charts/google_charts.hooks.inc | 37 ++++++++++++++ google_charts/google_charts.inc | 28 +++++------ google_charts/google_charts.info | 4 +- google_charts/google_charts.module | 36 -------------- openflashchart/openflashchart.hooks.inc | 27 +++++++++++ openflashchart/openflashchart.info | 4 +- openflashchart/openflashchart.module | 26 ---------- views/charts.views.inc | 10 ++-- views/charts_plugin_style_chart.inc | 8 ++-- 24 files changed, 279 insertions(+), 246 deletions(-) create mode 100644 charts.hooks.inc create mode 100644 charts_system/charts_system.hooks.inc create mode 100644 fusioncharts/fusioncharts.hooks.inc create mode 100644 google_charts/google_charts.hooks.inc create mode 100644 openflashchart/openflashchart.hooks.inc diff --git a/charts.admin.inc b/charts.admin.inc index dbde71d..aa37e92 100644 --- a/charts.admin.inc +++ b/charts.admin.inc @@ -48,7 +48,7 @@ function _charts_color_form_complete(&$form, $default) { ); } - drupal_add_js(drupal_get_path('module', 'charts') .'/charts_color.js'); + drupal_add_js(drupal_get_path('module', 'charts') . '/charts_color.js'); drupal_add_js(array('chartsColorCustom' => t('Custom')), 'setting'); } @@ -110,7 +110,7 @@ function _charts_module_invoke_all() { unset($args[0]); $return = array(); foreach (module_implements($hook) as $module) { - $function = $module .'_'. $hook; + $function = $module . '_' . $hook; $result = call_user_func_array($function, $args); if (isset($result) && is_array($result)) { $return += $result; @@ -227,7 +227,7 @@ function _charts_settings_page_submit(&$form, &$form_state) { // merge between the chart data and the defaults easier on every // chart display. foreach ($settings as $index => $value) { - $default['#'. $index] = $value; + $default['#' . $index] = $value; } // Save the data into database diff --git a/charts.hooks.inc b/charts.hooks.inc new file mode 100644 index 0000000..5559d25 --- /dev/null +++ b/charts.hooks.inc @@ -0,0 +1,64 @@ +<?php +// $Id$ +/** + * @author Bruno Massa http://drupal.org/user/67164 + * @file + * Transform DATA into INFORMATION using beautiful CHARTS. + * + * @note only cachable hooks are here. + */ + +/** + * Implementation of hook_chart_types(). + */ +function charts_chart_types() { + return array( + 'line2D' => t('Line 2D'), + 'hbar2D' => t('Horizontal Bar 2D'), + 'vbar2D' => t('Vertical Bar 2D'), + 'pie2D' => t('Pie 2D'), + 'pie3D' => t('Pie 3D'), + ); +} + +/** + * Implementation of hook_menu(). + */ +function charts_menu() { + $items['admin/settings/charts'] = array( + 'access arguments' => array('set default settings for charts'), + 'description' => 'Set the default behaviour and look of all your charts', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('_charts_settings_page'), + 'title' => 'Charts' + ); + return $items; +} + +/** + * Implementation of hook_perm(). + */ +function charts_perm() { + return array('set default settings for charts'); +} + +/** + * Implementation of hook_theme(). + */ +function charts_theme() { + return array( + 'charts_settings_color' => array( + 'arguments' => array('form' => NULL), + ), + ); +} + +/** + * Implementation of hook_views_api(). + */ +function charts_views_api() { + return array( + 'api' => 2, + 'path' => drupal_get_path('module', 'charts') . '/views', + ); +} diff --git a/charts.inc b/charts.inc index 5bcb3b1..0f1c519 100644 --- a/charts.inc +++ b/charts.inc @@ -73,7 +73,9 @@ function _charts_chart(&$data) { */ function _chart_series_attributes(&$data, &$value, &$settings) { foreach ($settings['#series_attributes'] as $attribute) { - $data[$attribute] = $settings[$attribute][$value]; + if (isset($settings[$attribute][$value])) { + $data[$attribute] = $settings[$attribute][$value]; + } } } diff --git a/charts.info b/charts.info index b4bca20..f42e5a2 100644 --- a/charts.info +++ b/charts.info @@ -1,5 +1,10 @@ ; $Id$ -core = "6.x" +core = "7.x" description = "Transform DATA into INFORMATION using beautiful CHARTS." +files[] = charts.module +files[] = charts.admin.inc +files[] = charts.inc +files[] = charts.hooks.inc +files[] = charts.install name = "Charts" -package = "Charts" \ No newline at end of file +package = "Charts" diff --git a/charts.install b/charts.install index 6493359..8a8e6c5 100644 --- a/charts.install +++ b/charts.install @@ -6,7 +6,7 @@ * Install and unistall functions for this module */ -DEFINE(CHARTS_MINIMUM_PHP, '5.2.0'); +DEFINE('CHARTS_MINIMUM_PHP', '5.2.0'); /** * Implementation of hook_uninstall(). diff --git a/charts.module b/charts.module index 9815496..3156729 100644 --- a/charts.module +++ b/charts.module @@ -5,7 +5,6 @@ * @file * Transform DATA into INFORMATION using beautiful CHARTS. * - * @note only hooks are here. * @note For instructions about the API, see chart_api.txt file. */ @@ -23,59 +22,3 @@ function charts_chart(&$data) { module_load_include('inc', 'charts'); return _charts_chart($data); } - -/** - * Immplementation of hook_chart_types(). - */ -function charts_chart_types() { - return array( - 'line2D' => t('Line 2D'), - 'hbar2D' => t('Horizontal Bar 2D'), - 'vbar2D' => t('Vertical Bar 2D'), - 'pie2D' => t('Pie 2D'), - 'pie3D' => t('Pie 3D'), - ); -} - -/** - * Implementation of hook_menu(). - */ -function charts_menu() { - $items['admin/settings/charts'] = array( - 'access arguments' => array('set default settings for charts'), - 'description' => 'Set the default behaviour and look of all your charts', - 'file' => 'charts.admin.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_charts_settings_page'), - 'title' => 'Charts' - ); - return $items; -} - -/** - * Implementation of hook_perm(). - */ -function charts_perm() { - return array('set default settings for charts'); -} - -/** - * Implementation of hook_theme(). - */ -function charts_theme() { - return array( - 'charts_settings_color' => array( - 'arguments' => array('form' => NULL), - ), - ); -} - -/** - * Implementation of hook_views_api(). - */ -function charts_views_api() { - return array( - 'api' => 2, - 'path' => drupal_get_path('module', 'charts') .'/views', - ); -} diff --git a/charts_system/charts_system.hooks.inc b/charts_system/charts_system.hooks.inc new file mode 100644 index 0000000..78986b1 --- /dev/null +++ b/charts_system/charts_system.hooks.inc @@ -0,0 +1,47 @@ +<?php +// $Id$ +/** + * @author Bruno Massa http://drupal.org/user/67164 + * @author TJ (based on his Chart module) + * @file + * Use Charts for Drupal administration + */ + +/** + * Implementation of hook_menu(). + */ +function charts_system_menu() { + $items['admin/reports/charts'] = array( + 'access arguments' => array('access site reports'), + 'file' => 'charts_system.inc', + 'page callback' => '_charts_system_charts', + 'page arguments' => array('nodes'), + 'title' => 'Charts' + ); + $items['admin/reports/charts/nodes'] = array( + 'access arguments' => array('access site reports'), + 'file' => 'charts_system.inc', + 'page callback' => '_charts_system_charts', + 'page arguments' => array('nodes'), + 'title' => 'Nodes', + 'type' => MENU_DEFAULT_LOCAL_TASK + ); + $items['admin/reports/charts/users'] = array( + 'access arguments' => array('access site reports'), + 'file' => 'charts_system.inc', + 'page callback' => '_charts_system_charts', + 'page arguments' => array('users'), + 'title' => 'Users', + 'type' => MENU_LOCAL_TASK + ); + $items['admin/reports/charts/watchdog'] = array( + 'access arguments' => array('access site reports'), + 'file' => 'charts_system.inc', + 'page callback' => '_charts_system_charts', + 'page arguments' => array('watchdog'), + 'title' => 'Watchdog', + 'type' => MENU_LOCAL_TASK + ); + + return $items; +} diff --git a/charts_system/charts_system.inc b/charts_system/charts_system.inc index db7758a..945e427 100644 --- a/charts_system/charts_system.inc +++ b/charts_system/charts_system.inc @@ -81,7 +81,7 @@ function _charts_system_charts($ctype) { break; } - return '<div id="charts-system">'. $output .'</div>'; + return '<div id="charts-system">' . $output . '</div>'; } /** @@ -109,7 +109,7 @@ function _charts_system_generate($title, $sql, $callback = NULL) { $data[] = array( '#value' => $result['count'], - '#label' => $result['name'] .': '. $result['count'] + '#label' => $result['name'] . ': ' . $result['count'] ); } @@ -132,7 +132,7 @@ function _charts_system_generate($title, $sql, $callback = NULL) { * String. The HTML chart when all data is fine or a blank string */ function _charts_system_node_activity() { - $now = time(); + $now = REQUEST_TIME; $results = db_query('SELECT type, created FROM {node} @@ -144,11 +144,17 @@ function _charts_system_node_activity() { $max = array(); $counts = array(); $types = array(); + $type = 0; - while ($result = db_fetch_array($results)) { - $day = ltrim(date('d', $result['created']), '0'); - $types[$result['type']] = $type++; - $counts[$day][$result['type']]++; + foreach ($results as $result) { + $day = ltrim(date('d', $result->created), '0'); + $types[$result->type] = $type++; + if (isset($counts[$day][$result->type])) { + $counts[$day][$result->type]++; + } + else { + $counts[$day][$result->type] = 1; + } } // Generate data and labels diff --git a/charts_system/charts_system.info b/charts_system/charts_system.info index 8a92791..c48030d 100644 --- a/charts_system/charts_system.info +++ b/charts_system/charts_system.info @@ -1,6 +1,8 @@ ; $Id$ -core = "6.x" +core = "7.x" dependencies[] = charts description = "Use Charts for Drupal administration" +files[] = charts_system.inc +files[] = charts_system.hooks.inc name = "Charts System" package = "Charts" diff --git a/charts_system/charts_system.module b/charts_system/charts_system.module index 78986b1..b3d9bbc 100644 --- a/charts_system/charts_system.module +++ b/charts_system/charts_system.module @@ -1,47 +1 @@ <?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @author TJ (based on his Chart module) - * @file - * Use Charts for Drupal administration - */ - -/** - * Implementation of hook_menu(). - */ -function charts_system_menu() { - $items['admin/reports/charts'] = array( - 'access arguments' => array('access site reports'), - 'file' => 'charts_system.inc', - 'page callback' => '_charts_system_charts', - 'page arguments' => array('nodes'), - 'title' => 'Charts' - ); - $items['admin/reports/charts/nodes'] = array( - 'access arguments' => array('access site reports'), - 'file' => 'charts_system.inc', - 'page callback' => '_charts_system_charts', - 'page arguments' => array('nodes'), - 'title' => 'Nodes', - 'type' => MENU_DEFAULT_LOCAL_TASK - ); - $items['admin/reports/charts/users'] = array( - 'access arguments' => array('access site reports'), - 'file' => 'charts_system.inc', - 'page callback' => '_charts_system_charts', - 'page arguments' => array('users'), - 'title' => 'Users', - 'type' => MENU_LOCAL_TASK - ); - $items['admin/reports/charts/watchdog'] = array( - 'access arguments' => array('access site reports'), - 'file' => 'charts_system.inc', - 'page callback' => '_charts_system_charts', - 'page arguments' => array('watchdog'), - 'title' => 'Watchdog', - 'type' => MENU_LOCAL_TASK - ); - - return $items; -} diff --git a/fusioncharts/fusioncharts.hooks.inc b/fusioncharts/fusioncharts.hooks.inc new file mode 100644 index 0000000..aa63611 --- /dev/null +++ b/fusioncharts/fusioncharts.hooks.inc @@ -0,0 +1,37 @@ +<?php +// $Id$ +/** + * @author Bruno Massa http://drupal.org/user/67164 + * @file + * Use FusionCharts on your site. + * + * @note only hooks are here. + */ + +/** + * Implementation of hook_charts_info(). + * + * Its a Charts module hook. It defines almost all aspects + * of a chart provider, like its name, what types of charts + * it can perform and what are the restrictions. + */ +function fusioncharts_charts_info() { + return array( + 'fusioncharts' => array( + 'file' => drupal_get_path('module', 'fusioncharts') . '/fusioncharts.inc', + 'name' => t('FusionCharts'), + 'render' => '_fusioncharts_charts_render', + 'types' => array('line2D', 'hbar2D', 'hbar3D', 'vbar2D', 'vbar3D', 'pie2D', 'pie3D'), + ), + ); +} + +/** + * Implementation of hook_chart_types(). + */ +function fusioncharts_chart_types() { + return array( + 'hbar3D' => t('Horizontal Bar 3D'), + 'vbar3D' => t('Vertical Bar 3D'), + ); +} diff --git a/fusioncharts/fusioncharts.inc b/fusioncharts/fusioncharts.inc index 2a66aa2..0fc3020 100644 --- a/fusioncharts/fusioncharts.inc +++ b/fusioncharts/fusioncharts.inc @@ -101,7 +101,7 @@ function _fusioncharts_charts_render(&$data) { return t('This type is not possible using %chartplugin', array('%chartplugin' => 'FusionCharts')); } - $file = file_create_url('fusioncharts') .'/'. $options[$data['#type']]; + $file = file_create_url('fusioncharts') . '/' . $options[$data['#type']]; // Convert the chat SIZE into the FusionCharts way. // Since its a requirement to build the chart on Google, if the value @@ -129,7 +129,7 @@ function _fusioncharts_charts_render(&$data) { return $message; } - $chart = '&dataXML='. str_replace('"', "'", format_xml_elements(array($chart))); + $chart = '&dataXML=' . str_replace('"', "'", format_xml_elements(array($chart))); // Its the HTML tag to include the chart return <<<FUSIONCHARTS diff --git a/fusioncharts/fusioncharts.info b/fusioncharts/fusioncharts.info index f74acb5..d98e53c 100644 --- a/fusioncharts/fusioncharts.info +++ b/fusioncharts/fusioncharts.info @@ -1,6 +1,9 @@ ; $Id$ -core = "6.x" +core = "7.x" dependencies[] = charts description = "Use FusionCharts on your site." +files[] = fusioncharts.inc +files[] = fusioncharts.hooks.inc +files[] = fusioncharts.install name = "FusionCharts" package = "Charts" diff --git a/fusioncharts/fusioncharts.install b/fusioncharts/fusioncharts.install index f59f1e7..d5c142b 100644 --- a/fusioncharts/fusioncharts.install +++ b/fusioncharts/fusioncharts.install @@ -10,8 +10,8 @@ * Implementation of hook_requirements(). */ function fusioncharts_requirements($phase) { - $path = file_create_path() .'/fusioncharts'; - if (!file_exists($path .'/MSLine.swf')) { + $path = file_create_path() . '/fusioncharts'; + if (!file_exists($path . '/MSLine.swf')) { $requirements['charts']['title'] = t('FusionCharts'); $requirements['charts']['value'] = t('FusionCharts flash files not installed'); $requirements['charts']['severity'] = REQUIREMENT_ERROR; diff --git a/fusioncharts/fusioncharts.module b/fusioncharts/fusioncharts.module index 03df4ee..b3d9bbc 100644 --- a/fusioncharts/fusioncharts.module +++ b/fusioncharts/fusioncharts.module @@ -1,37 +1 @@ <?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use FusionCharts on your site. - * - * @note only hooks are here. - */ - -/** - * Immplementation of hook_charts_info(). - * - * Its a Charts module hook. It defines almost all aspects - * of a chart provider, like its name, what types of charts - * it can perform and what are the restrictions. - */ -function fusioncharts_charts_info() { - return array( - 'fusioncharts' => array( - 'file' => drupal_get_path('module', 'fusioncharts') .'/fusioncharts.inc', - 'name' => t('FusionCharts'), - 'render' => '_fusioncharts_charts_render', - 'types' => array('line2D', 'hbar2D', 'hbar3D', 'vbar2D', 'vbar3D', 'pie2D', 'pie3D'), - ), - ); -} - -/** - * Immplementation of hook_chart_types(). - */ -function fusioncharts_chart_types() { - return array( - 'hbar3D' => t('Horizontal Bar 3D'), - 'vbar3D' => t('Vertical Bar 3D'), - ); -} diff --git a/google_charts/google_charts.hooks.inc b/google_charts/google_charts.hooks.inc new file mode 100644 index 0000000..649d3b6 --- /dev/null +++ b/google_charts/google_charts.hooks.inc @@ -0,0 +1,37 @@ +<?php +// $Id$ +/** + * @author Bruno Massa http://drupal.org/user/67164 + * @file + * Use Google Charts on your site. + * + * @note only hooks are here. + */ + +/** + * Implementation of hook_charts_info(). + * + * Its a Charts module hook. It defines almost all aspects + * of a chart provider, like its name, what types of charts + * it can perform and what are the restrictions. + */ +function google_charts_charts_info() { + return array( + 'google' => array( + 'file' => drupal_get_path('module', 'google_charts') . '/google_charts.inc', + 'name' => t('Google Chart'), + 'render' => '_google_charts_render', + 'types' => array('line2D', 'hbar2D', 'vbar2D', 'pie2D', 'pie3D', 'venn', 'scatter'), + ), + ); +} + +/** + * Implementation of hook_chart_types(). + */ +function google_charts_chart_types() { + return array( + 'venn' => t('Venn'), + 'scatter' => t('Scatter Plot'), + ); +} diff --git a/google_charts/google_charts.inc b/google_charts/google_charts.inc index 300ccd0..db26f35 100644 --- a/google_charts/google_charts.inc +++ b/google_charts/google_charts.inc @@ -42,7 +42,7 @@ function _google_charts_chart(&$chart, &$data) { $chart[] = 'cht=pc'; } else { - $chart[] = 'cht='. $options['typecode']; + $chart[] = 'cht=' . $options['typecode']; } // Convert the chat SIZE into the Google Chart way. @@ -51,17 +51,17 @@ function _google_charts_chart(&$chart, &$data) { if (empty($data['#width']) or empty($data['#height'])) { return t('Height and Width are required'); } - $chart[] = 'chs='. $data['#width'] .'x'. $data['#height']; + $chart[] = 'chs=' . $data['#width'] . 'x' . $data['#height']; // Add Title and Description to the chart if (!empty($data['#title'])) { - $chart[] = 'chtt='. $data['#title']; + $chart[] = 'chtt=' . $data['#title']; } // Chart background color. Since the default color // is white (#ffffff), only different colors are considered if (!empty($data['#color']['background']) and $data['#color']['background'] != '#ffffff') { - $chart[] = 'chf=bg,s,'. substr($data['#color']['background'], 1); + $chart[] = 'chf=bg,s,' . substr($data['#color']['background'], 1); } return; @@ -117,7 +117,7 @@ function _google_charts_render(&$data) { } // If its all ok, build the HTML img tag - return '<img src="http://chart.apis.google.com/chart?'. implode('&', $chart) .'" />'; + return '<img src="http://chart.apis.google.com/chart?' . implode('&', $chart) . '" />'; } /** @@ -165,10 +165,10 @@ function _google_charts_series(&$chart, &$data) { // Get the highlight points if (!empty($svalue['#highlight']) or ($data['#type'] == 'scatter' and ($series % 2 == 0))) { - $highlight[] = 't'. $svalue['#label'] .','. - (empty($svalue['#color']) ? substr($data[$series]['#color'], 1) : substr($svalue['#color'], 1)) .','. - $series .','. - $value .','. + $highlight[] = 't' . $svalue['#label'] . ',' . + (empty($svalue['#color']) ? substr($data[$series]['#color'], 1) : substr($svalue['#color'], 1)) . ',' . + $series . ',' . + $value . ',' . (empty($svalue['#size']) ? 10 : $svalue['#size']); } @@ -199,27 +199,27 @@ function _google_charts_series(&$chart, &$data) { } // Insert data - $chart[] = 'chd=s:'. $chart_data; + $chart[] = 'chd=s:' . $chart_data; // Insert series color if (!empty($colors)) { - $chart[] = 'chco='. implode(',', $colors); + $chart[] = 'chco=' . implode(',', $colors); } // Insert values labels if (!empty($value_labels)) { - $chart[] = 'chl='. implode('|', $value_labels); + $chart[] = 'chl=' . implode('|', $value_labels); } // Insert multiple series tag if ($options['legend'] and !empty($legends)) { - $chart[] = 'chdl='. implode('|', $legends); + $chart[] = 'chdl=' . implode('|', $legends); } // Insert values labels if (!empty($highlight)) { - $chart[] = 'chm='. implode('|', $highlight); + $chart[] = 'chm=' . implode('|', $highlight); } return; diff --git a/google_charts/google_charts.info b/google_charts/google_charts.info index 1c2f5a7..5cbd0fe 100644 --- a/google_charts/google_charts.info +++ b/google_charts/google_charts.info @@ -1,6 +1,8 @@ ; $Id$ -core = "6.x" +core = "7.x" dependencies[] = charts description = "Use Google Charts on your site." +files[] = google_charts.inc +files[] = google_charts.hooks.inc name = "Google" package = "Charts" diff --git a/google_charts/google_charts.module b/google_charts/google_charts.module index 2b28c96..b3d9bbc 100644 --- a/google_charts/google_charts.module +++ b/google_charts/google_charts.module @@ -1,37 +1 @@ <?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use Google Charts on your site. - * - * @note only hooks are here. - */ - -/** - * Immplementation of hook_charts_info(). - * - * Its a Charts module hook. It defines almost all aspects - * of a chart provider, like its name, what types of charts - * it can perform and what are the restrictions. - */ -function google_charts_charts_info() { - return array( - 'google' => array( - 'file' => drupal_get_path('module', 'google_charts') .'/google_charts.inc', - 'name' => t('Google Chart'), - 'render' => '_google_charts_render', - 'types' => array('line2D', 'hbar2D', 'vbar2D', 'pie2D', 'pie3D', 'venn', 'scatter'), - ), - ); -} - -/** - * Immplementation of hook_chart_types(). - */ -function google_charts_chart_types() { - return array( - 'venn' => t('Venn'), - 'scatter' => t('Scatter Plot'), - ); -} diff --git a/openflashchart/openflashchart.hooks.inc b/openflashchart/openflashchart.hooks.inc new file mode 100644 index 0000000..ce9627d --- /dev/null +++ b/openflashchart/openflashchart.hooks.inc @@ -0,0 +1,27 @@ +<?php +// $Id$ +/** + * @author Bruno Massa http://drupal.org/user/67164 + * @file + * Use Open Flash Chart on your site. + * + * @note only hooks are here. + */ + +/** + * Implementation of hook_charts_info(). + * + * Its a Charts module hook. It defines almost all aspects + * of a chart provider, like its name, what types of charts + * it can perform and what are the restrictions. + */ +function openflashchart_charts_info() { + return array( + 'openflashchart' => array( + 'file' => drupal_get_path('module', 'openflashchart') . '/openflashchart.inc', + 'name' => t('Open Flash Chart'), + 'render' => '_openflashchart_charts_render', + 'types' => array('line2D', 'vbar2D', 'vbar3D', 'pie2D'), + ), + ); +} diff --git a/openflashchart/openflashchart.info b/openflashchart/openflashchart.info index 244a1a1..c122d41 100644 --- a/openflashchart/openflashchart.info +++ b/openflashchart/openflashchart.info @@ -1,7 +1,9 @@ ; $Id$ -core = "6.x" +core = "7.x" dependencies[] = charts dependencies[] = open_flash_chart_api description = "Use Open Flash Charts on your site." +files[] = openflashchart.inc +files[] = openflashchart.hooks.inc name = "Open Flash Chart" package = "Charts" diff --git a/openflashchart/openflashchart.module b/openflashchart/openflashchart.module index c17cc81..b3d9bbc 100644 --- a/openflashchart/openflashchart.module +++ b/openflashchart/openflashchart.module @@ -1,27 +1 @@ <?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use Open Flash Chart on your site. - * - * @note only hooks are here. - */ - -/** - * Immplementation of hook_charts_info(). - * - * Its a Charts module hook. It defines almost all aspects - * of a chart provider, like its name, what types of charts - * it can perform and what are the restrictions. - */ -function openflashchart_charts_info() { - return array( - 'openflashchart' => array( - 'file' => drupal_get_path('module', 'openflashchart') .'/openflashchart.inc', - 'name' => t('Open Flash Chart'), - 'render' => '_openflashchart_charts_render', - 'types' => array('line2D', 'vbar2D', 'vbar3D', 'pie2D'), - ), - ); -} diff --git a/views/charts.views.inc b/views/charts.views.inc index 474956e..834b722 100644 --- a/views/charts.views.inc +++ b/views/charts.views.inc @@ -7,10 +7,10 @@ */ /** -* Implementation of hook_views_plugins(). -* -* Define charts style for Views. -*/ + * Implementation of hook_views_plugins(). + * + * Define charts style for Views. + */ function charts_views_plugins() { // Views support is only possible if Views Calc module is enabled. It // is responsible for turn the Views values into a aggregates. @@ -24,7 +24,7 @@ function charts_views_plugins() { 'chart' => array( 'handler' => 'charts_plugin_style_chart', 'help' => t('Displays the content in several Chart styles.'), - 'path' => drupal_get_path('module', 'charts') .'/views', + 'path' => drupal_get_path('module', 'charts') . '/views', 'parent' => 'parent', 'title' => t('Chart'), 'type' => 'normal', diff --git a/views/charts_plugin_style_chart.inc b/views/charts_plugin_style_chart.inc index f957aa3..0b6fa1a 100644 --- a/views/charts_plugin_style_chart.inc +++ b/views/charts_plugin_style_chart.inc @@ -95,7 +95,7 @@ class charts_plugin_style_chart extends views_plugin_style { function options_submit(&$form, &$form_state) { $chart = &$form_state['values']['style_options']['charts']; foreach (element_children($chart) as $index) { - $chart['#'. $index] = $chart[$index]; + $chart['#' . $index] = $chart[$index]; unset($chart[$index]); } } @@ -158,7 +158,7 @@ class charts_plugin_style_chart extends views_plugin_style { } $value['#label'] = strip_tags(theme_views_view_field($this->view, $this->view->field[$key], $row)); if ($this->options['show_sums']) { - $value['#label'] .= ' ('. $row->$calc .')'; + $value['#label'] .= ' (' . $row->$calc . ')'; } $value['#value'] = $row->$calc; $chart[$calc][] = $value; @@ -188,7 +188,7 @@ class charts_plugin_style_chart extends views_plugin_style { // another aggregation in for this field. foreach ($this->view->field as $field) { - $query_field = substr($field->field, 0, 3) == 'cid' ? $field->definition['calc'] : $field->table .'.'. $field->field; + $query_field = substr($field->field, 0, 3) == 'cid' ? $field->definition['calc'] : $field->table . '.' . $field->field; $query_alias = $field->field_alias; // Add the aggregation. @@ -204,7 +204,7 @@ class charts_plugin_style_chart extends views_plugin_style { } // Add computed values. if (in_array($field->field, $this->calc_fields())) { - $sql = "ROUND(". $this->options['calc'] ."($query_field), ". $this->options['precision'] .")"; + $sql = "ROUND(" . $this->options['calc'] . "($query_field), " . $this->options['precision'] . ")"; $this->view->query->add_field(NULL, $sql, $field->field, array('aggregate' => TRUE)); // TODO This part is not relationship-safe, needs additional work -- GitLab