diff --git a/modules/openlayers_views/views/openlayers_views.views.inc b/modules/openlayers_views/views/openlayers_views.views.inc index 4ebbec8..c888100 100644 --- a/modules/openlayers_views/views/openlayers_views.views.inc +++ b/modules/openlayers_views/views/openlayers_views.views.inc @@ -49,12 +49,25 @@ function openlayers_views_views_plugins() { 'theme path' => drupal_get_path('module', 'openlayers_views') .'/views', 'path' => drupal_get_path('module', 'openlayers_views') .'/views', 'uses fields' => TRUE, - 'uses row plugin' => FALSE, + 'uses row plugin' => TRUE, 'uses options' => TRUE, 'uses grouping' => TRUE, 'type' => 'openlayers', 'even empty' => TRUE, ), ), + 'row' => array( + 'fields_openlayers' => array( + 'title' => t('Fields Openlayers'), + 'help' => t('Displays the fields with an optional template.'), + 'handler' => 'views_plugin_row_openlayers', + 'path' => drupal_get_path('module', 'openlayers_views') .'/views', + 'theme' => 'views_view_fields', + 'uses fields' => TRUE, + 'uses options' => TRUE, + 'type' => 'openlayers', + 'help topic' => 'style-row-openlayers', + ), + ), ); } diff --git a/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc b/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc index 4c57070..a49d461 100644 --- a/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc +++ b/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc @@ -41,7 +41,7 @@ class openlayers_views_plugin_display_openlayers extends views_plugin_display { // Overrides for standard stuff: $options['style_plugin']['default'] = 'openlayers_data'; - $options['row_plugin']['default'] = ''; + $options['row_plugin']['default'] = 'fields_openlayers'; $options['defaults']['default']['row_plugin'] = FALSE; $options['defaults']['default']['row_options'] = FALSE; return $options; diff --git a/modules/openlayers_views/views/openlayers_views_style_data.inc b/modules/openlayers_views/views/openlayers_views_style_data.inc index 8ba00a9..2ed7ee9 100644 --- a/modules/openlayers_views/views/openlayers_views_style_data.inc +++ b/modules/openlayers_views/views/openlayers_views_style_data.inc @@ -166,7 +166,7 @@ class openlayers_views_style_data extends views_plugin_style { '#title' => t('Description Field'), '#description' => t('Choose the field which will appear as a description on tooltips.'), '#required' => FALSE, - '#options' => array_merge(array('' => ''), $fields), + '#options' => array_merge(array('' => '', '#all_fields' => t('Display all fields')), $fields), '#default_value' => $this->options['data_source']['description_field'], ); $form['data_source']['keep_orig_desc_field'] = array( @@ -298,8 +298,14 @@ class openlayers_views_style_data extends views_plugin_style { $description_field = (!empty($data_source['description_field'])) ? $fields[$data_source['description_field']]['field_alias'] : NULL; // Create output + if ($data_source['description_field'] == '#all_fields') { $descriptions[] = theme('openlayers_views_group_display_item', + $rendered_record[$name_field], $this->row_plugin->render($record)); + } + else { + $descriptions[] = theme('openlayers_views_group_display_item', $rendered_record[$name_field], $rendered_record[$description_field]); + } } $grouped_description = theme('item_list', $descriptions); @@ -327,6 +333,7 @@ class openlayers_views_style_data extends views_plugin_style { // Separate mapping for non-grouped views. else { + $this->view->row_index = 0; $excluded_fields = array(); $records = array_shift($records); @@ -405,9 +412,14 @@ class openlayers_views_style_data extends views_plugin_style { } if (is_array($data_source) && $data_source['description_field']) { $description_field = $fields[$data_source['description_field']]['field_alias']; - $feature['attributes']['description'] = $rendered_record[$description_field]; + if ($data_source['description_field'] == '#all_fields') { + $feature['attributes']['description'] = $this->row_plugin->render($record); + } + else { + $feature['attributes']['description'] = $rendered_record[$description_field]; + } $excluded_fields[] = $description_field; - if (!empty($data_source['keep_orig_desc_field'])) { + if ($data_source['description_field'] != '#all_fields' && !empty($data_source['keep_orig_desc_field'])) { $feature['attributes'][$data_source['description_field']] = $record->$description_field; } } @@ -432,7 +444,9 @@ class openlayers_views_style_data extends views_plugin_style { if (!empty($feature['wkt'])) { $features[] = theme('openlayers_views_render_feature', $feature, $record); } + $this->view->row_index++; } + unset($this->view->row_index); return $features; } } diff --git a/modules/openlayers_views/views/views_plugin_row_openlayers.inc b/modules/openlayers_views/views/views_plugin_row_openlayers.inc new file mode 100644 index 0000000..c942dc2 --- /dev/null +++ b/modules/openlayers_views/views/views_plugin_row_openlayers.inc @@ -0,0 +1,68 @@ + array()); + $options['separator'] = array('default' => ''); + $options['hide_empty'] = array('default' => FALSE); + return $options; + } + + /** + * Provide a form for setting options. + */ + function options_form(&$form, &$form_state) { + $options = $this->display->handler->get_field_labels(); + + if (empty($this->options['inline'])) { + $this->options['inline'] = array(); + } + + $form['inline'] = array( + '#type' => 'checkboxes', + '#title' => t('Inline fields'), + '#options' => $options, + '#default_value' => $this->options['inline'], + '#description' => t('Inline fields will be displayed next to each other rather than one after another.'), + ); + + $form['separator'] = array( + '#title' => t('Separator'), + '#type' => 'textfield', + '#size' => 10, + '#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '', + '#description' => t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'), + ); + + $form['hide_empty'] = array( + '#type' => 'checkbox', + '#title' => t('Hide empty fields'), + '#default_value' => $this->options['hide_empty'], + '#description' => t('Do not display fields, labels or markup for fields that are empty.'), + ); + } + + /** + * Perform any necessary changes to the form values prior to storage. + * There is no need for this function to actually store the data. + */ + function options_submit($form, &$form_state) { + $form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']); + } +} +