X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Fsystem.module;fp=web%2Fcore%2Fmodules%2Fsystem%2Fsystem.module;h=ef6e3d5d552bdfd4217a3495b99347e3689a5a5e;hp=a1a6b715a3a6a428f99703d4764218a27a2f6318;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/system/system.module b/web/core/modules/system/system.module index a1a6b715a..ef6e3d5d5 100644 --- a/web/core/modules/system/system.module +++ b/web/core/modules/system/system.module @@ -33,6 +33,8 @@ use GuzzleHttp\Exception\RequestException; * * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. * Use \Drupal\user\UserInterface::TIMEZONE_DEFAULT instead. + * + * @see https://www.drupal.org/node/2831620 */ const DRUPAL_USER_TIMEZONE_DEFAULT = 0; @@ -41,6 +43,8 @@ const DRUPAL_USER_TIMEZONE_DEFAULT = 0; * * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. * Use \Drupal\user\UserInterface::TIMEZONE_EMPTY instead. + * + * @see https://www.drupal.org/node/2831620 */ const DRUPAL_USER_TIMEZONE_EMPTY = 1; @@ -49,6 +53,8 @@ const DRUPAL_USER_TIMEZONE_EMPTY = 1; * * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. * Use \Drupal\user\UserInterface::TIMEZONE_SELECT instead. + * + * @see https://www.drupal.org/node/2831620 */ const DRUPAL_USER_TIMEZONE_SELECT = 2; @@ -74,6 +80,7 @@ const DRUPAL_REQUIRED = 2; * Use \Drupal\block\BlockRepositoryInterface::REGIONS_VISIBLE instead. * * @see system_region_list() + * @see https://www.drupal.org/node/2831620 */ const REGIONS_VISIBLE = 'visible'; @@ -84,6 +91,7 @@ const REGIONS_VISIBLE = 'visible'; * Use \Drupal\block\BlockRepositoryInterface::REGIONS_ALL instead. * * @see system_region_list() + * @see https://www.drupal.org/node/2831620 */ const REGIONS_ALL = 'all'; @@ -603,7 +611,7 @@ function system_page_attachments(array &$page) { } // Get the major Drupal version. - list($version, ) = explode('.', \Drupal::VERSION); + list($version,) = explode('.', \Drupal::VERSION); // Attach default meta tags. $meta_default = [ @@ -845,7 +853,7 @@ function system_user_timezone(&$form, FormStateInterface $form_state) { '#type' => 'select', '#title' => t('Time zone'), '#default_value' => $account->getTimezone() ? $account->getTimezone() : \Drupal::config('system.date')->get('timezone.default'), - '#options' => system_time_zones($account->id() != $user->id()), + '#options' => system_time_zones($account->id() != $user->id(), TRUE), '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'), ]; $user_input = $form_state->getUserInput(); @@ -1056,7 +1064,6 @@ function _system_rebuild_module_data() { _system_rebuild_module_data_ensure_required($module, $modules); } - if ($profile && isset($modules[$profile])) { // The installation profile is required, if it's a valid module. $modules[$profile]->info['required'] = TRUE; @@ -1355,10 +1362,15 @@ function system_mail($key, &$message, $params) { /** * Generate an array of time zones and their local time&date. * - * @param $blank + * @param mixed $blank * If evaluates true, prepend an empty time zone option to the array. + * @param bool $grouped + * (optional) Whether the timezones should be grouped by region. + * + * @return array + * An array or nested array containing time zones, keyed by the system name. */ -function system_time_zones($blank = NULL) { +function system_time_zones($blank = NULL, $grouped = FALSE) { $zonelist = timezone_identifiers_list(); $zones = $blank ? ['' => t('- None selected -')] : []; foreach ($zonelist as $zone) { @@ -1371,6 +1383,27 @@ function system_time_zones($blank = NULL) { } // Sort the translated time zones alphabetically. asort($zones); + if ($grouped) { + $grouped_zones = []; + foreach ($zones as $key => $value) { + $split = explode('/', $value); + $city = array_pop($split); + $region = array_shift($split); + if (!empty($region)) { + $grouped_zones[$region][$key] = empty($split) ? $city : $city . ' (' . implode('/', $split) . ')'; + } + else { + $grouped_zones[$key] = $value; + } + } + foreach ($grouped_zones as $key => $value) { + if (is_array($grouped_zones[$key])) { + asort($grouped_zones[$key]); + } + } + $zones = $grouped_zones; + } + return $zones; }