Browse Source

updated contrib modules

Bachir Soussi Chiadmi 2 months ago
parent
commit
438237e852
100 changed files with 5021 additions and 2526 deletions
  1. 21 5
      sites/all/modules/context/context.core.inc
  2. 3 4
      sites/all/modules/context/context.info
  3. 1 1
      sites/all/modules/context/context.install
  4. 60 5
      sites/all/modules/context/context.module
  5. 2 2
      sites/all/modules/context/context.plugins.inc
  6. 3 4
      sites/all/modules/context/context_layouts/context_layouts.info
  7. 3 4
      sites/all/modules/context/context_ui/context_ui.info
  8. 2 2
      sites/all/modules/context/context_ui/context_ui.js
  9. 8 12
      sites/all/modules/context/context_ui/context_ui.module
  10. 2 2
      sites/all/modules/context/context_ui/context_ui_dialog.js
  11. 11 11
      sites/all/modules/context/context_ui/export_ui/context_export_ui.class.php
  12. 1 1
      sites/all/modules/context/context_ui/tests/context_ui.test
  13. 1 1
      sites/all/modules/context/plugins/context_condition_bookroot.inc
  14. 1 1
      sites/all/modules/context/plugins/context_condition_menu.inc
  15. 9 5
      sites/all/modules/context/plugins/context_condition_node_taxonomy.inc
  16. 1 1
      sites/all/modules/context/plugins/context_condition_query_string.inc
  17. 11 10
      sites/all/modules/context/plugins/context_reaction_block.inc
  18. 5 6
      sites/all/modules/context/plugins/context_reaction_block.js
  19. 1 0
      sites/all/modules/context/plugins/context_reaction_breadcrumb.inc
  20. 3 1
      sites/all/modules/context/plugins/context_reaction_menu.inc
  21. 5 1
      sites/all/modules/context/plugins/context_reaction_region.inc
  22. 1 1
      sites/all/modules/context/plugins/context_reaction_template_suggestions.inc
  23. 0 22
      sites/all/modules/context/tests/context.conditions.test
  24. 3 4
      sites/all/modules/context/theme/context_reaction_block.theme.inc
  25. 101 0
      sites/all/modules/link/README.txt
  26. 7 0
      sites/all/modules/link/link-rtl.css
  27. 2 3
      sites/all/modules/link/link.css
  28. 32 0
      sites/all/modules/link/link.devel_generate.inc
  29. 22 0
      sites/all/modules/link/link.diff.inc
  30. 6 6
      sites/all/modules/link/link.info
  31. 54 28
      sites/all/modules/link/link.install
  32. 139 0
      sites/all/modules/link/link.migrate.inc
  33. 947 301
      sites/all/modules/link/link.module
  34. 269 461
      sites/all/modules/link/tests/link.attribute.test
  35. 31 24
      sites/all/modules/link/tests/link.crud.test
  36. 309 159
      sites/all/modules/link/tests/link.crud_browser.test
  37. 164 0
      sites/all/modules/link/tests/link.entity_token.test
  38. 25 16
      sites/all/modules/link/tests/link.test
  39. 207 110
      sites/all/modules/link/tests/link.token.test
  40. 376 163
      sites/all/modules/link/tests/link.validate.test
  41. 3 0
      sites/all/modules/link/views/link.views.inc
  42. 16 9
      sites/all/modules/link/views/link_views_handler_argument_target.inc
  43. 55 16
      sites/all/modules/link/views/link_views_handler_filter_protocol.inc
  44. 49 62
      sites/all/modules/module_filter/CHANGELOG.txt
  45. 2 2
      sites/all/modules/module_filter/README.txt
  46. 0 2
      sites/all/modules/module_filter/css/dynamic_position.css
  47. 6 0
      sites/all/modules/module_filter/css/module_filter.css
  48. 15 4
      sites/all/modules/module_filter/css/module_filter_tab.css
  49. 53 0
      sites/all/modules/module_filter/css/modules.css
  50. BIN
      sites/all/modules/module_filter/images/collapsed.png
  51. BIN
      sites/all/modules/module_filter/images/expanded.png
  52. 19 27
      sites/all/modules/module_filter/js/dynamic_position.js
  53. 7 6
      sites/all/modules/module_filter/js/module_filter.js
  54. 151 25
      sites/all/modules/module_filter/js/module_filter_tab.js
  55. 11 0
      sites/all/modules/module_filter/js/modules.js
  56. 27 9
      sites/all/modules/module_filter/module_filter.admin.inc
  57. 3 5
      sites/all/modules/module_filter/module_filter.info
  58. 6 1
      sites/all/modules/module_filter/module_filter.install
  59. 73 28
      sites/all/modules/module_filter/module_filter.module
  60. 12 5
      sites/all/modules/module_filter/module_filter.pages.inc
  61. 64 74
      sites/all/modules/module_filter/module_filter.theme.inc
  62. 13 0
      sites/all/modules/uuid/composer.json
  63. 3 3
      sites/all/modules/uuid/uuid.info
  64. 16 17
      sites/all/modules/uuid/uuid.test
  65. 3 3
      sites/all/modules/uuid/uuid_path/uuid_path.info
  66. 5 3
      sites/all/modules/uuid/uuid_services/uuid_services.info
  67. 8 1
      sites/all/modules/uuid/uuid_services/uuid_services.module
  68. 231 0
      sites/all/modules/uuid/uuid_services/uuid_services.user_services.test
  69. 3 3
      sites/all/modules/uuid/uuid_services_example/uuid_services_example.info
  70. 1 1
      sites/all/modules/views/css/ie/views-admin.ie7.css
  71. 1 1
      sites/all/modules/views/css/views-admin.bartik-rtl.css
  72. 70 73
      sites/all/modules/views/css/views-admin.bartik.css
  73. 7 9
      sites/all/modules/views/css/views-admin.css
  74. 1 1
      sites/all/modules/views/css/views-admin.ctools-rtl.css
  75. 9 9
      sites/all/modules/views/css/views-admin.ctools.css
  76. 2 2
      sites/all/modules/views/css/views-admin.garland-rtl.css
  77. 70 73
      sites/all/modules/views/css/views-admin.garland.css
  78. 80 83
      sites/all/modules/views/css/views-admin.seven.css
  79. 55 56
      sites/all/modules/views/css/views-admin.theme.css
  80. 0 1
      sites/all/modules/views/css/views-rtl.css
  81. 83 66
      sites/all/modules/views/drush/views.drush.inc
  82. 58 26
      sites/all/modules/views/handlers/views_handler_area.inc
  83. 1 1
      sites/all/modules/views/handlers/views_handler_area_messages.inc
  84. 22 7
      sites/all/modules/views/handlers/views_handler_area_result.inc
  85. 37 12
      sites/all/modules/views/handlers/views_handler_area_text.inc
  86. 25 7
      sites/all/modules/views/handlers/views_handler_area_text_custom.inc
  87. 8 6
      sites/all/modules/views/handlers/views_handler_area_view.inc
  88. 279 156
      sites/all/modules/views/handlers/views_handler_argument.inc
  89. 35 18
      sites/all/modules/views/handlers/views_handler_argument_date.inc
  90. 16 7
      sites/all/modules/views/handlers/views_handler_argument_formula.inc
  91. 15 4
      sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc
  92. 41 15
      sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc
  93. 15 6
      sites/all/modules/views/handlers/views_handler_argument_null.inc
  94. 29 10
      sites/all/modules/views/handlers/views_handler_argument_numeric.inc
  95. 49 22
      sites/all/modules/views/handlers/views_handler_argument_string.inc
  96. 249 149
      sites/all/modules/views/handlers/views_handler_field.inc
  97. 26 12
      sites/all/modules/views/handlers/views_handler_field_boolean.inc
  98. 11 3
      sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
  99. 23 8
      sites/all/modules/views/handlers/views_handler_field_counter.inc
  100. 0 0
      sites/all/modules/views/handlers/views_handler_field_ctools_dropdown.inc

+ 21 - 5
sites/all/modules/context/context.core.inc

