Browse Source

more module updates

Bachir Soussi Chiadmi 9 years ago
parent
commit
7c85261e56
100 changed files with 6506 additions and 830 deletions
  1. 3 3
      sites/all/modules/contrib/admin/admin/admin.info
  2. 1 1
      sites/all/modules/contrib/admin/admin_menu/README.txt
  3. 3 3
      sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info
  4. 1 2
      sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css
  5. 5 22
      sites/all/modules/contrib/admin/admin_menu/admin_menu.css
  6. 0 123
      sites/all/modules/contrib/admin/admin_menu/admin_menu.inc
  7. 3 3
      sites/all/modules/contrib/admin/admin_menu/admin_menu.info
  8. 4 3
      sites/all/modules/contrib/admin/admin_menu/admin_menu.install
  9. 0 12
      sites/all/modules/contrib/admin/admin_menu/admin_menu.js
  10. 35 52
      sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc
  11. 0 6
      sites/all/modules/contrib/admin/admin_menu/admin_menu.module
  12. 3 3
      sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info
  13. 1 1
      sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module
  14. 27 0
      sites/all/modules/contrib/admin/rules/fix_errors_on_update-2090511-214_2.patch
  15. 411 0
      sites/all/modules/contrib/admin/rules/includes/rules.event.inc
  16. 134 0
      sites/all/modules/contrib/admin/rules/rules.drush.inc
  17. 99 0
      sites/all/modules/contrib/admin/rules/rules_scheduler/includes/rules_scheduler.handler.inc
  18. 81 0
      sites/all/modules/contrib/admin/rules/rules_scheduler/rules_scheduler.drush.inc
  19. 24 0
      sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.inc
  20. 13 0
      sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.info
  21. 6 0
      sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.module
  22. 12 0
      sites/all/modules/contrib/admin/rules/tests/rules_test_invocation.info
  23. 13 0
      sites/all/modules/contrib/admin/rules/tests/rules_test_invocation.module
  24. 13 0
      sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc
  25. 14 0
      sites/all/modules/contrib/admin/uuid/uuid_services/uuid_services.admin.inc
  26. 31 0
      sites/all/modules/contrib/dev/prod_check/js/prod-check-database.js
  27. 12 0
      sites/all/modules/contrib/ecommerce/uc_restrict_qty/README.txt
  28. 2 2
      sites/all/modules/contrib/fields/addressfield/addressfield-rtl.css
  29. 442 0
      sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc
  30. 1037 0
      sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc
  31. 66 0
      sites/all/modules/contrib/fields/addressfield/addressfield.api.php
  32. 2 1
      sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc
  33. 5 3
      sites/all/modules/contrib/fields/addressfield/addressfield.info
  34. 30 0
      sites/all/modules/contrib/fields/addressfield/addressfield.install
  35. 172 0
      sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc
  36. 197 88
      sites/all/modules/contrib/fields/addressfield/addressfield.module
  37. 233 0
      sites/all/modules/contrib/fields/addressfield/addressfield.tokens.inc
  38. 3 3
      sites/all/modules/contrib/fields/addressfield/example/addressfield_example.info
  39. 0 0
      sites/all/modules/contrib/fields/addressfield/example/plugins/format/address-ch-example.inc
  40. 3 4
      sites/all/modules/contrib/fields/addressfield/plugins/format/address-hide-country.inc
  41. 24 0
      sites/all/modules/contrib/fields/addressfield/plugins/format/address-hide-postal-code.inc
  42. 24 0
      sites/all/modules/contrib/fields/addressfield/plugins/format/address-hide-street.inc
  43. 36 0
      sites/all/modules/contrib/fields/addressfield/plugins/format/address-optional.inc
  44. 174 356
      sites/all/modules/contrib/fields/addressfield/plugins/format/address.inc
  45. 16 3
      sites/all/modules/contrib/fields/addressfield/plugins/format/name-full.inc
  46. 8 1
      sites/all/modules/contrib/fields/addressfield/plugins/format/name-oneline.inc
  47. 8 1
      sites/all/modules/contrib/fields/addressfield/plugins/format/organisation.inc
  48. 71 2
      sites/all/modules/contrib/fields/addressfield/views/addressfield.views.inc
  49. 40 0
      sites/all/modules/contrib/fields/addressfield/views/addressfield_views_handler_field_country.inc
  50. 36 0
      sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe-rtl.css
  51. 1 1
      sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.css
  52. 3 3
      sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.info
  53. 22 10
      sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.js
  54. 10 2
      sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.module
  55. 1 1
      sites/all/modules/contrib/fields/cck_phone/cck_phone.css
  56. 67 0
      sites/all/modules/contrib/fields/cck_phone/cck_phone.feeds.inc
  57. 2 2
      sites/all/modules/contrib/fields/cck_phone/cck_phone.info
  58. 1 1
      sites/all/modules/contrib/fields/cck_phone/cck_phone.js
  59. 83 11
      sites/all/modules/contrib/fields/cck_phone/cck_phone.module
  60. 1 1
      sites/all/modules/contrib/fields/cck_phone/cck_phone_countrycodes.inc
  61. 3 3
      sites/all/modules/contrib/fields/computed_field/computed_field.info
  62. 1 1
      sites/all/modules/contrib/fields/computed_field/computed_field.module
  63. 31 24
      sites/all/modules/contrib/fields/serial/serial.inc
  64. 3 3
      sites/all/modules/contrib/fields/serial/serial.info
  65. 31 6
      sites/all/modules/contrib/fields/serial/serial.install
  66. 38 25
      sites/all/modules/contrib/fields/serial/serial.module
  67. 11 0
      sites/all/modules/contrib/fields/title/CHANGELOG.txt
  68. 13 0
      sites/all/modules/contrib/fields/title/MAINTAINERS.txt
  69. 3 3
      sites/all/modules/contrib/fields/title/tests/title_test.info
  70. 1 5
      sites/all/modules/contrib/fields/title/title.admin.inc
  71. 24 22
      sites/all/modules/contrib/fields/title/title.field.inc
  72. 3 3
      sites/all/modules/contrib/fields/title/title.info
  73. 50 1
      sites/all/modules/contrib/fields/title/title.module
  74. 6 4
      sites/all/modules/contrib/fields/title/views/title.views.inc
  75. BIN
      sites/all/modules/contrib/fields/video_embed_field/img/vimeo.jpg
  76. BIN
      sites/all/modules/contrib/fields/video_embed_field/img/youtube.jpg
  77. 5 0
      sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/README.txt
  78. BIN
      sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/img/brightcove.jpg
  79. 14 0
      sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/video_embed_brightcove.info
  80. 159 0
      sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/video_embed_brightcove.module
  81. BIN
      sites/all/modules/contrib/fields/video_embed_field/video_embed_facebook/img/facebook.jpg
  82. 94 0
      sites/all/modules/contrib/fields/video_embed_field/video_embed_field.devel_generate.inc
  83. 73 0
      sites/all/modules/contrib/fields/video_embed_field/video_embed_field.feeds.inc
  84. 57 0
      sites/all/modules/contrib/fields/video_embed_field/video_embed_field.migrate.inc
  85. 22 0
      sites/all/modules/contrib/fields/video_embed_field/views/handlers/views_embed_field_views_handler_field_thumbnail_path.inc
  86. 72 0
      sites/all/modules/contrib/fields/video_embed_field/views/video_embed_field.views.inc
  87. 22 0
      sites/all/modules/contrib/files/transliteration/transliteration.api.php
  88. 289 0
      sites/all/modules/contrib/taxonomy/synonyms/synonyms.pages.inc
  89. 17 0
      sites/all/modules/contrib/taxonomy/synonyms/views/synonyms.views.inc
  90. 163 0
      sites/all/modules/contrib/taxonomy/synonyms/views/synonyms_views_plugin_argument_validate_taxonomy_term.inc
  91. 8 0
      sites/all/modules/contrib/theming/colorbox/colorbox.make
  92. 77 0
      sites/all/modules/contrib/views/views_bulk_operations/actions/book.action.inc
  93. 81 0
      sites/all/modules/contrib/views/views_bulk_operations/actions/user_cancel.action.inc
  94. 1 0
      sites/all/modules/contrib/views/views_data_export/.gitignore
  95. 508 0
      sites/all/modules/contrib/views/views_data_export/tests/base.test
  96. 211 0
      sites/all/modules/contrib/views/views_data_export/tests/csv_export.test
  97. 48 0
      sites/all/modules/contrib/views/views_data_export/tests/doc_export.test
  98. 164 0
      sites/all/modules/contrib/views/views_data_export/tests/txt_export.test
  99. 48 0
      sites/all/modules/contrib/views/views_data_export/tests/xls_export.test
  100. 386 0
      sites/all/modules/contrib/views/views_data_export/tests/xml_export.test

+ 3 - 3
sites/all/modules/contrib/admin/admin/admin.info

@@ -13,9 +13,9 @@ files[] = theme/admin-panes.tpl.php
 files[] = theme/admin-toolbar.tpl.php
 files[] = theme/theme.inc
 
-; Information added by drupal.org packaging script on 2011-09-30
-version = "7.x-2.x-dev"
+; Information added by drupal.org packaging script on 2013-09-30
+version = "7.x-2.0-beta3+8-dev"
 core = "7.x"
 project = "admin"
-datestamp = "1317340920"
+datestamp = "1380552733"
 

+ 1 - 1
sites/all/modules/contrib/admin/admin_menu/README.txt

@@ -20,7 +20,7 @@ None.
 
 -- INSTALLATION --
 
-* Install as usual, see http://drupal.org/node/70151 for further information.
+* Install as usual, see http://drupal.org/node/895232 for further information.
 
 * You likely want to disable Toolbar module, since its output clashes with
   Administration menu.

+ 3 - 3
sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info

@@ -4,9 +4,9 @@ package = Administration
 core = 7.x
 scripts[] = admin_devel.js
 
-; Information added by drupal.org packaging script on 2013-01-31
-version = "7.x-3.0-rc4"
+; Information added by Drupal.org packaging script on 2014-12-19
+version = "7.x-3.0-rc5"
 core = "7.x"
 project = "admin_menu"
-datestamp = "1359651687"
+datestamp = "1419029284"
 

+ 1 - 2
sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css

@@ -32,8 +32,7 @@
 #admin-menu li li.expandable {
   background-color: #b93f3f;
 }
-#admin-menu li li:hover,
-#admin-menu li li.iehover {
+#admin-menu li li:hover {
   background-color: #690f0f;
 }
 #admin-menu li li.expandable:hover a,

+ 5 - 22
sites/all/modules/contrib/admin/admin_menu/admin_menu.css

@@ -98,6 +98,7 @@ body.admin-menu {
 #admin-menu .dropdown li li {
   background: #202020;
   filter: Alpha(opacity=88);
+  float: none;
   opacity: 0.88;
   width: 160px; /* Required for Opera */
 }
@@ -126,11 +127,7 @@ body.admin-menu {
 #admin-menu .dropdown li:hover ul ul,
 #admin-menu .dropdown li:hover ul ul ul,
 #admin-menu .dropdown li:hover ul ul ul ul,
-#admin-menu .dropdown li:hover ul ul ul ul ul,
-#admin-menu .dropdown li.iehover ul ul,
-#admin-menu .dropdown li.iehover ul ul ul,
-#admin-menu .dropdown li.iehover ul ul ul ul,
-#admin-menu .dropdown li.iehover ul ul ul ul ul {
+#admin-menu .dropdown li:hover ul ul ul ul ul {
   display: none;
   left: -999em; /* LTR */
 }
@@ -140,12 +137,7 @@ body.admin-menu {
 #admin-menu .dropdown li li:hover ul,
 #admin-menu .dropdown li li li:hover ul,
 #admin-menu .dropdown li li li li:hover ul,
-#admin-menu .dropdown li li li li li:hover ul,
-#admin-menu .dropdown li.iehover ul,
-#admin-menu .dropdown li li.iehover ul,
-#admin-menu .dropdown li li li.iehover ul,
-#admin-menu .dropdown li li li li.iehover ul,
-#admin-menu .dropdown li li li li li.iehover ul {
+#admin-menu .dropdown li li li li li:hover ul {
   display: block;
   left: auto; /* LTR */
 }
@@ -157,8 +149,7 @@ body.admin-menu {
 #admin-menu .dropdown li li.expandable {
   background: #45454A url(images/arrow.png) no-repeat 145px 6px;
 }
-#admin-menu .dropdown li li:hover,
-#admin-menu .dropdown li li.iehover {
+#admin-menu .dropdown li li:hover {
   background-color: #111;
 }
 #admin-menu .dropdown li li:hover a,
@@ -175,17 +166,9 @@ body.admin-menu {
 #admin-menu .dropdown li li.expandable:hover li.expandable:hover li a {
   border-color: #323232;
 }
-#admin-menu .dropdown li li:hover li a,
-#admin-menu .dropdown li li.iehover li a,
-#admin-menu .dropdown li li.iehover li.iehover li a {
+#admin-menu .dropdown li li:hover li a {
   color: #EEE;
 }
-#admin-menu .dropdown li li.iehover a,
-#admin-menu .dropdown li li.iehover li.iehover a,
-#admin-menu .dropdown li li.iehover li.iehover li.iehover a {
-  color: #FFF;
-  width: 90%; /* IE */
-}
 
 /* Search form */
 #admin-menu .admin-menu-search .form-item {

+ 0 - 123
sites/all/modules/contrib/admin/admin_menu/admin_menu.inc

@@ -497,18 +497,6 @@ function admin_menu_links_icon() {
     );
   }
 
-  // Add link to toggle developer modules (performance).
-  $saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
-  $links['icon']['toggle-modules'] = array(
-    '#title' => isset($saved_state) ? t('Enable developer modules') : t('Disable developer modules'),
-    '#weight' => 88,
-    '#access' => user_access('administer modules'),
-    '#href' => 'admin_menu/toggle-modules',
-    '#options' => array(
-      'query' => $destination + array('token' => drupal_get_token('admin_menu/toggle-modules')),
-    ),
-  );
-
   // Add Devel module menu links.
   if (module_exists('devel')) {
     $devel_tree = menu_build_tree('devel');
@@ -697,29 +685,6 @@ function admin_menu_theme_settings() {
     '#title' => t('Cache menu in client-side browser'),
     '#default_value' => variable_get('admin_menu_cache_client', 1),
   );
-  // Fetch all available modules manually, since module_list() only returns
-  // currently enabled modules, which makes this setting pointless if developer
-  // modules are currently disabled.
-  $all_modules = array();
-  $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' ORDER BY name ASC");
-  foreach ($result as $module) {
-    if (file_exists($module->filename)) {
-      $info = unserialize($module->info);
-      $all_modules[$module->name] = $info['name'];
-    }
-  }
-  $devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
-  $devel_modules = array_intersect_key($all_modules, array_flip($devel_modules));
-  $form['performance']['admin_menu_devel_modules_skip'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Developer modules to keep enabled'),
-    '#default_value' => variable_get('admin_menu_devel_modules_skip', array()),
-    '#options' => $devel_modules,
-    '#access' => !empty($devel_modules),
-    '#description' => t('The selected modules will not be disabled when the link %disable-developer-modules below the icon in the menu is invoked.', array(
-      '%disable-developer-modules' => t('Disable developer modules'),
-    )),
-  );
 
   return system_settings_form($form);
 }
@@ -783,94 +748,6 @@ function _admin_menu_form_devel_admin_settings_alter(&$form, $form_state) {
   );
 }
 
