upgrades core to 8.4.2
This commit is contained in:
@@ -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();
|
||||
@@ -1355,10 +1363,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 +1384,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user