function template_preprocess_semanticviews_view_unformatted in Semantic Views 7
Same name and namespace in other branches
- 6 semanticviews.theme.inc \template_preprocess_semanticviews_view_unformatted()
Display the simple view of rows one after another
File
- ./
semanticviews.theme.inc, line 75 - Theme for Semantic Views.
Code
function template_preprocess_semanticviews_view_unformatted(&$vars) {
$view = $vars['view'];
$vars['group_element'] = check_plain($vars['options']['group']['element_type']);
$vars['group_attributes'] = array();
if ($vars['options']['group']['class']) {
$vars['group_attributes']['class'] = $vars['options']['group']['class'];
}
$vars['list_element'] = check_plain($vars['options']['list']['element_type']);
$vars['list_attributes'] = array();
if ($vars['options']['list']['class']) {
$vars['list_attributes']['class'] = $vars['options']['list']['class'];
}
// TODO: set a default or handle empty value.
$vars['row_element'] = check_plain($vars['options']['row']['element_type']);
$last_every_nth = $vars['options']['row']['last_every_nth'];
$vars['row_attributes'] = array();
// Set up striping class array.
$stripes = array();
if (trim($vars['options']['row']['striping_classes'])) {
$stripes = explode(' ', trim($vars['options']['row']['striping_classes']));
}
$striping = count($stripes);
// When grouping fields row index doesn't reset in each group so we have to do it manually,
// otherwise "last_every_nth" may work incorrect.
$index_in_group = 0;
foreach ($vars['rows'] as $id => $row) {
$vars['row_attributes'][$id] = array();
$classes = array();
if ($row_class = $view->style_plugin
->tokenize_class($id, $vars['options']['row']['class'])) {
$classes[] = $row_class;
}
if ($vars['options']['row']['first_class']) {
// The FIRST class attribute can be used in two ways. When the "last every
// nth" option is specified, the FIRST attribute is added to the class in
// those intervals. This could be useful for grid designs where the first
// unit in a row needs a zero width margin.
if ($last_every_nth && $index_in_group % $last_every_nth == 0 || !$last_every_nth && $index_in_group == 0) {
if ($class = $view->style_plugin
->tokenize_class($id, $vars['options']['row']['first_class'])) {
$classes[] = $class;
}
}
}
if ($vars['options']['row']['last_class']) {
// The LAST class attribute can be used in two ways. When the "last every
// nth" option is specified, the LAST attribute is added to the class in
// those intervals. This could be useful for grid designs where the last
// unit in a row needs a zero width margin.
if ($last_every_nth && ($index_in_group + 1) % $last_every_nth == 0 || !$last_every_nth && $index_in_group + 1 == count($vars['rows'])) {
if ($class = $view->style_plugin
->tokenize_class($id, $vars['options']['row']['last_class'])) {
$classes[] = $class;
}
}
}
if ($striping) {
if ($class = $view->style_plugin
->tokenize_class($id, $stripes[$id % $striping])) {
$classes[] = $class;
}
}
if (!empty($classes)) {
$vars['row_attributes'][$id]['class'] = implode(' ', $classes);
}
$index_in_group++;
}
}