-/**
- * Menu callback; Enable/disable developer modules.
- *
- * This can save up to 150ms on each uncached page request.
- */
-function admin_menu_toggle_modules() {
-  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], current_path())) {
-    return MENU_ACCESS_DENIED;
-  }
-
-  $rebuild = FALSE;
-  $saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
-  if (isset($saved_state)) {
-    // Re-enable modules that were enabled before.
-    module_enable($saved_state);
-    variable_del('admin_menu_devel_modules_enabled');
-    drupal_set_message(t('Enabled these modules: !module-list.', array('!module-list' => implode(', ', $saved_state))));
-    $rebuild = TRUE;
-  }
-  else {
-    // Allow site admins to override this variable via settings.php.
-    $devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
-    // Store currently enabled modules in a variable.
-    $devel_modules = array_intersect(module_list(FALSE, FALSE), $devel_modules);
-    $devel_modules = array_diff($devel_modules, variable_get('admin_menu_devel_modules_skip', array()));
-    if (!empty($devel_modules)) {
-      variable_set('admin_menu_devel_modules_enabled', $devel_modules);
-      // Disable developer modules.
-      module_disable($devel_modules);
-      drupal_set_message(t('Disabled these modules: !module-list.', array('!module-list' => implode(', ', $devel_modules))));
-      $rebuild = TRUE;
-    }
-    else {
-      drupal_set_message(t('No developer modules are enabled.'));
-    }
-  }
-  if ($rebuild) {
-    // Make sure everything is rebuilt, basically a combination of the calls
-    // from system_modules() and system_modules_submit().
-    drupal_theme_rebuild();
-    menu_rebuild();
-    cache_clear_all('schema', 'cache');
-    cache_clear_all();
-    drupal_clear_css_cache();
-    drupal_clear_js_cache();
-    // Synchronize to catch any actions that were added or removed.
-    actions_synchronize();
-    // Finally, flush admin_menu's cache.
-    admin_menu_flush_caches();
-  }
-  drupal_goto();
-}
-
-/**
- * Helper function to return a default list of developer modules.
- */
-function _admin_menu_developer_modules() {
-  return array(
-    'admin_devel',
-    'cache_disable',
-    'coder',
-    'content_copy',
-    'context_ui',
-    'debug',
-    'delete_all',
-    'demo',
-    'devel',
-    'devel_node_access',
-    'devel_themer',
-    'field_ui',
-    'fontyourface_ui',
-    'form_controller',
-    'imagecache_ui',
-    'journal',
-    'l10n_client',
-    'l10n_update',
-    'macro',
-    'rules_admin',
-    'stringoverrides',
-    'trace',
-    'upgrade_status',
-    'user_display_ui',
-    'util',
-    'views_ui',
-    'views_theme_wizard',
-  );
-}
-
 /**
  * Flush all caches or a specific one.
  *

+ 3 - 3
sites/all/modules/contrib/admin/admin_menu/admin_menu.info

@@ -8,9 +8,9 @@ configure = admin/config/administration/admin_menu
 dependencies[] = system (>7.10)
 files[] = tests/admin_menu.test
 
-; Information added by drupal.org packaging script on 2013-01-31
-version = "7.x-3.0-rc4"
+; Information added by Drupal.org packaging script on 2014-12-19
+version = "7.x-3.0-rc5"
 core = "7.x"
 project = "admin_menu"
-datestamp = "1359651687"
+datestamp = "1419029284"
 

+ 4 - 3
sites/all/modules/contrib/admin/admin_menu/admin_menu.install

@@ -33,9 +33,6 @@ function admin_menu_install() {
 function admin_menu_uninstall() {
   // Delete variables.
   variable_del('admin_menu_components');
-  variable_del('admin_menu_devel_modules');
-  variable_del('admin_menu_devel_modules_enabled');
-  variable_del('admin_menu_devel_modules_skip');
   variable_del('admin_menu_margin_top');
   variable_del('admin_menu_position_fixed');
   variable_del('admin_menu_tweak_modules');
@@ -44,6 +41,10 @@ function admin_menu_uninstall() {
   variable_del('admin_menu_display');
   variable_del('admin_menu_cache_server');
   variable_del('admin_menu_cache_client');
+  // Unused variables still should be deleted.
+  variable_del('admin_menu_devel_modules');
+  variable_del('admin_menu_devel_modules_enabled');
+  variable_del('admin_menu_devel_modules_skip');
 }
 
 /**

+ 0 - 12
sites/all/modules/contrib/admin/admin_menu/admin_menu.js

@@ -219,18 +219,6 @@ Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) {
  *   it will not run last.
  */
 Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) {
-  // Hover emulation for IE 6.
-  if ($.browser.msie && parseInt(jQuery.browser.version) == 6) {
-    $('li', $adminMenu).hover(
-      function () {
-        $(this).addClass('iehover');
-      },
-      function () {
-        $(this).removeClass('iehover');
-      }
-    );
-  }
-
   // Delayed mouseout.
   $('li.expandable', $adminMenu).hover(
     function () {

+ 35 - 52
sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc

@@ -58,68 +58,52 @@ function node_admin_menu_map() {
 
 /**
  * Implements hook_admin_menu_map() on behalf of Field UI module.
+ *
+ * @todo Figure out how to fix the comment entity bundle mappings.
  */
 function field_ui_admin_menu_map() {
   $map = array();
-  foreach (entity_get_info() as $obj_type => $info) {
-    foreach ($info['bundles'] as $bundle_name => $bundle_info) {
-      if (isset($bundle_info['admin'])) {
-        $arguments = array();
-        switch ($obj_type) {
-          case 'comment':
-            $fields = array();
-            foreach (field_info_instances($obj_type, $bundle_name) as $field) {
-              $fields[] = $field['field_name'];
-            }
-            // @todo Make Comment module expose the original node type bundle,
-            //   pretty please.
-            if (drupal_substr($bundle_name, 0, 13) == 'comment_node_') {
-              $bundle_name = drupal_substr($bundle_name, 13);
-            }
-            // @todo Doesn't work yet. Why?
-            $arguments = array(
-              '%comment_node_type' => array($bundle_name),
-              '%field_ui_menu' => $fields,
-            );
-            break;
 
-          case 'node':
-            $fields = array();
-            foreach (field_info_instances($obj_type, $bundle_name) as $field) {
-              $fields[] = $field['field_name'];
-            }
-            $arguments = array(
-              '%node_type' => array($bundle_name),
-              '%field_ui_menu' => $fields,
-            );
-            break;
+  foreach (entity_get_info() as $entity_type => $entity_info) {
+    if (!$entity_info['fieldable']) {
+      continue;
+    }
+
+    foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
+      // @see field_ui_menu()
+      if (!isset($bundle_info['admin'])) {
+        continue;
+      }
 
-          case 'taxonomy_term':
-            $fields = array();
-            foreach (field_info_instances($obj_type, $bundle_name) as $field) {
-              $fields[] = $field['field_name'];
-            }
-            // Map machine_name to vid.
-            $arguments = array(
-              '%taxonomy_vocabulary_machine_name' => array($bundle_name),
-              '%field_ui_menu' => $fields,
-            );
-            break;
+      // Check access to this bundle.
+      $bundle_info['admin'] += array(
+        'access callback' => 'user_access',
+        'access arguments' => array('administer site configuration'),
+      );
+      if (!call_user_func_array($bundle_info['admin']['access callback'], $bundle_info['admin']['access arguments'])) {
+        continue;
+      }
 
-          case 'user':
-            $arguments = array(
-              '%field_ui_menu' => array_keys(field_info_fields('user')),
-            );
-            break;
+      if ($fields = field_info_instances($entity_type, $bundle)) {
+        $path = $bundle_info['admin']['path'];
+        $argument = array();
+        if (isset($bundle_info['admin']['bundle argument'])) {
+          $bundle_arg = arg($bundle_info['admin']['bundle argument'], $path);
+          $argument[$bundle_arg] = array($bundle);
         }
-        if (!empty($arguments)) {
-          $path = $bundle_info['admin']['path'];
-          $map["$path/fields/%field_ui_menu"]['parent'] = "$path/fields";
-          $map["$path/fields/%field_ui_menu"]['arguments'][] = $arguments;
+        $argument['%field_ui_menu'] = array_keys($fields);
+
+        if (!isset($map["$path/fields/%field_ui_menu"])) {
+          $map["$path/fields/%field_ui_menu"] = array(
+            'parent' => "$path/fields",
+            'arguments' => array(),
+          );
         }
+        $map["$path/fields/%field_ui_menu"]['arguments'][] = $argument;
       }
     }
   }
+
   return $map;
 }
 
@@ -161,4 +145,3 @@ function views_ui_admin_menu_map() {
   );
   return $map;
 }
-

+ 0 - 6
sites/all/modules/contrib/admin/admin_menu/admin_menu.module

@@ -87,12 +87,6 @@ function admin_menu_menu() {
     'file' => 'admin_menu.inc',
   );
   // Menu link callbacks.
-  $items['admin_menu/toggle-modules'] = array(
-    'page callback' => 'admin_menu_toggle_modules',
-    'access arguments' => array('administer modules'),
-    'type' => MENU_CALLBACK,
-    'file' => 'admin_menu.inc',
-  );
   $items['admin_menu/flush-cache'] = array(
     'page callback' => 'admin_menu_flush_cache',
     'access arguments' => array('flush caches'),

+ 3 - 3
sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info

@@ -4,9 +4,9 @@ package = Administration
 core = 7.x
 dependencies[] = admin_menu
 
-; Information added by drupal.org packaging script on 2013-01-31
-version = "7.x-3.0-rc4"
+; Information added by Drupal.org packaging script on 2014-12-19
+version = "7.x-3.0-rc5"
 core = "7.x"
 project = "admin_menu"
-datestamp = "1359651687"
+datestamp = "1419029284"
 

+ 1 - 1
sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module

@@ -70,7 +70,7 @@ function admin_menu_toolbar_admin_menu_output_build(&$content) {
     '#title' => t('Show shortcuts'),
     '#href' => '',
     '#options' => array(
-      'attributes' => array('class' => 'shortcut-toggle'),
+      'attributes' => array('class' => array('shortcut-toggle')),
     ),
   );
 

+ 27 - 0
sites/all/modules/contrib/admin/rules/fix_errors_on_update-2090511-214_2.patch

@@ -0,0 +1,27 @@
+diff --git a/rules.module b/rules.module
+index 719852c..9e4ec8f 100644
+--- a/rules.module
++++ b/rules.module
+@@ -8,6 +8,22 @@
+ // hook_init().
+ require_once dirname(__FILE__) . '/modules/events.inc';
+ 
++/** Rules >=2.4 introduces a class called 'RulesEventHandlerEntityBundle' found in
++ * 'includes/rules.event.inc', so we include this file for versions older than 2.4
++ * in order to prevent a bug at node/2090511.
++ */
++$result = db_query("SELECT schema_version FROM {system} WHERE name = :name", array(
++  ':name' => 'rules',
++));
++
++if ($result) {
++  while ($row = $result->fetchAssoc()) {
++    if ($row['schema_version'] <7210) {
++      require_once dirname(__FILE__) . '/includes/rules.event.inc';
++    }
++  }
++}
++
+ /**
+  * Implements hook_module_implements_alter().
+  */

+ 411 - 0
sites/all/modules/contrib/admin/rules/includes/rules.event.inc

@@ -0,0 +1,411 @@
+<?php
+
+/**
+ * @file
+ * Contains event handler interface and base classes.
+ */
+
+/**
+ * Interface for handling rules events.
+ *
+ * Configurable events (i.e. events making use of settings) have a custom
+ * event suffix, which gets appended to the base event name. The configured
+ * event name of, e.g. the event for viewing an article node, would be
+ * node_view--article, whereas "node_view" is the base event name and "article"
+ * the event suffix as returned from
+ * RulesEventHandlerInterface::getEventNameSuffix(). The event suffix is
+ * generated based upon the event settings and must map to this settings, i.e.
+ * each set of event settings must always generate the same suffix.
+ * For a configurable event to be invoked, rules_invoke_event() has to be called
+ * with the configured event name, e.g.
+ * @code
+ * rules_invoke_event('node_view--' . $node->type, $node, $view_mode);
+ * @endcode
+ * If the event settings are optional, both events have to be invoked whereas
+ * usually the more general event is invoked last. E.g.:
+ * @code
+ * rules_invoke_event('node_view--' . $node->type, $node, $view_mode);
+ * rules_invoke_event('node_view', $node, $view_mode);
+ * @endcode
+ *
+ * Rules event handlers have to be declared using the 'class' key in
+ * hook_rules_event_info(), or may be discovered automatically, see
+ * rules_discover_plugins() for details.
+ *
+ * @see RulesEventHandlerBase
+ * @see RulesEventDefaultHandler
+ */
+interface RulesEventHandlerInterface {
+
+  /**
+   * Constructs the event handler.
+   *
+   * @param string $event_name
+   *   The base event string.
+   * @param array $info
+   *   The event info of the given event.
+   */
+  public function __construct($event_name, $info);
+
+  /**
+   * Sets the event settings.
+   *
+   * @param array $settings
+   *   An array of settings to set.
+   *
+   * @return RulesEventHandlerInterface
+   *   The handler itself for chaining.
+   */
+  public function setSettings(array $settings);
+
+  /**
+   * Gets the event settings.
+   *
+   * @return array
+   *   The array of settings.
+   */
+  public function getSettings();
+
+  /**
+   * Returns an array of default settings.
+   *
+   * @return array
+   */
+  public function getDefaults();
+
+  /**
+   * Returns a user-facing summary of the settings.
+   *
+   * @return string
+   *   The summary in HTML, i.e. properly escaped or filtered.
+   */
+  public function summary();
+
+  /**
+   * Builds the event settings form.
+   *
+   * @param array $form_state
+   *   An associative array containing the current state of the form.
+   *
+   * @return array
+   *   The form structure.
+   */
+  public function buildForm(array &$form_state);
+
+  /**
+   * Validate the event settings independent from a form submission.
+   *
+   * @throws RulesIntegrityException
+   *   In case of validation errors, RulesIntegrityExceptions are thrown.
+   */
+  public function validate();
+
+  /**
+   * Extract the form values and update the event settings.
+   *
+   * @param array $form
+   *   An associative array containing the structure of the form.
+   * @param array $form_state
+   *   An associative array containing the current state of the form.
+   */
+  public function extractFormValues(array &$form, array &$form_state);
+
+  /**
+   * Returns the suffix to be added to the base event named based upon settings.
+   *
+   * If event settings are used, the event name Rules uses for the configured
+   * event is {EVENT_NAME}--{SUFFIX}.
+   *
+   * @return string
+   *   The suffix string. Return an empty string for not appending a suffix.
+   */
+  public function getEventNameSuffix();
+
+  /**
+   * Returns info about the variables provided by this event.
+   *
+   * @return array
+   *   An array of provided variables, keyed by variable names and with the
+   *   variable info array as value.
+   */
+  public function availableVariables();
+
+  /**
+   * Returns the base name of the event the event handler belongs to.
+   *
+   * @return string
+   *   The name of the event the event handler belongs to.
+   */
+  public function getEventName();
+
+  /**
+   * Returns the info array of the event the event handler belongs to.
+   *
+   * @return string
+   *   The info array of the event the event handler belongs to.
+   */
+  public function getEventInfo();
+}
+
+/**
+ * Interface for event dispatchers.
+ */
+interface RulesEventDispatcherInterface extends RulesEventHandlerInterface {
+
+  /**
+   * Starts the event watcher.
+   */
+  public function startWatching();
+
+  /**
+   * Stops the event watcher.
+   */
+  public function stopWatching();
+
+  /**
+   * Returns whether the event dispatcher is currently active.
+   *
+   * @return bool
+   *   TRUE if the event dispatcher is currently active, FALSE otherwise.
+   */
+  public function isWatching();
+}
+
+/**
+ * Base class for event handler.
+ */
+abstract class RulesEventHandlerBase implements RulesEventHandlerInterface {
+
+  /**
+   * The event name.
+   *
+   * @var string
+   */
+  protected $eventName;
+
+  /**
+   * The event info.
+   *
+   * @var array
+   */
+  protected $eventInfo;
+
+  /**
+   * The event settings.
+   *
+   * @var array
+   */
+  protected $settings = array();
+
+  /**
+   * Implements RulesEventHandlerInterface::__construct()
+   */
+  public function __construct($event_name, $info) {
+    $this->eventName = $event_name;
+    $this->eventInfo = $info;
+    $this->settings = $this->getDefaults();
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getSettings()
+   */
+  public function getSettings() {
+    return $this->settings;
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::setSettings()
+   */
+  public function setSettings(array $settings) {
+    $this->settings = $settings + $this->getDefaults();
+    return $this;
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::validate()
+   */
+  public function validate() {
+    // Nothing to check by default.
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::extractFormValues()
+   */
+  public function extractFormValues(array &$form, array &$form_state) {
+    foreach ($this->getDefaults() as $key => $setting) {
+      $this->settings[$key] = isset($form_state['values'][$key]) ? $form_state['values'][$key] : $setting;
+    }
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::availableVariables()
+   */
+  public function availableVariables() {
+    return isset($this->eventInfo['variables']) ? $this->eventInfo['variables'] : array();
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getEventName()
+   */
+  public function getEventName() {
+    return $this->eventName;
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getEventInfo()
+   */
+  public function getEventInfo() {
+    return $this->eventInfo;
+  }
+}
+
+/**
+ * A handler for events having no settings. This is the default handler.
+ */
+class RulesEventDefaultHandler extends RulesEventHandlerBase  {
+
+  /**
+   * Implements RulesEventHandlerInterface::buildForm()
+   */
+  public function buildForm(array &$form_state) {
+    return array();
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getConfiguredEventName()
+   */
+  public function getEventNameSuffix() {
+    return '';
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::summary()
+   */
+  public function summary() {
+    return check_plain($this->eventInfo['label']);
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getDefaults()
+   */
+  public function getDefaults() {
+    return array();
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getSettings()
+   */
+  public function getSettings() {
+    return NULL;
+  }
+}
+
+/**
+ * Exposes the bundle of an entity as event setting.
+ */
+class RulesEventHandlerEntityBundle extends RulesEventHandlerBase {
+
+  protected $entityType, $entityInfo, $bundleKey;
+
+  /**
+   * Implements RulesEventHandlerInterface::__construct()
+   */
+  public function __construct($event_name, $info) {
+    parent::__construct($event_name, $info);
+    // Cut off the suffix, e.g. remove 'view' from node_view.
+    $this->entityType = implode('_', explode('_', $event_name, -1));
+    $this->entityInfo = entity_get_info($this->entityType);
+    if (!$this->entityInfo) {
+      throw new InvalidArgumentException('Unsupported event name passed.');
+    }
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::summary()
+   */
+  public function summary() {
+    $bundle = &$this->settings['bundle'];
+    $bundle_label = isset($this->entityInfo['bundles'][$bundle]['label']) ? $this->entityInfo['bundles'][$bundle]['label'] : $bundle;
+    $suffix = isset($bundle) ? ' ' . t('of @bundle-key %name', array('@bundle-key' => $this->getBundlePropertyLabel(), '%name' => $bundle_label)) : '';
+    return check_plain($this->eventInfo['label']) . $suffix;
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::buildForm()
+   */
+  public function buildForm(array &$form_state) {
+    $form['bundle'] = array(
+      '#type' => 'select',
+      '#title' => t('Restrict by @bundle', array('@bundle' => $this->getBundlePropertyLabel())),
+      '#description' => t('If you need to filter for multiple values, either add multiple events or use the "Entity is of bundle" condition instead.'),
+      '#default_value' => $this->settings['bundle'],
+      '#empty_value' => '',
+    );
+    foreach ($this->entityInfo['bundles'] as $name => $bundle_info) {
+      $form['bundle']['#options'][$name] = $bundle_info['label'];
+    }
+    return $form;
+  }
+
+  /**
+   * Returns the label to use for the bundle property.
+   *
+   * @return string
+   */
+  protected function getBundlePropertyLabel() {
+    return $this->entityInfo['entity keys']['bundle'];
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::extractFormValues()
+   */
+  public function extractFormValues(array &$form, array &$form_state) {
+    $this->settings['bundle'] = !empty($form_state['values']['bundle']) ? $form_state['values']['bundle'] : NULL;
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::validate()
+   */
+  public function validate() {
+    if ($this->settings['bundle'] && empty($this->entityInfo['bundles'][$this->settings['bundle']])) {
+      throw new RulesIntegrityException(t('The @bundle %bundle of %entity_type is not known.',
+        array(
+          '%bundle' => $this->settings['bundle'],
+          '%entity_type' => $this->entityInfo['label'],
+          '@bundle' => $this->getBundlePropertyLabel(),
+      )), array(NULL, 'bundle'));
+    }
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getConfiguredEventName()
+   */
+  public function getEventNameSuffix() {
+    return $this->settings['bundle'];
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::getDefaults()
+   */
+  public function getDefaults() {
+    return array(
+      'bundle' => NULL,
+    );
+  }
+
+  /**
+   * Implements RulesEventHandlerInterface::availableVariables()
+   */
+  public function availableVariables() {
+    $variables = $this->eventInfo['variables'];
+    if ($this->settings['bundle']) {
+      // Add the bundle to all variables of the entity type.
+      foreach ($variables as $name => $variable_info) {
+        if ($variable_info['type'] == $this->entityType) {
+          $variables[$name]['bundle'] = $this->settings['bundle'];
+        }
+      }
+    }
+    return $variables;
+  }
+}

+ 134 - 0
sites/all/modules/contrib/admin/rules/rules.drush.inc

@@ -0,0 +1,134 @@
+<?php
+
+/**
+ * @file
+ * Rules module drush integration.
+ */
+
+/**
+ * Implements hook_drush_command().
+ *
+ * @return
+ *   An associative array describing your command(s).
+ *
+ * @see drush_parse_command()
+ */
+function rules_drush_command() {
+  $items = array();
+
+  $items['rules-list'] = array(
+    'description' => "List all the active and inactive rules for your site.",
+    'drupal dependencies' => array('rules'),
+    'aliases' => array('rules'),
+  );
+  $items['rules-enable'] = array(
+    'description' => "Enable a rule on your site.",
+    'arguments' => array(
+      'rule' => 'Rule name to enable.',
+    ),
+    'drupal dependencies' => array('rules'),
+    'aliases' => array('re'),
+  );
+  $items['rules-disable'] = array(
+    'description' => "Disable a rule on your site.",
+    'arguments' => array(
+      'rule' => 'Rule name to export.',
+    ),
+    'drupal dependencies' => array('rules'),
+    'aliases' => array('rd'),
+  );
+
+  return $items;
+}
+
+/**
+ * Implements hook_drush_help().
+ */
+function rules_drush_help($section) {
+  switch ($section) {
+    case 'drush:rules':
+      return dt("List all the rules on your site.");
+    case 'drush:rules-enable':
+      return dt("Enable/activate a rule on your site.");
+    case 'drush:rules-disable':
+      return dt("Disable/deactivate a rule on your site.");
+  }
+}
+
+/**
+ * Get a list of all rules.
+ */
+function drush_rules_list() {
+  $rules = rules_config_load_multiple(FALSE);
+  $rows = array(array(dt('Rule'), dt('Label'), dt('Event'), dt('Active'), dt('Status')));
+  foreach ($rules as $rule) {
+    if (!empty($rule->name) && !empty($rule->label)) {
+      $events = array();
+      $event_info = rules_fetch_data('event_info');
+      if ($rule instanceof RulesTriggerableInterface) {
+        foreach ($rule->events() as $event_name) {
+          $event_info += array($event_name => array('label' => dt('Unknown event "!event_name"', array('!event_name' => $event_name))));
+          $events[] = check_plain($event_info[$event_name]['label']);
+        }
+      }
+      $rows[] = array(
+        $rule->name,
+        $rule->label,
+        implode(', ', $events),
+        $rule->active ? dt('Enabled') : dt('Disabled'),
+        $rule->status ? theme('entity_status', array('status' => $rule->status, 'html' => FALSE)) : '',
+      );
+    }
+  }
+  drush_print_table($rows, TRUE);
+}
+
+/**
+ * Enable a rule on the site.
+ */
+function drush_rules_enable() {
+  $args = func_get_args();
+  $rule_name = (!empty($args) && is_array($args)) ? array_shift($args) : '';
+  if (empty($rule_name)) {
+    return drush_set_error('', 'No rule name given.');
+  }
+
+  $rule = rules_config_load($rule_name);
+  if (empty($rule)) {
+    return drush_set_error('', dt('Could not load rule named "!rule-name".', array('!rule-name' => $rule_name)));
+  }
+
+  if (empty($rule->active)) {
+    $rule->active = TRUE;
+    $rule->save();
+    drush_log(dt('The rule "!name" has been enabled.', array('!name' => $rule_name)), 'success');
+  }
+  else {
+    drush_log(dt('The rule "!name" is already enabled.', array('!name' => $rule_name)), 'warning');
+  }
+}
+
+/**
+ * Disable a rule on the site.
+ */
+function drush_rules_disable() {
+  $args = func_get_args();
+  $rule_name = (!empty($args) && is_array($args)) ? array_shift($args) : '';
+  if (empty($rule_name)) {
+    return drush_set_error('', 'No rule name given.');
+  }
+
+  $rule = rules_config_load($rule_name);
+  if (empty($rule)) {
+    return drush_set_error('', dt('Could not load rule named "!rule-name".', array('!rule-name' => $rule_name)));
+  }
+
+  if (!empty($rule->active)) {
+    $rule->active = FALSE;
+    $rule->save();
+    drush_log(dt('The rule "!name" has been disabled.', array('!name' => $rule_name)), 'success');
+  }
+  else {
+    drush_log(dt('The rule "!name" is already disabled.', array('!name' => $rule_name)), 'warning');
+  }
+}

+ 99 - 0
sites/all/modules/contrib/admin/rules/rules_scheduler/includes/rules_scheduler.handler.inc

@@ -0,0 +1,99 @@
+<?php
+
+/**
+ * Default scheduled task handler.
+ */
+class RulesSchedulerDefaultTaskHandler implements RulesSchedulerTaskHandlerInterface {
+
+  /**
+   * The task array.
+   *
+   * @var array
+   */
+  protected $task;
+
+  /**
+   * Constructs a repetitive task handler object.
+   */
+  public function __construct(array $task) {
+    $this->task = $task;
+  }
+
+  /**
+   * Implements RulesSchedulerTaskHandlerInterface::runTask().
+   */
+  public function runTask() {
+    if ($component = rules_get_cache('comp_' . $this->task['config'])) {
+      $replacements = array('%label' => $component->label(), '%plugin' => $component->plugin());
+      $replacements['%identifier'] = $this->task['identifier'] ? $this->task['identifier'] : t('without identifier');
+      rules_log('Scheduled evaluation of %plugin %label, task %identifier.', $replacements, RulesLog::INFO, $component, TRUE);
+      $state = unserialize($this->task['data']);
+      $state->restoreBlocks();
+      // Block the config to prevent any future recursion.
+      $state->block($component);
+      // Finally evaluate the component with the given state.
+      $component->evaluate($state);
+      $state->unblock($component);
+      rules_log('Finished evaluation of %plugin %label, task %identifier.', $replacements, RulesLog::INFO, $component, FALSE);
+      $state->cleanUp();
+    }
+  }
+
+  /**
+   * Implements RulesSchedulerTaskHandlerInterface::afterTaskQueued().
+   */
+  public function afterTaskQueued() {
+    // Delete the task from the task list.
+    db_delete('rules_scheduler')
+      ->condition('tid', $this->task['tid'])
+      ->execute();
+  }
+
+  /**
+   * Implements RulesSchedulerTaskHandlerInterface::getTask().
+   */
+  public function getTask() {
+    return $this->task;
+  }
+
+}
+
+/**
+ * Interface for scheduled task handlers.
+ *
+ * Task handlers control the behavior of a task when it's queued or executed.
+ * Unless specified otherwise, the RulesSchedulerDefaultTaskHandler task handler
+ * is used.
+ *
+ * @see rules_scheduler_run_task()
+ * @see rules_scheduler_cron()
+ * @see RulesSchedulerDefaultTaskHandler
+ */
+interface RulesSchedulerTaskHandlerInterface {
+
+  /**
+   * Processes a queue item.
+   *
+   * @throws RulesEvaluationException
+   *   If there are any problems executing the task.
+   *
+   * @see rules_scheduler_run_task()
+   */
+  public function runTask();
+
+  /**
+   * Processes a task after it has been queued.
+   *
+   * @see rules_scheduler_cron()
+   */
+  public function afterTaskQueued();
+
+  /**
+   * Returns the task associated with the task handler.
+   *
+   * @return array
+   *   The task (queue item) array.
+   */
+  public function getTask();
+
+}

+ 81 - 0
sites/all/modules/contrib/admin/rules/rules_scheduler/rules_scheduler.drush.inc

@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * @file
+ * Rules Scheduler Drush integration.
+ */
+
+/**
+ * Implements hook_drush_command().
+ */
+function rules_scheduler_drush_command() {
+  $items = array();
+
+  $items['rules-scheduler-tasks'] = array(
+    'description' => 'Checks for scheduled tasks to be added to the queue.',
+    'options' => array(
+      'claim' => 'Optionally claim tasks from the queue to work on. Any value set will override the default time spent on this queue.',
+    ),
+    'drupal dependencies' => array('rules', 'rules_scheduler'),
+    'aliases' => array('rusch'),
+    'examples' => array(
+      'drush rusch' => 'Add scheduled tasks to the queue.',
+      'drush rusch --claim' => 'Add scheduled tasks to the queue and claim items for the default amount of time.',
+      'drush rusch --claim=30' => 'Add schedules tasks to the queue and claim items for 30 seconds.',
+    ),
+  );
+
+  return $items;
+}
+
+/**
+ * Implements hook_drush_help().
+ */
+function rules_scheduler_drush_help($section) {
+  switch ($section) {
+    case 'drush:rules-scheduler-tasks':
+      return dt('Checks for scheduled tasks to be added the queue. Can optionally claim tasks from the queue to work on.');
+  }
+}
+
+/**
+ * Command callback for processing the rules_scheduler_tasks queue.
+ *
+ * @see rules_scheduler_cron_queue_info().
+ * @see rules_scheduler_cron().
+ */
+function drush_rules_scheduler_tasks() {
+  if (rules_scheduler_queue_tasks()) {
+    // hook_exit() is not invoked for drush runs, so register it as shutdown
+    // callback for logging the rules log to the watchdog.
+    drupal_register_shutdown_function('rules_exit');
+    // Clear the log before running tasks via the queue to avoid logging
+    // unrelated logs from previous operations.
+    RulesLog::logger()->clear();
+    drush_log(dt('Added scheduled tasks to the queue.'), 'success');
+  }
+
+  $claim = drush_get_option('claim', FALSE);
+  if ($claim) {
+    // Fetch the queue information and let other modules alter it.
+    $queue_name = 'rules_scheduler_tasks';
+    $info = module_invoke('rules_scheduler', 'cron_queue_info');
+    drupal_alter('cron_queue_info', $info);
+
+    $function = $info[$queue_name]['worker callback'];
+    // The drush option can override the default process time.
+    $time = is_numeric($claim) ? (int) $claim : $info[$queue_name]['time'];
+    $end = time() + $time;
+    // Claim items and process the queue.
+    $queue = DrupalQueue::get($queue_name);
+    $claimed = 0;
+    while (time() < $end && ($item = $queue->claimItem())) {
+      $function($item->data);
+      $queue->deleteItem($item);
+      $claimed++;
+    }
+    if ($claimed) {
+      drush_log(dt('Claimed and worked on !claimed scheduled tasks for up to !time seconds.', array('!claimed' => $claimed, '!time' => $time)), 'success');
+    }
+  }
+}

+ 24 - 0
sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.inc

@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @file
+ * Include file for Rules Scheduler tests.
+ */
+
+/**
+ * Test task handler class.
+ */
+class RulesTestTaskHandler extends RulesSchedulerDefaultTaskHandler {
+
+  /**
+   * Overrides RulesSchedulerDefaultTaskHandler::runTask().
+   */
+  public function runTask() {
+    $task = $this->getTask();
+    $data = unserialize($task['data']);
+
+    // Set the variable defined in the test to TRUE.
+    variable_set($data['variable'], TRUE);
+  }
+
+}

+ 13 - 0
sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.info

@@ -0,0 +1,13 @@
+name = "Rules Scheduler Tests"
+description = "Support module for the Rules Scheduler tests."
+package = Testing
+core = 7.x
+files[] = rules_scheduler_test.inc
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2015-03-16
+version = "7.x-2.9"
+core = "7.x"
+project = "rules"
+datestamp = "1426527210"
+

+ 6 - 0
sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.module

@@ -0,0 +1,6 @@
+<?php
+
+/**
+ * @file
+ * Rules Scheduler test module.
+ */

+ 12 - 0
sites/all/modules/contrib/admin/rules/tests/rules_test_invocation.info

@@ -0,0 +1,12 @@
+name = "Rules Test invocation"
+description = "Helper module to test Rules invocations."
+package = Testing
+core = 7.x
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2015-03-16
+version = "7.x-2.9"
+core = "7.x"
+project = "rules"
+datestamp = "1426527210"
+

+ 13 - 0
sites/all/modules/contrib/admin/rules/tests/rules_test_invocation.module

@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * @file
+ * Helper module for Rules invocation testing.
+ */
+
+/**
+ * Implements hook_node_load().
+ */
+function rules_test_invocation_node_load($nodes, $types) {
+  rules_invoke_event('rules_test_event');
+}

+ 13 - 0
sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc

@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Implements hook_token_info()
+ */
+function token_test_token_info() {
+  $info['tokens']['node']['colons:in:name'] = array(
+    'name' => t('A test token with colons in the name'),
+    'description' => NULL,
+  );
+
+  return $info;
+}

+ 14 - 0
sites/all/modules/contrib/admin/uuid/uuid_services/uuid_services.admin.inc

@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * Settings form for UUID Services.
+ */
+function uuid_services_settings() {
+  $form['uuid_services_support_all_entity_types'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Support all UUID entity types'),
+    '#description' => t('Check this box to automatically provide Services integration for all entity types with UUID support.'),
+    '#default_value' => variable_get('uuid_services_support_all_entity_types', FALSE),
+  );
+  return system_settings_form($form);
+}

+ 31 - 0
sites/all/modules/contrib/dev/prod_check/js/prod-check-database.js

@@ -0,0 +1,31 @@
+(function ($) {
+
+  // Show / hide detailed db info.
+
+  Drupal.behaviors.prod_check = {
+    attach: function(context, settings) {
+      $('#content').find('a.show-more').unbind('click').bind('click', function(e) {
+        e.preventDefault();
+
+        var $this = $(this),
+            details = $this.attr('data-details'),
+            hide = Drupal.t('Hide details'),
+            show = Drupal.t('Show details'),
+            active = 'expanded';
+
+        if ($this.hasClass(active)) {
+          $('#content').find('pre.' + details).hide();
+          $this.text(show);
+          $this.removeClass(active);
+        }
+        else {
+          $('#content').find('pre.' + details).show();
+          $this.text(hide);
+          $this.addClass(active);
+        }
+      });
+    }
+  };
+
+})(jQuery);
+

+ 12 - 0
sites/all/modules/contrib/ecommerce/uc_restrict_qty/README.txt

@@ -0,0 +1,12 @@
+Ubercart Restrict Qty lets you add a very basic Restrict Qty. to a product in your Ubercart store to limit the quantity of that product in the shopping cart to 1. This is useful for single purchase products or for instances where it just doesn't make sense for a customer to purchase more than one and you want to prevent it from happening.
+
+Due to the way products are added to the cart, customers can add multiple variations of the same product to their carts (i.e. different attribute/option combinations) but never more than one of any given variation.
+
+Instructions:
+
+Upload the module to your ubercart/contrib directory and enable it on your Drupal site.
+Browse to the product you want to have a quantity restriction as an administrator.
+Click on the product's Edit tab and then its Features secondary task tab.
+Choose Restrict Qty. from the select box and click Add.
+Test it out by adding the product to your cart!
+If you already had a copy of that product in your shopping cart, you should empty your cart and add it again. Due to the way the module works, it won't restrict quantities on products already in customers' shopping carts.

+ 2 - 2
sites/all/modules/contrib/fields/addressfield/addressfield-rtl.css

@@ -1,10 +1,10 @@
-.addressfield-container-inline > div.form-item {
+div.addressfield-container-inline > div.form-item {
   float: right;
   margin-right: 0;
   margin-left: 1em;
 }
 
-.addressfield-container-inline.country-GB > div.form-item {
+div.addressfield-container-inline.country-GB > div.form-item {
   margin-left: auto;
   margin-right: 0;
 }

+ 442 - 0
sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc

@@ -0,0 +1,442 @@
+<?php
+
+/**
+ * Contains the predefined address formats.
+ *
+ * Derived from Google's dataset: https://i18napis.appspot.com/address.
+ */
+
+/**
+ * Returns the address format for the given country code.
+ *
+ * @param $country_code
+ *   The country code for which the address format should be returned.
+ *
+ * @return
+ *   The address format array with the following keys:
+ *   - used_fields: An array of fields used by this format. Possible values:
+ *     'dependent_locality', 'locality', 'administrative_area', 'postal_code'.
+ *   - required_fields: An array of required fields. See "used_fields".
+ *   - dependent_locality_label: The label for the dependent locality field.
+ *   - locality_label: The label for the locality field.
+ *   - administrative_area_label: The label for the administrative area field.
+ *   - postal_code_label: The label for the postal code field.
+ *   - render_administrative_area_value: True if the value should be rendered
+ *     instead of the ISO code. US example: California instead of CA.
+ *     Only relevant for countries with predefined administrative areas.
+ */
+function addressfield_get_address_format($country_code) {
+  $default_values = array(
+    'used_fields' => array('locality'),
+    'required_fields' => array('locality'),
+    'dependent_locality_label' => t('Suburb'),
+    'locality_label' => t('City'),
+    'administrative_area_label' => t('Province'),
+    'postal_code_label' => t('Postal code'),
+    'render_administrative_area_value' => FALSE,
+  );
+
+  $address_formats = array();
+  // These formats differ from the default only by the presence of the
+  // postal code in 'used_fields'.
+  $countries_with_optional_postal_code = array(
+    'AC', 'AD', 'AL', 'AZ', 'BA', 'BB', 'BD', 'BG', 'BH', 'BM', 'BN', 'BT',
+    'CR', 'CY', 'CZ', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE', 'GN', 'GT',
+    'GW', 'HR', 'HT', 'HU', 'IL', 'IS', 'JO', 'KE', 'KG', 'KH', 'KW', 'LA',
+    'LA', 'LB', 'LK', 'LR', 'LS',  'MA', 'MC', 'MD', 'ME', 'MG', 'MK', 'MM',
+    'MT', 'MU', 'MV', 'NE', 'NP', 'OM', 'PK', 'PY', 'RO', 'RS', 'SA', 'SI',
+    'SK', 'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'VA', 'VC', 'VG', 'XK', 'ZM',
+  );
+  foreach ($countries_with_optional_postal_code as $code) {
+    $address_formats[$code] = array(
+      'used_fields' => array('locality', 'postal_code'),
+    );
+  }
+
+  // These formats differ from the default only by the presence of the
+  // postal code in 'used_fields' and 'required_fields'.
+  $countries_with_required_postal_code = array(
+    'AT', 'AX', 'BE', 'BL', 'CH', 'DE', 'DK', 'FI', 'FK', 'FR', 'GF', 'GG',
+    'GL', 'GP', 'GR', 'GS', 'IM', 'IO', 'JE', 'LI', 'LU', 'MF', 'MQ', 'NC',
+    'NL', 'NO', 'PL', 'PM', 'PN', 'PT', 'RE', 'SE', 'SH', 'SJ', 'TC', 'WF',
+    'YT',
+  );
+  foreach ($countries_with_required_postal_code as $code) {
+    $address_formats[$code] = array(
+      'used_fields' => array('locality', 'postal_code'),
+      'required_fields' => array('locality', 'postal_code'),
+    );
+  }
+
+  $address_formats['AE'] = array(
+    'used_fields' => array('administrative_area'),
+    'administrative_area_label' => t('Emirate'),
+  );
+  $address_formats['AM'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['AR'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['AS'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['AU'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'locality_label' => t('City/Suburb'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('Postcode'),
+  );
+  $address_formats['BR'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'dependent_locality_label' => t('Neighborhood'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['BS'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['BY'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['CA'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['CC'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['CL'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['CN'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+    'dependent_locality_label' => t('District'),
+  );
+  $address_formats['CO'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['CV'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['CX'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['EG'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('Governorate'),
+  );
+  $address_formats['EE'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'administrative_area_label' => t('County'),
+  );
+  $address_formats['ES'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['FM'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['GB'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'locality_label' => t('Town/City'),
+    'administrative_area_label' => t('County'),
+    'postal_code_label' => t('Postcode'),
+  );
+  $address_formats['GI'] = array(
+    'used_fields' => array('postal_code'),
+  );
+  $address_formats['GU'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['HK'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'required_fields' => array('administrative_area'),
+    'locality_label' => t('District'),
+    'administrative_area_label' => t('Area', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['HN'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['ID'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'locality_label' => t('City/Regency'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['IE'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'locality_label' => t('Town/City'),
+    'administrative_area_label' => t('County'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['IN'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('PIN code'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['IQ'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['IR'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+    'dependent_locality_label' => t('Neighborhood'),
+  );
+  $address_formats['IT'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['JM'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'required_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Parish', array(), array('context' => 'Territory of a country')),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['JP'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('Prefecture'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['KI'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['KN'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'required_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['KR'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'dependent_locality_label' => t('District'),
+  );
+  $address_formats['KY'] = array(
+    'used_fields' => array('administrative_area', 'postal_code'),
+    'required_fields' => array('administrative_area'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['KZ'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('Region', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['LT'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'administrative_area_label' => t('County'),
+  );
+  $address_formats['LV'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'administrative_area_label' => t('Municipality'),
+  );
+  $address_formats['MH'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['MN'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['MP'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['MX'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'dependent_locality_label' => t('Neighborhood'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['MY'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'dependent_locality_label' => t('Village / Township'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['MZ'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['NF'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['NG'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['NI'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['NR'] = array(
+    'used_fields' => array('administrative_area'),
+    'required_fields' => array('administrative_area'),
+    'administrative_area_label' => t('District'),
+  );
+  $address_formats['NZ'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'locality_label' => t('Town/City'),
+    'postal_code_label' => t('Postcode'),
+  );
+  $address_formats['PA'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['PE'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'locality_label' => t('District'),
+    'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['PF'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['PG'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['PH'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['PR'] = array(
+    'used_fields' => array('locality', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['PW'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['RU'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+  );
+  $address_formats['SC'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['SG'] = array(
+    'used_fields' => array('postal_code'),
+    'required_fields' => array('postal_code'),
+  );
+  $address_formats['SM'] = array(
+    'used_fields' => array('locality', 'postal_code'),
+    'required_fields' => array('postal_code'),
+  );
+  $address_formats['SO'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['SR'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['SV'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+  );
+  $address_formats['TH'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['TR'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'locality_label' => t('District'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['TV'] = array(
+    'used_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('Island'),
+  );
+  $address_formats['TW'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['UA'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+    'administrative_area_label' => t('Region', array(), array('context' => 'Territory of a country')),
+  );
+  $address_formats['UM'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['US'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['UY'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['UZ'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['VE'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area'),
+    'render_administrative_area_value' => TRUE,
+  );
+  $address_formats['VI'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'required_fields' => array('locality', 'administrative_area', 'postal_code'),
+    'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
+    'postal_code_label' => t('ZIP code'),
+  );
+  $address_formats['VN'] = array(
+    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
+  );
+  $address_formats['ZA'] = array(
+    'used_fields' => array('dependent_locality', 'locality', 'postal_code'),
+    'required_fields' => array('locality', 'postal_code'),
+  );
+
+  // Allow other modules to alter the formats.
+  drupal_alter('addressfield_address_formats', $address_formats);
+
+  if (isset($address_formats[$country_code])) {
+    $format = $address_formats[$country_code] + $default_values;
+  }
+  else {
+    // There is no predefined address format for the requested country,
+    // but the defaults should work fine.
+    $format = $default_values;
+  }
+
+  return $format;
+}

+ 1037 - 0
sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc

@@ -0,0 +1,1037 @@
+<?php
+
+/**
+ * Returns the predefined administrative areas.
+ *
+ * @param $country_code
+ *   The country code for which administrative areas should be returned.
+ *
+ * @return
+ *   An array of predefined administrative areas for the given country code, or
+ *   NULL if not found.
+ */
+function addressfield_get_administrative_areas($country_code) {
+  $administrative_areas = array();
+  $administrative_areas['AE'] = array(
+    'AZ' => t('Abu Dhabi'),
+    'FU' => t('Fujairah'),
+    'UQ' => t('Umm al-Quwain'),
+    'SH' => t('Sharjah'),
+    'DU' => t('Dubai'),
+    'RK' => t('Ras al-Khaimah'),
+    'AJ' => t('Ajmān'),
+  );
+  $administrative_areas['AR'] = array(
+    'B' => t('Buenos Aires'),
+    'K' => t('Catamarca'),
+    'H' => t('Chaco'),
+    'U' => t('Chubut'),
+    'C' => t('Ciudad de Buenos Aires'),
+    'X' => t('Córdoba'),
+    'W' => t('Corrientes'),
+    'E' => t('Entre Ríos'),
+    'P' => t('Formosa'),
+    'Y' => t('Jujuy'),
+    'L' => t('La Pampa'),
+    'F' => t('La Rioja'),
+    'M' => t('Mendoza'),
+    'N' => t('Misiones'),
+    'Q' => t('Neuquén'),
+    'R' => t('Río Negro'),
+    'A' => t('Salta'),
+    'J' => t('San Juan'),
+    'D' => t('San Luis'),
+    'Z' => t('Santa Cruz'),
+    'S' => t('Santa Fe'),
+    'G' => t('Santiago del Estero'),
+    'V' => t('Tierra del Fuego'),
+    'T' => t('Tucumán'),
+  );
+  $administrative_areas['AU'] = array(
+    'ACT' => t('Australian Capital Territory'),
+    'NSW' => t('New South Wales'),
+    'NT' => t('Northern Territory'),
+    'QLD' => t('Queensland'),
+    'SA' => t('South Australia'),
+    'TAS' => t('Tasmania'),
+    'VIC' => t('Victoria'),
+    'WA' => t('Western Australia'),
+  );
+  $administrative_areas['BR'] = array(
+    'AC' => t('Acre'),
+    'AL' => t('Alagoas'),
+    'AM' => t('Amazonas'),
+    'AP' => t('Amapá'),
+    'BA' => t('Bahia'),
+    'CE' => t('Ceará'),
+    'DF' => t('Distrito Federal'),
+    'ES' => t('Espírito Santo'),
+    'GO' => t('Goiás'),
+    'MA' => t('Maranhão'),
+    'MG' => t('Minas Gerais'),
+    'MS' => t('Mato Grosso do Sul'),
+    'MT' => t('Mato Grosso'),
+    'PA' => t('Pará'),
+    'PB' => t('Paraíba'),
+    'PE' => t('Pernambuco'),
+    'PI' => t('Piauí'),
+    'PR' => t('Paraná'),
+    'RJ' => t('Rio de Janeiro'),
+    'RN' => t('Rio Grande do Norte'),
+    'RO' => t('Rondônia'),
+    'RR' => t('Roraima'),
+    'RS' => t('Rio Grande do Sul'),
+    'SC' => t('Santa Catarina'),
+    'SE' => t('Sergipe'),
+    'SP' => t('São Paulo'),
+    'TO' => t('Tocantins'),
+  );
+  $administrative_areas['CA'] = array(
+    'AB' => t('Alberta'),
+    'BC' => t('British Columbia'),
+    'MB' => t('Manitoba'),
+    'NB' => t('New Brunswick'),
+    'NL' => t('Newfoundland and Labrador'),
+    'NT' => t('Northwest Territories'),
+    'NS' => t('Nova Scotia'),
+    'NU' => t('Nunavut'),
+    'ON' => t('Ontario'),
+    'PE' => t('Prince Edward Island'),
+    'QC' => t('Quebec'),
+    'SK' => t('Saskatchewan'),
+    'YT' => t('Yukon Territory'),
+  );
+  $administrative_areas['CL'] = array(
+    'AI' => t('Aysén del General Carlos Ibáñez del Campo'),
+    'AN' => t('Antofagasta'),
+    'AR' => t('Araucanía'),
+    'AP' => t('Arica y Parinacota'),
+    'AT' => t('Atacama'),
+    'BI' => t('Biobío'),
+    'CO' => t('Coquimbo'),
+    'LI' => t('Libertador General Bernardo O\'Higgins'),
+    'LL' => t('Los Lagos'),
+    'LR' => t('Los Ríos'),
+    'MA' => t('Magallanes y de la Antártica Chilena'),
+    'ML' => t('Maule'),
+    'RM' => t('Metropolitana de Santiago'),
+    'TA' => t('Tarapacá'),
+    'VS' => t('Valparaíso'),
+  );
+  $administrative_areas['CN'] = array(
+    '34' => t('Anhui Sheng'),
+    '92' => t('Macau'),
+    '11' => t('Beijing Shi'),
+    '50' => t('Chongqing Shi'),
+    '35' => t('Fujian Sheng'),
+    '62' => t('Gansu Sheng'),
+    '44' => t('Guangdong Sheng'),
+    '45' => t('Guangxi Zhuangzuzizhiqu'),
+    '52' => t('Guizhou Sheng'),
+    '46' => t('Hainan Sheng'),
+    '13' => t('Hebei Sheng'),
+    '41' => t('Henan Sheng'),
+    '23' => t('Heilongjiang Sheng'),
+    '42' => t('Hubei Sheng'),
+    '43' => t('Hunan Sheng'),
+    '22' => t('Jilin Sheng'),
+    '32' => t('Jiangsu Sheng'),
+    '36' => t('Jiangxi Sheng'),
+    '21' => t('Liaoning Sheng'),
+    '15' => t('Neimenggu Zizhiqu'),
+    '64' => t('Ningxia Huizuzizhiqu'),
+    '63' => t('Qinghai Sheng'),
+    '37' => t('Shandong Sheng'),
+    '14' => t('Shanxi Sheng'),
+    '61' => t('Shaanxi Sheng'),
+    '31' => t('Shanghai Shi'),
+    '51' => t('Sichuan Sheng'),
+    '71' => t('Taiwan'),
+    '12' => t('Tianjin Shi'),
+    '54' => t('Xizang Zizhiqu'),
+    '91' => t('Hong Kong'),
+    '65' => t('Xinjiang Weiwuerzizhiqu'),
+    '53' => t('Yunnan Sheng'),
+    '33' => t('Zhejiang Sheng'),
+  );
+  $administrative_areas['CO'] = array(
+    'AMA' => t('Amazonas'),
+    'ANT' => t('Antioquia'),
+    'ARA' => t('Arauca'),
+    'ATL' => t('Atlántico'),
+    'BOL' => t('Bolívar'),
+    'BOY' => t('Boyacá'),
+    'CAL' => t('Caldas'),
+    'CAQ' => t('Caquetá'),
+    'CAS' => t('Casanare'),
+    'CAU' => t('Cauca'),
+    'CES' => t('Cesar'),
+    'COR' => t('Córdoba'),
+    'CUN' => t('Cundinamarca'),
+    'CHO' => t('Chocó'),
+    'GUA' => t('Guainía'),
+    'GUV' => t('Guaviare'),
+    'HUI' => t('Huila'),
+    'LAG' => t('La Guajira'),
+    'MAG' => t('Magdalena'),
+    'MET' => t('Meta'),
+    'NAR' => t('Nariño'),
+    'NSA' => t('Norte de Santander'),
+    'PUT' => t('Putumayo'),
+    'QUI' => t('Quindío'),
+    'RIS' => t('Risaralda'),
+    'SAP' => t('San Andrés, Providencia y Santa Catalina'),
+    'SAN' => t('Santander'),
+    'SUC' => t('Sucre'),
+    'TOL' => t('Tolima'),
+    'VAC' => t('Valle del Cauca'),
+    'VAU' => t('Vaupés'),
+    'VID' => t('Vichada'),
+  );
+  $administrative_areas['EE'] = array(
+    '37' => t('Harjumaa'),
+    '39' => t('Hiiumaa'),
+    '44' => t('Ida-Virumaa'),
+    '49' => t('Jõgevamaa'),
+    '51' => t('Järvamaa'),
+    '57' => t('Läänemaa'),
+    '59' => t('Lääne-Virumaa'),
+    '65' => t('Põlvamaa'),
+    '67' => t('Pärnumaa'),
+    '70' => t('Raplamaa'),
+    '74' => t('Saaremaa'),
+    '78' => t('Tartumaa'),
+    '82' => t('Valgamaa'),
+    '84' => t('Viljandimaa'),
+    '86' => t('Võrumaa'),
+  );
+  $administrative_areas['EG'] = array(
+    'ALX' => t('Alexandria'),
+    'ASN' => t('Aswan'),
+    'AST' => t('Asyut'),
+    'BH' => t('Beheira'),
+    'BNS' => t('Beni Suef'),
+    'C' => t('Cairo'),
+    'DK' => t('Dakahlia'),
+    'DT' => t('Damietta'),
+    'FYM' => t('Faiyum'),
+    'GH' => t('Gharbia'),
+    'GZ' => t('Giza'),
+    'IS' => t('Ismailia'),
+    'KFS' => t('Kafr el-Sheikh'),
+    'MT' => t('Matruh'),
+    'MN' => t('Minya'),
+    'MNF' => t('Monufia'),
+    'WAD' => t('New Valley'),
+    'SIN' => t('North Sinai'),
+    'PTS' => t('Port Said'),
+    'KB' => t('Qalyubia'),
+    'KN' => t('Qena'),
+    'BA' => t('Red Sea'),
+    'SHR' => t('Sharqia'),
+    'SHG' => t('Sohag'),
+    'JS' => t('South Sinai'),
+    'SUZ' => t('Suez'),
+    'LX' => t('Luxor'),
+  );
+  $administrative_areas['ES'] = array(
+    'C' => t("A Coruña"),
+    'VI' => t('Alava'),
+    'AB' => t('Albacete'),
+    'A' => t('Alicante'),
+    'AL' => t("Almería"),
+    'O' => t('Asturias'),
+    'AV' => t("Ávila"),
+    'BA' => t('Badajoz'),
+    'PM' => t('Baleares'),
+    'B' => t('Barcelona'),
+    'BU' => t('Burgos'),
+    'CC' => t("Cáceres"),
+    'CA' => t("Cádiz"),
+    'S' => t('Cantabria'),
+    'CS' => t("Castellón"),
+    'CE' => t('Ceuta'),
+    'CR' => t('Ciudad Real'),
+    'CO' => t("Córdoba"),
+    'CU' => t('Cuenca'),
+    'GI' => t('Gerona'),
+    'GR' => t('Granada'),
+    'GU' => t('Guadalajara'),
+    'SS' => t("Guipúzcoa"),
+    'H' => t('Huelva'),
+    'HU' => t('Huesca'),
+    'J' => t("Jaén"),
+    'LO' => t('La Rioja'),
+    'GC' => t('Las Palmas'),
+    'LE' => t("León"),
+    'L' => t("Lérida"),
+    'LU' => t('Lugo'),
+    'M' => t('Madrid'),
+    'MA' => t("Málaga"),
+    'ML' => t('Melilla'),
+    'MU' => t('Murcia'),
+    'NA' => t('Navarra'),
+    'OR' => t('Ourense'),
+    'P' => t('Palencia'),
+    'PO' => t('Pontevedra'),
+    'SA' => t('Salamanca'),
+    'TF' => t('Santa Cruz de Tenerife'),
+    'SG' => t('Segovia'),
+    'SE' => t('Sevilla'),
+    'SO' => t('Soria'),
+    'T' => t('Tarragona'),
+    'TE' => t('Teruel'),
+    'TO' => t('Toledo'),
+    'V' => t('Valencia'),
+    'VA' => t('Valladolid'),
+    'BI' => t('Vizcaya'),
+    'ZA' => t('Zamora'),
+    'Z' => t('Zaragoza'),
+  );
+  $administrative_areas['HK'] = array(
+    // HK subdivisions have no ISO codes assigned.
+    'Kowloon' => t('Kowloon'),
+    'Hong Kong Island' => t('Hong Kong Island'),
+    'New Territories' => t('New Territories'),
+  );
+  $administrative_areas['ID'] = array(
+    'AC' => t('Aceh'),
+    'BA' => t('Bali'),
+    'BB' => t('Bangka Belitung'),
+    'BT' => t('Banten'),
+    'BE' => t('Bengkulu'),
+    'JK' => t('DKI Jakarta'),
+    'YO' => t('D.I. Yogyakarta'),
+    'GO' => t('Gorontalo'),
+    'JA' => t('Jambi'),
+    'JB' => t('Jawa Barat'),
+    'JT' => t('Jawa Tengah'),
+    'JI' => t('Jawa Timur'),
+    'KB' => t('Kalimantan Barat'),
+    'KS' => t('Kalimantan Selatan'),
+    'KT' => t('Kalimantan Tengah'),
+    'KI' => t('Kalimantan Timur'),
+    'KR' => t('Kepulauan Riau'),
+    'LA' => t('Lampung'),
+    'MA' => t('Maluku'),
+    'MU' => t('Maluku Utara'),
+    'NB' => t('Nusa Tenggara Barat'),
+    'NT' => t('Nusa Tenggara Timur'),
+    'PA' => t('Papua'),
+    'PB' => t('Papua Barat'),
+    'RI' => t('Riau'),
+    'SR' => t('Sulawesi Barat'),
+    'SN' => t('Sulawesi Selatan'),
+    'ST' => t('Sulawesi Tengah'),
+    'SG' => t('Sulawesi Tenggara'),
+    'SA' => t('Sulawesi Utara'),
+    'SB' => t('Sumatera Barat'),
+    'SS' => t('Sumatera Selatan'),
+    'SU' => t('Sumatera Utara'),
+  );
+  $administrative_areas['IE'] = array(
+    'CW' => t('Co Carlow'),
+    'CN' => t('Co Cavan'),
+    'CE' => t('Co Clare'),
+    'CO' => t('Co Cork'),
+    'DL' => t('Co Donegal'),
+    'D' => t('Co Dublin'),
+    'D1' => t('Dublin 1'),
+    'D2' => t('Dublin 2'),
+    'D3' => t('Dublin 3'),
+    'D4' => t('Dublin 4'),
+    'D5' => t('Dublin 5'),
+    'D6' => t('Dublin 6'),
+    'D6W' => t('Dublin 6w'),
+    'D7' => t('Dublin 7'),
+    'D8' => t('Dublin 8'),
+    'D9' => t('Dublin 9'),
+    'D10' => t('Dublin 10'),
+    'D11' => t('Dublin 11'),
+    'D12' => t('Dublin 12'),
+    'D13' => t('Dublin 13'),
+    'D14' => t('Dublin 14'),
+    'D15' => t('Dublin 15'),
+    'D16' => t('Dublin 16'),
+    'D17' => t('Dublin 17'),
+    'D18' => t('Dublin 18'),
+    'D19' => t('Dublin 19'),
+    'D20' => t('Dublin 20'),
+    'D21' => t('Dublin 21'),
+    'D22' => t('Dublin 22'),
+    'D23' => t('Dublin 23'),
+    'D24' => t('Dublin 24'),
+    'G' => t('Co Galway'),
+    'KY' => t('Co Kerry'),
+    'KE' => t('Co Kildare'),
+    'KK' => t('Co Kilkenny'),
+    'LS' => t('Co Laois'),
+    'LM' => t('Co Leitrim'),
+    'LK' => t('Co Limerick'),
+    'LD' => t('Co Longford'),
+    'LH' => t('Co Louth'),
+    'MO' => t('Co Mayo'),
+    'MH' => t('Co Meath'),
+    'MN' => t('Co Monaghan'),
+    'OY' => t('Co Offaly'),
+    'RN' => t('Co Roscommon'),
+    'SO' => t('Co Sligo'),
+    'TA' => t('Co Tipperary'),
+    'WD' => t('Co Waterford'),
+    'WH' => t('Co Westmeath'),
+    'WX' => t('Co Wexford'),
+    'WW' => t('Co Wicklow'),
+  );
+  $administrative_areas['IN'] = array(
+    'AP' => t('Andhra Pradesh'),
+    'AR' => t('Arunachal Pradesh'),
+    'AS' => t('Assam'),
+    'BR' => t('Bihar'),
+    'CT' => t('Chhattisgarh'),
+    'DD' => t('Daman & Diu'),
+    'DN' => t('Dadra & Nagar Haveli'),
+    'GA' => t('Goa'),
+    'GJ' => t('Gujarat'),
+    'HP' => t('Himachal Pradesh'),
+    'HR' => t('Haryana'),
+    'JH' => t('Jharkhand'),
+    'JK' => t('Jammu & Kashmir'),
+    'KA' => t('Karnataka'),
+    'KL' => t('Kerala'),
+    'MH' => t('Maharashtra'),
+    'MN' => t('Manipur'),
+    'ML' => t('Meghalaya'),
+    'MP' => t('Madhya Pradesh'),
+    'MZ' => t('Mizoram'),
+    'NL' => t('Nagaland'),
+    'OR' => t('Odisha'),
+    'PB' => t('Punjab'),
+    'RJ' => t('Rajasthan'),
+    'SK' => t('Sikkim'),
+    'TN' => t('Tamil Nadu'),
+    'TG' => t('Telangana'),
+    'TR' => t('Tripura'),
+    'UP' => t('Uttar Pradesh'),
+    'UT' => t('Uttarakhand'),
+    'WB' => t('West Bengal'),
+    ' ' => t('--'),
+    'AN' => t('Andaman & Nicobar'),
+    'CH' => t('Chandigarh'),
+    'DN' => t('Dadra & Nagar Haveli'),
+    'DD' => t('Daman & Diu'),
+    'DL' => t('Delhi'),
+    'LD' => t('Lakshadweep'),
+    'PY' => t('Puducherry'),
+  );
+  $administrative_areas['IT'] = array(
+    'AG' => t('Agrigento'),
+    'AL' => t('Alessandria'),
+    'AN' => t('Ancona'),
+    'AO' => t('Aosta'),
+    'AP' => t('Ascoli Piceno'),
+    'AQ' => t("L'Aquila"),
+    'AR' => t('Arezzo'),
+    'AT' => t('Asti'),
+    'AV' => t('Avellino'),
+    'BA' => t('Bari'),
+    'BG' => t('Bergamo'),
+    'BI' => t('Biella'),
+    'BL' => t('Belluno'),
+    'BN' => t('Benevento'),
+    'BO' => t('Bologna'),
+    'BR' => t('Brindisi'),
+    'BS' => t('Brescia'),
+    'BT' => t('Barletta-Andria-Trani'),
+    'BZ' => t('Bolzano/Bozen'),
+    'CA' => t('Cagliari'),
+    'CB' => t('Campobasso'),
+    'CE' => t('Caserta'),
+    'CH' => t('Chieti'),
+    'CI' => t('Carbonia-Iglesias'),
+    'CL' => t('Caltanissetta'),
+    'CN' => t('Cuneo'),
+    'CO' => t('Como'),
+    'CR' => t('Cremona'),
+    'CS' => t('Cosenza'),
+    'CT' => t('Catania'),
+    'CZ' => t('Catanzaro'),
+    'EN' => t('Enna'),
+    'FC' => t('Forlì-Cesena'),
+    'FE' => t('Ferrara'),
+    'FG' => t('Foggia'),
+    'FI' => t('Firenze'),
+    'FM' => t('Fermo'),
+    'FR' => t('Frosinone'),
+    'GE' => t('Genova'),
+    'GO' => t('Gorizia'),
+    'GR' => t('Grosseto'),
+    'IM' => t('Imperia'),
+    'IS' => t('Isernia'),
+    'KR' => t('Crotone'),
+    'LC' => t('Lecco'),
+    'LE' => t('Lecce'),
+    'LI' => t('Livorno'),
+    'LO' => t('Lodi'),
+    'LT' => t('Latina'),
+    'LU' => t('Lucca'),
+    'MB' => t('Monza e Brianza'),
+    'MC' => t('Macerata'),
+    'ME' => t('Messina'),
+    'MI' => t('Milano'),
+    'MN' => t('Mantova'),
+    'MO' => t('Modena'),
+    'MS' => t('Massa-Carrara'),
+    'MT' => t('Matera'),
+    'NA' => t('Napoli'),
+    'NO' => t('Novara'),
+    'NU' => t('Nuoro'),
+    'OG' => t('Ogliastra'),
+    'OR' => t('Oristano'),
+    'OT' => t('Olbia-Tempio'),
+    'PA' => t('Palermo'),
+    'PC' => t('Piacenza'),
+    'PD' => t('Padova'),
+    'PE' => t('Pescara'),
+    'PG' => t('Perugia'),
+    'PI' => t('Pisa'),
+    'PN' => t('Pordenone'),
+    'PO' => t('Prato'),
+    'PR' => t('Parma'),
+    'PT' => t('Pistoia'),
+    'PU' => t('Pesaro e Urbino'),
+    'PV' => t('Pavia'),
+    'PZ' => t('Potenza'),
+    'RA' => t('Ravenna'),
+    'RC' => t('Reggio Calabria'),
+    'RE' => t('Reggio Emilia'),
+    'RG' => t('Ragusa'),
+    'RI' => t('Rieti'),
+    'RM' => t('Roma'),
+    'RN' => t('Rimini'),
+    'RO' => t('Rovigo'),
+    'SA' => t('Salerno'),
+    'SI' => t('Siena'),
+    'SO' => t('Sondrio'),
+    'SP' => t('La Spezia'),
+    'SR' => t('Siracusa'),
+    'SS' => t('Sassari'),
+    'SV' => t('Savona'),
+    'TA' => t('Taranto'),
+    'TE' => t('Teramo'),
+    'TN' => t('Trento'),
+    'TO' => t('Torino'),
+    'TP' => t('Trapani'),
+    'TR' => t('Terni'),
+    'TS' => t('Trieste'),
+    'TV' => t('Treviso'),
+    'UD' => t('Udine'),
+    'VA' => t('Varese'),
+    'VB' => t('Verbano-Cusio-Ossola'),
+    'VC' => t('Vercelli'),
+    'VE' => t('Venezia'),
+    'VI' => t('Vicenza'),
+    'VR' => t('Verona'),
+    'VS' => t('Medio Campidano'),
+    'VT' => t('Viterbo'),
+    'VV' => t('Vibo Valentia'),
+  );
+  $administrative_areas['JM'] = array(
+    '13' => 'Clarendon',
+    '09' => 'Hanover',
+    '01' => 'Kingston',
+    '12' => 'Manchester',
+    '04' => 'Portland',
+    '02' => 'St. Andrew',
+    '06' => 'St. Ann',
+    '14' => 'St. Catherine',
+    '11' => 'St. Elizabeth',
+    '08' => 'St. James',
+    '05' => 'St. Mary',
+    '03' => 'St. Thomas',
+    '07' => 'Trelawny',
+    '10' => 'Westmoreland',
+  );
+  $administrative_areas['JP'] = array(
+    '01' => t('Hokkaido'),
+    '02' => t('Aomori'),
+    '03' => t('Iwate'),
+    '04' => t('Miyagi'),
+    '05' => t('Akita'),
+    '06' => t('Yamagata'),
+    '07' => t('Fukushima'),
+    '08' => t('Ibaraki'),
+    '09' => t('Tochigi'),
+    '10' => t('Gunma'),
+    '11' => t('Saitama'),
+    '12' => t('Chiba'),
+    '13' => t('Tokyo'),
+    '14' => t('Kanagawa'),
+    '15' => t('Niigata'),
+    '16' => t('Toyama'),
+    '17' => t('Ishikawa'),
+    '18' => t('Fukui'),
+    '19' => t('Yamanashi'),
+    '20' => t('Nagano'),
+    '21' => t('Gifu'),
+    '22' => t('Shizuoka'),
+    '23' => t('Aichi'),
+    '24' => t('Mie'),
+    '25' => t('Shiga'),
+    '26' => t('Kyoto'),
+    '27' => t('Osaka'),
+    '28' => t('Hyogo'),
+    '29' => t('Nara'),
+    '30' => t('Wakayama'),
+    '31' => t('Tottori'),
+    '32' => t('Shimane'),
+    '33' => t('Okayama'),
+    '34' => t('Hiroshima'),
+    '35' => t('Yamaguchi'),
+    '36' => t('Tokushima'),
+    '37' => t('Kagawa'),
+    '38' => t('Ehime'),
+    '39' => t('Kochi'),
+    '40' => t('Fukuoka'),
+    '41' => t('Saga'),
+    '42' => t('Nagasaki'),
+    '43' => t('Kumamoto'),
+    '44' => t('Oita'),
+    '45' => t('Miyazaki'),
+    '46' => t('Kagoshima'),
+    '47' => t('Okinawa'),
+  );
+  $administrative_areas['KR'] = array(
+    '11' => t('Seoul'),
+    '26' => t('Busan'),
+    '27' => t('Daegu'),
+    '30' => t('Daejeon'),
+    '29' => t('Gwangju'),
+    '28' => t('Incheon'),
+    '31' => t('Ulsan'),
+    '43' => t('Chungcheongbuk-do'),
+    '44' => t('Chungcheongnam-do'),
+    '42' => t('Gangwon-do'),
+    '41' => t('Gyeonggi-do'),
+    '47' => t('Gyeongsangbuk-do'),
+    '48' => t('Gyeongsangnam-do'),
+    '49' => t('Jeju-do'),
+    '45' => t('Jeollabuk-do'),
+    '46' => t('Jeollanam-do'),
+    '50' => t('Sejong'),
+  );
+  $administrative_areas['KZ'] = array(
+    'AST' => t('Astana'),
+    'ALA' => t('Almaty'),
+    'ALM' => t('Almaty region'),
+    'AKM' => t('Aqmola region'),
+    'AKT' => t('Aqtöbe region'),
+    'ATY' => t('Atyraū region'),
+    'ZAP' => t('Batys Qazaqstan region'),
+    'MAN' => t('Mangghystaū region'),
+    'YUZ' => t('Ongtüstik Qazaqstan region'),
+    'PAV' => t('Pavlodar region'),
+    'KAR' => t('Qaraghandy region'),
+    'KUS' => t('Qostanay region'),
+    'KZY' => t('Qyzylorda region'),
+    'VOS' => t('Shyghys Qazaqstan region'),
+    'SEV' => t('Soltüstik Qazaqstan region'),
+    'ZHA' => t('Zhambyl region'),
+  );
+  $administrative_areas['MX'] = array(
+    'AGU' => t('Aguascalientes'),
+    'BCN' => t('Baja California'),
+    'BCS' => t('Baja California Sur'),
+    'CAM' => t('Campeche'),
+    'COA' => t('Coahuila'),
+    'COL' => t('Colima'),
+    'CHP' => t('Chiapas'),
+    'CHH' => t('Chihuahua'),
+    'DIF' => t('Distrito Federal'),
+    'DUG' => t('Durango'),
+    'MEX' => t('Estado de México'),
+    'GUA' => t('Guanajuato'),
+    'GRO' => t('Guerrero'),
+    'HID' => t('Hidalgo'),
+    'JAL' => t('Jalisco'),
+    'MIC' => t('Michoacán'),
+    'MOR' => t('Morelos'),
+    'NAY' => t('Nayarit'),
+    'NLE' => t('Nuevo León'),
+    'OAX' => t('Oaxaca'),
+    'PUE' => t('Puebla'),
+    'QUE' => t('Queretaro'),
+    'ROO' => t('Quintana Roo'),
+    'SLP' => t('San Luis Potosí'),
+    'SIN' => t('Sinaloa'),
+    'SON' => t('Sonora'),
+    'TAB' => t('Tabasco'),
+    'TAM' => t('Tamaulipas'),
+    'TLA' => t('Tlaxcala'),
+    'VER' => t('Veracruz'),
+    'YUC' => t('Yucatán'),
+    'ZAC' => t('Zacatecas'),
+  );
+  $administrative_areas['MY'] = array(
+    '01' => t('Johor'),
+    '02' => t('Kedah'),
+    '03' => t('Kelantan'),
+    '14' => t('Kuala Lumpur'),
+    '15' => t('Labuan'),
+    '04' => t('Melaka'),
+    '05' => t('Negeri Sembilan'),
+    '06' => t('Pahang'),
+    '08' => t('Perak'),
+    '09' => t('Perlis'),
+    '07' => t('Pulau Pinang'),
+    '16' => t('Putrajaya'),
+    '12' => t('Sabah'),
+    '13' => t('Sarawak'),
+    '10' => t('Selangor'),
+    '11' => t('Terengganu'),
+    );
+  $administrative_areas['PE'] = array(
+    'AMA' => t('Amazonas'),
+    'ANC' => t('Ancash'),
+    'APU' => t('Apurimac'),
+    'ARE' => t('Arequipa'),
+    'AYA' => t('Ayacucho'),
+    'CAJ' => t('Cajamarca'),
+    'CAL' => t('Callao'),
+    'CUS' => t('Cusco'),
+    'HUV' => t('Huancavelica'),
+    'HUC' => t('Huanuco'),
+    'ICA' => t('Ica'),
+    'JUN' => t('Junin'),
+    'LAL' => t('La Libertad'),
+    'LAM' => t('Lambayeque'),
+    'LIM' => t('Lima'),
+    'LOR' => t('Loreto'),
+    'MDD' => t('Madre de Dios'),
+    'MOQ' => t('Moquegua'),
+    'PAS' => t('Pasco'),
+    'PIU' => t('Piura'),
+    'PUN' => t('Puno'),
+    'SAM' => t('San Martin'),
+    'TAC' => t('Tacna'),
+    'TUM' => t('Tumbes'),
+    'UCA' => t('Ucayali'),
+  );
+  $administrative_areas['RU'] = array(
+    'MOW' => t('Moskva'),
+    'SPE' => t('Sankt-Peterburg'),
+    'AD' => t('Adygeya, Respublika'),
+    'AL' => t('Altay, Respublika'),
+    'BA' => t('Bashkortostan, Respublika'),
+    'BU' => t('Buryatiya, Respublika'),
+    'CE' => t('Chechenskaya Respublika'),
+    'CU' => t('Chuvashskaya Respublika'),
+    'DA' => t('Dagestan, Respublika'),
+    'IN' => t('Ingushetiya, Respublika'),
+    'KB' => t('Kabardino-Balkarskaya Respublika'),
+    'KL' => t('Kalmykiya, Respublika'),
+    'KC' => t('Karachayevo-Cherkesskaya Respublika'),
+    'KR' => t('Kareliya, Respublika'),
+    'KK' => t('Khakasiya, Respublika'),
+    'KO' => t('Komi, Respublika'),
+    'ME' => t('Mariy El, Respublika'),
+    'MO' => t('Mordoviya, Respublika'),
+    'SA' => t('Sakha, Respublika [Yakutiya]'),
+    'SE' => t('Severnaya Osetiya-Alaniya, Respublika'),
+    'TA' => t('Tatarstan, Respublika'),
+    'TY' => t('Tyva, Respublika [Tuva]'),
+    'UD' => t('Udmurtskaya Respublika'),
+    'ALT' => t('Altayskiy kray'),
+    'KAM' => t('Kamchatskiy kray'),
+    'KHA' => t('Khabarovskiy kray'),
+    'KDA' => t('Krasnodarskiy kray'),
+    'KYA' => t('Krasnoyarskiy kray'),
+    'PER' => t('Permskiy kray'),
+    'PRI' => t('Primorskiy kray'),
+    'STA' => t('Stavropolskiy kray'),
+    'ZAB' => t('Zabaykalskiy kray'),
+    'AMU' => t('Amurskaya oblast'),
+    'ARK' => t('Arkhangelskaya oblast'),
+    'AST' => t('Astrakhanskaya oblast'),
+    'BEL' => t('Belgorodskaya oblast'),
+    'BRY' => t('Bryanskaya oblast'),
+    'CHE' => t('Chelyabinskaya oblast'),
+    'IRK' => t('Irkutskaya oblast'),
+    'IVA' => t('Ivanovskaya oblast'),
+    'KGD' => t('Kaliningradskaya oblast'),
+    'KLU' => t('Kaluzhskaya oblast'),
+    'KEM' => t('Kemerovskaya oblast'),
+    'KIR' => t('Kirovskaya oblast'),
+    'KOS' => t('Kostromskaya oblast'),
+    'KGN' => t('Kurganskaya oblast'),
+    'KRS' => t('Kurskaya oblast'),
+    'LEN' => t('Leningradskaya oblast'),
+    'LIP' => t('Lipetskaya oblast'),
+    'MAG' => t('Magadanskaya oblast'),
+    'MOS' => t('Moskovskaya oblast'),
+    'MUR' => t('Murmanskaya oblast'),
+    'NIZ' => t('Nizhegorodskaya oblast'),
+    'NGR' => t('Novgorodskaya oblast'),
+    'NVS' => t('Novosibirskaya oblast'),
+    'OMS' => t('Omskaya oblast'),
+    'ORE' => t('Orenburgskaya oblast'),
+    'ORL' => t('Orlovskaya oblast'),
+    'PNZ' => t('Penzenskaya oblast'),
+    'PSK' => t('Pskovskaya oblast'),
+    'ROS' => t('Rostovskaya oblast'),
+    'RYA' => t('Ryazanskaya oblast'),
+    'SAK' => t('Sakhalinskaya oblast'),
+    'SAM' => t('Samarskaya oblast'),
+    'SAR' => t('Saratovskaya oblast'),
+    'SMO' => t('Smolenskaya oblast'),
+    'SVE' => t('Sverdlovskaya oblast'),
+    'TAM' => t('Tambovskaya oblast'),
+    'TOM' => t('Tomskaya oblast'),
+    'TUL' => t('Tulskaya oblast'),
+    'TVE' => t('Tverskaya oblast'),
+    'TYU' => t('Tyumenskaya oblast'),
+    'ULY' => t('Ulyanovskaya oblast'),
+    'VLA' => t('Vladimirskaya oblast'),
+    'VGG' => t('Volgogradskaya oblast'),
+    'VLG' => t('Vologodskaya oblast'),
+    'VOR' => t('Voronezhskaya oblast'),
+    'YAR' => t('Yaroslavskaya oblast'),
+    'YEV' => t('Yevreyskaya avtonomnaya oblast'),
+    'CHU' => t('Chukotskiy avtonomnyy okrug'),
+    'KHM' => t('Khanty-Mansiyskiy avtonomnyy okrug-Yugra'),
+    'NEN' => t('Nenetskiy avtonomnyy okrug'),
+    'YAN' => t('Yamalo-Nenetskiy avtonomnyy okrug'),
+  );
+  $administrative_areas['TR'] = array(
+    '01' => t('Adana'),
+    '02' => t('Adıyaman'),
+    '03' => t('Afyon'),
+    '04' => t('Ağrı'),
+    '68' => t('Aksaray'),
+    '05' => t('Amasya'),
+    '06' => t('Ankara'),
+    '07' => t('Antalya'),
+    '75' => t('Ardahan'),
+    '08' => t('Artvin'),
+    '09' => t('Aydın'),
+    '10' => t('Balıkesir'),
+    '74' => t('Bartın'),
+    '72' => t('Batman'),
+    '69' => t('Bayburt'),
+    '11' => t('Bilecik'),
+    '12' => t('Bingöl'),
+    '13' => t('Bitlis'),
+    '14' => t('Bolu'),
+    '15' => t('Burdur'),
+    '16' => t('Bursa'),
+    '17' => t('Çanakkale'),
+    '18' => t('Çankırı'),
+    '19' => t('Çorum'),
+    '20' => t('Denizli'),
+    '21' => t('Diyarbakır'),
+    '81' => t('Düzce'),
+    '22' => t('Edirne'),
+    '23' => t('Elazığ'),
+    '24' => t('Erzincan'),
+    '25' => t('Erzurum'),
+    '26' => t('Eskişehir'),
+    '27' => t('Gaziantep'),
+    '28' => t('Giresun'),
+    '29' => t('Gümüşhane'),
+    '30' => t('Hakkari'),
+    '31' => t('Hatay'),
+    '76' => t('Iğdır'),
+    '32' => t('Isparta'),
+    '34' => t('İstanbul'),
+    '35' => t('İzmir'),
+    '46' => t('Kahramanmaraş'),
+    '78' => t('Karabük'),
+    '70' => t('Karaman'),
+    '36' => t('Kars'),
+    '37' => t('Kastamonu'),
+    '38' => t('Kayseri'),
+    '71' => t('Kırıkkale'),
+    '39' => t('Kırklareli'),
+    '40' => t('Kırşehir'),
+    '79' => t('Kilis'),
+    '41' => t('Kocaeli'),
+    '42' => t('Konya'),
+    '43' => t('Kütahya'),
+    '44' => t('Malatya'),
+    '45' => t('Manisa'),
+    '47' => t('Mardin'),
+    '33' => t('Mersin'),
+    '48' => t('Muğla'),
+    '49' => t('Muş'),
+    '50' => t('Nevşehir'),
+    '51' => t('Niğde'),
+    '52' => t('Ordu'),
+    '80' => t('Osmaniye'),
+    '53' => t('Rize'),
+    '54' => t('Sakarya'),
+    '55' => t('Samsun'),
+    '56' => t('Siirt'),
+    '57' => t('Sinop'),
+    '58' => t('Sivas'),
+    '63' => t('Şanlıurfa'),
+    '73' => t('Şırnak'),
+    '59' => t('Tekirdağ'),
+    '60' => t('Tokat'),
+    '61' => t('Trabzon'),
+    '62' => t('Tunceli'),
+    '64' => t('Uşak'),
+    '65' => t('Van'),
+    '77' => t('Yalova'),
+    '66' => t('Yozgat'),
+    '67' => t('Zonguldak'),
+  );
+  $administrative_areas['TW'] = array(
+    'TXG' => t('Taichung City'),
+    'TPE' => t('Taipei City'),
+    'TTT' => t('Taitung County'),
+    'TNN' => t('Tainan City'),
+    'ILA' => t('Yilan County'),
+    'HUA' => t('Hualien County'),
+    'Kinmen County' => t('Kinmen County'),
+    'NAN' => t('Nantou County'),
+    'PIF' => t('Pingtung County'),
+    'MIA' => t('Miaoli County'),
+    'TAO' => t('Taoyuan County'),
+    'KHH' => t('Kaohsiung City'),
+    'KEE' => t('Keelung City'),
+    'Lienchiang County' => t('Lienchiang County'),
+    'YUN' => t('Yunlin County'),
+    'TPQ' => t('New Taipei City'),
+    'HSZ' => t('Hsinchu City'),
+    'HSQ' => t('Hsinchu County'),
+    'CYI' => t('Chiayi City'),
+    'CYQ' => t('Chiayi County'),
+    'CHA' => t('Changhua County'),
+    'PEN' => t('Penghu County'),
+  );
+  $administrative_areas['UA'] = array(
+    '43' => t('Crimea'),
+    '05' => t('Vinnyts\'ka oblast'),
+    '07' => t('Volyns\'ka oblast'),
+    '12' => t('Dnipropetrovsk Oblast'),
+    '14' => t('Donetsk Oblast'),
+    '18' => t('Zhytomyrs\'ka oblast'),
+    '21' => t('Zakarpats\'ka oblast'),
+    '23' => t('Zaporiz\'ka oblast'),
+    '26' => t('Ivano-Frankivs\'ka oblast'),
+    '30' => t('Kyiv city'),
+    '30' => t('Kiev Oblast'),
+    '35' => t('Kirovohrads\'ka oblast'),
+    '09' => t('Luhans\'ka oblast'),
+    '46' => t('Lviv Oblast'),
+    '48' => t('Mykolaivs\'ka oblast'),
+    '51' => t('Odessa Oblast'),
+    '53' => t('Poltavs\'ka oblast'),
+    '56' => t('Rivnens\'ka oblast'),
+    '40' => t('Sevastopol\' city'),
+    '59' => t('Sums\'ka oblast'),
+    '61' => t('Ternopil\'s\'ka oblast'),
+    '63' => t('Kharkiv Oblast'),
+    '65' => t('Khersons\'ka oblast'),
+    '68' => t('Khmel\'nyts\'ka oblast'),
+    '71' => t('Cherkas\'ka oblast'),
+    '77' => t('Chernivets\'ka oblast'),
+    '74' => t('Chernihivs\'ka oblast'),
+  );
+  $administrative_areas['US'] = array(
+    'AL' => t('Alabama'),
+    'AK' => t('Alaska'),
+    'AZ' => t('Arizona'),
+    'AR' => t('Arkansas'),
+    'CA' => t('California'),
+    'CO' => t('Colorado'),
+    'CT' => t('Connecticut'),
+    'DE' => t('Delaware'),
+    'DC' => t('District of Columbia'),
+    'FL' => t('Florida'),
+    'GA' => t('Georgia'),
+    'HI' => t('Hawaii'),
+    'ID' => t('Idaho'),
+    'IL' => t('Illinois'),
+    'IN' => t('Indiana'),
+    'IA' => t('Iowa'),
+    'KS' => t('Kansas'),
+    'KY' => t('Kentucky'),
+    'LA' => t('Louisiana'),
+    'ME' => t('Maine'),
+    'MD' => t('Maryland'),
+    'MA' => t('Massachusetts'),
+    'MI' => t('Michigan'),
+    'MN' => t('Minnesota'),
+    'MS' => t('Mississippi'),
+    'MO' => t('Missouri'),
+    'MT' => t('Montana'),
+    'NE' => t('Nebraska'),
+    'NV' => t('Nevada'),
+    'NH' => t('New Hampshire'),
+    'NJ' => t('New Jersey'),
+    'NM' => t('New Mexico'),
+    'NY' => t('New York'),
+    'NC' => t('North Carolina'),
+    'ND' => t('North Dakota'),
+    'OH' => t('Ohio'),
+    'OK' => t('Oklahoma'),
+    'OR' => t('Oregon'),
+    'PA' => t('Pennsylvania'),
+    'RI' => t('Rhode Island'),
+    'SC' => t('South Carolina'),
+    'SD' => t('South Dakota'),
+    'TN' => t('Tennessee'),
+    'TX' => t('Texas'),
+    'UT' => t('Utah'),
+    'VT' => t('Vermont'),
+    'VA' => t('Virginia'),
+    'WA' => t('Washington'),
+    'WV' => t('West Virginia'),
+    'WI' => t('Wisconsin'),
+    'WY' => t('Wyoming'),
+    ' ' => t('--'),
+    'AA' => t('Armed Forces (Americas)'),
+    'AE' => t('Armed Forces (Europe, Canada, Middle East, Africa)'),
+    'AP' => t('Armed Forces (Pacific)'),
+    'AS' => t('American Samoa'),
+    'FM' => t('Federated States of Micronesia'),
+    'GU' => t('Guam'),
+    'MH' => t('Marshall Islands'),
+    'MP' => t('Northern Mariana Islands'),
+    'PW' => t('Palau'),
+    'PR' => t('Puerto Rico'),
+    'VI' => t('Virgin Islands'),
+  );
+  $administrative_areas['VE'] = array(
+    'Z' => t('Amazonas'),
+    'B' => t('Anzoátegui'),
+    'C' => t('Apure'),
+    'D' => t('Aragua'),
+    'E' => t('Barinas'),
+    'F' => t('Bolívar'),
+    'G' => t('Carabobo'),
+    'H' => t('Cojedes'),
+    'Y' => t('Delta Amacuro'),
+    'W' => t('Dependencias Federales'),
+    'A' => t('Distrito Federal'),
+    'I' => t('Falcón'),
+    'J' => t('Guárico'),
+    'K' => t('Lara'),
+    'L' => t('Mérida'),
+    'M' => t('Miranda'),
+    'N' => t('Monagas'),
+    'O' => t('Nueva Esparta'),
+    'P' => t('Portuguesa'),
+    'R' => t('Sucre'),
+    'S' => t('Táchira'),
+    'T' => t('Trujillo'),
+    'X' => t('Vargas'),
+    'U' => t('Yaracuy'),
+    'V' => t('Zulia'),
+  );
+
+  // Allow other modules to alter the administrative areas.
+  drupal_alter('addressfield_administrative_areas', $administrative_areas);
+
+  return isset($administrative_areas[$country_code]) ? $administrative_areas[$country_code] : null;
+}

+ 66 - 0
sites/all/modules/contrib/fields/addressfield/addressfield.api.php

@@ -29,6 +29,72 @@ function CALLBACK_addressfield_format_callback(&$format, $address, $context = ar
   // No example.
 }
 
+/**
+ * Allows modules to alter the default values for an address field.
+ *
+ * @param $default_values
+ *   The array of default values. The country is populated from the
+ *   'default_country' widget setting.
+ * @param $context
+ *   An array with the following keys:
+ *   - field: The field array.
+ *   - instance: The instance array.
+ *   - address: The current address values. Allows for per-country defaults.
+ */
+function hook_addressfield_default_values_alter(&$default_values, $context) {
+  // If no other default country was provided, set it to France.
+  // Note: you might want to check $context['instance']['required'] and
+  // skip setting the default country if the field is optional.
+  if (empty($default_values['country'])) {
+    $default_values['country'] = 'FR';
+  }
+
+  // Determine the country for which other defaults should be provided.
+  $selected_country = $default_values['country'];
+  if (isset($context['address']['country'])) {
+    $selected_country = $context['address']['country'];
+  }
+
+  // Add defaults for the US.
+  if ($selected_country == 'US') {
+    $default_values['locality'] = 'New York';
+    $default_values['administrative_area'] = 'NY';
+  }
+}
+
+/**
+ * Allows modules to alter the predefined address formats.
+ *
+ * @param $address_formats
+ *   The array of all predefined address formats.
+ *
+ * @see addressfield_get_address_format()
+ */
+function hook_addressfield_address_formats_alter(&$address_formats) {
+  // Remove the postal_code from the list of required fields for China.
+  $address_formats['CN']['required_fields'] = array('locality', 'administrative_area');
+}
+
+/**
+ * Allows modules to alter the predefined administrative areas.
+ *
+ * @param $administrative_areas
+ *   The array of all predefined administrative areas.
+ *
+ * @see addressfield_get_administrative_areas()
+ */
+function hook_addressfield_administrative_areas_alter(&$administrative_areas) {
+  // Alter the label of the Spanish administrative area with the iso code PM.
+  $administrative_areas['ES']['PM'] = t('Balears / Baleares');
+
+  // Add administrative areas for imaginary country XT, keyed by their
+  // imaginary ISO codes.
+  $administrative_areas['XT'] = array(
+      'A' => t('Aland'),
+      'B' => t('Bland'),
+  );
+}
+
 /**
  * Allows modules to add arbitrary AJAX commands to the array returned from the
  * standard address field widget refresh.

+ 2 - 1
sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc

@@ -45,7 +45,7 @@ function _addressfield_sample_addresses() {
       if (is_resource($handle)) {
         $addresses = array();
         while (($buffer = fgets($handle)) !== false) {
-          list($country, $administrative_area, $sub_administrative_area, $locality, $dependent_locality, $postal_code, $thoroughfare, $premise) = explode("\t", $buffer);
+          list($country, $administrative_area, $sub_administrative_area, $locality, $dependent_locality, $postal_code, $thoroughfare, $premise, $sub_premise) = explode("\t", $buffer);
           $fields[] = array(
             'country' => ($country == 'NULL') ? NULL : trim($country),
             'administrative_area' => ($administrative_area == 'NULL') ? NULL : trim($administrative_area),
@@ -55,6 +55,7 @@ function _addressfield_sample_addresses() {
             'postal_code' => ($postal_code == 'NULL') ? NULL : trim($postal_code),
             'thoroughfare' => ($thoroughfare == 'NULL') ? NULL : trim($thoroughfare),
             'premise' => ($premise == 'NULL') ? NULL : trim($premise),
+            'sub_premise' => ($sub_premise == 'NULL') ? NULL : trim($sub_premise),
           );
         }
       }

+ 5 - 3
sites/all/modules/contrib/fields/addressfield/addressfield.info

@@ -5,11 +5,13 @@ package = Fields
 
 dependencies[] = ctools
 
+files[] = addressfield.migrate.inc
+files[] = views/addressfield_views_handler_field_country.inc
 files[] = views/addressfield_views_handler_filter_country.inc
 
-; Information added by drupal.org packaging script on 2013-05-07
-version = "7.x-1.0-beta4"
+; Information added by Drupal.org packaging script on 2015-01-16
+version = "7.x-1.0"
 core = "7.x"
 project = "addressfield"
-datestamp = "1367945112"
+datestamp = "1421426885"
 

+ 30 - 0
sites/all/modules/contrib/fields/addressfield/addressfield.install

@@ -184,3 +184,33 @@ function addressfield_update_7000() {
     }
   }
 }
+
+/**
+ * Sets the value of the new "Default country" setting.
+ */
+function addressfield_update_7001() {
+  $address_fields = array();
+  foreach (field_info_fields() as $field_name => $field_info) {
+    if ($field_info['type'] == 'addressfield') {
+      $address_fields[$field_name] = $field_name;
+    }
+  }
+
+  foreach (field_info_instances() as $entity_type => $bundles) {
+    foreach ($bundles as $bundle_name => $instances) {
+      foreach (array_intersect_key($instances, $address_fields) as $field_name => $instance) {
+        // Optional fields get the None default. Required fields get the
+        // previously selected default country.
+        $default_country = '';
+        if (!empty($instance['required']) && !empty($instance['default_value'])) {
+          $default_country = $instance['default_value']['country'];
+        }
+
+        $instance['widget']['settings']['default_country'] = $default_country;
+        unset($instance['default_value']);
+
+        field_update_instance($instance);
+      }
+    }
+  }
+}

+ 172 - 0
sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc

@@ -0,0 +1,172 @@
+<?php
+
+/**
+ * @file
+ * Base integration with the Migrate API class.
+ */
+
+/**
+ * Implements hook_migrate_api().
+ */
+function addressfield_migrate_api() {
+  $api = array(
+    'api' => 2,
+    'field handlers' => array('MigrateAddressFieldHandler'),
+  );
+  return $api;
+}
+
+/**
+ * Primary value passed to this field must be the two letter ISO country code of
+ * the address.
+ *
+ * Arguments are used to specify all the other values:
+ *   'administrative_area' - The administrative area of this address. (i.e. State/Province)
+ *   'sub_administrative_area' - The sub administrative area of this address.
+ *   'locality' - The locality of this address. (i.e. City)
+ *   'dependent_locality' - The dependent locality of this address.
+ *   'postal_code' - The postal code of this address.
+ *   'thoroughfare' - The thoroughfare of this address. (i.e. Street address)
+ *   'premise' - The premise of this address. (i.e. Apartment / Suite number)
+ *   'sub_premise' - The sub_premise of this address.
+ *   'organisation_name' - Contents of a primary OrganisationName element in the xNL XML.
+ *   'name_line' - Contents of a primary NameLine element in the xNL XML.
+ *   'first_name' - Contents of the FirstName element of a primary PersonName element in the xNL XML.
+ *   'last_name' - Contents of the LastName element of a primary PersonName element in the xNL XML.
+ *   'data' - Additional data for this address.
+ *
+ * Add the source field mappings to the argument array then add null mappings to
+ * avoid having fields flagged as as unmapped:
+ * @code
+ *   // The country should be passed in as the primary value.
+ *   $this->addFieldMapping('field_address', 'profile_country');
+ *   $this->addFieldMapping('field_address:thoroughfare', 'profile_address');
+ *   $this->addFieldMapping('field_address:locality', 'profile_city');
+ *   $this->addFieldMapping('field_address:administrative_area', 'profile_state');
+ * @endcode
+ */
+class MigrateAddressFieldHandler extends MigrateFieldHandler {
+  public function __construct() {
+    $this->registerTypes(array('addressfield'));
+  }
+
+  /**
+   * Provide subfields for the addressfield columns.
+   */
+  public function fields() {
+    // Declare our arguments to also be available as subfields.
+    $fields = array(
+      'administrative_area' => t('<a href="@doc">The administrative area of ' .
+          'this address (i.e. State/Province)</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#administrative_area')),
+      'sub_administrative_area' => t('<a href="@doc">The sub administrative ' .
+          'area of this address</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#sub_administrative_area')),
+      'locality' => t('<a href="@doc">The locality of this address (i.e. ' .
+          'City)</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#locality')),
+      'dependent_locality' => t('<a href="@doc">The dependent locality of ' .
+          'this address</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#dependent_locality')),
+      'postal_code' => t('<a href="@doc">The postal code of this address</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#postal_code')),
+      'thoroughfare' => t('<a href="@doc">The thoroughfare of this address ' .
+          '(i.e. Street address)</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#thoroughfare')),
+      'premise' => t('<a href="@doc">The premise of this address (i.e. Apartment / Suite number)</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#premise')),
+      'sub_premise' => t('<a href="@doc">The sub_premise of this address</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#sub_premise')),
+      'organisation_name' => t('<a href="@doc">Contents of a primary ' .
+          'OrganisationName element in the xNL XML</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#organisation_name')),
+      'name_line' => t('<a href="@doc">Contents of a primary NameLine element ' .
+          'in the xNL XML</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#name_line')),
+      'first_name' => t('<a href="@doc">Contents of the FirstName element of ' .
+          'a primary PersonName element in the xNL XML</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#first_name')),
+      'last_name' => t('<a href="@doc">Contents of the LastName element of a ' .
+          'primary PersonName element in the xNL XML</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#last_name')),
+      'data' => t('<a href="@doc">Additional data for this address</a>',
+        array('@doc' => 'http://drupal.org/node/1996546#data')),
+    );
+    return $fields;
+  }
+
+  /**
+   * Implements MigrateFieldHandler::prepare().
+   *
+   * @param $entity
+   * @param array $field_info
+   * @param array $instance
+   * @param array $values
+   *
+   * @return null
+   */
+  public function prepare($entity, array $field_info, array $instance,
+                          array $values) {
+    $arguments = array();
+    if (isset($values['arguments'])) {
+      $arguments = array_filter($values['arguments']);
+      unset($values['arguments']);
+    }
+    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
+
+    // Setup the standard Field API array for saving.
+    $delta = 0;
+    foreach ($values as $value) {
+      $return[$language][$delta] = array('country' => $value)
+        + $this->prepareArguments($arguments, $field_info, $delta);
+      $delta++;
+    }
+
+    return isset($return) ? $return : NULL;
+  }
+
+  /**
+   * Builds an array with additional data for the current $delta.
+   *
+   * @param  array $arguments
+   * @param  array $field_info
+   * @param  $delta
+   *
+   * @return array
+   */
+  protected function prepareArguments(array $arguments, array $field_info, $delta) {
+    $result = array();
+    $data = array();
+
+    foreach ($arguments as $column_key => $column_value) {
+      $value = NULL;
+
+      if (is_array($arguments[$column_key])) {
+        if (!empty($arguments[$column_key][$delta])) {
+          $value = $arguments[$column_key][$delta];
+        }
+      }
+      else {
+        $value = $arguments[$column_key];
+      }
+
+      if ($value) {
+        if (isset($field_info['columns'][$column_key])) {
+          // Store the data in a seperate column.
+          $result[$column_key] = $value;
+        }
+        else {
+          // Add the data to the 'data' column.
+          $data[$column_key] = $value;
+        }
+      }
+    }
+
+    // Store all the other data as a serialized array in the data field.
+    if (!empty($data)) {
+      $result['data'] = serialize($data);
+    }
+
+    return $result;
+  }
+}

+ 197 - 88
sites/all/modules/contrib/fields/addressfield/addressfield.module

@@ -34,6 +34,33 @@ function addressfield_views_api() {
   );
 }
 
+/**
+ * Implements hook_module_implements_alter().
+ *
+ * Moves the hook_token_info_alter() implementation to the bottom so it is
+ * invoked after all modules implementing the same hook.
+ */
+function addressfield_module_implements_alter(&$implementations, $hook) {
+  if ($hook == 'token_info_alter') {
+    // Make sure that the $implementations list is populated before altering it,
+    // to work around a crash experienced by some people (#2181001).
+    if (isset($implementations['addressfield'])) {
+      $group = $implementations['addressfield'];
+      unset($implementations['addressfield']);
+      $implementations['addressfield'] = $group;
+    }
+  }
+}
+
+/**
+ * Returns TRUE if a field map array value represents an addressfield.
+ *
+ * Provided for use as a callback by array_filter().
+ */
+function addressfield_field_map_filter($field) {
+  return !empty($field['type']) && $field['type'] == 'addressfield';
+}
+
 /**
  * Get the list of format plugins.
  */
@@ -119,7 +146,10 @@ function addressfield_generate($address, array $handlers, array $context = array
 
   ctools_include('plugins');
   $format = array();
-  $format['#handlers'] = $handlers;
+  // Add the handlers, ordered by weight.
+  $plugins = addressfield_format_plugins();
+  $format['#handlers'] = array_intersect(array_keys($plugins), $handlers);
+
   foreach ($format['#handlers'] as $handler) {
     if ($callback = ctools_plugin_load_function('addressfield', 'format', $handler, 'format callback')) {
       $callback($format, $address, $context);
@@ -133,7 +163,6 @@ function addressfield_generate($address, array $handlers, array $context = array
   if ($context['mode'] == 'form') {
     $format['#addressfield'] = TRUE;
     $format['#process'][] = 'addressfield_process_format_form';
-    $format['#required'] = FALSE;
   }
   elseif ($context['mode'] == 'render') {
     $format['#pre_render'][] = 'addressfield_render_address';
@@ -152,39 +181,43 @@ function addressfield_process_format_form($format, &$form_state, $complete_form)
     ctools_plugin_load_function('addressfield', 'format', $handler, 'format callback');
   }
 
-  _addressfield_process_format_form($format, $format['#address'], $format['#required']);
+  _addressfield_process_format_form($format, $format['#address']);
   return $format;
 }
 
-function _addressfield_process_format_form(&$format, $address, $required) {
+function _addressfield_process_format_form(&$format, $address) {
   foreach (element_children($format) as $key) {
     $child = &$format[$key];
 
-    // Automatically expand elements that matches one of the field of the
-    // address structure.
+    // Automatically convert any element in the format array to an appropriate
+    // form element that matches one of the address component names.
     if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'))) {
-      // Set the type.
+      // Set the form element type for the address component to whatever the
+      // address format specified in its #widget_type property.
       if (isset($child['#widget_type'])) {
         $child['#type'] = $child['#widget_type'];
       }
       else {
+        // If the element didn't specify a #widget_type and has options, turn it
+        // into a select list and unset its #size value, which is typically used
+        // to provide the width of a textfield.
         if (isset($child['#options'])) {
           $child['#type'] = 'select';
-          $child['#size'] = 0;
+          unset($child['#size']);
         }
         else {
+          // Otherwise go ahead and make it a textfield.
           $child['#type'] = 'textfield';
         }
       }
-      if (!$required) {
-        unset($child['#required']);
-      }
 
-      $child['#default_value'] = $address[$key];
+      if (isset($address[$key])) {
+        $child['#default_value'] = $address[$key];
+      }
     }
 
-    // Recurse through the child.
-    _addressfield_process_format_form($child, $address, $required);
+    // Recurse through the element's children if it has any.
+    _addressfield_process_format_form($child, $address);
   }
 }
 
@@ -200,8 +233,8 @@ function _addressfield_render_address(&$format, $address) {
   foreach (element_children($format) as $key) {
     $child = &$format[$key];
 
-    // Automatically expand elements that matches one of the field of the
-    // address structure.
+    // Automatically expand elements that match one of the fields of the address
+    // structure.
     if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'), TRUE)) {
       if (isset($child['#render_type'])) {
         $child['#type'] = $child['#render_type'];
@@ -216,12 +249,15 @@ function _addressfield_render_address(&$format, $address) {
       // If the element instructs us to render the option value instead of the
       // raw address element value and its #options array has a matching key,
       // swap it out for the option value now.
-      if (!empty($child['#render_option_value']) && isset($child['#options'][$address[$key]])) {
+      if (!empty($child['#render_option_value']) && isset($address[$key]) && isset($child['#options'][$address[$key]])) {
         $child['#children'] = check_plain($child['#options'][$address[$key]]);
       }
-      else {
+      elseif (isset($address[$key])) {
         $child['#children'] = check_plain($address[$key]);
       }
+      else {
+        $child['#children'] = '';
+      }
 
       // Skip empty elements.
       if ((string) $child['#children'] === '') {
@@ -261,8 +297,12 @@ function addressfield_theme() {
  */
 function theme_addressfield_container($variables) {
   $element = $variables['element'];
-
   $element['#children'] = trim($element['#children']);
+  // Remove the autocomplete attributes because the W3C validator complains.
+  // They are only used on forms anyway.
+  unset($element['#attributes']['autocomplete']);
+  unset($element['#attributes']['x-autocompletetype']);
+
   if (strlen($element['#children']) > 0) {
     $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
     $output .= $element['#children'];
@@ -321,22 +361,27 @@ function addressfield_field_info() {
 
 /**
  * Returns an array of default values for the addressfield form elements.
- */
-function addressfield_default_values($available_countries = NULL) {
-  if (!isset($available_countries)) {
-    $available_countries = _addressfield_country_options_list();
-  }
-
-  // Use the default country of the site if possible.
-  $default_country = variable_get('site_default_country', NULL);
-
-  // If the default country is undefined or not in the list of available countries,
-  // just fallback to the first country in the list.
-  if (!$default_country || !isset($available_countries[$default_country])) {
+ *
+ * @param $field
+ *   The field array.
+ * @param $instance
+ *   The instance array.
+ * @param $address
+ *   The current address values, if known. Allows for per-country defaults.
+ *
+ * @return
+ *   An array of default values.
+ */
+function addressfield_default_values($field, $instance, array $address = array()) {
+  $available_countries = _addressfield_country_options_list($field, $instance);
+  $default_country = $instance['widget']['settings']['default_country'];
+  // If the default country is not in the list of available countries,
+  // fallback to the first country in the list.
+  if ($default_country && !isset($available_countries[$default_country])) {
     $default_country = key($available_countries);
   }
 
-  return array(
+  $default_values = array(
     'country' => $default_country,
     'name_line' => '',
     'first_name' => '',
@@ -352,6 +397,16 @@ function addressfield_default_values($available_countries = NULL) {
     'sub_premise' => '',
     'data' => '',
   );
+
+  // Allow other modules to alter the default values.
+  $context = array(
+    'field' => $field,
+    'instance' => $instance,
+    'address' => $address,
+  );
+  drupal_alter('addressfield_default_values', $default_values, $context);
+
+  return $default_values;
 }
 
 /**
@@ -363,6 +418,35 @@ function addressfield_field_is_empty($item, $field) {
   return empty($item['country']);
 }
 
+/**
+ * Implements hook_field_presave().
+ */
+function addressfield_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+  foreach ($items as $delta => &$item) {
+    // If the first name and last name are set but the name line isn't...
+    if (isset($item['first_name']) && isset($item['last_name']) && !isset($item['name_line'])) {
+      // Combine the first and last name to be the name line.
+      $items[$delta]['name_line'] = $items[$delta]['first_name'] . ' ' . $items[$delta]['last_name'];
+    }
+    elseif (isset($item['name_line'])) {
+      // Otherwise if the name line is set, separate it out into a best guess at
+      // the first and last name.
+      $names = explode(' ', $item['name_line']);
+
+      $item['first_name'] = array_shift($names);
+      $item['last_name'] = implode(' ', $names);
+    }
+
+    // Trim whitespace from all of the address components and convert any double
+    // spaces to single spaces.
+    foreach ($item as $key => &$value) {
+      if (!in_array($key, array('data')) && is_string($value)) {
+        $value = trim(str_replace('  ', ' ', $value));
+      }
+    }
+  }
+}
+
 /**
  * Implements hook_field_widget_info()
  */
@@ -374,6 +458,7 @@ function addressfield_field_widget_info() {
     'field types' => array('addressfield'),
     'settings' => array(
       'available_countries' => array(),
+      'default_country' => '',
       'format_handlers' => array('address'),
     ),
   );
@@ -399,7 +484,13 @@ function addressfield_field_widget_settings_form($field, $instance) {
       '#options' => _addressfield_country_options_list(),
       '#default_value' => $settings['available_countries'],
     );
-
+    $form['default_country'] = array(
+      '#type' => 'select',
+      '#title' => t('Default country'),
+      '#options' => _addressfield_country_options_list(),
+      '#default_value' => $settings['default_country'],
+      '#empty_value' => '',
+    );
     $form['format_handlers'] = array(
       '#type' => 'checkboxes',
       '#title' => t('Format handlers'),
@@ -411,41 +502,38 @@ function addressfield_field_widget_settings_form($field, $instance) {
   return $form;
 }
 
+/**
+ * Implements hook_form_BASE_FORM_ID_alter().
+ *
+ * Removes the default values form from the field settings page.
+ * Allows the module to implement its own, more predictable default value
+ * handling, getting around #1253820 and other bugs.
+ */
+function addressfield_form_field_ui_field_edit_form_alter(&$form, $form_state) {
+  if ($form['#field']['type'] == 'addressfield') {
+    $form['instance']['default_value_widget']['#access'] = FALSE;
+  }
+}
+
 /**
  * Implements hook_field_widget_form()
  */
 function addressfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $settings = $instance['widget']['settings'];
 
-  // Generate a specific key used to identify this element to restore a default
-  // value upon AJAX submission regardless of where this element is in the
-  // $form array.
-  $element_key = implode('|', array($element['#entity_type'], $element['#bundle'], $element['#field_name'], $element['#language'], $element['#delta']));
-
-  // Store the key in the element array as a value so it can be easily retrieved
-  // in context in the $form_state['values'] array in the element validator.
-  $element['element_key'] = array(
-    '#type' => 'value',
-    '#value' => $element_key,
-  );
-
-  // Get the default address used to build the widget form elements, looking
-  // first in the form state, then in the stored value for the field, and then
-  // in the default values of the instance.
   $address = array();
-
-  if (!empty($form_state['addressfield'][$element_key])) {
-    // Use the value from the form_state if available.
-    $address = $form_state['addressfield'][$element_key];
+  // If the form has been rebuilt via AJAX, use the form state values.
+  // $form_state['values'] is empty because of #limit_validation_errors, so
+  // $form_state['input'] needs to be used instead.
+  $parents = array_merge($element['#field_parents'], array($element['#field_name'], $langcode, $delta));
+  $input_address = drupal_array_get_nested_value($form_state['input'], $parents);
+  if (!empty($input_address)) {
+    $address = $input_address;
   }
   elseif (!empty($items[$delta]['country'])) {
     // Else use the saved value for the field.
     $address = $items[$delta];
   }
-  else {
-    // Otherwise use the instance default.
-    $address = (array) $instance['default_value'][0];
-  }
 
   // Determine the list of available countries, and if the currently selected
   // country is not in it, unset it so it can be reset to the default country.
@@ -454,8 +542,8 @@ function addressfield_field_widget_form(&$form, &$form_state, $field, $instance,
     unset($address['country']);
   }
 
-  // Merge in default values to provide a value for every expected array key.
-  $address += addressfield_default_values($countries);
+  // Merge in default values.
+  $address += addressfield_default_values($field, $instance, $address);
 
   // Add the form elements for the standard widget, which includes a country
   // select list at the top that reloads the available address elements when the
@@ -466,6 +554,19 @@ function addressfield_field_widget_form(&$form, &$form_state, $field, $instance,
     // in that context, and it is overridable if necessary.
     $element['#type'] = 'fieldset';
 
+    if (!empty($instance['description'])) {
+      // Checkout panes convert the fieldset into a container, causing
+      // #description to not be rendered. Hence, a real element is added and
+      // the old #description is removed.
+      $element['#description'] = '';
+      $element['element_description'] = array(
+        '#markup' =>  $instance['description'],
+        '#prefix' => '<div class="fieldset-description">',
+        '#suffix' => '</div>',
+        '#weight' => -999,
+      );
+    }
+
     // Generate the address form.
     $context = array(
       'mode' => 'form',
@@ -476,32 +577,39 @@ function addressfield_field_widget_form(&$form, &$form_state, $field, $instance,
     );
     $element += addressfield_generate($address, $settings['format_handlers'], $context);
 
-    // Mark the form element as required if necessary.
-    $element['#required'] = $delta == 0 && $instance['required'];
+    // Remove any already saved default value.
+    // See addressfield_form_field_ui_field_edit_form_alter() for the reasoning.
+    if ($form_state['build_info']['form_id'] == 'field_ui_field_edit_form') {
+      $element['#address'] = array('country' => '');
+    }
   }
 
   return $element;
 }
 
 /**
- * Element validate callback: rebuilds the form on country change and stores the
- * current address value in the $form_state for retrieval on rebuild.
+ * Element validate callback: rebuilds the form on country change.
  */
 function addressfield_standard_country_validate($element, &$form_state) {
-  // If the country was changed, rebuild the form.
   if ($element['#default_value'] != $element['#value']) {
-    $form_state['rebuild'] = TRUE;
-  }
-
-  $parents = $element['#parents'];
-  array_pop($parents);
+    $parents = $element['#parents'];
+    array_pop($parents);
+    $address = drupal_array_get_nested_value($form_state['values'], $parents);
+
+    // Clear the country-specific field values.
+    $country_specific_data = array(
+      'dependent_locality' => '',
+      'locality' => '',
+      'administrative_area' => '',
+      'postal_code' => '',
+    );
+    $address = array_diff_key($address, $country_specific_data);
 
-  // Search through the form values to find the current address.
-  $address = drupal_array_get_nested_value($form_state['values'], $parents);
+    drupal_array_set_nested_value($form_state['values'], $parents, $address);
+    drupal_array_set_nested_value($form_state['input'], $parents, $address);
 
-  // Store the present address values in the form state for retrieval by the
-  // widget form regardless of where the widget sits in the $form array.
-  $form_state['addressfield'][$address['element_key']] = array_diff_key($address, array('element_key' => ''));
+    $form_state['rebuild'] = TRUE;
+  }
 }
 
 /**
@@ -531,6 +639,9 @@ function addressfield_standard_widget_refresh($form, $form_state) {
   // new country select list.
   $commands[] = ajax_command_replace(NULL, render($element));
   $commands[] = ajax_command_invoke('#' . $element['country']['#id'], 'focus');
+  // Add the status messages inside the new addressfield's wrapper element,
+  // just like core does.
+  $commands[] = ajax_command_prepend(NULL, theme('status_messages'));
 
   // Allow other modules to add arbitrary AJAX commands on the refresh.
   drupal_alter('addressfield_standard_widget_refresh', $commands, $form, $form_state);
@@ -679,12 +790,8 @@ function addressfield_property_info_callback(&$info, $entity_type, $field, $inst
  *
  * @see addressfield_property_info_callback()
  */
-function addressfield_auto_creation() {
-  // We can't call addressfield_default_values() directly, because it has an
-  // optional array argument that will receive an invalid value when Entity API
-  // tries to call it directly with its usual $property_name and $context
-  // arguments.
-  return addressfield_default_values();
+function addressfield_auto_creation($property_name, $context) {
+  return addressfield_default_values($context['field'], $context['instance']);
 }
 
 /**
@@ -730,6 +837,9 @@ function addressfield_data_property_info($name = NULL) {
     'premise' => array(
       'label' => t('Premise (i.e. Apartment / Suite number)'),
     ),
+    'sub_premise' => array(
+      'label' => t('Sub Premise (i.e. Suite, Apartment, Floor, Unknown.'),
+    ),
   );
 
   // Add the default values for each of the address field properties.
@@ -746,13 +856,16 @@ function addressfield_data_property_info($name = NULL) {
 }
 
 /**
- * Wraps country_get_list() for use as an Entity API options list.
+ * Returns the country list in a format suitable for use as an options list.
  */
 function _addressfield_country_options_list($field = NULL, $instance = NULL) {
-  // Necessary for country_get_list().
-  require_once DRUPAL_ROOT . '/includes/locale.inc';
-
-  $countries = country_get_list();
+  if (module_exists('countries')) {
+    $countries = countries_get_countries('name', array('enabled' => COUNTRIES_ENABLED));
+  }
+  else {
+    require_once DRUPAL_ROOT . '/includes/locale.inc';
+    $countries = country_get_list();
+  }
 
   if (isset($field)) {
     // If the instance is not specified, loop against all the instances of the field.
@@ -771,10 +884,6 @@ function _addressfield_country_options_list($field = NULL, $instance = NULL) {
     foreach ($instances as $instance) {
       if (!empty($instance['widget']['settings']['available_countries'])) {
         $countries = array_intersect_key($countries, $instance['widget']['settings']['available_countries']);
-      }
-      else {
-        // This instance allow all the countries.
-        $countries = country_get_list();
         break;
       }
     }

+ 233 - 0
sites/all/modules/contrib/fields/addressfield/addressfield.tokens.inc

@@ -0,0 +1,233 @@
+<?php
+
+/**
+ * @file
+ * Token module integration.
+ */
+
+/**
+ * Implements hook_token_info().
+ */
+function addressfield_token_info() {
+  $type = array(
+    'name' => t('Address field'),
+    'description' => t('Tokens related to address field values and their components.'),
+    'needs-data' => 'address-field',
+    'field' => TRUE,
+  );
+
+  // Define tokens for the various components of addresses supported through the
+  // user interface along with two helper tokens for country and administrative
+  // area to distinguish between names and abbreviations.
+  $info['country'] = array(
+    'name' => t('Country name'),
+    'description' => t('The full name of the country.'),
+  );
+  $info['country-code'] = array(
+    'name' => t('Country code'),
+    'description' => t('The two letter ISO country code.'),
+  );
+  $info['administrative-area'] = array(
+    'name' => t('Administrative area (i.e. State/Province)'),
+    'description' => t('The administrative area value, expanded to the full name if applicable.'),
+  );
+  $info['administrative-area-raw'] = array(
+    'name' => t('Administrative area (raw value)'),
+    'description' => t('The raw administrative area value.'),
+  );
+  $info['locality'] = array(
+    'name' => t('Locality (i.e. City)'),
+    'description' => t('The locality value.'),
+  );
+  $info['postal-code'] = array(
+    'name' => t('Postal code'),
+    'description' => t('The postal code value.'),
+  );
+  $info['thoroughfare'] = array(
+    'name' => t('Thoroughfare (i.e. Street address)'),
+    'description' => t('The thoroughfare value.'),
+  );
+  $info['premise'] = array(
+    'name' => t('Premise (i.e. Street address)'),
+    'description' => t('The premise value.'),
+  );
+  $info['sub_premise'] = array(
+    'name' => t('Sub Premise (i.e. Suite, Apartment, Floor, Unknown.)'),
+    'description' => t('The sub premise value.'),
+  );
+  $info['organisation'] = array(
+    'name' => t('Organisation'),
+    'description' => t('The organisation name value.'),
+  );
+  $info['name-line'] = array(
+    'name' => t('Full name'),
+    'description' => t('The name line value of the address.'),
+  );
+  $info['first-name'] = array(
+    'name' => t('First name'),
+    'description' => t('The first name value.'),
+  );
+  $info['last-name'] = array(
+    'name' => t('Last name'),
+    'description' => t('The last name value.'),
+  );
+
+  // Add a helper token to format addresses as expected by MailChimp.
+  $info['format-mailchimp'] = array(
+    'name' => t('Address formatted for MailChimp'),
+    'description' => t('The full address formatted for import into MailChimp.'),
+  );
+
+  return array(
+    'types' => array('address-field' => $type),
+    'tokens' => array('address-field' => $info),
+  );
+}
+
+/**
+ * Implements hook_token_info_alter().
+ */
+function addressfield_token_info_alter(&$data) {
+  // Loop over every address field on the site.
+  foreach (array_filter(field_info_field_map(), 'addressfield_field_map_filter') as $field_name => $field) {
+    foreach ($data['tokens'] as $group => $token){
+      if (isset($data['tokens'][$group][$field_name]) && is_array($data['tokens'][$group][$field_name])) {
+        // Set the token type for the field to use the addressfield child tokens.
+        $data['tokens'][$group][$field_name]['type'] = 'address-field';
+      }
+    }
+  }
+}
+
+/**
+ * Implements hook_tokens().
+ */
+function addressfield_tokens($type, $tokens, array $data = array(), array $options = array()) {
+  if (isset($options['language'])) {
+    $language_code = $options['language']->language;
+  }
+  else {
+    $language_code = LANGUAGE_NONE;
+  }
+
+  $sanitize = !empty($options['sanitize']);
+
+  $replacements = array();
+
+  // If we're generating tokens for an address field, extract the address data
+  // from the field value array and generate the necessary replacements.
+  if ($type == 'address-field' && !empty($data['address-field'][$language_code]) && is_array($data['address-field'][$language_code])) {
+    $address = reset($data['address-field'][$language_code]);
+
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        case 'country':
+          $countries = _addressfield_country_options_list();
+          $replacements[$original] = $sanitize ? check_plain($countries[$address['country']]) : $countries[$address['country']];
+          break;
+
+        case 'country-code':
+          $replacements[$original] = $sanitize ? check_plain($address['country']) : $address['country'];
+          break;
+
+        case 'administrative-area':
+          // If we received format handlers in the data array, generate the form
+          // for the address field to see if the administrative area should be
+          // expanded from an abbreviation to a related name.
+          $administrative_area = $address['administrative_area'];
+
+          if (!empty($data['format_handlers'])) {
+            $form = addressfield_generate($address, $data['format_handlers'], array('mode' => 'form'));
+
+            if (!empty($form['locality_block']['administrative_area']['#options'][$administrative_area])) {
+              $administrative_area = $form['locality_block']['administrative_area']['#options'][$administrative_area];
+            }
+          }
+
+          $replacements[$original] = $sanitize ? check_plain($administrative_area) : $administrative_area;
+          break;
+
+        case 'administrative-area-raw':
+          $replacements[$original] = $sanitize ? check_plain($address['administrative_area']) : $address['administrative_area'];
+          break;
+
+        case 'locality':
+          $replacements[$original] = $sanitize ? check_plain($address['locality']) : $address['locality'];
+          break;
+
+        case 'postal-code':
+          $replacements[$original] = $sanitize ? check_plain($address['postal_code']) : $address['postal_code'];
+          break;
+
+        case 'thoroughfare':
+          $replacements[$original] = $sanitize ? check_plain($address['thoroughfare']) : $address['thoroughfare'];
+          break;
+
+        case 'premise':
+          $replacements[$original] = $sanitize ? check_plain($address['premise']) : $address['premise'];
+          break;
+
+        case 'sub_premise':
+          $replacements[$original] = $sanitize ? check_plain($address['sub_premise']) : $address['sub_premise'];
+          break;
+
+        case 'organisation':
+          $replacements[$original] = $sanitize ? check_plain($address['organisation_name']) : $address['organisation_name'];
+          break;
+
+        case 'name-line':
+          $replacements[$original] = $sanitize ? check_plain($address['name_line']) : $address['name_line'];
+          break;
+
+        case 'first-name':
+          $replacements[$original] = $sanitize ? check_plain($address['first_name']) : $address['first_name'];
+          break;
+
+        case 'last-name':
+          $replacements[$original] = $sanitize ? check_plain($address['last_name']) : $address['last_name'];
+          break;
+
+        // See: http://kb.mailchimp.com/article/how-do-i-format-my-list-fields-to-import-them
+        case 'format-mailchimp':
+          $components = array();
+
+          foreach (array('thoroughfare', 'premise', 'locality', 'administrative_area', 'postal_code', 'country') as $component) {
+            if (!empty($address[$component])) {
+              $components[] = $address[$component];
+            }
+          }
+
+          $format_mailchimp = implode('  ', $components);
+          $replacements[$original] = $sanitize ? check_plain($format_mailchimp) : $format_mailchimp;
+          break;
+      }
+    }
+  }
+
+  // The Token module extends direct token generation by using a generic entity
+  // token generation process. Since we intend to overwrite the default Token
+  // module implementation of address field tokens, we use this generic token
+  // generation process to find and replace address field tokens on relevant
+  // entities. This ensures our tokens aren't overwritten by the Token module
+  // and helps us avoid having to do the entity detection ourselves.
+  if ($type == 'entity') {
+    // Loop over the address fields defined on the site.
+    foreach (array_filter(field_info_field_map(), 'addressfield_field_map_filter') as $field_name => $field) {
+      // If there are any address field tokens in the token list...
+      if ($addressfield_tokens = token_find_with_prefix($tokens, $field_name)) {
+        // If the current field is on the matching entity type...
+        if (!empty($field['bundles'][$data['entity_type']])) {
+          // Extract the format handlers selected in a representative instance
+          // settings form for use in formatting tokens.
+          $instance = field_info_instance($data['entity_type'], $field_name, reset($field['bundles'][$data['entity_type']]));
+          $format_handlers = $instance['widget']['settings']['format_handlers'];
+        }
+
+        // Generate the necessary address field tokens for the entity.
+        $replacements += token_generate('address-field', $addressfield_tokens, array('address-field' => $data['entity']->$field_name, 'format_handlers' => $format_handlers), $options);
+      }
+    }
+  }
+
+  return $replacements;
+}

+ 3 - 3
sites/all/modules/contrib/fields/addressfield/example/addressfield_example.info

@@ -7,9 +7,9 @@ hidden = TRUE
 dependencies[] = ctools
 dependencies[] = addressfield
 
-; Information added by drupal.org packaging script on 2013-05-07
-version = "7.x-1.0-beta4"
+; Information added by Drupal.org packaging script on 2015-01-16
+version = "7.x-1.0"
 core = "7.x"
 project = "addressfield"
-datestamp = "1367945112"
+datestamp = "1421426885"
 

+ 0 - 0
sites/all/modules/contrib/fields/addressfield/example/plugins/format/addressfield-example.inc → sites/all/modules/contrib/fields/addressfield/example/plugins/format/address-ch-example.inc


+ 3 - 4
sites/all/modules/contrib/fields/addressfield/plugins/format/address-hide-country.inc

@@ -18,10 +18,9 @@ $plugin = array(
  * @see CALLBACK_addressfield_format_callback()
  */
 function addressfield_format_address_hide_country(&$format, $address, $context = array()) {
-  // When building the format for a form, we expect the country element to have
-  // an #options list. If it does, and there is only one option, hide the field
-  // by setting #access to FALSE.
-  if ($context['mode'] == 'form') {
+  // Hide the country element only if the whole field is required, otherwise
+  // there will always be an additional None option.
+  if ($context['mode'] == 'form' && $context['instance']['required']) {
     if (!empty($format['country']['#options']) && count($format['country']['#options']) == 1) {
       $format['country']['#access'] =  FALSE;
     }

+ 24 - 0
sites/all/modules/contrib/fields/addressfield/plugins/format/address-hide-postal-code.inc

@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @file
+ * Hide the postal code field.
+ */
+
+$plugin = array(
+  'title' => t('Hide the postal code'),
+  'format callback' => 'addressfield_format_address_hide_postal_code',
+  'type' => 'address',
+  'weight' => -85,
+);
+
+/**
+ * Format callback.
+ *
+ * @see CALLBACK_addressfield_format_callback()
+ */
+function addressfield_format_address_hide_postal_code(&$format, $address, $context = array()) {
+  if (isset($format['locality_block']['postal_code'])) {
+    $format['locality_block']['postal_code']['#access'] = FALSE;
+  }
+}

+ 24 - 0
sites/all/modules/contrib/fields/addressfield/plugins/format/address-hide-street.inc

@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @file
+ * Hide the street address fields.
+ */
+
+$plugin = array(
+  'title' => t('Hide the street address'),
+  'format callback' => 'addressfield_format_address_hide_street',
+  'type' => 'address',
+  'weight' => -85,
+);
+
+/**
+ * Format callback.
+ *
+ * @see CALLBACK_addressfield_format_callback()
+ */
+function addressfield_format_address_hide_street(&$format, $address, $context = array()) {
+  if (isset($format['street_block'])) {
+    $format['street_block']['#access'] = FALSE;
+  }
+}

+ 36 - 0
sites/all/modules/contrib/fields/addressfield/plugins/format/address-optional.inc

@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * @file
+ * Make all fields optional.
+ * Allows users to save incomplete addresses, bypassing validation.
+ */
+
+$plugin = array(
+  'title' => t('Make all fields optional (Not recommended)'),
+  'format callback' => 'addressfield_format_address_optional',
+  'type' => 'address',
+  'weight' => 100,
+);
+
+/**
+ * Format callback.
+ *
+ * @see CALLBACK_addressfield_format_callback()
+ */
+function addressfield_format_address_optional(&$format, $address, $context = array()) {
+  if (isset($format['name_block'])) {
+    if (isset($format['name_block']['name_line'])) {
+      $format['name_block']['name_line']['#required'] = FALSE;
+    }
+    elseif (isset($format['name_block']['first_name'])) {
+      $format['name_block']['first_name']['#required'] = FALSE;
+      $format['name_block']['last_name']['#required'] = FALSE;
+    }
+  }
+  $format['street_block']['thoroughfare']['#required'] = FALSE;
+  $format['locality_block']['postal_code']['#required'] = FALSE;
+  $format['locality_block']['dependent_locality']['#required'] = FALSE;
+  $format['locality_block']['locality']['#required'] = FALSE;
+  $format['locality_block']['administrative_area']['#required'] = FALSE;
+}

+ 174 - 356
sites/all/modules/contrib/fields/addressfield/plugins/format/address.inc

@@ -18,370 +18,222 @@ $plugin = array(
  * @see CALLBACK_addressfield_format_callback()
  */
 function addressfield_format_address_generate(&$format, $address, $context = array()) {
-  // We start with a reasonable default: a simple block format suitable
-  // for international shipping. We extend it with country-specific heuristics
-  // below.
+  // Load the predefined address format for the selected country.
+  module_load_include('inc', 'addressfield', 'addressfield.address_formats');
+  $address_format = addressfield_get_address_format($address['country']);
+
+  // Used to move certain fields to their own row.
+  $clearfix = '<div class="clearfix"></div>';
 
   // The street block.
   $format['street_block'] = array(
     '#type' => 'addressfield_container',
-    '#attributes' => array('class' => array('street-block')),
+    '#attributes' => array(
+      'class' => array('street-block'),
+    ),
     '#weight' => 0,
   );
   $format['street_block']['thoroughfare'] = array(
     '#title' => t('Address 1'),
     '#tag' => 'div',
-    '#attributes' => array('class' => array('thoroughfare')),
+    '#attributes' => array(
+      'class' => array('thoroughfare'),
+      'x-autocompletetype' => 'address-line1',
+      'autocomplete' => 'address-line1',
+    ),
     '#size' => 30,
-    // The #required will be automatically set to FALSE when processing.
     '#required' => TRUE,
   );
   $format['street_block']['premise'] = array(
     '#title' => t('Address 2'),
     '#tag' => 'div',
-    '#attributes' => array('class' => array('premise')),
+    '#attributes' => array(
+      'class' => array('premise'),
+      'x-autocompletetype' => 'address-line2',
+      'autocomplete' => 'address-line2',
+    ),
     '#size' => 30,
   );
   $format['locality_block'] = array(
     '#type' => 'addressfield_container',
-    '#attributes' => array('class' => array('addressfield-container-inline', 'locality-block', 'country-' . $address['country'])),
+    '#attributes' => array(
+      'class' => array('addressfield-container-inline', 'locality-block', 'country-' . $address['country']),
+    ),
     '#weight' => 50,
   );
   $format['locality_block']['#attached']['css'][] = drupal_get_path('module', 'addressfield') . '/addressfield.css';
   $format['locality_block']['postal_code'] = array(
-    '#title' => t('Postal code'),
+    '#title' => $address_format['postal_code_label'],
+    '#required' => in_array('postal_code', $address_format['required_fields']),
+    '#access' => in_array('postal_code', $address_format['used_fields']),
     '#size' => 10,
-    '#required' => TRUE,
-    '#attributes' => array('class' => array('postal-code')),
+    '#attributes' => array(
+      'class' => array('postal-code'),
+      'x-autocompletetype' => 'postal-code',
+      'autocomplete' => 'postal-code',
+    ),
+  );
+  $format['locality_block']['dependent_locality'] = array(
+    '#title' => $address_format['dependent_locality_label'],
+    '#required' => in_array('dependent_locality', $address_format['required_fields']),
+    '#access' => in_array('dependent_locality', $address_format['used_fields']),
+    '#size' => 25,
+    '#tag' => 'div',
+    '#attributes' => array(
+      'class' => array('dependent-locality')
+    ),
+    // Most formats place this field in its own row.
+    '#suffix' => $clearfix,
   );
   $format['locality_block']['locality'] = array(
-    '#title' => t('City'),
+    '#title' => $address_format['locality_label'],
+    '#required' => in_array('locality', $address_format['required_fields']),
+    '#access' => in_array('locality', $address_format['used_fields']),
     '#size' => 30,
-    '#required' => TRUE,
     '#prefix' => ' ',
-    '#attributes' => array('class' => array('locality')),
+    '#attributes' => array(
+      'class' => array('locality'),
+      'x-autocompletetype' => 'locality',
+      'autocomplete' => 'locality',
+    ),
+  );
+  $format['locality_block']['administrative_area'] = array(
+    '#title' => $address_format['administrative_area_label'],
+    '#required' => in_array('administrative_area', $address_format['required_fields']),
+    '#access' => in_array('administrative_area', $address_format['used_fields']),
+    '#empty_value' => '',
+    '#size' => 10,
+    '#prefix' => ' ',
+    '#render_option_value' => $address_format['render_administrative_area_value'],
+    '#attributes' => array(
+      'class' => array('state'),
+      'x-autocompletetype' => 'region',
+      'autocomplete' => 'region',
+    ),
   );
   $format['country'] = array(
     '#title' => t('Country'),
     '#options' => _addressfield_country_options_list(),
     '#render_option_value' => TRUE,
     '#required' => TRUE,
-    '#attributes' => array('class' => array('country')),
+    '#attributes' => array(
+      'class' => array('country'),
+      'x-autocompletetype' => 'country',
+      'autocomplete' => 'country',
+    ),
     '#weight' => 100,
   );
 
-  // Those countries do not seem to have a relevant postal code.
-  static $countries_no_postal_code = array('AF', 'AG', 'AL', 'AO', 'BB', 'BI', 'BJ', 'BO', 'BS', 'BW', 'BZ', 'CF', 'CG', 'CM', 'CO', 'DJ', 'DM', 'EG', 'ER', 'FJ', 'GD', 'GH', 'GM', 'GQ', 'GY', 'HK', 'IE', 'KI', 'KM', 'KP', 'KY', 'LC', 'LY', 'ML', 'MR', 'NA', 'NR', 'RW', 'SB', 'SC', 'SL', 'SR', 'ST', 'TD', 'TG', 'TL', 'TO', 'TT', 'TV', 'TZ', 'UG', 'VC', 'VU', 'WS', 'ZW');
-  if (in_array($address['country'], $countries_no_postal_code)) {
-    unset($format['locality_block']['postal_code']);
-
+  if (empty($format['locality_block']['postal_code']['#access'])) {
     // Remove the prefix from the first widget of the block.
     $element_children = element_children($format['locality_block']);
     $first_child = reset($element_children);
     unset($format['locality_block'][$first_child]['#prefix']);
   }
 
-  // Those countries generally use the administrative area in postal addresses.
-  static $countries_administrative_area = array('AR', 'AU', 'BR', 'BS', 'BY', 'BZ', 'CA', 'CN', 'DO', 'EG', 'ES', 'FJ', 'FM', 'GB', 'HN', 'ID', 'IE', 'IN', 'IT', 'JO', 'JP', 'KI', 'KN', 'KR', 'KW', 'KY', 'KZ', 'MX', 'MY', 'MZ', 'NG', 'NI', 'NR', 'NZ', 'OM', 'PA', 'PF', 'PG', 'PH', 'PR', 'PW', 'RU', 'SM', 'SO', 'SR', 'SV', 'TH', 'TW', 'UA', 'US', 'UY', 'VE', 'VI', 'VN', 'YU', 'ZA');
-  if (in_array($address['country'], $countries_administrative_area)) {
-    $format['locality_block']['administrative_area'] = array(
-      '#title' => t('State', array(), array('context' => 'addressfield')),
-      '#size' => 10,
-      '#required' => TRUE,
-      '#prefix' => ' ',
-      '#attributes' => array('class' => array('state')),
-    );
+  if (!empty($format['locality_block']['administrative_area']['#access'])) {
+    // Set the predefined administrative areas, if found.
+    module_load_include('inc', 'addressfield', 'addressfield.administrative_areas');
+    $administrative_areas = addressfield_get_administrative_areas($address['country']);
+    $format['locality_block']['administrative_area']['#options'] = $administrative_areas;
   }
 
-  // A few countries have a well-known list of administrative divisions.
-  if ($address['country'] == 'US') {
-    $format['locality_block']['administrative_area']['#options'] = array(
-      ''   => t('--'),
-      'AL' => t('Alabama'),
-      'AK' => t('Alaska'),
-      'AZ' => t('Arizona'),
-      'AR' => t('Arkansas'),
-      'CA' => t('California'),
-      'CO' => t('Colorado'),
-      'CT' => t('Connecticut'),
-      'DE' => t('Delaware'),
-      'DC' => t('District Of Columbia'),
-      'FL' => t('Florida'),
-      'GA' => t('Georgia'),
-      'HI' => t('Hawaii'),
-      'ID' => t('Idaho'),
-      'IL' => t('Illinois'),
-      'IN' => t('Indiana'),
-      'IA' => t('Iowa'),
-      'KS' => t('Kansas'),
-      'KY' => t('Kentucky'),
-      'LA' => t('Louisiana'),
-      'ME' => t('Maine'),
-      'MD' => t('Maryland'),
-      'MA' => t('Massachusetts'),
-      'MI' => t('Michigan'),
-      'MN' => t('Minnesota'),
-      'MS' => t('Mississippi'),
-      'MO' => t('Missouri'),
-      'MT' => t('Montana'),
-      'NE' => t('Nebraska'),
-      'NV' => t('Nevada'),
-      'NH' => t('New Hampshire'),
-      'NJ' => t('New Jersey'),
-      'NM' => t('New Mexico'),
-      'NY' => t('New York'),
-      'NC' => t('North Carolina'),
-      'ND' => t('North Dakota'),
-      'OH' => t('Ohio'),
-      'OK' => t('Oklahoma'),
-      'OR' => t('Oregon'),
-      'PA' => t('Pennsylvania'),
-      'RI' => t('Rhode Island'),
-      'SC' => t('South Carolina'),
-      'SD' => t('South Dakota'),
-      'TN' => t('Tennessee'),
-      'TX' => t('Texas'),
-      'UT' => t('Utah'),
-      'VT' => t('Vermont'),
-      'VA' => t('Virginia'),
-      'WA' => t('Washington'),
-      'WV' => t('West Virginia'),
-      'WI' => t('Wisconsin'),
-      'WY' => t('Wyoming'),
-      ' ' => t('--'),
-      'AA' => t('Armed Forces (Americas)'),
-      'AE' => t('Armed Forces (Europe, Canada, Middle East, Africa)'),
-      'AP' => t('Armed Forces (Pacific)'),
-      'AS' => t('American Samoa'),
-      'FM' => t('Federated States of Micronesia'),
-      'GU' => t('Guam'),
-      'MH' => t('Marshall Islands'),
-      'MP' => t('Northern Mariana Islands'),
-      'PW' => t('Palau'),
-      'PR' => t('Puerto Rico'),
-      'VI' => t('Virgin Islands'),
-    );
-    $format['locality_block']['postal_code']['#title'] = t('ZIP Code');
-
+  // Country-specific customizations.
+  if (in_array($address['country'], array('AU', 'EE', 'LT', 'LV', 'NZ', 'RU'))) {
+    // These countries don't use the "Address 2" line.
+    // Leave it as a precaution, but hide the label to avoid confusing users.
+    $format['street_block']['thoroughfare']['#title'] = t('Address');
+    $format['street_block']['premise']['#title_display'] = 'invisible';
+  }
+  elseif ($address['country'] == 'US') {
     if ($context['mode'] == 'render') {
       $format['locality_block']['locality']['#suffix'] = ',';
     }
   }
-  else if ($address['country'] == 'IT') {
-    $format['locality_block']['administrative_area']['#options'] = array(
-      '' => t('--'),
-      'AG' => t('Agrigento'),
-      'AL' => t('Alessandria'),
-      'AN' => t('Ancona'),
-      'AO' => t("Valle d'Aosta/Vallée d'Aoste"),
-      'AP' => t('Ascoli Piceno'),
-      'AQ' => t("L'Aquila"),
-      'AR' => t('Arezzo'),
-      'AT' => t('Asti'),
-      'AV' => t('Avellino'),
-      'BA' => t('Bari'),
-      'BG' => t('Bergamo'),
-      'BI' => t('Biella'),
-      'BL' => t('Belluno'),
-      'BN' => t('Benevento'),
-      'BO' => t('Bologna'),
-      'BR' => t('Brindisi'),
-      'BS' => t('Brescia'),
-      'BT' => t('Barletta-Andria-Trani'),
-      'BZ' => t('Bolzano/Bozen'),
-      'CA' => t('Cagliari'),
-      'CB' => t('Campobasso'),
-      'CE' => t('Caserta'),
-      'CH' => t('Chieti'),
-      'CI' => t('Carbonia-Iglesias'),
-      'CL' => t('Caltanissetta'),
-      'CN' => t('Cuneo'),
-      'CO' => t('Como'),
-      'CR' => t('Cremona'),
-      'CS' => t('Cosenza'),
-      'CT' => t('Catania'),
-      'CZ' => t('Catanzaro'),
-      'EN' => t('Enna'),
-      'FC' => t('Forlì-Cesena'),
-      'FE' => t('Ferrara'),
-      'FG' => t('Foggia'),
-      'FI' => t('Firenze'),
-      'FM' => t('Fermo'),
-      'FR' => t('Frosinone'),
-      'GE' => t('Genova'),
-      'GO' => t('Gorizia'),
-      'GR' => t('Grosseto'),
-      'IM' => t('Imperia'),
-      'IS' => t('Isernia'),
-      'KR' => t('Crotone'),
-      'LC' => t('Lecco'),
-      'LE' => t('Lecce'),
-      'LI' => t('Livorno'),
-      'LO' => t('Lodi'),
-      'LT' => t('Latina'),
-      'LU' => t('Lucca'),
-      'MB' => t('Monza e Brianza'),
-      'MC' => t('Macerata'),
-      'ME' => t('Messina'),
-      'MI' => t('Milano'),
-      'MN' => t('Mantova'),
-      'MO' => t('Modena'),
-      'MS' => t('Massa-Carrara'),
-      'MT' => t('Matera'),
-      'NA' => t('Napoli'),
-      'NO' => t('Novara'),
-      'NU' => t('Nuoro'),
-      'OG' => t('Ogliastra'),
-      'OR' => t('Oristano'),
-      'OT' => t('Olbia-Tempio'),
-      'PA' => t('Palermo'),
-      'PC' => t('Piacenza'),
-      'PD' => t('Padova'),
-      'PE' => t('Pescara'),
-      'PG' => t('Perugia'),
-      'PI' => t('Pisa'),
-      'PN' => t('Pordenone'),
-      'PO' => t('Prato'),
-      'PR' => t('Parma'),
-      'PT' => t('Pistoia'),
-      'PU' => t('Pesaro e Urbino'),
-      'PV' => t('Pavia'),
-      'PZ' => t('Potenza'),
-      'RA' => t('Ravenna'),
-      'RC' => t('Reggio di Calabria'),
-      'RE' => t("Reggio nell'Emilia"),
-      'RG' => t('Ragusa'),
-      'RI' => t('Rieti'),
-      'RM' => t('Roma'),
-      'RN' => t('Rimini'),
-      'RO' => t('Rovigo'),
-      'SA' => t('Salerno'),
-      'SI' => t('Siena'),
-      'SO' => t('Sondrio'),
-      'SP' => t('La Spezia'),
-      'SR' => t('Siracusa'),
-      'SS' => t('Sassari'),
-      'SV' => t('Savona'),
-      'TA' => t('Taranto'),
-      'TE' => t('Teramo'),
-      'TN' => t('Trento'),
-      'TO' => t('Torino'),
-      'TP' => t('Trapani'),
-      'TR' => t('Terni'),
-      'TS' => t('Trieste'),
-      'TV' => t('Treviso'),
-      'UD' => t('Udine'),
-      'VA' => t('Varese'),
-      'VB' => t('Verbano-Cusio-Ossola'),
-      'VC' => t('Vercelli'),
-      'VE' => t('Venezia'),
-      'VI' => t('Vicenza'),
-      'VR' => t('Verona'),
-      'VS' => t('Medio Campidano'),
-      'VT' => t('Viterbo'),
-      'VV' => t('Vibo Valentia'),
+  elseif ($address['country'] == 'BR') {
+    $format['locality_block']['dependent_locality']['#suffix'] = $clearfix;
+    $format['locality_block']['dependent_locality']['#tag'] = 'div';
+    $format['locality_block']['administrative_area']['#suffix'] = $clearfix;
+    $format['locality_block']['postal_code']['#tag'] = 'div';
+    // Change some titles to make translation easier.
+    $format['street_block']['#attributes'] = array(
+      'class' => array('addressfield-container-inline'),
     );
-    $format['locality_block']['administrative_area']['#title'] = t('Province');
-  }
-  else if ($address['country'] == 'BR') {
-    $format['locality_block']['administrative_area']['#render_option_value'] = TRUE;
-    $format['locality_block']['administrative_area']['#options'] = array(
-      '' => t('--'),
-      'AC' => t('Acre'),
-      'AL' => t('Alagoas'),
-      'AM' => t('Amazonas'),
-      'AP' => t('Amapá'),
-      'BA' => t('Bahia'),
-      'CE' => t('Ceará'),
-      'DF' => t('Distrito Federal'),
-      'ES' => t('Espírito Santo'),
-      'GO' => t('Goiás'),
-      'MA' => t('Maranhão'),
-      'MG' => t('Minas Gerais'),
-      'MS' => t('Mato Grosso do Sul'),
-      'MT' => t('Mato Grosso'),
-      'PA' => t('Pará'),
-      'PB' => t('Paraíba'),
-      'PE' => t('Pernambuco'),
-      'PI' => t('Piauí'),
-      'PR' => t('Paraná'),
-      'RJ' => t('Rio de Janeiro'),
-      'RN' => t('Rio Grande do Norte'),
-      'RO' => t('Rondônia'),
-      'RR' => t('Roraima'),
-      'RS' => t('Rio Grande do Sul'),
-      'SC' => t('Santa Catarina'),
-      'SE' => t('Sergipe'),
-      'SP' => t('São Paulo'),
-      'TO' => t('Tocantins'),
+    $format['street_block']['thoroughfare']['#title'] = t('Thoroughfare');
+    $format['street_block']['thoroughfare']['#tag'] = NULL;
+    $format['street_block']['premise'] = array(
+      '#title' => t('Complement'),
+      '#tag' => NULL,
+      '#attributes' => array('class' => array('premise')),
+      '#size' => 20,
+      '#prefix' => ', ',
     );
+    $format['locality_block']['locality']['#suffix'] = ' - ';
+    // Hide suffixes and prefixes while in form.
+    if ($context['mode'] == 'form') {
+      $format['street_block']['premise']['#prefix'] = NULL;
+      $format['street_block']['premise']['#suffix'] = NULL;
+      $format['locality_block']['locality']['#suffix'] = NULL;
+    }
   }
-  else if ($address['country'] == 'CA') {
-    $format['locality_block']['administrative_area']['#options'] = array(
-      '' => t('--'),
-      'AB' => t('Alberta'),
-      'BC' => t('British Columbia'),
-      'MB' => t('Manitoba'),
-      'NB' => t('New Brunswick'),
-      'NL' => t('Newfoundland and Labrador'),
-      'NT' => t('Northwest Territories'),
-      'NS' => t('Nova Scotia'),
-      'NU' => t('Nunavut'),
-      'ON' => t('Ontario'),
-      'PE' => t('Prince Edward Island'),
-      'QC' => t('Quebec'),
-      'SK' => t('Saskatchewan'),
-      'YT' => t('Yukon Territory'),
-    );
-    $format['locality_block']['administrative_area']['#title'] = t('Province');
-
+  elseif ($address['country'] == 'CN') {
+    $format['locality_block']['locality']['#suffix'] = $clearfix;
+  }
+  elseif ($address['country'] == 'CA') {
     if ($context['mode'] == 'render') {
       $format['locality_block']['locality']['#suffix'] = ',';
     }
   }
-  else if ($address['country'] == 'AU') {
-    $format['locality_block']['administrative_area']['#options'] = array(
-      '' => t('--'),
-      'ACT' => t('Australian Capital Territory'),
-      'NSW' => t('New South Wales'),
-      'NT' => t('Northern Territory'),
-      'QLD' => t('Queensland'),
-      'SA' => t('South Australia'),
-      'TAS' => t('Tasmania'),
-      'VIC' => t('Victoria'),
-      'WA' => t('Western Australia'),
-    );
+  elseif ($address['country'] == 'GB') {
+    $format['locality_block']['administrative_area']['#size'] = '30';
   }
-  else if ($address['country'] == 'NZ') {
-    $format['locality_block']['locality']['#title'] = ('Town/City');
-    $format['locality_block']['postal_code']['#title'] = t('Postcode');
-    $format['locality_block']['administrative_area']['#render_option_value'] = TRUE;
-    $format['locality_block']['administrative_area']['#title'] = t('Region');
-    $format['locality_block']['administrative_area']['#required'] = FALSE;
-    $format['locality_block']['administrative_area']['#options'] = array(
-      ''   => t('--'),
-      'AUK' => t('Auckland'),
-      'BOP' => t('Bay of Plenty'),
-      'CAN' => t('Canterbury'),
-      'HKB' => t("Hawke's Bay"),
-      'MWT' => t('Manawatu-Wanganui'),
-      'NTL' => t('Northland'),
-      'OTA' => t('Otago'),
-      'STL' => t('Southland'),
-      'TKI' => t('Taranaki'),
-      'WKO' => t('Waikato'),
-      'WGN' => t('Wellington'),
-      'WTC' => t('West Coast'),
-      'GIS' => t('Gisborne District'),
-      'MBH' => t('Marlborough District'),
-      'NSN' => t('Nelson City'),
-      'TAS' => t('Tasman District'),
-      'CIT' => t('Chatham Islands Territory'),
-    );
+  elseif ($address['country'] == 'ID') {
+    $format['locality_block']['administrative_area']['#weight'] = 1;
+  }
+  elseif ($address['country'] == 'JP') {
+    $format['locality_block']['#weight'] = 10;
+    $format['locality_block']['postal_code']['#weight'] = 10;
+    $format['locality_block']['postal_code']['#tag'] = 'div';
+    $format['locality_block']['postal_code']['#size'] = 30;
+    $format['locality_block']['administrative_area']['#weight'] = 20;
+    $format['locality_block']['administrative_area']['#size'] = 30;
+    $format['locality_block']['locality']['#weight'] = 30;
+    $format['street_block']['#weight'] = 20;
+  }
+  elseif ($address['country'] == 'PE') {
+    $format['locality_block']['administrative_area']['#weight'] = 1;
+    $format['locality_block']['locality']['#weight'] = 2;
+  }
+  elseif ($address['country'] == 'PH' || $address['country'] == 'TH') {
+    $format['locality_block']['dependent_locality']['#suffix'] = '';
+    $format['locality_block']['locality']['#suffix'] = $clearfix;
   }
 
-  // Those countries tend to put the postal code after the locality.
-  static $countries_postal_code_after_locality = array('AU', 'BD', 'BF', 'BH', 'BM', 'BN', 'BT', 'CA', 'FM', 'GB', 'ID', 'IN', 'JM', 'JO', 'KH', 'LB', 'LS', 'LV', 'MM', 'MN', 'MV', 'MW', 'NG', 'NP', 'NZ', 'PE', 'PK', 'PR', 'PW', 'SA', 'SG', 'SO', 'TH', 'US', 'VI', 'VG', 'VN');
+  // These countries show every field in its own row.
+  $countries_field_per_row = array(
+    'AM', 'EG', 'FK', 'GB', 'GG', 'GS', 'HK', 'HU', 'IE', 'IM', 'IO', 'JE', 'JM',
+    'JP', 'KE', 'KR', 'KZ', 'LK', 'PA', 'PN', 'RU', 'SC', 'SH', 'SZ', 'TC', 'UA',
+    'VG', 'ZA',
+  );
+  if (in_array($address['country'], $countries_field_per_row)) {
+    $format['locality_block']['#attributes']['class'][0] = 'addressfield-container';
+    $format['locality_block']['postal_code']['#prefix'] = '';
+    $format['locality_block']['postal_code']['#tag'] = 'div';
+    $format['locality_block']['locality']['#prefix'] = '';
+    $format['locality_block']['locality']['#tag'] = 'div';
+    $format['locality_block']['administrative_area']['#prefix'] = '';
+    $format['locality_block']['administrative_area']['#tag'] = 'div';
+  }
+
+  // These countries tend to put the postal code after the locality.
+  $countries_postal_code_after_locality = array(
+    'AS', 'AU', 'BD', 'BF', 'BH', 'BM', 'BN', 'BR', 'BT', 'CA', 'CC', 'CN', 'CX',
+    'EG', 'FK', 'FM', 'GB', 'GG', 'GS', 'GU', 'HN', 'HU', 'ID', 'IL', 'IM', 'IN',
+    'IO', 'IQ', 'IR', 'JE', 'JO', 'JP', 'KE', 'KH', 'KR', 'LB', 'LK', 'LS', 'LV',
+    'MH', 'MM', 'MN', 'MP', 'MT', 'MV', 'MX', 'MY', 'NF', 'NG', 'NP', 'NZ', 'PG',
+    'PH', 'PK', 'PN', 'PR', 'PW', 'RU', 'SA', 'SH', 'SO', 'SZ', 'TC', 'TH', 'TW',
+    'UA', 'UM', 'US', 'VE', 'VI', 'VG', 'VN', 'ZA',
+  );
   if (in_array($address['country'], $countries_postal_code_after_locality)) {
     // Take the widget out of the array.
     $postal_code_widget = $format['locality_block']['postal_code'];
@@ -397,44 +249,6 @@ function addressfield_format_address_generate(&$format, $address, $context = arr
     unset($format['locality_block'][$first_child]['#prefix']);
   }
 
-  // GB-specific tweaks
-  if ($address['country'] == 'GB') {
-    // Locality
-    $format['locality_block']['locality'] = array_merge(
-      $format['locality_block']['locality'],
-      array(
-        '#title' => t('Town/City'),
-        '#weight' => 40,
-        '#prefix' => '',
-        '#tag' => 'div',
-      )
-    );
-
-    // Administrative
-    $format['locality_block']['administrative_area'] = array_merge(
-      $format['locality_block']['administrative_area'],
-      array(
-        '#title' => t('County'),
-        '#required' => FALSE,
-        '#weight' => 50,
-        '#size' => 30,
-        '#prefix' => '',
-        '#tag' => 'div',
-      )
-    );
-
-    // Postal code
-    $format['locality_block']['postal_code'] = array_merge(
-      $format['locality_block']['postal_code'],
-      array(
-        '#title' => t('Postcode'),
-        '#weight' => 60,
-        '#prefix' => '',
-        '#tag' => 'div',
-      )
-    );
-  }
-
   if ($context['mode'] == 'form') {
     // Provide a wrapper ID for AJAX replacement based on country selection.
     if (!isset($format['#wrapper_id'])) {
@@ -442,15 +256,6 @@ function addressfield_format_address_generate(&$format, $address, $context = arr
       $format['#prefix'] = '<div id="' . $format['#wrapper_id'] . '">';
       $format['#suffix'] = '</div>';
     }
-
-    // Form mode, move the country selector to the top of the form.
-    $format['country']['#weight'] = -10;
-
-    // Limit it to the countries supported by the widget.
-    if (isset($context['field'])) {
-      $format['country']['#options'] = _addressfield_country_options_list($context['field'], $context['instance']);
-    }
-
     // AJAX enable it.
     $format['country']['#ajax'] = array(
       'callback' => 'addressfield_standard_widget_refresh',
@@ -460,12 +265,25 @@ function addressfield_format_address_generate(&$format, $address, $context = arr
     // Don't validate any element when the country is changed.
     $format['country']['#limit_validation_errors'] = array();
 
-    if (isset($context['delta']) && $context['delta'] > 0) {
-      // On subsequent elements of a field, we make the country field non
-      // required and add a ' - None - ' option to it, so as to allow the
-      // user to remove the address by clearing the country field.
+    // Move the country selector to the top of the form.
+    $format['country']['#weight'] = -500;
+    // Limit it to the countries supported by the widget.
+    if (isset($context['field'])) {
+      $format['country']['#options'] = _addressfield_country_options_list($context['field'], $context['instance']);
+    }
+
+    // The whole field is considered empty if the country column is empty.
+    // Therefore, if the field is optional, allow the country to be optional.
+    // The same logic applies if the field allows multiple values, in which case
+    // only the first delta needs to have a value.
+    if (empty($context['instance']['required']) || (isset($context['delta']) && $context['delta'] > 0)) {
       $format['country']['#required'] = FALSE;
       $format['country']['#empty_value'] = '';
+      // Hide all other fields until the country is selected.
+      if (empty($address['country'])) {
+        $format['street_block']['#access'] = FALSE;
+        $format['locality_block']['#access'] = FALSE;
+      }
     }
   }
 }

+ 16 - 3
sites/all/modules/contrib/fields/addressfield/plugins/format/name-full.inc

@@ -20,20 +20,33 @@ $plugin = array(
 function addressfield_format_name_full_generate(&$format, $address) {
   $format['name_block'] = array(
     '#type' => 'addressfield_container',
-    '#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
+    '#attributes' => array(
+      'class' => array('addressfield-container-inline', 'name-block'),
+    ),
     '#weight' => -100,
+    // The addressfield is considered empty without a country, hide all fields
+    // until one is selected.
+    '#access' => !empty($address['country']),
   );
   $format['name_block']['first_name'] = array(
     '#title' => t('First name'),
     '#size' => 30,
     '#required' => TRUE,
-    '#attributes' => array('class' => array('first-name')),
+    '#attributes' => array(
+      'class' => array('first-name'),
+      'x-autocompletetype' => 'given-name',
+      'autocomplete' => 'given-name',
+    ),
   );
   $format['name_block']['last_name'] = array(
     '#title' => t('Last name'),
     '#size' => 30,
     '#required' => TRUE,
     '#prefix' => ' ',
-    '#attributes' => array('class' => array('last-name')),
+    '#attributes' => array(
+      'class' => array('last-name'),
+      'x-autocompletetype' => 'family-name',
+      'autocomplete' => 'family-name',
+    ),
   );
 }

+ 8 - 1
sites/all/modules/contrib/fields/addressfield/plugins/format/name-oneline.inc

@@ -22,11 +22,18 @@ function addressfield_format_name_oneline_generate(&$format, $address) {
     '#type' => 'addressfield_container',
     '#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
     '#weight' => -100,
+    // The addressfield is considered empty without a country, hide all fields
+    // until one is selected.
+    '#access' => !empty($address['country']),
   );
   $format['name_block']['name_line'] = array(
     '#title' => t('Full name'),
     '#tag' => 'div',
-    '#attributes' => array('class' => array('name-block')),
+    '#attributes' => array(
+      'class' => array('name-block'),
+      'x-autocompletetype' => 'name',
+      'autocomplete' => 'name',
+    ),
     '#size' => 30,
     '#required' => TRUE,
   );

+ 8 - 1
sites/all/modules/contrib/fields/addressfield/plugins/format/organisation.inc

@@ -22,10 +22,17 @@ function addressfield_format_organisation_generate(&$format, $address) {
     '#type' => 'addressfield_container',
     '#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
     '#weight' => -50,
+    // The addressfield is considered empty without a country, hide all fields
+    // until one is selected.
+    '#access' => !empty($address['country']),
   );
   $format['organisation_block']['organisation_name'] = array(
     '#title' => t('Company'),
     '#size' => 30,
-    '#attributes' => array('class' => array('organisation-name')),
+    '#attributes' => array(
+      'class' => array('organisation-name'),
+      'x-autocompletetype' => 'organization',
+      'autocomplete' => 'organization',
+    ),
   );
 }

+ 71 - 2
sites/all/modules/contrib/fields/addressfield/views/addressfield.views.inc

@@ -6,8 +6,9 @@
 function addressfield_field_views_data($field) {
   $data = field_views_field_default_views_data($field);
 
-  // Add a handler for countries.
-  foreach ($field['storage']['details']['sql'] as $type => $tables) {
+  // Add a filter handler for countries.
+  $key = key($field['storage']['details']);
+  foreach ($field['storage']['details'][$key] as $type => $tables) {
     foreach ($tables as $table_name => $columns) {
       if (!isset($columns['country'])) {
         continue;
@@ -22,5 +23,73 @@ function addressfield_field_views_data($field) {
     }
   }
 
+  // Only expose these components as Views field handlers.
+  $implemented = array(
+    'country' => 'addressfield_views_handler_field_country',
+    'administrative_area' => 'views_handler_field',
+    'sub_administrative_area' => 'views_handler_field',
+    'dependent_locality' => 'views_handler_field',
+    'locality' => 'views_handler_field',
+    'postal_code' => 'views_handler_field',
+    'thoroughfare' => 'views_handler_field',
+    'premise' => 'views_handler_field',
+    'sub_premise' => 'views_handler_field',
+    'organisation_name' => 'views_handler_field',
+    'name_line' => 'views_handler_field',
+    'first_name' => 'views_handler_field',
+    'last_name' => 'views_handler_field',
+    'data' => 'views_handler_field_serialized',
+  );
+
+  // Get the translated field information.
+  $properties = addressfield_data_property_info();
+
+  // Iterate over addressfield defined tables.
+  foreach ($data as &$table) {
+    // Make sure the parent Views field (addressfield) is defined.
+    if (isset($table[$field['field_name']]['field'])) {
+      // Use the parent field definition as a template for component columns.
+      $field_def = $table[$field['field_name']]['field'];
+
+      // Remove 'additional fields' from the field definition. We don't
+      // necessarily want all our sibling columns.
+      unset($field_def['additional fields']);
+
+      // Define the valid columns.
+      $valid_columns = array();
+      foreach ($implemented as $implement => $handler) {
+        $column_name = $field['field_name'] . '_' . $implement;
+        $valid_columns[$column_name] = $handler;
+      }
+
+      // Iterate over the addressfield components.
+      foreach ($table as $column_name => &$column) {
+        if (empty($column['field']) && isset($valid_columns[$column_name])) {
+          // Assign the default component definition.
+          $column['field'] = $field_def;
+          $column['field']['real field'] = $column_name;
+          $column['field']['handler'] = $valid_columns[$column_name];
+
+          // Assign human-friendly field labels for addressfield components.
+          $field_labels = field_views_field_label($field['field_name']);
+          $field_label = array_shift($field_labels);
+          $property = str_replace($field_def['field_name'] . '_', '', $column_name);
+
+          if (!empty($properties[$property])) {
+            $property_label = $properties[$property]['label'];
+
+            $title = t('@field-label - @property-label', array(
+              '@field-label' => $field_label,
+              '@property-label' => $property_label,
+            ));
+
+            $column['title'] = $title;
+            $column['title short'] = $title;
+          }
+        }
+      }
+    }
+  }
+
   return $data;
 }

+ 40 - 0
sites/all/modules/contrib/fields/addressfield/views/addressfield_views_handler_field_country.inc

@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Defines a field handler that can display the country name instead of the two
+ * character country code for an address field country value.
+ */
+class addressfield_views_handler_field_country extends views_handler_field {
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['display_name'] = array('default' => TRUE);
+    return $options;
+  }
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    $form['display_name'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Display the localized country name instead of the two character country code'),
+      '#default_value' => $this->options['display_name'],
+    );
+  }
+
+  function get_value($values, $field = NULL) {
+    $value = parent::get_value($values, $field);
+
+    // If we have a value for the field, look for the country name in the
+    // Address Field options list array if specified.
+    if (!empty($value) && !empty($this->options['display_name'])) {
+      $countries = _addressfield_country_options_list();
+
+      if (!empty($countries[$value])) {
+        $value = $countries[$value];
+      }
+    }
+
+    return $value;
+  }
+}

+ 36 - 0
sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe-rtl.css

@@ -0,0 +1,36 @@
+span.autocomplete-deluxe-value-delete {
+  float: left;
+}
+div.autocomplete-deluxe-multiple {
+ padding: 4px 5px;
+}
+
+input.autocomplete-deluxe-form.autocomplete-deluxe-multiple {
+  margin-left: 0;
+  margin-right: 5px;
+  float: right;
+}
+
+div.autocomplete-deluxe-throbber {
+  float: left;
+}
+
+.autocomplete-deluxe-closed {
+  background-position: 0 6px;
+}
+
+.autocomplete-deluxe-open {
+  background-position: 0 -14px;
+}
+
+.autocomplete-deluxe-item {
+  float: right;
+  margin: 3px 5px 3px 0;
+  padding: 3px 5px 3px 20px;
+}
+
+.autocomplete-deluxe-item-delete {
+  position: absolute;
+  right: auto;
+  left: 3px;
+}

+ 1 - 1
sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.css

@@ -114,7 +114,7 @@ div.autocomplete-deluxe-multiple {
   background: no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
   background: no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
   background: no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
-  padding: 4px 5px 4px 20px;
+  padding: 4px 5px;
   border: 1px solid #AAAAAA;
   cursor: text;
   height: auto !important;

+ 3 - 3
sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.info

@@ -5,9 +5,9 @@ core = 7.x
 files[] = autocomplete_deluxe.module
 dependencies[] = taxonomy
 
-; Information added by drupal.org packaging script on 2013-08-05
-version = "7.x-2.0-beta3"
+; Information added by Drupal.org packaging script on 2015-03-16
+version = "7.x-2.1"
 core = "7.x"
 project = "autocomplete_deluxe"
-datestamp = "1375695669"
+datestamp = "1426503185"
 

+ 22 - 10
sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.js

@@ -82,7 +82,10 @@
     return this;
   };
 
-
+  /**
+   * If there is no result this label will be shown.
+   * @type {{label: string, value: string}}
+   */
   Drupal.autocomplete_deluxe.empty =  {label: '- ' + Drupal.t('None') + ' -', value: "" };
 
   /**
@@ -105,6 +108,9 @@
   Drupal.autocomplete_deluxe.Widget = function() {
   };
 
+  /**
+   * Url for the callback.
+   */
   Drupal.autocomplete_deluxe.Widget.prototype.uri = null;
 
   /**
@@ -119,7 +125,7 @@
   };
 
   Drupal.autocomplete_deluxe.Widget.prototype.init = function(settings) {
-    if ($.browser.msie && $.browser.version === "6.0") {
+    if(navigator.appVersion.indexOf("MSIE 6.") != -1) {
       return;
     }
 
@@ -131,6 +137,7 @@
     this.required = settings.required;
     this.limit = settings.limit;
     this.synonyms = typeof settings.use_synonyms == 'undefined' ? false : settings.use_synonyms;
+    this.not_found_message = typeof settings.use_synonyms == 'undefined' ? "The term '@term' will be added." : settings.not_found_message;
 
     this.wrapper = '""';
 
@@ -140,7 +147,6 @@
       this.delimiter =  settings.delimiter.charCodeAt(0);
     }
 
-
     this.items = {};
 
     var self = this;
@@ -163,7 +169,7 @@
       }
       if ($.isEmptyObject(result)) {
         result.push({
-          label: Drupal.t("The term '@term' will be added.", {'@term' : term}),
+          label: Drupal.t(self.not_found_message, {'@term' : term}),
           value: term,
           newTerm: true
         });
@@ -203,6 +209,9 @@
     });
 
     var jqObject = this.jqObject;
+
+    var autocompleteDataKey = typeof(this.jqObject.data('autocomplete')) === 'object' ? 'item.autocomplete' : 'ui-autocomplete';
+
     var throbber = $('<div class="autocomplete-deluxe-throbber autocomplete-deluxe-closed">&nbsp;</div>').insertAfter(jqObject);
 
     this.jqObject.bind("autocompletesearch", function(event, ui) {
@@ -224,8 +233,9 @@
         var re = new RegExp('()*""' + escapedValue + '""|' + escapedValue + '()*', 'gi');
         var t = item.label.replace(re,"<span class='autocomplete-deluxe-highlight-char'>$&</span>");
       }
+
       return $( "<li></li>" )
-        .data( "item.autocomplete", item )
+        .data(autocompleteDataKey, item)
         .append( "<a>" + t + "</a>" )
         .appendTo( ul );
     };
@@ -304,23 +314,25 @@
     this.element.remove();
     var values = this.widget.valueForm.val();
     var escapedValue = Drupal.autocomplete_deluxe.escapeRegex( this.item.value );
-    var regex = new RegExp('()*""' + escapedValue + '""|' + escapedValue + '()*', 'gi');
+    var regex = new RegExp('()*""' + escapedValue + '""()*', 'gi');
     this.widget.valueForm.val(values.replace(regex, ''));
     delete this.widget.items[this.value];
   };
 
   Drupal.autocomplete_deluxe.MultipleWidget.prototype.setup = function() {
     var jqObject = this.jqObject;
-    var parent = jqObject.parent();
-    var value_container = jqObject.parent().parent().children('.autocomplete-deluxe-value-container');
-    var value_input = value_container.children().children();
+    var parent = jqObject.parents('.autocomplete-deluxe-container');
+    var value_container = parent.next();
+    var value_input = value_container.find('input');
     var items = this.items;
     var self = this;
     this.valueForm = value_input;
 
     // Override the resize function, so that the suggestion list doesn't resizes
     // all the time.
-    jqObject.data("autocomplete")._resizeMenu = function()  {};
+    var autocompleteDataKey = typeof(this.jqObject.data('autocomplete')) === 'object' ? 'autocomplete' : 'ui-autocomplete';
+
+    jqObject.data(autocompleteDataKey)._resizeMenu = function()  {};
 
     jqObject.show();
 

+ 10 - 2
sites/all/modules/contrib/fields/autocomplete_deluxe/autocomplete_deluxe.module

@@ -27,7 +27,7 @@ function autocomplete_deluxe_field_widget_info() {
 /**
  * Custom taxonomy callback, which also accepts an empty string search.
  */
-function taxonomy_autocomplete_deluxe($field_name, $tags_typed = '', $limit = 10) {
+function autocomplete_deluxe_taxonomy_callback($field_name, $tags_typed = '', $limit = 10) {
   $field = field_info_field($field_name);
   $use_synonyms = !empty($_GET['synonyms']);
 
@@ -163,6 +163,12 @@ function autocomplete_deluxe_field_widget_settings_form($field, $instance) {
     '#default_value' => isset($settings['delimiter']) ? $settings['delimiter'] : '',
     '#size' => 1,
   );
+  $form['not_found_message'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Term not found message.'),
+    '#description' => t('A message text which will be displayed, if the entered term was not found.'),
+    '#default_value' => isset($settings['not_found_message']) ? $settings['not_found_message'] : "The term '@term' will be added.",
+  );
 
   if (module_exists('synonyms')) {
     $form['use_synonyms'] = array(
@@ -219,6 +225,7 @@ function autocomplete_deluxe_field_widget_form(&$form, &$form_state, $field, $in
     '#min_length' => isset($instance['widget']['settings']['min_length']) ? $instance['widget']['settings']['min_length'] : 0,
     '#use_synonyms' =>isset($instance['widget']['settings']['use_synonyms']) ? $instance['widget']['settings']['use_synonyms'] : 0,
     '#delimiter' =>isset($instance['widget']['settings']['delimiter']) ? $instance['widget']['settings']['delimiter'] : '',
+    '#not_found_message' =>isset($instance['widget']['settings']['not_found_message']) ? $instance['widget']['settings']['not_found_message'] : "The term '@term' will be added.",
   );
 
   $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED ? TRUE : FALSE;
@@ -276,6 +283,7 @@ function autocomplete_deluxe_element_process($element) {
     'min_length' => isset($element['#min_length']) ? $element['#min_length'] : 0,
     'use_synonyms' => isset($element['#use_synonyms']) ? $element['#use_synonyms'] : 0,
     'delimiter' => isset($element['#delimiter']) ? $element['#delimiter'] : '',
+    'not_found_message' => isset($element['#not_found_message']) ? $element['#not_found_message'] : "The term '@term' will be added.",
   );
 
   if (isset($element['#autocomplete_deluxe_path'])) {
@@ -384,7 +392,7 @@ function autocomplete_deluxe_element_info() {
 function autocomplete_deluxe_menu() {
   $items['autocomplete_deluxe/taxonomy'] = array(
     'title' => 'Autocomplete deluxe taxonomy',
-    'page callback' => 'taxonomy_autocomplete_deluxe',
+    'page callback' => 'autocomplete_deluxe_taxonomy_callback',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );

+ 1 - 1
sites/all/modules/contrib/fields/cck_phone/cck_phone.css

@@ -17,4 +17,4 @@
 .cck-phone-settings .cck-phone-default-country {
   background: #eee;
   font-weight: bold;
-}
+}

+ 67 - 0
sites/all/modules/contrib/fields/cck_phone/cck_phone.feeds.inc

@@ -0,0 +1,67 @@
+<?php
+/**
+ * @file
+ * Implements Feeds mapping API
+ */
+
+/**
+ * Implements hook_feeds_processor_targets_alter().
+ */
+function cck_phone_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
+  foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
+    $info = field_info_field($name);
+    if ($info['type'] == 'phone_number') {
+      $targets[$name .':country_codes'] = array(
+        'name' => t('!label - country code', array('!label' => check_plain($instance['label']))),
+        'callback' => 'cck_phone_feeds_set_target',
+        'description' => t('The @label field.', array('@label' => $instance['label'])),
+      );
+      $targets[$name .':number'] = array(
+        'name' => t('!label - phone number', array('!label' => check_plain($instance['label']))),
+        'callback' => 'cck_phone_feeds_set_target',
+        'description' => t('The @label field.', array('@label' => $instance['label'])),
+      );
+      $targets[$name .':extension'] = array(
+        'name' => t('!label - extension', array('!label' => check_plain($instance['label']))),
+        'callback' => 'cck_phone_feeds_set_target',
+        'description' => t('The @label field.', array('@label' => $instance['label'])),
+      );
+    }
+  }
+}
+
+/**
+ * Callback for feed mapping.
+ */
+function cck_phone_feeds_set_target($source, $entity, $target, $value) {
+  if (empty($value)) {
+    return;
+  }
+
+  // Handle non-multiple value fields.
+  if (!is_array($value)) {
+    $value = array($value);
+  }
+
+  // Iterate over all values.
+  $i = 0;
+  $info = field_info_field($target);
+  list($field_name, $sub_field) = explode(':', $target);
+
+  // We will call this multiple times, preserve existing values.
+  $field = empty($entity->{$field_name}) ? array() : $entity->{$field_name};
+
+  foreach ($value as $v) {
+    if ($sub_field == 'country_codes') {
+      $v = strtolower($v);
+    }
+    if (!is_array($v) && !is_object($v)) {
+      $field['und'][$i][$sub_field] = $v;
+    }
+    if ($info['cardinality'] == 1) {
+      break;
+    }
+    $i++;
+  }
+  $entity->{$field_name} = $field;
+}

+ 2 - 2
sites/all/modules/contrib/fields/cck_phone/cck_phone.info

@@ -15,9 +15,9 @@ files[] = includes/phone.my.inc
 files[] = includes/phone.pl.inc
 files[] = includes/phone.us.inc
 
-; Information added by drupal.org packaging script on 2012-03-02
+; Information added by  packaging script on 2013-11-05
 version = "7.x-1.x-dev"
 core = "7.x"
 project = "cck_phone"
-datestamp = "1330689918"
+datestamp = "1383621212"
 

+ 1 - 1
sites/all/modules/contrib/fields/cck_phone/cck_phone.js

@@ -97,4 +97,4 @@
       $('a.cck-phone-check').bind('click', Drupal.PhoneNumber.checkall);
     }
   };
-})(jQuery);
+})(jQuery);

+ 83 - 11
sites/all/modules/contrib/fields/cck_phone/cck_phone.module

@@ -34,7 +34,7 @@ function cck_phone_theme() {
       'render element' => 'element',
     ),
     'phone_number_extension' => array(
-      'render element' => 'element',
+      'variables' => array('extension' => NULL),
     ),
     'cck_phone_formatter_global_phone_number' => array(
       'variables' => array('element' => NULL),
@@ -65,10 +65,68 @@ function cck_phone_field_info() {
       ),
       'default_widget' => 'phone_number',
       'default_formatter' => 'global_phone_number',
+       // Support hook_entity_property_info() from contrib "Entity API".
+      'property_type' => 'field_item_phone_number',
+      'property_callbacks' => array('cck_phone_field_property_info_callback'),
     ),
   );
 }
 
+/**
+ * Additional callback to adapt the property info of phone number fields.
+ * @see entity_metadata_field_entity_property_info().
+ */
+function cck_phone_field_property_info_callback(&$info, $entity_type, $field, $instance, $field_type) {
+  $property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];
+
+  // Define a data structure so it's possible constituent parts of field.
+  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
+  $property['setter callback'] = 'entity_metadata_field_verbatim_set';
+
+  // Auto-create the field item as soon as a property is set.
+  $property['auto creation'] = 'cck_phone_field_item_create';
+
+  $property['property info'] = cck_phone_field_item_property_info();
+  $property['property info']['country_codes']['required'] = !$instance['settings']['enable_default_country'];
+  if (!$instance['settings']['enable_extension']) {
+    unset($property['property info']['extension']);
+  }
+
+  unset($property['query callback']);
+}
+
+/**
+ * Callback for creating a new, empty phone number field item.
+ *
+ * @see cck_phone_field_property_info_callback()
+ */
+function cck_phone_field_item_create() {
+  return array('number' => NULL);
+}
+
+
+/**
+ * Defines info for the properties of the phone number field item data structure.
+ */
+function cck_phone_field_item_property_info() {
+  $properties['number'] = array(
+    'type' => 'text',
+    'label' => t('The phone number.'),
+    'setter callback' => 'entity_property_verbatim_set',
+  );
+  $properties['country_codes'] = array(
+    'type' => 'text',
+    'label' => t('The country code for a given phone number.'),
+    'setter callback' => 'entity_property_verbatim_set',
+  );
+  $properties['extension'] = array(
+    'type' => 'text',
+    'label' => t('The extension for a given phone number.'),
+    'setter callback' => 'entity_property_verbatim_set',
+  );
+  return $properties;
+}
+
 /**
  * Implements hook_field_instance_settings_form().
  */
@@ -255,8 +313,8 @@ function cck_phone_field_is_empty($item, $field) {
 /**
  * Theme function for phone extension.
  */
-function theme_phone_number_extension($element = '') {
-  return t('<em> ext.</em> %extension', array('%extension' => $element['element']));
+function theme_phone_number_extension($variables) {
+  return '<em>' . t('ext.') . '</em> ' . check_plain($variables['extension']);
 }
 
 /**
@@ -267,7 +325,7 @@ function theme_cck_phone_formatter_global_phone_number($element) {
 
   // Display a global phone number with country code.
   if (!empty($element['number']) && !empty($element['country_codes'])) {
-    // Call country default formatter if exist
+    // Call country default formatter if exists.
     $custom_cc = _cck_phone_custom_cc();
     if (isset($custom_cc[$element['country_codes']])) {
       $function = $element['country_codes'] . '_formatter_default';
@@ -276,15 +334,16 @@ function theme_cck_phone_formatter_global_phone_number($element) {
       }
     }
 
-    // Output a raw value if no custom formatter or formatter return empty
+    // Output a raw value if no custom formatter or formatter returns empty
+    // value.
     if (empty($phone)) {
       $cc = cck_phone_countrycodes($element['country_codes']);
       $phone = $cc['code'] . '-' . $element['number'];
     }
 
-    // Extension
+    // Extension.
     if (!empty($element['extension'])) {
-      $phone = $phone . theme('phone_number_extension', $element['extension']);
+      $phone = $phone . theme('phone_number_extension', $element);
     }
   }
 
@@ -299,7 +358,7 @@ function theme_cck_phone_formatter_local_phone_number($element) {
 
   // Display a local phone number without country code.
   if (!empty($element['number'])) {
-    // Call country local formatter if exist
+    // Call country local formatter if exists.
     $custom_cc = _cck_phone_custom_cc();
     if (isset($custom_cc[$element['country_codes']])) {
       $function = $element['country_codes'] . '_formatter_local';
@@ -308,14 +367,14 @@ function theme_cck_phone_formatter_local_phone_number($element) {
       }
     }
 
-    // Output a raw value if no custom formatter or formatter return empty
+    // Output a raw value if no custom formatter or formatter return empty.
     if (empty($phone)) {
       $phone = $element['number'];
     }
 
-    // Extension
+    // Extension.
     if (!empty($element['extension'])) {
-      $phone = $phone . theme('phone_number_extension', $element['extension']);
+      $phone = $phone . theme('phone_number_extension', $element);
     }
   }
 
@@ -352,6 +411,7 @@ function _cck_phone_cc_options($show_custom = FALSE, $country_selection = array(
     $options[$cc] = check_plain($cc_name);
   }
 
+  asort($options);
   return $options;
 }
 
@@ -632,6 +692,9 @@ function cck_phone_field_widget_process($element, &$form_state, $form) {
      '#required' => FALSE,
      '#default_value' => isset($item['extension']) ? $item['extension'] : NULL,
      '#weight' => 2,
+     '#attributes' => array(
+       'class' => array('extension'),
+     ),
     );
   }
 
@@ -688,6 +751,9 @@ function cck_phone_phone_number_process($element, &$form_state, $form) {
       )
     ),
     '#weight' => 0,
+    '#attributes' => array(
+      'class' => array('phone-number'),
+    ),
   );
 
   // If only one country code, make it as hidden form item
@@ -705,6 +771,9 @@ function cck_phone_phone_number_process($element, &$form_state, $form) {
             '#type' => 'item',
             '#markup' => $value = $cc['country'] . ' (' . $cc['code'] . ')',
             '#weight' => ($settings['country_code_position'] == 'after' ? 1 : -1),
+            '#attributes' => array(
+              'class' => array('country-code'),
+            ),
           );
         }
       }
@@ -716,6 +785,9 @@ function cck_phone_phone_number_process($element, &$form_state, $form) {
   //    '#title' => 'Country code',
       '#options' => _cck_phone_cc_options(),
       '#weight' => ($settings['country_code_position'] == 'after' ? 1 : -1),
+      '#attributes' => array(
+        'class' => array('country-code'),
+      ),
     );
   }
 

+ 1 - 1
sites/all/modules/contrib/fields/cck_phone/cck_phone_countrycodes.inc

@@ -266,4 +266,4 @@ function cck_phone_countrycodes($cc = NULL) {
   }
 
   return FALSE;
-}
+}

+ 3 - 3
sites/all/modules/contrib/fields/computed_field/computed_field.info

@@ -5,9 +5,9 @@ dependencies[] = field
 package = Fields
 files[]=computed_field.install
 files[]=computed_field.module
-; Information added by drupal.org packaging script on 2012-02-02
-version = "7.x-1.0-beta1"
+; Information added by  packaging script on 2013-12-03
+version = "7.x-1.0"
 core = "7.x"
 project = "computed_field"
-datestamp = "1328217338"
+datestamp = "1386094705"
 

File diff suppressed because it is too large
+ 1 - 1
sites/all/modules/contrib/fields/computed_field/computed_field.module


+ 31 - 24
sites/all/modules/contrib/fields/serial/serial.inc

@@ -114,16 +114,16 @@ function _serial_get_table_schema() {
         'not null' => TRUE,
         'description' => 'The atomic serial field.',
       ),
-      'nid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
+      'uniqid' => array(
+        'description' => 'Unique temporary allocation Id.',
+        'type' => 'varchar',
+        'length' => 23,
         'not null' => TRUE,
-        'description' => 'Id of the owner node.',
-      ),
+        'default' => ''),
     ),
     'primary key' => array('sid'),
     'unique keys' => array(
-      'nid' => array('nid'),
+      'uniqid' => array('uniqid'),
     ),
   );
 }
@@ -142,29 +142,30 @@ function _serial_get_table_schema() {
  * @return
  *   the unique serial value number.
  */
-function _serial_generate_value($nid, $bundle, $field_name, $delete = TRUE) {
+function _serial_generate_value($bundle, $field_name, $delete = TRUE) {
 
   // Get the name of the relevant table.
   $table = _serial_get_table_name($bundle, $field_name);
 
-  // Create a temporary record for this node and retrieve the serial value.
+  // Insert a temporary record to get a new unique serial value.
+  $uniqid = uniqid('', TRUE);
   $sid = db_insert($table)
     ->fields(array(
-      'nid' => $nid,
+      'uniqid' => $uniqid,
     ))
     ->execute();
 
   // If there's a reason why it's come back undefined, reset it.
   $sid = isset($sid) ? $sid : 0;
 
-  // Delete old temporary records:
+  // Delete the temporary record.
   if ($delete && ($sid % 10) == 0) {
-    db_delete($table)
-      ->condition('nid', $nid, '<')
-      ->execute();
+  db_delete($table)
+    ->condition('uniqid', $uniqid, '=')
+    ->execute();
   }
 
-  // Return the new unique serial value:
+  // Return the new unique serial value.
   return $sid;
 }
 
@@ -189,22 +190,28 @@ function _serial_init_old_nodes($bundle, $field_name) {
   foreach ($result as $node) {
     $nid = $node->nid;
     $node = node_load($nid);
-    $sid = _serial_generate_value($nid, $bundle, $field_name, FALSE);
+    $sid = _serial_generate_value($bundle, $field_name, FALSE);
     $node->{$field_name} = array('und' => array(array('value' => $sid)));
     node_save($node);
-    $last_nid = $nid;
     $count++;
   }
 
-  // Delete temporary records (except the last):
-  if (isset($last_nid)) {
-    $serial_table = _serial_get_table_name($bundle, $field_name);
-    db_delete($serial_table)
-      ->condition('nid', $last_nid, '<')
-      ->execute();
-  }
-
   // Return the number of existing nodes that have been initialized:
   return $count;
 }
 
+/**
+ * Retrieves all the managed serial fields.
+ *
+ * @return result set containing pairs of (node type name, field name).
+ */
+function _serial_get_all_fields() {
+  $query = db_select('field_config', 'f');
+  $query->join('field_config_instance', 'i', 'i.field_name = f.field_name');
+  $query->fields('i', array('bundle', 'field_name'))
+        ->condition('f.type', 'serial', '=')
+        ->condition('i.deleted', 0, '=');
+  $result = $query->execute();
+  return $result->fetchAll();
+}
+

+ 3 - 3
sites/all/modules/contrib/fields/serial/serial.info

@@ -6,9 +6,9 @@ dependencies[] = field
 files[] = serial.module
 
 
-; Information added by drupal.org packaging script on 2011-11-05
-version = "7.x-1.2"
+; Information added by drupal.org packaging script on 2013-10-15
+version = "7.x-1.3"
 core = "7.x"
 project = "serial"
-datestamp = "1320468935"
+datestamp = "1381844527"
 

+ 31 - 6
sites/all/modules/contrib/fields/serial/serial.install

@@ -6,7 +6,7 @@
  */
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function serial_uninstall() {
   /*
@@ -37,7 +37,7 @@ function serial_field_schema($field) {
 }
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function serial_schema() {
   // Get the standard schema:
@@ -46,10 +46,7 @@ function serial_schema() {
 
   // Build the schema by iteration over all the serial field instances:
   $schema = array();
-  $query = "SELECT i.bundle AS bundle, f.field_name AS field_name ".
-           "FROM {field_config} f, {field_config_instance} i ".
-           "WHERE f.field_name = i.field_name AND f.type = 'serial' AND i.deleted = 0";
-  $result = db_query($query);
+  $result = _serial_get_all_fields();
   foreach ($result as $field) {
     $table = _serial_get_table_name($field->bundle, $field->field_name);
     $schema[$table] = $table_schema;
@@ -59,3 +56,31 @@ function serial_schema() {
   return $schema;
 }
 
+/**
+ * Upgrade path.
+ *
+ * Switches from nids to uniqid.
+ */
+function serial_update_7130() {
+  // Get the new field schema.
+  module_load_include('inc', 'serial');
+  $table_schema = _serial_get_table_schema();
+  $uniqid_schema = $table_schema['fields']['uniqid'];
+
+  // Update the schema of old assistant tables.
+  $result = _serial_get_all_fields();
+  foreach ($result as $field) {
+    // Empty the table.
+    $table = _serial_get_table_name($field->bundle, $field->field_name);
+    db_delete($table)->execute();
+
+    // Drop nid field and key
+    db_drop_field($table, 'nid');
+    db_drop_unique_key($table, 'nid');
+
+    // Add uniqid field and key
+    db_add_field($table, 'uniqid', $uniqid_schema);
+    db_add_unique_key($table, 'uniqid', array('uniqid'));
+  }
+}
+

+ 38 - 25
sites/all/modules/contrib/fields/serial/serial.module

@@ -10,7 +10,7 @@
 //==================//
 
 /**
- * Implementation of hook_field_info().
+ * Implements hook_field_info().
  */
 function serial_field_info() {
   return array(
@@ -24,7 +24,7 @@ function serial_field_info() {
 }
 
 /**
- * Implementation of hook_field_create_instance().
+ * Implements hook_field_create_instance().
  */
 function serial_field_create_instance($instance) {
   $field = field_read_field($instance['field_name']);
@@ -45,7 +45,7 @@ function serial_field_create_instance($instance) {
 }
 
 /**
- * Implementation of hook_field_delete_instance().
+ * Implements hook_field_delete_instance().
  */
 function serial_field_delete_instance($instance) {
   $field = field_read_field($instance['field_name']);
@@ -57,7 +57,7 @@ function serial_field_delete_instance($instance) {
 }
 
 /**
- * Implementation of hook_form_alter().
+ * Implements hook_form_alter().
  */
 function serial_form_alter(&$form, $form_state, $form_id) {
 
@@ -76,37 +76,50 @@ function serial_form_alter(&$form, $form_state, $form_id) {
 }
 
 /**
- * Implementation of hook_field_insert().
+ * Implements hook_field_presave().
  */
-function serial_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
-    module_load_include('inc', 'serial');
-    $sid = _serial_generate_value($entity->nid, $instance['bundle'], $field['field_name']);
+function serial_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+  module_load_include('inc', 'serial');
+  if (empty($items)) {
+    $sid = _serial_generate_value($instance['bundle'], $field['field_name']);
     $items = array(array('value' => $sid));
-    $entity->$field['field_name'] = $items;
+  }
 }
 
+
 /**
- * Implementation of hook_field_is_empty().
+ * Implements hook_field_is_empty().
  */
 function serial_field_is_empty($item, $field) {
   return FALSE; // never should be treated as empty
 }
 
 /**
- * Implementation of hook_node_type_update()
+ * Implements hook_node_presave().
  */
-function serial_node_type_update($info) {
-    // Handle content type rename:
-    if (isset($info->old_type) && ($info->old_type != $info->type)) {
-      module_load_include('inc', 'serial');
-      _serial_rename_tables($info->old_type, $info->type);
+function serial_node_presave($node) {
+  if (module_exists('auto_nodetitle')) {
+    if (auto_nodetitle_get_setting($node->type)) {
+      auto_nodetitle_set_title($node);
     }
+  }
+}
+
+/**
+ * Implements hook_node_type_update().
+ */
+function serial_node_type_update($info) {
+  // Handle content type rename:
+  if (isset($info->old_type) && ($info->old_type != $info->type)) {
+    module_load_include('inc', 'serial');
+    _serial_rename_tables($info->old_type, $info->type);
+  }
 }
 
 // Tokens for fields are currently not supported - http://drupal.org/node/691078.
 
 ///**
-// * Implementation of hook_token_info().
+// * Implements hook_token_info().
 // */
 //function serial_token_info() {
 //  $type = array(
@@ -126,7 +139,7 @@ function serial_node_type_update($info) {
 //}
 //
 ///**
-// * Implementation of hook_tokens().
+// * Implements hook_tokens().
 // */
 //function serial_tokens($type, $tokens, $data, $options) {
 //  // TODO
@@ -137,7 +150,7 @@ function serial_node_type_update($info) {
 //=================//
 
 /**
- * Implementation of hook_field_formatter_info().
+ * Implements hook_field_formatter_info().
  */
 function serial_field_formatter_info() {
   return array(
@@ -165,12 +178,12 @@ function serial_field_formatter_view($entity_type, $entity, $field, $instance, $
   return $element;
 }
 
-/****************************************************************************
- ** Theme Functions *********************************************************
-/****************************************************************************/
+/**
+ * Theme Functions
+ */
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function serial_theme() {
 
@@ -196,7 +209,7 @@ function theme_serial_formatter_default($variables) {
 //==============//
 
 /**
- * Implementation of hook_field_widget_info().
+ * Implements hook_field_widget_info().
  */
 function serial_field_widget_info() {
   return array(
@@ -208,7 +221,7 @@ function serial_field_widget_info() {
 }
 
 /**
- * Implementation of hook_field_widget().
+ * Implements hook_field_widget().
  */
 function serial_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
   return array(

+ 11 - 0
sites/all/modules/contrib/fields/title/CHANGELOG.txt

@@ -1,6 +1,17 @@
 
 Title 7.x-1.x, xxxx-xx-xx
 -------------------------
+#2286147 by plach: Language fallback does not work when an entity translation is
+  unpublished.
+#2286145 by plach: Prevent empty translations from being synced into the legacy field.
+#1772116 by duellj, GaëlG | f4o: Fixed Menu link title is not getting node title
+  by default.
+#1779268 by ndobromirov | brycesenz: Undefined index: field_name in
+  title_field_views_data_alter().
+#1441224 by MiroslavBanov | OPIN: Fieldgroup and Title break Manage Fields UI.
+#1980520 by StoraH, pbz1912: Fixed Empty wrapper tags.
+#1920096 by Johnny vd Laar | GiorgosK: Fixed Title incompatibility with the Term
+  reference widget
 #1991712 by milesw: Fixed Title displays wrong revision using Revisioning
   module.
 #1907078 by sylus: Fixed Undefined index: field_name() in

+ 13 - 0
sites/all/modules/contrib/fields/title/MAINTAINERS.txt

@@ -0,0 +1,13 @@
+
+Title is built and maintained by the Drupal project community.
+Everyone is encouraged to submit issues and changes (patches) to improve it, and
+to contribute in other ways -- see http://drupal.org/contribute to find out how.
+
+Project maintainers
+-------------------
+
+The Title maintainers oversee the development of the project as a whole. The project
+maintainers for Title are:
+
+- Francesco Placella 'plach' <http://drupal.org/u/plach>, branch 7.x-1.x
+- Sam Becker 'Sam152' <https://www.drupal.org/u/sam152>, branch 8.x-2.x

+ 3 - 3
sites/all/modules/contrib/fields/title/tests/title_test.info

@@ -7,9 +7,9 @@ dependencies[] = title
 dependencies[] = entity
 dependencies[] = entity_translation
 
-; Information added by drupal.org packaging script on 2013-07-24
-version = "7.x-1.0-alpha7+5-dev"
+; Information added by Drupal.org packaging script on 2015-03-23
+version = "7.x-1.0-alpha7+14-dev"
 core = "7.x"
 project = "title"
-datestamp = "1374690078"
+datestamp = "1427069882"
 

+ 1 - 5
sites/all/modules/contrib/fields/title/title.admin.inc

@@ -14,20 +14,16 @@ function title_form_field_ui_overview(&$form, &$form_state) {
   if (!empty($entity_info['field replacement'])) {
     $field_replacement_info = $entity_info['field replacement'];
     $admin_path = _field_ui_bundle_admin_path($form['#entity_type'], $form['#bundle']);
-    $form['fields']['#header'][6]['colspan'] += 1;
 
     foreach (element_children($form['fields']) as $field_name) {
       if (isset($field_replacement_info[$field_name])) {
-        $form['fields'][$field_name]['field_replacement'] = array(
+        $form['fields'][$field_name]['delete'] = array(
           '#type' => 'link',
           '#title' => t('replace'),
           '#href' => $admin_path . '/fields/replace/' . $field_name,
           '#options' => array('attributes' => array('title' => t('Replace %field with a customizable field instance that can be translated.', array('%field' => $field_name)))),
         );
       }
-      else {
-        $form['fields'][$field_name]['field_replacement'] = array();
-      }
     }
   }
 }

+ 24 - 22
sites/all/modules/contrib/fields/title/title.field.inc

@@ -98,35 +98,37 @@ function title_field_formatter_settings_summary($field, $instance, $view_mode) {
 function title_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
   $settings = $display['settings'];
   $output = isset($items[0]) ? $items[0]['safe_value'] : '';
+  $element = array();
 
-  if (!empty($output) && $settings['title_link'] == 'content') {
-    $uri = entity_uri($entity_type, $entity);
-    $output = l($output, $uri['path'], array('html' => TRUE));
-  }
+  if (!empty($output)) {
+    if ($settings['title_link'] == 'content') {
+      $uri = entity_uri($entity_type, $entity);
+      $output = l($output, $uri['path'], array('html' => TRUE));
+    }
 
-  $wrap_tag = empty($settings['title_style']) ? '_none' : $settings['title_style'];
+    $wrap_tag = empty($settings['title_style']) ? '_none' : $settings['title_style'];
 
-  if ($wrap_tag != '_none') {
-    $variables = array(
-      'element' => array(
-        '#tag' => $wrap_tag,
-        '#value' => $output,
-      ),
-    );
+    if ($wrap_tag != '_none') {
+      $variables = array(
+        'element' => array(
+          '#tag' => $wrap_tag,
+          '#value' => $output,
+        ),
+      );
+
+      if (!empty($settings['title_class'])) {
+        $variables['element']['#attributes'] = array('class' => $settings['title_class']);
+      }
 
-    if (!empty($settings['title_class'])) {
-      $variables['element']['#attributes'] = array('class' => $settings['title_class']);
+      $output = theme('html_tag', $variables);
     }
 
-    $output = theme('html_tag', $variables);
+    $element = array(
+      array(
+        '#markup' => $output,
+      ),
+    );
   }
-
-  $element = array(
-    array(
-      '#markup' => $output,
-    ),
-  );
-
   return $element;
 }
 

+ 3 - 3
sites/all/modules/contrib/fields/title/title.info

@@ -9,9 +9,9 @@ files[] = title.module
 files[] = views/views_handler_title_field.inc
 files[] = tests/title.test
 
-; Information added by drupal.org packaging script on 2013-07-24
-version = "7.x-1.0-alpha7+5-dev"
+; Information added by Drupal.org packaging script on 2015-03-23
+version = "7.x-1.0-alpha7+14-dev"
 core = "7.x"
 project = "title"
-datestamp = "1374690078"
+datestamp = "1427069882"
 

+ 50 - 1
sites/all/modules/contrib/fields/title/title.module

@@ -218,6 +218,9 @@ function title_field_attach_load($entity_type, $entities, $age, $options) {
  * replaced fields.
  */
 function title_entity_load($entities, $type) {
+  // Load entity translations otherwise field language will not be computed
+  // correctly.
+  module_invoke('entity_translation', 'entity_load', $entities, $type);
   foreach ($entities as &$entity) {
     // Synchronize values from the regular field unless we are intializing it.
     title_entity_sync($type, $entity, NULL, !empty($GLOBALS['title_field_replacement_init']));
@@ -487,8 +490,14 @@ function title_field_sync_get($entity_type, $entity, $legacy_field, $info, $lang
     $langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode);
     $values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
     foreach ($values as $name => $value) {
-      $entity->{$name} = $value;
+      if ($value !== NULL) {
+        $entity->{$name} = $value;
+      }
     }
+    // Ensure we do not pollute field language static cache.
+    $cache = &drupal_static('field_language');
+    list($id, ,) = entity_extract_ids($entity_type, $entity);
+    unset($cache[$entity_type][$id]);
   }
 }
 
@@ -584,6 +593,11 @@ function title_field_attach_form($entity_type, $entity, &$form, &$form_state, $l
         if (isset($form[$legacy_field]['#access'])) {
           $form[$info['field']['field_name']]['#access'] = $form[$legacy_field]['#access'];
         }
+
+        // Add class from legacy field so behaviors can still be applied on
+        // title widget.
+        $form[$info['field']['field_name']]['#attributes']['class'] = array('form-item-' . $legacy_field);
+
         // Restrict access to the legacy field form element and mark it as
         // replaced.
         $form[$legacy_field]['#access'] = FALSE;
@@ -952,3 +966,38 @@ function title_field_attach_create_bundle($entity_type, $bundle) {
     }
   }
 }
+
+/**
+ * Implements hook_field_info_alter().
+ */
+function title_field_info_alter(&$info) {
+  $supported_types = array('taxonomy_term_reference' => TRUE);
+  foreach ($info as $field_type => &$field_type_info) {
+    if (isset($supported_types[$field_type])) {
+      if (!isset($field_type_info['settings'])) {
+        $field_type_info['settings'] = array();
+      }
+      $field_type_info['settings'] += array('options_list_callback' => 'title_taxonomy_allowed_values');
+    }
+  }
+}
+
+/**
+ * Return taxonomy term values for taxonomy reference fields.
+ */
+function title_taxonomy_allowed_values($field) {
+  $bundle = !empty($field['settings']['allowed_values'][0]['vocabulary']) ? $field['settings']['allowed_values'][0]['vocabulary'] : NULL;
+  if ($bundle && ($label = title_field_replacement_get_label_field('taxonomy_term', $bundle))) {
+    $options = array();
+    foreach ($field['settings']['allowed_values'] as $tree) {
+      $vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary']);
+      if ($vocabulary && ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'], NULL, TRUE))) {
+        foreach ($terms as $term) {
+          $options[$term->tid] = str_repeat('-', $term->depth) . entity_label('taxonomy_term', $term);
+        }
+      }
+    }
+    return $options;
+  }
+  return taxonomy_allowed_values($field);
+}

+ 6 - 4
sites/all/modules/contrib/fields/title/views/title.views.inc

@@ -9,10 +9,12 @@ function title_field_views_data_alter(&$data) {
     $replacements = title_field_replacement_info($entity_type);
     if ($replacements) {
       foreach ($replacements as $replacement) {
-        $field = field_info_field($replacement['field']['field_name']);
-        $table = _field_sql_storage_tablename($field);
-        if (isset($data[$table][$field['field_name']])) {
-          $data[$table][$field['field_name']]['field']['handler'] = 'views_handler_title_field';
+        if (isset($replacement['field']['field_name'])) {
+          $field = field_info_field($replacement['field']['field_name']);
+          $table = _field_sql_storage_tablename($field);
+          if (isset($data[$table][$field['field_name']])) {
+            $data[$table][$field['field_name']]['field']['handler'] = 'views_handler_title_field';
+          }
         }
       }
     }

BIN
sites/all/modules/contrib/fields/video_embed_field/img/vimeo.jpg


BIN
sites/all/modules/contrib/fields/video_embed_field/img/youtube.jpg


+ 5 - 0
sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/README.txt

@@ -0,0 +1,5 @@
+Brightcove Video Embed Field
+----------------------------
+This module parses a Brightcove URL via the Video Embed Field
+
+Example URL: http://link.brightcove.com/services/player/bcpid3303744435001?bckey=AQ~~,AAAAAGL7jok~,vslbwQw3pdWM_Ya9IsUVNvJJIhV9YG1S&bctid=3118695475001

BIN
sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/img/brightcove.jpg


+ 14 - 0
sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/video_embed_brightcove.info

@@ -0,0 +1,14 @@
+name = "Video Embed Brightcove"
+description = "Provides Brightcove handler for Video Embed Fields."
+core = 7.x
+package = Media
+configure = admin/config/media/vef_video_styles
+
+dependencies[] = "video_embed_field"
+
+; Information added by Drupal.org packaging script on 2015-04-17
+version = "7.x-2.0-beta8+7-dev"
+core = "7.x"
+project = "video_embed_field"
+datestamp = "1429278491"
+

+ 159 - 0
sites/all/modules/contrib/fields/video_embed_field/video_embed_brightcove/video_embed_brightcove.module

@@ -0,0 +1,159 @@
+<?php
+
+/**
+ * @file
+ * Add a handler for brightcove videos to Video Embed Field.
+ * @see video_embed_field.api.php for more documentation.
+ */
+
+/**
+ * Implements hook_video_embed_handler_info().
+ */
+function video_embed_brightcove_video_embed_handler_info() {
+  $handlers = array();
+  $handlers['brightcove'] = array(
+    'title' => 'Brightcove Video',
+    'function' => 'video_embed_brightcove_handle_video',
+    'thumbnail_default' => drupal_get_path('module', 'video_embed_brightcove') . '/img/brightcove.jpg',
+    'form' => 'video_embed_brightcove_form',
+    'form_validate' => 'video_embed_field_handler_brightcove_form_validate',
+    'domains' => array(
+      'brightcove.com',
+      'link.brightcove.com',
+    ),
+    'defaults' => array(
+      'width' => 640,
+      'height' => 360,
+    ),
+  );
+
+  return $handlers;
+}
+
+/**
+ * Form to configure out video settings.
+ *
+ * @param array $defaults
+ *   Values for your provider.
+ *
+ * @return array
+ *   A form as defined by form API.
+ */
+function video_embed_brightcove_form($defaults) {
+  $form = array();
+  // Element for the width of the player.
+  $form['width'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Player Width'),
+    '#description' => t('The width of the player.'),
+    '#default_value' => $defaults['width'],
+  );
+
+  // Element for the height of the player.
+  $form['height'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Player Height'),
+    '#description' => t('The height of the player.'),
+    '#default_value' => $defaults['height'],
+  );
+
+  return $form;
+}
+
+/**
+ * Validates the form elements for the Brightcove configuration form.
+ */
+function video_embed_field_handler_brightcove_form_validate($element, &$form_state, $form) {
+  video_embed_field_validate_dimensions($element);
+}
+
+/**
+ * The video handler.
+ *
+ * @param string $url
+ *   The full video url.
+ * @param array $settings
+ *   Handlers settings from the settings form.
+ *
+ * @return array|string
+ *   The embed code for the video.
+ */
+function video_embed_brightcove_handle_video($url, $settings) {
+  $parameters = _video_embed_brightcove_get_video_properties($url);
+
+  if (isset($parameters['id']) && isset($parameters['key'])) {
+    // Embed code.
+    $embed = '<object id="myExperience" class="BrightcoveExperience">
+      <param name="bgcolor" value="#FFFFFF" />
+      <param name="width" value="@width" />
+      <param name="height" value="@height" />
+      <param name="playerID" value="!id" />
+      <param name="playerKey" value="!key" />
+      <param name="isVid" value="true" />
+      <param name="isUI" value="true" />
+      <param name="dynamicStreaming" value="true" />
+      <param name="@videoPlayer" value="!videoplayer" />
+    </object>';
+    // Replace our placeholders with the values from the settings.
+    $embed = format_string($embed, array(
+      '!id' => $parameters['id'],
+      '!key' => $parameters['key'],
+      '@width' => $settings['width'],
+      '@height' => $settings['height'],
+      '!videoplayer' => $parameters['player'],
+    ));
+
+    $video = array(
+      '#markup' => $embed,
+      '#suffix' => '<script type="text/javascript">brightcove.createExperiences();</script>',
+      '#attached' => array(
+        'js' => array(
+          '//admin.brightcove.com/js/BrightcoveExperiences.js' => array(
+            'type' => 'external',
+          ),
+        ),
+      ),
+    );
+
+    return $video;
+  }
+  return '';
+}
+
+/**
+ * Helper function to take a brightcove video url and return its id.
+ *
+ * @param string $url
+ *   The full brightcove video url.
+ *
+ * @return array
+ *   The video properties.
+ */
+function _video_embed_brightcove_get_video_properties($url) {
+  // Easy way to break a url into its components.
+  $components = array(
+    'id' => array(
+      'start' => 'bcpid',
+      'finish' => '\?bckey',
+    ),
+    'key' => array(
+      'start' => 'bckey=',
+      'finish' => '&bctid',
+    ),
+    'player' => array(
+      'start' => 'bctid=',
+      'finish' => '',
+    ),
+  );
+
+  $matches = array();
+  $return = array();
+  foreach ($components as $key => $component) {
+    $string = "/(.*){$component['start']}(.*){$component['finish']}/";
+    preg_match($string, $url, $matches);
+    if ($matches && !empty($matches[2])) {
+      $return[$key] = $matches[2];
+    }
+  }
+  return $return;
+}

BIN
sites/all/modules/contrib/fields/video_embed_field/video_embed_facebook/img/facebook.jpg


+ 94 - 0
sites/all/modules/contrib/fields/video_embed_field/video_embed_field.devel_generate.inc

@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * @file
+ * Devel generate support for video_embed_field module.
+ */
+
+// The Youtube’s API url.
+define('YT_API_URL', 'http://gdata.youtube.com/feeds/api/videos?q=');
+
+/**
+ * Devel generate plugin definition.
+ */
+function video_embed_field_devel_generate($object, $field, $instance, $bundle) {
+  if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
+    return devel_generate_multiple('_video_embed_field_devel_generate', $object, $field, $instance, $bundle);
+  }
+  else {
+    return _video_embed_field_devel_generate($object, $field, $instance, $bundle);
+  }
+}
+
+/**
+ * Generates a random video_embed_field item.
+ *
+ * @param object $object
+ *   The devel_generate object.
+ * @param array $field
+ *   The field definition.
+ * @param array $instance
+ *   The field instance definition.
+ * @param array $bundle
+ *   The bundle definition.
+ *
+ * @return array
+ *   The video_embed_field item.
+ */
+function _video_embed_field_devel_generate($object, $field, $instance, $bundle) {
+  $video = video_embed_field_retrieve_video();
+  $object_field = array();
+  $object_field['video_url'] = $video['video_url'];
+  if ($instance['settings']['description_field']) {
+    $object_field['description'] = $video['description'];
+  }
+  return $object_field;
+}
+
+/**
+ * Retrieves a random youtube video info from the bunch.
+ *
+ * @return array
+ *   The video definition.
+ */
+function video_embed_field_retrieve_video() {
+  $videos = video_embed_field_generate_videos();
+  return $videos[array_rand($videos)];
+}
+
+/**
+ * Generates a pseudo random bunch of youtube videos.
+ *
+ * @return array
+ *   A bunch of youtube videos.
+ */
+function video_embed_field_generate_videos() {
+  $videos = &drupal_static(__FUNCTION__);
+  if (!isset($videos)) {
+    $videos = array();
+
+    // Create random video seed.
+    $video_id = user_password(2);
+
+    // Using cURL php extension to make the request to youtube API.
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_URL, YT_API_URL . $video_id);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    // $feed holds a rss feed xml returned by youtube API.
+    $feed = curl_exec($ch);
+    curl_close($ch);
+
+    // Using SimpleXML to parse youtube’s feed.
+    $xml = simplexml_load_string($feed);
+    foreach ($xml->entry as $entry) {
+      $videos[] = array(
+        'video_url' => $entry->children('media', TRUE)->group->player->attributes()->url,
+        'description' => $entry->title,
+      );
+    }
+    if (empty($videos)) {
+      video_embed_field_generate_videos();
+    }
+  }
+  return $videos;
+}

+ 73 - 0
sites/all/modules/contrib/fields/video_embed_field/video_embed_field.feeds.inc

@@ -0,0 +1,73 @@
+<?php
+/**
+ * @file
+ * On behalf implementation of Feeds mapping API for video_embed_field.module.
+ */
+
+/**
+ * Implements hook_feeds_processor_targets_alter().
+ *
+ * @see FeedsNodeProcessor::getMappingTargets()
+ */
+function video_embed_field_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
+  foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
+    $info = field_info_field($name);
+    if ($info['type'] == 'video_embed_field') {
+      $targets[$name . ":video_url"] = array(
+        'name' => t('@name: Embed URL', array('@name' => $instance['label'])),
+        'callback' => 'video_embed_field_set_target',
+        'description' => t('The URL for the @label field of the @entity_type.', array('@entity_type' => $entity_type, '@label' => $instance['label'])),
+        'real_target' => $name,
+      );
+      $targets[$name . ':description'] = array(
+        'name' => t('@name: Embed description', array('@name' => $instance['label'])),
+        'callback' => 'video_embed_field_set_target',
+        'description' => t('The description for the @label field of the @entity_type.', array('@entity_type' => $entity_type, '@label' => $instance['label'])),
+        'real_target' => $name,
+      );
+    }
+  }
+}
+
+/**
+ * Callback for mapping. Here is where the actual mapping happens.
+ *
+ * When the callback is invoked, $target contains the name of the field the
+ * user has decided to map to and $value contains the value of the feed item
+ * element the user has picked as a source.
+ */
+function video_embed_field_set_target($source, $entity, $target, $value) {
+  if (empty($value)) {
+    return;
+  }
+
+  if (!is_array($value)) {
+    $value = array($value);
+  }
+
+  list($field_name, $sub_field) = explode(':', $target, 2);
+
+  $info = field_info_field($field_name);
+
+  // Iterate over all values.
+  $field = isset($entity->$field_name) ? $entity->$field_name : array(LANGUAGE_NONE => array());
+
+  // Allow for multiple mappings to the same target.
+  $count = call_user_func_array('array_merge_recursive', $field[LANGUAGE_NONE]);
+  $delta = count($count[$sub_field]);
+
+  foreach ($value as $v) {
+
+    if ($info['cardinality'] != FIELD_CARDINALITY_UNLIMITED && $info['cardinality'] <= $delta) {
+      break;
+    }
+
+    if (is_scalar($v)) {
+      $field[LANGUAGE_NONE][$delta][$sub_field] = $v;
+
+      $delta++;
+    }
+  }
+
+  $entity->{$field_name} = $field;
+}

+ 57 - 0
sites/all/modules/contrib/fields/video_embed_field/video_embed_field.migrate.inc

@@ -0,0 +1,57 @@
+<?php
+/**
+ * @file
+ * Migrate support for Video Embed Field module.
+ */
+
+/**
+ * Implements hook_migrate_api().
+ */
+function video_embed_field_migrate_api() {
+  $api = array(
+    'api' => 2,
+    'field handlers' => array('MigrateVideoEmbedFieldFieldHandler'),
+  );
+  return $api;
+}
+
+/**
+ * Custom extended MigrateFieldHandler class for Video Embed Field module.
+ */
+class MigrateVideoEmbedFieldFieldHandler extends MigrateFieldHandler {
+
+  public function __construct() {
+    $this->registerTypes(array('video_embed_field'));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function fields($type, $parent_field, $migration = NULL) {
+    $fields = array(
+      'video_url' => t('Video: The video URL.'),
+    );
+    return $fields;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function prepare($entity, array $field_info, array $instance, array $values) {
+    $arguments = array();
+    if (isset($values['arguments'])) {
+      $arguments = array_filter($values['arguments']);
+      unset($values['arguments']);
+    }
+    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
+
+    // Setup the standard Field API array for saving.
+    $delta = 0;
+    foreach ($values as $value) {
+      $return[$language][$delta] = array('video_url' => $value);
+      $delta++;
+    }
+
+    return isset($return) ? $return : NULL;
+  }
+}

+ 22 - 0
sites/all/modules/contrib/fields/video_embed_field/views/handlers/views_embed_field_views_handler_field_thumbnail_path.inc

@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @file
+ * Video embed field thumbnail_path column implementation.
+ */
+
+/**
+ * Defines a field handler that can display the thumbnail_path url instead of
+ * the drupal internal uri.
+ */
+class views_embed_field_views_handler_field_thumbnail_path extends views_handler_field {
+
+  /**
+   * {@inheritdoc}
+   */
+  function get_value($values, $field = NULL) {
+    $value = parent::get_value($values, $field);
+
+    return file_create_url($value);
+  }
+}

+ 72 - 0
sites/all/modules/contrib/fields/video_embed_field/views/video_embed_field.views.inc

@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * @file
+ * Hooks for Views integration.
+ */
+
+/**
+ * Implements hook_field_views_data().
+ */
+function video_embed_field_field_views_data($field) {
+  $data = field_views_field_default_views_data($field);
+
+  // Only expose these components as Views field handlers.
+  $implemented = array(
+    'video_url' => 'views_handler_field',
+    'thumbnail_path' => 'views_embed_field_views_handler_field_thumbnail_path',
+    'description' => 'views_handler_field',
+  );
+
+  // Get the translated field information.
+  $properties = video_embed_field_data_property_info();
+
+  // Iterate over video_embed_field defined tables.
+  foreach ($data as &$table) {
+    // Make sure the parent Views field (video_embed_field) is defined.
+    if (isset($table[$field['field_name']]['field'])) {
+      // Use the parent field definition as a template for component columns.
+      $field_def = $table[$field['field_name']]['field'];
+
+      // Remove 'additional fields' from the field definition. We don't
+      // necessarily want all our sibling columns.
+      unset($field_def['additional fields']);
+
+      // Define the valid columns.
+      $valid_columns = array();
+      foreach ($implemented as $implement => $handler) {
+        $column_name = $field['field_name'] . '_' . $implement;
+        $valid_columns[$column_name] = $handler;
+      }
+
+      // Iterate over the video_embed_field components.
+      foreach ($table as $column_name => &$column) {
+        if (empty($column['field']) && isset($valid_columns[$column_name])) {
+          // Assign the default component definition.
+          $column['field'] = $field_def;
+          $column['field']['real field'] = $column_name;
+          $column['field']['handler'] = $valid_columns[$column_name];
+
+          // Assign human-friendly labels for video_embed_field components.
+          $field_labels = field_views_field_label($field['field_name']);
+          $field_label = array_shift($field_labels);
+          $property = str_replace($field_def['field_name'] . '_', '', $column_name);
+
+          if (!empty($properties[$property])) {
+            $property_label = $properties[$property]['label'];
+
+            $title = t('@field-label - @property-label', array(
+              '@field-label' => $field_label,
+              '@property-label' => $property_label,
+            ));
+
+            $column['title'] = $title;
+            $column['title short'] = $title;
+          }
+        }
+      }
+    }
+  }
+
+  return $data;
+}

+ 22 - 0
sites/all/modules/contrib/files/transliteration/transliteration.api.php

@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @file
+ * Documents Transliteration's hooks for api reference.
+ */
+
+/**
+ * Alters a file name before transliteration and sanitization.
+ *
+ * @param &$filename
+ *   The file name before being parsed by transliteration.
+ *
+ * @param $source_langcode
+ *   Optional ISO 639 language code that denotes the language of the input.
+ *
+ * @see transliteration_clean_filename()
+ */
+function hook_transliteration_clean_filename_prepare_alter(&$filename, $source_langcode) {
+  $filename = drupal_strtolower($filename);
+  $filename = str_ireplace(array('&amp; ', '& '), 'and ', $filename);
+}

+ 289 - 0
sites/all/modules/contrib/taxonomy/synonyms/synonyms.pages.inc

@@ -0,0 +1,289 @@
+<?php
+
+/**
+ * @file
+ * Menu page callbacks of Synonyms module.
+ */
+
+/**
+ * Page callback: Outputs JSON for taxonomy autocomplete suggestions.
+ *
+ * This callback outputs term name suggestions in response to Ajax requests
+ * made by the synonyms autocomplete widget for taxonomy term reference
+ * fields. The output is a JSON object of plain-text term suggestions,
+ * keyed by the user-entered value with the completed term name appended.
+ * Term names containing commas are wrapped in quotes. The search is made
+ * with consideration of synonyms.
+ *
+ * @param string $field_name
+ *   The name of the term reference field.
+ * @param string $entity_type
+ *   Entity type to which the supplied $field_name is attached to
+ * @param string $bundle
+ *   Bundle name to which the supplied $field_name is attached to
+ * @param string $tags_typed
+ *   (optional) A comma-separated list of term names entered in the
+ *   autocomplete form element. Only the last term is used for autocompletion.
+ *   Defaults to '' (an empty string).
+ */
+function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed = '') {
+  // If the request has a '/' in the search text, then the menu system will have
+  // split it into multiple arguments, recover the intended $tags_typed.
+  $args = func_get_args();
+  // Shift off the $field_name argument.
+  array_shift($args);
+  // Shift off the $entity_type argument.
+  array_shift($args);
+  // Shift off the $bundle argument.
+  array_shift($args);
+  $tags_typed = implode('/', $args);
+
+  // Make sure the field exists and is a taxonomy field.
+  if (!($field = field_info_field($field_name)) || $field['type'] != 'taxonomy_term_reference') {
+    // Error string. The JavaScript handler will realize this is not JSON and
+    // will display it as debugging information.
+    print t('Taxonomy field @field_name not found.', array('@field_name' => $field_name));
+    exit;
+  }
+
+  if (!($instance = field_info_instance($entity_type, $field['field_name'], $bundle))) {
+    // Error string. The JavaScript handler will realize this is not JSON and
+    // will display it as debugging information.
+    print t('There was not found an instance of @field_name in @entity_type.', array(
+      '@field_name' => $field_name,
+      '@entity_type' => $entity_type,
+    ));
+    exit;
+  }
+
+  // How many suggestions maximum we are able to output.
+  $max_suggestions = $instance['widget']['settings']['suggestion_size'];
+
+  // Whether we are allowed to suggest more than one entry per term, shall that
+  // entry be either term name itself or one of its synonyms.
+  $suggest_only_unique = $instance['widget']['settings']['suggest_only_unique'];
+
+  // The user enters a comma-separated list of tags. We only autocomplete the
+  // last tag.
+  $tags_typed = drupal_explode_tags($tags_typed);
+  $tag_last = drupal_strtolower(array_pop($tags_typed));
+
+  $term_matches = array();
+  if ($tag_last != '') {
+    // Part of the criteria for the query come from the field's own settings.
+    $vocabularies = array();
+    $tmp = taxonomy_vocabulary_get_names();
+    foreach ($field['settings']['allowed_values'] as $tree) {
+      $vocabularies[$tmp[$tree['vocabulary']]->vid] = $tree['vocabulary'];
+    }
+    $vocabularies = taxonomy_vocabulary_load_multiple(array_keys($vocabularies));
+
+    // Array of found suggestions. Each subarray of this array will represent
+    // a single suggestion entry. The sub array must at least contain the
+    // following keys:
+    //   tid - tid of the suggested term
+    //   name - name of the suggested term
+    // And optionally, if the term is suggested based on its synonym, the sub
+    // array should also include the additional key:
+    //   synonym - string representation of the synonym based on which the
+    //     suggested term was included.
+    $tags_return = array();
+
+    // Firstly getting a list of tids that match by $term->name.
+    $query = db_select('taxonomy_term_data', 't');
+    $query->addTag('translatable');
+    $query->addTag('term_access');
+
+    // Do not select already entered terms.
+    if (!empty($tags_typed)) {
+      $query->condition('t.name', $tags_typed, 'NOT IN');
+    }
+    // Select rows that match by term name.
+    $result = $query
+      ->fields('t', array('tid', 'name'))
+      ->condition('t.vid', array_keys($vocabularies))
+      ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
+      ->range(0, $max_suggestions)
+      ->execute()
+      ->fetchAllKeyed();
+
+    // Converting results into another format.
+    foreach ($result as $tid => $name) {
+      $tags_return[] = array(
+        'name' => $name,
+        'tid' => $tid,
+      );
+    }
+
+    $synonym_tids = array();
+    // Now we go vocabulary by vocabulary looking through synonym fields.
+    foreach ($vocabularies as $vocabulary) {
+      // Now we go a synonym field by synonym field gathering suggestions.
+      // Since officially EntityFieldQuery doesn't support OR conditions
+      // we are enforced to go a field by field querying multiple times the DB.
+      $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
+      foreach (synonyms_synonyms_fields($vocabulary) as $field) {
+        $field = field_info_field($field);
+        $instance = field_info_instance('taxonomy_term', $field['field_name'], $bundle);
+        $query = new EntityFieldQuery();
+        $query->entityCondition('entity_type', 'taxonomy_term')
+          ->entityCondition('bundle', $bundle);
+
+        // We let the class that defines this field type as a source of synonyms
+        // filter out and provide its suggestions based on this field.
+        $class = synonyms_extractor_info($field['type']);
+        call_user_func(array($class, 'processEntityFieldQuery'), $tag_last, $query, $field, $instance);
+
+        if (!empty($tags_typed)) {
+          $query->propertyCondition('name', $tags_typed, 'NOT IN');
+        }
+        if ($suggest_only_unique && !empty($tags_return)) {
+          $tmp = array();
+          foreach ($tags_return as $tag_return) {
+            $tmp[] = $tag_return['tid'];
+          }
+          // We don't want to search among the terms already found by term name.
+          $query->entityCondition('entity_id', $tmp, 'NOT IN');
+        }
+        if ($suggest_only_unique && !empty($synonym_tids)) {
+          // We also don't want to search among the terms already matched by
+          // previous synonym fields.
+          $query->entityCondition('entity_id', $synonym_tids, 'NOT IN');
+        }
+        $tmp = $query->execute();
+        if (!empty($tmp)) {
+          // Merging the results.
+          $tmp = array_keys($tmp['taxonomy_term']);
+          $synonym_tids = array_merge($synonym_tids, $tmp);
+        }
+      }
+    }
+
+    if (!empty($synonym_tids)) {
+      foreach (taxonomy_term_load_multiple($synonym_tids) as $synonym_term) {
+        $tmp = array(
+          'name' => $synonym_term->name,
+          'tid' => $synonym_term->tid,
+        );
+        // Additionally we have to find out which synonym triggered inclusion of
+        // this term.
+        foreach (synonyms_get_sanitized($synonym_term) as $item) {
+          if (strpos(mb_strtoupper($item, 'UTF-8'), mb_strtoupper($tag_last, 'UTF-8')) !== FALSE) {
+            $tags_return[] = array('synonym' => $item) + $tmp;
+            if ($suggest_only_unique) {
+              // We just want to output 1 single suggestion entry per term, so
+              // one synonym is enough.
+              break;
+            }
+          }
+        }
+      }
+    }
+    $prefix = empty($tags_typed) ? '' : drupal_implode_tags($tags_typed) . ', ';
+
+    if (count($tags_return) > $max_suggestions) {
+      $tags_return = array_slice($tags_return, 0, $max_suggestions);
+    }
+
+    // Now formatting the results.
+    foreach ($tags_return as $info) {
+      $n = $info['name'];
+      // Term names containing commas or quotes must be wrapped in quotes.
+      if (strpos($info['name'], ',') !== FALSE || strpos($info['name'], '"') !== FALSE) {
+        $n = '"' . str_replace('"', '""', $info['name']) . '"';
+      }
+
+      if (isset($info['synonym'])) {
+        $display_name = t('@synonym, synonym of %term', array('@synonym' => $info['synonym'], '%term' => $info['name']));
+      }
+      else {
+        $display_name = check_plain($info['name']);
+      }
+      while (isset($term_matches[$prefix . $n])) {
+        $n .= ' ';
+      }
+      $term_matches[$prefix . $n] = $display_name;
+    }
+  }
+  drupal_json_output($term_matches);
+}
+
+/**
+ * Mark nodes that reference specific terms for search re-indexing.
+ *
+ * This is particularly useful, when the terms in question have been changed.
+ *
+ * @param $tids array
+ *   Array of tids of the terms
+ */
+function synonyms_reindex_nodes_by_terms($tids) {
+  // In order to speed up the process, we will query DB for nid's that reference
+  // handled to us tids, and at the end we'll trigger their re-indexing in just
+  // a single SQL query. Probably it is better to use search_touch_node(), but
+  // that would imply a big amount of SQL queries on some websites.
+  $found_nids = array();
+  foreach (field_info_field_map() as $field_name => $v) {
+    if ($v['type'] == 'taxonomy_term_reference' && isset($v['bundles']['node'])) {
+      // This field is taxonomy term reference and it is attached to nodes, so
+      // we will run EntityFieldQuery on it.
+      $query = new EntityFieldQuery();
+      $result = $query->entityCondition('entity_type', 'node')
+        ->fieldCondition($field_name, 'tid', $tids, 'IN')
+        ->execute();
+      if (isset($result['node'])) {
+        $found_nids = array_merge($found_nids, array_keys($result['node']));
+      }
+    }
+  }
+  if (!empty($found_nids)) {
+    db_update('search_dataset')
+      ->fields(array('reindex' => REQUEST_TIME))
+      ->condition('type', 'node')
+      ->condition('sid', $found_nids, 'IN')
+      ->execute();
+  }
+}
+
+/**
+ * Mark nodes that reference terms from a vocabulary for search re-indexing.
+ *
+ * @param $vocabulary object
+ *   Fully loaded vocabulary object
+ */
+function synonyms_reindex_nodes_by_vocabulary($vocabulary) {
+  $tids = db_select('taxonomy_term_data', 't')
+    ->fields('t', array('tid'))
+    ->condition('vid', $vocabulary->vid)
+    ->execute()
+    ->fetchCol();
+  if (!empty($tids)) {
+    synonyms_reindex_nodes_by_terms($tids);
+  }
+}
+
+/**
+ * Submit handler for Taxonomy vocabulary edit form.
+ *
+ * Store extra values attached to form in this module.
+ */
+function synonyms_taxonomy_form_vocabulary_submit($form, &$form_state) {
+  $values = $form_state['values'];
+
+  if ($values['op'] == $form['actions']['submit']['#value']) {
+    if (isset($form['#vocabulary']->vid)) {
+      $vocabulary = taxonomy_vocabulary_load($form['#vocabulary']->vid);
+    }
+    else {
+      // As a fallback, if this is a just created vocabulary, we try to pull it
+      // up by the just submitted machine name.
+      $vocabulary = taxonomy_vocabulary_machine_name_load($values['machine_name']);
+    }
+
+    // Preprocessing values keeping only field names of the checked fields.
+    $values['synonyms']['synonyms'] = array_values(array_filter($values['synonyms']['synonyms']));
+
+    $settings = synonyms_vocabulary_settings($vocabulary);
+    $settings = $values['synonyms'] + $settings;
+    synonyms_vocabulary_settings_save($vocabulary, $settings);
+  }
+}

+ 17 - 0
sites/all/modules/contrib/taxonomy/synonyms/views/synonyms.views.inc

@@ -0,0 +1,17 @@
+<?php
+
+/**
+ * @file
+ * Views integration of Synonyms module.
+ */
+
+/**
+ * Implements hook_views_plugins_alter().
+ *
+ * @see hook_views_plugins_alter()
+ */
+function synonyms_views_plugins_alter(&$plugins) {
+  // Replace default taxonomy term argument validator with our extended version,
+  // which can also handle a term synonym as an argument.
+  $plugins['argument validator']['taxonomy_term']['handler'] = 'synonyms_views_plugin_argument_validate_taxonomy_term';
+}

+ 163 - 0
sites/all/modules/contrib/taxonomy/synonyms/views/synonyms_views_plugin_argument_validate_taxonomy_term.inc

@@ -0,0 +1,163 @@
+<?php
+
+/**
+ * @file
+ * An extended version of the 'taxonomy term' argument validator plugin, which
+ * supports synonyms as arguments.
+ */
+
+/**
+ * Validate whether an argument is an acceptable taxonomy term.
+ */
+class synonyms_views_plugin_argument_validate_taxonomy_term extends views_plugin_argument_validate_taxonomy_term {
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    // We just want to add yet another way of validation - synonyms friendly
+    // validation.
+    $form['type']['#options']['synonym'] = t('Term name or synonym');
+    $form['type']['#options']['synonym_tid'] = t('Term name or synonym converted to Term ID');
+  }
+
+  function validate_argument($argument) {
+    $vocabularies = array_filter($this->options['vocabularies']);
+    $type = $this->options['type'];
+    $transform = $this->options['transform'];
+
+    switch ($type) {
+      case 'synonym':
+      case 'synonym_tid':
+        // We are requested to do synonyms friendly validation. We will have to
+        // go through each of allowed vocabularies, collecting terms whose
+        // synonyms might look like the argument we have. However, it is not
+        // that easy to achieve due to the fact that synonyms may be kept in
+        // whatever format in whatever column and only corresponding Synonyms
+        // extractor class has the knowledge how it is organized. Firstly we are
+        // going to query database trying to find a term with our argument's
+        // name. If we find one, it is great and we stop right there. Otherwise,
+        // the nightmare starts: we are going to use
+        // AbstractSynonymsExtractor::processEntityFieldQuery() method to find
+        // synonyms that are similar to our argument. Then we will load those
+        // terms and manually in PHP will determine whether it is a match.
+        $query = db_select('taxonomy_term_data', 't')
+          ->fields('t', array('tid', 'name'));
+        if (!empty($vocabularies)) {
+          $query->innerJoin('taxonomy_vocabulary', 'v', 't.vid = v.vid');
+          $query->condition('v.machine_name', $vocabularies);
+        }
+        if ($transform) {
+          $query->where("replace(t.name, ' ', '-') = :name", array(':name' => $argument));
+        }
+        else {
+          $query->condition('t.name', $argument, '=');
+        }
+        $result = $query->range(0, 1)
+          ->execute();
+        if ($result->rowCount()) {
+          // We have found a term, we are going to use it.
+          $term = taxonomy_term_load($result->fetchField(0));
+          $this->argument->argument = $this->synonyms_get_term_property($term);
+          $this->argument->validated_title = check_plain(entity_label('taxonomy_term', $term));
+          return TRUE;
+        }
+
+        if (empty($vocabularies)) {
+          // At this point we want to convert an empty $vocabulary (implicitly
+          // meaning "all") into actually a list of all fully loaded
+          // vocabularies.
+          $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
+        }
+        else {
+          // We need to load the filtered vocabularies based on their machine
+          // names.
+          foreach ($vocabularies as $v) {
+            $vocabularies[$v] = taxonomy_vocabulary_machine_name_load($v);
+          }
+        }
+
+        // We haven't had much luck, seems like we have to do the hard part. We
+        // will pull up terms that are similar to our argument using the same
+        // functionality as for synonyms friendly autocomplete widget and then
+        // will find those who actually match among this narrowed set of terms.
+        // Since $match will be use as value for LIKE SQL operator, we are not
+        // sure whether we need to substitute dash (-) with spacebar, or keep
+        // the dash, to match both we will use underscore (_) since this symbol
+        // matches one symbol in LIKE operator.
+        $match = $transform ? str_replace('-', '_', $argument) : $argument;
+        $tids = array();
+        // Unfortunately we have to query multiple times the database for each
+        // vocabulary for each synonyms-source field.
+        foreach ($vocabularies as $vocabulary) {
+          $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
+          foreach (synonyms_synonyms_fields($vocabulary) as $field) {
+            $field = field_info_field($field);
+            $instance = field_info_instance('taxonomy_term', $field['field_name'], $bundle);
+            $query = new EntityFieldQuery();
+            $query->entityCondition('entity_type', 'taxonomy_term')
+              ->entityCondition('bundle', $vocabulary->machine_name);
+
+            // We let the class that defines this field type as a source of
+            // synonyms filter out and provide its suggestions based on this
+            // field.
+            $class = synonyms_extractor_info($field['type']);
+            call_user_func(array($class, 'processEntityFieldQuery'), $match, $query, $field, $instance);
+            if (!empty($tids)) {
+              $query->entityCondition('entity_id', $tids, 'NOT IN');
+            }
+            $result = $query->execute();
+            if (isset($result['taxonomy_term'])) {
+              $tids = array_merge($tids, array_keys($result['taxonomy_term']));
+            }
+          }
+        }
+        $terms = taxonomy_term_load_multiple($tids);
+        // We have an array of terms whose synonyms look like they could be
+        // equal to our argument, let us iterate over each term's synonyms to
+        // actually see if they match.
+        $argument = mb_strtoupper($argument, 'UTF-8');
+        foreach ($terms as $term) {
+          foreach (synonyms_get_term_synonyms($term) as $synonym) {
+            $synonym = mb_strtoupper($synonym['safe_value'], 'UTF-8');
+            if ($transform) {
+              $synonym = str_replace(' ', '-', $synonym);
+            }
+            if ($synonym == $argument) {
+              // Finally we found a synonym that matches our argument. We are
+              // going to use the corresponding term and there is no point to
+              // continue searching.
+              $this->argument->argument = $this->synonyms_get_term_property($term);
+              $this->argument->validated_title = check_plain(entity_label('taxonomy_term', $term));
+              return TRUE;
+            }
+          }
+        }
+        // We haven't found any synonym that matched our argument, so there is
+        // no term to return.
+        return FALSE;
+
+      default:
+        return parent::validate_argument($argument);
+    }
+  }
+
+  /**
+   * Return necessary property (per chosen validator) of encountered term.
+   *
+   * @param $term object
+   *   Fully loaded taxonomy term from which necessary property should be
+   *   returned
+   *
+   * @return mixed
+   *   Necessary property (per chosen validator) of the provided term
+   */
+  function synonyms_get_term_property($term) {
+    switch ($this->options['type']) {
+      case 'synonym':
+        return $term->name;
+
+      case 'synonym_tid':
+        return $term->tid;
+    }
+    return NULL;
+  }
+}

+ 8 - 0
sites/all/modules/contrib/theming/colorbox/colorbox.make

@@ -0,0 +1,8 @@
+core = 7.x
+api = 2
+
+libraries[colorbox][type] = "libraries"
+libraries[colorbox][download][type] = "file"
+libraries[colorbox][download][url] = "https://github.com/jackmoore/colorbox/archive/1.x.zip"
+libraries[colorbox][directory_name] = "colorbox"
+libraries[colorbox][destination] = "libraries"

+ 77 - 0
sites/all/modules/contrib/views/views_bulk_operations/actions/book.action.inc

@@ -0,0 +1,77 @@
+<?php
+
+/**
+ * @file
+ * Implements actions for managing books (book.module).
+ */
+
+function views_bulk_operations_book_action_info() {
+  $actions = array();
+  if (module_exists('book')) {
+    $actions['views_bulk_operations_move_to_book_action'] = array(
+      'type' => 'node',
+      'label' => t('Move to book'),
+      'configurable' => TRUE,
+      'behavior' => array('changes_property'),
+    );
+    $actions['views_bulk_operations_remove_from_book_action'] = array(
+      'type' => 'node',
+      'label' => t('Remove from book'),
+      'configurable' => FALSE,
+    );
+  }
+
+  return $actions;
+}
+
+function views_bulk_operations_move_to_book_action_form($context) {
+  $form = array();
+  if (!isset($context['book'])) {
+    $context['book'] = '';
+  }
+  $options = array();
+  $books = book_get_books();
+  foreach ($books as $value) {
+    $options[$value['nid']] = $value['title'];
+  }
+
+  if (empty($options)) {
+    drupal_set_message(t('You have no books.'), 'error');
+    return array();
+  }
+
+  $form['book'] = array(
+    '#type' => 'select',
+    '#title' => t('Choose a parent book'),
+    '#options' => $options,
+    '#description' => t('Select the parent book page you wish to move the book page into'),
+  );
+  return $form;
+}
+
+function views_bulk_operations_move_to_book_action_submit($form, $form_state) {
+  return array('book' => $form_state['values']['book']);
+}
+
+function views_bulk_operations_move_to_book_action($node, $context = array()) {
+  if (isset($context['book'])) {
+    $book_node = node_load($context['book']);
+    $mlid = db_select('menu_links' , 'ml')
+      ->condition('ml.link_path' , 'node/' . $node->nid)
+      ->fields('ml' , array('mlid'))
+      ->execute()
+      ->fetchField();
+    $node->book['mlid'] = $mlid;
+    $node->book['bid'] = $book_node->nid;
+    $node->book['plid'] = $book_node->book['mlid'];
+    $node->book['module'] = 'book';
+  }
+}
+
+/**
+ * Adds the action 'Remove node from a parent book'
+ */
+function views_bulk_operations_remove_from_book_action($node, $context) {
+  $book = $node->book['mlid'];
+  book_node_delete($node);
+}

+ 81 - 0
sites/all/modules/contrib/views/views_bulk_operations/actions/user_cancel.action.inc

@@ -0,0 +1,81 @@
+<?php
+/**
+  * @file
+  * VBO action to cancel user accounts.
+  */
+
+function views_bulk_operations_user_cancel_action_info() {
+  return array('views_bulk_operations_user_cancel_action' => array(
+    'type' => 'user',
+    'label' => t('Cancel user account'),
+    'configurable' => TRUE,
+    'behavior' => array('deletes_property'),
+  ));
+}
+
+function views_bulk_operations_user_cancel_action_form($context) {
+  module_load_include('inc', 'user', 'user.pages');
+  $form['user_cancel_method'] = array(
+    '#type' => 'item',
+    '#title' => t('When cancelling these accounts'),
+  );
+  $form['user_cancel_method'] += user_cancel_methods();
+  // Remove method descriptions.
+  foreach (element_children($form['user_cancel_method']) as $element) {
+    unset($form['user_cancel_method'][$element]['#description']);
+  }
+  $admin_access = user_access('administer users');
+  $default_notify = variable_get('user_mail_status_canceled_notify', FALSE);
+  $form['user_cancel_notify'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Notify user when account is canceled.'),
+    '#default_value' => ($admin_access ? FALSE : $default_notify),
+    '#access' => $admin_access && $default_notify,
+    '#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
+  );
+
+  return $form;
+}
+
+function views_bulk_operations_user_cancel_action_submit($form, $form_state) {
+  return array(
+    'user_cancel_method' => $form_state['values']['user_cancel_method'],
+    'user_cancel_notify' => $form_state['values']['user_cancel_notify'],
+  );
+}
+
+function views_bulk_operations_user_cancel_action($account, $context) {
+  global $user;
+  // Prevent the user from cancelling itself.
+  if ($account->uid == $user->uid) {
+    return;
+  }
+
+  // Allow other modules to react on the cancellation.
+  if ($context['user_cancel_method'] != 'user_cancel_delete') {
+    module_invoke_all('user_cancel', array(), $account, $context['user_cancel_method']);
+  }
+
+  switch ($context['user_cancel_method']) {
+    case 'user_cancel_block':
+    case 'user_cancel_block_unpublish':
+    default:
+      // Send account blocked notification if option was checked.
+      if (!empty($context['user_cancel_notify'])) {
+        _user_mail_notify('status_blocked', $account);
+      }
+      user_save($account, array('status' => 0));
+      watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
+      break;
+
+    case 'user_cancel_reassign':
+    case 'user_cancel_delete':
+      // Send account canceled notification if option was checked.
+      if (!empty($context['user_cancel_notify'])) {
+        _user_mail_notify('status_canceled', $account);
+      }
+      user_delete($account->uid);
+      watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
+      break;
+  }
+}

+ 1 - 0
sites/all/modules/contrib/views/views_data_export/.gitignore

@@ -0,0 +1 @@
+.DS_Store

+ 508 - 0
sites/all/modules/contrib/views/views_data_export/tests/base.test

@@ -0,0 +1,508 @@
+<?php
+
+abstract class ViewsDataExportBaseTest extends ViewsTestCase {
+
+  protected function setUp() {
+    $modules = func_get_args();
+    if (isset($modules[0]) && is_array($modules[0])) {
+      $modules = $modules[0];
+    }
+
+    $modules[] = 'views_data_export';
+    $modules[] = 'views_ui';
+    $modules[] = 'views';
+    parent::setUp($modules);
+
+    // Define the schema and views data variable before enabling the test module.
+    variable_set('views_test_schema', $this->schemaDefinition());
+    variable_set('views_test_views_data', $this->viewsData());
+    variable_set('views_test_views_plugins', $this->viewsPlugins());
+
+    module_enable(array('views_test'));
+    $this->resetAll();
+
+    // Load the test dataset.
+    $data_set = $this->dataSet();
+    $query = db_insert('views_test')
+      ->fields(array_keys($data_set[0]));
+    foreach ($data_set as $record) {
+      $query->values($record);
+    }
+    $query->execute();
+    $this->checkPermissions(array(), TRUE);
+  }
+
+  /**
+   * This function allows to enable views ui from a higher class which can't change the setup function anymore.
+   *
+   * @TODO
+   *   Convert existing setUp functions.
+   */
+  function enableViewsUi() {
+    module_enable(array('views_ui'));
+    // @TODO Figure out why it's required to clear the cache here.
+    views_module_include('views_default', TRUE);
+    views_get_all_views(TRUE);
+    menu_rebuild();
+  }
+
+  /**
+   * The schema definition.
+   */
+  protected function schemaDefinition() {
+    $schema['views_test'] = array(
+      'description' => 'Basic test table for Views tests.',
+      'fields' => array(
+        'id' => array(
+          'type' => 'serial',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+        ),
+        'name' => array(
+          'description' => "A person's name",
+          'type' => 'varchar',
+          'length' => 255,
+          'not null' => TRUE,
+          'default' => '',
+        ),
+        'age' => array(
+          'description' => "The person's age",
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'default' => 0),
+        'job' => array(
+          'description' => "The person's job",
+          'type' => 'varchar',
+          'length' => 255,
+          'not null' => TRUE,
+          'default' => 'Undefined',
+        ),
+        'created' => array(
+          'description' => "The creation date of this record",
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'default' => 0,
+        ),
+      ),
+      'primary key' => array('id'),
+      'unique keys' => array(
+        'name' => array('name')
+      ),
+      'indexes' => array(
+        'ages' => array('age'),
+      ),
+    );
+    return $schema;
+  }
+
+  /**
+   * The views data definition.
+   */
+  protected function viewsData() {
+    // Declaration of the base table.
+    $data['views_test']['table'] = array(
+      'group' => t('Views test'),
+      'base' => array(
+        'field' => 'id',
+        'title' => t('Views test'),
+        'help' => t('Users who have created accounts on your site.'),
+      ),
+    );
+
+    // Declaration of fields.
+    $data['views_test']['id'] = array(
+      'title' => t('ID'),
+      'help' => t('The test data ID'),
+      'field' => array(
+        'handler' => 'views_handler_field_numeric',
+        'click sortable' => TRUE,
+      ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_numeric',
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_numeric',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    );
+    $data['views_test']['name'] = array(
+      'title' => t('Name'),
+      'help' => t('The name of the person'),
+      'field' => array(
+        'handler' => 'views_handler_field',
+        'click sortable' => TRUE,
+      ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_string',
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_string',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    );
+    $data['views_test']['age'] = array(
+      'title' => t('Age'),
+      'help' => t('The age of the person'),
+      'field' => array(
+        'handler' => 'views_handler_field_numeric',
+        'click sortable' => TRUE,
+      ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_numeric',
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_numeric',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    );
+    $data['views_test']['job'] = array(
+      'title' => t('Job'),
+      'help' => t('The job of the person'),
+      'field' => array(
+        'handler' => 'views_handler_field',
+        'click sortable' => TRUE,
+      ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_string',
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_string',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    );
+    $data['views_test']['created'] = array(
+      'title' => t('Created'),
+      'help' => t('The creation date of this record'),
+      'field' => array(
+        'handler' => 'views_handler_field_date',
+        'click sortable' => TRUE,
+      ),
+      'argument' => array(
+        'handler' => 'views_handler_argument_date',
+      ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_date',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort_date',
+      ),
+    );
+    return $data;
+  }
+
+  protected function viewsPlugins() {
+    return array();
+  }
+
+  /**
+   * A very simple test dataset.
+   */
+  protected function dataSet() {
+    return array(
+      array(
+        'name' => 'John',
+        'age' => 25,
+        'job' => 'Singer',
+        'created' => gmmktime(0, 0, 0, 1, 1, 2000),
+      ),
+      array(
+        'name' => 'George',
+        'age' => 27,
+        'job' => 'Singer',
+        'created' => gmmktime(0, 0, 0, 1, 2, 2000),
+      ),
+      array(
+        'name' => 'Ringo',
+        'age' => 28,
+        'job' => 'Drummer',
+        'created' => gmmktime(6, 30, 30, 1, 1, 2000),
+      ),
+      array(
+        'name' => 'Paul',
+        'age' => 26,
+        'job' => 'Songwriter',
+        'created' => gmmktime(6, 0, 0, 1, 1, 2000),
+      ),
+      array(
+        'name' => 'Meredith',
+        'age' => 30,
+        'job' => 'Speaker',
+        'created' => gmmktime(6, 30, 10, 1, 1, 2000),
+      ),
+    );
+  }
+
+  /**
+   * Build and return a basic view of the views_test table.
+   *
+   * @return view
+   */
+  protected function getBasicView() {
+    views_include('view');
+
+    // Create the basic view.
+    $view = new view();
+    $view->vid = 'test_view';
+    $view->add_display('default');
+    $view->base_table = 'views_test';
+
+    // Set up the fields we need.
+    $display = $view->new_display('default', 'Master', 'default');
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    // Set up the sort order.
+    $display->override_option('sorts', array(
+      'id' => array(
+        'order' => 'ASC',
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+    ));
+
+    // Set up the pager.
+    $display->override_option('pager', array(
+      'type' => 'none',
+      'options' => array('offset' => 0),
+    ));
+
+    return $view;
+  }
+
+  public function logViewResult($result, $prefix = 'View result:<br>') {
+    $this->verbose($prefix . '<br><pre>' . check_plain($result) .'</pre>');
+  }
+
+  public function assertBatchedExportEqual($path, $expected, $message) {
+    $this->drupalGet($path);
+    $output = $this->drupalGetContent();
+    $this->logViewResult($output);
+    $this->logViewResult($expected, 'Expected result:<br>');
+    $this->assertEqual($this->normaliseString($output), $this->normaliseString($expected), $message);
+  }
+
+  public function assertExportEqual($a, $b, $message) {
+    $this->logViewResult($a);
+    $this->logViewResult($b, 'Expected result:<br>');
+    $this->assertEqual($this->normaliseString($a), $this->normaliseString($b), $message);
+  }
+
+  protected function normaliseString($s) {
+    // Normalize line endings
+    // Convert all line-endings to UNIX format
+    $s = str_replace("\r\n", "\n", $s);
+    $s = str_replace("\r", "\n", $s);
+    $s = trim($s);
+    return $s;
+  }
+
+}
+
+abstract class ViewsDataExportSimpleExportTest extends ViewsDataExportBaseTest {
+
+  protected $vde_export_type;
+
+  /**
+   * Tests the non-batched export functionality for this style.
+   */
+  public function testNonBatchedExport() {
+    $path = 'vde_test/' . $this->randomName();
+    list($view, $expected) = $this->getExportView($path);
+    // Save this view so we can hit the path.
+    $view->save();
+    // Ensure that the menu router system is rebuilt on the next page load.
+    variable_set('menu_rebuild_needed', TRUE);
+
+    $this->drupalGet($path);
+    $result = $this->drupalGetContent();
+
+    $this->assertExportEqual($result, $expected, 'Non batched ' . $this->vde_export_type . ' export matched expected output.');
+  }
+
+  /**
+   * Tests the batched export functionality for this style.
+   */
+  public function testBatchedExport() {
+    $path = 'vde_test/' . $this->randomName();
+    list($view, $expected) = $this->getExportView($path);
+    $display = &$view->display['vde_test']->handler;
+    // Set this view to be batched.
+    $display->override_option('use_batch', 'batch');
+    // Save this view so we can hit the path.
+    $view->save();
+    // Ensure that the menu router system is rebuilt on the next page load.
+    variable_set('menu_rebuild_needed', TRUE);
+
+    $this->assertBatchedExportEqual($path, $expected, 'Batched ' . $this->vde_export_type . ' export matched expected output.');
+  }
+
+  /**
+   * Get a very basic view and expected output for this style.
+   *
+   * @return
+   *   An array containing two elements:
+   *   - A View object, for the export.
+   *   - The expected out from that view, if is was executed without further
+   *     changes.
+   */
+  abstract protected function getExportView($path = 'vde_test');
+
+  /**
+   * Build and return a basic view of the views_test table.
+   *
+   * @return view
+   */
+  protected function getBasicExportView() {
+    views_include('view');
+
+    // Create the basic view.
+    $view = new view();
+    $view->vid = 'new';
+    $view->base_table = 'views_test';
+
+    // Set up the fields we need.
+    $display = $view->new_display('default', 'Master', 'default');
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    // Set up the sort order.
+    $display->override_option('sorts', array(
+      'id' => array(
+        'order' => 'ASC',
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+    ));
+
+    // Set up the pager.
+    $display->override_option('pager', array(
+      'type' => 'none',
+      'options' => array('offset' => 0),
+    ));
+
+    return $view;
+  }
+
+  /**
+   * Get a view that's our basic view, but with hide if empty/0 support.
+   *
+   * We add this to the 'age' field.
+   */
+  protected function getHideIfEmptyExportView() {
+    $view = $this->getBasicExportView();
+
+    $display = $view->display['default']->handler;
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+        // Hide their name if its empty.
+        'hide_empty' => TRUE,
+        // But we don't hide it if it's: 0.
+        'empty_zero' => FALSE,
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+        // Hide their age if it's empty.
+        'hide_empty' => TRUE,
+        'empty_zero' => TRUE,
+      ),
+    ));
+
+    return $view;
+  }
+
+  /**
+   * Execute a given view very simply.
+   *
+   * This will take a view, and add a display plugin of the correct export type,
+   * and then run it and compare it with the expected output.
+   */
+  protected function executeAndCompareGivenView(view $view, $expected, $message = '', $style_options = array()) {
+    $path = 'vde_test/' . $this->randomName();
+
+    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
+    $display->override_option('style_plugin', $this->getStylePluginName());
+    $display->override_option('style_options', $style_options);
+    $display->override_option('path', $path);
+
+    // Save this view so we can hit the path.
+    $view->save();
+
+    // Ensure that the menu router system is rebuilt on the next page load.
+    variable_set('menu_rebuild_needed', TRUE);
+
+    $this->drupalGet($path);
+    $result = $this->drupalGetContent();
+
+    $this->assertExportEqual($result, $expected, $message);
+  }
+
+  /**
+   * Return the name of the style plugin represented by this test.
+   */
+  abstract protected function getStylePluginName();
+}

+ 211 - 0
sites/all/modules/contrib/views/views_data_export/tests/csv_export.test

@@ -0,0 +1,211 @@
+<?php
+
+class CSVExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
+
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'CSV Export',
+      'description' => 'Various tests for exporting to CSV.',
+      'group' => 'Views Data Export',
+    );
+  }
+
+  protected $vde_export_type = 'CSV';
+
+  protected function getStylePluginName() {
+    return 'views_data_export_csv';
+  }
+
+  protected function getExportView($path = 'vde_test') {
+    // Create the basic view.
+    $view = $this->getBasicExportView();
+
+    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
+    $display->override_option('style_plugin', $this->getStylePluginName());
+    $display->override_option('path', $path);
+
+    $expected = '"ID","Name","Age"
+"1","John","25"
+"2","George","27"
+"3","Ringo","28"
+"4","Paul","26"
+"5","Meredith","30"';
+
+    return array(&$view, $expected);
+  }
+
+  /**
+   * Test to ensure that HTML tags are kept in CSV files when requested.
+   */
+  protected function testKeepHTML() {
+    $view = $this->getBasicExportView();
+
+    $display = $view->display['default']->handler;
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+        // Add a label to include HTML
+        'label' => '<strong id="id">ID</strong>',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+        // Alter this field to include HTML.
+        'alter' => array(
+          'alter_text' => TRUE,
+          'text' => '<em>[name]</em>',
+        ),
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    $style_options = array(
+      'keep_html' => TRUE,
+    );
+
+    $expected = '"<strong id=""id"">ID</strong>","Name","Age"
+"1","<em>John</em>","25"
+"2","<em>George</em>","27"
+"3","<em>Ringo</em>","28"
+"4","<em>Paul</em>","26"
+"5","<em>Meredith</em>","30"';
+
+    $message = 'Keep HTML test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+
+
+    // And now make sure that HTML tags are stripped correctly.
+    $style_options = array(
+      'keep_html' => FALSE,
+    );
+
+    $expected = '"ID","Name","Age"
+"1","John","25"
+"2","George","27"
+"3","Ringo","28"
+"4","Paul","26"
+"5","Meredith","30"';
+
+    $message = 'Keep HTML reverse test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+  }
+
+  /**
+   * Test to ensure that HTML tags are kept in CSV files when requested.
+   */
+  protected function testTrimFields() {
+    $view = $this->getBasicExportView();
+
+    $display = $view->display['default']->handler;
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+        'label' => 'ID',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+        // Alter this field to include HTML.
+        'alter' => array(
+          'alter_text' => TRUE,
+          'text' => ' [name]  ',
+        ),
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    $style_options = array(
+      'trim' => FALSE,
+    );
+
+    $expected = '"ID","Name","Age"
+"1"," John  ","25"
+"2"," George  ","27"
+"3"," Ringo  ","28"
+"4"," Paul  ","26"
+"5"," Meredith  ","30"';
+
+    $message = 'Trim reverse test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+
+    // And now make sure that trimming works as expected.
+    $style_options = array(
+      'trim' => TRUE,
+    );
+
+    $expected = '"ID","Name","Age"
+"1","John","25"
+"2","George","27"
+"3","Ringo","28"
+"4","Paul","26"
+"5","Meredith","30"';
+
+    $message = 'Trim test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+  }
+
+  /**
+   * Test to ensure that Encoding options work.
+   */
+  protected function testIconvEncoding() {
+    $view = $this->getBasicExportView();
+
+    db_update('views_test')
+      ->fields(array('name' => 'Jo€hn'))
+      ->condition('name', 'John')
+      ->execute();
+
+    $encodings = array(
+      'ISO-8859-1//TRANSLIT' => 'EUR',
+      'utf8_decode' => '?',
+    );
+
+    foreach ($encodings as $encoding => $conversion) {
+
+      $style_options = array(
+        'encoding' => $encoding,
+      );
+
+      $expected = '"ID","Name","Age"
+"1","Jo' . $conversion . 'hn","25"
+"2","George","27"
+"3","Ringo","28"
+"4","Paul","26"
+"5","Meredith","30"';
+
+      $message = 'Character encoding ' . $encoding . ' worked correctly.';
+
+      $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+    }
+
+  }
+
+}

+ 48 - 0
sites/all/modules/contrib/views/views_data_export/tests/doc_export.test

@@ -0,0 +1,48 @@
+<?php
+
+class DOCExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
+
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'DOC Export',
+      'description' => 'Various tests for exporting to DOC.',
+      'group' => 'Views Data Export',
+    );
+  }
+
+  protected $vde_export_type = 'DOC';
+
+  protected function getStylePluginName() {
+    return 'views_data_export_doc';
+  }
+
+  protected function getExportView($path = 'vde_test') {
+    // Create the basic view.
+    $view = $this->getBasicExportView();
+
+    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
+    $display->override_option('style_plugin', $this->getStylePluginName());
+    $display->override_option('path', $path);
+
+    $expected = '<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  </head>
+  <body>
+    <table>
+    <thead><tr><th>ID</th><th>Name</th><th>Age</th></tr></thead>    <tbody> <tr class="odd"><td>1</td><td>John</td><td>25</td> </tr>
+ <tr class="even"><td>2</td><td>George</td><td>27</td> </tr>
+ <tr class="odd"><td>3</td><td>Ringo</td><td>28</td> </tr>
+ <tr class="even"><td>4</td><td>Paul</td><td>26</td> </tr>
+ <tr class="odd"><td>5</td><td>Meredith</td><td>30</td> </tr>
+      </tbody>
+    </table>
+  </body>
+</html>';
+
+    return array(&$view, $expected);
+  }
+
+}

+ 164 - 0
sites/all/modules/contrib/views/views_data_export/tests/txt_export.test

@@ -0,0 +1,164 @@
+<?php
+
+class TXTExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
+
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'TXT Export',
+      'description' => 'Various tests for exporting to TXT.',
+      'group' => 'Views Data Export',
+    );
+  }
+
+  protected $vde_export_type = 'TXT';
+
+  protected function getStylePluginName() {
+    return 'views_data_export_txt';
+  }
+
+  protected function getExportView($path = 'vde_test') {
+    // Create the basic view.
+    $view = $this->getBasicExportView();
+
+    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
+    $display->override_option('style_plugin', $this->getStylePluginName());
+    $display->override_option('path', $path);
+
+    $expected = '[ID]
+
+1
+[Name]
+
+John
+[Age]
+
+25
+----------------------------------------
+
+[ID]
+
+2
+[Name]
+
+George
+[Age]
+
+27
+----------------------------------------
+
+[ID]
+
+3
+[Name]
+
+Ringo
+[Age]
+
+28
+----------------------------------------
+
+[ID]
+
+4
+[Name]
+
+Paul
+[Age]
+
+26
+----------------------------------------
+
+[ID]
+
+5
+[Name]
+
+Meredith
+[Age]
+
+30
+----------------------------------------';
+
+    return array(&$view, $expected);
+  }
+
+  /**
+   * Test to check if empty fields are correctly hidden.
+   */
+  protected function testHideEmptySupport() {
+    $view = $this->getHideIfEmptyExportView();
+
+    // We need to ensure that the test fields are actually empty/0.
+    db_update('views_test')
+      ->fields(array('age' => 0,))
+      ->condition('name', 'Paul')
+      ->execute();
+
+    db_update('views_test')
+      ->fields(array('name' => '',))
+      ->condition('name', 'George')
+      ->execute();
+
+    db_update('views_test')
+      ->fields(array('name' => 0,))
+      ->condition('name', 'John')
+      ->execute();
+
+    $expected = '[ID]
+
+1
+[Name]
+
+0
+[Age]
+
+25
+----------------------------------------
+
+[ID]
+
+2
+[Age]
+
+27
+----------------------------------------
+
+[ID]
+
+3
+[Name]
+
+Ringo
+[Age]
+
+28
+----------------------------------------
+
+[ID]
+
+4
+[Name]
+
+Paul
+----------------------------------------
+
+[ID]
+
+5
+[Name]
+
+Meredith
+[Age]
+
+30
+----------------------------------------';
+
+    $message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message);
+
+  }
+
+}

+ 48 - 0
sites/all/modules/contrib/views/views_data_export/tests/xls_export.test

@@ -0,0 +1,48 @@
+<?php
+
+class XLSExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
+
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'XLS Export',
+      'description' => 'Various tests for exporting to XLS.',
+      'group' => 'Views Data Export',
+    );
+  }
+
+  protected $vde_export_type = 'XLS';
+
+  protected function getStylePluginName() {
+    return 'views_data_export_xls';
+  }
+
+  protected function getExportView($path = 'vde_test') {
+    // Create the basic view.
+    $view = $this->getBasicExportView();
+
+    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
+    $display->override_option('style_plugin', $this->getStylePluginName());
+    $display->override_option('path', $path);
+
+    $expected = '<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  </head>
+  <body>
+    <table>
+    <thead><tr><th>ID</th><th>Name</th><th>Age</th></tr></thead>    <tbody> <tr class="odd"><td>1</td><td>John</td><td>25</td> </tr>
+ <tr class="even"><td>2</td><td>George</td><td>27</td> </tr>
+ <tr class="odd"><td>3</td><td>Ringo</td><td>28</td> </tr>
+ <tr class="even"><td>4</td><td>Paul</td><td>26</td> </tr>
+ <tr class="odd"><td>5</td><td>Meredith</td><td>30</td> </tr>
+      </tbody>
+    </table>
+  </body>
+</html>';
+
+    return array(&$view, $expected);
+  }
+
+}

+ 386 - 0
sites/all/modules/contrib/views/views_data_export/tests/xml_export.test

@@ -0,0 +1,386 @@
+<?php
+
+class XMLExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
+
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'XML Export',
+      'description' => 'Various tests for exporting to XML.',
+      'group' => 'Views Data Export',
+    );
+  }
+
+  protected $vde_export_type = 'XML';
+
+  protected function getStylePluginName() {
+    return 'views_data_export_xml';
+  }
+
+  protected function getExportView($path = 'vde_test') {
+    // Create the basic view.
+    $view = $this->getBasicExportView();
+
+    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
+    $display->override_option('style_plugin', 'views_data_export_xml');
+    $display->override_option('path', $path);
+
+    $expected = '<?xml version="1.0" encoding="UTF-8" ?>
+<views_tests>
+  <views_test>
+    <ID>1</ID>
+    <Name>John</Name>
+    <Age>25</Age>
+  </views_test>
+  <views_test>
+    <ID>2</ID>
+    <Name>George</Name>
+    <Age>27</Age>
+  </views_test>
+  <views_test>
+    <ID>3</ID>
+    <Name>Ringo</Name>
+    <Age>28</Age>
+  </views_test>
+  <views_test>
+    <ID>4</ID>
+    <Name>Paul</Name>
+    <Age>26</Age>
+  </views_test>
+  <views_test>
+    <ID>5</ID>
+    <Name>Meredith</Name>
+    <Age>30</Age>
+  </views_test>
+</views_tests>';
+
+    return array(&$view, $expected);
+  }
+
+  /**
+   * Test to check if empty fields are correctly hidden.
+   */
+  protected function testHideEmptySupport() {
+    $view = $this->getHideIfEmptyExportView();
+
+    // We need to ensure that the test fields are actually empty/0.
+    db_update('views_test')
+      ->fields(array('age' => 0,))
+      ->condition('name', 'Paul')
+      ->execute();
+
+    db_update('views_test')
+      ->fields(array('name' => '',))
+      ->condition('name', 'George')
+      ->execute();
+
+    db_update('views_test')
+      ->fields(array('name' => 0,))
+      ->condition('name', 'John')
+      ->execute();
+
+    $expected = '<?xml version="1.0" encoding="UTF-8" ?>
+<views_tests>
+  <views_test>
+    <ID>1</ID>
+    <Name>0</Name>
+    <Age>25</Age>
+  </views_test>
+  <views_test>
+    <ID>2</ID>
+    <Age>27</Age>
+  </views_test>
+  <views_test>
+    <ID>3</ID>
+    <Name>Ringo</Name>
+    <Age>28</Age>
+  </views_test>
+  <views_test>
+    <ID>4</ID>
+    <Name>Paul</Name>
+  </views_test>
+  <views_test>
+    <ID>5</ID>
+    <Name>Meredith</Name>
+    <Age>30</Age>
+  </views_test>
+</views_tests>';
+
+    $message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message);
+
+  }
+
+  /**
+   * Test to ensure that valid XML is produced when someone doesn't specify a label.
+   */
+  protected function testEmptyLabels() {
+    $view = $this->getBasicExportView();
+
+    $display = $view->display['default']->handler;
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+        // Remove the label from the name field.
+        'label' => '',
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+        // Make this label intentially invalid XML.
+        'label' => '.',
+      ),
+    ));
+
+    $expected = '<?xml version="1.0" encoding="UTF-8" ?>
+<views_tests>
+  <views_test>
+    <ID>1</ID>
+    <no-name>John</no-name>
+    <invalid-tag-name>25</invalid-tag-name>
+  </views_test>
+  <views_test>
+    <ID>2</ID>
+    <no-name>George</no-name>
+    <invalid-tag-name>27</invalid-tag-name>
+  </views_test>
+  <views_test>
+    <ID>3</ID>
+    <no-name>Ringo</no-name>
+    <invalid-tag-name>28</invalid-tag-name>
+  </views_test>
+  <views_test>
+    <ID>4</ID>
+    <no-name>Paul</no-name>
+    <invalid-tag-name>26</invalid-tag-name>
+  </views_test>
+  <views_test>
+    <ID>5</ID>
+    <no-name>Meredith</no-name>
+    <invalid-tag-name>30</invalid-tag-name>
+  </views_test>
+</views_tests>';
+
+    $message = 'Empty label test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message);
+  }
+
+  /**
+   * Test to ensure that XML nodes names can be manually specified.
+   */
+  protected function testCustomiseXMLNodes() {
+    $view = $this->getBasicExportView();
+
+    // Load the include that contains the _views_data_export_xml_tag_clean function.
+    module_load_include('inc', 'views_data_export', 'theme/views_data_export.theme');
+
+
+    $root_node = _views_data_export_xml_tag_clean($this->randomName());
+    $item_node = _views_data_export_xml_tag_clean($this->randomName());
+
+    $style_options = array(
+      'root_node' => $root_node,
+      'item_node' => $item_node,
+    );
+
+    $expected = '<?xml version="1.0" encoding="UTF-8" ?>
+<' . $root_node . '>
+  <' . $item_node . '>
+    <ID>1</ID>
+    <Name>John</Name>
+    <Age>25</Age>
+  </' . $item_node . '>
+  <' . $item_node . '>
+    <ID>2</ID>
+    <Name>George</Name>
+    <Age>27</Age>
+  </' . $item_node . '>
+  <' . $item_node . '>
+    <ID>3</ID>
+    <Name>Ringo</Name>
+    <Age>28</Age>
+  </' . $item_node . '>
+  <' . $item_node . '>
+    <ID>4</ID>
+    <Name>Paul</Name>
+    <Age>26</Age>
+  </' . $item_node . '>
+  <' . $item_node . '>
+    <ID>5</ID>
+    <Name>Meredith</Name>
+    <Age>30</Age>
+  </' . $item_node . '>
+</' . $root_node . '>';
+
+    $message = 'Custom XML nodes test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+  }
+
+  /**
+   * Test to ensure certain fields can be optionally non-escaped.
+   */
+  protected function testXMLNoEntityEncode() {
+    $view = $this->getBasicExportView();
+
+    $display = $view->display['default']->handler;
+
+    $style_options = array(
+      'no_entity_encode' => array(
+        'id' => 'id',
+      ),
+    );
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+        'alter' => array(
+          'alter_text' => TRUE,
+          'text' => '<strong>[id]</strong>',
+        ),
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+        'alter' => array(
+          'alter_text' => TRUE,
+          'text' => '<em>[name]</em>',
+        ),
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    $expected = '<?xml version="1.0" encoding="UTF-8" ?>
+<views_tests>
+  <views_test>
+    <ID><strong>1</strong></ID>
+    <Name>&lt;em&gt;John&lt;/em&gt;</Name>
+    <Age>25</Age>
+  </views_test>
+  <views_test>
+    <ID><strong>2</strong></ID>
+    <Name>&lt;em&gt;George&lt;/em&gt;</Name>
+    <Age>27</Age>
+  </views_test>
+  <views_test>
+    <ID><strong>3</strong></ID>
+    <Name>&lt;em&gt;Ringo&lt;/em&gt;</Name>
+    <Age>28</Age>
+  </views_test>
+  <views_test>
+    <ID><strong>4</strong></ID>
+    <Name>&lt;em&gt;Paul&lt;/em&gt;</Name>
+    <Age>26</Age>
+  </views_test>
+  <views_test>
+    <ID><strong>5</strong></ID>
+    <Name>&lt;em&gt;Meredith&lt;/em&gt;</Name>
+    <Age>30</Age>
+  </views_test>
+</views_tests>';
+
+    $message = 'XML in values test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+  }
+
+  /**
+   * Test to ensure certain fields can be optionally non-escaped.
+   */
+  protected function testXMLCDATAWrapper() {
+    $view = $this->getBasicExportView();
+
+    $style_options = array(
+      'cdata_wrapper' => array(
+        'id' => 'id',
+        'name' => 'name',
+      ),
+    );
+
+    $display = $view->display['default']->handler;
+
+    $display->override_option('fields', array(
+      'id' => array(
+        'id' => 'id',
+        'table' => 'views_test',
+        'field' => 'id',
+        'relationship' => 'none',
+      ),
+      'name' => array(
+        'id' => 'name',
+        'table' => 'views_test',
+        'field' => 'name',
+        'relationship' => 'none',
+        'alter' => array(
+          'alter_text' => TRUE,
+          'text' => '<em>[name]</em>',
+        ),
+      ),
+      'age' => array(
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    $expected = '<?xml version="1.0" encoding="UTF-8" ?>
+<views_tests>
+  <views_test>
+    <ID><![CDATA[1]]></ID>
+    <Name><![CDATA[<em>John</em>]]></Name>
+    <Age>25</Age>
+  </views_test>
+  <views_test>
+    <ID><![CDATA[2]]></ID>
+    <Name><![CDATA[<em>George</em>]]></Name>
+    <Age>27</Age>
+  </views_test>
+  <views_test>
+    <ID><![CDATA[3]]></ID>
+    <Name><![CDATA[<em>Ringo</em>]]></Name>
+    <Age>28</Age>
+  </views_test>
+  <views_test>
+    <ID><![CDATA[4]]></ID>
+    <Name><![CDATA[<em>Paul</em>]]></Name>
+    <Age>26</Age>
+  </views_test>
+  <views_test>
+    <ID><![CDATA[5]]></ID>
+    <Name><![CDATA[<em>Meredith</em>]]></Name>
+    <Age>30</Age>
+  </views_test>
+</views_tests>';
+
+    $message = 'XML in values test in ' . $this->vde_export_type . ' export matched expected output.';
+
+    $this->executeAndCompareGivenView($view, $expected, $message, $style_options);
+  }
+
+}

Some files were not shown because too many files changed in this diff