added some modules, updated some others

This commit is contained in:
2021-11-25 16:58:25 +01:00
parent 62fc3df712
commit 072ea7de50
28 changed files with 2459 additions and 49 deletions
@@ -161,6 +161,8 @@ function token_theme() {
'attributes' => array(),
'empty' => '',
'caption' => '',
'colgroups' => array(),
'sticky' => TRUE,
),
'file' => 'token.pages.inc',
);
@@ -180,7 +182,7 @@ function token_theme() {
'text' => NULL,
'options' => array(),
'dialog' => TRUE,
),
) + $info['token_tree']['variables'],
'file' => 'token.pages.inc',
);
@@ -273,8 +275,12 @@ function token_form_block_admin_configure_alter(&$form, $form_state) {
* Implements hook_widget_form_alter().
*/
function token_field_widget_form_alter(&$element, &$form_state, $context) {
if (!empty($element['#description']) && is_string($element['#description'])) {
$element['#description'] = filter_xss_admin(token_replace($element['#description']));
if (!empty($element['#description']) && !empty($context['instance']['description'])) {
$instance = $context['instance'];
if (module_exists('i18n_field')) {
$instance = i18n_string_object_translate('field_instance', $instance);
}
$element['#description'] = field_filter_xss(token_replace($instance['description']));
}
}
@@ -412,12 +418,18 @@ function token_get_entity_mapping($value_type = 'token', $value = NULL, $fallbac
*/
function token_entity_info_alter(&$info) {
foreach (array_keys($info) as $entity_type) {
// Add a token view mode if it does not already exist.
if (!empty($info[$entity_type]['view modes']) && !isset($info[$entity_type]['view modes']['token'])) {
$info[$entity_type]['view modes']['token'] = array(
'label' => t('Tokens'),
'custom settings' => FALSE,
);
// Add a token view mode if it does not already exist. Only work with
// fieldable entities.
if (!empty($info[$entity_type]['fieldable'])) {
if (!isset($info[$entity_type])) {
$info[$entity_type]['view modes'] = array();
}
if (!isset($info[$entity_type]['view modes']['token'])) {
$info[$entity_type]['view modes']['token'] = array(
'label' => t('Tokens'),
'custom settings' => FALSE,
);
}
}
if (!empty($info[$entity_type]['token type'])) {
@@ -647,6 +659,10 @@ function token_get_invalid_tokens($type, $tokens) {
$invalid_tokens = array();
foreach ($tokens as $token => $full_token) {
if (isset($token_info['tokens'][$type][$token])) {
continue;
}
// Split token up if it has chains.
$parts = explode(':', $token, 2);
@@ -709,15 +725,13 @@ function token_element_validate(&$element, &$form_state) {
// Validate if an element must have a minimum number of tokens.
if (isset($element['#min_tokens']) && count($tokens) < $element['#min_tokens']) {
// @todo Change this error message to include the minimum number.
$error = format_plural($element['#min_tokens'], 'The %element-title cannot contain fewer than one token.', 'The %element-title must contain at least @count tokens.', array('%element-title' => $title));
$error = format_plural($element['#min_tokens'], '%name must contain at least one token.', '%name must contain at least @count tokens.', array('%name' => $title));
form_error($element, $error);
}
// Validate if an element must have a maximum number of tokens.
if (isset($element['#max_tokens']) && count($tokens) > $element['#max_tokens']) {
// @todo Change this error message to include the maximum number.
$error = format_plural($element['#max_tokens'], 'The %element-title must contain as most one token.', 'The %element-title must contain at most @count tokens.', array('%element-title' => $title));
$error = format_plural($element['#max_tokens'], '%name must contain at most one token.', '%name must contain at most @count tokens.', array('%name' => $title));
form_error($element, $error);
}
@@ -725,7 +739,7 @@ function token_element_validate(&$element, &$form_state) {
if (isset($element['#token_types'])) {
$invalid_tokens = token_get_invalid_tokens_by_context($tokens, $element['#token_types']);
if ($invalid_tokens) {
form_error($element, t('The %element-title is using the following invalid tokens: @invalid-tokens.', array('%element-title' => $title, '@invalid-tokens' => implode(', ', $invalid_tokens))));
form_error($element, t('%name is using the following invalid tokens: @invalid-tokens.', array('%name' => $title, '@invalid-tokens' => implode(', ', $invalid_tokens))));
}
}
@@ -973,7 +987,7 @@ function _token_build_tree($token_type, array $options) {
// parent.
$token_parents[] = $token_type;
}
elseif (in_array($token, array_slice($token_parents, 1))) {
elseif (in_array($token, array_slice($token_parents, 1), TRUE)) {
// Prevent duplicate recursive tokens. For example, this will prevent
// the tree from generating the following tokens or deeper:
// [comment:parent:parent]
@@ -1216,7 +1230,7 @@ function token_menu_link_load_all_parents($mlid) {
if (!isset($cache[$mlid])) {
$cache[$mlid] = array();
$plid = db_query("SELECT plid FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchField();
while ($plid && $parent = token_menu_link_load($plid)) {
while ($plid && $plid != $mlid && $parent = token_menu_link_load($plid)) {
$cache[$mlid] = array($plid => $parent['title']) + $cache[$mlid];
$plid = $parent['plid'];
}