1 system.admin.inc system_date_time_formats()

Displays the date format strings overview page.

File

core/modules/system/system.admin.inc, line 2254
Admin page callbacks for the system module.

Code

function system_date_time_formats() {
  $header = array(
    array('data' => t('Label')),
    array('data' => t('Machine name')),
    array('data' => t('Pattern')),
    array('data' => t('Operations'))
  );
  $rows = array();

  $formats = system_get_date_formats();
  if (!empty($formats)) {
    foreach ($formats as $date_format_name => $format_info) {
      // Do not display date formats that are hidden.
      if (empty($format_info['hidden'])) {
        $row = array();
        $row[] = array('data' => check_plain($format_info['label']));
        $row[] = array('data' => $date_format_name);
        $row[] = array('data' => format_date(REQUEST_TIME, 'custom', $format_info['pattern']));

        // Prepare Operational links.
        $links = array();
        $links['edit'] = array(
          'title' => t('Configure'),
          'href' => 'admin/config/regional/date-time/formats/' . $date_format_name . '/edit',
        );
        if (module_exists('locale')) {
          $links['localize'] = array(
            'title' => t('Localize'),
            'href' => 'admin/config/regional/date-time/formats/' . $date_format_name . '/localize',
          );
        }
        // Do not allow deletion of module-provided formats.
        if (empty($format_info['module'])) {
          $links['delete'] = array(
            'title' => t('Delete'),
            'href' => 'admin/config/regional/date-time/formats/' . $date_format_name . '/delete',
          );
        }
        $row['operations'] = array('data' => array(
          '#type' => 'operations',
          '#links' => $links,
        ));

        $rows[] = $row;
      }
    }
  }

  $build['date_formats_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No custom date formats available. <a href="@link">Add date format</a>.', array('@link' => url('admin/config/regional/date-time/formats/add'))),
  );

  return $build;
}