views_vertical_tabs.module in Views vertical tabs style plugin 7
Same filename and directory in other branches
Views vertical_tabs style plugin code.
File
views_vertical_tabs.moduleView source
<?php
/**
* @file
* Views vertical_tabs style plugin code.
*/
/**
* Implements hook_views_api().
*/
function views_vertical_tabs_views_api() {
return array(
'api' => 3.0,
);
}
/**
* Implements hook_preprocess_HOOK() for theme_views_view_vertical_tabs().
*/
function template_preprocess_views_view_vertical_tabs(&$vars) {
$view = $vars['view'];
$rows = $vars['rows'];
$style = $view->style_plugin;
$options = $style->options;
$group = $view->name . '_' . $view->current_display;
$element = array(
'#type' => 'vertical_tabs',
'#attached' => array(
'js' => array(
drupal_get_path('module', 'views_vertical_tabs') . '/views_vertical_tabs.js',
),
),
);
$default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : FALSE;
$row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : FALSE;
// Set up striping values.
$count = 0;
$max = count($rows);
$summaries = array();
foreach ($rows as $id => $row) {
$html_id = drupal_html_id($group . '-' . $id);
$classes = array();
$count++;
if ($default_row_class) {
$classes[] = 'views-row';
$classes[] = 'views-row-' . $count;
}
if ($row_class_special) {
$classes[] = 'views-row-' . ($count % 2 ? 'odd' : 'even');
if ($count == 1) {
$classes[] = 'views-row-first';
}
if ($count == $max) {
$classes[] = 'views-row-last';
}
}
if ($row_class = $view->style_plugin
->get_row_class($id)) {
$classes[] = $row_class;
}
$field = $options['title'];
$title = '';
if (isset($view->field[$field])) {
$title = $style
->get_field($id, $field);
if ($view->field[$field]->options['label']) {
$title = $view->field[$field]->options['label'] . ': ' . $title;
}
$title = strip_tags(htmlspecialchars_decode($title));
}
$field = $options['description'];
$description = '';
if (isset($view->field[$field])) {
$description = $style
->get_field($id, $field);
if ($view->field[$field]->options['label']) {
$description = $view->field[$field]->options['label'] . ': ' . $description;
}
$description = strip_tags(htmlspecialchars_decode($description));
}
$field = $options['summary'];
$summary = '';
if (isset($view->field[$field])) {
$summary = $style
->get_field($id, $field);
if ($view->field[$field]->options['label']) {
$summary = $view->field[$field]->options['label'] . ': ' . $summary;
}
$summary = strip_tags(htmlspecialchars_decode($summary));
}
if (!empty($summary)) {
$summaries[$html_id] = $summary;
}
$element[$id] = array(
'#title' => $title,
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#children' => $row,
'#description' => $description,
'#attributes' => array(
'class' => $classes,
'id' => $html_id,
),
);
}
drupal_add_js(array(
'views_vertical_tabs' => array(
$group => $summaries,
),
), 'setting');
$vars['vertical_tabs'][] = $element;
}
Functions
Name | Description |
---|---|
template_preprocess_views_view_vertical_tabs | Implements hook_preprocess_HOOK() for theme_views_view_vertical_tabs(). |
views_vertical_tabs_views_api | Implements hook_views_api(). |