d3_views.module in d3.js 7
D3 views module file.
File
modules/d3_views/d3_views.moduleView source
<?php
/**
* @file
* D3 views module file.
*/
/**
* Implements hook_views_api().
*/
function d3_views_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'd3_views') . '/views',
);
}
/**
* Implements hook_theme().
*/
function d3_views_theme() {
return array(
'views_ui_style_d3_options_form' => array(
'render element' => 'form',
),
);
}
function d3_views_library_info_handlers() {
return array(
'views' => array(
'processor' => 'D3ViewsLibraryInfoProcessor',
'controller' => 'D3ViewsLibraryInfoController',
'mapping' => 'D3ViewsDataMapping',
),
);
}
/**
* Implements template_preprocess_views_ui_style_d3_options_form().
*/
function d3_preprocess_views_ui_style_d3_options_form(&$vars) {
drupal_add_css(drupal_get_path('module', 'd3_views') . '/css/views_ui_style_options_form.css');
}
/**
* Helper function to keep code for each row contained.
*
* @see theme_views_ui_style_d3_options_form().
*/
function _theme_views_ui_style_d3_options_form_row(&$element, &$header) {
$td = array();
foreach (element_children($element) as $key) {
// Use the title for the header of the table, and not the label.
$header[] = isset($element[$key]['#title']) ? $element[$key]['#title'] : '';
// Make sure it doesn't get rendered as a label.
unset($element[$key]['#title']);
$td[] = drupal_render($element[$key]);
}
return $td;
}
/**
* Theme the form for the table style plugin.
*/
function theme_views_ui_style_d3_options_form($variables) {
$form = $variables['form'];
$output = drupal_render($form['library']);
$required =& $form['fields'];
// Loop over each type of dataset, default will be 'rows'.
foreach (element_children($required) as $id) {
$header = array();
$rows = array();
// This row does not have sub fields.
if (!empty($required[$id]['field'])) {
$rows[] = _theme_views_ui_style_d3_options_form_row($required[$id], $header);
}
else {
// Each of these sub fields another mapping.
foreach (element_children($required[$id]) as $field_name) {
$header = array();
$rows[] = _theme_views_ui_style_d3_options_form_row($required[$id][$field_name], $header);
}
}
// Each data array has an option to convert it to a numeric array.
$rows[] = array(
array(
'data' => drupal_render($form['numeric'][$id]),
'colspan' => count($header),
),
);
$required['table' . $id] = array(
'#caption' => isset($required[$id]['#caption']) ? $required[$id]['#caption'] : FALSE,
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
);
}
$output .= drupal_render($required) . drupal_render_children($form);
return $output;
}
Functions
Name | Description |
---|---|
d3_preprocess_views_ui_style_d3_options_form | Implements template_preprocess_views_ui_style_d3_options_form(). |
d3_views_library_info_handlers | |
d3_views_theme | Implements hook_theme(). |
d3_views_views_api | Implements hook_views_api(). |
theme_views_ui_style_d3_options_form | Theme the form for the table style plugin. |
_theme_views_ui_style_d3_options_form_row | Helper function to keep code for each row contained. |