@@ -94,11 +94,27 @@ function context_theme_registry_alter(&$theme_registry) {
  */
 function context_ctools_render_alter($info, $page, $data) {
   extract($data);
-  if ($page && in_array($task['name'], array('node_view', 'node_edit'), TRUE)) {
-    foreach ($contexts as $ctools_context) {
-      if (in_array('node', $ctools_context->type) && !empty($ctools_context->data)) {
-        context_node_condition($ctools_context->data, $task['name'] === 'node_view' ? 'view' : 'form');
-        break;
+
+  // Check for page handlers.
+  if ($page) {
+    // Check for node page handler.
+    if (in_array($task['name'], array('node_view', 'node_edit'), TRUE)) {
+      foreach ($contexts as $ctools_context) {
+        if (in_array('node', $ctools_context->type) && !empty($ctools_context->data)) {
+          context_node_condition($ctools_context->data, $task['name'] === 'node_view' ? 'view' : 'form');
+          break;
+        }
+      }
+    }
+    // Check for taxonomy term page handler.
+    elseif (in_array($task['name'], array('term_view', 'term_edit'), TRUE)) {
+      foreach ($contexts as $ctools_context) {
+        if (in_array('taxonomy_term', $ctools_context->type) && !empty($ctools_context->data)) {
+          if ($plugin = context_get_plugin('condition', 'taxonomy_term')) {
+            $plugin->execute($ctools_context->data, $task['name'] === 'term_view' ? 'view' : 'form');
+          }
+          break;
+        }
       }
     }
   }

+ 3 - 4
sites/all/modules/context/context.info

@@ -8,9 +8,8 @@ files[] = tests/context.test
 files[] = tests/context.conditions.test
 files[] = tests/context.reactions.test
 
-; Information added by Drupal.org packaging script on 2015-01-06
-version = "7.x-3.6"
+; Information added by Drupal.org packaging script on 2019-02-26
+version = "7.x-3.10"
 core = "7.x"
 project = "context"
-datestamp = "1420573188"
-
+datestamp = "1551220089"

+ 1 - 1
sites/all/modules/context/context.install

@@ -103,7 +103,7 @@ function context_update_7000() {
     }
   }
   if (empty($updated)) {
-    $ret = t('No contexts requiring migration detected');
+    $ret = t('No contexts requiring migration detected.');
   }
   else {
     $ret = t('The following contexts had theme reaction data migrated: @names', array('@names' => join(', ', $updated)));

+ 60 - 5
sites/all/modules/context/context.module

@@ -192,11 +192,66 @@ function context_init() {
  * theme('menu_link') for the menu rendering to html.
  */
 function context_preprocess_menu_link(&$variables) {
-  if($contexts = context_active_contexts()){
-    foreach($contexts as $context){
-      if((isset($context->reactions['menu']))){
-        if ($variables['element']['#href'] == $context->reactions['menu']) {
-          $variables['element']['#localized_options']['attributes']['class'][] = "active";
+  if ($contexts = context_active_contexts()) {
+    foreach ($contexts as $context) {
+      if (isset($context->reactions['menu'])) {
+        // In context module < v3.2 the url was a string. In version 3.3+ this is
+        // an array of urls. Implement interims BC layer.
+        //
+        // Examples:
+        // - OLD < v3.2 context reaction structure:
+        // array('menu' => 'taxonomy/term/1')
+        //
+        // - NEW 3.3+ context reaction structure:
+        // array(
+        //   'menu' => array(
+        //     0 => 'navigation:taxonomy/term/1'
+        //     1 => 'foo-menu:taxonomy/term/1'
+        //   )
+        // )
+        $reactions_menu = is_array($context->reactions['menu']) ? array_values($context->reactions['menu']) : array($context->reactions['menu']);
+
+        // Get everything after the first ':' character (if found) as the url to
+        // match against element '#href'.
+        $urls = array();
+        foreach ($reactions_menu as $url) {
+          if (strpos($url, ':') !== FALSE) {
+            // Get unique menu name 'navigation' from 'navigation:taxonomy/term/1'
+            $reaction_menu = explode(':', $url);
+            $path = $reaction_menu[1];
+            $urls[$path] = $reaction_menu[0];
+          }
+          else {
+            // BC layer for menu contexts that have not re-saved. This is for
+            // urls like 'taxonomy/term/1'. We need to add a fake menu key
+            // 'bc-context-menu-layer' or the BC link get's removed by
+            // array_intersect below.
+            //
+            // @TODO: Remove BC layer in 4.x
+            $urls[$url] = 'context-reaction-menu-bc-layer';
+          }
+        }
+
+        // Filter urls by the menu name of the current link. The link reaction
+        // can be configured per menu link in specific menus and the contect
+        // reaction should not applied to other menus with the same menu link.
+        $menu_name = $variables['element']['#original_link']['menu_name'];
+        $menu_paths = array_intersect($urls, array($menu_name, 'context-reaction-menu-bc-layer'));
+        $reaction_menu_paths = array_keys($menu_paths);
+
+        // - If menu href and context reaction menu url match, add the 'active'
+        //   css class to the link of this menu.
+        // - Do not add class twice on current page.
+        if (in_array($variables['element']['#href'], $reaction_menu_paths) && $variables['element']['#href'] != $_GET['q']) {
+          // Initialize classes array if not set.
+          if (!isset($variables['element']['#localized_options']['attributes']['class'])) {
+            $variables['element']['#localized_options']['attributes']['class'] = array();
+          }
+
+          // Do not add the 'active' class twice in views tabs.
+          if (!in_array('active', $variables['element']['#localized_options']['attributes']['class'])) {
+            $variables['element']['#localized_options']['attributes']['class'][] = 'active';
+          }
         }
       }
     }

+ 2 - 2
sites/all/modules/context/context.plugins.inc

@@ -37,7 +37,7 @@ function _context_context_registry() {
       'plugin' => 'context_condition_path',
     ),
     'query_string' => array(
-      'title' => t('Query String'),
+      'title' => t('Query string'),
       'description' => t('Set this context when any of the query strings above match the page query string. Put each query string on a separate line. You can use the "*" character as a wildcard and <code>~</code> to exclude one or more query strings.'),
       'plugin' => 'context_condition_query_string',
     ),
@@ -119,7 +119,7 @@ function _context_context_registry() {
       'plugin' => 'context_reaction_template_suggestions',
     ),
     'theme' => array(
-      'title' => t('Theme Page'),
+      'title' => t('Theme page'),
       'description' => t('Control page theme variables using context.'),
       'plugin' => 'context_reaction_theme',
     ),

+ 3 - 4
sites/all/modules/context/context_layouts/context_layouts.info

@@ -6,9 +6,8 @@ core = 7.x
 
 files[] = plugins/context_layouts_reaction_block.inc
 
-; Information added by Drupal.org packaging script on 2015-01-06
-version = "7.x-3.6"
+; Information added by Drupal.org packaging script on 2019-02-26
+version = "7.x-3.10"
 core = "7.x"
 project = "context"
-datestamp = "1420573188"
-
+datestamp = "1551220089"

+ 3 - 4
sites/all/modules/context/context_ui/context_ui.info

@@ -8,9 +8,8 @@ configure = admin/structure/context
 files[] = context.module
 files[] = tests/context_ui.test
 
-; Information added by Drupal.org packaging script on 2015-01-06
-version = "7.x-3.6"
+; Information added by Drupal.org packaging script on 2019-02-26
+version = "7.x-3.10"
 core = "7.x"
 project = "context"
-datestamp = "1420573188"
-
+datestamp = "1551220089"

+ 2 - 2
sites/all/modules/context/context_ui/context_ui.js

@@ -12,11 +12,11 @@ function DrupalContextPlugins(form) {
     $('.context-plugin-list > li', this.form).each(function() {
       var plugin = $(this).attr('class').split('context-plugin-')[1].split(' ')[0];
       if ($(this).is('.disabled')) {
-        $('.context-plugin-selector select option[value='+plugin+']', this.form).show();
+        $('.context-plugin-selector select option[value="'+plugin+'"]', this.form).show();
       }
       else {
         state.push(plugin);
-        $('.context-plugin-selector select option[value='+plugin+']', this.form).hide();
+        $('.context-plugin-selector select option[value="'+plugin+'"]', this.form).hide();
       }
     });
     // Set the hidden plugin list state.

+ 8 - 12
sites/all/modules/context/context_ui/context_ui.module

@@ -81,7 +81,7 @@ function context_ui_permission() {
     'description' => 'Associate menus, views, blocks, etc. with different contexts to structure your site.'
   );
   $permissions['context ajax block access'] = array(
-    'title' => t('Access All Blocks'),
+    'title' => t('Access all blocks'),
     'description' => t('Allows users to access all rendered blocks via an AJAX callback. If you have some blocks that should not be rendered for some users but need those users to be able to use context UI, then implement hook_context_allow_ajax_block_access with the necessary logic.'),
   );
   return $permissions;
@@ -143,7 +143,7 @@ function context_ui_editor($form, &$form_state, $contexts) {
 
   $form['title'] = array(
     '#prefix' => '<h2 class="context-editor-title">',
-    '#markup' => t('Select the Context/Layer to Edit'),
+    '#markup' => t('Select the context/layer to edit'),
     '#suffix' => '</h2>',
     '#weight' => -2,
   );
@@ -151,10 +151,7 @@ function context_ui_editor($form, &$form_state, $contexts) {
   //add some help text to the top of the form
   $form['help'] = array (
     '#prefix' => '<p class="context-help help">',
-    '#markup' => t('Select which context, or layer of blocks, to edit.
-                    Each context is configured to appear on different sets of pages so read the description carefully.
-                    When you are done editing click Done and save your changes.
-                    You may use the Stop Editing Layout link to close the editor.'),
+    '#markup' => t('Select which context, or layer of blocks, to edit. Each context is configured to appear on different sets of pages so read the description carefully. When you are done editing click Done and save your changes. You may use the Stop Editing Layout link to close the editor.'),
     '#suffix' => '</p>',
     '#weight' => -1,
   );
@@ -166,10 +163,9 @@ function context_ui_editor($form, &$form_state, $contexts) {
     $edit = l(t('Edit'), $_GET['q'], array('fragment' => $context->name, 'attributes' => array('class' => array('edit'))));
     $done = l(t('Done'), $_GET['q'], array('fragment' => $context->name, 'attributes' => array('class' => array('done'))));
     $readable_name = ucwords(str_replace('_', ' ', $context->name));
-    $description = empty($context->description) ? '' :
-                        "<br/><div class='label bottom'>".check_plain($context->description)."</div>";
+    $description = empty($context->description) ? '' : '<br/><div class="label bottom">' . check_plain($context->description) . '</div>';
     $items[] = array(
-      'data' => "<div class='label top'>" . $readable_name. "</div><div class='links'>{$edit} {$done}</div>" . $description,
+      'data' => '<div class="label top">' . $readable_name. "</div><div class='links'>{$edit} {$done}</div>" . $description,
       'class' => array('context-editable clearfix'),
       'id' => "context-editable-trigger-{$context->name}",
     );
@@ -306,9 +302,9 @@ function context_ui_settings($form, &$form_state) {
   }
   $form['context_ui_dialog_enabled'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Use Context Editor Dialog'),
+    '#title' => t('Use context editor dialog'),
     '#default_value' => context_ui_dialog_is_enabled(),
-    '#description' => t('When enabled all contextual links will have a Edit Layout link that will refresh the page with the context editor in a dialog box.'),
+    '#description' => t('When enabled all contextual links will have a <em>Edit layout</em> link that will refresh the page with the context editor in a dialog box.'),
   );
   $form = system_settings_form($form);
   $form['#submit'][] = 'context_ui_settings_submit';
@@ -374,7 +370,7 @@ function context_ui_menu_contextual_links_alter(&$links, $router_item, $root_pat
      !context_isset('context_ui', 'context_ui_editor_present') && user_access('administer contexts')) {
     $links['layout'] = array(
       'href' => 'context-ui/activate',
-      'title' => t('Configure Layout'),
+      'title' => t('Configure layout'),
       'localized_options' => array(
         'query' =>  array('destination'=> $_GET['q']),
         'options' => array('html' => FALSE, 'attributes' => array()),

+ 2 - 2
sites/all/modules/context/context_ui/context_ui_dialog.js

@@ -9,11 +9,11 @@
         selector.detach();
         $('#page').prepend(selector);
 
-        var labelOpen = Drupal.t('Select Context');
+        var labelOpen = Drupal.t('Select context');
         var labelClose = Drupal.t('Hide');
 
         // Create a tab to show/hide our edit area
-        var tab = $('<a href="javascript:" class="context-ui-dialog-open" title="Show Context Selector">'+labelClose+'</a>');
+        var tab = $('<a href="javascript:" class="context-ui-dialog-open" title="' + Drupal.t('Show context selector') + '">'+labelClose+'</a>');
         selector.append(tab);
 
         selector.toggled = false;

+ 11 - 11
sites/all/modules/context/context_ui/export_ui/context_export_ui.class.php

@@ -22,7 +22,7 @@ class context_export_ui extends ctools_export_ui {
   function list_render(&$form_state) {
     $table = array(
       'header' => $this->list_table_header(),
-      'rows' => $this->rows, 
+      'rows' => $this->rows,
       'attributes' => array(
         'class' => array('context-admin'),
         'id' => 'ctools-export-ui-list-items',
@@ -104,17 +104,17 @@ class context_export_ui extends ctools_export_ui {
  * @param $form_state
  *   Form state array
  */
-function context_ui_form(&$form, &$form_state) {  
+function context_ui_form(&$form, &$form_state) {
   $conditions = array_keys(context_conditions());
   sort($conditions);
   $reactions = array_keys(context_reactions());
   sort($reactions);
-    
+
   $context = $form_state['item'];
   if (!empty($form_state['input'])) {
     $context = _context_ui_rebuild_from_input($context, $form_state['input'], $conditions, $reactions);
   }
-  
+
   $form['#base'] = 'context_ui_form';
   $form['#theme'] = 'context_ui_form';
 
@@ -131,7 +131,7 @@ function context_ui_form(&$form, &$form_state) {
     '#required' => FALSE,
     '#maxlength' => 255,
     '#default_value' => isset($context->tag) ? $context->tag : '',
-    '#description' => t('Example: <code>theme</code>') .'<br/>'. t('A tag to group this context with others.'),
+    '#description' => t('Example: <code>theme</code>') . '<br/>' . t('A tag to group this context with others.'),
   );
 
   $form['info']['description'] = array(
@@ -155,11 +155,11 @@ function context_ui_form(&$form, &$form_state) {
   $form['conditions'] = array(
     '#theme' => 'context_ui_plugins',
     '#title' => t('Conditions'),
-    '#description' => t('Trigger the activation of this context'),
+    '#description' => t('Trigger the activation of this context.'),
     '#tree' => TRUE,
     'selector' => array(
       '#type' => 'select',
-      '#options' => array(0 => '<'. t('Add a condition') .'>'),
+      '#options' => array(0 => '<' . t('Add a condition') . '>'),
       '#default_value' => 0,
     ),
     'state' => array(
@@ -185,11 +185,11 @@ function context_ui_form(&$form, &$form_state) {
   $form['reactions'] = array(
     '#theme' => 'context_ui_plugins',
     '#title' => t('Reactions'),
-    '#description' => t('Actions to take when this context is active'),
+    '#description' => t('Actions to take when this context is active.'),
     '#tree' => TRUE,
     'selector' => array(
       '#type' => 'select',
-      '#options' => array(0 => '<'. t('Add a reaction') .'>'),
+      '#options' => array(0 => '<' . t('Add a reaction') . '>'),
       '#default_value' => 0,
     ),
     'state' => array(
@@ -225,7 +225,7 @@ function context_ui_form(&$form, &$form_state) {
  *   A context object
  */
 function _context_ui_rebuild_from_input($context, $input, $conditions, $reactions) {
-  $condition_defaults = array();  
+  $condition_defaults = array();
   foreach ($conditions as $condition) {
     if ($plugin = context_get_plugin('condition', $condition)) {
       $condition_defaults[$condition] = array(
@@ -235,7 +235,7 @@ function _context_ui_rebuild_from_input($context, $input, $conditions, $reaction
     }
   }
   $input['conditions']['plugins'] = array_merge($condition_defaults, $input['conditions']['plugins']);
-  
+
   $reaction_defaults = array();
   foreach ($reactions as $reaction) {
     if ($plugin = context_get_plugin('reaction', $reaction)) {

+ 1 - 1
sites/all/modules/context/context_ui/tests/context_ui.test

@@ -48,7 +48,7 @@ class ContextUiTestCase extends DrupalWebTestCase {
       'description' => $context->description,
       'tag' => $context->tag,
       'conditions[plugins][node][values][blog]' => 'blog',
-      'reactions[plugins][menu]' => 'node/add/blog',
+      'reactions[plugins][menu][]' => 'navigation:node/add/blog',
     );
     $this->drupalPost('admin/structure/context/add', $edit, 'Save');
     $this->assertText($context->name . ' has been created.', 'Context saved.');

+ 1 - 1
sites/all/modules/context/plugins/context_condition_bookroot.inc

@@ -8,7 +8,7 @@ class context_condition_bookroot extends context_condition_node {
     if ($this->condition_used() && !empty($node->book['bid'])) {
       $type = db_select('node')
         ->fields('node', array('type'))
-        ->condition('nid', $node->book['nid'])
+        ->condition('nid', $node->book['bid'])
         ->execute()
         ->fetchField();
       $book = new stdClass();

+ 1 - 1
sites/all/modules/context/plugins/context_condition_menu.inc

@@ -14,7 +14,7 @@ class context_condition_menu extends context_condition {
       foreach ($menus as $key => $name) {
         $id = explode(':', $key);
         if ($id[1] == '0') {
-          $root_menus[$id[0]] = check_plain($name);
+          $root_menus[$id[0]] = $name;
         }
         else {
           $link = menu_link_load($id[1]);

+ 9 - 5
sites/all/modules/context/plugins/context_condition_node_taxonomy.inc

@@ -45,24 +45,28 @@ class context_condition_node_taxonomy extends context_condition_node {
     $check_fields = array();
     foreach ($instance_fields as $key => $field_info) {
       if ($fields[$key]['type'] == 'taxonomy_term_reference') {
-        $check_fields[] = $key;
+        $check_fields[$key] = 'tid';
+      }
+      else if ($fields[$key]['type'] == 'entityreference' &&
+               $fields[$key]['settings']['target_type'] == 'taxonomy_term') {
+        $check_fields[$key] = 'target_id';
       }
     }
 
     if ($this->condition_used() && !empty($check_fields)) {
-      foreach ($check_fields as $field) {
+      foreach ($check_fields as $field => $term_id_key) {
         if ($terms = field_get_items('node', $node, $field)) {
           foreach ($terms as $term) {
-            foreach ($this->get_contexts($term['tid']) as $context) {
+            foreach ($this->get_contexts($term[$term_id_key]) as $context) {
               // Check the node form option.
               if ($op === 'form') {
                 $options = $this->fetch_from_context($context, 'options');
                 if (!empty($options['node_form'])) {
-                  $this->condition_met($context, $term['tid']);
+                  $this->condition_met($context, $term[$term_id_key]);
                 }
               }
               else {
-                $this->condition_met($context, $term['tid']);
+                $this->condition_met($context, $term[$term_id_key]);
               }
             }
           }

+ 1 - 1
sites/all/modules/context/plugins/context_condition_query_string.inc

@@ -16,7 +16,7 @@ class context_condition_query_string extends context_condition_path {
    */
   function execute() {
     if ($this->condition_used()) {
-      $current_query_string = $_SERVER["QUERY_STRING"];
+      $current_query_string = empty($_SERVER["QUERY_STRING"]) ? '' : $_SERVER["QUERY_STRING"];
       foreach ($this->get_contexts() as $context) {
         $query_strings = $this->fetch_from_context($context, 'values');
         if ($this->match($current_query_string, $query_strings, TRUE)) {

+ 11 - 10
sites/all/modules/context/plugins/context_reaction_block.inc

@@ -400,13 +400,17 @@ class context_reaction_block extends context_reaction {
       unset($_context_blocks);
 
       foreach ($context_blocks as $r => $blocks) {
-        //only render blocks in an active region
+        // Only render blocks in an active region.
         if (array_key_exists($r, $active_regions)) {
           $context_blocks[$r] = _block_render_blocks($blocks);
 
-          // Make blocks editable if allowed.
-          if ($this->is_editable_region($r)) {
-            foreach ($context_blocks[$r] as $key => $block) {
+          $editable = $this->is_editable_region($r);
+          foreach ($context_blocks[$r] as $key => $block) {
+            // Add the region property to each block.
+            $context_blocks[$r][$key]->region = $r;
+
+            // Make blocks editable if allowed.
+            if ($editable) {
               $context_blocks[$r][$key] = $this->editable_block($block);
             }
           }
@@ -450,12 +454,9 @@ class context_reaction_block extends context_reaction {
    */
   protected function max_block_weight() {
     $blocks = $this->get_blocks();
-    $block_count = 0;
-    foreach ($blocks as $region => $block_list) {
-      $block_count += count($block_list);
-    }
-    // Add 2 to make sure there's space at either end of the block list
-    return round(($block_count + 2) / 2);
+
+    // Add 2 to make sure there's space at either end of the block list.
+    return round((count($blocks) + 2) / 2);
   }
 
   /**

+ 5 - 6
sites/all/modules/context/plugins/context_reaction_block.js

@@ -68,8 +68,8 @@ DrupalContextBlockForm = function(blockForm) {
 
     // Hide enabled blocks from selector that are used
     $('table.context-blockform-region tr').each(function() {
-      var bid = $(this).attr('id');
-      $('div.context-blockform-selector input[value='+bid+']').parents('div.form-item').eq(0).hide();
+      var bid = Drupal.checkPlain($(this).attr('id'));
+      $('div.context-blockform-selector input[value="'+bid+'"]').parents('div.form-item').eq(0).hide();
     });
     // Show blocks in selector that are unused
     $('div.context-blockform-selector input').each(function() {
@@ -159,7 +159,7 @@ DrupalContextBlockForm = function(blockForm) {
           $(this).removeAttr('checked');
         });
         if (weight_warn) {
-          alert(Drupal.t('Desired block weight exceeds available weight options, please check weights for blocks before saving'));
+          alert(Drupal.t('Desired block weight exceeds available weight options, please check weights for blocks before saving.'));
         }
       }
       return false;
@@ -426,9 +426,8 @@ DrupalContextBlockEditor.prototype = {
 
     $('.editing-context-label').remove();
     var label = $('#context-editable-trigger-'+context+' .label').text();
-    label = Drupal.t('Now Editing: ') + label;
-    editor.parent().parent()
-      .prepend('<div class="editing-context-label">'+ label + '</div>');
+    label = Drupal.t('Now editing: @label', {'@label': label});
+    editor.parent().parent().prepend('<div class="editing-context-label">' + label + '</div>');
 
     // First pass, enable sortables on all regions.
     $(this.regions).each(function() {

+ 1 - 0
sites/all/modules/context/plugins/context_reaction_breadcrumb.inc

@@ -8,6 +8,7 @@ class context_reaction_breadcrumb extends context_reaction_menu {
    * Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path.
    */
   function set_active_trail_from_link($item) {
+    $breadcrumb = array(l(t('Home'), '<front>'));
     $result = db_select('menu_links')
       ->fields('menu_links', array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8'))
       ->condition('hidden', 0)

+ 3 - 1
sites/all/modules/context/plugins/context_reaction_menu.inc

@@ -22,19 +22,21 @@ class context_reaction_menu extends context_reaction {
           $link = menu_link_load($mlid);
           $identifier = $link['link_path'];
           $root_menu = $menu_names[$menu_name];
-          while (isset($options[$root_menu][$identifier])) {
+          while (isset($options[$root_menu][$menu_name . ':' . $identifier])) {
             $identifier .= "'";
           }
           $options[$root_menu][$menu_name . ':' . $identifier] = $title;
         }
       }
     }
+    $menu_count = count($options, COUNT_RECURSIVE);
     return array(
       '#title' => $this->title,
       '#description' => $this->description,
       '#options' => $options,
       '#type' => 'select',
       '#multiple' => TRUE,
+      '#size' => $menu_count > 20 ? 20 : $menu_count,
       '#default_value' => $this->fetch_from_context($context),
     );
   }

+ 5 - 1
sites/all/modules/context/plugins/context_reaction_region.inc

@@ -17,7 +17,7 @@ class context_reaction_region extends context_reaction {
           '#type' => 'fieldset',
           '#title' => "Disable Regions in {$theme->name} Theme",
           '#collapsible' => TRUE,
-          '#collapsed' => !array_reduce($default, create_function('$a, $b', 'return $a || $b;')),
+          '#collapsed' => !array_reduce($default, 'context_reaction_region::collapseRegion'),
         );
         $form[$theme->name]['disable'] = array(
           '#type' => 'checkboxes',
@@ -29,6 +29,10 @@ class context_reaction_region extends context_reaction {
     }
     return $form;
   }
+
+  function collapseRegion($a, $b) {
+    return $a || $b;
+  }
   
   function execute(&$page) {  
     global $theme;

+ 1 - 1
sites/all/modules/context/plugins/context_reaction_template_suggestions.inc

@@ -14,7 +14,7 @@ class context_reaction_template_suggestions extends context_reaction {
     return array(
       '#title' => t('Template suggestions'),
       '#type' => 'textarea',
-      '#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens).  For more information, please visit ') . l(t('Drupal 7 Template (Theme Hook) Suggestions'), 'http://drupal.org/node/1089656', array(array('target' => '_blank'), 'html' => TRUE,)) . '.',
+      '#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens). For more information, please visit <a href="@template-suggestions">Drupal 7 Template (Theme Hook) Suggestions</a>.', array('@template-suggestions' => 'http://drupal.org/node/1089656')),
       '#default_value' => is_string($default_value) ? $default_value : '',
     );
   }

+ 0 - 22
sites/all/modules/context/tests/context.conditions.test

@@ -36,13 +36,6 @@ class ContextConditionUserTest extends DrupalWebTestCase {
     $this->assertTrue($saved, "Context 'testcontext' saved.");
   }
 
-  function tearDown() {
-    parent::tearDown();
-    context_delete($this->context);
-    user_delete($this->user1->uid);
-    user_delete($this->user2->uid);
-  }
-
   function test() {
     // User 1 triggers the context.
     $this->drupalLogin($this->user1);
@@ -82,14 +75,6 @@ class ContextConditionUserPageTest extends DrupalWebTestCase {
     $this->assertTrue($saved, "Context 'testcontext' saved.");
   }
 
-  function tearDown() {
-    parent::tearDown();
-    context_delete($this->context);
-    $edit = array();
-    user_delete($this->user1->uid);
-    user_delete($this->user2->uid);
-  }
-
   function test() {
     // Viewing any user profile triggers context.
     $this->drupalLogin($this->user1);
@@ -157,13 +142,6 @@ class ContextConditionNodeTaxonomyTest extends DrupalWebTestCase {
     $this->assertTrue($saved, "Context 'testcontext' saved.");
   }
 
-  function tearDown() {
-    parent::tearDown();
-    context_delete($this->context);
-    taxonomy_term_delete($this->terms['apples']->tid);
-    taxonomy_term_delete($this->terms['oranges']->tid);
-  }
-
   function test() {
     // Apples does trigger the context.
     $edit = array(

+ 3 - 4
sites/all/modules/context/theme/context_reaction_block.theme.inc

@@ -52,7 +52,7 @@ function theme_context_block_regions_form($vars) {
     $output .= "<div class='label context-blockform-regionlabel-{$region}'>";
     $output .= l(t('+') . ' ' . t('Add'), $_GET['q'], array('fragment' => $region, 'attributes' => array('class' => array('add-block'))));
     $output .= $form[$region]['#title'];
-    $output .= "</div>";
+    $output .= '</div>';
     $output .= theme('table', array('rows' => $rows, 'attributes' => $attr));
   }
   return $output;
@@ -100,14 +100,13 @@ function template_preprocess_context_block_browser(&$vars) {
   //add help text to tell people how to use the block browser
   $help_text = array(
     '#prefix' => '<div class="context_ui-help-text">',
-    '#markup' => t('To add a block to the current region, simply click on the block.  You may use the category filter to filter by
-      block type or the search filter to find the block that you wish to add.'),
+    '#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by block type or the search filter to find the block that you wish to add.'),
     '#suffix' => '</div>',
   );
 
   $filter_label = array(
     '#prefix' => '<div class="filter-label">',
-    '#markup' => t('Search Filter'),
+    '#markup' => t('Search filter'),
     '#suffix' => '</div>',
   );
 

+ 101 - 0
sites/all/modules/link/README.txt

@@ -0,0 +1,101 @@
+CONTENTS OF THIS FILE
+---------------------
+   
+ * Introduction
+ * Requirements
+ * Installation
+ * Configuration
+ * Example
+ * Theming and Output
+ * Maintainers
+
+
+INTRODUCTION
+------------
+
+The link can be count to the top 50 projects in Drupal installations and
+provides a standard custom content field for links. With this module links can
+be added easily to any content types and profiles and include advanced
+validating and different ways of storing internal or external links and URLs. It
+also supports additional link text title, site wide tokens for titles and title
+attributes, target attributes, css class attribution, static repeating values,
+input conversion, and many more.
+
+
+
+REQUIREMENTS
+------------
+
+Project in Drupal 7 requires the following modules:
+
+ * Fields API (Fields API is provided already by core)
+ * Panels (https://drupal.org/project/panels)
+
+Drupal 8:
+
+ * Link is in core now. No installation needed. Yay! Don't forget to activate
+   it. It's deactivated by default.
+
+
+INSTALLATION
+------------
+
+Install as you would normally install a contributed Drupal module. See:
+https://drupal.org/documentation/install/modules-themes/modules-7 for further
+information.
+
+
+CONFIGURATION
+-------------
+
+ * Configuration is only slightly more complicated than a text field. Link text
+   titles for URLs can be made required, set as instead of URL, optional
+   (default), or left out entirely. If no link text title is provided, the
+   trimmed version of the complete URL will be displayed. The target attribute
+   should be set to "_blank", "top", or left out completely (checkboxes provide
+   info). The rel=nofollow attribute prevents the link from being followed by
+   certain search engines. More info at Wikipedia
+   (http://en.wikipedia.org/wiki/Spam_in_blogs#rel.3D.22nofollow.22).
+
+
+EXAMPLE
+-------
+If you were to create a field named 'My New Link', the default display of the
+link would be:
+<em><div class="field_my_new_link" target="[target_value]"><a href="[URL]">
+[Title]</a></div></em> where items between [] characters would be customized
+based on the user input.
+
+The link project supports both, internal and external URLs. URLs are validated
+on input. Here are some examples of data input and the default view of a link:
+http://drupal.org results in http://drupal.org, but drupal.org results in
+http://drupal.org, while <front> will convert into http://drupal.org and
+node/74971 into http://drupal.org/project/link
+
+Anchors and query strings may also be used in any of these cases, including:
+node/74971/edit?destination=node/74972<front>#pager
+
+
+THEMING AND OUTPUT
+------------------
+Since link module is mainly a data storage field in a modular framework, the
+theming and output is up to the site builder and other additional modules. There
+are many modules in the Drupal repository, which control the output of fields
+perfectly and can handle rules, user actions, markup dependencies, and can vary
+the output under many different conditions, with much more efficience and
+flexibility for different scenarios. Please check out modules like views,
+display suite, panels, etc for such needs
+
+
+MAINTAINERS
+-----------
+
+Current maintainers:
+ * John C Fiala (jcfiala) - https://www.drupal.org/user/163643
+ * Renato Gonçalves (RenatoG) - https://www.drupal.org/user/3326031
+ * Clemens Tolboom (clemens.tolboom) - https://www.drupal.org/user/125814
+ * diqidoq - https://www.drupal.org/user/1001934
+ * dropcube - https://www.drupal.org/user/37031
+ * Tom Kirkpatrick (mrfelton) - https://www.drupal.org/user/305669
+ * Sumit Madan (sumitmadan) - https://www.drupal.org/user/1538790
+ * Daniel Kudwien (sun) - https://www.drupal.org/user/54136

+ 7 - 0
sites/all/modules/link/link-rtl.css

@@ -0,0 +1,7 @@
+.link-field-column {
+  float: right;
+}
+.link-field-column.link-field-url .form-text {
+  direction: ltr;
+  text-align: left;
+}

+ 2 - 3
sites/all/modules/link/link.css

@@ -1,8 +1,7 @@
-div.link-field-column {
+.link-field-column {
   float: left;
   width: 48%;
 }
-
-div.link-field-column .form-text {
+.link-field-column .form-text {
   width: 95%;
 }

+ 32 - 0
sites/all/modules/link/link.devel_generate.inc

@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @file
+ * Devel Generate support for Link module.
+ */
+
+/**
+ * Implements hook_devel_generate().
+ */
+function link_devel_generate($object, $field, $instance, $bundle) {
+  if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
+    return devel_generate_multiple('_link_devel_generate', $object, $field, $instance, $bundle);
+  }
+  else {
+    return _link_devel_generate($object, $field, $instance, $bundle);
+  }
+}
+
+/**
+ * Callback for hook_devel_generate().
+ */
+function _link_devel_generate($object, $field, $instance, $bundle) {
+  $link = array(
+    'url' => url('<front>', array('absolute' => TRUE)),
+    'attributes' => _link_default_attributes(),
+  );
+  if ($instance['settings']['title'] != 'none') {
+    $link['title'] = devel_create_greeking(mt_rand(1, 3), TRUE);
+  }
+  return $link;
+}

+ 22 - 0
sites/all/modules/link/link.diff.inc

@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @file
+ * Provide diff field functions for the Link module.
+ */
+
+/**
+ * Diff field callback for parsing link fields comparative values.
+ */
+function link_field_diff_view($items, $context) {
+  $diff_items = array();
+  foreach ($items as $delta => $item) {
+    if ($item['url'] && isset($item['title'])) {
+      $diff_items[$delta] = $item['title'] . ' (' . $item['url'] . ')';
+    }
+    else {
+      $diff_items[$delta] = $item['url'];
+    }
+  }
+  return $diff_items;
+}

+ 6 - 6
sites/all/modules/link/link.info

@@ -3,23 +3,23 @@ description = Defines simple link field types.
 core = 7.x
 package = Fields
 
-files[] = link.module
-files[] = link.install
+files[] = link.migrate.inc
+
 ; Tests
 files[] = tests/link.test
 files[] = tests/link.attribute.test
 files[] = tests/link.crud.test
 files[] = tests/link.crud_browser.test
 files[] = tests/link.token.test
+files[] = tests/link.entity_token.test
 files[] = tests/link.validate.test
 
 ; Views Handlers
 files[] = views/link_views_handler_argument_target.inc
 files[] = views/link_views_handler_filter_protocol.inc
 
-; Information added by drupal.org packaging script on 2011-10-23
-version = "7.x-1.0"
+; Information added by Drupal.org packaging script on 2019-02-20
+version = "7.x-1.6"
 core = "7.x"
 project = "link"
-datestamp = "1319392535"
-
+datestamp = "1550680687"

+ 54 - 28
sites/all/modules/link/link.install

@@ -6,11 +6,39 @@
  */
 
 /**
- * Upgrade notes:
- * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:
+ * Upgrade notes.
+ *
+ * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:.
  */
 
 /**
+ * Implements hook_uninstall().
+ */
+function link_install() {
+  // Notify the user they may want to install token.
+  if (!module_exists('token')) {
+    $t = get_t();
+    drupal_set_message($t('If you install the <a href="!url" target="blank">Token</a>, static title can use any other entity field as its value.', array(
+      '!url' => 'http://drupal.org/project/token',
+    )));
+  }
+}
+
+/**
+ * Removes unused link_extra_domains variable.
+ */
+function link_update_7002() {
+  variable_del('link_extra_domains');
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function link_uninstall() {
+  variable_del('link_allowed_domains');
+}
+
+/**
  * Implements hook_field_schema().
  */
 function link_field_schema($field) {
@@ -18,20 +46,21 @@ function link_field_schema($field) {
     'columns' => array(
       'url' => array(
         'type' => 'varchar',
-        'length' => 2048, // Maximum URLs length.
+        // Maximum URLs length.
+        'length' => 2048,
         'not null' => FALSE,
-        'sortable' => TRUE
+        'sortable' => TRUE,
       ),
       'title' => array(
         'type' => 'varchar',
         'length' => 255,
         'not null' => FALSE,
-        'sortable' => TRUE
+        'sortable' => TRUE,
       ),
       'attributes' => array(
         'type' => 'text',
         'size' => 'medium',
-        'not null' => FALSE
+        'not null' => FALSE,
       ),
     ),
   );
@@ -45,19 +74,21 @@ function link_update_last_removed() {
 }
 
 /**
- * Handles moving settings data from field_config.data to field_config_instance.data.
+ * Implements hook_update_N().
+ *
+ * Handles moving settings data from field_config.data to
+ * field_config_instance.data.
  */
 function link_update_7000() {
-  
-  // For each field that is a link field, we need to copy the settings from the general field level down to the instance.
-  //$field_data = array();
+
+  // For each field that is a link field, we need to copy the settings from the
+  // general field level down to the instance.
   $result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
   foreach ($result as $field) {
-    $field_id = $field->id;
-    $name = $field->field_name;
+
     $field_data = unserialize($field->data);
-    
-    $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
+
+    $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id));
     foreach ($instances as $instance) {
       // If this field has been updated already, we want to skip it.
       $instance_data = unserialize($instance->data);
@@ -70,8 +101,8 @@ function link_update_7000() {
           }
         }
         if ($update_instance) {
-          // update the database.
-          $num_updated = db_update('field_config_instance')
+          // Update the database.
+          db_update('field_config_instance')
             ->fields(array('data' => serialize($instance_data)))
             ->condition('id', $instance->id)
             ->execute();
@@ -79,36 +110,31 @@ function link_update_7000() {
       }
     }
   }
-  
+
   return t("Instance settings have been set with the data from the field settings.");
 }
 
 /**
- * Renames all displays from foobar to link_foobar
+ * Renames all displays from foobar to link_foobar.
  */
 function link_update_7001() {
-  // for each field that is a link field, we need to update the display types:
-  
+  // Update the display type for each link field type.
   $result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
   foreach ($result as $field) {
-    $field_id = $field->id;
-    $name = $field->field_name;
-    $field_data = unserialize($field->data);
-    
-    $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
+
+    $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id));
     foreach ($instances as $instance) {
       // If this field has been updated already, we want to skip it.
       $instance_data = unserialize($instance->data);
       $update_instance = FALSE;
       foreach ($instance_data['display'] as $display_name => $display_data) {
         if ($display_data['type'] && (0 !== strpos($display_data['type'], 'link_'))) {
-          $instance_data['display'][$display_name]['type'] = 'link_'. $display_data['type'];
+          $instance_data['display'][$display_name]['type'] = 'link_' . $display_data['type'];
           $update_instance = TRUE;
         }
       }
       if ($update_instance) {
-        // update the database.
-        $num_updated = db_update('field_config_instance')
+        db_update('field_config_instance')
           ->fields(array('data' => serialize($instance_data)))
           ->condition('id', $instance->id)
           ->execute();

+ 139 - 0
sites/all/modules/link/link.migrate.inc

@@ -0,0 +1,139 @@
+<?php
+
+/**
+ * @file
+ * Support for migrate module.
+ *
+ * With Migrate 2.4 or later, you can use the subfield syntax to set the title
+ * and attributes:
+ *
+ * @code
+ * $this->addFieldMapping('field_my_link', 'source_url');
+ * $this->addFieldMapping('field_my_link:title', 'source_title');
+ * $this->addFieldMapping('field_my_link:attributes', 'source_attributes');
+ *
+ * # With earlier versions of Migrate, you must pass an arguments array:
+ *
+ * $link_args = array(
+ *   'title' => array('source_field' => 'source_title'),
+ *   'attributes' => array('source_field' => 'source_attributes'),
+ * );
+ * $this->addFieldMapping('field_my_link', 'source_url')
+ *      ->arguments($link_args);
+ * @endcode
+ */
+
+if (!class_exists('MigrateFieldHandler')) {
+  return;
+}
+
+/**
+ * Implements hook_migrate_api().
+ */
+function link_migrate_api() {
+  return array(
+    'api' => 2,
+    'field handlers' => array('MigrateLinkFieldHandler'),
+  );
+}
+
+// @codingStandardsIgnoreLine
+class MigrateLinkFieldHandler extends MigrateFieldHandler {
+
+  /**
+   * Construct.
+   */
+  public function __construct() {
+    $this->registerTypes(array('link_field'));
+  }
+
+  /**
+   * Arguments.
+   */
+  public static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
+    $arguments = array();
+    if (!is_null($title)) {
+      $arguments['title'] = $title;
+    }
+    if (!is_null($attributes)) {
+      $arguments['attributes'] = $attributes;
+    }
+    if (!is_null($language)) {
+      $arguments['language'] = $language;
+    }
+    return $arguments;
+  }
+
+  /**
+   * Implementation of MigrateFieldHandler::fields().
+   *
+   * @param array $type
+   *   The field type.
+   * @param array $instance
+   *   Instance info for the field.
+   * @param Migration $migration
+   *   The migration context for the parent field. We can look at the mappings
+   *   and determine which subfields are relevant.
+   *
+   * @return array
+   *   Array with values.
+   *
+   * @codingStandardsIgnoreStart
+   */
+  public function fields($type, $instance, $migration = NULL) {
+    // @codingStandardsIgnoreEnd
+    return array(
+      'title' => t('Subfield: The link title attribute'),
+      'attributes' => t('Subfield: The attributes for this link'),
+      'language' => t('Subfield: The language for the field'),
+    );
+  }
+
+  /**
+   * Prepare.
+   */
+  public function prepare($entity, array $field_info, array $instance, array $values) {
+    if (isset($values['arguments'])) {
+      $arguments = $values['arguments'];
+      unset($values['arguments']);
+    }
+    else {
+      $arguments = array();
+    }
+
+    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
+    $values = array_filter($values);
+
+    foreach ($values as $delta => $value) {
+      $item = array();
+      if (isset($arguments['title'])) {
+        if (!is_array($arguments['title'])) {
+          $item['title'] = $arguments['title'];
+        }
+        elseif (isset($arguments['title'][$delta])) {
+          $item['title'] = $arguments['title'][$delta];
+        }
+      }
+      if (isset($arguments['attributes'])) {
+        if (is_array($arguments['attributes']) && isset($arguments['attributes'][$delta])) {
+          $item['attributes'] = $arguments['attributes'][$delta];
+        }
+        else {
+          $item['attributes'] = $arguments['attributes'];
+        }
+      }
+      $item['url'] = $value;
+
+      if (is_array($language)) {
+        $current_language = $language[$delta];
+      }
+      else {
+        $current_language = $language;
+      }
+      $return[$current_language][$delta] = $item;
+    }
+
+    return isset($return) ? $return : NULL;
+  }
+
+}

File diff suppressed because it is too large
+ 947 - 301
sites/all/modules/link/link.module


File diff suppressed because it is too large
+ 269 - 461
sites/all/modules/link/tests/link.attribute.test


+ 31 - 24
sites/all/modules/link/tests/link.crud.test

@@ -2,11 +2,20 @@
 
 /**
  * @file
- * Basic CRUD simpletests for the link module, based off of content.crud.test in CCK.
+ * File for Crud Tests.
+ *
+ * Basic CRUD simpletests for the link module, based off of content.crud.test in
+ * CCK.
  */
 
+/**
+ * Content Crud.
+ */
 class LinkContentCrudTest extends DrupalWebTestCase {
 
+  /**
+   * Get Info.
+   */
   public static function getInfo() {
     return array(
       'name' => 'Link CRUD - Basic API tests',
@@ -15,47 +24,53 @@ class LinkContentCrudTest extends DrupalWebTestCase {
     );
   }
 
-  function setUp() {
-    parent::setUp('field_ui', 'link'); // was views?
-    //$this->loginWithPermissions();
+  /**
+   * Setup.
+   */
+  public function setUp() {
+    parent::setUp('field_ui', 'link');
   }
 
   /**
-   * All we're doing here is creating a content type, creating a simple link field
-   * on that content type.
+   * Create Field API.
+   *
+   * All we're doing here is creating a content type, creating a simple link
+   * field on that content type.
+   *
+   * @codingStandardsIgnoreStart
    */
-  function testLinkCreateFieldAPI() {
+  public function testLinkCreateFieldAPI() {
+    // @codingStandardsIgnoreEnd
     $content_type_friendly = $this->randomName(20);
     $content_type_machine = strtolower($this->randomName(10));
-    $title = $this->randomName(20);
 
     // Create and login user.
-    $account = $this->drupalCreateUser(array('administer content types'));
-    $this->drupalLogin($account);
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+    ));
+    $this->drupalLogin($this->web_user);
 
     $this->drupalGet('admin/structure/types');
 
     // Create the content type.
     $this->clickLink(t('Add content type'));
 
-
-    $edit = array (
+    $edit = array(
       'name' => $content_type_friendly,
       'type' => $content_type_machine,
     );
     $this->drupalPost(NULL, $edit, t('Save and add fields'));
     $this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
 
-    //$field = $this->createField(array('type' => 'link', 'widget_type' => 'link'), 0);
     // Now add a singleton field.
     $single_field_name_friendly = $this->randomName(20);
     $single_field_name_machine = strtolower($this->randomName(10));
-    $edit = array (
+    $edit = array(
       'fields[_add_new_field][label]' => $single_field_name_friendly,
       'fields[_add_new_field][field_name]' => $single_field_name_machine,
       'fields[_add_new_field][type]' => 'link_field',
       'fields[_add_new_field][widget_type]' => 'link_field',
-
     );
     $this->drupalPost(NULL, $edit, t('Save'));
 
@@ -72,14 +87,6 @@ class LinkContentCrudTest extends DrupalWebTestCase {
     menu_rebuild();
     $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
     $this->assertTrue($type_exists, 'The new content type has been created in the database.');
-
-    /*$table_schema = drupal_get_schema();
-    $this->assertEqual(1, 1, print_r(array_keys($table_schema), TRUE));
-    // Check the schema - the values should be in the per-type table.
-    $this->assertSchemaMatchesTables(array(
-      'per_type' => array(
-        $this->content_types[0]->type => array($field['field_name'] => array('url', 'title', 'attributes')),
-      ),
-    ));*/
   }
+
 }

+ 309 - 159
sites/all/modules/link/tests/link.crud_browser.test

@@ -6,25 +6,28 @@
  */
 
 /**
- * Testing that users can not input bad URLs or labels
+ * Testing that users can not input bad URLs or labels.
  */
 class LinkUITest extends DrupalWebTestcase {
 
   /**
-   * Link supposed to be good
+   * Link supposed to be good.
    */
   const LINK_INPUT_TYPE_GOOD = 0;
 
   /**
-   * Link supposed to have a bad title
+   * Link supposed to have a bad title.
    */
   const LINK_INPUT_TYPE_BAD_TITLE = 1;
 
   /**
-   * Link supposed to have a bad URL
+   * Link supposed to have a bad URL.
    */
   const LINK_INPUT_TYPE_BAD_URL = 2;
 
+  /**
+   * Get Info.
+   */
   public static function getInfo() {
     return array(
       'name' => 'Link CRUD - browser test',
@@ -33,24 +36,30 @@ class LinkUITest extends DrupalWebTestcase {
     );
   }
 
-  function setUp() {
+  /**
+   * Setup.
+   */
+  public function setUp() {
     parent::setUp('field_ui', 'link');
   }
 
   /**
    * Creates a link field for the "page" type and creates a page with a link.
    */
-  function testLinkCreate() {
-    //libxml_use_internal_errors(true);
-    $account = $this->drupalCreateUser(array('administer content types',
-                                             'administer nodes',
-                                             'administer filters',
-                                             'access content',
-                                             'create page content',
-                                             'access administration pages'));
-    $this->drupalLogin($account);
-
-    // create field
+  public function testLinkCreate() {
+    // libxml_use_internal_errors(true);
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'administer nodes',
+      'administer filters',
+      'access content',
+      'create page content',
+      'access administration pages',
+    ));
+    $this->drupalLogin($this->web_user);
+
+    // Create field.
     $name = strtolower($this->randomName());
     $edit = array(
       'fields[_add_new_field][label]' => $name,
@@ -70,62 +79,68 @@ class LinkUITest extends DrupalWebTestcase {
     $permission = 'create page content';
     $this->checkPermissions(array($permission), TRUE);
 
-    // create page form
-    //$this->drupalGet('node/add');
+    // Create page form
+    // $this->drupalGet('node/add');.
     $this->drupalGet('node/add/page');
     $field_name = 'field_' . $name;
-    $this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
-    $this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
+    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
+    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
 
     $input_test_cases = array(
       array(
         'href' => 'http://example.com/' . $this->randomName(),
         'label' => $this->randomName(),
         'msg' => 'Link found',
-        'type' => self::LINK_INPUT_TYPE_GOOD
+        'type' => self::LINK_INPUT_TYPE_GOOD,
       ),
       array(
         'href' => 'http://example.com/' . $this->randomName(),
         'label' => $this->randomName() . '<script>alert("hi");</script>',
         'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
       ),
       array(
         'href' => 'http://example.com/' . $this->randomName(),
         'label' => $this->randomName() . '<script src="http://devil.site.com"></script>',
         'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
       ),
       array(
         'href' => 'http://example.com/' . $this->randomName(),
         'label' => $this->randomName() . '" onmouseover="alert(\'hi\')',
         'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
       ),
-       array(
+      array(
         'href' => 'http://example.com/' . $this->randomName(),
         'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
         'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
       ),
-     array(
+      array(
         'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
         'label' => $this->randomName(),
         'msg' => 'js url',
-        'type' => self::LINK_INPUT_TYPE_BAD_URL
+        'type' => self::LINK_INPUT_TYPE_BAD_URL,
+      ),
+      array(
+        'href' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
+        'label' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
+        'msg' => 'Url with . in querystring',
+        'type' => self::LINK_INPUT_TYPE_GOOD,
       ),
     );
     $test_case = array(
-      'href' => 'www.example.com/'. $this->randomName(),
+      'href' => 'www.example.com/' . $this->randomName(),
       'label' => $this->randomName(),
       'msg' => 'Link found',
       'type' => self::LINK_INPUT_TYPE_GOOD,
     );
-    $test_case['expected_href'] = 'http://'. $test_case['href'];
+    $test_case['expected_href'] = 'http://' . $test_case['href'];
     $input_test_cases[] = $test_case;
 
     foreach ($input_test_cases as $input) {
-      $this->drupalLogin($account);
+      $this->drupalLogin($this->web_user);
       $this->drupalGet('node/add/page');
 
       $edit = array(
@@ -135,49 +150,60 @@ class LinkUITest extends DrupalWebTestcase {
       );
       $this->drupalPost(NULL, $edit, t('Save'));
       if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
-        $this->assertRaw(t('Not a valid URL.'), 'Not a valid URL: ' . $input['href']);
+        $this->assertRaw(t('The value %value provided for %field is not a valid URL.', array(
+          '%field' => $name,
+          '%value' => trim($input['href']),
+        )), 'Not a valid URL: ' . $input['href']);
         continue;
       }
       else {
-        $this->assertRaw(t(' has been created.',
-                           array('@type' => 'Basic Page', '%title' => $edit['title'])),
-                         'Page created: ' . $input['href']);
+        $this->assertRaw(' ' . t('has been created.',
+            array('@type' => 'Basic Page', '%title' => $edit['title'])),
+          'Page created: ' . $input['href']);
       }
       $url = $this->getUrl();
 
-      // change to anonym user
+      // Change to Anonymous user.
       $this->drupalLogout();
 
       $this->drupalGet($url);
-      //debug($this);
-      // If simpletest starts using something to override the error system, this will flag
-      // us and let us know it's broken.
+      // debug($this);
+      // If simpletest starts using something to override the error system, this
+      // will flag us and let us know it's broken.
       $this->assertFalse(libxml_use_internal_errors(TRUE));
       if (isset($input['expected_href'])) {
-        $path = '//a[@href="'. $input['expected_href'] .'" and text()="'. $input['label'] .'"]';
+        $path = '//a[@href="' . $input['expected_href'] . '" and text()="' . $input['label'] . '"]';
       }
       else {
-        $path = '//a[@href="'. $input['href'] .'" and text()="'. $input['label'] .'"]';
+        $path = '//a[@href="' . $input['href'] . '" and text()="' . $input['label'] . '"]';
       }
-      //$this->pass(htmlentities($path));
       $elements = $this->xpath($path);
       libxml_use_internal_errors(FALSE);
       $this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']);
     }
-    //libxml_use_internal_errors(FALSE);
+    // libxml_use_internal_errors(FALSE);
   }
 
   /**
-   * Creates a link field for the "page" type and creates a page with a link.
-   * Just like the above test, only here we're turning off the validation on the field.
+   * Static Link Create.
+   *
+   * Testing that if you use <strong> in a static title for your link, that the
+   * title actually displays <strong>.
    */
-  /*function testLinkCreate_NoValidation() {
-    //libxml_use_internal_errors(true);
-    $account = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
-    $this->drupalLogin($account);
+  public function testStaticLinkCreate() {
+
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'access content',
+      'create page content',
+    ));
 
-    // create field
+    $this->drupalLogin($this->web_user);
+
+    // Create field.
     $name = strtolower($this->randomName());
+    $field_name = 'field_' . $name;
     $edit = array(
       'fields[_add_new_field][label]' => $name,
       'fields[_add_new_field][field_name]' => $name,
@@ -186,107 +212,58 @@ class LinkUITest extends DrupalWebTestcase {
     );
     $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
     $this->drupalPost(NULL, array(), t('Save field settings'));
-    $this->drupalPost(NULL, array('validate_url' => FALSE), t('Save settings'));
+    $this->drupalPost(NULL, array(
+      'instance[settings][title]' => 'value',
+      'instance[settings][title_value]' => '<strong>' . $name . '</strong>',
+    ), t('Save settings'));
 
     // Is field created?
     $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
-    _content_type_info(TRUE);
-    $fields = content_fields();
-    $this->assertTRUE(0 === $fields['field_'. $name]['validate_url'], 'Make sure validation is off.');
 
-    // create page form
+    // Create page form.
     $this->drupalGet('node/add/page');
-    $field_name = 'field_' . $name;
-    $this->assertField($field_name . '[0][title]', 'Title found');
-    $this->assertField($field_name . '[0][url]', 'URL found');
+    $this->assertField($field_name . '[und][0][url]', 'URL found');
 
-    $input_test_cases = array(
-      array(
-        'href' => 'http://example.com/' . $this->randomName(),
-        'label' => $this->randomName(),
-        'msg' => 'Link found',
-        'type' => self::LINK_INPUT_TYPE_GOOD
-      ),
-      array(
-        'href' => 'http://example.com/' . $this->randomName(),
-        'label' => $this->randomName() . '<script>alert("hi");</script>',
-        'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
-      ),
-      array(
-        'href' => 'http://example.com/' . $this->randomName(),
-        'label' => $this->randomName() . '<script src="http://devil.site.com"></script>',
-        'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
-      ),
-      array(
-        'href' => 'http://example.com/' . $this->randomName(),
-        'label' => $this->randomName() . '" onmouseover="alert(\'hi\')',
-        'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
-      ),
-       array(
-        'href' => 'http://example.com/' . $this->randomName(),
-        'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
-        'msg' => 'js label',
-        'type' => self::LINK_INPUT_TYPE_BAD_TITLE
-      ),
-     array(
-        'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
-        'label' => $this->randomName(),
-        'msg' => 'js url',
-        'type' => self::LINK_INPUT_TYPE_BAD_URL
-      ),
+    $input = array(
+      'href' => 'http://example.com/' . $this->randomName(),
     );
-    foreach ($input_test_cases as $input) {
-      $this->drupalLogin($account);
-      $this->drupalGet('node/add/page');
 
-      $edit = array(
-        'title' => $input['label'],
-        $field_name . '[0][title]' => $input['label'],
-        $field_name . '[0][url]' => $input['href'],
-      );
-      $this->drupalPost(NULL, $edit, t('Save'));
-      if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
-        //$this->assertRaw(t('Not a valid URL.'), 'Not a valid URL: ' . $input['href']);
-        $this->assertNoRaw($input['href']);
-        $this->assertRaw(t('@type %title has been created.', array('@type' => 'Basic Page', '%title' => $edit['title'])), 'Page created: ' . $input['href']);
-        continue;
-      }
-      else {
-        $this->assertRaw(t('@type %title has been created.', array('@type' => 'Basic Page', '%title' => $edit['title'])), 'Page created: ' . $input['href']);
-      }
-      $url = $this->getUrl();
+    $edit = array(
+      'title' => $name,
+      $field_name . '[und][0][url]' => $input['href'],
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
 
-      // change to anonym user
-      $this->drupalLogout();
+    $url = $this->getUrl();
 
-      $this->drupalGet($url);
-      //debug($this);
-      // If simpletest starts using something to override the error system, this will flag
-      // us and let us know it's broken.
-      $this->assertFalse(libxml_use_internal_errors(TRUE));
-      $path = '//a[@href="'. $input['href'] .'" and text()="'. $input['label'] .'"]';
-      //$this->pass(htmlentities($path));
-      $elements = $this->xpath($path);
-      libxml_use_internal_errors(FALSE);
-      $this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']);
-    }
-    //libxml_use_internal_errors(FALSE);
-  }*/
+    // Change to anonymous user.
+    $this->drupalLogout();
+    $this->drupalGet($url);
+
+    $this->assertRaw(l('<strong>' . $name . '</strong>', $input['href'], array('html' => TRUE)));
+  }
 
   /**
-   * Testing that if you use <strong> in a static title for your link, that the
-   * title actually displays <strong>.
+   * CRUD Title Only Title No Link.
+   *
+   * Testing that if you have the title but no url, the title is not sanitized
+   * twice.
+   *
+   * @codingStandardsIgnoreStart
    */
-  function testStaticLinkCreate() {
-    $account = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
-    $this->drupalLogin($account);
-
-    // create field
+  public function testCRUDTitleOnlyTitleNoLink() {
+    // @codingStandardsIgnoreEnd
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'access content',
+      'create page content',
+    ));
+    $this->drupalLogin($this->web_user);
+
+    // Create field.
     $name = strtolower($this->randomName());
-    $field_name = 'field_'. $name;
+    $field_name = 'field_' . $name;
     $edit = array(
       'fields[_add_new_field][label]' => $name,
       'fields[_add_new_field][field_name]' => $name,
@@ -296,44 +273,58 @@ class LinkUITest extends DrupalWebTestcase {
     $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
     $this->drupalPost(NULL, array(), t('Save field settings'));
     $this->drupalPost(NULL, array(
-      'instance[settings][title]' => 'value',
-      'instance[settings][title_value]' => '<strong>'. $name .'</strong>'), t('Save settings'));
+      'instance[settings][url]' => 1,
+    ), t('Save settings'));
 
     // Is field created?
     $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
 
-    // create page form
+    // Create page form.
     $this->drupalGet('node/add/page');
     $this->assertField($field_name . '[und][0][url]', 'URL found');
 
     $input = array(
-      'href' => 'http://example.com/' . $this->randomName()
+      'title' => 'This & That',
+      'href' => '',
     );
 
     $edit = array(
       'title' => $name,
+      $field_name . '[und][0][title]' => $input['title'],
       $field_name . '[und][0][url]' => $input['href'],
     );
     $this->drupalPost(NULL, $edit, t('Save'));
 
     $url = $this->getUrl();
 
-    // change to anonymous user
+    // Change to anonymous user.
     $this->drupalLogout();
     $this->drupalGet($url);
 
-    $this->assertRaw(l('<strong>'. $name .'</strong>', $input['href'], array('html' => TRUE)));
+    $this->assertRaw('This &amp; That');
   }
 
   /**
-   * If we're creating a new field and just hit 'save' on the default options, we want to make
-   * sure they are set to the expected results.
+   * CRUD Create Field Defaults.
+   *
+   * If we're creating a new field and just hit 'save' on the default options,
+   * we want to make sure they are set to the expected results.
+   *
+   * @codingStandardsIgnoreStart
    */
-  function testCRUDCreateFieldDefaults() {
-    $account = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
-    $this->drupalLogin($account);
+  public function testCRUDCreateFieldDefaults() {
+    // @codingStandardsIgnoreEnd
+
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'access content',
+      'create page content',
+    ));
+
+    $this->drupalLogin($this->web_user);
 
-    // create field
+    // Create field.
     $name = strtolower($this->randomName());
     $edit = array(
       'fields[_add_new_field][label]' => $name,
@@ -349,25 +340,184 @@ class LinkUITest extends DrupalWebTestcase {
     $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
     node_types_rebuild();
     menu_rebuild();
-    //_content_type_info(TRUE);
-    //$fields = content_fields();
-    //$field = $fields['field_'. $name];
-    //$field = field_info_field('field_'. $name);
+
     _field_info_collate_fields(TRUE);
     $instances = field_info_instances('node', 'page');
-    //$this->debug($instances);
-    //$this->assert('debug', '<pre>'. print_r($instances, TRUE) .'</pre>', 'Debug');
-    $instance = $instances['field_'. $name];
-    //$this->assertTrue(1 === $instance['validate_url'], 'Make sure validation is on.');
+
+    $instance = $instances['field_' . $name];
     $this->assertFalse($instance['required'], 'Make sure field is not required.');
     $this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
-    $this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be off by default.');
+    $this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
+    $this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
     $this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
     $this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
     $this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
     $this->assertFalse($instance['settings']['attributes']['class'], 'By default, no class should be set.');
     $this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
+  }
+
+  /**
+   * CRUD Create Field With Class.
+   *
+   * If we're creating a new field and just hit 'save' on the default options,
+   * we want to make sure they are set to the expected results.
+   *
+   * @codingStandardsIgnoreStart
+   */
+  public function testCRUDCreateFieldWithClass() {
+    // @codingStandardsIgnoreEnd
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'access content',
+      'create page content',
+    ));
+    $this->drupalLogin($this->web_user);
+
+    // Create field.
+    $name = strtolower($this->randomName());
+    $edit = array(
+      'fields[_add_new_field][label]' => $name,
+      'fields[_add_new_field][field_name]' => $name,
+      'fields[_add_new_field][type]' => 'link_field',
+      'fields[_add_new_field][widget_type]' => 'link_field',
+    );
+    $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
+
+    $this->drupalPost(NULL, array(), t('Save field settings'));
+    $link_class_name = 'basic-link-' . strtolower($this->randomName());
+    $edit = array(
+      'instance[settings][attributes][class]' => $link_class_name,
+    );
+    $this->drupalPost(NULL, $edit, t('Save settings'));
+
+    // Is field created?
+    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
+    node_types_rebuild();
+    menu_rebuild();
+
+    _field_info_collate_fields(TRUE);
+    $instances = field_info_instances('node', 'page');
+
+    $instance = $instances['field_' . $name];
+    $this->assertFalse($instance['required'], 'Make sure field is not required.');
+    $this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
+    $this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
+    $this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
+    $this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
+    $this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
+    $this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
+    $this->assertEqual($instance['settings']['attributes']['class'], $link_class_name, 'One class should be set.');
+    $this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
+
+    // Now, let's create a node with this field and make sure the link shows up:
+    // create page form.
+    $field_name = 'field_' . $name;
+    $this->drupalGet('node/add/page');
+    $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+    $input = array(
+      'title' => 'This & That',
+      'href' => 'http://www.example.com/',
+    );
+
+    $edit = array(
+      'title' => $field_name,
+      $field_name . '[und][0][title]' => $input['title'],
+      $field_name . '[und][0][url]' => $input['href'],
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+
+    $url = $this->getUrl();
+
+    // Change to anonymous user.
+    $this->drupalLogout();
+    $this->drupalGet($url);
+
+    $this->assertRaw('This &amp; That');
+    $this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Class $link_class_name exists on page.");
+  }
+
+  /**
+   * CRUD Create Field With Two Classes.
+   *
+   * If we're creating a new field and just hit 'save' on the default options,
+   * we want to make sure they are set to the expected results.
+   *
+   * @codingStandardsIgnoreStart
+   */
+  public function testCRUDCreateFieldWithTwoClasses() {
+    // @codingStandardsIgnoreEnd
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'access content',
+      'create page content',
+    ));
+    $this->drupalLogin($this->web_user);
+
+    // Create field.
+    $name = strtolower($this->randomName());
+    $edit = array(
+      'fields[_add_new_field][label]' => $name,
+      'fields[_add_new_field][field_name]' => $name,
+      'fields[_add_new_field][type]' => 'link_field',
+      'fields[_add_new_field][widget_type]' => 'link_field',
+    );
+    $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
+
+    $this->drupalPost(NULL, array(), t('Save field settings'));
+    $link_class_name = 'basic-link ' . strtoupper($this->randomName());
+    $edit = array(
+      'instance[settings][attributes][class]' => $link_class_name,
+    );
+    $this->drupalPost(NULL, $edit, t('Save settings'));
+
+    // Is field created?
+    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
+    node_types_rebuild();
+    menu_rebuild();
+
+    _field_info_collate_fields(TRUE);
+    $instances = field_info_instances('node', 'page');
+
+    $instance = $instances['field_' . $name];
+    $this->assertFalse($instance['required'], 'Make sure field is not required.');
+    $this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
+    $this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
+    $this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
+    $this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
+    $this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
+    $this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
+    $this->assertEqual($instance['settings']['attributes']['class'], $link_class_name, 'Two classes should be set.');
+    $this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
+
+    // Now, let's create a node with this field and make sure the link shows up:
+    // create page form.
+    $field_name = 'field_' . $name;
+    $this->drupalGet('node/add/page');
+    $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+    $input = array(
+      'title' => 'This & That',
+      'href' => 'http://www.example.com/',
+    );
 
-    //$this->fail('<pre>'. print_r($fields['field_'. $name], TRUE) .'</pre>');
+    $edit = array(
+      'title' => $field_name,
+      $field_name . '[und][0][title]' => $input['title'],
+      $field_name . '[und][0][url]' => $input['href'],
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+
+    $url = $this->getUrl();
+
+    // Change to anonymous user.
+    $this->drupalLogout();
+    $this->drupalGet($url);
+
+    $this->assertRaw('This &amp; That');
+    $this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Classes $link_class_name exist on page.");
   }
+
 }

+ 164 - 0
sites/all/modules/link/tests/link.entity_token.test

@@ -0,0 +1,164 @@
+<?php
+
+/**
+ * @file
+ * Contains simpletests making sure entity_token integration works.
+ */
+
+/**
+ * Testing that tokens can be used in link titles.
+ */
+class LinkEntityTokenTest extends LinkBaseTestClass {
+
+  /**
+   * Get Info.
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Link entity tokens test',
+      'description' => 'Tests that a link field appears properly in entity tokens',
+      'group' => 'Link',
+      'dependencies' => array('token', 'entity', 'entity_token'),
+    );
+  }
+
+  /**
+   * Setup.
+   */
+  public function setUp($modules = array()) {
+    parent::setUp(array('token', 'entity', 'entity_token'));
+  }
+
+  /**
+   * Creates a link field, fills it, then uses a loaded node to test tokens.
+   */
+  public function testFieldTokenNodeLoaded() {
+    // Create field.
+    $settings = array(
+      'instance[settings][enable_tokens]' => 0,
+    );
+    $field_name = $this->createLinkField('page',
+      $settings);
+
+    // Create page form.
+    $this->drupalGet('node/add/page');
+    // $field_name = 'field_' . $name;.
+    $this->assertField($field_name . '[und][0][title]', 'Title found');
+    $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+    $token_url_tests = array(
+      1 => array(
+        'href' => 'http://example.com/' . $this->randomName(),
+        'label' => $this->randomName(),
+      ),
+      2 => array(
+        'href' => 'http://example.com/' . $this->randomName() . '?property=value',
+        'label' => $this->randomName(),
+      ),
+      3 => array(
+        'href' => 'http://example.com/' . $this->randomName() . '#position',
+        'label' => $this->randomName(),
+      ),
+      4 => array(
+        'href' => 'http://example.com/' . $this->randomName() . '#lower?property=value2',
+        'label' => $this->randomName(),
+      ),
+    );
+    // @codingStandardsIgnoreLine
+    // $this->assert('pass', '<pre>' . print_r($token_url_tests, TRUE) . '<pre>');.
+    foreach ($token_url_tests as &$input) {
+      $this->drupalGet('node/add/page');
+
+      $edit = array(
+        'title' => $input['label'],
+        $field_name . '[und][0][title]' => $input['label'],
+        $field_name . '[und][0][url]' => $input['href'],
+      );
+      $this->drupalPost(NULL, $edit, t('Save'));
+      $url = $this->getUrl();
+      $input['url'] = $url;
+    }
+
+    // Change to anonymous user.
+    $this->drupalLogout();
+
+    foreach ($token_url_tests as $index => $input2) {
+      $node = node_load($index);
+      $this->assertNotEqual(NULL, $node, "Do we have a node?");
+      $this->assertEqual($node->nid, $index, "Test that we have a node.");
+      $token_name = '[node:' . str_replace('_', '-', $field_name) . ':url]';
+      $assert_data = token_replace($token_name,
+        array('node' => $node));
+      $this->assertEqual($input2['href'], $assert_data, "Test that the url token has been set to " . $input2['href'] . ' - ' . $assert_data);
+    }
+  }
+
+  /**
+   * Field Token Node Viewed.
+   *
+   * Creates a link field, fills it, then uses a loaded and node_view'd node to
+   * test tokens.
+   */
+  public function testFieldTokenNodeViewed() {
+    // Create field.
+    $settings = array(
+      'instance[settings][enable_tokens]' => 0,
+    );
+    $field_name = $this->createLinkField('page',
+      $settings);
+
+    // Create page form.
+    $this->drupalGet('node/add/page');
+    // $field_name = 'field_' . $name;.
+    $this->assertField($field_name . '[und][0][title]', 'Title found');
+    $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+    $token_url_tests = array(
+      1 => array(
+        'href' => 'http://example.com/' . $this->randomName(),
+        'label' => $this->randomName(),
+      ),
+      2 => array(
+        'href' => 'http://example.com/' . $this->randomName() . '?property=value',
+        'label' => $this->randomName(),
+      ),
+      3 => array(
+        'href' => 'http://example.com/' . $this->randomName() . '#position',
+        'label' => $this->randomName(),
+      ),
+      4 => array(
+        'href' => 'http://example.com/' . $this->randomName() . '#lower?property=value2',
+        'label' => $this->randomName(),
+      ),
+    );
+
+    //@codingStandardsIgnoreLine
+    // $this->assert('pass', '<pre>' . print_r($token_url_tests, TRUE) . '<pre>');.
+    foreach ($token_url_tests as &$input) {
+      $this->drupalGet('node/add/page');
+
+      $edit = array(
+        'title' => $input['label'],
+        $field_name . '[und][0][title]' => $input['label'],
+        $field_name . '[und][0][url]' => $input['href'],
+      );
+      $this->drupalPost(NULL, $edit, t('Save'));
+      $url = $this->getUrl();
+      $input['url'] = $url;
+    }
+
+    // Change to anonymous user.
+    $this->drupalLogout();
+
+    foreach ($token_url_tests as $index => $input2) {
+      $node = node_load($index);
+      $this->assertNotEqual(NULL, $node, "Do we have a node?");
+      $this->assertEqual($node->nid, $index, "Test that we have a node.");
+      $token_name = '[node:' . str_replace('_', '-', $field_name) . ':url]';
+      $assert_data = token_replace($token_name,
+        array('node' => $node));
+      $this->assertEqual($input2['href'], $assert_data, "Test that the url token has been set to " . $input2['href'] . ' - ' . $assert_data);
+    }
+  }
+
+}

+ 25 - 16
sites/all/modules/link/tests/link.test

@@ -5,10 +5,15 @@
  * Link base test file - contains common functions for testing links.
  */
 
+/**
+ * Base Test Class.
+ */
 class LinkBaseTestClass extends DrupalWebTestCase {
-  public $permissions = array(
+
+  protected $permissions = array(
     'access content',
     'administer content types',
+    'administer fields',
     'administer nodes',
     'administer filters',
     'access comments',
@@ -17,21 +22,24 @@ class LinkBaseTestClass extends DrupalWebTestCase {
     'create page content',
   );
 
-  public $account;
-
-  function setUp($modules = array()) {
-    if ($modules) {
-      parent::setUp($modules);
-    }
-    else {
-      parent::setUp('field_ui', 'link');
-    }
-    $this->account = $this->drupalCreateUser($this->permissions);
-    $this->drupalLogin($this->account);
+  /**
+   * Setup.
+   */
+  public function setUp() {
+    $modules = func_get_args();
+    $modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules);
+    $modules[] = 'field_ui';
+    $modules[] = 'link';
+    parent::setUp($modules);
+
+    $this->web_user = $this->drupalCreateUser($this->permissions);
+    $this->drupalLogin($this->web_user);
   }
 
-  function createLinkField($node_type = 'page',
-                           $settings = array()) {
+  /**
+   * Create Link Field.
+   */
+  protected function createLinkField($node_type = 'page', $settings = array()) {
     $name = strtolower($this->randomName());
     $edit = array(
       'fields[_add_new_field][label]' => $name,
@@ -39,8 +47,8 @@ class LinkBaseTestClass extends DrupalWebTestCase {
       'fields[_add_new_field][type]' => 'link_field',
       'fields[_add_new_field][widget_type]' => 'link_field',
     );
-    $field_name = 'field_'. $name;
-    $this->drupalPost('admin/structure/types/manage/'. $node_type .'/fields', $edit, t('Save'));
+    $field_name = 'field_' . $name;
+    $this->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
     $this->drupalPost(NULL, array(), t('Save field settings'));
     $this->drupalPost(NULL, $settings, t('Save settings'));
 
@@ -51,4 +59,5 @@ class LinkBaseTestClass extends DrupalWebTestCase {
 
     return $field_name;
   }
+
 }

+ 207 - 110
sites/all/modules/link/tests/link.token.test

@@ -6,10 +6,13 @@
  */
 
 /**
- * Testing that tokens can be used in link titles
+ * Testing that tokens can be used in link titles.
  */
 class LinkTokenTest extends LinkBaseTestClass {
 
+  /**
+   * Get Info.
+   */
   public static function getInfo() {
     return array(
       'name' => 'Link tokens - browser test',
@@ -19,40 +22,38 @@ class LinkTokenTest extends LinkBaseTestClass {
     );
   }
 
-  function setUp($modules = array()) {
-    $modules[] = 'field_ui';
-    $modules[] = 'link';
-    $modules[] = 'token';
-    parent::setUp($modules);
+  /**
+   * Setup.
+   */
+  public function setUp($modules = array()) {
+    parent::setUp(array('token'));
   }
 
   /**
    * Creates a link field with a required title enabled for user-entered tokens.
+   *
    * Creates a node with a token in the link title and checks the value.
    */
-  function testUserTokenLinkCreate() {
-    /*$account = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
-    $this->drupalLogin($account);*/
-
-    // create field
+  public function testUserTokenLinkCreate() {
+    // Create field.
     $settings = array(
       'instance[settings][enable_tokens]' => 1,
     );
     $field_name = $this->createLinkField('page',
-                                        $settings);
+      $settings);
 
-    // create page form
+    // Create page form.
     $this->drupalGet('node/add/page');
-    //$field_name = 'field_' . $name;
+    // $field_name = 'field_' . $name;.
     $this->assertField($field_name . '[und][0][title]', 'Title found');
     $this->assertField($field_name . '[und][0][url]', 'URL found');
 
     $input = array(
-        'href' => 'http://example.com/' . $this->randomName(),
-        'label' => $this->randomName(),
+      'href' => 'http://example.com/' . $this->randomName(),
+      'label' => $this->randomName(),
     );
 
-    //$this->drupalLogin($account);
+    // $this->drupalLogin($this->web_user);.
     $this->drupalGet('node/add/page');
 
     $edit = array(
@@ -63,36 +64,37 @@ class LinkTokenTest extends LinkBaseTestClass {
     $this->drupalPost(NULL, $edit, t('Save'));
     $url = $this->getUrl();
 
-    // change to anonymous user
+    // Change to anonymous user.
     $this->drupalLogout();
     $this->drupalGet($url);
 
     $this->assertRaw(l($input['label'] . ' page', $input['href']));
   }
 
-
   /**
    * Creates a link field with a static title and an admin-entered token.
+   *
    * Creates a node with a link and checks the title value.
    */
-  function testStaticTokenLinkCreate() {
+  public function testStaticTokenLinkCreate() {
 
-    // create field
+    // Create field.
     $name = $this->randomName();
     $settings = array(
       'instance[settings][title]' => 'value',
-      'instance[settings][title_value]' => $name .' [node:content-type:machine-name]');
+      'instance[settings][title_value]' => $name . ' [node:content-type:machine-name]',
+    );
     $field_name = $this->createLinkField('page', $settings);
 
-    // create page form
+    // Create page form.
     $this->drupalGet('node/add/page');
     $this->assertField($field_name . '[und][0][url]', 'URL found');
 
     $input = array(
-      'href' => 'http://example.com/' . $this->randomName()
+      'href' => 'http://example.com/' . $this->randomName(),
     );
 
-    //$this->drupalLogin($account);
+    // $this->drupalLogin($this->web_user);.
     $this->drupalGet('node/add/page');
 
     $edit = array(
@@ -103,7 +105,7 @@ class LinkTokenTest extends LinkBaseTestClass {
 
     $url = $this->getUrl();
 
-    // change to anonymous user
+    // Change to anonymous user.
     $this->drupalLogout();
     $this->drupalGet($url);
 
@@ -112,30 +114,32 @@ class LinkTokenTest extends LinkBaseTestClass {
 
   /**
    * Creates a link field with a static title and an admin-entered token.
+   *
    * Creates a node with a link and checks the title value.
    *
    * Basically, I want to make sure the [title-raw] token works, because it's a
    * token that changes from node to node, where [type]'s always going to be the
    * same.
    */
-  function testStaticTokenLinkCreate2() {
+  public function testStaticTokenLinkCreate2() {
 
-    // create field
+    // Create field.
     $name = $this->randomName();
     $settings = array(
       'instance[settings][title]' => 'value',
-      'instance[settings][title_value]' => $name .' [node:title]');
+      'instance[settings][title_value]' => $name . ' [node:title]',
+    );
     $field_name = $this->createLinkField('page', $settings);
 
-    // create page form
+    // Create page form.
     $this->drupalGet('node/add/page');
     $this->assertField($field_name . '[und][0][url]', 'URL found');
 
     $input = array(
-      'href' => 'http://example.com/' . $this->randomName()
+      'href' => 'http://example.com/' . $this->randomName(),
     );
 
-    //$this->drupalLogin($account);
+    // $this->drupalLogin($this->web_user);.
     $this->drupalGet('node/add/page');
 
     $edit = array(
@@ -146,27 +150,32 @@ class LinkTokenTest extends LinkBaseTestClass {
 
     $url = $this->getUrl();
 
-    // change to anonymous user
+    // Change to anonymous user.
     $this->drupalLogout();
     $this->drupalGet($url);
 
-    $this->assertRaw(l($name .' '. $name, $input['href']));
+    $this->assertRaw(l($name . ' ' . $name, $input['href']));
   }
 
-  // This test doesn't seem to actually work, due to lack of 'title' in url.
-  function _test_Link_With_Title_Attribute_token_url_form() {
-   /* $this->loginWithPermissions($this->permissions);
+  /**
+   * This test doesn't seem to actually work, due to lack of 'title' in url.
+   *
+   * @codingStandardsIgnoreStart
+   */
+  public function _test_Link_With_Title_Attribute_token_url_form() {
+    // @codingStandardsIgnoreEnd
+    /* $this->loginWithPermissions($this->permissions);
     $this->acquireContentTypes(1);
     $field_settings = array(
-      'type' => 'link',
-      'widget_type' => 'link',
-      'type_name' => $this->content_types[0]->name,
-      'attributes' => array(
-        'class' => '',
-        'target' => 'default',
-        'rel' => 'nofollow',
-        'title' => '',
-      ),
+    'type' => 'link',
+    'widget_type' => 'link',
+    'type_name' => $this->content_types[0]->name,
+    'attributes' => array(
+    'class' => '',
+    'target' => 'default',
+    'rel' => 'nofollow',
+    'title' => '',
+    ),
     );
 
     $field = $this->createField($field_settings, 0);
@@ -176,10 +185,10 @@ class LinkTokenTest extends LinkBaseTestClass {
     $url_type = str_replace('_', '-', $this->content_types[0]->type);
 
     $edit = array('attributes[title]' => '['. $field_name .'-url]',
-                  'enable_tokens' => TRUE);
-
+    'enable_tokens' => TRUE);
+    // @codingStandardsIgnoreLine
     $this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
-                      $edit, t('Save field settings'));
+    $edit, t('Save field settings'));
     $this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));*/
     $name = $this->randomName();
     $settings = array(
@@ -189,40 +198,42 @@ class LinkTokenTest extends LinkBaseTestClass {
     $field_name = $this->createLinkField('page', $settings);
 
     // So, having saved this field_name, let's see if it works...
-    //$this->acquireNodes(1);
-
-    //$node = node_load($this->nodes[0]->nid);
-
-    //$this->drupalGet('node/'. $this->nodes[0]->nid);
-
+    // $this->acquireNodes(1);
+    // $node = node_load($this->nodes[0]->nid);
+    // $this->drupalGet('node/'. $this->nodes[0]->nid);.
     $edit = array();
     $test_link_url = 'http://www.example.com/test';
-    $edit[$field_name .'[und][0][url]'] = $test_link_url;
-    $title = 'title_'. $this->randomName(20);
-    $edit[$field_name .'[und][0][title]'] = $title;
+    $edit[$field_name . '[und][0][url]'] = $test_link_url;
+    $title = 'title_' . $this->randomName(20);
+    $edit[$field_name . '[und][0][title]'] = $title;
     $edit['title'] = $name;
 
     $this->drupalGet('node/add/page');
     $this->drupalPost(NULL, $edit, t('Save'));
 
     // Make sure we get a new version!
-    //$node = node_load($this->nodes[0]->nid, NULL, TRUE);
+    // $node = node_load($this->nodes[0]->nid, NULL, TRUE);.
     $this->assertText(t('Basic page @title has been updated.',
-                        array('@title' => $name)));
+      array('@title' => $name)));
 
-    //$this->drupalGet('node/'. $node->nid);
+    // $this->drupalGet('node/'. $node->nid);.
     $this->assertText($title, 'Make sure the link title/text shows');
-    $this->assertRaw(' title="'. $test_link_url .'"', "Do we show the link url as the title attribute?");
-    $this->assertNoRaw(' title="['. $field_name .'-url]"');
+    $this->assertRaw(' title="' . $test_link_url . '"', "Do we show the link url as the title attribute?");
+    $this->assertNoRaw(' title="[' . $field_name . '-url]"');
     $this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.'));
-    //$this->fail($this->content);
+    // $this->fail($this->content);.
   }
 
   /**
+   * Link With Title Attribute token title form.
+   *
    * If the title of the link is set to the title attribute, then the title
    * attribute isn't supposed to show.
+   *
+   * @codingStandardsIgnoreStart
    */
-  function _test_Link_With_Title_Attribute_token_title_form() {
+  public function _test_Link_With_Title_Attribute_token_title_form() {
+    // @codingStandardsIgnoreEnd
     $this->loginWithPermissions($this->permissions);
     $this->acquireContentTypes(1);
     $field_settings = array(
@@ -239,51 +250,61 @@ class LinkTokenTest extends LinkBaseTestClass {
 
     $field = $this->createField($field_settings, 0);
     $field_name = $field['field_name'];
-    $field_db_info = content_database_info($field);
     $url_type = str_replace('_', '-', $this->content_types[0]->type);
 
-    $edit = array('attributes[title]' => '['. $field_name .'-title]',
-                  'enable_tokens' => TRUE);
+    $edit = array(
+      'attributes[title]' => '[' . $field_name . '-title]',
+      'enable_tokens' => TRUE,
+    );
 
-    $this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
-                      $edit, t('Save field settings'));
+    $this->drupalPost('admin/content/node-type/' . $url_type . '/fields/' . $field['field_name'],
+      $edit, t('Save field settings'));
     $this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));
 
     // So, having saved this field_name, let's see if it works...
     $this->acquireNodes(1);
 
-    $node = node_load($this->nodes[0]->nid);
-
-    $this->drupalGet('node/'. $this->nodes[0]->nid);
+    $this->drupalGet('node/' . $this->nodes[0]->nid);
 
     $edit = array();
-    $edit[$field['field_name'] .'[0][url]'] = 'http://www.example.com/test';
-    $title = 'title_'. $this->randomName(20);
-    $edit[$field['field_name'] .'[0][title]'] = $title;
+    $edit[$field['field_name'] . '[0][url]'] = 'http://www.example.com/test';
+    $title = 'title_' . $this->randomName(20);
+    $edit[$field['field_name'] . '[0][title]'] = $title;
 
-    $this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
+    $this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
 
     // Make sure we get a new version!
     $node = node_load($this->nodes[0]->nid, NULL, TRUE);
     $this->assertText(t('@type @title has been updated.',
-                        array('@title' => $node->title,
-                              '@type' => $this->content_types[0]->name)));
+      array(
+        '@title' => $node->title,
+        '@type' => $this->content_types[0]->name,
+      )));
 
-    $this->drupalGet('node/'. $node->nid);
+    $this->drupalGet('node/' . $node->nid);
     $this->assertText($title, 'Make sure the link title/text shows');
-    $this->assertNoRaw(' title="'. $title .'"', "We should not show the link title as the title attribute?");
-    $this->assertNoRaw(' title="['. $field_name .'-title]"');
-    //$this->fail($this->content);
+    $this->assertNoRaw(' title="' . $title . '"', "We should not show the link title as the title attribute?");
+    $this->assertNoRaw(' title="[' . $field_name . '-title]"');
+    // $this->fail($this->content);.
   }
 
   /**
-   *  Trying to set the url to contain a token.
+   * Trying to set the url to contain a token.
+   *
+   * @codingStandardsIgnoreStart
    */
-  function _testUserTokenLinkCreateInURL() {
-    $account = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
-    $this->drupalLogin($account);
-
-    // create field
+  public function _testUserTokenLinkCreateInURL() {
+    //@codingStandardsIgnoreEnd
+
+    $this->web_user = $this->drupalCreateUser(array(
+      'administer content types',
+      'administer fields',
+      'access content',
+      'create page content',
+    ));
+    $this->drupalLogin($this->web_user);
+
+    // Create field.
     $name = strtolower($this->randomName());
     $edit = array(
       '_add_new_field[label]' => $name,
@@ -294,23 +315,24 @@ class LinkTokenTest extends LinkBaseTestClass {
     $this->drupalPost('admin/content/node-type/page/fields', $edit, t('Save'));
     $this->drupalPost(NULL, array(
       'title' => 'required',
-      'enable_tokens' => 1), t('Save field settings'));
+      'enable_tokens' => 1,