Parcourir la source

[up] Token 7.x-1.7

opi il y a 8 ans
Parent
commit
26c540c0f3

+ 3 - 3
sites/all/modules/token/tests/token_test.info

@@ -5,9 +5,9 @@ core = 7.x
 files[] = token_test.module
 files[] = token_test.module
 hidden = TRUE
 hidden = TRUE
 
 
-; Information added by Drupal.org packaging script on 2015-02-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2017-01-25
+version = "7.x-1.7"
 core = "7.x"
 core = "7.x"
 project = "token"
 project = "token"
-datestamp = "1425149060"
+datestamp = "1485316088"
 
 

+ 3 - 3
sites/all/modules/token/token.info

@@ -3,9 +3,9 @@ description = Provides a user interface for the Token API and some missing core
 core = 7.x
 core = 7.x
 files[] = token.test
 files[] = token.test
 
 
-; Information added by Drupal.org packaging script on 2015-02-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2017-01-25
+version = "7.x-1.7"
 core = "7.x"
 core = "7.x"
 project = "token"
 project = "token"
-datestamp = "1425149060"
+datestamp = "1485316088"
 
 

+ 21 - 19
sites/all/modules/token/token.install

@@ -21,18 +21,12 @@ function token_requirements($phase = 'runtime') {
         $problems = array_unique($problem['problems']);
         $problems = array_unique($problem['problems']);
         $problems = array_map('check_plain', $problems);
         $problems = array_map('check_plain', $problems);
         $token_problems[$problem_key] = $problem['label'] . theme('item_list', array('items' => $problems));
         $token_problems[$problem_key] = $problem['label'] . theme('item_list', array('items' => $problems));
+        $requirements['token-' . $problem_key] = array(
+          'title' => $problem['label'],
+          'value' => theme('item_list', array('items' => $problems)),
+          'severity' => $problem['severity'],
+        );
       }
       }
-      else {
-        unset($token_problems[$problem_key]);
-      }
-    }
-    if (!empty($token_problems)) {
-      $requirements['token_problems'] = array(
-        'title' => $t('Tokens'),
-        'value' => $t('Problems detected'),
-        'severity' => REQUIREMENT_WARNING,
-        'description' => '<p>' . implode('</p><p>', $token_problems) . '</p>', //theme('item_list', array('items' => $token_problems)),
-      );
     }
     }
   }
   }
 
 
@@ -272,19 +266,24 @@ function token_get_token_problems() {
   $token_info = token_info();
   $token_info = token_info();
   $token_problems = array(
   $token_problems = array(
     'not-array' => array(
     'not-array' => array(
-      'label' => t('The following tokens or token types are not defined as arrays:'),
+      'label' => t('Tokens or token types not defined as arrays'),
+      'severity' => REQUIREMENT_ERROR,
     ),
     ),
     'missing-info' => array(
     'missing-info' => array(
-      'label' => t('The following tokens or token types are missing required name and/or description information:'),
+      'label' => t('Tokens or token types missing name property'),
+      'severity' => REQUIREMENT_WARNING,
     ),
     ),
     'type-no-tokens' => array(
     'type-no-tokens' => array(
-      'label' => t('The following token types do not have any tokens defined:'),
+      'label' => t('Token types do not have any tokens defined'),
+      'severity' => REQUIREMENT_INFO,
     ),
     ),
     'tokens-no-type' => array(
     'tokens-no-type' => array(
-      'label' => t('The following token types are not defined but have tokens:'),
+      'label' => t('Token types are not defined but have tokens'),
+      'severity' => REQUIREMENT_INFO,
     ),
     ),
     'duplicate' => array(
     'duplicate' => array(
-      'label' => t('The following token or token types are defined by multiple modules:')
+      'label' => t('Token or token types are defined by multiple modules'),
+      'severity' => REQUIREMENT_ERROR,
     ),
     ),
   );
   );
 
 
@@ -295,9 +294,12 @@ function token_get_token_problems() {
       $token_problems['not-array']['problems'][] = "\$info['types']['$type']";
       $token_problems['not-array']['problems'][] = "\$info['types']['$type']";
       continue;
       continue;
     }
     }
-    elseif (!isset($type_info['name']) || !isset($type_info['description'])) {
+    elseif (!isset($type_info['name'])) {
       $token_problems['missing-info']['problems'][] = "\$info['types']['$type']";
       $token_problems['missing-info']['problems'][] = "\$info['types']['$type']";
     }
     }
+    elseif (is_array($type_info['name'])) {
+      $token_problems['duplicate']['problems'][] = "\$info['types']['$type']";
+    }
     elseif (empty($token_info['tokens'][$real_type])) {
     elseif (empty($token_info['tokens'][$real_type])) {
       $token_problems['type-no-tokens']['problems'][] = "\$info['tokens']['$real_type']";
       $token_problems['type-no-tokens']['problems'][] = "\$info['tokens']['$real_type']";
     }
     }
@@ -315,10 +317,10 @@ function token_get_token_problems() {
           $token_problems['not-array']['problems'][] = "\$info['tokens']['$type']['$token']";
           $token_problems['not-array']['problems'][] = "\$info['tokens']['$type']['$token']";
           continue;
           continue;
         }
         }
