1
1
<?php
2
2
3
3
/**
4
- * Implementation of hook_views_api().
4
+ * Implements hook_views_api().
5
5
*/
6
6
function flot_views_api() {
7
7
return array(
8
8
'api' => 2,
9
- 'path' => drupal_get_path('module', 'flot') .'/views',
9
+ 'path' => drupal_get_path('module', 'flot') . '/views',
10
10
);
11
11
}
12
12
13
13
/**
14
- * Implementation of hook_theme.
14
+ * Implements hook_theme() .
15
15
*/
16
16
function flot_theme() {
17
17
return array(
18
18
'flot_graph' => array(
19
- 'arguments ' => array('element' => array(), 'data' => array(), 'options' => array()),
19
+ 'variables ' => array('element' => array(), 'data' => array(), 'options' => array()),
20
20
),
21
21
);
22
22
}
@@ -25,30 +25,34 @@ function flot_theme() {
25
25
* Main flot graphing function
26
26
*
27
27
* @param $element
28
- * An associative array to define a placeholder element. If an 'id' is
28
+ * An associative array to define a placeholder element. If an 'id' is
29
29
* omitted one will be generated, If no 'style' is specified and width and
30
30
* height style will be added. In short you can just pass an empty array and
31
31
* everything will still work. This argument is essentially optional and has
32
32
* been kept as the first argument to remain consistant with flots own api.
33
33
* @param $data
34
- * The data series for the graph. Optional. See flot's API.txt for more
34
+ * The data series for the graph. Optional. See flot's API.txt for more
35
35
* details. This module defines the flotData class which can be used or
36
36
* extended to make generating data objects simpler.
37
37
* @param $options
38
38
* Options to pass to flot. Optional. See flot's API.txt for more details.
39
39
* @param $loader
40
- * Allows alterative loading of flot data. If 'false' data will passed
40
+ * Allows alterative loading of flot data. If 'false' data will passed
41
41
* directly to an invocation of $.plot(). Otherwise the contents of $loader
42
42
* should be js.
43
43
*
44
44
* @return
45
45
* The placeholder element
46
46
*/
47
- function theme_flot_graph($element, $data = array(), $options = array(), $loader = false) {
47
+ function theme_flot_graph($variables) {
48
+ $element = $variables['element'];
49
+ $data = $variables['data'];
50
+ $options = $variables['options'];
51
+ // TODO Number of parameters in this theme funcion does not match number of parameters found in hook_theme.
48
52
static $n;
49
53
if (!isset($element['id'])) {
50
54
$n++;
51
- $element['id'] = 'flot-auto-identifier-'. $n;
55
+ $element['id'] = 'flot-auto-identifier-' . $n;
52
56
}
53
57
54
58
if (!isset($element['style'])) {
@@ -62,22 +66,22 @@ function theme_flot_graph($element, $data = array(), $options = array(), $loader
62
66
$id = str_replace('-', '_', $element['id']);
63
67
64
68
if ($loader) {
65
- $json_data = function_exists('json_encode') ? json_encode($data) : drupal_to_js ($data);
69
+ $json_data = function_exists('json_encode') ? json_encode($data) : drupal_json_encode ($data);
66
70
$extra = "Drupal.flot.{$id}_data = {$json_data}; {$loader}";
67
71
$data = array();
68
72
}
69
73
70
- $json_data = function_exists('json_encode') ? json_encode($data) : drupal_to_js ($data);
71
- $json_options = function_exists('json_encode') ? json_encode($options) : drupal_to_js ($options);
74
+ $json_data = function_exists('json_encode') ? json_encode($data) : drupal_json_encode ($data);
75
+ $json_options = function_exists('json_encode') ? json_encode($options) : drupal_json_encode ($options);
72
76
$data = "if (Drupal.jsEnabled) {
73
77
$(document).ready(function() {
74
78
Drupal.flot.{$id} = $.plot($('#{$element['id']}'), {$json_data}, {$json_options});
75
79
{$extra}
76
80
});
77
81
}";
78
- drupal_add_js($data, ' inline');
82
+ drupal_add_js($data, array('type' => ' inline', 'scope' => JS_DEFAULT) );
79
83
}
80
- return '<div '. drupal_attributes($element) .'> </div>';
84
+ return '<div ' . drupal_attributes($element) . '> </div>';
81
85
}
82
86
83
87
/**
@@ -90,24 +94,24 @@ function flot_add_js() {
90
94
$path = libraries_get_path('flot');
91
95
}
92
96
if (!isset($path)) {
93
- $path = drupal_get_path('module', 'flot') .'/flot';
97
+ $path = drupal_get_path('module', 'flot') . '/flot';
94
98
}
95
99
96
100
// Different versions of flot have used different packing methods. Attempt to support both.
97
101
$excanvas = file_exists("{$path}/excanvas.min.js") ? "{$path}/excanvas.min.js" : "{$path}/excanvas.pack.js";
98
- drupal_set_html_head ('<!--[if IE]><script language="javascript" type="text/javascript" src="'. base_path() . $excanvas . '"></script><![endif]-->');
102
+ drupal_add_html_head ('<!--[if IE]><script language="javascript" type="text/javascript" src="' . base_path() . $excanvas . '"></script><![endif]-->', $key = NULL /* TODO Set this variable. */ );
99
103
drupal_add_js($path . '/jquery.flot.js');
100
- drupal_add_js('if (Drupal.jsEnabled) { Drupal.flot = {}; }', ' inline');
104
+ drupal_add_js('if (Drupal.jsEnabled) { Drupal.flot = {}; }', array('type' => ' inline', 'scope' => JS_DEFAULT) );
101
105
102
106
$added = true;
103
107
}
104
108
}
105
109
106
110
/**
107
- * Data class for the flot API.
108
- *
109
- * Make some nested objects to keep things simple when creating a data series.
110
- */
111
+ * Data class for the flot API.
112
+ *
113
+ * Make some nested objects to keep things simple when creating a data series.
114
+ */
111
115
class flotData {
112
116
113
117
public $data;
0 commit comments