diff --git a/core/modules/system/lib/Drupal/system/Controller/DateTimeController.php b/core/modules/system/lib/Drupal/system/Controller/DateTimeController.php new file mode 100644 index 0000000..a1ffc0e --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Controller/DateTimeController.php @@ -0,0 +1,72 @@ + t('Machine name'), 'field' => 'machine_name'), + array('data' => t('Name'), 'field' => 'name'), + array('data' => t('Pattern'), 'field' => 'pattern'), + array('data' => t('Operations')) + ); + $rows = array(); + + $formats = system_get_date_formats(); + + if (!empty($formats)) { + foreach ($formats as $date_format_id => $format_info) { + // Do not display date formats that are locked. + if (empty($format_info['locked'])) { + $row = array(); + $row[] = array('data' => $date_format_id); + $row[] = array('data' => $format_info['name']); + $row[] = array('data' => format_date(REQUEST_TIME, $date_format_id)); + + // Prepare Operational links. + $links = array(); + $links['edit'] = array( + 'title' => t('Edit'), + 'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/edit', + ); + $links['delete'] = array( + 'title' => t('Delete'), + 'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/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. Add date format.', array('@link' => url('admin/config/regional/date-time/formats/add'))), + ); + + return $build; + } +} diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php index c867581..7b4aa07 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php @@ -78,7 +78,7 @@ function testTimeZoneHandling() { */ function testDateFormatConfiguration() { // Confirm 'no custom date formats available' message appears. - $this->drupalGet('admin/config/regional/date-time/formats'); + $this->drupalGet('admin/config/regional/date-time'); // Add custom date format. $this->clickLink(t('Add format')); @@ -97,7 +97,7 @@ function testDateFormatConfiguration() { $this->assertText(t('Delete'), 'Delete link for custom date format appears.'); // Edit custom date format. - $this->drupalGet('admin/config/regional/date-time/formats'); + $this->drupalGet('admin/config/regional/date-time'); $this->clickLink(t('Edit')); $edit = array( 'date_format_pattern' => 'Y m', diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 1566c80..ac4efdd 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1831,59 +1831,6 @@ function theme_system_themes_page($variables) { } /** - * Displays the date format strings overview page. - */ -function system_date_time_formats() { - $header = array( - array('data' => t('Machine name'), 'field' => 'machine_name'), - array('data' => t('Name'), 'field' => 'name'), - array('data' => t('Pattern'), 'field' => 'pattern'), - array('data' => t('Operations')) - ); - $rows = array(); - - $formats = system_get_date_formats(); - - if (!empty($formats)) { - foreach ($formats as $date_format_id => $format_info) { - // Do not display date formats that are locked. - if (empty($format_info['locked'])) { - $row = array(); - $row[] = array('data' => $date_format_id); - $row[] = array('data' => $format_info['name']); - $row[] = array('data' => format_date(REQUEST_TIME, $date_format_id)); - - // Prepare Operational links. - $links = array(); - $links['edit'] = array( - 'title' => t('Edit'), - 'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/edit', - ); - $links['delete'] = array( - 'title' => t('Delete'), - 'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/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. Add date format.', array('@link' => url('admin/config/regional/date-time/formats/add'))), - ); - - return $build; -} - -/** * Allow users to add additional date formats. * * @param string $date_format_id @@ -2015,7 +1962,7 @@ function system_date_formats_form_submit($form, &$form_state) { drupal_set_message(t('Custom date format added.')); } - $form_state['redirect'] = 'admin/config/regional/date-time/formats'; + $form_state['redirect'] = 'admin/config/regional/date-time'; } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0d472e5..30581a9 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -880,10 +880,8 @@ function system_menu() { $items['admin/config/regional/date-time'] = array( 'title' => 'Date and time formats', 'description' => 'Configure display format strings for date and time.', - 'page callback' => 'system_date_time_formats', - 'access arguments' => array('administer site configuration'), + 'route_name' => 'system_date_time_formats', 'weight' => -9, - 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/add'] = array( 'title' => 'Add format', diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 9859d6a..8487446 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -87,3 +87,10 @@ date_format_localize_reset: _form: '\Drupal\system\Form\DateFormatLocalizeResetForm' requirements: _permission: 'administer site configuration' + +system_date_time_formats: + pattern: 'admin/config/regional/date-time' + defaults: + _content: '\Drupal\system\Controller\DateTimeController::formats' + requirements: + _permission: 'administer site configuration'