function template_preprocess_views_view_fieldset in Views fieldset style plugin 7
Same name and namespace in other branches
- 8 views_fieldset.module \template_preprocess_views_view_fieldset()
Implements hook_preprocess_HOOK() for theme_views_view_fieldset().
File
- ./
views_fieldset.module, line 20 - Views fieldset style plugin code.
Code
function template_preprocess_views_view_fieldset(&$vars) {
$view = $vars['view'];
$rows = $vars['rows'];
$style = $view->style_plugin;
$options = $style->options;
$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);
foreach ($rows as $id => $row) {
$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));
}
$element = array(
'#title' => $title,
'#type' => 'fieldset',
'#collapsed' => $options['collapsed'],
'#collapsible' => $options['collapsible'],
'#children' => $row,
'#parents' => array(),
'#description' => $description,
'#attributes' => array(
'class' => $classes,
),
);
// Leave first fieldset open if all the fieldset are collapsed and open
// first is TRUE.
if ($id == 0 && $options['collapsed'] && $options['open_first']) {
$element['#collapsed'] = FALSE;
}
$form_state = array();
$element = form_process_fieldset($element, $form_state);
$vars['fieldsets'][] = $element;
}
}