You are here

function weather_admin_main_page in Weather 7

Same name and namespace in other branches
  1. 6.5 weather.module \weather_admin_main_page()
  2. 7.3 weather.forms.inc \weather_admin_main_page()
  3. 7.2 weather.forms.inc \weather_admin_main_page()

Show an overview of configured displays and the default display.

1 string reference to 'weather_admin_main_page'
weather_menu in ./weather.module
Implement hook_menu().

File

./weather.forms.inc, line 27
Provide forms for configuration of weather displays.

Code

function weather_admin_main_page() {
  $output = '';
  $path = 'admin/config/user-interface/weather/system-wide/';
  $displays = weather_get_displays_in_use('system-wide');
  if (!empty($displays)) {
    foreach ($displays as $display_number) {
      $header = array(
        l(t('System-wide display (#!number)', array(
          '!number' => $display_number,
        )), $path . $display_number),
        t('Weight'),
      );
      $rows = array();
      $result = db_query("SELECT * FROM {weather_location}\n        WHERE display_type='system-wide' AND display_number=:number ORDER BY weight ASC, real_name ASC", array(
        ':number' => $display_number,
      ));
      foreach ($result as $location) {
        $rows[] = array(
          l($location->real_name, $path . $display_number . '/' . $location->id . '/edit'),
          $location->weight,
        );
      }

      // Insert link for adding locations into the table as last row.
      $rows[] = array(
        array(
          'data' => l(t('Add location to this display'), $path . $display_number . '/add'),
          'colspan' => 2,
        ),
      );
      $output .= theme('table', array(
        'header' => $header,
        'rows' => $rows,
      ));
      if (isset($form['pager']['#value'])) {
        $output .= drupal_render($form['pager']);
      }
    }
  }
  $form = drupal_get_form('weather_admin_main_page_form');
  $output .= drupal_render($form);
  return $output;
}