source: sipes/modules_contrib/views/plugins/views_plugin_style_summary_jump_menu.inc @ 65dadeb

stableversion-3.0
Last change on this file since 65dadeb was 59029b2, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo la version del modulo views

  • Propiedad mode establecida a 100644
File size: 4.2 KB
Línea 
1<?php
2/**
3 * @file
4 * Contains the default summary style plugin, which displays items in an HTML list.
5 */
6
7/**
8 * The default style plugin for summaries.
9 *
10 * @ingroup views_style_plugins
11 */
12class views_plugin_style_summary_jump_menu extends views_plugin_style {
13  function option_definition() {
14    $options = parent::option_definition();
15
16    $options['base_path'] = array('default' => '');
17    $options['count'] = array('default' => TRUE);
18    $options['hide'] = array('default' => FALSE);
19    $options['text'] = array('default' => 'Go', 'translatable' => TRUE);
20    $options['choose'] = array('default' => '- Choose -', 'translatable' => TRUE);
21    $options['default_value'] = array('default' => FALSE);
22
23    return $options;
24  }
25
26  function query() {
27    // Copy the offset option.
28    $pager = array(
29      'type' => 'none',
30      'options' => $this->display->handler->options['pager']['options'],
31    );
32    $this->display->handler->set_option('pager', $pager);
33  }
34
35  function options_form(&$form, &$form_state) {
36    parent::options_form($form, $form_state);
37    $form['base_path'] = array(
38      '#type' => 'textfield',
39      '#title' => t('Base path'),
40      '#default_value' => $this->options['base_path'],
41      '#description' => t('Define the base path for links in this summary
42        view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
43        Do not include beginning and ending forward slash. If this value
44        is empty, views will use the first path found as the base path,
45        in page displays, or / if no path could be found.'),
46    );
47    $form['count'] = array(
48      '#type' => 'checkbox',
49      '#default_value' => !empty($this->options['count']),
50      '#title' => t('Display record count with link'),
51    );
52
53    $form['hide'] = array(
54      '#type' => 'checkbox',
55      '#title' => t('Hide the "Go" button'),
56      '#default_value' => !empty($this->options['hide']),
57      '#description' => t('If hidden, this button will only be hidden for users with javascript and the page will automatically jump when the select is changed.'),
58    );
59
60    $form['text'] = array(
61      '#type' => 'textfield',
62      '#title' => t('Button text'),
63      '#default_value' => $this->options['text'],
64    );
65
66    $form['choose'] = array(
67      '#type' => 'textfield',
68      '#title' => t('Choose text'),
69      '#default_value' => $this->options['choose'],
70      '#description' => t('The text that will appear as the selected option in the jump menu.'),
71    );
72
73    $form['default_value'] = array(
74      '#type' => 'checkbox',
75      '#title' => t('Select the current argument'),
76      '#default_value' => !empty($this->options['default_value']),
77      '#description' => t('If checked, the current argument setting will be displayed as the default option in the jump menu, if applicable.'),
78    );
79  }
80
81  function render() {
82    $argument = $this->view->argument[$this->view->build_info['summary_level']];
83
84    $url_options = array();
85
86    if (!empty($this->view->exposed_raw_input)) {
87      $url_options['query'] = $this->view->exposed_raw_input;
88    }
89
90    $options = array();
91    $default_value = '';
92    foreach ($this->view->result as $id => $row) {
93      $args = $this->view->args;
94      $args[$argument->position] = $argument->summary_argument($row);
95      $base_path = NULL;
96      if (!empty($argument->options['style_options']['base_path'])) {
97        $base_path = $argument->options['style_options']['base_path'];
98      }
99      $path = url($this->view->get_url($args, $base_path), $url_options);
100      $summary_value = strip_tags($argument->summary_name($row));
101      $key = md5($path . $summary_value) . "::" . $path;
102
103      $options[$key] = $summary_value;
104      if (!empty($this->options['count'])) {
105        $options[$key] .= ' (' . intval($row->{$argument->count_alias}) . ')';
106      }
107      if ($this->options['default_value'] && $_GET['q'] == $this->view->get_url($args)) {
108        $default_value = $key;
109      }
110    }
111
112    ctools_include('jump-menu');
113    $settings = array(
114      'hide' => $this->options['hide'],
115      'button' => $this->options['text'],
116      'choose' => $this->options['choose'],
117      'default_value' => $default_value,
118    );
119
120    return drupal_get_form('ctools_jump_menu', $options, $settings);
121  }
122}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.