$form['#title'], '!summary' => $form['#summary'])); } else { return $form['#summary']; } } else { // Otherwise, use a sensible default based on the field type. switch ($form['#type']) { case 'fieldset': return array( 'data' => $form['#title'], 'children' => summarize_form($form), ); case 'textfield': return $form['#title'] .': '. check_plain($form['#default_value']); case 'select': case 'radios': return $form['#title'] .': '. $form['#options'][$form['#default_value']]; case 'checkbox': if ($form['#default_value']) { return $form['#title']; } else { return; } } // If we didn't have a default action, check for a callback. $callback = 'summarize_'. $form['#type']; if (function_exists($callback)) { return $callback($form); } } } function summarize_checkbox($form, $true, $false) { if ($form['#default_value']) { return $true; } else { return $false; } } /** * Summarizes the form pages that are children of the specified path. * * @param $path * The menu path to start from when checking for children forms. * @param $trim * When set to TRUE, summary data will only be included in the return array * when the summary actually has items. * @return * An array of data representing a form page summary including keys for the * page's 'path', and edit 'href', a summary 'title' and 'items'. */ function summarize_child_form_pages($path, $trim = FALSE) { $summaries = array(); // Fetch and loop through any child menu items from the database. $result = db_query("SELECT path FROM {menu_router} WHERE path LIKE '%s/%%' ORDER BY weight", $path); while ($row = db_fetch_array($result)) { $item = menu_get_item($row['path']); 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' => $item['path'], 'href' => $href, 'title' => $item['title'], 'items' => $summary_items, ); } } } return $summaries; } function theme_summary_overview($summaries, $link = TRUE) { $output = ''; foreach ($summaries as $summary) { // Add a containing div for the summary overview. $output .= '
'; // Add a div for the header containing the title and edit link. $output .= '
' . $summary['title'] .''; if ($link) { $output .= ' '. l(t('edit'), $summary['href']) .''; } $output .= '
'; // Add in the list for the summary items. $output .= theme('item_list', $summary['items']); // Close out the summary overview div. $output .= '
'; } return $output; }