You are here

function express_dashboards_dashboard_output in Express 7.2

Callback function for dashboard items.

1 string reference to 'express_dashboards_dashboard_output'
express_dashboards_menu in modules/custom/express_dashboards/express_dashboards.module
Implements hook_menu().

File

modules/custom/express_dashboards/express_dashboards.module, line 68

Code

function express_dashboards_dashboard_output($dashboard, $id) {
  $dashboard_sections = $dashboard();
  $dashboard_output = array();

  // Check for missing section weights and then sort
  foreach ($dashboard_sections as $key => $section) {
    $dashboard_sections[$key]['weight'] = isset($dashboard_sections[$key]['weight']) ? $dashboard_sections[$key]['weight'] : 0;
  }
  uasort($dashboard_sections, 'drupal_sort_weight');

  // Step through sections
  foreach ($dashboard_sections as $section_key => $section) {
    $vars = array();
    $dashboard_section_output = array();

    // Check for missing widget weights and then sort
    foreach ($dashboard_sections[$section_key]['widgets'] as $key => $widget) {
      $dashboard_sections[$section_key['widgets']][$key]['weight'] = isset($dashboard_sections[$section_key]['widgets'][$key]['weight']) ? $dashboard_sections[$section_key]['widgets'][$key]['weight'] : 0;
    }
    uasort($dashboard_sections[$section_key]['widgets'], 'drupal_sort_weight');

    // Step through widgets
    foreach ($dashboard_sections[$section_key]['widgets'] as $key => $widget) {
      $vars = array();
      $vars['dashboard_section_id'] = $section_key;
      $vars['dashboard_widget_id'] = $key;
      $vars['title'] = $widget['title'];
      $vars['content'] = $widget['content'];
      $dashboard_section_output[$section_key]['widgets'][$key]['#markup'] = theme('express_dashboard_widget', $vars);
    }
    $vars = array();
    $vars['content'] = $dashboard_section_output;
    $vars['dashboard_section_id'] = $section_key;
    $dashboard_output['content'][$section_key]['#markup'] = theme('express_dashboard_section', $vars);
  }

  // Adding dashboard id for making template suggestions
  $dashboard_output['dashboard_id'] = $id;

  // Return dashboard output
  return theme('express_dashboard', $dashboard_output);
}