Projet

Général

Profil

Paste
Télécharger (2,41 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / plugins / views_plugin_style_summary.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_plugin_style_summary.
6
 */
7

    
8
/**
9
 * The default style plugin for summaries.
10
 *
11
 * @ingroup views_style_plugins
12
 */
13
class views_plugin_style_summary extends views_plugin_style {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
19
    $options = parent::option_definition();
20

    
21
    $options['base_path'] = array('default' => '');
22
    $options['count'] = array('default' => TRUE, 'bool' => TRUE);
23
    $options['override'] = array('default' => FALSE, 'bool' => TRUE);
24
    $options['items_per_page'] = array('default' => 25);
25

    
26
    return $options;
27
  }
28

    
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function query() {
33
    if (!empty($this->options['override'])) {
34
      $this->view->set_items_per_page(intval($this->options['items_per_page']));
35
    }
36
  }
37

    
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function options_form(&$form, &$form_state) {
42
    $form['base_path'] = array(
43
      '#type' => 'textfield',
44
      '#title' => t('Base path'),
45
      '#default_value' => $this->options['base_path'],
46
      '#description' => t('Define the base path for links in this summary
47
        view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
48
        Do not include beginning and ending forward slash. If this value
49
        is empty, views will use the first path found as the base path,
50
        in page displays, or / if no path could be found.'),
51
    );
52
    $form['count'] = array(
53
      '#type' => 'checkbox',
54
      '#default_value' => !empty($this->options['count']),
55
      '#title' => t('Display record count with link'),
56
    );
57
    $form['override'] = array(
58
      '#type' => 'checkbox',
59
      '#default_value' => !empty($this->options['override']),
60
      '#title' => t('Override number of items to display'),
61
    );
62

    
63
    $form['items_per_page'] = array(
64
      '#type' => 'textfield',
65
      '#title' => t('Items to display'),
66
      '#default_value' => $this->options['items_per_page'],
67
      '#dependency' => array(
68
        'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1),
69
      ),
70
    );
71
  }
72

    
73
  /**
74
   * {@inheritdoc}
75
   */
76
  public function render() {
77
    $rows = array();
78
    foreach ($this->view->result as $row) {
79
      // @todo Include separator as an option.
80
      $rows[] = $row;
81
    }
82

    
83
    return theme($this->theme_functions(), array(
84
      'view' => $this->view,
85
      'options' => $this->options,
86
      'rows' => $rows,
87
    ));
88
  }
89

    
90
}