function views_plugin_style_jump_menu::render in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 6.3 plugins/views_plugin_style_jump_menu.inc \views_plugin_style_jump_menu::render()
- 7.3 plugins/views_plugin_style_jump_menu.inc \views_plugin_style_jump_menu::render()
Render the display in this style.
This is overridden so that we can render our grouping specially.
Overrides views_plugin_style::render
File
- plugins/
views_plugin_style_jump_menu.inc, line 90 - Contains the table style plugin.
Class
- views_plugin_style_jump_menu
- Style plugin to render each item as a row in a table.
Code
function render() {
$sets = $this
->render_grouping($this->view->result, $this->options['grouping']);
// Turn this all into an $options array for the jump menu.
$this->view->row_index = 0;
$options = array();
$paths = array();
foreach ($sets as $title => $records) {
foreach ($records as $row_index => $row) {
$this->view->row_index = $row_index;
$path = html_entity_decode(strip_tags($this
->get_field($this->view->row_index, $this->options['path'])), ENT_QUOTES);
// Putting a '/' in front messes up url() so let's take that out
// so users don't shoot themselves in the foot.
if (strpos($path, '/') === 0) {
$path = substr($path, 1);
}
// use parse_url() to preserve query and fragment in case the user
// wants to do fun tricks.
$url = parse_url($path);
$url_options = array();
if (isset($url['query'])) {
$path = strtr($path, array(
'?' . $url['query'] => '',
));
$url_options['query'] = $url['query'];
}
if (isset($url['fragment'])) {
$path = strtr($path, array(
'#' . $url['fragment'] => '',
));
$url_options['fragment'] = $url['fragment'];
}
$path = url($path, $url_options);
$field = html_entity_decode(strip_tags($this->row_plugin
->render($row)), ENT_QUOTES);
if ($title) {
$options[$title][$path] = $field;
}
else {
$options[$path] = $field;
}
$paths[$path] = $path;
$this->view->row_index++;
}
}
unset($this->view->row_index);
$default_value = '';
if ($this->options['default_value'] && !empty($paths[url($_GET['q'])])) {
$default_value = url($_GET['q']);
}
ctools_include('jump-menu');
$settings = array(
'hide' => $this->options['hide'],
'button' => $this->options['text'],
'choose' => $this->options['choose'],
'default_value' => $default_value,
);
return drupal_get_form('ctools_jump_menu', $options, $settings);
}