You are here

function summarize_child_form_pages in Ubercart 6.2

Summarize the form pages that are children of the specified path.

Parameters

$path: The menu path to start from when checking for children forms.

$trim: When set to TRUE, summary data will only be included in the return array when the summary actually has items.

$only_parent: When set to TRUE, forms will only be included from the given $path, no recursion will be done

Return value

An array of data representing a form page summary including keys for the page's 'path', and edit 'href', a summary 'title' and 'items'.

9 calls to summarize_child_form_pages()
uc_cart_cart_settings_overview in uc_cart/uc_cart.admin.inc
Display an overview of the cart settings.
uc_cart_checkout_settings_overview in uc_cart/uc_cart.admin.inc
Display an overview of the checkout settings.
uc_catalog_settings_overview in uc_catalog/uc_catalog.admin.inc
Display an overview of the catalog settings.
uc_country_settings_overview in uc_store/uc_store.admin.inc
Displays an overview of the country settings.
uc_order_settings_overview in uc_order/uc_order.admin.inc
Displays an overview of the order settings.

... See full list

File

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

Code

function summarize_child_form_pages($path, $trim = FALSE, $only_parent = FALSE) {
  $summaries = array();

  // Fetch and loop through any child menu items from the database.
  $accessor = "LIKE '%s/%%'";

  // If no_recur is TRUE, only look for the parent
  if ($only_parent) {
    $accessor = "= '%s'";
  }
  $result = db_query("SELECT path FROM {menu_router} WHERE path " . $accessor . " ORDER BY weight", $path);
  while ($row = db_fetch_array($result)) {
    $item = menu_get_item($row['path']);

    // Only allow items the user can access.
    if ($item['access'] === FALSE) {
      continue;
    }
    if ($item['page_callback'] == 'drupal_get_form') {
      if ($item['type'] == MENU_DEFAULT_LOCAL_TASK) {
        $parent = menu_get_item($item['tab_parent']);
        $href = $parent['href'];
      }
      else {
        $href = $item['href'];
      }
      $form_id = $item['page_arguments'][0];
      if (!function_exists($form_id)) {
        require_once $item['file'];
      }
      $form_state = array(
        'storage' => NULL,
        'submitted' => FALSE,
      );
      $form = drupal_retrieve_form($form_id, $form_state);
      drupal_prepare_form($form_id, $form, $form_state);
      $summary_items = summarize_form($form);
      if (!$trim || $trim && count($summary_items) > 0) {
        $summaries[] = array(
          'path' => url($item['path']),
          'href' => $href,
          'title' => $item['title'],
          'items' => $summary_items,
        );
      }
    }
  }
  return $summaries;
}