diff --git a/sites/all/modules/contrib/admin/admin/admin.info b/sites/all/modules/contrib/admin/admin/admin.info index 33c5b7eb..9ec8015b 100644 --- a/sites/all/modules/contrib/admin/admin/admin.info +++ b/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" diff --git a/sites/all/modules/contrib/admin/admin_menu/README.txt b/sites/all/modules/contrib/admin/admin_menu/README.txt index f66a61e3..136db709 100644 --- a/sites/all/modules/contrib/admin/admin_menu/README.txt +++ b/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. diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info b/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info index 6408a1bb..ab3d641f 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info +++ b/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" diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css index f2491cd5..ea3ef491 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css +++ b/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, diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu.css index fd86dd79..52ae3ff5 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.css +++ b/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 { diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc b/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc index e212970c..2eab789b 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc +++ b/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. * diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.info b/sites/all/modules/contrib/admin/admin_menu/admin_menu.info index ee58c66c..c6dbd892 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.info +++ b/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" diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.install b/sites/all/modules/contrib/admin/admin_menu/admin_menu.install index 70e31c6c..4e5443d3 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.install +++ b/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'); } /** diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.js b/sites/all/modules/contrib/admin/admin_menu/admin_menu.js index de0bb906..2e28b554 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.js +++ b/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 () { diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc b/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc index 72a89602..f86e80cd 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc +++ b/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; + } - 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; + foreach ($entity_info['bundles'] as $bundle => $bundle_info) { + // @see field_ui_menu() + if (!isset($bundle_info['admin'])) { + continue; + } - case 'user': - $arguments = array( - '%field_ui_menu' => array_keys(field_info_fields('user')), - ); - 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; + } + + 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; } - diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.module b/sites/all/modules/contrib/admin/admin_menu/admin_menu.module index 8a8dee14..795ad211 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.module +++ b/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'), diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info index 2514776c..fa4ca095 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info +++ b/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" diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module index 74a9ee1f..c6111bdc 100644 --- a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module +++ b/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')), ), ); diff --git a/sites/all/modules/contrib/admin/rules/fix_errors_on_update-2090511-214_2.patch b/sites/all/modules/contrib/admin/rules/fix_errors_on_update-2090511-214_2.patch new file mode 100644 index 00000000..c1fe32ba --- /dev/null +++ b/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(). + */ diff --git a/sites/all/modules/contrib/admin/rules/includes/rules.event.inc b/sites/all/modules/contrib/admin/rules/includes/rules.event.inc new file mode 100644 index 00000000..27f6a336 --- /dev/null +++ b/sites/all/modules/contrib/admin/rules/includes/rules.event.inc @@ -0,0 +1,411 @@ +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; + } +} diff --git a/sites/all/modules/contrib/admin/rules/rules.drush.inc b/sites/all/modules/contrib/admin/rules/rules.drush.inc new file mode 100644 index 00000000..dc30de4c --- /dev/null +++ b/sites/all/modules/contrib/admin/rules/rules.drush.inc @@ -0,0 +1,134 @@ + "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'); + } +} diff --git a/sites/all/modules/contrib/admin/rules/rules_scheduler/includes/rules_scheduler.handler.inc b/sites/all/modules/contrib/admin/rules/rules_scheduler/includes/rules_scheduler.handler.inc new file mode 100644 index 00000000..07e36521 --- /dev/null +++ b/sites/all/modules/contrib/admin/rules/rules_scheduler/includes/rules_scheduler.handler.inc @@ -0,0 +1,99 @@ +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(); + +} diff --git a/sites/all/modules/contrib/admin/rules/rules_scheduler/rules_scheduler.drush.inc b/sites/all/modules/contrib/admin/rules/rules_scheduler/rules_scheduler.drush.inc new file mode 100644 index 00000000..24405b2a --- /dev/null +++ b/sites/all/modules/contrib/admin/rules/rules_scheduler/rules_scheduler.drush.inc @@ -0,0 +1,81 @@ + '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'); + } + } +} diff --git a/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.inc b/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.inc new file mode 100644 index 00000000..39b378e4 --- /dev/null +++ b/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.inc @@ -0,0 +1,24 @@ +getTask(); + $data = unserialize($task['data']); + + // Set the variable defined in the test to TRUE. + variable_set($data['variable'], TRUE); + } + +} diff --git a/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.info b/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.info new file mode 100644 index 00000000..3ce5f836 --- /dev/null +++ b/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" + diff --git a/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.module b/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.module new file mode 100644 index 00000000..11e48755 --- /dev/null +++ b/sites/all/modules/contrib/admin/rules/rules_scheduler/tests/rules_scheduler_test.module @@ -0,0 +1,6 @@ + t('A test token with colons in the name'), + 'description' => NULL, + ); + + return $info; +} diff --git a/sites/all/modules/contrib/admin/uuid/uuid_services/uuid_services.admin.inc b/sites/all/modules/contrib/admin/uuid/uuid_services/uuid_services.admin.inc new file mode 100644 index 00000000..b57d296e --- /dev/null +++ b/sites/all/modules/contrib/admin/uuid/uuid_services/uuid_services.admin.inc @@ -0,0 +1,14 @@ + '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); +} diff --git a/sites/all/modules/contrib/dev/prod_check/js/prod-check-database.js b/sites/all/modules/contrib/dev/prod_check/js/prod-check-database.js new file mode 100644 index 00000000..8fc6395b --- /dev/null +++ b/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); + diff --git a/sites/all/modules/contrib/ecommerce/uc_restrict_qty/README.txt b/sites/all/modules/contrib/ecommerce/uc_restrict_qty/README.txt new file mode 100644 index 00000000..144fcd02 --- /dev/null +++ b/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. diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield-rtl.css b/sites/all/modules/contrib/fields/addressfield/addressfield-rtl.css index e0e1832c..d979946d 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield-rtl.css +++ b/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; } diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc new file mode 100644 index 00000000..5ab59954 --- /dev/null +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc @@ -0,0 +1,442 @@ + 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; +} diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc new file mode 100644 index 00000000..88343de9 --- /dev/null +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc @@ -0,0 +1,1037 @@ + 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; +} diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.api.php b/sites/all/modules/contrib/fields/addressfield/addressfield.api.php index 0d0d964b..b52b9503 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.api.php +++ b/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. diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc index 36810703..d3b0a1e9 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc +++ b/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), ); } } diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.info b/sites/all/modules/contrib/fields/addressfield/addressfield.info index 6559d83c..26d4d238 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.info +++ b/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" diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.install b/sites/all/modules/contrib/fields/addressfield/addressfield.install index ada59129..5e74bc14 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.install +++ b/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); + } + } + } +} diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc new file mode 100644 index 00000000..6e74d63f --- /dev/null +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc @@ -0,0 +1,172 @@ + 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('The administrative area of ' . + 'this address (i.e. State/Province)', + array('@doc' => 'http://drupal.org/node/1996546#administrative_area')), + 'sub_administrative_area' => t('The sub administrative ' . + 'area of this address', + array('@doc' => 'http://drupal.org/node/1996546#sub_administrative_area')), + 'locality' => t('The locality of this address (i.e. ' . + 'City)', + array('@doc' => 'http://drupal.org/node/1996546#locality')), + 'dependent_locality' => t('The dependent locality of ' . + 'this address', + array('@doc' => 'http://drupal.org/node/1996546#dependent_locality')), + 'postal_code' => t('The postal code of this address', + array('@doc' => 'http://drupal.org/node/1996546#postal_code')), + 'thoroughfare' => t('The thoroughfare of this address ' . + '(i.e. Street address)', + array('@doc' => 'http://drupal.org/node/1996546#thoroughfare')), + 'premise' => t('The premise of this address (i.e. Apartment / Suite number)', + array('@doc' => 'http://drupal.org/node/1996546#premise')), + 'sub_premise' => t('The sub_premise of this address', + array('@doc' => 'http://drupal.org/node/1996546#sub_premise')), + 'organisation_name' => t('Contents of a primary ' . + 'OrganisationName element in the xNL XML', + array('@doc' => 'http://drupal.org/node/1996546#organisation_name')), + 'name_line' => t('Contents of a primary NameLine element ' . + 'in the xNL XML', + array('@doc' => 'http://drupal.org/node/1996546#name_line')), + 'first_name' => t('Contents of the FirstName element of ' . + 'a primary PersonName element in the xNL XML', + array('@doc' => 'http://drupal.org/node/1996546#first_name')), + 'last_name' => t('Contents of the LastName element of a ' . + 'primary PersonName element in the xNL XML', + array('@doc' => 'http://drupal.org/node/1996546#last_name')), + 'data' => t('Additional data for this address', + 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; + } +} diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.module b/sites/all/modules/contrib/fields/addressfield/addressfield.module index 1f2ff879..81082c2e 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.module +++ b/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. + * + * @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($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])) { +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' => '
@display_output
variable, which will be printed when the field is displayed. The raw computed value of the field is in @value
. Note: this code has no effect if you use the "Raw computed value" display formatter. Alternately, this code can be supplied by your own custom function named: @display_func($field, $entity_field_item, $entity_lang, $langcode)
. Return the value to be displayed. Original value is in $entity_field_item[\'value\'].',
+ '#description' => t('This code should assign a string to the @display_output
variable, which will be printed when the field is displayed. The raw computed value of the field is in @value
. Note: this code has no effect if you use the "Raw computed value" display formatter.
Alternately, this code can be supplied by your own custom function named: @display_func($field, $entity_field_item, $entity_lang, $langcode, $entity)
. Return the value to be displayed. Original value is in $entity_field_item[\'value\'].',
array('@display_output' => '$display_output',
'@value' => '$entity_field_item[\'value\']',
'@display_func' => $display_func)),
@@ -110,7 +110,7 @@ function computed_field_field_settings_form($field, $instance, $has_data) {
'#disabled' => $has_data,
);
$form['database'] = array('#type' => 'fieldset', '#title' => t('Database Storage Settings'));
-
+
if ($has_data) {
$form['database']['warning'] = array(
'#type' => 'item',
@@ -320,13 +320,13 @@ function computed_field_field_formatter_view($entity_type, $entity, $field, $ins
$display_func = 'computed_field_' . $field['field_name'] . '_display';
if (function_exists($display_func)) $display_in_code = TRUE;
else $display_in_code = FALSE;
-
+
// Loop the items to display
foreach ($items as $delta => $item) {
-
+
// For "some" backwards compatibility
$entity_field_item = $item;
-
+
// Setup a variable with the entity language if available
if (isset($entity->language)) $entity_lang = $entity->language;
else $entity_lang = LANGUAGE_NONE;
@@ -338,12 +338,12 @@ function computed_field_field_formatter_view($entity_type, $entity, $field, $ins
// Execute the display code
$display_output = NULL;
if ($display_in_code) {
- $display_output = $display_func($field, $entity_field_item, $entity_lang, $langcode);
+ $display_output = $display_func($field, $entity_field_item, $entity_lang, $langcode, $entity);
}
else {
eval($field['settings']['display_format']);
}
-
+
// Output the formatted display item
switch ($display['type']) {
case 'computed_field_unsanitized':
@@ -371,78 +371,6 @@ function computed_field_field_is_empty($item, $field) {
return empty($item['value']);
}
-/**
- * Implements hook_token_info().
- */
-function computed_field_token_info() {
- $types['computed'] = array(
- 'name' => t("Computed"),
- 'description' => t("Tokens related to Computed fields."),
- 'needs-data' => 'node',
- );
- $fields = field_info_fields();
- $node = array();
- $computed = array();
- foreach ($fields as $field_name => $field) {
- if ($field['module'] == "computed_field") {
- $node[str_replace('_', '-', $field_name)] = array(
- 'name' => t("Computed: %field_name", array('%field_name' => $field_name)),
- 'description' => t("Computed field %field_name value.", array('%field_name' => $field_name)),
- 'type' => 'computed',
- );
- $computed['rawvalue'] = array(
- 'name' => t("Raw computed value"),
- 'description' => t("Computed field %field_name raw value.", array('%field_name' => $field_name)),
- );
- }
- }
- if (!empty($computed)) {
- return array(
- 'types' => $types,
- 'tokens' => array('node' => $node, 'computed' => $computed),
- );
- }
-}
-
-/**
- * Implements hook_tokens().
- */
-function computed_field_tokens($type, $tokens, array $data = array(), array $options = array()) {
- $computed_fields = array();
- $replacements = array();
- $sanitize = !empty($options['sanitize']);
- $lang = isset($options['language']->language) ? $options['language']->language : LANGUAGE_NONE;
- $fields = field_info_fields();
- foreach ($fields as $field_name => $field) {
- if ($field['module'] == "computed_field") {
- $computed_fields[] = str_replace('_', '-', $field_name);
- }
- }
- foreach ($tokens as $name => $original) {
- // For normal display output
- if (in_array($name, $computed_fields)) {
- $field_name = str_replace('-', '_', $name);
- $entity_field_item = $data[$type]->{$field_name}[$lang][0];
- $field = $fields[$field_name];
- // Check if the value is to be formatted by a display function outside the DB
- $display_func = 'computed_field_' . $field_name . '_display';
- if (function_exists($display_func)) {
- $display_output = $display_func($field, $entity_field_item);
- }
- else {
- eval($field['settings']['display_format']);
- }
- $replacements[$original] = $sanitize ? check_plain($display_output) : $display_output;
- }
- // For raw value output
- elseif (in_array(str_replace(':rawvalue', '', $name), $computed_fields)) {
- $field_name = str_replace('-', '_', str_replace(':rawvalue', '', $name));
- $replacements[$original] = $sanitize ? check_plain($data[$type]->{$field_name}[$lang][0]['value']) : $data[$type]->{$field_name}[$lang][0]['value'];
- }
- }
- return $replacements;
-}
-
/**
* Private function to compute the fields value.
*/
@@ -451,11 +379,11 @@ function _computed_field_compute_value($entity_type, $entity, $field, $instance,
// Setup a variable with the field values
$entity_field =& $items;
-
+
// Setup a variable with the entity language if available
if (isset($entity->language)) $entity_lang = $entity->language;
else $entity_lang = LANGUAGE_NONE;
-
+
// Allow the value to be computed from code not stored in DB
$compute_func = 'computed_field_' . $field['field_name'] . '_compute';
if (function_exists($compute_func)) {
@@ -467,3 +395,4 @@ function _computed_field_compute_value($entity_type, $entity, $field, $instance,
}
}
}
+
diff --git a/sites/all/modules/contrib/fields/serial/serial.inc b/sites/all/modules/contrib/fields/serial/serial.inc
index 917149fb..cb3dec23 100644
--- a/sites/all/modules/contrib/fields/serial/serial.inc
+++ b/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();
+}
+
diff --git a/sites/all/modules/contrib/fields/serial/serial.info b/sites/all/modules/contrib/fields/serial/serial.info
index f4056db2..56dfddd7 100644
--- a/sites/all/modules/contrib/fields/serial/serial.info
+++ b/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"
diff --git a/sites/all/modules/contrib/fields/serial/serial.install b/sites/all/modules/contrib/fields/serial/serial.install
index b555dce8..18e72bfe 100644
--- a/sites/all/modules/contrib/fields/serial/serial.install
+++ b/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'));
+ }
+}
+
diff --git a/sites/all/modules/contrib/fields/serial/serial.module b/sites/all/modules/contrib/fields/serial/serial.module
index 6331866f..688bb101 100644
--- a/sites/all/modules/contrib/fields/serial/serial.module
+++ b/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_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);
- }
+ // 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(
diff --git a/sites/all/modules/contrib/fields/title/CHANGELOG.txt b/sites/all/modules/contrib/fields/title/CHANGELOG.txt
index be009c24..99d610a9 100644
--- a/sites/all/modules/contrib/fields/title/CHANGELOG.txt
+++ b/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
diff --git a/sites/all/modules/contrib/fields/title/MAINTAINERS.txt b/sites/all/modules/contrib/fields/title/MAINTAINERS.txt
new file mode 100644
index 00000000..f20ad650
--- /dev/null
+++ b/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'
') {
+ $this->verbose($prefix . '' . check_plain($result) .'
');
+ }
+
+ public function assertBatchedExportEqual($path, $expected, $message) {
+ $this->drupalGet($path);
+ $output = $this->drupalGetContent();
+ $this->logViewResult($output);
+ $this->logViewResult($expected, 'Expected result:
');
+ $this->assertEqual($this->normaliseString($output), $this->normaliseString($expected), $message);
+ }
+
+ public function assertExportEqual($a, $b, $message) {
+ $this->logViewResult($a);
+ $this->logViewResult($b, 'Expected result:
');
+ $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();
+}
diff --git a/sites/all/modules/contrib/views/views_data_export/tests/csv_export.test b/sites/all/modules/contrib/views/views_data_export/tests/csv_export.test
new file mode 100644
index 00000000..9852b778
--- /dev/null
+++ b/sites/all/modules/contrib/views/views_data_export/tests/csv_export.test
@@ -0,0 +1,211 @@
+ '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' => '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(
+ 'keep_html' => TRUE,
+ );
+
+ $expected = '"ID","Name","Age"
+"1","John","25"
+"2","George","27"
+"3","Ringo","28"
+"4","Paul","26"
+"5","Meredith","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);
+ }
+
+ }
+
+}
diff --git a/sites/all/modules/contrib/views/views_data_export/tests/doc_export.test b/sites/all/modules/contrib/views/views_data_export/tests/doc_export.test
new file mode 100644
index 00000000..deed57db
--- /dev/null
+++ b/sites/all/modules/contrib/views/views_data_export/tests/doc_export.test
@@ -0,0 +1,48 @@
+ '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 = '
+
+
+
+
+
+
+
+';
+
+ return array(&$view, $expected);
+ }
+
+}
diff --git a/sites/all/modules/contrib/views/views_data_export/tests/txt_export.test b/sites/all/modules/contrib/views/views_data_export/tests/txt_export.test
new file mode 100644
index 00000000..e7484e97
--- /dev/null
+++ b/sites/all/modules/contrib/views/views_data_export/tests/txt_export.test
@@ -0,0 +1,164 @@
+ '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);
+
+ }
+
+}
diff --git a/sites/all/modules/contrib/views/views_data_export/tests/xls_export.test b/sites/all/modules/contrib/views/views_data_export/tests/xls_export.test
new file mode 100644
index 00000000..ae47de76
--- /dev/null
+++ b/sites/all/modules/contrib/views/views_data_export/tests/xls_export.test
@@ -0,0 +1,48 @@
+ '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 = '
+
+
+
+
+ ID Name Age
+ 1 John 25
+ 2 George 27
+ 3 Ringo 28
+ 4 Paul 26
+
+ 5 Meredith 30
+
+
+';
+
+ return array(&$view, $expected);
+ }
+
+}
diff --git a/sites/all/modules/contrib/views/views_data_export/tests/xml_export.test b/sites/all/modules/contrib/views/views_data_export/tests/xml_export.test
new file mode 100644
index 00000000..6e52d506
--- /dev/null
+++ b/sites/all/modules/contrib/views/views_data_export/tests/xml_export.test
@@ -0,0 +1,386 @@
+ '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 = '
+ID Name Age
+ 1 John 25
+ 2 George 27
+ 3 Ringo 28
+ 4 Paul 26
+
+ 5 Meredith 30