4 class DataTables extends Plugin
7 /* Knowing the uuid of a query, we could get the results with Plugins */
9 public function render_content()
10 //$plugin_uuid, $options)
13 //Plugins::add_js('/DataTables/jquery.dataTables.js');
14 Plugins::add_js('//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.js');
15 Plugins::add_js('/DataTables/DataTables.js');
16 //Plugins::add_css('/DataTables/DataTables.css');
17 //Plugins::add_css('/DataTables/demo_table.css');
18 Plugins::add_css('/DataTables/demo_table_jui.css');
26 /* XXX required field in options : query_uuid */
29 $query = Plugins::get_query_by_uuid($this->params['query_uuid']);
30 $is_unique = Plugins::get_key_filter($query);
31 $method_keys = Plugins::get_default_fields($query->method, $is_unique);
32 //$method_keys = Plugins::query_get_default_keys($options['query_uuid']);
33 //$fields = Plugins::query_get_fields($options['query_uuid']);
34 //$all_headers = $_SESSION['metadata']['nodes']['columns'];
35 //$fields = $all_headers;
37 $fields = Plugins::metadata_get_fields($query->method);
42 * debug columns QueryEditor to DataTables
45 // Problem: field names are differents between
46 // $_SESSION['metadata']['nodes']['columns']
48 //$fields[]="arch"; // architecture in Session metadata
49 //$fields[]="astype"; // as_type in Session metadata
50 $fields['platform'] = Array('column' => 'platform');
51 $fields['platform_longname'] = Array('column' => 'platform_longname');
53 //----------------------------------
56 $out[] = "<table class='display' id='table-$uuid'>";
57 $out[] = "<thead><tr>";
59 foreach ($method_keys as $f) {
60 $out[] = "<th>$f</th>";
63 /* We put defaults fields (should be keys) at the beginning, and don't repeat them afterwards */
64 foreach ($fields as $key=>$f) {
65 if((array_search($f['column'], $method_keys)) === false)
66 $out[] = "<th>".$f['column']."</th>";
69 if (array_key_exists('checkboxes', $this->params) && ($this->params['checkboxes'])) {
70 $out[] = "<th>+/-</th>";
72 $out[] = "</tr></thead>";
75 /* This might be done asynchronously */
77 $query = Plugins::get_query_by_uuid($this->params['query_uuid']);
78 foreach ($results as $r) {
80 foreach ($fields as $f) {
82 $out[] = Plugins::render_element($query, $r[$f], $f); // XXX was query->method
85 if (array_key_exists('checkboxes', $this->params) && ($this->params['checkboxes'])) {
86 $out[] = "<td>[X]</td>";
94 /* setup datatables */
96 * - fixed row for key columns
97 * - uniform row height
98 * - how to make some columns disappear
99 * - how to udpate some columns based on keys
104 return implode($out);
108 Plugins::register_plugin(
109 'DataTables', /* plugin name */
110 'DataTables', /* class name */
115 /* XXX dependencies */