summaryrefslogtreecommitdiffstats
path: root/theme/theme.inc
blob: e4c9cf947be48e54c0b7c9c270e160a01713a167 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
// $Id$

/**
 * Preprocess the primary theme implementation for a view.
 */
function template_preprocess_views_view(&$vars) {
  $view = $vars['view'];

  $vars['rows']       = $view->style_handler->render($view->result);
  $vars['css_name']   = views_css_safe($view->name);

  if (!$vars['rows']) {
    $vars['empty']    = $view->display_handler->render_empty();
  }
  else {
    $vars['empty']    = '';
  }

  $vars['filters']    = $view->display_handler->render_filters();
  $vars['header']     = $view->display_handler->render_header();
  $vars['footer']     = $view->display_handler->render_footer();
  $vars['more']       = $view->display_handler->render_more_link();
  $vars['feed_icon']  = $view->display_handler->render_feed_icon();

  $vars['pager']      = '';
  if (!empty($view->use_pager)) {
    $vars['pager']    = theme('pager', array(), $view->page_size, $view->page_element);
  }

}

/**
 * Preprocess theme function to print a single record from a row, with fields
 */
function template_preprocess_views_view_row(&$vars) {
  $view = $vars['view'];

  // Loop through the fields for this view.
  foreach ($view->get_fields($view->current_display) as $field) {
    $themes = array(
      'views_view_field__' . $view->name . '__' . $field->handler->field_alias,
      'views_view_field__' . $view->name,
      'views_view_field__' . $field->handler->field_alias,
      'views_view_field',
    );
    // Add the field into a variable named after the field. field_alias will be unique.
    $vars[$field->handler->field_alias] = theme($themes, $view, $field, $vars['row']);
    // Create a second variable so we can easily find what fields we have and what the
    // CSS classes should be.
    $vars['fields'][$field->handler->field_alias] = views_css_safe($field->handler->field_alias);
  }
}

/**
 * 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($view, $field, $row) {
  return $field->handler->render($row);
}

/**
 * Preprocess theme function to print a single record from a row, with fields
 */
function template_preprocess_views_view_row_summary(&$vars) {
  $view     = $vars['view'];
  $row      = $vars['row'];
  $argument = $view->argument[$view->build_info['summary_level']]->handler;

  $vars['link'] = check_plain($row->{$argument->name_alias});
  $vars['url'] = $argument->summary_link($row, $view->get_url());
  $vars['count'] = intval($row->{$argument->count_alias});
}