Go to the documentation of this file.00001 <?php
00012 class views_plugin_style_summary_jump_menu extends views_plugin_style {
00013 function option_definition() {
00014 $options = parent::option_definition();
00015
00016 $options['base_path'] = array('default' => '');
00017 $options['count'] = array('default' => TRUE);
00018 $options['hide'] = array('default' => FALSE);
00019 $options['text'] = array('default' => 'Go', 'translatable' => TRUE);
00020 $options['choose'] = array('default' => '- Choose -', 'translatable' => TRUE);
00021 $options['default_value'] = array('default' => FALSE);
00022
00023 return $options;
00024 }
00025
00026 function query() {
00027
00028 $pager = array(
00029 'type' => 'none',
00030 'options' => $this->display->handler->options['pager']['options'],
00031 );
00032 $this->display->handler->set_option('pager', $pager);
00033 }
00034
00035 function options_form(&$form, &$form_state) {
00036 $form['base_path'] = array(
00037 '#type' => 'textfield',
00038 '#title' => t('Base path'),
00039 '#default_value' => $this->options['base_path'],
00040 '#description' => t('Define the base path for links in this summary
00041 view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
00042 Do not include beginning and ending forward slash. If this value
00043 is empty, views will use the first path found as the base path,
00044 in page displays, or / if no path could be found.'),
00045 );
00046 $form['count'] = array(
00047 '#type' => 'checkbox',
00048 '#default_value' => !empty($this->options['count']),
00049 '#title' => t('Display record count with link'),
00050 );
00051
00052 $form['hide'] = array(
00053 '#type' => 'checkbox',
00054 '#title' => t('Hide the "Go" button'),
00055 '#default_value' => !empty($this->options['hide']),
00056 '#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.'),
00057 );
00058
00059 $form['text'] = array(
00060 '#type' => 'textfield',
00061 '#title' => t('Button text'),
00062 '#default_value' => $this->options['text'],
00063 );
00064
00065 $form['choose'] = array(
00066 '#type' => 'textfield',
00067 '#title' => t('Choose text'),
00068 '#default_value' => $this->options['choose'],
00069 '#description' => t('The text that will appear as the selected option in the jump menu.'),
00070 );
00071
00072 $form['default_value'] = array(
00073 '#type' => 'checkbox',
00074 '#title' => t('Select the current contextual filter value'),
00075 '#default_value' => !empty($this->options['default_value']),
00076 '#description' => t('If checked, the current contextual filter value will be displayed as the default option in the jump menu, if applicable.'),
00077 );
00078 }
00079
00080 function render() {
00081 $argument = $this->view->argument[$this->view->build_info['summary_level']];
00082
00083 $url_options = array();
00084
00085 if (!empty($this->view->exposed_raw_input)) {
00086 $url_options['query'] = $this->view->exposed_raw_input;
00087 }
00088
00089 $options = array();
00090 $default_value = '';
00091 $row_args = array();
00092 foreach ($this->view->result as $id => $row) {
00093 $row_args[$id] = $argument->summary_argument($row);
00094 }
00095 $argument->process_summary_arguments($row_args);
00096
00097 foreach ($this->view->result as $id => $row) {
00098 $args = $this->view->args;
00099 $args[$argument->position] = $row_args[$id];
00100 $base_path = NULL;
00101 if (!empty($argument->options['summary_options']['base_path'])) {
00102 $base_path = $argument->options['summary_options']['base_path'];
00103 }
00104 $path = url($this->view->get_url($args, $base_path), $url_options);
00105 $summary_value = strip_tags($argument->summary_name($row));
00106 $key = md5($path . $summary_value) . "::" . $path;
00107
00108 $options[$key] = $summary_value;
00109 if (!empty($this->options['count'])) {
00110 $options[$key] .= ' (' . intval($row->{$argument->count_alias}) . ')';
00111 }
00112 if ($this->options['default_value'] && $_GET['q'] == $this->view->get_url($args)) {
00113 $default_value = $key;
00114 }
00115 }
00116
00117 ctools_include('jump-menu');
00118 $settings = array(
00119 'hide' => $this->options['hide'],
00120 'button' => $this->options['text'],
00121 'choose' => $this->options['choose'],
00122 'default_value' => $default_value,
00123 );
00124
00125 $form = drupal_get_form('ctools_jump_menu', $options, $settings);
00126 return drupal_render($form);
00127 }
00128 }