diff --git a/scheduler.admin.inc b/scheduler.admin.inc index 6b9b780..e6eb4bc 100644 --- a/scheduler.admin.inc +++ b/scheduler.admin.inc @@ -7,8 +7,6 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Url; /** * Helper function for the real hook_form_node_type_form_alter(). @@ -233,60 +231,6 @@ function _scheduler_generate_key(array $form, FormStateInterface $form_state) { } /** - * Page callback: Generate the timecheck admin page. - */ -function _scheduler_timecheck() { - return theme('scheduler_timecheck', array('now' => REQUEST_TIME)); -} - -/** - * Returns HTML the timecheck administration page. - * - * @param array $variables - * An associative array containing: - * - 'now': A UNIX timestamp to format. - * - * @ingroup themeable - */ -function theme_scheduler_timecheck($variables) { - $account = \Drupal::currentUser(); - - $now = $variables['now']; - $date_default_timezone = variable_get('date_default_timezone', date_default_timezone_get()); - - $t_options = array( - // For @utc specify 'GMT' as the timezone (4th parameter) so that no - // timezone offset is returned. - '@utc' => format_date($now, 'custom', 'jS F Y, H:i:s P', 'GMT'), - // For @localtime do not specify any timezone parameter so that the user or - // site default setting is returned. - '@localtime' => format_date($now, 'custom', 'jS F Y, H:i:s P T e'), - '@daylight_saving' => format_date($now, 'custom', 'I') ? t('currently in daylight saving mode') : t('not in daylight saving mode'), - '@user_account' => Url::fromRoute('entity.user.edit_form', array('user' => $account->id())), - '@date_default_timezone' => String::checkPlain($date_default_timezone), - '@date_default_offset' => format_date($now, 'custom', 'P', $date_default_timezone), - '@date_default_code' => format_date($now, 'custom', 'T', $date_default_timezone), - '@admin_regional_settings' => Url::fromRoute('system.regional_settings'), - ); - - $output = '
' . t('Your server\'s time is @utc. In most cases this should match Greenwich Mean Time (GMT) / Coordinated Universal Time (UTC)', $t_options) . '
' - . '' . t('The website default timezone is @date_default_timezone (@date_default_code) which is offset from GMT by @date_default_offset hours. This timezone can be changed by admin users with the appropriate access.', $t_options) . '
'; - - if (variable_get('configurable_timezones', 1)) { - $output .= '' . t('Your local time is @localtime (@daylight_saving). You can change this via your user account.', $t_options) . '
'; - if (!$account->getTimezone()) { - $output .= '' . t('Note: The user timezone has not been stored, so defaulting to the website timezone.') . '
'; - } - } - else { - $output .= '' . t('Your local time is @localtime (@daylight_saving). This is not configurable by you.', $t_options) . '
'; - } - - return $output; -} - -/** * Page callback: Displays a list of nodes scheduled for (un)publication. * * This will appear as a tab on the content admin page ('admin/content'). It is diff --git a/scheduler.install b/scheduler.install index ec01632..25e9422 100644 --- a/scheduler.install +++ b/scheduler.install @@ -6,6 +6,65 @@ */ /** + * Implements hook_requirements(). + */ +function scheduler_requirements($phase) { + $requirements = array(); + + // Report server internal clock. + if ($phase === 'runtime') { + $user = \Drupal::currentUser(); + + $now = REQUEST_TIME; + $system_date = \Drupal::config('system.date'); + $date_default_timezone = $system_date->get('timezone.default') ?: date_default_timezone_get(); + $date_formatter = \Drupal::service('date.formatter'); + + $t_options = array( + // For %utc specify 'GMT' as the timezone (4th parameter) so that no + // timezone offset is returned. + '%utc' => $date_formatter->format($now, 'custom', 'jS F Y, H:i:s P', 'GMT'), + // For %localtime do not specify any timezone parameter so that the user or + // site default setting is returned. + '%localtime' => $date_formatter->format($now, 'custom', 'jS F Y, H:i:s P T e'), + '%daylight_saving' => $date_formatter->format($now, 'custom', 'I') ? t('currently in daylight saving mode') : t('not in daylight saving mode'), + '%date_default_timezone' => $date_default_timezone, + '%date_default_offset' => $date_formatter->format($now, 'custom', 'P', $date_default_timezone), + '%date_default_code' => $date_formatter->format($now, 'custom', 'T', $date_default_timezone), + '!account_edit' => \Drupal::url('entity.user.edit_form', ['user' => $user->id()]), + '!admin_regional_settings' => \Drupal::url('system.regional_settings'), + '!link_gmt' => 'https://www.google.com/search?q=Greenwich%20Mean%20Time', + ); + + $description = ''; + $description .= t('Your server\'s time is %utc. In most cases this should match Greenwich Mean Time (GMT) / Coordinated Universal Time (UTC)', $t_options); + $description .= '