- <?php
- * @file
- * Preprocessors and helper functions to make theme development easier.
- */
-
- * Provide a full array of possible themes to try for a given hook.
- *
- * @param $hook
- * The hook to use. This is the base theme/template name.
- * @param $view
- * The view being rendered.
- * @param $display
- * The display being rendered, if applicable.
- */
- function _views_theme_functions($hook, $view, $display = NULL) {
- $themes = array();
-
- if ($display) {
- $themes[] = $hook . '__' . $view->name . '__' . $display->id;
- $themes[] = $hook . '__' . $display->id;
- $themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '_', strtolower((string) $view->tag));
-
-
- foreach (backdrop_explode_tags($view->tag) as $tag) {
- $themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '_', strtolower($tag));
- }
-
- if ($display->id != $display->display_plugin) {
- $themes[] = $hook . '__' . $view->name . '__' . $display->display_plugin;
- $themes[] = $hook . '__' . $display->display_plugin;
- }
- }
- $themes[] = $hook . '__' . $view->name;
- $themes[] = $hook;
- return $themes;
- }
-
- * Preprocess the primary theme implementation for a view.
- */
- function template_preprocess_views_view(&$variables) {
- global $base_path;
-
- $view = $variables['view'];
-
- $variables['rows'] = (!empty($view->result) || $view->style_plugin->even_empty()) ? $view->style_plugin->render($view->result) : '';
-
- $variables['css_name'] = backdrop_clean_css_identifier($view->name);
- $variables['name'] = $view->name;
- $variables['display_id'] = $view->current_display;
-
-
- $variables['css_class'] = '';
-
- $variables['classes'] = array();
- $variables['classes'][] = 'view';
- $variables['classes'][] = 'view-' . $variables['css_name'];
- $variables['classes'][] = 'view-id-' . $variables['name'];
- $variables['classes'][] = 'view-display-id-' . $variables['display_id'];
-
- $css_class = $view->display_handler->get_option('css_class');
- if (!empty($css_class)) {
- $variables['css_class'] = preg_replace('/[^a-zA-Z0-9- ]/', '-', $css_class);
- $variables['classes'][] = $variables['css_class'];
- }
-
- $empty = empty($variables['rows']);
-
- $variables['header'] = $view->display_handler->render_area('header', $empty);
- $variables['footer'] = $view->display_handler->render_area('footer', $empty);
- if ($empty) {
- $variables['empty'] = $view->display_handler->render_area('empty', $empty);
- }
-
- $variables['exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : '';
- $variables['more'] = $view->display_handler->render_more_link();
- $variables['feed_icon'] = !empty($view->feed_icon) ? $view->feed_icon : '';
-
- $variables['pager'] = '';
-
-
-
- $variables['title'] = !empty($view->views_ui_context) ? filter_xss_admin($view->get_title()) : '';
-
- if ($view->display_handler->render_pager()) {
- $exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL;
- $variables['pager'] = $view->query->render_pager($exposed_input);
- }
-
- $variables['attachment_before'] = !empty($view->attachment_before) ? $view->attachment_before : '';
- $variables['attachment_after'] = !empty($view->attachment_after) ? $view->attachment_after : '';
-
-
-
-
-
-
-
- views_add_contextual_links($variables['view_array'], 'view', $view, $view->current_display);
-
-
-
- if (empty($view->is_attachment)) {
-
-
-
-
-
-
-
-
-
- $variables['dom_id'] = $view->dom_id;
- $variables['classes'][] = 'view-dom-id-' . $variables['dom_id'];
- }
-
-
- if ($view->use_ajax && empty($view->is_attachment) && empty($view->live_preview)) {
- $settings = array(
- 'views' => array(
- 'ajax_path' => url('views/ajax'),
- 'ajaxViews' => array(
- 'views_dom_id:' . $variables['dom_id'] => array(
- 'view_name' => $view->name,
- 'view_display_id' => $view->current_display,
- 'view_args' => check_plain(implode('/', $view->args)),
- 'view_path' => check_plain($_GET['q']),
-
- 'view_base_path' => $view->get_path(),
- 'view_dom_id' => $variables['dom_id'],
-
-
- 'pager_element' => isset($view->query->pager) ? $view->query->pager->get_pager_id() : 0,
- ),
- ),
- ),
- );
-
- backdrop_add_js($settings, 'setting');
- views_add_js('ajax_view');
- }
-
-
- if (views_view_has_form_elements($view)) {
- $output = !empty($variables['rows']) ? $variables['rows'] : $variables['empty'];
- $form = backdrop_get_form(views_form_id($view), $view, $output);
-
-
- if ($form['show_view_elements']['#value'] == FALSE) {
- $variables['header'] = '';
- $variables['exposed'] = '';
- $variables['pager'] = '';
- $variables['footer'] = '';
- $variables['more'] = '';
- $variables['feed_icon'] = '';
- }
- $variables['rows'] = $form;
- }
- }
-
- * Preprocess theme function to print a single record from a row, with fields
- */
- function template_preprocess_views_view_fields(&$variables) {
- $view = $variables['view'];
-
-
- $previous_inline = FALSE;
- $variables['fields'] = array();
- foreach ($view->field as $id => $field) {
-
- $field_output = $view->style_plugin->get_field($view->row_index, $id);
- $empty = $field->is_value_empty($field_output, $field->options['empty_zero']);
- if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($variables['options']['hide_empty'])))) {
- $object = new stdClass();
- $object->handler = &$view->field[$id];
- $object->inline = !empty($variables['options']['inline'][$id]);
-
- $object->element_type = $object->handler->element_type(TRUE, !$variables['options']['default_field_elements'], $object->inline);
- if ($object->element_type) {
- $class = '';
- if ($object->handler->options['element_default_classes']) {
- $class = 'field-content';
- }
-
- if ($classes = $object->handler->element_classes($view->row_index)) {
- if ($class) {
- $class .= ' ';
- }
- $class .= $classes;
- }
-
- $pre = '<' . $object->element_type;
- if ($class) {
- $pre .= ' class="' . $class . '"';
- }
- $field_output = $pre . '>' . $field_output . '</' . $object->element_type . '>';
- }
-
-
-
- if (empty($object->element_type)) {
- $object->element_type = 'span';
- }
-
- $object->content = $field_output;
- if (isset($view->field[$id]->field_alias) && isset($variables['row']->{$view->field[$id]->field_alias})) {
- $object->raw = $variables['row']->{$view->field[$id]->field_alias};
- }
- else {
- $object->raw = NULL;
- }
-
- if (!empty($variables['options']['separator']) && $previous_inline && $object->inline && $object->content) {
- $object->separator = filter_xss_admin($variables['options']['separator']);
- }
-
- $object->class = backdrop_clean_css_identifier($id);
-
- $previous_inline = $object->inline;
- $object->inline_html = $object->handler->element_wrapper_type(TRUE, TRUE);
- if ($object->inline_html === '' && $variables['options']['default_field_elements']) {
- $object->inline_html = $object->inline ? 'span' : 'div';
- }
-
-
- $object->wrapper_prefix = '';
- $object->wrapper_suffix = '';
-
- if ($object->inline_html) {
- $class = '';
- if ($object->handler->options['element_default_classes']) {
- $class = "views-field views-field-" . $object->class;
- }
-
- if ($classes = $object->handler->element_wrapper_classes($view->row_index)) {
- if ($class) {
- $class .= ' ';
- }
- $class .= $classes;
- }
-
- $object->wrapper_prefix = '<' . $object->inline_html;
- if ($class) {
- $object->wrapper_prefix .= ' class="' . $class . '"';
- }
- $object->wrapper_prefix .= '>';
- $object->wrapper_suffix = '</' . $object->inline_html . '>';
- }
-
-
-
- $object->label = check_plain($view->field[$id]->label());
- $object->label_html = '';
- if ($object->label) {
- $object->label_html .= $object->label;
- if ($object->handler->options['element_label_colon']) {
- $object->label_html .= ': ';
- }
-
- $object->element_label_type = $object->handler->element_label_type(TRUE, !$variables['options']['default_field_elements']);
- if ($object->element_label_type) {
- $class = '';
- if ($object->handler->options['element_default_classes']) {
- $class = 'views-label views-label-' . $object->class;
- }
-
- $element_label_class = $object->handler->element_label_classes($view->row_index);
- if ($element_label_class) {
- if ($class) {
- $class .= ' ';
- }
-
- $class .= $element_label_class;
- }
-
- $pre = '<' . $object->element_label_type;
- if ($class) {
- $pre .= ' class="' . $class . '"';
- }
- $pre .= '>';
-
- $object->label_html = $pre . $object->label_html . '</' . $object->element_label_type . '>';
- }
- }
-
- $variables['fields'][$id] = $object;
- }
- }
-
- }
-
- * Display a single views grouping.
- */
- function theme_views_view_grouping($variables) {
- $view = $variables['view'];
- $title = $variables['title'];
- $content = $variables['content'];
-
- $output = '<div class="view-grouping">';
- $output .= '<div class="view-grouping-header">' . $title . '</div>';
- $output .= '<div class="view-grouping-content">' . $content . '</div>' ;
- $output .= '</div>';
-
- return $output;
- }
-
- * Process a single grouping within a view.
- */
- function template_preprocess_views_view_grouping(&$variables) {
- $variables['content'] = $variables['view']->style_plugin->render_grouping_sets($variables['rows'], $variables['grouping_level']);
- }
-
- * Display a single views field.
- *
- * Interesting bits of info:
- * $field->field_alias says what the raw value in $row will be. Reach it like
- * this: @code { $row->{$field->field_alias} @endcode
- */
- function theme_views_view_field($variables) {
- $view = $variables['view'];
- $field = $variables['field'];
- $row = $variables['row'];
- return $variables['output'];
- }
-
- * Process a single field within a view.
- *
- * This preprocess function isn't normally run, as a function is used by
- * default, for performance. However, by creating a template, this
- * preprocess should get picked up.
- */
- function template_preprocess_views_view_field(&$variables) {
- $variables['output'] = $variables['field']->advanced_render($variables['row']);
- }
-
- * Preprocess theme function to print a single record from a row, with fields
- */
- function template_preprocess_views_view_summary(&$variables) {
- $view = $variables['view'];
- $argument = $view->argument[$view->build_info['summary_level']];
- $variables['row_classes'] = array();
-
- $url_options = array();
-
- if (!empty($view->exposed_raw_input)) {
- $url_options['query'] = $view->exposed_raw_input;
- }
-
- $active_urls = backdrop_map_assoc(array(
- url($_GET['q'], array('alias' => TRUE)),
- url($_GET['q']),
- ));
-
-
-
- $row_args = array();
-
- foreach ($variables['rows'] as $id => $row) {
- $row_args[$id] = $argument->summary_argument($row);
- }
- $argument->process_summary_arguments($row_args);
-
- foreach ($variables['rows'] as $id => $row) {
- $variables['row_classes'][$id] = '';
-
- $variables['rows'][$id]->link = $argument->summary_name($row);
- $args = $view->args;
- $args[$argument->position] = $row_args[$id];
-
- $base_path = NULL;
- if (!empty($argument->options['summary_options']['base_path'])) {
- $base_path = $argument->options['summary_options']['base_path'];
- }
- $variables['rows'][$id]->url = url($view->get_url($args, $base_path), $url_options);
- $variables['rows'][$id]->count = intval($row->{$argument->count_alias});
- if (isset($active_urls[$variables['rows'][$id]->url])) {
- $variables['row_classes'][$id] = 'active';
- }
- }
- }
-
- * Template preprocess theme function to print summary basically
- * unformatted.
- */
- function template_preprocess_views_view_summary_unformatted(&$variables) {
- $view = $variables['view'];
- $argument = $view->argument[$view->build_info['summary_level']];
- $variables['row_classes'] = array();
-
- $url_options = array();
-
- if (!empty($view->exposed_raw_input)) {
- $url_options['query'] = $view->exposed_raw_input;
- }
-
- $count = 0;
- $active_urls = backdrop_map_assoc(array(
- url($_GET['q'], array('alias' => TRUE)),
- url($_GET['q']),
- ));
-
-
-
- $row_args = array();
- foreach ($variables['rows'] as $id => $row) {
- $row_args[$id] = $argument->summary_argument($row);
- }
- $argument->process_summary_arguments($row_args);
-
- foreach ($variables['rows'] as $id => $row) {
-
- if ($count++) {
- $variables['rows'][$id]->separator = filter_xss_admin($variables['options']['separator']);
- }
- $variables['rows'][$id]->link = $argument->summary_name($row);
- $args = $view->args;
- $args[$argument->position] = $row_args[$id];
-
- $base_path = NULL;
- if (!empty($argument->options['summary_options']['base_path'])) {
- $base_path = $argument->options['summary_options']['base_path'];
- }
- $variables['rows'][$id]->url = url($view->get_url($args, $base_path), $url_options);
- $variables['rows'][$id]->count = intval($row->{$argument->count_alias});
- if (isset($active_urls[$variables['rows'][$id]->url])) {
- $variables['row_classes'][$id] = 'active';
- }
- }
- }
-
- * Display a view as a table style.
- */
- function template_preprocess_views_view_table(&$variables) {
- $view = $variables['view'];
-
-
-
-
-
-
- $result = $variables['result'] = $variables['rows'];
- $variables['rows'] = array();
- $variables['field_classes'] = array();
- $variables['header'] = array();
-
- $options = $view->style_plugin->options;
- $handler = $view->style_plugin;
-
- $default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : TRUE;
- $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE;
-
- $fields = &$view->field;
- $columns = $handler->sanitize_columns($options['columns'], $fields);
-
- $active = !empty($handler->active) ? $handler->active : '';
- $order = !empty($handler->order) ? $handler->order : 'asc';
- $responsive_columns = array();
-
- $query = tablesort_get_query_parameters();
- if (isset($view->exposed_raw_input)) {
- $query += $view->exposed_raw_input;
- }
-
-
-
- $renders = $handler->render_fields($result);
-
- foreach ($columns as $field => $column) {
-
-
- $variables['fields'][$field] = backdrop_clean_css_identifier($field);
- if ($active == $field) {
- $variables['fields'][$field] .= ' active';
- }
-
-
- if ($field == $column && empty($fields[$field]->options['exclude'])) {
- $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : '');
- if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) {
- $variables['header'][$field] = $label;
- }
- else {
- $initial = !empty($options['info'][$field]['default_sort_order']) ? $options['info'][$field]['default_sort_order'] : 'asc';
-
- if ($active == $field) {
- $initial = ($order == 'asc') ? 'desc' : 'asc';
- }
-
- $title = t('sort by @s', array('@s' => $label));
- if ($active == $field) {
- $label .= theme('tablesort_indicator', array('style' => $initial));
- }
-
- $query['order'] = $field;
- $query['sort'] = $initial;
- $link_options = array(
- 'html' => TRUE,
- 'attributes' => array('title' => $title),
- 'query' => $query,
- );
- $variables['header'][$field] = l($label, $_GET['q'], $link_options);
- }
-
- $variables['header_classes'][$field] = array();
-
- if ($fields[$field]->options['element_default_classes']) {
- $variables['header_classes'][$field][] = "views-field";
- $variables['header_classes'][$field][] = "views-field-" . $variables['fields'][$field];
- }
- $class = $fields[$field]->element_label_classes(0);
- if ($class) {
- $variables['header_classes'][$field][] = $class;
- }
-
- if (!empty($options['info'][$field]['align'])) {
- $variables['header_classes'][$field][] = backdrop_clean_css_identifier($options['info'][$field]['align']);
- }
-
- if ($active == $field) {
- $variables['header_classes'][$field][] = 'active';
- }
-
-
- if ($variables['header'][$field]) {
- $element_label_type = $fields[$field]->element_label_type(TRUE, TRUE);
- if ($element_label_type) {
- $variables['header'][$field] = '<' . $element_label_type . '>' . $variables['header'][$field] . '</' . $element_label_type . '>';
- }
- }
-
-
-
-
-
- if (in_array(RESPONSIVE_PRIORITY_MEDIUM, $variables['header_classes'][$field])) {
- $responsive_columns[$field] = RESPONSIVE_PRIORITY_MEDIUM;
- }
- elseif (in_array(RESPONSIVE_PRIORITY_LOW, $variables['header_classes'][$field])) {
- $responsive_columns[$field] = RESPONSIVE_PRIORITY_LOW;
- }
- }
-
-
- if (!empty($options['info'][$field]['align'])) {
- $variables['fields'][$field] .= ' ' . backdrop_clean_css_identifier($options['info'][$field]['align']);
- }
-
-
- foreach ($result as $num => $row) {
-
- $variables['field_attributes'][$field][$num] = array();
- $variables['field_classes'][$field][$num] = array();
- if ($fields[$field]->options['element_default_classes']) {
- $variables['field_classes'][$field][$num][] = "views-field";
- $variables['field_classes'][$field][$num][] = "views-field-" . $variables['fields'][$field];
- }
-
-
- if (isset($responsive_columns[$field])) {
- $variables['field_classes'][$field][$num][] = $responsive_columns[$field];
- }
- if ($classes = $fields[$field]->element_classes($num)) {
- $classes_array = explode(' ', $classes);
- $variables['field_classes'][$field][$num] = array_merge($variables['field_classes'][$field][$num], $classes_array);
- }
-
- if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) {
- $field_output = $renders[$num][$field];
- $element_type = $fields[$field]->element_type(TRUE, TRUE);
- if ($element_type) {
- $field_output = '<' . $element_type . '>' . $field_output . '</' . $element_type . '>';
- }
-
-
- if (empty($field_output) && !empty($variables['rows'][$num][$column])) {
- continue;
- }
-
-
- if (!empty($variables['rows'][$num][$column])) {
- if (!empty($options['info'][$column]['separator'])) {
- $variables['rows'][$num][$column] .= filter_xss_admin($options['info'][$column]['separator']);
- }
- }
- else {
- $variables['rows'][$num][$column] = '';
- }
-
- $variables['rows'][$num][$column] .= $field_output;
- }
- }
-
-
- if (!empty($options['info'][$field]['empty_column'])) {
- $empty = TRUE;
- foreach ($variables['rows'] as $num => $columns) {
- $empty &= empty($columns[$column]);
- }
- if ($empty) {
- foreach ($variables['rows'] as $num => &$column_items) {
- unset($column_items[$column]);
- unset($variables['header'][$column]);
- }
- }
- }
- }
-
-
- if (!array_filter($variables['header'])) {
- $variables['header'] = array();
- }
-
- $count = 0;
- foreach ($variables['rows'] as $num => $row) {
- $variables['row_classes'][$num] = array();
- if ($row_class_special) {
- $variables['row_classes'][$num][] = ($count++ % 2 == 0) ? 'odd' : 'even';
- }
- if ($row_class = $handler->get_row_class($num)) {
- $variables['row_classes'][$num][] = $row_class;
- }
- }
-
- if ($row_class_special) {
- $variables['row_classes'][0][] = 'first';
- $variables['row_classes'][count($variables['row_classes']) - 1][] = 'last';
- }
-
- $variables['classes'] = array('views-table');
- if (empty($variables['rows']) && !empty($options['empty_table'])) {
- $variables['rows'][0][0] = $view->display_handler->render_area('empty');
-
- $variables['field_attributes'][0][0]['colspan'] = count($variables['header']);
- $variables['field_classes'][0][0] = array('views-empty');
- }
-
-
- if (!empty($options['sticky'])) {
- backdrop_add_js('core/misc/tableheader.js');
- $variables['classes'][] = 'sticky-enabled';
- }
-
-
- if (count($responsive_columns)) {
- backdrop_add_library('system', 'backdrop.tableresponsive');
-
-
- $variables['classes'][] = 'responsive-enabled';
- }
- $variables['classes'][] = 'cols-'. count($variables['header']);
-
-
- if (!empty($handler->options['summary'])) {
- $variables['attributes'] = array('summary' => filter_xss_admin($handler->options['summary']));
- }
-
-
- if (!empty($handler->options['caption'])) {
- $variables['caption'] = filter_xss_admin($handler->options['caption']);
- }
- else {
- $variables['caption'] = '';
- }
- }
-
- * Display a view as a grid style.
- */
- function template_preprocess_views_view_grid(&$variables) {
- $view = $variables['view'];
- $result = $view->result;
- $options = $view->style_plugin->options;
- $handler = $view->style_plugin;
- $default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : TRUE;
- $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE;
-
- $columns = $options['columns'];
-
- $rows = array();
- $row_indexes = array();
-
-
- $variables['deprecated_table'] = (!isset($options['deprecated_table']) || $options['deprecated_table']) ? TRUE : FALSE;
-
- if (!$variables['deprecated_table']) {
- $rows = $variables['rows'];
-
-
- $count = 0;
- $max = count($rows);
-
-
- if ($options['alignment'] == 'vertical') {
- $rows = array();
- $rows_reorder = array();
- $num_rows = floor(count($variables['rows']) / $columns);
-
- $remainders = count($variables['rows']) % $columns;
- $row = 0;
- $col = 0;
-
- foreach ($variables['rows'] as $count => $item) {
- $rows_reorder[$row][$col] = $item;
-
- $row_indexes[$row][$col] = $count;
-
- $row++;
-
- if (!$remainders && $row == $num_rows) {
- $row = 0;
- $col++;
- }
- elseif ($remainders && $row == $num_rows + 1) {
- $row = 0;
- $col++;
- $remainders--;
- }
- }
-
-
- $col = 0;
- foreach ($rows_reorder as $row) {
- foreach ($row as $column) {
- $rows[$col] = $column;
- $col++;
- }
- }
-
- }
-
- $count = 0;
- $col_count = 1;
- foreach ($rows as $id => $row) {
- $count++;
- $variables['row_classes'][$id] = array();
- if ($default_row_class) {
- $variables['row_classes'][$id][] = 'views-grid-box';
- $variables['row_classes'][$id][] = 'views-grid-box-' . $count;
- }
- if ($row_class_special) {
- $variables['row_classes'][$id][] = ($count % 2 ? 'odd' : 'even');
- if ($count == 1) {
- $variables['row_classes'][$id][] = 'first';
- }
- if ($count == $max) {
- $variables['row_classes'][$id][] = 'last';
- }
- if ($col_count == 1) {
- $variables['row_classes'][$id][] = 'row-first';
- }
- if ($col_count == $options['columns']) {
- $variables['row_classes'][$id][] = 'row-last';
- }
- }
- if ($row_class = $view->style_plugin->get_row_class($id)) {
- $variables['row_classes'][$id][] = $row_class;
- }
- if ($col_count == $options['columns']) {
- $col_count = 1;
- } else {
- $col_count++;
- }
- }
- $variables['classes'] = array('views-view-grid', 'views-view-grid-cols-' . $columns);
- }
- else {
- if ($options['alignment'] == 'horizontal') {
- $row = array();
- $col_count = 0;
- $row_count = 0;
- $count = 0;
- foreach ($variables['rows'] as $row_index => $item) {
- $count++;
- $row[] = $item;
- $row_indexes[$row_count][$col_count] = $row_index;
- $col_count++;
- if ($count % $columns == 0) {
- $rows[] = $row;
- $row = array();
- $col_count = 0;
- $row_count++;
- }
- }
- if ($row) {
-
- if (!empty($handler->options['fill_single_line']) && count($rows)) {
- for ($i = 0; $i < ($columns - $col_count); $i++) {
- $row[] = '';
- }
- }
- $rows[] = $row;
- }
- }
- else {
- $num_rows = floor(count($variables['rows']) / $columns);
-
- $remainders = count($variables['rows']) % $columns;
- $row = 0;
- $col = 0;
- foreach ($variables['rows'] as $count => $item) {
- $rows[$row][$col] = $item;
- $row_indexes[$row][$col] = $count;
- $row++;
-
- if (!$remainders && $row == $num_rows) {
- $row = 0;
- $col++;
- }
- elseif ($remainders && $row == $num_rows + 1) {
- $row = 0;
- $col++;
- $remainders--;
- }
- }
- for ($i = 0; $i < count($rows[0]); $i++) {
-
- if (!isset($rows[count($rows) - 1][$i])) {
- $rows[count($rows) - 1][$i] = '';
- }
- }
- }
-
-
- foreach ($rows as $row_number => $row) {
- $row_classes = array();
- if ($default_row_class) {
- $row_classes[] = 'row-' . ($row_number + 1);
- }
- if ($row_class_special) {
- if ($row_number == 0) {
- $row_classes[] = 'row-first';
- }
- if (count($rows) == ($row_number + 1)) {
- $row_classes[] = 'row-last';
- }
- }
- $variables['row_classes'][$row_number] = $row_classes;
- foreach ($rows[$row_number] as $column_number => $item) {
- $column_classes = array();
- if ($default_row_class) {
- $column_classes[] = 'col-'. ($column_number + 1);
- }
- if ($row_class_special) {
- if ($column_number == 0) {
- $column_classes[] = 'col-first';
- }
- elseif (count($rows[$row_number]) == ($column_number + 1)) {
- $column_classes[] = 'col-last';
- }
- }
- if (isset($row_indexes[$row_number][$column_number]) && $column_class = $view->style_plugin->get_row_class($row_indexes[$row_number][$column_number])) {
- $column_classes[] = $column_class;
- }
- $variables['column_classes'][$row_number][$column_number] = $column_classes;
- }
- }
-
- $variables['classes'] = array('views-view-grid', 'cols-' . $columns);
-
-
- if (!empty($handler->options['summary'])) {
- $variables['attributes'] = array('summary' => filter_xss_admin($handler->options['summary']));
- }
-
-
- if (!empty($handler->options['caption'])) {
- $variables['caption'] = filter_xss_admin($handler->options['caption']);
- }
- else {
- $variables['caption'] = '';
- }
- }
-
- $variables['rows'] = $rows;
- }
-
- * Display the simple view of rows one after another
- */
- function template_preprocess_views_view_unformatted(&$variables) {
- $view = $variables['view'];
- $rows = $variables['rows'];
- $style = $view->style_plugin;
- $options = $style->options;
-
- $variables['row_classes'] = array();
- $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;
-
- $count = 0;
- $max = count($rows);
- foreach ($rows as $id => $row) {
- $count++;
- $variables['row_classes'][$id] = array();
- if ($default_row_class) {
- $variables['row_classes'][$id][] = 'views-row';
- $variables['row_classes'][$id][] = 'views-row-' . $count;
- }
- if ($row_class_special) {
- $variables['row_classes'][$id][] = ($count % 2 ? 'odd' : 'even');
- if ($count == 1) {
- $variables['row_classes'][$id][] = 'first';
- }
- if ($count == $max) {
- $variables['row_classes'][$id][] = 'last';
- }
- }
-
- if ($row_class = $view->style_plugin->get_row_class($id)) {
- $variables['row_classes'][$id][] = $row_class;
- }
- }
- }
-
- * Display the view as an HTML list element
- */
- function template_preprocess_views_view_list(&$variables) {
- $handler = $variables['view']->style_plugin;
-
- $classes = explode(' ', $handler->options['class']);
- foreach ($classes as $key => $class) {
- $classes[$key] = backdrop_clean_css_identifier($class, array());
- }
-
- $wrapper_classes = explode(' ', $handler->options['wrapper_class']);
- foreach ($wrapper_classes as $key => $class) {
- $wrapper_classes[$key] = backdrop_clean_css_identifier($class, array());
- }
-
- $variables['class'] = implode(' ', $classes);
- $variables['wrapper_class'] = implode(' ', $wrapper_classes);
- $variables['wrapper_prefix'] = '';
- $variables['wrapper_suffix'] = '';
- $variables['list_type_prefix'] = '<' . $handler->options['type'] . '>';
- $variables['list_type_suffix'] = '</' . $handler->options['type'] . '>';
- if ($variables['wrapper_class']) {
- $variables['wrapper_prefix'] = '<div class="' . $variables['wrapper_class'] . '">';
- $variables['wrapper_suffix'] = '</div>';
- }
-
- if ($variables['class']) {
- $variables['list_type_prefix'] = '<' . $handler->options['type'] . ' class="' . $variables['class'] . '">';
- }
- template_preprocess_views_view_unformatted($variables);
- }
-
- * Preprocess an RSS feed
- */
- function template_preprocess_views_view_rss(&$variables) {
- global $base_url;
- global $language_content;
-
- $view = &$variables['view'];
- $options = &$variables['options'];
- $items = &$variables['rows'];
-
- $style = &$view->style_plugin;
-
-
-
-
- $variables['description'] = check_plain(decode_entities(strip_tags($style->get_description())));
-
- if ($view->display_handler->get_option('sitename_title')) {
- $site_config = config('system.core');
- $title = $site_config->get('site_name');
- if ($slogan = $site_config->getTranslated('site_slogan')) {
- $title .= ' - ' . $slogan;
- }
- }
- else {
- $title = $view->get_title();
- }
- $variables['title'] = check_plain($title);
-
-
-
- $link_display_id = $view->display_handler->get_link_display();
- if ($link_display_id && !empty($view->display[$link_display_id])) {
- $path = $view->display[$link_display_id]->handler->get_path();
- }
-
- if ($path) {
- $path = $view->get_url(NULL, $path);
- $url_options = array('absolute' => TRUE);
- if (!empty($view->exposed_raw_input)) {
- $url_options['query'] = $view->exposed_raw_input;
- }
-
-
- if ($path == config_get('system.core', 'site_frontpage')) {
- $path = '';
- }
-
- $variables['link'] = check_url(url($path, $url_options));
- }
-
- $variables['langcode'] = check_plain($language_content->langcode);
- $variables['namespaces'] = backdrop_attributes($style->namespaces);
- $variables['items'] = $items;
- $variables['channel_elements'] = format_xml_elements($style->channel_elements);
-
-
-
- if (empty($variables['view']->live_preview)) {
- backdrop_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
- }
- }
-
- * Default theme function for all RSS rows.
- */
- function template_preprocess_views_view_row_rss(&$variables) {
- $view = &$variables['view'];
- $options = &$variables['options'];
- $item = &$variables['row'];
-
- $variables['title'] = check_plain($item->title);
- $variables['link'] = check_url($item->link);
- $variables['description'] = check_plain($item->description);
- $variables['item_elements'] = empty($item->elements) ? '' : format_xml_elements($item->elements);
- }
-
- * Default theme function for all filter forms.
- */
- function template_preprocess_views_exposed_form(&$variables) {
- $form = &$variables['form'];
-
-
- $checkboxes = '';
-
- if (!empty($form['q'])) {
- $variables['q'] = backdrop_render($form['q']);
- }
-
- $variables['widgets'] = array();
- foreach ($form['#info'] as $id => $info) {
-
- if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') {
- $checkboxes .= backdrop_render($form[$info['value']]);
- continue;
- }
- $widget = new stdClass;
-
- $widget->label = $widget->operator = $widget->widget = $widget->description = NULL;
-
- $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : '';
-
- if (!empty($info['label'])) {
- $widget->label = check_plain($info['label']);
- }
- if (!empty($info['operator'])) {
- $widget->operator = backdrop_render($form[$info['operator']]);
- }
-
- $widget->widget = backdrop_render($form[$info['value']]);
-
- if (!empty($info['description'])) {
- $widget->description = check_plain($info['description']);
- }
-
- $variables['widgets'][$id] = $widget;
- }
-
-
- if ($checkboxes) {
- $widget = new stdClass;
-
- $widget->label = $widget->operator = $widget->widget = NULL;
- $widget->id = 'checkboxes';
- $widget->widget = $checkboxes;
- $variables['widgets']['checkboxes'] = $widget;
- }
-
- if (isset($form['sort_by'])) {
- $variables['sort_by'] = backdrop_render($form['sort_by']);
- $variables['sort_order'] = backdrop_render($form['sort_order']);
- }
- if (isset($form['items_per_page'])) {
- $variables['items_per_page'] = backdrop_render($form['items_per_page']);
- }
- if (isset($form['offset'])) {
- $variables['offset'] = backdrop_render($form['offset']);
- }
- if (isset($form['reset'])) {
- $variables['reset_button'] = backdrop_render($form['reset']);
- }
-
- $variables['button'] = backdrop_render_children($form);
- }
-
- * Theme function for a View with form elements: replace the placeholders.
- */
- function theme_views_form_views_form($variables) {
- $form = $variables['form'];
-
-
- $search = array();
- $replace = array();
-
-
- foreach ($form['#substitutions']['#value'] as $substitution) {
- $field_name = $substitution['field_name'];
- $row_id = $substitution['row_id'];
-
- $search[] = $substitution['placeholder'];
- $replace[] = isset($form[$field_name][$row_id]) ? backdrop_render($form[$field_name][$row_id]) : '';
- }
-
- $substitutions = module_invoke_all('views_form_substitutions');
- foreach ($substitutions as $placeholder => $substitution) {
- $search[] = $placeholder;
- $replace[] = $substitution;
- }
-
-
- $form['output']['#markup'] = str_replace($search, $replace, $form['output']['#markup']);
-
-
- return backdrop_render_children($form);
- }
-
- function theme_views_mini_pager($variables) {
- global $pager_page_array, $pager_total;
-
- $tags = $variables['tags'];
- $element = $variables['element'];
- $parameters = $variables['parameters'];
-
-
- if (!isset($pager_page_array[$element]) || empty($pager_total)) {
- return '';
- }
-
-
- $pager_current = $pager_page_array[$element] + 1;
-
- $pager_max = $pager_total[$element];
-
-
- if ($pager_total[$element] > 1) {
- $li_previous = theme('pager_previous',
- array(
- 'text' => isset($tags[1]) ? $tags[1] : t('‹‹'),
- 'element' => $element,
- 'interval' => 1,
- 'parameters' => $parameters,
- )
- );
-
- $li_next = theme('pager_next',
- array(
- 'text' => isset($tags[3]) ? $tags[3] : t('››'),
- 'element' => $element,
- 'interval' => 1,
- 'parameters' => $parameters,
- )
- );
-
- if ($li_previous) {
- $items[] = array(
- 'class' => array('pager-previous'),
- 'data' => $li_previous,
- );
- }
- $items[] = array(
- 'class' => array('pager-current'),
- 'data' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)),
- );
-
- if ($li_next) {
- $items[] = array(
- 'class' => array('pager-next'),
- 'data' => $li_next,
- );
- }
-
- return theme('item_list',
- array(
- 'items' => $items,
- 'title' => NULL,
- 'type' => 'ul',
- 'attributes' => array('class' => array('pager')),
- )
- );
- }
- }
-
- * Generic <div> container function.
- */
- function theme_views_container($variables) {
- $element = $variables['element'];
- return '<div' . backdrop_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
- }
-
- * @defgroup views_templates Views template files
- * @{
- * All views templates can be overridden with a variety of names, using
- * the view, the display ID of the view, the display type of the view,
- * or some combination thereof.
- *
- * For each view, there will be a minimum of two templates used. The first
- * is used for all views: views-view.tpl.php.
- *
- * The second template is determined by the style selected for the view. Note
- * that certain aspects of the view can also change which style is used; for
- * example, arguments which provide a summary view might change the style to
- * one of the special summary styles.
- *
- * The default style for all views is views-view-unformatted.tpl.php
- *
- * Many styles will then farm out the actual display of each row to a row
- * style; the default row style is views-view-fields.tpl.php.
- *
- * Here is an example of all the templates that will be tried in the following
- * case:
- *
- * View, named foobar. Style: unformatted. Row style: Fields. Display: Page.
- *
- * - views-view--foobar--page.tpl.php
- * - views-view--page.tpl.php
- * - views-view--foobar.tpl.php
- * - views-view.tpl.php
- *
- * - views-view-unformatted--foobar--page.tpl.php
- * - views-view-unformatted--page.tpl.php
- * - views-view-unformatted--foobar.tpl.php
- * - views-view-unformatted.tpl.php
- *
- * - views-view-fields--foobar--page.tpl.php
- * - views-view-fields--page.tpl.php
- * - views-view-fields--foobar.tpl.php
- * - views-view-fields.tpl.php
- *
- * Important! When adding a new template to your theme, be sure to flush the
- * theme registry cache!
- *
- * @see _views_theme_functions()
- * @}
- */