Révision a45e4bc1
Ajouté par Assos Assos il y a environ 9 ans
drupal7/sites/all/modules/webform/webform.api.php | ||
---|---|---|
71 | 71 |
* of key => value pairs. Select components support up to one level of |
72 | 72 |
* nesting, but when results are displayed, the list needs to be returned |
73 | 73 |
* without the nesting. |
74 |
* @param $filter |
|
75 |
* Boolean value indicating whether the included options should be passed |
|
76 |
* through the _webform_filter_values() function for token replacement (only) |
|
77 |
* needed if your list contains tokens). |
|
78 | 74 |
* @param $arguments |
79 | 75 |
* The "options arguments" specified in hook_webform_select_options_info(). |
80 | 76 |
* @return |
81 | 77 |
* An array of key => value pairs suitable for a select list's #options |
82 | 78 |
* FormAPI property. |
83 | 79 |
*/ |
84 |
function webform_options_example($component, $flat, $filter, $arguments) {
|
|
80 |
function webform_options_example($component, $flat, $arguments) { |
|
85 | 81 |
$options = array( |
86 | 82 |
'one' => t('Pre-built option one'), |
87 | 83 |
'two' => t('Pre-built option two'), |
... | ... | |
104 | 100 |
} |
105 | 101 |
} |
106 | 102 |
|
103 |
/** |
|
104 |
* Respond to the creation of a new submission from form values. |
|
105 |
* |
|
106 |
* This hook is called when a user has completed a submission to initialize the |
|
107 |
* submission object. After this object has its values populated, it will be |
|
108 |
* saved by webform_submission_insert(). Note that this hook is only called for |
|
109 |
* new submissions, not for submissions being edited. If responding to the |
|
110 |
* saving of all submissions, it's recommended to use |
|
111 |
* hook_webform_submission_presave(). |
|
112 |
* |
|
113 |
* @param $submission |
|
114 |
* The submission object that has been created. |
|
115 |
* @param $node |
|
116 |
* The Webform node for which this submission is being saved. |
|
117 |
* @param $account |
|
118 |
* The user account that is creating the submission. |
|
119 |
* @param $form_state |
|
120 |
* The contents of form state that is the basis for this submission. |
|
121 |
* |
|
122 |
* @see webform_submission_create() |
|
123 |
*/ |
|
124 |
function hook_webform_submission_create_alter(&$submission, &$node, &$account, &$form_state) { |
|
125 |
$submission->new_property = TRUE; |
|
126 |
} |
|
127 |
|
|
107 | 128 |
/** |
108 | 129 |
* Modify a Webform submission, prior to saving it in the database. |
109 | 130 |
* |
... | ... | |
115 | 136 |
function hook_webform_submission_presave($node, &$submission) { |
116 | 137 |
// Update some component's value before it is saved. |
117 | 138 |
$component_id = 4; |
118 |
$submission->data[$component_id]['value'][0] = 'foo';
|
|
139 |
$submission->data[$component_id][0] = 'foo'; |
|
119 | 140 |
} |
120 | 141 |
|
121 | 142 |
/** |
... | ... | |
195 | 216 |
* The Webform submission on which the actions may be performed. |
196 | 217 |
*/ |
197 | 218 |
function hook_webform_submission_actions($node, $submission) { |
219 |
$actions= array(); |
|
220 |
|
|
198 | 221 |
if (webform_results_access($node)) { |
199 | 222 |
$actions['myaction'] = array( |
200 | 223 |
'title' => t('Do my action'), |
... | ... | |
206 | 229 |
return $actions; |
207 | 230 |
} |
208 | 231 |
|
232 |
/** |
|
233 |
* Modify the draft to be presented for editing. |
|
234 |
* |
|
235 |
* When drafts are enabled for the webform, by default, a pre-existig draft is |
|
236 |
* presented when the webform is displayed to that user. To allow multiple |
|
237 |
* drafts, implement this alter function to set the $sid to NULL, or use your |
|
238 |
* application's business logic to determine whether a new draft or which of |
|
239 |
* he pre-existing drafts should be presented. |
|
240 |
* |
|
241 |
* @param integer $sid |
|
242 |
* The id of the most recent submission to be presented for editing. Change |
|
243 |
* to a different draft's sid or set to NULL for a new draft. |
|
244 |
* @param array $context |
|
245 |
* Array of context with indices 'nid' and 'uid'. |
|
246 |
*/ |
|
247 |
function hook_webform_draft_alter(&$sid, $context) { |
|
248 |
if ($_GET['newdraft']) { |
|
249 |
$sid = NULL; |
|
250 |
} |
|
251 |
} |
|
252 |
|
|
209 | 253 |
/** |
210 | 254 |
* Alter the display of a Webform submission. |
211 | 255 |
* |
... | ... | |
301 | 345 |
->execute(); |
302 | 346 |
} |
303 | 347 |
|
348 |
/** |
|
349 |
* Alter the entire analysis before rendering to the page on the Analysis tab. |
|
350 |
* |
|
351 |
* This alter hook allows modification of the entire analysis of a node's |
|
352 |
* Webform results. The resulting analysis is displayed on the Results -> |
|
353 |
* Analysis tab on the Webform. |
|
354 |
* |
|
355 |
* @param array $analysis |
|
356 |
* A Drupal renderable array, passed by reference, containing the entire |
|
357 |
* contents of the analysis page. This typically will contain the following |
|
358 |
* two major keys: |
|
359 |
* - form: The form for configuring the shown analysis. |
|
360 |
* - components: The list of analyses for each analysis-enabled component |
|
361 |
* for the node. Each keyed by its component ID. |
|
362 |
*/ |
|
363 |
function hook_webform_analysis_alter(&$analysis) { |
|
364 |
$node = $analysis['#node']; |
|
365 |
|
|
366 |
// Add an additional piece of information to every component's analysis: |
|
367 |
foreach (element_children($analysis['components']) as $cid) { |
|
368 |
$component = $node->components[$cid]; |
|
369 |
$analysis['components'][$cid]['chart'] = array( |
|
370 |
'#markup' => t('Chart for the @name component', array('@name' => $component['name'])), |
|
371 |
); |
|
372 |
} |
|
373 |
} |
|
374 |
/** |
|
375 |
* Alter data when displaying an analysis on that component. |
|
376 |
* |
|
377 |
* This hook modifies the data from an individual component's analysis results. |
|
378 |
* It can be used to add additional analysis, or to modify the existing results. |
|
379 |
* If needing to alter the entire set of analyses rather than an individual |
|
380 |
* component, hook_webform_analysis_alter() may be used instead. |
|
381 |
* |
|
382 |
* @param array $data |
|
383 |
* An array containing the result of a components analysis hook, passed by |
|
384 |
* reference. This is passed directly from a component's |
|
385 |
* _webform_analysis_component() function. See that hook for more information |
|
386 |
* on this value. |
|
387 |
* @param object $node |
|
388 |
* The node object that contains the component being analyzed. |
|
389 |
* @param array $component |
|
390 |
* The Webform component array whose analysis results are being displayed. |
|
391 |
* |
|
392 |
* @see _webform_analysis_component() |
|
393 |
* @see hook_webform_analysis_alter() |
|
394 |
*/ |
|
395 |
function hook_webform_analysis_component_data_alter(&$data, $node, $component) { |
|
396 |
if ($component['type'] === 'textfield') { |
|
397 |
// Do not display rows that contain a zero value. |
|
398 |
foreach ($data as $row_number => $row_data) { |
|
399 |
if ($row_data[1] === 0) { |
|
400 |
unset($data[$row_number]); |
|
401 |
} |
|
402 |
} |
|
403 |
} |
|
404 |
} |
|
405 |
|
|
304 | 406 |
/** |
305 | 407 |
* Alter a Webform submission's header when exported. |
306 | 408 |
*/ |
307 | 409 |
function hook_webform_csv_header_alter(&$header, $component) { |
308 |
// Use the machine name for component headers, but only for the webform
|
|
410 |
// Use the machine name for component headers, but only for the webform |
|
309 | 411 |
// with node 5 and components that are text fields. |
310 | 412 |
if ($component['nid'] == 5 && $component['type'] == 'textfield') { |
311 | 413 |
$header[2] = $component['form_key']; |
... | ... | |
383 | 485 |
'label' => t('Textfield'), |
384 | 486 |
'description' => t('Basic textfield type.'), |
385 | 487 |
'features' => array( |
488 |
// This component includes an analysis callback. Defaults to TRUE. |
|
489 |
'analysis' => TRUE, |
|
490 |
|
|
386 | 491 |
// Add content to CSV downloads. Defaults to TRUE. |
387 | 492 |
'csv' => TRUE, |
388 | 493 |
|
... | ... | |
430 | 535 |
// If this component saves a file that can be used as an e-mail |
431 | 536 |
// attachment. Defaults to FALSE. |
432 | 537 |
'attachment' => FALSE, |
538 |
|
|
539 |
// If this component reflects a time range and should use labels such as |
|
540 |
// "Before" and "After" when exposed as filters in Views module. |
|
541 |
'views_range' => FALSE, |
|
433 | 542 |
), |
543 |
|
|
544 |
// Specify the conditional behaviour of this component. |
|
545 |
// Examples are 'string', 'date', 'time', 'numeric', 'select'. |
|
546 |
// Defaults to 'string'. |
|
547 |
'conditional_type' => 'string', |
|
548 |
|
|
434 | 549 |
'file' => 'components/textfield.inc', |
435 | 550 |
); |
436 | 551 |
|
... | ... | |
524 | 639 |
* |
525 | 640 |
* Note in addition to the view access to the results granted here, the $account |
526 | 641 |
* must also have view access to the Webform node in order to see results. |
642 |
* Access via this hook is in addition (adds permission) to the standard |
|
643 |
* webform access. |
|
527 | 644 |
* |
528 | 645 |
* @see webform_results_access(). |
529 | 646 |
* |
... | ... | |
552 | 669 |
* |
553 | 670 |
* @see webform_results_clear_access(). |
554 | 671 |
* |
555 |
* @param $node object
|
|
672 |
* @param object $node
|
|
556 | 673 |
* The Webform node to check access on. |
557 |
* @param $account object
|
|
674 |
* @param object $account
|
|
558 | 675 |
* The user account to check access on. |
559 | 676 |
* @return boolean |
560 | 677 |
* TRUE or FALSE if the user can access the webform results. |
... | ... | |
563 | 680 |
return user_access('my additional access', $account); |
564 | 681 |
} |
565 | 682 |
|
683 |
/** |
|
684 |
* Overrides the node_access and user_access permission to access and edit |
|
685 |
* webform components, e-mails, conditions, and form settings. |
|
686 |
* |
|
687 |
* Return NULL to defer to other modules. If all implementations defer, then |
|
688 |
* access to the node's EDIT tab plus 'edit webform components' permission |
|
689 |
* determines access. To grant access, return TRUE; to deny access, return |
|
690 |
* FALSE. If more than one implementation return TRUE/FALSE, all must be TRUE |
|
691 |
* to grant access. |
|
692 |
* |
|
693 |
* In this way, access to the EDIT tab of the node may be decoupled from |
|
694 |
* access to the WEBFORM tab. When returning TRUE, consider all aspects of |
|
695 |
* access as this will be the only test. For example, 'return TRUE;' would grant |
|
696 |
* annonymous access to creating webform components, which seldom be desired. |
|
697 |
* |
|
698 |
* @see webform_node_update_access(). |
|
699 |
* |
|
700 |
* @param object $node |
|
701 |
* The Webform node to check access on. |
|
702 |
* @param object $account |
|
703 |
* The user account to check access on. |
|
704 |
* @return boolean|NULL |
|
705 |
* TRUE or FALSE if the user can access the webform results, or NULL if |
|
706 |
* access should be deferred to other implementations of this hook or |
|
707 |
* node_access('update') plus user_access('edit webform components'). |
|
708 |
*/ |
|
709 |
function hook_webform_update_access($node, $account) { |
|
710 |
// Allow anyone who can see webform_editable_by_user nodes and who has |
|
711 |
// 'my webform component edit access' permission to see, edit, and delete the |
|
712 |
// webform components, e-mails, conditionals, and form settings. |
|
713 |
if ($node->type == 'webform_editable_by_user') { |
|
714 |
return node_access('view', $node, $account) && user_access('my webform component edit access', $account); |
|
715 |
} |
|
716 |
} |
|
717 |
|
|
566 | 718 |
|
567 | 719 |
/** |
568 | 720 |
* Return an array of files associated with the component. |
... | ... | |
594 | 746 |
return $files; |
595 | 747 |
} |
596 | 748 |
|
749 |
|
|
750 |
/** |
|
751 |
* Alter default settings for a newly created webform node. |
|
752 |
* |
|
753 |
* @param array $defaults |
|
754 |
* Default settings for a newly created webform node as defined by webform_node_defaults(). |
|
755 |
* |
|
756 |
* @see webform_node_defaults() |
|
757 |
*/ |
|
758 |
function hook_webform_node_defaults_alter(&$defaults) { |
|
759 |
$defaults['allow_draft'] = '1'; |
|
760 |
} |
|
761 |
|
|
762 |
/** |
|
763 |
* Add additional fields to submission data downloads. |
|
764 |
* |
|
765 |
* @return |
|
766 |
* Keys and titles for default submission information. |
|
767 |
* |
|
768 |
* @see hook_webform_results_download_submission_information_data() |
|
769 |
*/ |
|
770 |
function hook_webform_results_download_submission_information_info() { |
|
771 |
return array( |
|
772 |
'field_key_1' => t('Field Title 1'), |
|
773 |
'field_key_2' => t('Field Title 2'), |
|
774 |
); |
|
775 |
} |
|
776 |
|
|
777 |
/** |
|
778 |
* Return values for submission data download fields. |
|
779 |
* |
|
780 |
* @param $token |
|
781 |
* The name of the token being replaced. |
|
782 |
* @param $submission |
|
783 |
* The data for an individual submission from webform_get_submissions(). |
|
784 |
* @param $options |
|
785 |
* A list of options that define the output format. These are generally passed |
|
786 |
* through from the GUI interface. |
|
787 |
* @param $serial_start |
|
788 |
* The starting position for the Serial column in the output. |
|
789 |
* @param $row_count |
|
790 |
* The number of the row being generated. |
|
791 |
* |
|
792 |
* @return |
|
793 |
* Value for requested submission information field. |
|
794 |
* |
|
795 |
* @see hook_webform_results_download_submission_information_info() |
|
796 |
*/ |
|
797 |
function hook_webform_results_download_submission_information_data($token, $submission, array $options, $serial_start, $row_count) { |
|
798 |
switch ($token) { |
|
799 |
case 'field_key_1': |
|
800 |
return 'Field Value 1'; |
|
801 |
case 'field_key_2': |
|
802 |
return 'Field Value 2'; |
|
803 |
} |
|
804 |
} |
|
805 |
|
|
597 | 806 |
/** |
598 | 807 |
* @} |
599 | 808 |
*/ |
... | ... | |
617 | 826 |
return array( |
618 | 827 |
'name' => '', |
619 | 828 |
'form_key' => NULL, |
620 |
'mandatory' => 0,
|
|
829 |
'required' => 0,
|
|
621 | 830 |
'pid' => 0, |
622 | 831 |
'weight' => 0, |
623 | 832 |
'extra' => array( |
... | ... | |
626 | 835 |
'optrand' => 0, |
627 | 836 |
'qrand' => 0, |
628 | 837 |
'description' => '', |
838 |
'private' => FALSE, |
|
839 |
'analysis' => TRUE, |
|
629 | 840 |
), |
630 | 841 |
); |
631 | 842 |
} |
... | ... | |
656 | 867 |
'#type' => 'textarea', |
657 | 868 |
'#title' => t('Options'), |
658 | 869 |
'#default_value' => $component['extra']['options'], |
659 |
'#description' => t('Key-value pairs may be entered separated by pipes. i.e. safe_key|Some readable option') . theme('webform_token_help'), |
|
870 |
'#description' => t('Key-value pairs may be entered separated by pipes. i.e. safe_key|Some readable option') . ' ' . theme('webform_token_help'),
|
|
660 | 871 |
'#cols' => 60, |
661 | 872 |
'#rows' => 5, |
662 | 873 |
'#weight' => -3, |
... | ... | |
679 | 890 |
* Whether or not to filter the contents of descriptions and values when |
680 | 891 |
* rendering the component. Values need to be unfiltered to be editable by |
681 | 892 |
* Form Builder. |
893 |
* @param $submission |
|
894 |
* The submission from which this component is being rendered. Usually not |
|
895 |
* needed. Used by _webform_render_date() to validate using the submission's |
|
896 |
* completion date. |
|
682 | 897 |
* |
683 | 898 |
* @see _webform_client_form_add_component() |
684 | 899 |
*/ |
685 |
function _webform_render_component($component, $value = NULL, $filter = TRUE) { |
|
900 |
function _webform_render_component($component, $value = NULL, $filter = TRUE, $submission = NULL) {
|
|
686 | 901 |
$form_item = array( |
687 | 902 |
'#type' => 'textfield', |
688 |
'#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
|
|
689 |
'#required' => $component['mandatory'],
|
|
903 |
'#title' => $filter ? webform_filter_xss($component['name']) : $component['name'], |
|
904 |
'#required' => $component['required'],
|
|
690 | 905 |
'#weight' => $component['weight'], |
691 |
'#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
|
|
692 |
'#default_value' => $filter ? _webform_filter_values($component['value']) : $component['value'],
|
|
906 |
'#description' => $filter ? webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], |
|
907 |
'#default_value' => $filter ? webform_replace_tokens($component['value']) : $component['value'],
|
|
693 | 908 |
'#prefix' => '<div class="webform-component-textfield" id="webform-component-' . $component['form_key'] . '">', |
694 | 909 |
'#suffix' => '</div>', |
695 | 910 |
); |
... | ... | |
701 | 916 |
return $form_item; |
702 | 917 |
} |
703 | 918 |
|
919 |
/** |
|
920 |
* Allow modules to modify a webform component that is going to be rendered in a form. |
|
921 |
* |
|
922 |
* @param array $element |
|
923 |
* The display element as returned by _webform_render_component(). |
|
924 |
* @param array $component |
|
925 |
* A Webform component array. |
|
926 |
* |
|
927 |
* @see _webform_render_component() |
|
928 |
*/ |
|
929 |
function hook_webform_component_render_alter(&$element, &$component) { |
|
930 |
if ($component['cid'] == 10) { |
|
931 |
$element['#title'] = 'My custom title'; |
|
932 |
$element['#default_value'] = 42; |
|
933 |
} |
|
934 |
} |
|
935 |
|
|
704 | 936 |
/** |
705 | 937 |
* Display the result of a submission for a component. |
706 | 938 |
* |
... | ... | |
716 | 948 |
* Either 'html' or 'text'. Defines the format that the content should be |
717 | 949 |
* returned as. Make sure that returned content is run through check_plain() |
718 | 950 |
* or other filtering functions when returning HTML. |
951 |
* @param $submission |
|
952 |
* The submission. Used to generate tokens. |
|
719 | 953 |
* @return |
720 | 954 |
* A renderable element containing at the very least these properties: |
721 | 955 |
* - #title |
... | ... | |
727 | 961 |
* which will properly format the label and content for use within an e-mail |
728 | 962 |
* (such as wrapping the text) or as HTML (ensuring consistent output). |
729 | 963 |
*/ |
730 |
function _webform_display_component($component, $value, $format = 'html') { |
|
964 |
function _webform_display_component($component, $value, $format = 'html', $submission = array()) {
|
|
731 | 965 |
return array( |
732 | 966 |
'#title' => $component['name'], |
733 | 967 |
'#weight' => $component['weight'], |
... | ... | |
742 | 976 |
); |
743 | 977 |
} |
744 | 978 |
|
979 |
/** |
|
980 |
* Allow modules to modify a "display only" webform component. |
|
981 |
* |
|
982 |
* @param array $element |
|
983 |
* The display element as returned by _webform_display_component(). |
|
984 |
* @param array $component |
|
985 |
* A Webform component array. |
|
986 |
* |
|
987 |
* @see _webform_display_component() |
|
988 |
*/ |
|
989 |
function hook_webform_component_display_alter(&$element, &$component) { |
|
990 |
if ($component['cid'] == 10) { |
|
991 |
$element['#title'] = 'My custom title'; |
|
992 |
$element['#default_value'] = 42; |
|
993 |
} |
|
994 |
} |
|
995 |
|
|
996 |
/** |
|
997 |
* Performs the conditional action set on an implemented component. |
|
998 |
* |
|
999 |
* Setting the form element allows form validation functions to see the value |
|
1000 |
* that webform has set for the given component. |
|
1001 |
* |
|
1002 |
* @param array $component |
|
1003 |
* The webform component array whose value is being set for the currently- |
|
1004 |
* edited submission. |
|
1005 |
* @param array $element |
|
1006 |
* The form element currently being set. |
|
1007 |
* @param array $form_state |
|
1008 |
* The form's state. |
|
1009 |
* @param string $value |
|
1010 |
* The value to be set, as defined in the conditional action. |
|
1011 |
*/ |
|
1012 |
function _webform_action_set_component($component, &$element, &$form_state, $value) { |
|
1013 |
$element['#value'] = $value; |
|
1014 |
form_set_value($element, $value, $form_state); |
|
1015 |
} |
|
1016 |
|
|
745 | 1017 |
/** |
746 | 1018 |
* A hook for changing the input values before saving to the database. |
747 | 1019 |
* |
... | ... | |
765 | 1037 |
function _webform_submit_component($component, $value) { |
766 | 1038 |
// Clean up a phone number into 123-456-7890 format. |
767 | 1039 |
if ($component['extra']['phone_number']) { |
768 |
$matches = array(); |
|
769 |
$number = preg_replace('[^0-9]', $value[0]); |
|
1040 |
$number = preg_replace('/[^0-9]/', '', $value[0]); |
|
770 | 1041 |
if (strlen($number) == 7) { |
771 | 1042 |
$number = substr($number, 0, 3) . '-' . substr($number, 3, 4); |
772 | 1043 |
} |
... | ... | |
846 | 1117 |
* Boolean flag determining if the details about a single component are being |
847 | 1118 |
* shown. May be used to provided detailed information about a single |
848 | 1119 |
* component's analysis, such as showing "Other" options within a select list. |
1120 |
* @param $join |
|
1121 |
* An optional SelectQuery object to be used to join with the submissions |
|
1122 |
* table to restrict the submissions being analyzed. |
|
849 | 1123 |
* @return |
850 |
* An array of data rows, each containing a statistic for this component's |
|
851 |
* submissions. |
|
1124 |
* An array containing one or more of the following keys: |
|
1125 |
* - table_rows: If this component has numeric data that can be represented in |
|
1126 |
* a grid, return the values here. This array assumes a 2-dimensional |
|
1127 |
* structure, with the first value being a label and subsequent values |
|
1128 |
* containing a decimal or integer. |
|
1129 |
* - table_header: If this component has more than a single set of values, |
|
1130 |
* include a table header so each column can be labeled. |
|
1131 |
* - other_data: If your component has non-numeric data to include, such as |
|
1132 |
* a description or link, include that in the other_data array. Each item |
|
1133 |
* may be a string or an array of values that matches the number of columns |
|
1134 |
* in the table_header property. |
|
1135 |
* At the very least, either table_rows or other_data should be provided. |
|
1136 |
* Note that if you want your component's analysis to be available by default |
|
1137 |
* without the user specifically enabling it, you must set |
|
1138 |
* $component['extra']['analysis'] = TRUE in your |
|
1139 |
* _webform_defaults_component() callback. |
|
1140 |
* |
|
1141 |
* @see _webform_defaults_component() |
|
852 | 1142 |
*/ |
853 |
function _webform_analysis_component($component, $sids = array(), $single = FALSE) { |
|
1143 |
function _webform_analysis_component($component, $sids = array(), $single = FALSE, $join = NULL) {
|
|
854 | 1144 |
// Generate the list of options and questions. |
855 | 1145 |
$options = _webform_select_options_from_text($component['extra']['options'], TRUE); |
856 | 1146 |
$questions = _webform_select_options_from_text($component['extra']['questions'], TRUE); |
... | ... | |
869 | 1159 |
$query->condition('sid', $sids, 'IN'); |
870 | 1160 |
} |
871 | 1161 |
|
1162 |
if ($join) { |
|
1163 |
$query->innerJoin($join, 'ws2_', 'wsd.sid = ws2_.sid'); |
|
1164 |
} |
|
1165 |
|
|
872 | 1166 |
$result = $query->execute(); |
873 | 1167 |
$counts = array(); |
874 | 1168 |
foreach ($result as $data) { |
... | ... | |
892 | 1186 |
} |
893 | 1187 |
$rows[] = $row; |
894 | 1188 |
} |
895 |
$output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('webform-grid')))); |
|
896 | 1189 |
|
897 |
return array(array(array('data' => $output, 'colspan' => 2))); |
|
1190 |
$other = array(); |
|
1191 |
$other[] = l(t('More information'), 'node/' . $component['nid'] . '/webform-results/analysis/' . $component['cid']); |
|
1192 |
|
|
1193 |
return array( |
|
1194 |
'table_header' => $header, |
|
1195 |
'table_rows' => $rows, |
|
1196 |
'other_data' => $other, |
|
1197 |
); |
|
898 | 1198 |
} |
899 | 1199 |
|
900 | 1200 |
/** |
... | ... | |
945 | 1245 |
function _webform_csv_headers_component($component, $export_options) { |
946 | 1246 |
$header = array(); |
947 | 1247 |
$header[0] = array(''); |
948 |
$header[1] = array($component['name']); |
|
1248 |
$header[1] = array($export_options['header_keys'] ? $component['form_key'] : $component['name']);
|
|
949 | 1249 |
$items = _webform_component_options($component['extra']['questions']); |
950 | 1250 |
$count = 0; |
951 | 1251 |
foreach ($items as $key => $item) { |
... | ... | |
989 | 1289 |
return $return; |
990 | 1290 |
} |
991 | 1291 |
|
1292 |
/** |
|
1293 |
* Adjusts the view field(s) that are automatically generated for number |
|
1294 |
* components. |
|
1295 |
* |
|
1296 |
* Provides each component the opportunity to adjust how this component is |
|
1297 |
* displayed in a view as a field in a view table. For example, a component may |
|
1298 |
* modify how it responds to click-sorting. Or it may add additional fields, |
|
1299 |
* such as a grid component having a column for each question. |
|
1300 |
* |
|
1301 |
* @param array $component |
|
1302 |
* A Webform component array |
|
1303 |
* @param array $fields |
|
1304 |
* An array of field-definition arrays. Will be passed one field definition, |
|
1305 |
* which may be modified. Additional fields may be added to the array. |
|
1306 |
* @return array |
|
1307 |
* The modified $fields array. |
|
1308 |
*/ |
|
1309 |
function _webform_view_field_component($component, $fields) { |
|
1310 |
foreach ($fields as &$field) { |
|
1311 |
$field['webform_datatype'] = 'number'; |
|
1312 |
} |
|
1313 |
return $fields; |
|
1314 |
} |
|
1315 |
|
|
1316 |
/** |
|
1317 |
* Modify the how a view was expanded to show all the components. |
|
1318 |
* |
|
1319 |
* This alter function is only called when the view is actually modified. It |
|
1320 |
* provides modules an opportunity to alter the changes that webform made to |
|
1321 |
* the view. |
|
1322 |
* |
|
1323 |
* This hook is called from webform_views_pre_view. If another module also |
|
1324 |
* changes views by implementing this same views hook, the relative order of |
|
1325 |
* execution of the two implementations will depend upon the module weights of |
|
1326 |
* the two modules. Using hook_webform_view_alter instead guarantees an |
|
1327 |
* opportuinty to modify the view AFTER webform. |
|
1328 |
* |
|
1329 |
* @param object $view |
|
1330 |
* The view object. |
|
1331 |
* @param string $display_id |
|
1332 |
* The display_id that was expanded by webform. |
|
1333 |
* @param array $args |
|
1334 |
* The argumentst that were passed to the view. |
|
1335 |
*/ |
|
1336 |
function hook_webform_view_alter($view, $display_id, $args) { |
|
1337 |
// Don't show component with cid == 4 |
|
1338 |
$fields = $view->get_items('field', $display_id); |
|
1339 |
foreach ($fields as $id => $field) { |
|
1340 |
if (isset($field['webform_cid']) && $field['webform_cid'] == 4) { |
|
1341 |
unset($fields[$id]); |
|
1342 |
} |
|
1343 |
} |
|
1344 |
$view->display[$display_id]->handler->set_option('fields', $fields); |
|
1345 |
} |
|
1346 |
|
|
1347 |
/** |
|
1348 |
* Modify the list of mail systems that are capable of sending HTML email. |
|
1349 |
* |
|
1350 |
* @param array &$systems |
|
1351 |
* An array of mail system class names. |
|
1352 |
*/ |
|
1353 |
function hook_webform_html_capable_mail_systems_alter(&$systems) { |
|
1354 |
if (module_exists('my_module')) { |
|
1355 |
$systems[] = 'MyModuleMailSystem'; |
|
1356 |
} |
|
1357 |
} |
|
1358 |
|
|
992 | 1359 |
/** |
993 | 1360 |
* @} |
994 | 1361 |
*/ |
Formats disponibles : Unified diff
Update webform to 4.10