public function views_plugin_style_jump_menu::render in Views (for Drupal 7) 7.3
Same name and namespace in other branches
- 6.3 plugins/views_plugin_style_jump_menu.inc \views_plugin_style_jump_menu::render()
- 6.2 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 110 - Definition of views_plugin_style_jump_menu.
Class
- views_plugin_style_jump_menu
- Style plugin to render each item as a row in a table.
Code
public 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 = strip_tags(decode_entities($this
->get_field($this->view->row_index, $this->options['path'])));
// Putting a '/' in front messes up url() so let's take that out
// so users don't shoot themselves in the foot.
$base_path = base_path();
if (strpos($path, $base_path) === 0) {
$path = drupal_substr($path, drupal_strlen($base_path));
}
// Use drupal_parse_url() to preserve query and fragment in case the
// user wants to do fun tricks.
$url_options = drupal_parse_url($path);
$path = url($url_options['path'], $url_options);
$field = strip_tags(decode_entities($this->row_plugin
->render($row)));
$key = md5($path . $field) . "::" . $path;
if ($title) {
$options[$title][$key] = $field;
}
else {
$options[$key] = $field;
}
$paths[$path] = $key;
$this->view->row_index++;
}
}
unset($this->view->row_index);
$default_value = '';
if ($this->options['default_value']) {
$lookup_options = array();
// We need to check if the path is absolute or else language is not taken
// in account.
if (!empty($this->view->display[$this->view->current_display]->display_options['fields'][$this->options['path']]['absolute'])) {
$lookup_options['absolute'] = TRUE;
}
$lookup_url = url($_GET['q'], $lookup_options);
if (!empty($paths[$lookup_url])) {
$default_value = $paths[$lookup_url];
}
}
ctools_include('jump-menu');
$settings = array(
'hide' => $this->options['hide'],
'button' => $this->options['text'],
'title' => $this->options['label'],
'choose' => $this->options['choose'],
'inline' => $this->options['inline'],
'default_value' => $default_value,
);
$form = drupal_get_form('ctools_jump_menu', $options, $settings);
return $form;
}