diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-09-10 06:31:39 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-09-10 06:31:39 +0000 |
commit | d481f1cd364de615d274c2ccde68e37126f1959e (patch) | |
tree | bb4c488f30b310441fb81ef76f0edbad382cd3f0 /modules | |
parent | 46c4a33b21988a5420ffab0964c6a017abbb96b2 (diff) | |
download | brdo-d481f1cd364de615d274c2ccde68e37126f1959e.tar.gz brdo-d481f1cd364de615d274c2ccde68e37126f1959e.tar.bz2 |
- Patch #572932 by sun: rename hook_elements() to hook_elements_info() for consistency. Yay to API clean-ups during 'slush'.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/field/field.api.php | 2 | ||||
-rw-r--r-- | modules/field/modules/number/number.module | 24 | ||||
-rw-r--r-- | modules/field/modules/options/options.module | 46 | ||||
-rw-r--r-- | modules/field/modules/text/text.module | 58 | ||||
-rw-r--r-- | modules/file/file.module | 15 | ||||
-rw-r--r-- | modules/simpletest/tests/field_test.module | 2 | ||||
-rw-r--r-- | modules/system/system.api.php | 15 | ||||
-rw-r--r-- | modules/system/system.module | 93 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 25 | ||||
-rw-r--r-- | modules/user/user.module | 17 |
10 files changed, 125 insertions, 172 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 47c2da25c..5ed330f32 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -603,7 +603,7 @@ function hook_field_widget_info_alter(&$info) { * Return a single form element for a form. * * It will be built out and validated in the callback(s) listed in - * hook_elements. We build it out in the callbacks rather than in + * hook_element_info(). We build it out in the callbacks rather than in * hook_field_widget so it can be plugged into any module that can * provide it with valid $field information. * diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module index dafe254cd..a95eace6b 100644 --- a/modules/field/modules/number/number.module +++ b/modules/field/modules/number/number.module @@ -292,32 +292,26 @@ function number_field_widget_info() { } /** - * Implement FAPI hook_elements(). - * - * Any FAPI callbacks needed for individual widgets can be declared here, - * and the element will be passed to those callbacks for processing. - * - * Drupal will automatically theme the element using a theme with - * the same name as the hook_elements key. + * Implement hook_element_info(). * * Includes a regex to check for valid values as an additional parameter * the validator can use. The regex can be overridden if necessary. */ -function number_elements() { - return array( - 'number' => array( - '#input' => TRUE, - '#columns' => array('value'), '#delta' => 0, - '#process' => array('number_elements_process'), - ), +function number_element_info() { + $types['number'] = array( + '#input' => TRUE, + '#columns' => array('value'), + '#delta' => 0, + '#process' => array('number_elements_process'), ); + return $types; } /** * Implement hook_field_widget(). * * Attach a single form element to the form. It will be built out and - * validated in the callback(s) listed in hook_elements. We build it + * validated in the callback(s) listed in hook_element_info(). We build it * out in the callbacks rather than here in hook_widget so it can be * plugged into any module that can provide it with valid * $field information. diff --git a/modules/field/modules/options/options.module b/modules/field/modules/options/options.module index 84e2e1615..b9ec74173 100644 --- a/modules/field/modules/options/options.module +++ b/modules/field/modules/options/options.module @@ -67,32 +67,28 @@ function options_field_widget_info() { } /** - * Implement FAPI hook_elements(). - * - * Any FAPI callbacks needed for individual widgets can be declared here, - * and the element will be passed to those callbacks for processing. - * - * Drupal will automatically theme the element using a theme with - * the same name as the hook_elements key. + * Implement hook_element_info(). */ -function options_elements() { - return array( - 'options_select' => array( - '#input' => TRUE, - '#columns' => array('value'), '#delta' => 0, - '#process' => array('options_select_elements_process'), - ), - 'options_buttons' => array( - '#input' => TRUE, - '#columns' => array('value'), '#delta' => 0, - '#process' => array('options_buttons_elements_process'), - ), - 'options_onoff' => array( - '#input' => TRUE, - '#columns' => array('value'), '#delta' => 0, - '#process' => array('options_onoff_elements_process'), - ), - ); +function options_element_info() { + $types['options_select'] = array( + '#input' => TRUE, + '#columns' => array('value'), + '#delta' => 0, + '#process' => array('options_select_elements_process'), + ); + $types['options_buttons'] = array( + '#input' => TRUE, + '#columns' => array('value'), + '#delta' => 0, + '#process' => array('options_buttons_elements_process'), + ); + $types['options_onoff'] = array( + '#input' => TRUE, + '#columns' => array('value'), + '#delta' => 0, + '#process' => array('options_onoff_elements_process'), + ); + return $types; } /** diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index d6653d873..db9ba24ed 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -521,48 +521,44 @@ function text_field_widget_settings_form($field, $instance) { } /** - * Implement FAPI hook_elements(). - * - * Any FAPI callbacks needed for individual widgets can be declared here, - * and the element will be passed to those callbacks for processing. - * - * Drupal will automatically theme the element using a theme with - * the same name as the hook_elements key. + * Implement hook_element_info(). * * Autocomplete_path is not used by text_field_widget but other * widgets can use it (see nodereference and userreference). */ -function text_elements() { - return array( - 'text_textfield' => array( - '#input' => TRUE, - '#columns' => array('value'), '#delta' => 0, - '#process' => array('text_textfield_elements_process'), - '#theme_wrappers' => array('text_textfield'), - '#autocomplete_path' => FALSE, - ), - 'text_textarea' => array( - '#input' => TRUE, - '#columns' => array('value', 'format'), '#delta' => 0, - '#process' => array('text_textarea_elements_process'), - '#theme_wrappers' => array('text_textarea'), - '#filter_value' => FILTER_FORMAT_DEFAULT, - ), - 'text_textarea_with_summary' => array( - '#input' => TRUE, - '#columns' => array('value', 'format', 'summary'), '#delta' => 0, - '#process' => array('text_textarea_with_summary_process'), - '#theme_wrappers' => array('text_textarea'), - '#filter_value' => FILTER_FORMAT_DEFAULT, - ), +function text_element_info() { + $types['text_textfield'] = array( + '#input' => TRUE, + '#columns' => array('value'), + '#delta' => 0, + '#process' => array('text_textfield_elements_process'), + '#theme_wrappers' => array('text_textfield'), + '#autocomplete_path' => FALSE, + ); + $types['text_textarea'] = array( + '#input' => TRUE, + '#columns' => array('value', 'format'), + '#delta' => 0, + '#process' => array('text_textarea_elements_process'), + '#theme_wrappers' => array('text_textarea'), + '#filter_value' => FILTER_FORMAT_DEFAULT, + ); + $types['text_textarea_with_summary'] = array( + '#input' => TRUE, + '#columns' => array('value', 'format', 'summary'), + '#delta' => 0, + '#process' => array('text_textarea_with_summary_process'), + '#theme_wrappers' => array('text_textarea'), + '#filter_value' => FILTER_FORMAT_DEFAULT, ); + return $types; } /** * Implement hook_field_widget(). * * Attach a single form element to the form. It will be built out and - * validated in the callback(s) listed in hook_elements. We build it + * validated in the callback(s) listed in hook_element_info(). We build it * out in the callbacks rather than here in hook_field_widget so it can be * plugged into any module that can provide it with valid * $field information. diff --git a/modules/file/file.module b/modules/file/file.module index 23542942a..b804b1a4f 100644 --- a/modules/file/file.module +++ b/modules/file/file.module @@ -30,15 +30,13 @@ function file_menu() { } /** - * Implement hook_elements(). + * Implement hook_element_info(). + * + * The managed file element may be used independently anywhere in Drupal. */ -function file_elements() { - $elements = array(); - +function file_element_info() { $file_path = drupal_get_path('module', 'file'); - - // The managed file element may be used independently anywhere in Drupal. - $elements['managed_file'] = array( + $types['managed_file'] = array( '#input' => TRUE, '#process' => array('file_managed_file_process'), '#value_callback' => 'file_managed_file_value', @@ -55,8 +53,7 @@ function file_elements() { 'js' => array($file_path . '/file.js'), ), ); - - return $elements; + return $types; } /** diff --git a/modules/simpletest/tests/field_test.module b/modules/simpletest/tests/field_test.module index f0b47bd76..fb711de78 100644 --- a/modules/simpletest/tests/field_test.module +++ b/modules/simpletest/tests/field_test.module @@ -470,7 +470,7 @@ function field_test_field_widget_info() { * Implement hook_field_widget(). * * Attach a single form element to the form. It will be built out and - * validated in the callback(s) listed in hook_elements. We build it + * validated in the callback(s) listed in hook_element_info(). We build it * out in the callbacks rather than here in hook_widget so it can be * plugged into any module that can provide it with valid * $field information. diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 4f2ec074b..2c5bcbd27 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -215,10 +215,15 @@ function hook_db_rewrite_sql($query, $primary_table, $primary_field, $args) { * - "#pre_render": array of callback functions taking $element and $form_state. * - "#post_render": array of callback functions taking $element and $form_state. * - "#submit": array of callback functions taking $form and $form_state. + * + * @see hook_element_info_alter() + * @see system_element_info() */ -function hook_elements() { - $type['filter_format'] = array('#input' => TRUE); - return $type; +function hook_element_info() { + $types['filter_format'] = array( + '#input' => TRUE, + ); + return $types; } /** @@ -228,9 +233,9 @@ function hook_elements() { * defined by a module. * * @param &$type - * All element type defaults as collected by hook_elements(). + * All element type defaults as collected by hook_element_info(). * - * @see hook_elements() + * @see hook_element_info() */ function hook_element_info_alter(&$type) { // Decrease the default size of textfields. diff --git a/modules/system/system.module b/modules/system/system.module index e0762d993..ff4cf4ed3 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -279,32 +279,28 @@ function system_entity_info() { } /** - * Implement hook_elements(). + * Implement hook_element_info(). */ -function system_elements() { - // Top level form - $type['form'] = array( +function system_element_info() { + // Top level elements. + $types['form'] = array( '#method' => 'post', '#action' => request_uri(), '#theme_wrappers' => array('form'), ); - - $type['page'] = array( + $types['page'] = array( '#show_messages' => TRUE, '#theme' => 'page', ); - - $type['list'] = array( + $types['list'] = array( '#title' => '', '#list_type' => 'ul', '#attributes' => array(), '#items' => array(), ); - /** - * Input elements. - */ - $type['submit'] = array( + // Input elements. + $types['submit'] = array( '#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', @@ -312,8 +308,7 @@ function system_elements() { '#process' => array('ajax_process_form'), '#theme_wrappers' => array('button'), ); - - $type['button'] = array( + $types['button'] = array( '#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', @@ -321,8 +316,7 @@ function system_elements() { '#process' => array('ajax_process_form'), '#theme_wrappers' => array('button'), ); - - $type['image_button'] = array( + $types['image_button'] = array( '#input' => TRUE, '#button_type' => 'submit', '#executes_submit_callback' => TRUE, @@ -332,8 +326,7 @@ function system_elements() { '#src' => NULL, '#theme_wrappers' => array('image_button'), ); - - $type['textfield'] = array( + $types['textfield'] = array( '#input' => TRUE, '#size' => 60, '#maxlength' => 128, @@ -342,8 +335,7 @@ function system_elements() { '#theme' => 'textfield', '#theme_wrappers' => array('form_element'), ); - - $type['password'] = array( + $types['password'] = array( '#input' => TRUE, '#size' => 60, '#maxlength' => 128, @@ -351,14 +343,12 @@ function system_elements() { '#theme' => 'password', '#theme_wrappers' => array('form_element'), ); - - $type['password_confirm'] = array( + $types['password_confirm'] = array( '#input' => TRUE, '#process' => array('form_process_password_confirm'), '#theme_wrappers' => array('form_element'), ); - - $type['textarea'] = array( + $types['textarea'] = array( '#input' => TRUE, '#cols' => 60, '#rows' => 5, @@ -367,15 +357,13 @@ function system_elements() { '#theme' => 'textarea', '#theme_wrappers' => array('form_element'), ); - - $type['radios'] = array( + $types['radios'] = array( '#input' => TRUE, '#process' => array('form_process_radios'), '#theme_wrappers' => array('radios'), '#pre_render' => array('form_pre_render_conditional_form_element'), ); - - $type['radio'] = array( + $types['radio'] = array( '#input' => TRUE, '#default_value' => NULL, '#process' => array('ajax_process_form'), @@ -383,16 +371,14 @@ function system_elements() { '#theme_wrappers' => array('form_element'), '#form_element_skip_title' => TRUE, ); - - $type['checkboxes'] = array( + $types['checkboxes'] = array( '#input' => TRUE, '#tree' => TRUE, '#process' => array('form_process_checkboxes'), '#theme_wrappers' => array('checkboxes'), '#pre_render' => array('form_pre_render_conditional_form_element'), ); - - $type['checkbox'] = array( + $types['checkbox'] = array( '#input' => TRUE, '#return_value' => 1, '#process' => array('ajax_process_form'), @@ -400,8 +386,7 @@ function system_elements() { '#theme_wrappers' => array('form_element'), '#form_element_skip_title' => TRUE, ); - - $type['select'] = array( + $types['select'] = array( '#input' => TRUE, '#size' => 0, '#multiple' => FALSE, @@ -409,64 +394,54 @@ function system_elements() { '#theme' => 'select', '#theme_wrappers' => array('form_element'), ); - - $type['weight'] = array( + $types['weight'] = array( '#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('form_process_weight', 'ajax_process_form'), ); - - $type['date'] = array( + $types['date'] = array( '#input' => TRUE, '#element_validate' => array('date_validate'), '#process' => array('form_process_date'), '#theme' => 'date', '#theme_wrappers' => array('form_element'), ); - - $type['file'] = array( + $types['file'] = array( '#input' => TRUE, '#size' => 60, '#theme' => 'file', '#theme_wrappers' => array('form_element'), ); - - $type['tableselect'] = array( + $types['tableselect'] = array( '#input' => TRUE, '#js_select' => TRUE, '#multiple' => TRUE, '#process' => array('form_process_tableselect'), '#options' => array(), '#empty' => '', - '#theme' => 'tableselect' + '#theme' => 'tableselect', ); - /** - * Form structure. - */ - $type['item'] = array( + // Form structure. + $types['item'] = array( '#markup' => '', '#theme' => 'markup', '#theme_wrappers' => array('form_element'), ); - - $type['hidden'] = array( + $types['hidden'] = array( '#input' => TRUE, '#process' => array('ajax_process_form'), '#theme' => 'hidden', ); - - $type['value'] = array( + $types['value'] = array( '#input' => TRUE, ); - - $type['markup'] = array( + $types['markup'] = array( '#markup' => '', '#theme' => 'markup', ); - - $type['fieldset'] = array( + $types['fieldset'] = array( '#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL, @@ -474,19 +449,17 @@ function system_elements() { '#pre_render' => array('form_pre_render_fieldset'), '#theme_wrappers' => array('fieldset'), ); - - $type['vertical_tabs'] = array( + $types['vertical_tabs'] = array( '#theme_wrappers' => array('vertical_tabs'), '#default_tab' => '', '#process' => array('form_process_vertical_tabs'), ); - - $type['token'] = array( + $types['token'] = array( '#input' => TRUE, '#theme' => array('hidden'), ); - return $type; + return $types; } /** diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 039b7bca0..7bf15935a 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -2144,23 +2144,16 @@ function taxonomy_autocomplete_validate($element, &$form_state) { } /** - * Implement FAPI hook_elements(). - * - * Any FAPI callbacks needed for individual widgets can be declared here, - * and the element will be passed to those callbacks for processing. - * - * Drupal will automatically theme the element using a theme with - * the same name as the hook_elements key. - */ -function taxonomy_elements() { - return array( - 'taxonomy_autocomplete' => array( - '#input' => TRUE, - '#columns' => array('value'), - '#delta' => 0, - '#process' => array('taxonomy_autocomplete_elements_process'), - ), + * Implement hook_element_info(). + */ +function taxonomy_element_info() { + $types['taxonomy_autocomplete'] = array( + '#input' => TRUE, + '#columns' => array('value'), + '#delta' => 0, + '#process' => array('taxonomy_autocomplete_elements_process'), ); + return $types; } /** diff --git a/modules/user/user.module b/modules/user/user.module index 13479217f..923230804 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -838,17 +838,16 @@ function user_search_execute($keys = NULL) { } /** - * Implement hook_elements(). + * Implement hook_element_info(). */ -function user_elements() { - return array( - 'user_profile_category' => array( - '#theme_wrappers' => array('user_profile_category') - ), - 'user_profile_item' => array( - '#theme' => 'user_profile_item' - ), +function user_element_info() { + $types['user_profile_category'] = array( + '#theme_wrappers' => array('user_profile_category'), + ); + $types['user_profile_item'] = array( + '#theme' => 'user_profile_item', ); + return $types; } /** |