diff --git a/README.txt b/README.txt index 1d6daea..a99c44a 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,4 @@ +$Id: README.txt,v 1.1 2010/03/05 09:33:06 freakalis Exp $ -- SUMMARY -- diff --git a/viewselect.inc b/viewselect.inc index 9c45278..1384789 100755 --- a/viewselect.inc +++ b/viewselect.inc @@ -1,10 +1,14 @@ NULL, 'aslist' => NULL, 'optrand' => 0, + 'html_display' => NULL, 'other_option' => NULL, 'other_text' => t('Other...'), 'description' => '', @@ -109,7 +114,14 @@ function _webform_edit_viewselect($component) { '#title' => t('Listbox'), '#return_value' => 'Y', '#default_value' => $component['extra']['aslist'], - '#description' => t('Check this option if you want the select component to be of listbox type instead of radiobuttons or checkboxes.'), + '#description' => t('Check this option if you want the select component to be of listbox type instead of radio buttons or checkboxes.'), + ); + $form['extra']['html_display'] = array( + '#type' => 'checkbox', + '#title' => t('Render view output'), + '#return_value' => 'Y', + '#default_value' => $component['extra']['html_display'], + '#description' => t('Check this option if you want the full view rendered as configured in Views UI.'), ); return $form; @@ -175,7 +187,7 @@ function _webform_render_viewselect($component, $value = NULL, $filter = TRUE) { $default_value = $filter ? _webform_filter_values($component['value'], NULL, NULL, NULL, FALSE) : $component['value']; $args = $component['extra']['advanced']['advanced_view_args']; - $options = _webform_viewselect_options($component['extra']['advanced']['advanced_view'],$args); + $options = _webform_viewselect_options($component['extra']['advanced']['advanced_view'], $args, $component['extra']['html_display']); if ($component['extra']['aslist'] === 'Y' && $component['extra']['multiple'] !== 'Y' && !($component['mandatory'] && !empty($component['value']))) { $options = array('' => t('select...')) + $options; @@ -286,7 +298,7 @@ function _webform_display_viewselect($component, $value, $format = 'html') { * Convert FAPI 0/1 values into something saveable. */ function _webform_submit_viewselect($component, $value) { - $options = _webform_viewselect_options($component['extra']['advanced']['advanced_view'],$component['extra']['advanced']['advanced_view_arguments']); + $options = _webform_viewselect_options($component['extra']['advanced']['advanced_view'], $component['extra']['advanced']['advanced_view_arguments']); if (is_array($value)) { foreach ($value as $key => $option_value) { @@ -299,7 +311,7 @@ function _webform_submit_viewselect($component, $value) { else { //$value[$key] = $options[$key]; $node = node_load($option_value); - if($node) { + if ($node) { $value[$key] = $node->title; } } @@ -310,15 +322,15 @@ function _webform_submit_viewselect($component, $value) { } } - // Always save at least something, even if it's an empty single value. if (empty($value)) { $value[0] = ''; } - } else { + } + else { // Single value $node = node_load($value); - if($node) { + if ($node) { $value = $node->title; } } @@ -489,7 +501,7 @@ function _webform_analysis_viewselect($component, $sids = array(), $single = FAL $show_other_results = $single; $sid_placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sid_filter = count($sids) ? " AND sid IN (".implode(",", $sid_placeholders).")" : ""; + $sid_filter = count($sids) ? " AND sid IN (" . implode(",", $sid_placeholders) . ")" : ""; $not = $show_other_results ? 'NOT ' : ''; $placeholders = count($options) ? array_fill(0, count($options), "'%s'") : array(); @@ -629,17 +641,24 @@ function _webform_csv_data_viewselect($component, $export_options, $value) { * @param $filter * Optional. Whether or not to filter returned values. */ -function _webform_viewselect_options($view,$args = '') { +function _webform_viewselect_options($view, $args = '', $html_display = '') { $options = array(); // Prepare field array - Reusing CCK nodreference function _nodereference_potential_references() $field['advanced_view'] = $view; $field['advanced_view_args'] = $args; + // Field name used for cid in _nodereference_potential_references + $field['field_name'] = md5($view . $args); $data = _nodereference_potential_references($field); - foreach($data as $index => $row) { - $options[$index] = check_plain($row['title']); + foreach ($data as $index => $row) { + if ($html_display === 'Y') { + $options[$index] = $row['rendered']; + } + else { + $options[$index] = check_plain($row['title']); + } } return $options; diff --git a/webform_viewreference.info b/webform_viewreference.info old mode 100755 new mode 100644 index 2e9431f..0dfb793 --- a/webform_viewreference.info +++ b/webform_viewreference.info @@ -1,6 +1,14 @@ +; $Id: webform_viewreference.info,v 1.1 2010/03/05 09:33:06 freakalis Exp $ name = Webform View Reference Component description = A Webform component that lets you use node View as a datasource. core = 6.x package = Webform dependencies[] = webform dependencies[] = views + +; Information added by drupal.org packaging script on 2010-03-19 +version = "6.x-1.0-beta2" +core = "6.x" +project = "webform_viewreference" +datestamp = "1269012014" + diff --git a/webform_viewreference.module b/webform_viewreference.module index 202f661..9ba3029 100755 --- a/webform_viewreference.module +++ b/webform_viewreference.module @@ -1,4 +1,5 @@