$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( array( 'data' => $form['#title'] .':', 'children' => summarize_form($form), ), ); case 'textfield': return $form['#title'] .': '. check_plain($form['#default_value']); case 'select': if (!empty($form['#multiple']) and is_array($form['#default_value'])) { $options = array(); foreach ($form['#default_value'] as $value) { if (isset($form['#options'][$value])) { $options[] = $form['#options'][$value]; } } // Return an item list of the selected options. return array(array( 'data' => $form['#title'].':', 'children' => $options, )); } // Else, fall through. 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); } } } /** * Return an empty summary string. */ function summarize_null($form) { return array(); } /** * Return the correct summary string for a checkbox element based on its * current value. * * @param $true * The summary string to use if the checkbox has been checked. * @param $false * The summary string to use if the checkbox has not been checked. * @return * The correct supplied string based on the current value of the checkbox. */ function summarize_checkbox($form, $true, $false) { if ($form['#default_value']) { return $true; } else { return $false; } } /** * Summarize 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. * @param $only_parent * When set to TRUE, forms will only be included from the given $path, * no recursion will be done * @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, $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; } /** * Theme a summaries array into a handy div for use with some JS enhancement. * * @param $summaries * An array of summary arrays each containing the following keys: * - path - the path of the settings form the array is summarizing. * - title - the title of the settings form. * - href - the actual URL of the summary's form page. * - items - an array of items formatted for theme_item_list(). * @param $link * TRUE or FALSE indicating whether or not to display an edit icon linking to * the settings form the summary represents. * @return * The HTML output of the summary. * @ingroup themeable */ function theme_summary_overview($summaries, $link = TRUE) { // Add some Ubercart specific JS for modifying summaries. drupal_add_js(drupal_get_path('module', 'uc_store') .'/includes/summaries.js'); drupal_add_js(array('editIconPath' => base_path() . drupal_get_path('module', 'uc_store') .'/images/order_edit.gif'), 'setting'); $output = ''; foreach ($summaries as $summary) { // Add a containing div for the summary overview. $output .= '