You are here

function summarize_form in Ubercart 6.2

Summarizes the elements in a form array.

Recursively builds summaries of items nested in fieldsets if applicable.

Parameters

$form: The form array to summarize.

Return value

An array of summary information, structured for theme_item_list().

3 calls to summarize_form()
summarize_child_form_pages in uc_store/includes/summaries.inc
Summarize the form pages that are children of the specified path.
summarize_element in uc_store/includes/summaries.inc
Summarize an individual element using its specified #summary if possible.
_uc_catalog_block_summarize in uc_catalog/uc_catalog.module
Summarizes the catalog's block settings.
12 string references to 'summarize_form'
uc_cart_cart_settings_form in uc_cart/uc_cart.admin.inc
General settings for the shopping cart.
uc_cart_checkout_messages_form in uc_cart/uc_cart.admin.inc
Settings for help messages displayed on the checkout page.
uc_cart_checkout_settings_form in uc_cart/uc_cart.admin.inc
General checkout settings.
uc_catalog_settings_form in uc_catalog/uc_catalog.admin.inc
Catalog settings form.
uc_order_panes_form in uc_order/uc_order.admin.inc
Settings for the order panes.

... See full list

File

uc_store/includes/summaries.inc, line 18
Provides summaries of forms and fieldsets.

Code

function summarize_form($form) {
  $items = array();

  // Loop through each element in $form.
  foreach (element_children($form) as $key) {

    // Set the callback for the summary to the default if not specified.
    if (!isset($form[$key]['#summary callback'])) {

      // Default filter forms to have no summary.
      if (isset($form[$key]['#element_validate']) && in_array('filter_form_validate', (array) $form[$key]['#element_validate'])) {
        $form[$key]['#summary callback'] = 'summarize_null';
      }
      else {
        $form[$key]['#summary callback'] = 'summarize_element';
      }
    }

    // Setup the arguments array, always passing in the form array.
    $args = array(
      $form[$key],
    );

    // Append the arguments specified by the element.
    if (isset($form[$key]['#summary arguments'])) {
      $args = array_merge($args, $form[$key]['#summary arguments']);
    }

    // Fetch the result from the summary callback.
    $result = call_user_func_array($form[$key]['#summary callback'], $args);

    // Check the type of the result...
    if (is_array($result)) {

      // Arrays get merged in so summaries can include multiple items.
      $items = array_merge($items, $result);
    }
    elseif (!empty($result)) {

      // Otherwise add a non-empty result to the array as a new value.
      $items[] = $result;
    }
  }
  return $items;
}