-        elseif (!isset($tokens[$token]['name']) || !isset($tokens[$token]['description'])) {
+        elseif (!isset($tokens[$token]['name'])) {
           $token_problems['missing-info']['problems'][] = "\$info['tokens']['$type']['$token']";
           $token_problems['missing-info']['problems'][] = "\$info['tokens']['$type']['$token']";
         }
         }
-        elseif (is_array($tokens[$token]['name']) || is_array($tokens[$token]['description'])) {
+        elseif (is_array($tokens[$token]['name'])) {
           $token_problems['duplicate']['problems'][] = "\$info['tokens']['$type']['$token']";
           $token_problems['duplicate']['problems'][] = "\$info['tokens']['$type']['$token']";
         }
         }
       }
       }

+ 9 - 7
sites/all/modules/token/token.module

@@ -274,7 +274,11 @@ function token_form_block_admin_configure_alter(&$form, $form_state) {
  */
  */
 function token_field_widget_form_alter(&$element, &$form_state, $context) {
 function token_field_widget_form_alter(&$element, &$form_state, $context) {
   if (!empty($element['#description']) && !empty($context['instance']['description'])) {
   if (!empty($element['#description']) && !empty($context['instance']['description'])) {
-    $element['#description'] = filter_xss_admin(token_replace($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']));
   }
   }
 }
 }
 
 
@@ -719,15 +723,13 @@ function token_element_validate(&$element, &$form_state) {
 
 
   // Validate if an element must have a minimum number of tokens.
   // Validate if an element must have a minimum number of tokens.
   if (isset($element['#min_tokens']) && count($tokens) < $element['#min_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);
     form_error($element, $error);
   }
   }
 
 
   // Validate if an element must have a maximum number of tokens.
   // Validate if an element must have a maximum number of tokens.
   if (isset($element['#max_tokens']) && count($tokens) > $element['#max_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);
     form_error($element, $error);
   }
   }
 
 
@@ -735,7 +737,7 @@ function token_element_validate(&$element, &$form_state) {
   if (isset($element['#token_types'])) {
   if (isset($element['#token_types'])) {
     $invalid_tokens = token_get_invalid_tokens_by_context($tokens, $element['#token_types']);
     $invalid_tokens = token_get_invalid_tokens_by_context($tokens, $element['#token_types']);
     if ($invalid_tokens) {
     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))));
     }
     }
   }
   }
 
 
@@ -983,7 +985,7 @@ function _token_build_tree($token_type, array $options) {
       // parent.
       // parent.
       $token_parents[] = $token_type;
       $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
       // Prevent duplicate recursive tokens. For example, this will prevent
       // the tree from generating the following tokens or deeper:
       // the tree from generating the following tokens or deeper:
       // [comment:parent:parent]
       // [comment:parent:parent]

+ 2 - 1
sites/all/modules/token/token.pages.inc

@@ -199,7 +199,7 @@ function _token_token_tree_format_row($token, array $token_info, $is_group = FAL
   $row = $defaults;
   $row = $defaults;
   $row['id'] = _token_clean_css_identifier($token);
   $row['id'] = _token_clean_css_identifier($token);
   $row['data']['name'] = $token_info['name'];
   $row['data']['name'] = $token_info['name'];
-  $row['data']['description'] = $token_info['description'];
+  $row['data']['description'] = isset($token_info['description']) ? $token_info['description'] : '';
 
 
   if ($is_group) {
   if ($is_group) {
     // This is a token type/group.
     // This is a token type/group.
@@ -207,6 +207,7 @@ function _token_token_tree_format_row($token, array $token_info, $is_group = FAL
   }
   }
   else {
   else {
     // This is a token.
     // This is a token.
+    $row['data']['token'] = array();
     $row['data']['token']['data'] = $token;
     $row['data']['token']['data'] = $token;
     $row['data']['token']['class'][] = 'token-key';
     $row['data']['token']['class'][] = 'token-key';
     if (isset($token_info['value'])) {
     if (isset($token_info['value'])) {

+ 1 - 2
sites/all/modules/token/token.tokens.inc

@@ -1392,7 +1392,6 @@ function field_token_info_alter(&$info) {
  */
  */
 function field_tokens($type, $tokens, array $data = array(), array $options = array()) {
 function field_tokens($type, $tokens, array $data = array(), array $options = array()) {
   $replacements = array();
   $replacements = array();
-  $sanitize = !empty($options['sanitize']);
   $langcode = isset($options['language']) ? $options['language']->language : NULL;
   $langcode = isset($options['language']) ? $options['language']->language : NULL;
 
 
   // Entity tokens.
   // Entity tokens.
@@ -1437,7 +1436,7 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar
 /**
 /**
  * Pre-render callback for field output used with tokens.
  * Pre-render callback for field output used with tokens.
  */
  */
-function token_pre_render_field_token(&$elements) {
+function token_pre_render_field_token($elements) {
   // Remove the field theme hook, attachments, and JavaScript states.
   // Remove the field theme hook, attachments, and JavaScript states.
   unset($elements['#theme']);
   unset($elements['#theme']);
   unset($elements['#states']);
   unset($elements['#states']);