diff --git a/sites/all/modules/contrib/admin/features/features.admin.inc b/sites/all/modules/contrib/admin/features/features.admin.inc index a4203a02..8360e974 100644 --- a/sites/all/modules/contrib/admin/features/features.admin.inc +++ b/sites/all/modules/contrib/admin/features/features.admin.inc @@ -203,7 +203,7 @@ function features_export_form($form, $form_state, $feature = NULL) { $form['advanced']['generate'] = array( '#type' => 'submit', '#value' => t('Generate feature'), - '#submit' => array('features_export_build_form_submit'), + '#submit' => array('features_export_build_form_submit', 'features_form_rebuild'), ); } // build the Component Listing panel on the right @@ -239,7 +239,7 @@ function features_export_form($form, $form_state, $feature = NULL) { '#type' => 'submit', '#value' => t('Download feature'), '#weight' => 10, - '#submit' => array('features_export_build_form_submit'), + '#submit' => array('features_export_build_form_submit', 'features_form_rebuild'), ); $form['#attached']['library'][] = array('system', 'ui.dialog'); @@ -597,6 +597,7 @@ function _features_export_build($feature, &$form_state) { $component_export['selected'][$section] = array(); } $options = features_invoke($component, 'features_export_options'); + drupal_alter('features_export_options', $options, $component); if (!empty($options)) { $exported_components = !empty($exported_features_info[$component]) ? $exported_features_info[$component] : array(); $new_components = !empty($new_features_info[$component]) ? $new_features_info[$component] : array(); @@ -843,7 +844,7 @@ function _features_export_generate($export, $form_state, $feature = NULL) { } // If either update status-related keys are provided, add a project key // corresponding to the module name. - if (!empty($form_state['values']['version']) || !empty($form_state['values']['project_status_url'])) { + if (!empty($form_state['values']['version']) && !empty($form_state['values']['project_status_url'])) { $export['project'] = $form_state['values']['module_name']; } if (!empty($form_state['values']['version'])) { @@ -900,6 +901,35 @@ function features_export_build_form_submit($form, &$form_state) { $tar = array(); $filenames = array(); + // Copy any files if _files key is there. + if (!empty($files['_files'])) { + foreach ($files['_files'] as $file_name => $file_info) { + if ($generate) { + // See if files are in a sub directory. + if (strpos($file_name, '/')) { + $file_directory = $directory . '/' . substr($file_name, 0, strrpos($file_name, '/')); + if (!is_dir($file_directory)) { + mkdir($file_directory); + } + } + if (!empty($file_info['file_path'])) { + file_unmanaged_copy($file_info['file_path'], "{$directory}/{$file_name}", FILE_EXISTS_REPLACE); + } + elseif ($file_info['file_content']) { + file_put_contents("{$directory}/{$file_name}", $file_info['file_content']); + } + } + else { + if (!empty($file_info['file_path'])) { + print features_tar_create("{$module_name}/{$file_name}", file_get_contents($file_info['file_path'])); + } + elseif ($file_info['file_content']) { + features_tar_create("{$directory}/{$file_name}", $file_info['file_content']); + } + } + } + unset($files['_files']); + } foreach ($files as $extension => $file_contents) { if (!in_array($extension, array('module', 'info'))) { $extension .= '.inc'; @@ -973,28 +1003,14 @@ function features_filter_hidden($module) { * Form constructor for the features configuration form. */ function features_admin_form($form, $form_state) { + $features = _features_get_features_list(); + $modules = array_filter(features_get_modules(), 'features_filter_hidden'); + $conflicts = features_get_conflicts(); + // Load export functions to use in comparison. module_load_include('inc', 'features', 'features.export'); - // Clear & rebuild key caches - features_get_info(NULL, NULL, TRUE); - features_rebuild(); - - $modules = array_filter(features_get_modules(), 'features_filter_hidden'); - $features = array_filter(features_get_features(), 'features_filter_hidden'); - $conflicts = features_get_conflicts(); - - foreach ($modules as $key => $module) { - if ($module->status && !empty($module->info['dependencies'])) { - foreach ($module->info['dependencies'] as $dependent) { - if (isset($features[$dependent])) { - $features[$dependent]->dependents[$key] = $module->info['name']; - } - } - } - } - - if ( empty($features) ) { + if (empty($features) ) { $form['no_features'] = array( '#markup' => t('No Features were found. Please use the !create_link link to create a new Feature module, or upload an existing Feature to your modules directory.', @@ -1328,6 +1344,13 @@ function features_form_submit(&$form, &$form_state) { } } +/** + * Submit handler for the 'manage features' form rebuild button. + */ +function features_form_rebuild() { + cache_clear_all('features:features_list', 'cache'); +} + /** * Form for clearing cache after enabling a feature. */ @@ -1588,3 +1611,42 @@ function _features_get_used($module_name = NULL) { $features_ignore_conflicts = $old_value; return $conflicts; } + +/** + * Retrieves the array of features as expected on the Manage Features form. + * Uses caching for performance reasons if caching is enabled. + * + * @internal - This function might return cached result with outdated data, + * use with caution. + */ +function _features_get_features_list() { + $features = array(); + + $cache = cache_get('features:features_list'); + if ($cache) { + $features = $cache->data; + } + + if (empty($features)) { + // Clear & rebuild key caches + features_get_info(NULL, NULL, TRUE); + features_rebuild(); + + $modules = array_filter(features_get_modules(), 'features_filter_hidden'); + $features = array_filter(features_get_features(), 'features_filter_hidden'); + + foreach ($modules as $key => $module) { + if ($module->status && !empty($module->info['dependencies'])) { + foreach ($module->info['dependencies'] as $dependent) { + if (isset($features[$dependent])) { + $features[$dependent]->dependents[$key] = $module->info['name']; + } + } + } + } + + cache_set('features:features_list', $features); + } + + return $features; +} diff --git a/sites/all/modules/contrib/admin/features/features.api.php b/sites/all/modules/contrib/admin/features/features.api.php index f5984e0c..6a13b0c1 100644 --- a/sites/all/modules/contrib/admin/features/features.api.php +++ b/sites/all/modules/contrib/admin/features/features.api.php @@ -157,7 +157,8 @@ function hook_features_export_options() { * of the module, e.g. the key for `hook_example` should simply be `example` * The values in the array can also be in the form of an associative array * with the required key of 'code' and optional key of 'args', if 'args' need - * to be added to the hook. + * to be added to the hook. Alternate it can be an associative array in the + * same style as hook_features_export_files() to add additional files. */ function hook_features_export_render($module_name, $data, $export = NULL) { $code = array(); @@ -314,6 +315,26 @@ function hook_features_pipe_alter(&$pipe, $data, $export) { } } + +/** + * Add extra files to the exported file. + * + * @return array + * An array of files, keyed by file name that will appear in feature and + * with either file_path key to indicate where to copy the file from or + * file_content key to indicate the contents of the file. + */ +function hook_features_export_files($module_name, $export) { + return array('css/main.css' => array('file_content' => 'body {background-color:blue;}')); +} + +/** + * Alter the extra files added to the export. + */ +function hook_features_export_files_alter(&$files, $module_name, $export) { + $files['css/main.css']['file_content'] = 'body {background-color:black;}'; +} + /** * @defgroup features_component_alter_hooks Feature's component alter hooks * @{ diff --git a/sites/all/modules/contrib/admin/features/features.drush.inc b/sites/all/modules/contrib/admin/features/features.drush.inc index d9f3a2ec..6fdbc263 100644 --- a/sites/all/modules/contrib/admin/features/features.drush.inc +++ b/sites/all/modules/contrib/admin/features/features.drush.inc @@ -610,6 +610,28 @@ function _drush_features_export($info, $module_name = NULL, $directory = NULL) { drupal_flush_all_caches(); $export = _drush_features_generate_export($info, $module_name); $files = features_export_render($export, $module_name, TRUE); + // Copy any files if _files key is there. + if (!empty($files['_files'])) { + foreach ($files['_files'] as $file_name => $file_info) { + // See if files are in a sub directory. + if (strpos($file_name, '/')) { + $file_directory = $directory . '/' . substr($file_name, 0, strrpos($file_name, '/')); + if (!is_dir($file_directory)) { + drush_op('mkdir', $file_directory); + } + } + if (!empty($file_info['file_path'])) { + drush_op('file_unmanaged_copy', $file_info['file_path'], "{$directory}/{$file_name}", FILE_EXISTS_REPLACE); + } + elseif (!empty($file_info['file_content'])) { + drush_op('file_put_contents', "{$directory}/{$file_name}", $file_info['file_content']); + } + else { + drush_log(dt("Entry for @file_name.in !module is invalid. ", array('!module' => $module_name, '@file_name' => $file_name)), 'ok'); + } + } + unset($files['_files']); + } foreach ($files as $extension => $file_contents) { if (!in_array($extension, array('module', 'info'))) { $extension .= '.inc'; diff --git a/sites/all/modules/contrib/admin/features/features.export.inc b/sites/all/modules/contrib/admin/features/features.export.inc index 154b26bc..5cf2a8c8 100644 --- a/sites/all/modules/contrib/admin/features/features.export.inc +++ b/sites/all/modules/contrib/admin/features/features.export.inc @@ -45,6 +45,9 @@ function features_populate($info, $module_name) { * @return fully populated $export array. */ function _features_populate($pipe, &$export, $module_name = '', $reset = FALSE) { + // Ensure that the export will be created in the english language. + _features_set_export_language(); + if ($reset) { drupal_static_reset(__FUNCTION__); } @@ -295,6 +298,11 @@ function features_export_render($export, $module_name, $reset = FALSE) { } foreach ($hooks as $hook_name => $hook_info) { + // These are purely files that will be copied over. + if (is_array($hook_info) && (!empty($hook_info['file_path']) || !empty($hook_info['file_content']))) { + $code['_files'][$hook_name] = $hook_info; + continue; + } $hook_code = is_array($hook_info) ? $hook_info['code'] : $hook_info; $hook_args = is_array($hook_info) && !empty($hook_info['args']) ? $hook_info['args'] : ''; $hook_file = is_array($hook_info) && !empty($hook_info['file']) ? $hook_info['file'] : $file['name']; @@ -305,7 +313,17 @@ function features_export_render($export, $module_name, $reset = FALSE) { // Finalize strings to be written to files $code = array_filter($code); foreach ($code as $filename => $contents) { - $code[$filename] = "info); - _features_sanitize($export); + features_sanitize($module->info); + features_sanitize($export); $compare = array('normal' => features_export_info($export), 'default' => features_export_info($module->info)); if ($compare['normal'] !== $compare['default']) { @@ -408,8 +426,8 @@ function features_detect_overrides($module) { if ($state != FEATURES_DEFAULT) { $normal = features_get_normal($component, $module->name); $default = features_get_default($component, $module->name); - _features_sanitize($normal); - _features_sanitize($default); + features_sanitize($normal, $component); + features_sanitize($default, $component); $compare = array('normal' => features_var_export($normal), 'default' => features_var_export($default)); if (_features_linetrim($compare['normal']) !== _features_linetrim($compare['default'])) { @@ -663,8 +681,7 @@ function features_get_signature($state = 'default', $module_name, $component, $r break; } if (!empty($objects)) { - $objects = (array) $objects; - _features_sanitize($objects); + features_sanitize($objects, $component); return md5(_features_linetrim(features_var_export($objects))); } return FALSE; @@ -721,7 +738,7 @@ function features_get_normal($component, $module_name, $reset = FALSE) { // Special handling for dependencies component. if ($component === 'dependencies') { - $cache[$module_name][$component] = isset($module->info['dependencies']) ? array_filter($module->info['dependencies'], 'module_exists') : array(); + $cache[$module_name][$component] = isset($module->info['dependencies']) ? array_filter($module->info['dependencies'], '_features_module_exists') : array(); } // All other components. else { @@ -739,6 +756,17 @@ function features_get_normal($component, $module_name, $reset = FALSE) { return isset($cache[$module_name][$component]) ? $cache[$module_name][$component] : FALSE; } +/** + * Helper function to determine if a module is enabled + * @param $module + * This module name comes from the .info file and can have version info in it. + */ +function _features_module_exists($module) { + $parsed_dependency = drupal_parse_dependency($module); + $name = $parsed_dependency['name']; + return module_exists($name); +} + /** * Get defaults for a given module/component pair. */ @@ -970,25 +998,52 @@ function _features_linetrim($code) { return implode("\n", $code); } +/** + * Helper function to "sanitize" an array or object. + * Converts everything to an array, sorts the keys, removes recursion. + * @param $array + * @param $component string name of component + * @param bool $remove_empty if set, remove null or empty values for assoc arrays. + */ +function features_sanitize(&$array, $component = NULL, $remove_empty = TRUE) { + // make a deep copy of data to prevent problems when removing recursion later. + $array = unserialize(serialize($array)); + if (isset($component)) { + $ignore_keys = _features_get_ignore_keys($component); + // remove keys to be ignored + // doing this now allows us to better control which recursive parts are removed + if (count($ignore_keys)) { + _features_remove_ignores($array, $ignore_keys); + } + } + features_remove_recursion($array); + _features_sanitize($array, $remove_empty); +} + /** * "Sanitizes" an array recursively, performing two key operations: * - Sort an array by its keys (assoc) or values (non-assoc) - * - Remove any null or empty values for associative arrays (array_filter()). + * @param bool $remove_empty if set, remove null or empty values for assoc arrays. */ -function _features_sanitize(&$array) { +function _features_sanitize(&$array, $remove_empty = TRUE) { + if (is_object($array)) { + $array = get_object_vars($array); + } if (is_array($array)) { $is_assoc = _features_is_assoc($array); if ($is_assoc) { ksort($array, SORT_STRING); - $array = array_filter($array); + if ($remove_empty) { + $array = array_filter($array); + } } else { sort($array); } foreach ($array as $k => $v) { - if (is_array($v)) { + if (is_array($v) or is_object($v)) { _features_sanitize($array[$k]); - if ($is_assoc && empty($array[$k])) { + if ($remove_empty && $is_assoc && empty($array[$k])) { unset($array[$k]); } } @@ -1010,3 +1065,127 @@ function _features_sanitize(&$array) { function _features_is_assoc($array) { return (is_array($array) && (0 !== count(array_diff_key($array, array_keys(array_keys($array)))) || count($array)==0)); } + +/** + * Removes recursion from an object or array. + * + * @param $item + * An object or array passed by reference. + */ +function features_remove_recursion(&$item) { + $uniqid = __FUNCTION__ . mt_rand(); // use of uniqid() here impacts performance + $stack = array(); + return _features_remove_recursion($item, $stack, $uniqid); +} + +/** + * Helper to removes recursion from an object/array. + * + * @param $item + * An object or array passed by reference. + */ +function _features_remove_recursion(&$object, &$stack = array(), $uniqid) { + if ((is_object($object) || is_array($object)) && $object) { + $in_stack = FALSE; + foreach ($stack as &$item) { + if (_features_is_ref_to($object, $item, $uniqid)) { + $in_stack = TRUE; + break; + } + } + unset($item); + + if (!$in_stack) { + $stack[] = $object; + foreach ($object as $key => &$subobject) { + if (_features_remove_recursion($subobject, $stack, $uniqid)) { + if (is_object($object)) { + unset($object->$key); + } + else { + unset($object[$key]); + } + } + } + unset($subobject); + } + else { + return TRUE; + } + } + return FALSE; +} + +/** + * Helper function in determining equality of arrays. Credit to http://stackoverflow.com/a/4263181 + * + * @see _features_remove_recursion() + * + * @param $a + * object a + * @param $b + * object b + * @return bool + * + */ +function _features_is_ref_to(&$a, &$b, $uniqid) { + if (is_object($a) && is_object($b)) { + return ($a === $b); + } + + $temp_a = $a; + $temp_b = $b; + + $b = $uniqid; + + if ($a === $uniqid) $return = true; + else $return = false; + + $a = $temp_a; + $b = $temp_b; + return $return; +} + +/** + * Helper to removes a set of keys an object/array. + * + * @param $item + * An object or array passed by reference. + * @param $ignore_keys + * Array of keys to be ignored. Values are the level of the key. + * @param $level + * Level of key to remove. Up to 2 levels deep because $item can still be + * recursive + */ +function _features_remove_ignores(&$item, $ignore_keys, $level = -1) { + $is_object = is_object($item); + if (!is_array($item) && !is_object($item)) { + return; + } + foreach ($item as $key => $value) { + if (isset($ignore_keys[$key]) && ($ignore_keys[$key] == $level)) { + if ($is_object) { + unset($item->$key); + } + else { + unset($item[$key]); + } + } + elseif (($level < 2) && (is_array($value) || is_object($value))) { + _features_remove_ignores($value, $ignore_keys, $level+1); + } + } +} + +/** + * Returns an array of keys to be ignored for various exportables + * @param $component + * The component to retrieve ignore_keys from. + */ +function _features_get_ignore_keys($component) { + static $cache; + if (!isset($cache[$component])) { + $cache[$component] = module_invoke_all('features_ignore', $component); + } + return $cache[$component]; +} diff --git a/sites/all/modules/contrib/admin/features/features.info b/sites/all/modules/contrib/admin/features/features.info index 205f2c8f..e18cc8f1 100644 --- a/sites/all/modules/contrib/admin/features/features.info +++ b/sites/all/modules/contrib/admin/features/features.info @@ -6,9 +6,9 @@ files[] = tests/features.test configure = admin/structure/features/settings -; Information added by Drupal.org packaging script on 2015-04-13 -version = "7.x-2.5" +; Information added by Drupal.org packaging script on 2015-06-24 +version = "7.x-2.6" core = "7.x" project = "features" -datestamp = "1428944073" +datestamp = "1435165997" diff --git a/sites/all/modules/contrib/admin/features/features.install b/sites/all/modules/contrib/admin/features/features.install index 9b1fd901..008f41b1 100644 --- a/sites/all/modules/contrib/admin/features/features.install +++ b/sites/all/modules/contrib/admin/features/features.install @@ -5,6 +5,15 @@ * Install, update and uninstall functions for the features module. */ +/** + * Implements hook_schema(). + */ +function features_schema() { + $schema['cache_features'] = drupal_get_schema_unprocessed('system', 'cache'); + $schema['cache_features']['description'] = 'Cache table for features to store module info.'; + return $schema; +} + /** * Implements hook_install(). */ @@ -33,7 +42,7 @@ function features_uninstall() { ->execute(); db_delete('variable') ->condition('name', 'features_component_locked_%', 'LIKE') - ->execute();variable_del('features_component_locked_' . $component); + ->execute(); if (db_table_exists('menu_custom')) { db_delete('menu_custom') @@ -130,3 +139,13 @@ function features_update_6101() { } return array(); } + +/** + * Add {cache_features} table. + */ +function features_update_7200() { + if (!db_table_exists('cache_features')) { + $schema = drupal_get_schema_unprocessed('system', 'cache'); + db_create_table('cache_features', $schema); + } +} diff --git a/sites/all/modules/contrib/admin/features/features.js b/sites/all/modules/contrib/admin/features/features.js index 023247a4..0a4a1307 100644 --- a/sites/all/modules/contrib/admin/features/features.js +++ b/sites/all/modules/contrib/admin/features/features.js @@ -128,10 +128,12 @@ jQuery.fn.sortElements = (function(){ if (!$(this).hasClass('features-checkall')) { var key = $(this).attr('name'); var matches = key.match(/^([^\[]+)(\[.+\])?\[(.+)\]\[(.+)\]$/); - var component = matches[1]; - var item = matches[4]; - if ((component in moduleConflicts) && (moduleConflicts[component].indexOf(item) != -1)) { - $(this).parent().addClass('features-conflict'); + if (matches != null) { + var component = matches[1]; + var item = matches[4]; + if ((component in moduleConflicts) && (moduleConflicts[component].indexOf(item) != -1)) { + $(this).parent().addClass('features-conflict'); + } } } }); @@ -290,7 +292,7 @@ jQuery.fn.sortElements = (function(){ } // Handle component selection UI - $('#features-export-wrapper input[type=checkbox]', context).click(function() { + $('#features-export-wrapper input[type=checkbox]:not(.processed)', context).addClass('processed').click(function() { _resetTimeout(); if ($(this).hasClass('component-select')) { moveCheckbox(this, 'added', true); diff --git a/sites/all/modules/contrib/admin/features/features.module b/sites/all/modules/contrib/admin/features/features.module index 3743963b..2fcc660b 100644 --- a/sites/all/modules/contrib/admin/features/features.module +++ b/sites/all/modules/contrib/admin/features/features.module @@ -268,14 +268,17 @@ function features_theme() { * Implements hook_flush_caches(). */ function features_flush_caches() { - if (variable_get('features_rebuild_on_flush', TRUE)) { + if (($modules_changed = variable_get('features_modules_changed', FALSE)) || variable_get('features_rebuild_on_flush', TRUE)) { + if ($modules_changed) { + variable_set('features_modules_changed', FALSE); + } features_rebuild(); // Don't flush the modules cache during installation, for performance reasons. if (variable_get('install_task') == 'done') { features_get_modules(NULL, TRUE); } } - return array(); + return array('cache_features'); } /** @@ -349,6 +352,15 @@ function features_modules_disabled($modules) { * Implements hook_modules_enabled(). */ function features_modules_enabled($modules) { + // Allow distributions to disable this behavior and rebuild the features + // manually inside a batch. + if (!variable_get('features_rebuild_on_module_install', TRUE)) { + return; + } + + // mark modules as being changed for test in features_flush_caches + variable_set('features_modules_changed', TRUE); + // Go through all modules and gather features that can be enabled. $items = array(); foreach ($modules as $module) { @@ -385,7 +397,7 @@ function features_include($reset = FALSE) { // Features provides integration on behalf of these modules. // The features include provides handling for the feature dependencies. // Note that ctools is placed last because it implements hooks "dynamically" for other modules. - $modules = array('features', 'block', 'context', 'field', 'filter', 'image', 'locale', 'menu', 'node', 'taxonomy', 'user', 'views', 'ctools'); + $modules = array('features', 'block', 'contact', 'context', 'field', 'filter', 'image', 'locale', 'menu', 'node', 'taxonomy', 'user', 'views', 'ctools'); foreach (array_filter($modules, 'module_exists') as $module) { module_load_include('inc', 'features', "includes/features.$module"); @@ -535,13 +547,13 @@ function features_get_components($component = NULL, $key = NULL, $reset = FALSE) if ($reset || !isset($components) || !isset($component_by_key)) { $components = $component_by_key = array(); - if (!$reset && ($cache = cache_get('features_api'))) { + if (!$reset && ($cache = cache_get('features_api', 'cache_features'))) { $components = $cache->data; } else { $components = module_invoke_all('features_api'); drupal_alter('features_api', $components); - cache_set('features_api', $components); + cache_set('features_api', $components, 'cache_features'); } foreach ($components as $component_type => $component_information) { @@ -607,6 +619,8 @@ function features_hook($component, $hook, $reset = FALSE) { * Clear the module info cache. */ function features_install_modules($modules) { + variable_set('features_modules_changed', TRUE); + module_load_include('inc', 'features', 'features.export'); $files = system_rebuild_module_data(); @@ -650,7 +664,7 @@ function features_get_features($name = NULL, $reset = FALSE) { function features_get_info($type = 'module', $name = NULL, $reset = FALSE) { static $cache; if (!isset($cache)) { - $cache = cache_get('features_module_info'); + $cache = cache_get('features_module_info', 'cache_features'); } if (empty($cache) || $reset) { $data = array( @@ -738,7 +752,7 @@ function features_get_info($type = 'module', $name = NULL, $reset = FALSE) { $data['feature'] = $sorted; variable_set('features_ignored_orphans', $ignored); - cache_set("features_module_info", $data); + cache_set('features_module_info', $data, 'cache_features'); $cache = new stdClass(); $cache->data = $data; } @@ -1067,6 +1081,7 @@ function features_hook_info() { 'features_api', 'features_pipe_alter', 'features_export_alter', + 'features_export_options_alter', ); return array_fill_keys($hooks, array('group' => 'features')); } @@ -1189,7 +1204,6 @@ function features_feature_lock($feature, $component = NULL) { variable_set('features_feature_locked', $locked); } - /** * Unlocks a feature or it's component. */ @@ -1203,3 +1217,115 @@ function features_feature_unlock($feature, $component = NULL) { } variable_set('features_feature_locked', $locked); } + +/** + * Sets the current language to english to ensure a proper export. + */ +function _features_set_export_language() { + // Ensure this is only done if the language isn't already en. + // This can be called multiple times - ensure the handling is done just once. + if ($GLOBALS['language']->language != 'en' && !drupal_static(__FUNCTION__)) { + // Create the language object as language_default() does. + $GLOBALS['language'] = (object) array( + 'language' => 'en', + 'name' => 'English', + 'native' => 'English', + 'direction' => 0, + 'enabled' => 1, + 'plurals' => 0, + 'formula' => '', + 'domain' => '', + 'prefix' => '', + 'weight' => 0, + 'javascript' => '', + ); + // Ensure that static caches are cleared, as they might contain language + // specific information. But keep some important ones. The call below + // accesses a non existing key and requests to reset it. In such cases the + // whole caching data array is returned. + $static = drupal_static(uniqid('', TRUE), NULL, TRUE); + drupal_static_reset(); + // Restore some of the language independent, runtime state information to + // keep everything working and avoid unnecessary double processing. + $static_caches_to_keep = array( + 'conf_path', + 'system_list', + 'ip_address', + 'drupal_page_is_cacheable', + 'list_themes', + 'drupal_page_header', + 'drupal_send_headers', + 'drupal_http_headers', + 'language_list', + 'module_implements', + 'drupal_alter', + 'path_is_admin', + 'path_get_admin_paths', + 'drupal_match_path', + 'menu_get_custom_theme', + 'menu_get_item', + 'arg', + 'drupal_system_listing', + 'drupal_parse_info_file', + 'libraries_get_path', + 'module_hook_info', + 'drupal_add_js', + 'drupal_add_js:jquery_added', + 'drupal_add_library', + 'drupal_get_library', + 'drupal_add_css', + 'menu_set_active_trail', + 'menu_link_get_preferred', + 'menu_set_active_menu_names', + 'theme_get_registry', + 'features_get_components', + 'features_get_components_by_key', + ); + foreach ($static_caches_to_keep as $cid) { + if (isset($static[$cid])) { + $data = &drupal_static($cid); + $data = $static[$cid]; + } + } + $called = &drupal_static(__FUNCTION__); + $called = TRUE; + } +} + +/** + * Implements hook_features_ignore(). + */ +function features_features_ignore($component) { + // Determine which keys need to be ignored for override diff for various components. + // Value is how many levels deep the key is. + $ignores = array(); + switch ($component) { + case 'views_view': + $ignores['current_display'] = 0; + $ignores['display_handler'] = 0; + $ignores['handler'] = 2; + $ignores['query'] = 0; + $ignores['localization_plugin'] = 0; + // Views automatically adds these two on export to set values. + $ignores['api_version'] = 0; + $ignores['disabled'] = 0; + break; + case 'image': + $ignores['module'] = 0; + $ignores['name'] = 0; + $ignores['storage'] = 0; + // Various properties are loaded into the effect in image_styles. + $ignores['summary theme'] = 2; + $ignores['module'] = 2; + $ignores['label'] = 2; + $ignores['help'] = 2; + $ignores['form callback'] = 2; + $ignores['effect callback'] = 2; + $ignores['dimensions callback'] = 2; + break; + case 'field': + $ignores['locked'] = 1; + break; + } + return $ignores; +} diff --git a/sites/all/modules/contrib/admin/features/includes/features.field.inc b/sites/all/modules/contrib/admin/features/includes/features.field.inc index 73332271..c6202748 100644 --- a/sites/all/modules/contrib/admin/features/includes/features.field.inc +++ b/sites/all/modules/contrib/admin/features/includes/features.field.inc @@ -274,7 +274,8 @@ function field_base_features_rebuild($module) { // Create or update field. if (isset($existing_fields[$field['field_name']])) { $existing_field = $existing_fields[$field['field_name']]; - if ($field + $existing_field !== $existing_field) { + $array_diff_result = drupal_array_diff_assoc_recursive($field + $existing_field, $existing_field); + if (!empty($array_diff_result)) { field_update_field($field); } } @@ -483,7 +484,8 @@ function field_features_rebuild($module) { $field_config = $field['field_config']; if (isset($existing_fields[$field_config['field_name']])) { $existing_field = $existing_fields[$field_config['field_name']]; - if ($field_config + $existing_field !== $existing_field) { + $array_diff_result = drupal_array_diff_assoc_recursive($field_config + $existing_field, $existing_field); + if (!empty($array_diff_result)) { try { field_update_field($field_config); } diff --git a/sites/all/modules/contrib/admin/features/includes/features.menu.inc b/sites/all/modules/contrib/admin/features/includes/features.menu.inc index c883e6ac..6ba83e6e 100644 --- a/sites/all/modules/contrib/admin/features/includes/features.menu.inc +++ b/sites/all/modules/contrib/admin/features/includes/features.menu.inc @@ -253,11 +253,11 @@ function menu_links_features_export_render($module, $data, $export = NULL) { $translatables[] = $link['link_title']; } } + $code[] = ''; if (!empty($translatables)) { $code[] = features_translatables_export($translatables, ' '); } - $code[] = ''; $code[] = ' return $menu_links;'; $code = implode("\n", $code); return array('menu_default_menu_links' => $code); diff --git a/sites/all/modules/contrib/admin/features/tests/features.test b/sites/all/modules/contrib/admin/features/tests/features.test index 1fa51ac2..bbdeb0b9 100644 --- a/sites/all/modules/contrib/admin/features/tests/features.test +++ b/sites/all/modules/contrib/admin/features/tests/features.test @@ -287,3 +287,43 @@ class FeaturesCtoolsIntegrationTest extends DrupalWebTestCase { } } } + + +/** + * Test detecting modules as features. + */ +class FeaturesDetectionTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + + /** + * Test info. + */ + public static function getInfo() { + return array( + 'name' => t('Feature Detection tests'), + 'description' => t('Run tests for detecting items as features.') , + 'group' => t('Features'), + ); + } + + /** + * Set up test. + */ + public function setUp() { + parent::setUp(array( + 'features', + )); + } + + /** + * Run test. + */ + public function test() { + module_load_include('inc', 'features', 'features.export'); + // First test that features_populate inserts the features api key. + $export = features_populate(array(), array(), 'features_test_empty_fake'); + $this->assertTrue(!empty($export['features']['features_api']) && key($export['features']['features_api']) == 'api:' . FEATURES_API, 'Features API key added to new export.'); + $this->assertTrue((bool)features_get_features('features_test'), 'Features test recognized as a feature.'); + $this->assertFalse((bool)features_get_features('features'), 'Features module not recognized as a feature.'); + } +} diff --git a/sites/all/modules/contrib/admin/features/tests/features_test/features_test.info b/sites/all/modules/contrib/admin/features/tests/features_test/features_test.info index d27d18ce..50085c55 100644 --- a/sites/all/modules/contrib/admin/features/tests/features_test/features_test.info +++ b/sites/all/modules/contrib/admin/features/tests/features_test/features_test.info @@ -21,9 +21,9 @@ features[user_permission][] = create features_test content features[views_view][] = features_test hidden = 1 -; Information added by Drupal.org packaging script on 2015-04-13 -version = "7.x-2.5" +; Information added by Drupal.org packaging script on 2015-06-24 +version = "7.x-2.6" core = "7.x" project = "features" -datestamp = "1428944073" +datestamp = "1435165997" diff --git a/sites/all/modules/contrib/content/pathauto/API.txt b/sites/all/modules/contrib/content/pathauto/API.txt deleted file mode 100644 index e585cd48..00000000 --- a/sites/all/modules/contrib/content/pathauto/API.txt +++ /dev/null @@ -1,149 +0,0 @@ -This document explains how to provide "Pathauto integration" in a -module. You need this if you would like to provide additional tokens -or if your module has paths and you wish to have them automatically -aliased. The simplest integration is just to provide tokens so we -cover that first. More advanced integration requires an -implementation of hook_pathauto to provide a settings form. - -It may be helpful to review some examples of integration from the -pathauto_node.inc, pathauto_taxonomy.inc, and pathauto_user.inc files. - - -================== -1 - Providing additional tokens -================== - -If all you want is to enable tokens for your module you will simply -need to implement two functions: - - hook_token_values - hook_token_list - -See the token.module and it's API.txt for more information about this -process. - -If the token is intended to generate a path expected to contain slashes, -the token name must end in 'path', 'path-raw' or 'alias'. This indicates to -Pathauto that the slashes should not be removed from the replacement value. - -When an object is created (whether it is a node or a user or a -taxonomy term) the data that Pathauto hands to the token_values in the -$object is in a specific format. This is the format that most people -write code to handle. However, during edits and bulk updates the data -may be in a totally different format. So, if you are writing a -hook_token_values implementation to add special tokens, be sure to -test creation, edit, and bulk update cases to make sure your code will -handle it. - -================== -2 - Settings hook - To create aliases for your module -================== -You must implement hook_pathauto($op), where $op is always (at this -time) 'settings'. Return an object (NOT an array) containing the -following members, which will be used by pathauto to build a group -of settings for your module and define the variables for saving your -settings: - -module - The name of your module (e.g., 'node') -groupheader - The translated label for the settings group (e.g., - t('Content path settings') -patterndescr - The translated label for the default pattern (e.g., - t('Default path pattern (applies to all content types with blank patterns below)') -patterndefault - A translated default pattern (e.g., t('[cat]/[title].html')) -token_type - The token type (e.g. 'node', 'user') that can be used. -patternitems - For modules which need to express multiple patterns - (for example, the node module supports a separate pattern for each - content type), an array whose keys consist of identifiers for each - pattern (e.g., the content type name) and values consist of the - translated label for the pattern -bulkname - For modules which support a bulk update operation, the - translated label for the action (e.g., t('Bulk update content paths')) -bulkdescr - For modules which support a bulk update operation, a - translated, more thorough description of what the operation will do - (e.g., t('Generate aliases for all existing content items which do not already have aliases.')) - - -================== -2 - $alias = pathauto_create_alias($module, $op, $placeholders, $src, $type=NULL) -================== - -At the appropriate time (usually when a new item is being created for -which a generated alias is desired), call pathauto_create_alias() to -generate and create the alias. See the user, taxonomy, and nodeapi hook -implementations in pathauto.module for examples. - -$module - The name of your module (e.g., 'node') -$op - Operation being performed on the item ('insert', 'update', or - 'bulkupdate') -$placeholders - An array whose keys consist of the translated placeholders - which appear in patterns and values are the "clean" values to be - substituted into the pattern. Call pathauto_cleanstring() on any - values which you do not know to be purely alphanumeric, to substitute - any non-alphanumerics with the user's designated separator. Note that - if the pattern has multiple slash-separated components (e.g., [term:path]), - pathauto_cleanstring() should be called for each component, not the - complete string. - Example: $placeholders[t('[title]')] = pathauto_cleanstring($node->title); -$src - The "real" URI of the content to be aliased (e.g., "node/$node->nid") -$type - For modules which provided patternitems in hook_autopath(), - the relevant identifier for the specific item to be aliased (e.g., - $node->type) - -pathauto_create_alias() returns the alias that was created. - - -================== -3 - Bulk update function -================== - -If a module supports bulk updating of aliases, it must provide a -function of this form, to be called by pathauto when the corresponding -checkbox is selected and the settings page submitted: - -function _pathauto_bulkupdate() - -The function should iterate over the content items controlled by the -module, calling pathauto_create_alias() for each one. It is -recommended that the function report on its success (e.g., with a -count of created aliases) via drupal_set_message(). - - -================== -4 - Bulk delete hook_path_alias_types() -================== - -For modules that create new types of pages that can be aliased with pathauto, a -hook implementation is needed to allow the user to delete them all at once. - -function hook_path_alias_types() - -This hook returns an array whose keys match the beginning of the source paths -(e.g.: "node/", "user/", etc.) and whose values describe the type of page (e.g.: -"content", "users"). Like all displayed strings, these descriptionsshould be -localized with t(). Use % to match interior pieces of a path; "user/%/track". This -is a database wildcard, so be careful. - - -================== -Modules that extend node and/or taxonomy -================== - -NOTE: this is basically not true any more. If you feel you need this file an issue. - -Many contributed Drupal modules extend the core node and taxonomy -modules. To extend pathauto patterns to support their extensions, they -may implement the pathauto_node and pathauto_taxonomy hooks. - -To do so, implement the function _pathauto_node (or _taxonomy), -accepting the arguments $op and $node (or $term). Two operations are -supported: - -$op = 'placeholders' - return an array keyed on placeholder strings -(e.g., t('[eventyyyy]')) valued with descriptions (e.g. t('The year the -event starts.')). -$op = 'values' - return an array keyed on placeholder strings, valued -with the "clean" actual value for the passed node or category (e.g., -pathauto_cleanstring(date('M', $eventstart))); - -See contrib/pathauto_node_event.inc for an example of extending node -patterns. diff --git a/sites/all/modules/contrib/content/pathauto/README.txt b/sites/all/modules/contrib/content/pathauto/README.txt index 4c458a14..fc56959d 100644 --- a/sites/all/modules/contrib/content/pathauto/README.txt +++ b/sites/all/modules/contrib/content/pathauto/README.txt @@ -1,48 +1,49 @@ -Please read this file and also the INSTALL.txt. +Please read this file and also the INSTALL.txt. They contain answers to many common questions. If you are developing for this module, the API.txt may be interesting. If you are upgrading, check the CHANGELOG.txt for major changes. -**Description: -The Pathauto module provides support functions for other modules to -automatically generate aliases based on appropriate criteria, with a +** Description: +The Pathauto module provides support functions for other modules to +automatically generate aliases based on appropriate criteria, with a central settings path for site administrators. Implementations are provided for core entity types: content, taxonomy terms, -and users (including blogs and tracker pages). +and users (including blogs and forum pages). -Pathauto also provides a way to delete large numbers of aliases. This feature -is available at Administer > Site building > URL aliases > Delete aliases +Pathauto also provides a way to delete large numbers of aliases. This feature +is available at Administer > Configuration > Search and metadata > URL aliases +> Delete aliases. -**Benefits: +** Benefits: Besides making the page address more reflective of its content than -"node/138", it's important to know that modern search engines give -heavy weight to search terms which appear in a page's URL. By -automatically using keywords based directly on the page content in the URL, +"node/138", it's important to know that modern search engines give +heavy weight to search terms which appear in a page's URL. By +automatically using keywords based directly on the page content in the URL, relevant search engine hits for your page can be significantly enhanced. -**Installation AND Upgrades: +** Installation AND Upgrades: See the INSTALL.txt file. -**Notices: +** Notices: Pathauto just adds URL aliases to content, users, and taxonomy terms. -Because it's an alias, the standard Drupal URL (for example node/123 or -taxonomy/term/1) will still function as normal. If you have external links -to your site pointing to standard Drupal URLs, or hardcoded links in a module, +Because it's an alias, the standard Drupal URL (for example node/123 or +taxonomy/term/1) will still function as normal. If you have external links +to your site pointing to standard Drupal URLs, or hardcoded links in a module, template, content or menu which point to standard Drupal URLs it will bypass the alias set by Pathauto. -There are reasons you might not want two URLs for the same content on your -site. If this applies to you, please note that you will need to update any -hard coded links in your content or blocks. +There are reasons you might not want two URLs for the same content on your +site. If this applies to you, please note that you will need to update any +hard coded links in your content or blocks. If you use the "system path" (i.e. node/10) for menu items and settings like that, Drupal will replace it with the url_alias. -For external links, you might want to consider the Path Redirect or -Global Redirect modules, which allow you to set forwarding either per item or -across the site to your aliased URLs. +For external links, you might want to consider the Path Redirect or +Global Redirect modules, which allow you to set forwarding either per item or +across the site to your aliased URLs. URLs (not) Getting Replaced With Aliases: Please bear in mind that only URLs passed through Drupal's l() or url() @@ -54,41 +55,27 @@ Drupal API instead: * 'href="'. url("node/$node->nid") .'"' or * l("Your link title", "node/$node->nid") -See http://api.drupal.org/api/HEAD/function/url and +See http://api.drupal.org/api/HEAD/function/url and http://api.drupal.org/api/HEAD/function/l for more information. ** Disabling Pathauto for a specific content type (or taxonomy) -When the pattern for a content type is left blank, the default pattern will be -used. But if the default pattern is also blank, Pathauto will be disabled +When the pattern for a content type is left blank, the default pattern will be +used. But if the default pattern is also blank, Pathauto will be disabled for that content type. -** Bulk Updates Must be Run Multiple Times: -As of 5.x-2.x Pathauto now performs bulk updates in a manner which is more -likely to succeed on large sites. The drawback is that it needs to be run -multiple times. If you want to reduce the number of times that you need to -run Pathauto you can increase the "Maximum number of objects to alias in a -bulk update:" setting under General Settings. - -**WYSIWYG Conflicts - FCKEditor, TinyMCE, etc. -If you use a WYSIWYG editor, please disable it for the Pathauto admin page. -Failure to do so may cause errors about "preg_replace" problems due to the

-tag being added to the "strings to replace". See http://drupal.org/node/175772 - -**Credits: +** Credits: The original module combined the functionality of Mike Ryan's autopath with Tommy Sundstrom's path_automatic. Significant enhancements were contributed by jdmquin @ www.bcdems.net. -Matt England added the tracker support. +Matt England added the tracker support (tracker support has been removed in +recent changes). Other suggestions and patches contributed by the Drupal community. -Current maintainers: - Greg Knaddison - http://growingventuresolutions.com +Current maintainers: + Dave Reid - http://www.davereid.net + Greg Knaddison - http://www.knaddison.com Mike Ryan - http://mikeryan.name Frederik 'Freso' S. Olesen - http://freso.dk - -**Changes: -See the CHANGELOG.txt file. - diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.admin.inc b/sites/all/modules/contrib/content/pathauto/pathauto.admin.inc index 9030f487..b2103867 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.admin.inc +++ b/sites/all/modules/contrib/content/pathauto/pathauto.admin.inc @@ -64,17 +64,11 @@ function pathauto_patterns_form($form, $form_state) { } } - // Display the user documentation of placeholders supported by - // this module, as a description on the last pattern + // Show the token help relevant to this pattern type. $form[$module]['token_help'] = array( - '#title' => t('Replacement patterns'), - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form[$module]['token_help']['help'] = array( '#theme' => 'token_tree', '#token_types' => array($settings->token_type), + '#dialog' => TRUE, ); } @@ -144,7 +138,7 @@ function pathauto_settings_form($form) { $description = t('What should Pathauto do when updating an existing content item which already has an alias?'); if (module_exists('redirect')) { - $description .= ' ' . t('The Redirect module settings affect whether a redirect is created when an alias is deleted.', array('!url' => url('admin/config/search/redirect'))); + $description .= ' ' . t('The Redirect module settings affect whether a redirect is created when an alias is deleted.', array('!url' => url('admin/config/search/redirect/settings'))); } else { $description .= ' ' . t('Considering installing the Redirect module to get redirects when your aliases change.', array('!url' => 'http://drupal.org/project/redirect')); @@ -165,7 +159,7 @@ function pathauto_settings_form($form) { '#type' => 'checkbox', '#title' => t('Transliterate prior to creating alias'), '#default_value' => variable_get('pathauto_transliterate', FALSE) && module_exists('transliteration'), - '#description' => t('When a pattern includes certain characters (such as those with accents) should Pathauto attempt to transliterate them into the ASCII-96 alphabet? Transliteration is handled by the Transliteration module.'), + '#description' => t('When a pattern includes certain characters (such as those with accents) should Pathauto attempt to transliterate them into the US-ASCII alphabet? Transliteration is handled by the Transliteration module.'), '#access' => module_exists('transliteration'), ); diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.api.php b/sites/all/modules/contrib/content/pathauto/pathauto.api.php index 41f11543..4c921888 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.api.php +++ b/sites/all/modules/contrib/content/pathauto/pathauto.api.php @@ -1,17 +1,171 @@ $type) { + $settings['patternitems'][$file_type] = t('Pattern for all @file_type paths.', array('@file_type' => $type->label)); + } + return (object) $settings; + + default: + break; + } +} + +/** + * Determine if a possible URL alias would conflict with any existing paths. + * + * Returning TRUE from this function will trigger pathauto_alias_uniquify() to + * generate a similar URL alias with a suffix to avoid conflicts. + * + * @param string $alias + * The potential URL alias. + * @param string $source + * The source path for the alias (e.g. 'node/1'). + * @param string $langcode + * The language code for the alias (e.g. 'en'). + * + * @return bool + * TRUE if $alias conflicts with an existing, reserved path, or FALSE/NULL if + * it does not match any reserved paths. + * + * @see pathauto_alias_uniquify() + */ +function hook_pathauto_is_alias_reserved($alias, $source, $langcode) { + // Check our module's list of paths and return TRUE if $alias matches any of + // them. + return (bool) db_query("SELECT 1 FROM {mytable} WHERE path = :path", array(':path' => $alias))->fetchField(); +} + +/** + * Alter the pattern to be used before an alias is generated by Pathauto. + * + * This hook will only be called if a default pattern is configured (on + * admin/config/search/path/patterns). + * + * @param string $pattern + * The alias pattern for Pathauto to pass to token_replace() to generate the + * URL alias. + * @param array $context + * An associative array of additional options, with the following elements: + * - 'module': The module or entity type being aliased. + * - 'op': A string with the operation being performed on the object being + * aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'. + * - 'source': A string of the source path for the alias (e.g. 'node/1'). + * - 'data': An array of keyed objects to pass to token_replace(). + * - 'type': The sub-type or bundle of the object being aliased. + * - 'language': A string of the language code for the alias (e.g. 'en'). + * This can be altered by reference. + */ +function hook_pathauto_pattern_alter(&$pattern, array $context) { + // Switch out any [node:created:*] tokens with [node:updated:*] on update. + if ($context['module'] == 'node' && ($context['op'] == 'update')) { + $pattern = preg_replace('/\[node:created(\:[^]]*)?\]/', '[node:updated$1]', $pattern); + } } /** diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.inc b/sites/all/modules/contrib/content/pathauto/pathauto.inc index 9f98eec3..9699aa08 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.inc +++ b/sites/all/modules/contrib/content/pathauto/pathauto.inc @@ -59,30 +59,27 @@ define('PATHAUTO_PUNCTUATION_DO_NOTHING', 2); * A string alias. * @param $source * A string that is the internal path. - * @param $language + * @param $langcode * A string indicating the path's language. - * @return + * + * @return bool * TRUE if an alias exists, FALSE if not. + * + * @deprecated Use path_pathauto_is_alias_reserved() instead. */ -function _pathauto_alias_exists($alias, $source, $language = LANGUAGE_NONE) { - $pid = db_query_range("SELECT pid FROM {url_alias} WHERE source <> :source AND alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", 0, 1, array( - ':source' => $source, - ':alias' => $alias, - ':language' => $language, - ':language_none' => LANGUAGE_NONE, - ))->fetchField(); - - return !empty($pid); +function _pathauto_alias_exists($alias, $source, $langcode = LANGUAGE_NONE) { + return path_pathauto_is_alias_reserved($alias, $source, $langcode); } /** * Fetches an existing URL alias given a path and optional language. * - * @param $source + * @param string $source * An internal Drupal path. - * @param $language + * @param string $language * An optional language code to look up the path in. - * @return + * + * @return bool|array * FALSE if no alias was found or an associative array containing the * following keys: * - pid: Unique path alias identifier. @@ -111,12 +108,17 @@ function _pathauto_existing_alias_data($source, $language = LANGUAGE_NONE) { * This function should *not* be called on URL alias or path strings because it * is assumed that they are already clean. * - * @param $string + * @param string $string * A string to clean. - * @return + * @param array $options + * (optional) A keyed array of settings and flags to control the Pathauto + * clean string replacement process. Supported options are: + * - langcode: A language code to be used when translating strings. + * + * @return string * The cleaned string. */ -function pathauto_cleanstring($string) { +function pathauto_cleanstring($string, array $options = array()) { // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; if (!isset($drupal_static_fast)) { @@ -161,6 +163,7 @@ function pathauto_cleanstring($string) { if ($ignore_words_regex) { $cache['ignore_words_regex'] = '\b' . $ignore_words_regex . '\b'; if (function_exists('mb_eregi_replace')) { + mb_regex_encoding('UTF-8'); $cache['ignore_words_callback'] = 'mb_eregi_replace'; } else { @@ -170,15 +173,23 @@ function pathauto_cleanstring($string) { } } - // Empty strings do not need any proccessing. + // Empty strings do not need any processing. if ($string === '' || $string === NULL) { return ''; } + $langcode = NULL; + if (!empty($options['language']->language)) { + $langcode = $options['language']->language; + } + elseif (!empty($options['langcode'])) { + $langcode = $options['langcode']; + } + // Check if the string has already been processed, and if so return the // cached result. - if (isset($cache['strings'][$string])) { - return $cache['strings'][$string]; + if (isset($cache['strings'][$langcode][$string])) { + return $cache['strings'][$langcode][$string]; } // Remove all HTML tags from the string. @@ -186,7 +197,10 @@ function pathauto_cleanstring($string) { // Optionally transliterate (by running through the Transliteration module) if ($cache['transliterate']) { - $output = transliteration_get($output); + // If the reduce strings to letters and numbers is enabled, don't bother + // replacing unknown characters with a question mark. Use an empty string + // instead. + $output = transliteration_get($output, $cache['reduce_ascii'] ? '' : '?', $langcode); } // Replace or drop punctuation based on user settings @@ -220,7 +234,7 @@ function pathauto_cleanstring($string) { $output = truncate_utf8($output, $cache['maxlength'], TRUE); // Cache this result in the static array. - $cache['strings'][$string] = $output; + $cache['strings'][$langcode][$string] = $output; return $output; } @@ -228,11 +242,12 @@ function pathauto_cleanstring($string) { /** * Trims duplicate, leading, and trailing separators from a string. * - * @param $string + * @param string $string * The string to clean path separators from. - * @param $separator + * @param string $separator * The path separator to use when cleaning. - * @return + * + * @return string * The cleaned version of the string. * * @see pathauto_cleanstring() @@ -250,21 +265,20 @@ function _pathauto_clean_separators($string, $separator = NULL) { $output = $string; - // Clean duplicate or trailing separators. if (strlen($separator)) { - // Escape the separator. - $seppattern = preg_quote($separator, '/'); - // Trim any leading or trailing separators. - $output = preg_replace("/^$seppattern+|$seppattern+$/", '', $output); + $output = trim($output, $separator); - // Replace trailing separators around slashes. - if ($separator !== '/') { - $output = preg_replace("/$seppattern+\/|\/$seppattern+/", "/", $output); - } + // Escape the separator for use in regular expressions. + $seppattern = preg_quote($separator, '/'); // Replace multiple separators with a single one. $output = preg_replace("/$seppattern+/", $separator, $output); + + // Replace trailing separators around slashes. + if ($separator !== '/') { + $output = preg_replace("/\/+$seppattern\/+|$seppattern\/+|\/+$seppattern/", "/", $output); + } } return $output; @@ -278,9 +292,10 @@ function _pathauto_clean_separators($string, $separator = NULL) { * - Trim duplicate, leading, and trailing separators. * - Shorten to a desired length and logical position based on word boundaries. * - * @param $alias + * @param string $alias * A string with the URL alias to clean up. - * @return + * + * @return string * The cleaned URL alias. */ function pathauto_clean_alias($alias) { @@ -294,12 +309,15 @@ function pathauto_clean_alias($alias) { $output = $alias; - // Trim duplicate, leading, and trailing back-slashes. - $output = _pathauto_clean_separators($output, '/'); - - // Trim duplicate, leading, and trailing separators. + // Trim duplicate, leading, and trailing separators. Do this before cleaning + // backslashes since a pattern like "[token1]/[token2]-[token3]/[token4]" + // could end up like "value1/-/value2" and if backslashes were cleaned first + // this would result in a duplicate blackslash. $output = _pathauto_clean_separators($output); + // Trim duplicate, leading, and trailing backslashes. + $output = _pathauto_clean_separators($output, '/'); + // Shorten to a logical place based on word boundaries. $output = truncate_utf8($output, $cache['maxlength'], TRUE); @@ -328,8 +346,10 @@ function pathauto_clean_alias($alias) { * (e.g., $node->type). * @param $language * A string specify the path's language. - * @return - * The alias that was created. + * + * @return array|null|false + * The alias array that was created, NULL if an empty alias was generated, or + * FALSE if the alias generation was not possible. * * @see _pathauto_set_alias() * @see token_replace() @@ -337,20 +357,32 @@ function pathauto_clean_alias($alias) { function pathauto_create_alias($module, $op, $source, $data, $type = NULL, $language = LANGUAGE_NONE) { // Retrieve and apply the pattern for this content type. $pattern = pathauto_pattern_load_by_entity($module, $type, $language); + + // Allow other modules to alter the pattern. + $context = array( + 'module' => $module, + 'op' => $op, + 'source' => $source, + 'data' => $data, + 'type' => $type, + 'language' => &$language, + ); + drupal_alter('pathauto_pattern', $pattern, $context); + if (empty($pattern)) { // No pattern? Do nothing (otherwise we may blow away existing aliases...) - return ''; + return FALSE; } // Special handling when updating an item which is already aliased. $existing_alias = NULL; - if ($op == 'update' || $op == 'bulkupdate') { + if ($op != 'insert') { if ($existing_alias = _pathauto_existing_alias_data($source, $language)) { switch (variable_get('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE)) { case PATHAUTO_UPDATE_ACTION_NO_NEW: // If an alias already exists, and the update action is set to do nothing, // then gosh-darn it, do nothing. - return ''; + return FALSE; } } } @@ -369,26 +401,19 @@ function pathauto_create_alias($module, $op, $source, $data, $type = NULL, $lang // @see token_scan() $pattern_tokens_removed = preg_replace('/\[[^\s\]:]*:[^\s\]]*\]/', '', $pattern); if ($alias === $pattern_tokens_removed) { - return ''; + return; } $alias = pathauto_clean_alias($alias); // Allow other modules to alter the alias. - $context = array( - 'module' => $module, - 'op' => $op, - 'source' => &$source, - 'data' => $data, - 'type' => $type, - 'language' => &$language, - 'pattern' => $pattern, - ); + $context['source'] = &$source; + $context['pattern'] = $pattern; drupal_alter('pathauto_alias', $alias, $context); // If we have arrived at an empty string, discontinue. if (!drupal_strlen($alias)) { - return ''; + return; } // If the alias already exists, generate a new, hopefully unique, variant. @@ -432,7 +457,7 @@ function pathauto_create_alias($module, $op, $source, $data, $type = NULL, $lang * A string with a language code. */ function pathauto_alias_uniquify(&$alias, $source, $langcode) { - if (!_pathauto_alias_exists($alias, $source, $langcode)) { + if (!pathauto_is_alias_reserved($alias, $source, $langcode)) { return; } @@ -445,9 +470,9 @@ function pathauto_alias_uniquify(&$alias, $source, $langcode) { do { // Append an incrementing numeric suffix until we find a unique alias. $unique_suffix = $separator . $i; - $alias = truncate_utf8($original_alias, $maxlength - drupal_strlen($unique_suffix, TRUE)) . $unique_suffix; + $alias = truncate_utf8($original_alias, $maxlength - drupal_strlen($unique_suffix), TRUE) . $unique_suffix; $i++; - } while (_pathauto_alias_exists($alias, $source, $langcode)); + } while (pathauto_is_alias_reserved($alias, $source, $langcode)); } /** @@ -463,7 +488,7 @@ function pathauto_alias_uniquify(&$alias, $source, $langcode) { function _pathauto_path_is_callback($path) { // We need to use a try/catch here because of a core bug which will throw an // exception if $path is something like 'node/foo/bar'. - // @todo Remove when http://drupal.org/node/1302158 is fixed in core. + // @todo Remove when http://drupal.org/node/1003788 is fixed in core. try { $menu = menu_get_item($path); } @@ -498,26 +523,19 @@ function _pathauto_path_is_callback($path) { * An optional string with the operation being performed. * * @return - * The saved path from path_save() or NULL if the path was not saved. + * The saved path from path_save() or FALSE if the path was not saved. * * @see path_save() */ function _pathauto_set_alias(array $path, $existing_alias = NULL, $op = NULL) { $verbose = _pathauto_verbose(NULL, $op); - // Alert users that an existing callback cannot be overridden automatically - if (_pathauto_path_is_callback($path['alias'])) { - if ($verbose) { - _pathauto_verbose(t('Ignoring alias %alias due to existing path conflict.', array('%alias' => $path['alias']))); - } - return; - } // Alert users if they are trying to create an alias that is the same as the internal path if ($path['source'] == $path['alias']) { if ($verbose) { _pathauto_verbose(t('Ignoring alias %alias because it is the same as the internal path.', array('%alias' => $path['alias']))); } - return; + return FALSE; } // Skip replacing the current alias with an identical alias @@ -529,7 +547,7 @@ function _pathauto_set_alias(array $path, $existing_alias = NULL, $op = NULL) { switch (variable_get('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE)) { case PATHAUTO_UPDATE_ACTION_NO_NEW: // Do not create the alias. - return; + return FALSE; case PATHAUTO_UPDATE_ACTION_LEAVE: // Create a new alias instead of overwriting the existing by leaving // $path['pid'] empty. @@ -605,7 +623,7 @@ function pathauto_clean_token_values(&$replacements, $data = array(), $options = foreach ($replacements as $token => $value) { // Only clean non-path tokens. if (!preg_match('/(path|alias|url|url-brief)\]$/', $token)) { - $replacements[$token] = pathauto_cleanstring($value); + $replacements[$token] = pathauto_cleanstring($value, $options); } } } diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.info b/sites/all/modules/contrib/content/pathauto/pathauto.info index 1488faa0..9a73e491 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.info +++ b/sites/all/modules/contrib/content/pathauto/pathauto.info @@ -3,13 +3,14 @@ description = Provides a mechanism for modules to automatically generate aliases dependencies[] = path dependencies[] = token core = 7.x +files[] = pathauto.migrate.inc files[] = pathauto.test configure = admin/config/search/path/patterns recommends[] = redirect -; Information added by drupal.org packaging script on 2012-08-09 -version = "7.x-1.2" +; Information added by Drupal.org packaging script on 2015-10-07 +version = "7.x-1.3" core = "7.x" project = "pathauto" -datestamp = "1344525185" +datestamp = "1444232655" diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.install b/sites/all/modules/contrib/content/pathauto/pathauto.install index cd5211cb..62a4ed24 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.install +++ b/sites/all/modules/contrib/content/pathauto/pathauto.install @@ -7,19 +7,59 @@ * @ingroup pathauto */ +/** + * Implements hook_schema(). + */ +function pathauto_schema() { + $schema['pathauto_state'] = array( + 'description' => 'The status of each entity alias (whether it was automatically generated or not).', + 'fields' => array( + 'entity_type' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'description' => 'An entity type.', + ), + 'entity_id' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'description' => 'An entity ID.', + ), + 'pathauto' => array( + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The automatic alias status of the entity.', + ), + ), + 'primary key' => array('entity_type', 'entity_id'), + ); + + return $schema; +} + + /** * Implements hook_install(). */ function pathauto_install() { // Set some default variables necessary for the module to perform. - variable_set('pathauto_node_pattern', 'content/[node:title]'); - variable_set('pathauto_taxonomy_term_pattern', '[term:vocabulary]/[term:name]'); - variable_set('pathauto_forum_pattern', '[term:vocabulary]/[term:name]'); - variable_set('pathauto_user_pattern', 'users/[user:name]'); - variable_set('pathauto_blog_pattern', 'blogs/[user:name]'); - - // Set the default separator character to replace instead of remove (default). - variable_set('pathauto_punctuation_hyphen', 1); + $defaults = array( + 'pathauto_node_pattern' => 'content/[node:title]', + 'pathauto_taxonomy_term_pattern' => '[term:vocabulary]/[term:name]', + 'pathauto_forum_pattern' => '[term:vocabulary]/[term:name]', + 'pathauto_user_pattern' => 'users/[user:name]', + 'pathauto_blog_pattern' => 'blogs/[user:name]', + // Set hyphen character to replace instead of remove. + 'pathauto_punctuation_hyphen' => 1, + ); + foreach ($defaults as $variable => $default) { + if (variable_get($variable) === NULL) { + variable_set($variable, $default); + } + } // Set the weight to 1 db_update('system') @@ -38,6 +78,23 @@ function pathauto_uninstall() { cache_clear_all('variables', 'cache'); } +/** + * Implements hook_requirements(). + */ +function pathauto_requirements($phase) { + $requirements = array(); + $t = get_t(); + if ($phase == 'runtime' && module_exists('pathauto_persist')) { + $requirements['pathauto'] = array( + 'title' => $t('Pathauto Persist'), + 'value' => $t('Enabled'), + 'description' => $t('Pathauto Persist is installed and enabled. As Pathauto Persist has been merged into Pathauto, the Pathauto Persist module can be safely disabled and removed. All Pathauto Persist settings have been migrated to the Pathauto implementation.'), + 'severity' => REQUIREMENT_INFO, + ); + } + return $requirements; +} + /** * Remove the unsupported user/%/contact and user/%/tracker pattern variables. */ @@ -168,6 +225,55 @@ function pathauto_update_7005() { return 'Your Pathauto taxonomy and forum patterns have been corrected. You may wish to regenerate your taxonomy and forum term URL aliases.'; } +/** + * Create pathauto_state table, using data from pathauto_persist if it exists. + */ +function pathauto_update_7006() { + if (!db_table_exists('pathauto_state')) { + + $schema['pathauto_state'] = array( + 'description' => 'The status of each entity alias (whether it was automatically generated or not).', + 'fields' => array( + 'entity_type' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'description' => 'The entity type.', + ), + 'entity_id' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'description' => 'The entity ID.', + ), + 'pathauto' => array( + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The automatic alias status of the entity.', + ), + ), + 'primary key' => array('entity_type', 'entity_id'), + ); + + if (db_table_exists('pathauto_persist')) { + // Rename pathauto_persist's table, then create a new empty one just so + // that we can cleanly disable that module. + db_rename_table('pathauto_persist', 'pathauto_state'); + db_create_table('pathauto_persist', $schema['pathauto_state']); + // Disable the module and inform the user. + if (module_exists('pathauto_persist')) { + module_disable(array('pathauto_persist')); + } + return t('The Pathauto Persist module and all of its data has been merged into Pathauto. The Pathauto Persist module has been disabled and can be safely uninstalled.'); + } + else { + db_create_table('pathauto_state', $schema['pathauto_state']); + } + } +} + /** * Build a list of Drupal 6 tokens and their Drupal 7 token names. */ diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.js b/sites/all/modules/contrib/content/pathauto/pathauto.js index be49cd63..52dcf12d 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.js +++ b/sites/all/modules/contrib/content/pathauto/pathauto.js @@ -3,13 +3,13 @@ Drupal.behaviors.pathFieldsetSummaries = { attach: function (context) { $('fieldset.path-form', context).drupalSetSummary(function (context) { - var path = $('.form-item-path-alias input').val(); - var automatic = $('.form-item-path-pathauto input').attr('checked'); + var path = $('.form-item-path-alias input', context).val(); + var automatic = $('.form-item-path-pathauto input', context).attr('checked'); if (automatic) { return Drupal.t('Automatic alias'); } - if (path) { + else if (path) { return Drupal.t('Alias: @alias', { '@alias': path }); } else { diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.migrate.inc b/sites/all/modules/contrib/content/pathauto/pathauto.migrate.inc new file mode 100644 index 00000000..bbb9f297 --- /dev/null +++ b/sites/all/modules/contrib/content/pathauto/pathauto.migrate.inc @@ -0,0 +1,56 @@ +registerTypes(array('entity')); + } + + /** + * Make the destination field visible. + */ + public function fields() { + return array( + 'pathauto' => t('Pathauto: Perform aliasing (set to 0 to prevent alias generation during migration'), + ); + } + + public function prepare($entity, stdClass $row) { + if (isset($entity->pathauto)) { + if (!isset($entity->path)) { + $entity->path = array(); + } + elseif (is_string($entity->path)) { + // If MigratePathEntityHandler->prepare() hasn't run yet, support + // the alias (set as $entity->path as a string) being formatted properly + // in the path alias array. + $path = $entity->path; + $entity->path = array(); + $entity->path['alias'] = $path; + } + $entity->path['pathauto'] = $entity->pathauto; + if (!isset($entity->path['alias'])) { + $entity->path['alias'] = ''; + } + unset($entity->pathauto); + } + } +} + +/* + * Implementation of hook_migrate_api(). + */ +function pathauto_migrate_api() { + $api = array( + 'api' => 2, + 'destination handlers' => array('PathautoMigrationHandler'), + ); + return $api; +} diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.module b/sites/all/modules/contrib/content/pathauto/pathauto.module index dffc2928..63058209 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.module +++ b/sites/all/modules/contrib/content/pathauto/pathauto.module @@ -26,30 +26,14 @@ define('PATHAUTO_IGNORE_WORDS', 'a, an, as, at, before, but, by, for, from, is, * Implements hook_hook_info(). */ function pathauto_hook_info() { - $info['pathauto'] = array('group' => 'pathauto'); - $info['path_alias_types'] = array('group' => 'pathauto'); - return $info; -} - -/** - * Implements hook_module_implements_alter(). - * - * Adds pathauto support for core modules. - */ -function pathauto_module_implements_alter(&$implementations, $hook) { - $hooks = pathauto_hook_info(); - if (isset($hooks[$hook])) { - $modules = array('node', 'taxonomy', 'user', 'forum', 'blog'); - foreach ($modules as $module) { - if (module_exists($module)) { - $implementations[$module] = TRUE; - } - } - // Move pathauto.module to get included first since it is responsible for - // other modules. - unset($implementations['pathauto']); - $implementations = array_merge(array('pathauto' => 'pathauto'), $implementations); - } + $hooks = array( + 'pathauto', + 'path_alias_types', + 'pathauto_pattern_alter', + 'pathauto_alias_alter', + 'pathauto_is_alias_reserved', + ); + return array_fill_keys($hooks, array('group' => 'pathauto')); } /** @@ -67,6 +51,9 @@ function pathauto_help($path, $arg) { $output .= '

' . t('The maximum alias length and maximum component length values default to 100 and have a limit of @max from Pathauto. This length is limited by the length of the "alias" column of the url_alias database table. The default database schema for this column is @max. If you set a length that is equal to that of the one set in the "alias" column it will cause problems in situations where the system needs to append additional words to the aliased URL. You should enter a value that is the length of the "alias" column minus the length of any strings that might get added to the end of the URL. The length of strings that might get added to the end of your URLs depends on which modules you have enabled and on your Pathauto settings. The recommended and default value is 100.', array('@max' => _pathauto_get_schema_alias_maxlength())) . '
'; $output .= ''; return $output; + case 'admin/config/search/path/update_bulk': + $output = '

' . t('Bulk generation will only generate URL aliases for items that currently have no aliases. This is typically used when installing Pathauto on a site that has existing un-aliased content that needs to be aliased in bulk.') . '

'; + return $output; } } @@ -109,7 +96,7 @@ function pathauto_menu() { 'file' => 'pathauto.admin.inc', ); $items['admin/config/search/path/update_bulk'] = array( - 'title' => 'Bulk update', + 'title' => 'Bulk generate', 'page callback' => 'drupal_get_form', 'page arguments' => array('pathauto_bulk_update_form'), 'access arguments' => array('administer url aliases'), @@ -295,9 +282,19 @@ function pathauto_field_attach_form($entity_type, $entity, &$form, &$form_state, if (!empty($id)) { module_load_include('inc', 'pathauto'); $uri = entity_uri($entity_type, $entity); - $path = drupal_get_path_alias($uri['path'], $langcode); $pathauto_alias = pathauto_create_alias($entity_type, 'return', $uri['path'], array($entity_type => $entity), $bundle, $langcode); - $entity->path['pathauto'] = ($path != $uri['path'] && $path == $pathauto_alias); + if ($pathauto_alias === FALSE) { + // If Pathauto is not going to be able to generate an alias, then we + // should not bother to show the checkbox since it wouldn't do anything. + // Note that if a pattern does apply, but all the tokens currently + // evaluate to empty strings, then $pathauto_alias would equal null and + // not false. + return; + } + else { + $path = drupal_get_path_alias($uri['path'], $langcode); + $entity->path['pathauto'] = ($path != $uri['path'] && $path == $pathauto_alias); + } } else { $entity->path['pathauto'] = TRUE; @@ -341,10 +338,54 @@ function pathauto_field_attach_form($entity_type, $entity, &$form, &$form_state, } } +/** + * Implements hook_entity_load(). + */ +function pathauto_entity_load($entities, $entity_type) { + // Statically cache which entity types have data in the pathauto_state + // table to avoid unnecessary queries for entities that would not have any + // data anyway. + static $loadable_types; + if (!isset($loadable_types)) { + $loadable_types = &drupal_static(__FUNCTION__); + if (!isset($loadable_types)) { + // Prevent errors if pathauto_update_7006() has not yet been run. + if (!db_table_exists('pathauto_state')) { + $loadable_types = array(); + } + else { + $loadable_types = db_query("SELECT DISTINCT entity_type FROM {pathauto_state}")->fetchCol(); + } + } + } + + // Check if this entity type has loadable records. + if (!in_array($entity_type, $loadable_types)) { + return; + } + + $states = pathauto_entity_state_load_multiple($entity_type, array_keys($entities)); + foreach ($states as $id => $state) { + if (!isset($entities[$id]->path)) { + $entities[$id]->path = array(); + } + + if (is_array($entities[$id]->path) && !isset($entities[$id]->path['pathauto'])) { + $entities[$id]->path['pathauto'] = $state; + } + } +} + /** * Implements hook_entity_presave(). */ -function pathauto_entity_presave($entity, $type) { +function pathauto_entity_presave($entity, $entity_type) { + if (isset($entity->path['pathauto']) && is_array($entity->path)) { + // We must set an empty alias string for the path to prevent saving an + // alias. + $entity->path += array('alias' => ''); + } + // About to be saved (before insert/update) if (!empty($entity->path['pathauto']) && isset($entity->path['old_alias']) && $entity->path['alias'] == '' && $entity->path['old_alias'] != '') { @@ -366,6 +407,109 @@ function pathauto_entity_presave($entity, $type) { } } +/** + * Implements hook_entity_insert(). + */ +function pathauto_entity_insert($entity, $entity_type) { + if (isset($entity->path['pathauto'])) { + pathauto_entity_state_save($entity_type, $entity, $entity->path['pathauto']); + } +} + +/** + * Implements hook_entity_update(). + */ +function pathauto_entity_update($entity, $entity_type) { + if (isset($entity->path['pathauto'])) { + pathauto_entity_state_save($entity_type, $entity, $entity->path['pathauto']); + } +} + +/** + * Implements hook_entity_delete(). + */ +function pathauto_entity_delete($entity, $entity_type) { + if (isset($entity->path['pathauto'])) { + pathauto_entity_state_delete($entity_type, $entity); + } +} + +/** + * Load a pathauto state for an entity. + * + * @param string $entity_type + * An entity type. + * @param int $entity_id + * An entity ID. + * + * @return bool + * A value that evaluates to TRUE if Pathauto should control this entity's + * path. A value that evaluates to FALSE if Pathauto should not manage the + * entity's path. + */ +function pathauto_entity_state_load($entity_type, $entity_id) { + $pathauto_state = pathauto_entity_state_load_multiple($entity_type, array($entity_id)); + return !empty($pathauto_state) ? reset($pathauto_state) : FALSE; +} + +/** + * Load a pathauto state for multiple entities. + * + * @param string $entity_type + * The entity type. + * @param int[] $entity_ids + * The array of entity IDs. + * + * @return bool[] + * An array of Pathauto states keyed by entity ID. + */ +function pathauto_entity_state_load_multiple($entity_type, $entity_ids) { + return db_query("SELECT entity_id, pathauto FROM {pathauto_state} WHERE entity_type = :entity_type AND entity_id IN (:entity_ids)", array(':entity_type' => $entity_type, ':entity_ids' => $entity_ids))->fetchAllKeyed(); +} + +/** + * Save the pathauto state for an entity. + * + * @param string $entity_type + * The entity type. + * @param object $entity + * The entity object. + * @param bool $pathauto_state + * A value that evaluates to TRUE means that Pathauto should keep controlling + * this entity's path in the future. A value that evaluates to FALSE means + * that Pathauto should not manage the entity's path. + */ +function pathauto_entity_state_save($entity_type, $entity, $pathauto_state) { + list($entity_id) = entity_extract_ids($entity_type, $entity); + db_merge('pathauto_state') + ->key(array( + 'entity_type' => $entity_type, + 'entity_id' => $entity_id, + )) + ->fields(array( + 'pathauto' => $pathauto_state ? 1 : 0, + )) + ->execute(); + drupal_static_reset('pathauto_entity_load'); +} + +/** + * Delete the pathauto state for an entity. + * + * @param string $entity_type + * The entity type. + * @param object $entity + * The entity object. + */ +function pathauto_entity_state_delete($entity_type, $entity) { + list($entity_id) = entity_extract_ids($entity_type, $entity); + db_delete('pathauto_state') + ->condition('entity_type', $entity_type) + ->condition('entity_id', $entity_id) + ->execute(); + drupal_static_reset('pathauto_entity_load'); +} + /** * Implements hook_action_info(). */ @@ -374,16 +518,19 @@ function pathauto_action_info() { 'type' => 'node', 'label' => t('Update node alias'), 'configurable' => FALSE, + 'triggers' => array(), ); $info['pathauto_taxonomy_term_update_action'] = array( 'type' => 'taxonomy_term', 'label' => t('Update taxonomy term alias'), 'configurable' => FALSE, + 'triggers' => array(), ); $info['pathauto_user_update_action'] = array( 'type' => 'user', 'label' => t('Update user alias'), 'configurable' => FALSE, + 'triggers' => array(), ); return $info; @@ -393,7 +540,7 @@ function pathauto_action_info() { * Returns the language code of the given entity. * * Backward compatibility layer to ensure that installations running an older - * version of core where entity_language() is not avilable do not break. + * version of core where entity_language() is not available do not break. * * @param string $entity_type * An entity type. @@ -417,6 +564,46 @@ function pathauto_entity_language($entity_type, $entity, $check_language_propert return !empty($langcode) ? $langcode : LANGUAGE_NONE; } +function pathauto_is_alias_reserved($alias, $source, $langcode = LANGUAGE_NONE) { + foreach (module_implements('pathauto_is_alias_reserved') as $module) { + $result = module_invoke($module, 'pathauto_is_alias_reserved', $alias, $source, $langcode); + if (!empty($result)) { + // As soon as the first module says that an alias is in fact reserved, + // then there is no point in checking the rest of the modules. + return TRUE; + } + } + + return FALSE; +} + +/** + * Implements hook_pathauto_is_alias_reserved() on behalf of path.module. + */ +function path_pathauto_is_alias_reserved($alias, $source, $langcode) { + // For language neutral content, we need to make sure the alias doesn't + // collide with any existing aliases. For localized content, just make sure + // it doesn't collide with same language or language neutral aliases. + $query = db_select('url_alias', 'ua') + ->fields('ua', array('pid')) + ->condition('source', $source, '<>') + ->condition('alias', $alias); + + if ($langcode != LANGUAGE_NONE) { + $query->condition('language', array($langcode, LANGUAGE_NONE), 'IN'); + } + + return $query->execute()->rowCount() > 0; +} + +/** + * Implements hook_pathauto_is_alias_reserved(). + */ +function pathauto_pathauto_is_alias_reserved($alias, $source, $langcode) { + module_load_include('inc', 'pathauto'); + return _pathauto_path_is_callback($alias); +} + if (!function_exists('path_field_extra_fields')) { /** * Implements hook_field_extra_fields() on behalf of path.module. @@ -459,6 +646,47 @@ function path_field_extra_fields() { * @{ */ +/** + * Implements hook_path_alias_types() on behalf of node module. + */ +function node_path_alias_types() { + return array('node/' => t('Content')); +} + +/** + * Implements hook_pathauto() on behalf of node module. + */ +function node_pathauto($op) { + if ($op == 'settings') { + $settings = array(); + $settings['module'] = 'node'; + $settings['token_type'] = 'node'; + $settings['groupheader'] = t('Content paths'); + $settings['patterndescr'] = t('Default path pattern (applies to all content types with blank patterns below)'); + $settings['patterndefault'] = 'content/[node:title]'; + $settings['batch_update_callback'] = 'node_pathauto_bulk_update_batch_process'; + $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; + + $languages = array(); + if (module_exists('locale')) { + $languages = array(LANGUAGE_NONE => t('language neutral')) + locale_language_list('name'); + } + + foreach (node_type_get_names() as $node_type => $node_name) { + if (count($languages) && variable_get('language_content_type_' . $node_type, 0)) { + $settings['patternitems'][$node_type] = t('Default path pattern for @node_type (applies to all @node_type content types with blank patterns below)', array('@node_type' => $node_name)); + foreach ($languages as $lang_code => $lang_name) { + $settings['patternitems'][$node_type . '_' . $lang_code] = t('Pattern for all @language @node_type paths', array('@node_type' => $node_name, '@language' => $lang_name)); + } + } + else { + $settings['patternitems'][$node_type] = t('Pattern for all @node_type paths', array('@node_type' => $node_name)); + } + } + return (object) $settings; + } +} + /** * Implements hook_node_insert(). */ @@ -517,20 +745,20 @@ function pathauto_node_operations() { */ function pathauto_node_update_alias(stdClass $node, $op, array $options = array()) { // Skip processing if the user has disabled pathauto for the node. - if (isset($node->path['pathauto']) && empty($node->path['pathauto'])) { - return; + if (isset($node->path['pathauto']) && empty($node->path['pathauto']) && empty($options['force'])) { + return FALSE; } $options += array('language' => pathauto_entity_language('node', $node)); // Skip processing if the node has no pattern. if (!pathauto_pattern_load_by_entity('node', $node->type, $options['language'])) { - return; + return FALSE; } module_load_include('inc', 'pathauto'); $uri = entity_uri('node', $node); - pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type, $options['language']); + return pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type, $options['language']); } /** @@ -573,6 +801,42 @@ function pathauto_node_update_action($node, $context = array()) { * @{ */ +/** + * Implements hook_path_alias_types() on behalf of taxonomy module. + */ +function taxonomy_path_alias_types() { + return array('taxonomy/term/' => t('Taxonomy terms')); +} + +/** + * Implements hook_pathauto() on behalf of taxonomy module. + */ +function taxonomy_pathauto($op) { + if ($op == 'settings') { + $settings = array(); + $settings['module'] = 'taxonomy_term'; + $settings['token_type'] = 'term'; + $settings['groupheader'] = t('Taxonomy term paths'); + $settings['patterndescr'] = t('Default path pattern (applies to all vocabularies with blank patterns below)'); + $settings['patterndefault'] = '[term:vocabulary]/[term:name]'; + $settings['batch_update_callback'] = 'taxonomy_pathauto_bulk_update_batch_process'; + $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; + + $vocabularies = taxonomy_get_vocabularies(); + if (count($vocabularies)) { + $settings['patternitems'] = array(); + foreach ($vocabularies as $vid => $vocabulary) { + if ($vid == variable_get('forum_nav_vocabulary', '')) { + // Skip the forum vocabulary. + continue; + } + $settings['patternitems'][$vocabulary->machine_name] = t('Pattern for all %vocab-name paths', array('%vocab-name' => $vocabulary->name)); + } + } + return (object) $settings; + } +} + /** * Implements hook_taxonomy_term_insert(). */ @@ -617,8 +881,8 @@ function pathauto_form_taxonomy_form_term_alter(&$form, $form_state) { */ function pathauto_taxonomy_term_update_alias(stdClass $term, $op, array $options = array()) { // Skip processing if the user has disabled pathauto for the term. - if (isset($term->path['pathauto']) && empty($term->path['pathauto'])) { - return; + if (isset($term->path['pathauto']) && empty($term->path['pathauto']) && empty($options['force'])) { + return FALSE; } $module = 'taxonomy_term'; @@ -627,7 +891,7 @@ function pathauto_taxonomy_term_update_alias(stdClass $term, $op, array $options $module = 'forum'; } else { - return; + return FALSE; } } @@ -644,21 +908,22 @@ function pathauto_taxonomy_term_update_alias(stdClass $term, $op, array $options // Skip processing if the term has no pattern. if (!pathauto_pattern_load_by_entity($module, $term->vocabulary_machine_name)) { - return; + return FALSE; } module_load_include('inc', 'pathauto'); $uri = entity_uri('taxonomy_term', $term); - pathauto_create_alias($module, $op, $uri['path'], array('term' => $term), $term->vocabulary_machine_name, $options['language']); + $result = pathauto_create_alias($module, $op, $uri['path'], array('term' => $term), $term->vocabulary_machine_name, $options['language']); if (!empty($options['alias children'])) { // For all children generate new aliases. - $options['alias children'] = FALSE; unset($options['language']); - foreach (taxonomy_get_tree($term->vid, $term->tid) as $subterm) { + foreach (taxonomy_get_children($term->tid, $term->vid) as $subterm) { pathauto_taxonomy_term_update_alias($subterm, $op, $options); } } + + return $result; } /** @@ -696,11 +961,68 @@ function pathauto_taxonomy_term_update_action($term, $context = array()) { * @} End of "name pathauto_taxonomy". */ +/** + * @name pathauto_forum Pathauto integration for the core forum module. + * @{ + */ + +/** + * Implements hook_path_alias_types() on behalf of forum module. + */ +function forum_path_alias_types() { + return array('forum/' => t('Forums')); +} + +/** + * Implements hook_pathauto() for forum module. + */ +function forum_pathauto($op) { + if ($op == 'settings') { + $settings = array(); + $settings['module'] = 'forum'; + $settings['token_type'] = 'term'; + $settings['groupheader'] = t('Forum paths'); + $settings['patterndescr'] = t('Pattern for forums and forum containers'); + $settings['patterndefault'] = '[term:vocabulary]/[term:name]'; + $settings['batch_update_callback'] = 'forum_pathauto_bulk_update_batch_process'; + $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; + return (object) $settings; + } +} + +/** + * @} End of "name pathauto_forum". + */ + /** * @name pathauto_user Pathauto integration for the core user and blog modules. * @{ */ +/** + * Implements hook_path_alias_types() on behalf of user module. + */ +function user_path_alias_types() { + return array('user/' => t('Users')); +} + +/** + * Implements hook_pathauto() on behalf of user module. + */ +function user_pathauto($op) { + if ($op == 'settings') { + $settings = array(); + $settings['module'] = 'user'; + $settings['token_type'] = 'user'; + $settings['groupheader'] = t('User paths'); + $settings['patterndescr'] = t('Pattern for user account page paths'); + $settings['patterndefault'] = 'users/[user:name]'; + $settings['batch_update_callback'] = 'user_pathauto_bulk_update_batch_process'; + $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; + return (object) $settings; + } +} + /** * Implements hook_user_insert(). */ @@ -748,8 +1070,8 @@ function pathauto_user_operations() { */ function pathauto_user_update_alias(stdClass $account, $op, array $options = array()) { // Skip processing if the user has disabled pathauto for the account. - if (isset($account->path['pathauto']) && empty($account->path['pathauto'])) { - return; + if (isset($account->path['pathauto']) && empty($account->path['pathauto']) && empty($options['force'])) { + return FALSE; } $options += array( @@ -761,17 +1083,19 @@ function pathauto_user_update_alias(stdClass $account, $op, array $options = arr // Skip processing if the account has no pattern. if (!pathauto_pattern_load_by_entity('user', '', $options['language'])) { - return; + return FALSE; } module_load_include('inc', 'pathauto'); $uri = entity_uri('user', $account); - pathauto_create_alias('user', $op, $uri['path'], array('user' => $account), NULL, $options['language']); + $return = pathauto_create_alias('user', $op, $uri['path'], array('user' => $account), NULL, $options['language']); // Because blogs are also associated with users, also generate the blog paths. if (!empty($options['alias blog'])) { pathauto_blog_update_alias($account, $op, $options); } + + return $return; } /** @@ -805,6 +1129,39 @@ function pathauto_user_update_action($account, $context = array()) { pathauto_user_update_alias($account, 'bulkupdate', array('message' => TRUE)); } +/** + * @} End of "name pathauto_user". + */ + +/** + * @name pathauto_blog Pathauto integration for the core blog module. + * @{ + */ + +/** + * Implements hook_path_alias_types() on behalf of blog module. + */ +function blog_path_alias_types() { + return array('blog/' => t('User blogs')); +} + +/** + * Implements hook_pathauto() on behalf of blog module. + */ +function blog_pathauto($op) { + if ($op == 'settings') { + $settings = array(); + $settings['module'] = 'blog'; + $settings['token_type'] = 'user'; + $settings['groupheader'] = t('Blog paths'); + $settings['patterndescr'] = t('Pattern for blog page paths'); + $settings['patterndefault'] = 'blogs/[user:name]'; + $settings['batch_update_callback'] = 'blog_pathauto_bulk_update_batch_process'; + $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; + return (object) $settings; + } +} + /** * Update the blog URL aliases for an individual user account. * @@ -819,7 +1176,7 @@ function pathauto_user_update_action($account, $context = array()) { function pathauto_blog_update_alias(stdClass $account, $op, array $options = array()) { // Skip processing if the blog has no pattern. if (!pathauto_pattern_load_by_entity('blog')) { - return; + return FALSE; } $options += array( @@ -828,7 +1185,7 @@ function pathauto_blog_update_alias(stdClass $account, $op, array $options = arr module_load_include('inc', 'pathauto'); if (node_access('create', 'blog', $account)) { - pathauto_create_alias('blog', $op, "blog/{$account->uid}", array('user' => $account), NULL, $options['language']); + return pathauto_create_alias('blog', $op, "blog/{$account->uid}", array('user' => $account), NULL, $options['language']); } else { pathauto_path_delete_all("blog/{$account->uid}"); @@ -836,5 +1193,30 @@ function pathauto_blog_update_alias(stdClass $account, $op, array $options = arr } /** - * @} End of "name pathauto_user". + * @} End of "name pathauto_blog". */ + +/** + * Implements hook_features_pipe_COMPONENT_alter(). + */ +function pathauto_features_pipe_node_alter(&$pipe, $data, $export) { + foreach ($data as $node_type) { + $pipe['variable'][] = "pathauto_node_{$node_type}_pattern"; + if (module_exists('locale')) { + $langcodes = array_keys(locale_language_list('name')); + $langcodes[] = LANGUAGE_NONE; + foreach ($langcodes as $langcode) { + $pipe['variable'][] = "pathauto_node_{$node_type}_{$langcode}_pattern"; + } + } + } +} + +/** + * Implements hook_features_pipe_COMPONENT_alter(). + */ +function pathauto_features_pipe_taxonomy_alter(&$pipe, $data, $export) { + foreach ($data as $vocabulary) { + $pipe['variable'][] = "pathauto_taxonomy_term_{$vocabulary}_pattern"; + } +} diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.pathauto.inc b/sites/all/modules/contrib/content/pathauto/pathauto.pathauto.inc index 28d3ce09..23df259c 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.pathauto.inc +++ b/sites/all/modules/contrib/content/pathauto/pathauto.pathauto.inc @@ -7,79 +7,6 @@ * @ingroup pathauto */ -/** - * Implements hook_path_alias_types(). - * - * Used primarily by the bulk delete form. - */ -function pathauto_path_alias_types() { - $objects['user/'] = t('Users'); - $objects['node/'] = t('Content'); - if (module_exists('blog')) { - $objects['blog/'] = t('User blogs'); - } - if (module_exists('taxonomy')) { - $objects['taxonomy/term/'] = t('Taxonomy terms'); - } - if (module_exists('forum')) { - $objects['forum/'] = t('Forums'); - } - return $objects; -} - -/** - * Implements hook_pathauto(). - * - * This function is empty so that the other core module implementations can be - * defined in this file. This is because in pathauto_module_implements_alter() - * we add pathauto to be included first. The module system then peforms a - * check on any subsequent run if this function still exists. If this does not - * exist, than this file will not get included and the core implementations - * will never get run. - * - * @see pathauto_module_implements_alter(). - */ -function pathauto_pathauto() { - // Empty hook; see the above comment. -} - -/** - * Implements hook_pathauto(). - */ -function node_pathauto($op) { - switch ($op) { - case 'settings': - $settings = array(); - $settings['module'] = 'node'; - $settings['token_type'] = 'node'; - $settings['groupheader'] = t('Content paths'); - $settings['patterndescr'] = t('Default path pattern (applies to all content types with blank patterns below)'); - $settings['patterndefault'] = 'content/[node:title]'; - $settings['batch_update_callback'] = 'node_pathauto_bulk_update_batch_process'; - $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; - - $languages = array(); - if (module_exists('locale')) { - $languages = array(LANGUAGE_NONE => t('language neutral')) + locale_language_list('name'); - } - - foreach (node_type_get_names() as $node_type => $node_name) { - if (count($languages) && variable_get('language_content_type_' . $node_type, 0)) { - $settings['patternitems'][$node_type] = t('Default path pattern for @node_type (applies to all @node_type content types with blank patterns below)', array('@node_type' => $node_name)); - foreach ($languages as $lang_code => $lang_name) { - $settings['patternitems'][$node_type . '_' . $lang_code] = t('Pattern for all @language @node_type paths', array('@node_type' => $node_name, '@language' => $lang_name)); - } - } - else { - $settings['patternitems'][$node_type] = t('Pattern for all @node_type paths', array('@node_type' => $node_name)); - } - } - return (object) $settings; - default: - break; - } -} - /** * Batch processing callback; Generate aliases for nodes. */ @@ -122,38 +49,6 @@ function node_pathauto_bulk_update_batch_process(&$context) { } } -/** - * Implements hook_pathauto(). - */ -function taxonomy_pathauto($op) { - switch ($op) { - case 'settings': - $settings = array(); - $settings['module'] = 'taxonomy_term'; - $settings['token_type'] = 'term'; - $settings['groupheader'] = t('Taxonomy term paths'); - $settings['patterndescr'] = t('Default path pattern (applies to all vocabularies with blank patterns below)'); - $settings['patterndefault'] = '[term:vocabulary]/[term:name]'; - $settings['batch_update_callback'] = 'taxonomy_pathauto_bulk_update_batch_process'; - $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; - - $vocabularies = taxonomy_get_vocabularies(); - if (count($vocabularies)) { - $settings['patternitems'] = array(); - foreach ($vocabularies as $vid => $vocabulary) { - if ($vid == variable_get('forum_nav_vocabulary', '')) { - // Skip the forum vocabulary. - continue; - } - $settings['patternitems'][$vocabulary->machine_name] = t('Pattern for all %vocab-name paths', array('%vocab-name' => $vocabulary->name)); - } - } - return (object) $settings; - default: - break; - } -} - /** * Batch processing callback; Generate aliases for taxonomy terms. */ @@ -200,26 +95,6 @@ function taxonomy_pathauto_bulk_update_batch_process(&$context) { } } -/** - * Implements hook_pathauto() for forum module. - */ -function forum_pathauto($op) { - switch ($op) { - case 'settings': - $settings = array(); - $settings['module'] = 'forum'; - $settings['token_type'] = 'term'; - $settings['groupheader'] = t('Forum paths'); - $settings['patterndescr'] = t('Pattern for forums and forum containers'); - $settings['patterndefault'] = '[term:vocabulary]/[term:name]'; - $settings['batch_update_callback'] = 'forum_pathauto_bulk_update_batch_process'; - $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; - return (object) $settings; - default: - break; - } -} - /** * Batch processing callback; Generate aliases for forums. */ @@ -263,26 +138,6 @@ function forum_pathauto_bulk_update_batch_process(&$context) { } } -/** - * Implements hook_pathauto(). - */ -function user_pathauto($op) { - switch ($op) { - case 'settings': - $settings = array(); - $settings['module'] = 'user'; - $settings['token_type'] = 'user'; - $settings['groupheader'] = t('User paths'); - $settings['patterndescr'] = t('Pattern for user account page paths'); - $settings['patterndefault'] = 'users/[user:name]'; - $settings['batch_update_callback'] = 'user_pathauto_bulk_update_batch_process'; - $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; - return (object) $settings; - default: - break; - } -} - /** * Batch processing callback; Generate aliases for users. */ @@ -325,26 +180,6 @@ function user_pathauto_bulk_update_batch_process(&$context) { } } -/** - * Implements hook_pathauto(). - */ -function blog_pathauto($op) { - switch ($op) { - case 'settings': - $settings = array(); - $settings['module'] = 'blog'; - $settings['token_type'] = 'user'; - $settings['groupheader'] = t('Blog paths'); - $settings['patterndescr'] = t('Pattern for blog page paths'); - $settings['patterndefault'] = 'blogs/[user:name]'; - $settings['batch_update_callback'] = 'blog_pathauto_bulk_update_batch_process'; - $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc'; - return (object) $settings; - default: - break; - } -} - /** * Batch processing callback; Generate aliases for blogs. */ diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.test b/sites/all/modules/contrib/content/pathauto/pathauto.test index 6fa096e8..298f8822 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.test +++ b/sites/all/modules/contrib/content/pathauto/pathauto.test @@ -55,9 +55,13 @@ class PathautoTestHelper extends DrupalWebTestCase { $this->assertEntityAlias($entity_type, $entity, $uri['path'], $language); } - function assertNoEntityAliasExists($entity_type, $entity) { + function assertNoEntityAliasExists($entity_type, $entity, $alias = NULL) { $uri = entity_uri($entity_type, $entity); - $this->assertNoAliasExists(array('source' => $uri['path'])); + $path = array('source' => $uri['path']); + if (!empty($alias)) { + $path['alias'] = $alias; + } + $this->assertNoAliasExists($path); } function assertAlias($source, $expected_alias, $language = LANGUAGE_NONE) { @@ -192,6 +196,23 @@ class PathautoUnitTestCase extends PathautoTestHelper { } } + /** + * Test pathauto_clean_alias(). + */ + function testCleanAlias() { + $tests = array(); + $tests['one/two/three'] = 'one/two/three'; + $tests['/one/two/three/'] = 'one/two/three'; + $tests['one//two///three'] = 'one/two/three'; + $tests['one/two--three/-/--/-/--/four---five'] = 'one/two-three/four-five'; + $tests['one/-//three--/four'] = 'one/three/four'; + foreach ($tests as $input => $expected) { + $output = pathauto_clean_alias($input); + $this->assertEqual($output, $expected, t("pathauto_clean_alias('@input') expected '@expected', actual '@output'", array('@input' => $input, '@expected' => $expected, '@output' => $output))); + } + + } + /** * Test pathauto_path_delete_multiple(). */ @@ -244,7 +265,7 @@ class PathautoUnitTestCase extends PathautoTestHelper { $node->title = 'Fifth title'; pathauto_node_update($node); $this->assertEntityAlias('node', $node, 'content/fourth-title'); - $this->assertNoAliasExists(array('alias' => 'content/fith-title')); + $this->assertNoAliasExists(array('alias' => 'content/fifth-title')); // Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'update'. $this->deleteAllAliases(); @@ -289,6 +310,40 @@ class PathautoUnitTestCase extends PathautoTestHelper { $this->assertEntityAlias('taxonomy_term', $term2, 'My Crazy/Alias/child-term'); } + /** + * Test using fields for path structures. + */ + function testParentChildPathTokens() { + // First create a field which will be used to create the path. It must + // begin with a letter. + $fieldname = 'a' . drupal_strtolower($this->randomName()); + field_create_field(array('field_name' => $fieldname, 'type' => 'text')); + field_create_instance(array('field_name' => $fieldname, 'entity_type' => 'taxonomy_term', 'bundle' => 'tags')); + + // Make the path pattern of a field use the value of this field appended + // to the parent taxonomy term's pattern if there is one. + variable_set('pathauto_taxonomy_term_tags_pattern', '[term:parents:join-path]/[term:' . $fieldname . ']'); + + // Start by creating a parent term. + $parent = new stdClass(); + $parent->$fieldname = array(LANGUAGE_NONE => array(array('value' => $parent->name = $this->randomName()))); + $parent->vid = 1; + taxonomy_term_save($parent); + + // Create the child term. + $child = new stdClass(); + $child->name = $this->randomName(); + $child->$fieldname = array(LANGUAGE_NONE => array(array('value' => $child->name = $this->randomName()))); + $child->vid = 1; + $child->parent = $parent->tid; + taxonomy_term_save($child); + $this->assertEntityAlias('taxonomy_term', $child, drupal_strtolower($parent->name . '/' . $child->name)); + + // Re-saving the parent term should not modify the child term's alias. + taxonomy_term_save($parent); + $this->assertEntityAlias('taxonomy_term', $child, drupal_strtolower($parent->name . '/' . $child->name)); + } + function testEntityBundleRenamingDeleting() { // Create a vocabulary and test that it's pattern variable works. $vocab = $this->addVocabulary(array('machine_name' => 'old_name')); @@ -315,17 +370,17 @@ class PathautoUnitTestCase extends PathautoTestHelper { // Check that Pathauto does not create an alias of '/admin'. $node = $this->drupalCreateNode(array('title' => 'Admin', 'type' => 'page')); - $this->assertNoEntityAlias('node', $node); + $this->assertEntityAlias('node', $node, 'admin-0'); // Check that Pathauto does not create an alias of '/modules'. $node->title = 'Modules'; node_save($node); - $this->assertNoEntityAlias('node', $node); + $this->assertEntityAlias('node', $node, 'modules-0'); // Check that Pathauto does not create an alias of '/index.php'. $node->title = 'index.php'; node_save($node); - $this->assertNoEntityAlias('node', $node); + $this->assertEntityAlias('node', $node, 'index.php-0'); // Check that a safe value gets an automatic alias. This is also a control // to ensure the above tests work properly. @@ -333,6 +388,18 @@ class PathautoUnitTestCase extends PathautoTestHelper { node_save($node); $this->assertEntityAlias('node', $node, 'safe-value'); } + + function testPathAliasUniquifyWordsafe() { + variable_set('pathauto_max_length', 25); + + $node_1 = $this->drupalCreateNode(array('title' => 'thequick brownfox jumpedover thelazydog', 'type' => 'page')); + $node_2 = $this->drupalCreateNode(array('title' => 'thequick brownfox jumpedover thelazydog', 'type' => 'page')); + + // Check that pathauto_alias_uniquify is calling truncate_utf8 with $wordsafe param set to TRUE. + // If it doesn't path alias result would be content/thequick-brownf-0 + $this->assertEntityAlias('node', $node_1, 'content/thequick-brownfox'); + $this->assertEntityAlias('node', $node_2, 'content/thequick-0'); + } } /** @@ -408,13 +475,23 @@ class PathautoFunctionalTestCase extends PathautoFunctionalTestHelper { $this->drupalGet($automatic_alias); $this->assertText($title, 'Node accessible through automatic alias.'); + // Disable the update action. The checkbox should not be visible. + variable_set('pathauto_update_action', 0); + $this->drupalGet("node/{$node->nid}/edit"); + $this->assertNoFieldById('edit-path-pathauto'); + + // Reset the update action back to default. The checkbox should be visible. + variable_del('pathauto_update_action'); + $this->drupalGet("node/{$node->nid}/edit"); + $this->assertFieldChecked('edit-path-pathauto'); + // Manually set the node's alias. $manual_alias = 'content/' . $node->nid; $edit = array( 'path[pathauto]' => FALSE, 'path[alias]' => $manual_alias, ); - $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save')); + $this->drupalPost(NULL, $edit, t('Save')); $this->assertText("Basic page $title has been updated."); // Check that the automatic alias checkbox is now unchecked by default. @@ -449,6 +526,26 @@ class PathautoFunctionalTestCase extends PathautoFunctionalTestHelper { $this->assertNoFieldById('edit-path-pathauto'); $this->assertFieldByName('path[alias]', ''); $this->assertNoEntityAlias('node', $node); + + // Set the page pattern to use only tokens so we can test the checkbox + // behavior if none of the tokens have a value currently. + variable_set('pathauto_node_page_pattern', '[node:title]'); + + // Create a node with an empty title. The Pathauto checkbox should still be + // visible but unchecked. + $node = $this->drupalCreateNode(array('type' => 'page', 'title' => '')); + $this->drupalGet('node/' . $node->nid . '/edit'); + $this->assertNoFieldChecked('edit-path-pathauto'); + $this->assertFieldByName('path[alias]', ''); + $this->assertNoEntityAlias('node', $node); + + $edit = array(); + $edit['title'] = 'Valid title'; + $edit['path[pathauto]'] = TRUE; + $this->drupalPost(NULL, $edit, t('Save')); + $this->drupalGet('node/' . $node->nid . '/edit'); + $this->assertFieldChecked('edit-path-pathauto'); + $this->assertFieldByName('path[alias]', 'valid-title'); } /** @@ -472,6 +569,83 @@ class PathautoFunctionalTestCase extends PathautoFunctionalTestHelper { $this->assertEntityAlias('node', $node2, 'node/' . $node2->nid); } + /** + * @todo Merge this with existing node test methods? + */ + public function testNodeState() { + $nodeNoAliasUser = $this->drupalCreateUser(array('bypass node access')); + $nodeAliasUser = $this->drupalCreateUser(array('bypass node access', 'create url aliases')); + + $node = $this->drupalCreateNode(array( + 'title' => 'Node version one', + 'type' => 'page', + 'path' => array( + 'pathauto' => FALSE, + ), + )); + + $this->assertNoEntityAlias('node', $node); + + // Set a manual path alias for the node. + $node->path['alias'] = 'test-alias'; + node_save($node); + + // Ensure that the pathauto field was saved to the database. + $node = node_load($node->nid, NULL, TRUE); + $this->assertFalse($node->path['pathauto']); + + // Ensure that the manual path alias was saved and an automatic alias was not generated. + $this->assertEntityAlias('node', $node, 'test-alias'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-one'); + + // Save the node as a user who does not have access to path fieldset. + $this->drupalLogin($nodeNoAliasUser); + $this->drupalGet('node/' . $node->nid . '/edit'); + $this->assertNoFieldByName('path[pathauto]'); + + $edit = array('title' => 'Node version two'); + $this->drupalPost(NULL, $edit, 'Save'); + $this->assertText('Basic page Node version two has been updated.'); + + $this->assertEntityAlias('node', $node, 'test-alias'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-one'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-two'); + + // Load the edit node page and check that the Pathauto checkbox is unchecked. + $this->drupalLogin($nodeAliasUser); + $this->drupalGet('node/' . $node->nid . '/edit'); + $this->assertNoFieldChecked('edit-path-pathauto'); + + // Edit the manual alias and save the node. + $edit = array( + 'title' => 'Node version three', + 'path[alias]' => 'manually-edited-alias', + ); + $this->drupalPost(NULL, $edit, 'Save'); + $this->assertText('Basic page Node version three has been updated.'); + + $this->assertEntityAlias('node', $node, 'manually-edited-alias'); + $this->assertNoEntityAliasExists('node', $node, 'test-alias'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-one'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-two'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-three'); + + // Programatically save the node with an automatic alias. + $node = node_load($node->nid, NULL, TRUE); + $node->path['pathauto'] = TRUE; + node_save($node); + + // Ensure that the pathauto field was saved to the database. + $node = node_load($node->nid, NULL, TRUE); + $this->assertTrue($node->path['pathauto']); + + $this->assertEntityAlias('node', $node, 'content/node-version-three'); + $this->assertNoEntityAliasExists('node', $node, 'manually-edited-alias'); + $this->assertNoEntityAliasExists('node', $node, 'test-alias'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-one'); + $this->assertNoEntityAliasExists('node', $node, 'content/node-version-two'); + } + /** * Basic functional testing of Pathauto with taxonomy terms. */ @@ -672,6 +846,14 @@ class PathautoLocaleTestCase extends PathautoFunctionalTestHelper { $this->assertEntityAlias('node', $node, 'content/english-node-0', 'en'); $this->assertEntityAlias('node', $node, 'french-node', 'fr'); $this->assertAliasExists(array('pid' => $english_alias['pid'], 'alias' => 'content/english-node-0')); + + // Create a new node with the same title as before but without + // specifying a language. + $node = $this->drupalCreateNode(array('title' => 'English node')); + + // Check that the new node had a unique alias generated with the '-1' + // suffix. + $this->assertEntityAlias('node', $node, 'content/english-node-1'); } } @@ -718,11 +900,11 @@ class PathautoBulkUpdateTestCase extends PathautoFunctionalTestHelper { // Add a new node. $new_node = $this->drupalCreateNode(array('path' => array('alias' => '', 'pathauto' => FALSE))); - // Run the update again which should only run against the new node. + // Run the update again which should not run against any nodes. $this->drupalPost('admin/config/search/path/update_bulk', $edit, t('Update')); - $this->assertText('Generated 1 URL alias.'); // 1 node + 0 users + $this->assertText('No new URL aliases to generate.'); - $this->assertEntityAliasExists('node', $new_node); + $this->assertNoEntityAliasExists('node', $new_node); } } diff --git a/sites/all/modules/contrib/content/pathauto/pathauto.tokens.inc b/sites/all/modules/contrib/content/pathauto/pathauto.tokens.inc index a0f0b49b..dabcaa88 100644 --- a/sites/all/modules/contrib/content/pathauto/pathauto.tokens.inc +++ b/sites/all/modules/contrib/content/pathauto/pathauto.tokens.inc @@ -35,7 +35,7 @@ function pathauto_tokens($type, $tokens, array $data = array(), array $options = $values = array(); foreach (element_children($array) as $key) { $value = is_array($array[$key]) ? render($array[$key]) : (string) $array[$key]; - $value = pathauto_cleanstring($value); + $value = pathauto_cleanstring($value, $options); $values[] = $value; } $replacements[$original] = implode('/', $values); diff --git a/sites/all/modules/contrib/fields/addressfield/addresses.txt b/sites/all/modules/contrib/fields/addressfield/addresses.txt index e64b8202..1f11bd89 100644 --- a/sites/all/modules/contrib/fields/addressfield/addresses.txt +++ b/sites/all/modules/contrib/fields/addressfield/addresses.txt @@ -1,298 +1,298 @@ -AT NULL Feldkirch NULL 6800 Pater Grimm Weg 20 -AU NULL Melbourne NULL -AU NULL Sydney NULL -AU 04 NULL NORMANBY NULL 4059 30 Normanby Terrace -BD NULL Dhaka NULL 1205 23, Subal Das Road, Chowdhury Bazar, Lalbagh -BD NULL Dhaka NULL 1207 R-1,H-19,Kallaynpur,Mirpur,Dhaka -BD NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar -BD NULL Dhaka NULL 1209 House# 66B, Flat# B2 Zigatola -BD NULL Dhaka NULL 1219 390 West Rampura Dhaka -BD NULL Dhaka NULL 1230 Uttara -BD 81 NULL Dhaka NULL 1000 Institute of Water and Flood Management -BD 81 NULL Dhaka NULL 1203 84/a maniknagar -BD 81 NULL Dhaka NULL 1205 Dhaka Bangladesh -BD 81 NULL Dhaka NULL 1207 BetterStories Limited 17 West Panthopath -BD 81 NULL Dhaka NULL 1216 Mirpur, Dhaka -BD 81 NULL Dhaka NULL 1230 830, Prembagan, Dhakshin Khan -BD 82 NULL khulna NULL 9203 -BD NULL NULL Dhaka NULL 1000 Institute of Water and Flood Management -BD NULL NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar -BE NULL Brussels NULL -BE NULL Watermael-Boitsfort NULL 1170 Avenue des Staphylins -BH NULL Manama NULL 00973 Manama Bahrain Manama Bahrain -BR NULL Porto Alegre NULL -BR NULL Recife NULL -BR RJ NULL Rio de Janeiro NULL -BW NULL Francistown NULL NULL -BW NULL NULL Francistown NULL NULL -CA NULL Montreal NULL -CA NULL Toronto NULL -CA BC NULL Vancouver NULL -CA ON NULL Kitchener NULL -CA ON NULL wterloo NULL n2l3g1 200 University Avenue West -CH NULL Geneva NULL 1202 15, chemin Louis-Dunant -CH 25 NULL Zurich NULL 8098 UBS Optimus Foundation Augustinerhof 1 -DE NULL Berlin NULL -DE 05 NULL Frankfurt am Main NULL 60386 Johanna-Tesch-Platz 7 -DK NULL Aarhus NULL -ES NULL Bilbao NULL -ET 44 NULL ADDIS ABABA NULL 11945 ADDIS ABABA,P.O.BOX 11945 -FI NULL Espoo NULL 02130 Mahlarinne 3B -FI NULL Helsinki NULL 00580 Hermannin rantatie 2 A Hermannin rantatie 2 A -FI NULL Tampere NULL 33101 Tampere Univerity of Technology -FI 13 NULL Espoo NULL 02150 Aalto Venture Garage Betonimiehenkuja 3 -GB NULL Exeter NULL -GB NULL London NULL -GB NULL London NULL N4 2DP 2 Myddleton Ave -GB NULL London NULL N7 0AH 104 St George’s Avenue -GB NULL London NULL SE16 3UL 25 Blue Anchor Lane -GB NULL London NULL SW18 5SP Flat 1 150 Merton road -GB NULL London NULL W1T 4BQ 13 Fitzroy Street -GB NULL Oxford NULL -GB NULL Southampton NULL -GB C3 NULL NULL cb244qg 32 market street swavesey -GB E7 NULL London NULL SE3 7TP -GB F3 NULL Wood Green NULL N22 5RU 6 Cedar House -GB H1 NULL London NULL SE11 5JD 47-49 Durham Street -GB H6 NULL London NULL SE8 4DD 8 Harton St Deptford -GB K2 NULL Oxford NULL OX2 6QY 3 The Villas, Rutherway -GH 05 NULL NSAWAM NULL NULL P.O.BOX 455 -GH NULL NULL Accra NULL NULL -ID NULL Bandung NULL 40134 Jalan Sadang Hegar 1 No. 12 RT04 RW13 Sadang Serang -ID NULL Bekasi NULL 17411 Jl.Binadharma 1 No.62. Jatiwaringin -ID NULL Jakarta NULL -ID NULL Jakarta NULL 12440 Jl. H. Niin 7 Lebak Bulus, Cilandak -ID NULL Jakarta NULL 13330 Otista -ID NULL Jakarta selatan NULL 12000 jl. rawa jati timur 6 no. 10 -ID NULL Jakarta Timur NULL Jl.Mulia No.15B Kel.Bidara Cina, Kec.Jatinegara, Jakarta Timur -ID NULL Pematang Siantar NULL 51511 Jl. Durian I 30 -ID 04 NULL Bogor NULL 16165 -ID 04 NULL jakarta NULL otista -ID 04 NULL Jakarta NULL 12520 Jl. Pertanian Raya III No.42 Jakarta Selatan Pasar Minggu -ID 04 NULL Jakarta NULL 13330 Jakarta -ID 04 NULL Jakarta NULL 13330 Jl Sensus IIC Bidaracina Jaktim -ID 04 NULL Jakarta NULL 13330 Jl. Bonasut 2 no.22 -ID 04 NULL Jakarta NULL 13330 Otista 64c -ID 04 NULL jakarta NULL 13330 Otista jaktim -ID 04 NULL Jakarta Timur NULL 13330 Kebon Sayur I no. 1 RT 10/15 -ID 04 NULL Jakarta Timur NULL 13460 Jl. Pondok Kopi Blok G4/5 RT. 005/08 Jakarta Timur -ID 04 NULL Jakarta Timur NULL 13810 Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur -ID 07 NULL Brebes NULL 54321 Jl Kersem Blok D14 Perum Taman Indo Kaligangsa Wetan Brebes -ID 07 NULL Semarang NULL 50143 Puspowarno Tengah 2/2 -ID 08 NULL Lumajang NULL 67373 Desa Tumpeng Kecamatan Candipuro Lumajang -ID 30 NULL Bandung NULL 55241 Jl Pelesiran No 55A/56 -ID 30 NULL Bekasi NULL 17510 bekasi West Java Indonesia -ID 30 NULL Depok NULL 16245 Jalan juragan sinda 2 no 10 -ID 30 NULL Depok NULL 16424 Jalan Margonda RayaJalan Kober Gang Mawar -ID 30 NULL Depok NULL 16424 Jl. Haji Yahya Nuih no.24, Pondok Cina -ID 30 NULL Depok NULL 16425 Kukusan Kelurahan -ID 30 NULL Depok NULL 16518 Jl. Salak No.1/C.88 Durenseribu Bojongsari -ID 30 NULL Depok NULL 16952 Jl. Merak No.34 -36 Rt.004/014 Jl. Merak No. 34 -36 Rt. 004/014 -ID 36 NULL biak numfor NULL 98111 jl. s. mamberamo no 6782 biak numfor -IL NULL Tel Aviv NULL -IN NULL Bangalore NULL -IN NULL India NULL -IN NULL new delhi NULL 110003 55 lodi estate -IN 07 NULL NEW DELHI NULL 110018 15/11 A 1ST FLOOR TILAK NAGAR -IN 07 NULL New Delhu NULL 110075 B 54 Hilansh Apartments Plot No 1, Sector 10, Dwarka -IN 10 NULL Gurgaon NULL D- 201 Ivy Apartments Sushant Lok 1 Gurgaon Haryana -IN 13 NULL Trivandrum NULL 695010 TC 9/1615, SRMH Road, Sasthamangalam, Trivandrum -IN 16 NULL Mumbai NULL 400020 Bharat Mahal, Flat#55 Marine Drive -IN 16 NULL Mumbai NULL 400028 303,Shree Parvati Co-Op Housing Society, D.L.Vaidya Road,Dadar -IN 16 NULL Pune NULL -IN 16 NULL Pune NULL Infosys Campus Hinjewadi Phase 2 -IN 16 NULL Pune NULL 400705 #22 Iris Garden Gokhale Road -IN 16 NULL PUNE NULL 411043 -IN 16 NULL Pune NULL 411051 -IN 16 NULL Pune NULL 411057 Infosys Ltd. Rajiv gandhi infostech park Hinjewadi phase 2 -IN 16 NULL Pune NULL 412108 Pune Maharatshtra -IN 16 NULL Pune NULL 433011 502 utkarsh vihar golande state pune -IN 19 NULL Bangalore NULL 560080 Indian Institute for Human Settlements IIHS Bangalore City Campus, Sadashivanagar, -IN 19 NULL Bangalore NULL 560100 electronic city -IN 19 NULL Bhalki NULL 585411 bhalki,bidar ,karnataka karnataka -IN 24 NULL Jaipur NULL 302011 Institute of Health Management Research 1, Prabhu Dayal Marg -IR 26 NULL Tehran NULL 1118844454 Baharestan sq. mostafa khomeini str., javahery Ave., no. 11, -IT NULL Trento NULL -JM 08 NULL Kingston NULL Kgn 7 MOna Campus UWI -KE NULL Nairobi NULL -KE 05 NULL Nairobi NULL 30300 212,kapsabet -KH NULL NULL Phnom Penh NULL -LR NULL Monrovia NULL 00000 -NG 11 NULL Abuja NULL 930001 17 Bechar street Wuse zone 2 -PE 15 NULL Lima NULL 18 Lima Lima -PE 15 NULL Lima NULL Lima 18 123 Miraflores -PE NULL NULL Lima NULL 03 Calle Granada 104 -PE NULL NULL Lima NULL 18 Lima Lima -PH NULL Manila NULL Globe Telepark 111 Valero Street -PH NULL Quezon Coty NULL 1109 86 Harvard Street, Cubao, Quezon City, Philippines 84 Harvard Street, Cubao, Quezon City,hilippines -PH 20 NULL Silang NULL 4118 370 Bayungan Kaong Silang Cavite -PH 57 NULL Kidapawan NULL 9400 Kidapawan City Kidapawan City -PH 66 NULL zamboanga NULL 7000 29-tripplet rd san jose 29-tripplet rd san jose -PH D9 NULL Pasig City NULL World Bank Office Manila, 20/F Taipan Place F. Ortigas Jr. Road, Ortigas Center -PK NULL Lahore NULL 54000 17-R Model Town Lahore -PK NULL Lahore NULL 54000 53- chamber lane road Lahore -PK NULL Lahore NULL 54000 85 E block Model Town -PK NULL Lahore NULL 54000 House no 227, street no 5, Imamia Colony Shahadra Lahore -PK NULL LAHORE NULL 54000 room no.6 khalid bim waleed hall, near New Anarkali, LAHORE room no.6 khalid bim waleed hall, near New Anarkali, LAHORE -PK NULL Lahore NULL pk097 LUMS, Lahore, -PK NULL Sheikhupura NULL 03935 D.H.Q.Hospital Sheikhupura House number 08. Room no 109 Khalid bin waleed haal, punjab University lahore old campus. -PK 02 NULL Quetta NULL 87000 Postal Address 87000, Kuchlak, Quetta, Balochistan. H#24 Peer Abul Khair road Quetta, Balochistan. -PK 02 NULL Quetta NULL 87300 block no-1 falt no. 7 New Crime Branch Abbas Ali Road Cantt -PK 02 NULL Quetta NULL 87300 Flat no. 3 Shafeen Centre Jinnah Town ,Near I.T university , Quetta -PK 02 NULL Quetta NULL 87300 H-no. C-220 Zarghoonabad Phase-2 , Nawa Killi ,Quetta -PK 04 NULL burewala NULL 60101 Fatima Fayyaz Hazrat Sakina hall girls hostel number 9 Punjab university Lahore Pakistan Sardar Wajid Azim Azeem abad Burewala dist Vehari Pakistan -PK 04 NULL Faisalabad NULL 38000 P 101/1, Green Town, Millat Road, Faisalabad -PK 04 NULL Islamabad NULL 44000 P.O Tarlai kalan chappar Islamabad -PK 04 NULL lahore NULL -PK 04 NULL Lahore NULL 54000 -PK 04 NULL lahore NULL 54000 Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. -PK 04 NULL Lahore NULL 54000 1149-1-D2 Green Town Lahore -PK 04 NULL Lahore NULL 54000 124, street# 2, karim block Allama Iqbal Town lahore. 124, street# 2, karim block Allama Iqbal Town lahore. -PK 04 NULL Lahore NULL 54000 150 A Qila Lachman Singh Ravi Road lahore -PK 04 NULL Lahore NULL 54000 166/1L DHA Lahore -PK 04 NULL Lahore NULL 54000 172 A2 Township Lahore -PK 04 NULL Lahore NULL 54000 183,S/Block, Model Town, Lhr -PK 04 NULL lahore NULL 54000 19- A block ,Eden Lane Villas Raiwind Road ,Lahore -PK 04 NULL lahore NULL 54000 3-c kaliyar road opposite kids lyceum, rustam park near mor samnabad -PK 04 NULL Lahore NULL 54000 31 Saeed Block, Canal Bank Scheme -PK 04 NULL Lahore NULL 54000 31c DHA Lahore -PK 04 NULL Lahore NULL 54000 387 E1 wapda town, Lahore -PK 04 NULL Lahore NULL 54000 45-D dha eme sector multan road,lahore -PK 04 NULL Lahore NULL 54000 5 Zafar Ali Road -PK 04 NULL Lahore NULL 54000 54-R PGECHS -PK 04 NULL lahore NULL 54000 566 E-1 johar town lahore 566 E-1 johar town lahore -PK 04 NULL Lahore NULL 54000 82/1 Z Block, Phase 3 DHA -PK 04 NULL Lahore NULL 54000 A-1 VRI Zarrar shaheed road lahore cantt A-1 VRI Zarrar shaheed road lahore cantt -PK 04 NULL lahore NULL 54000 e5/39D street 6 zaman colony cavalry ground ext -PK 04 NULL Lahore NULL 54000 Ho # 61, Block G3, Johar Town Lahore -PK 04 NULL LAhore NULL 54000 House #19-A street #5 Usman nagr Ghaziabad Lahore -PK 04 NULL lahore NULL 54000 House no 692 street no 67 sadar bazar -PK 04 NULL Lahore NULL 54000 Khosa Law Chamber 1 Turner Road -PK 04 NULL Lahore NULL 54000 Lahore,Pakistan Lahore,Pakistan -PK 04 NULL Lahore NULL 54000 room no 69, khalid bin waleed hall, anarkali -PK 04 NULL Lahore NULL 54000 Suite # 8, Al-Hafeez Suites, Gulberg II -PK 04 NULL Lahore NULL 54085 199 Shadman 2 -PK 04 NULL Lahore NULL 54300 Mughalpura Lahore Pakistan -PK 04 NULL Lahore NULL 54660 SD 69 falcon complex gulberg III lahore -PK 04 NULL lahore NULL 54800 764-G4 johar town ,lahore -PK 04 NULL Rawalpindi NULL 44000 House 522, F-Block Sattellite Town, Rawalpindi -PK 04 NULL Rawalpindi NULL 46000 1950/c, Indusroad 2, Tariqabad, Rawalpindi Cantt -PK 04 NULL Rawalpindi NULL 46000 House 54-E Lane 9 Sector 4, AECHS Chaklala Rawalpindi -PK 04 NULL Rawalpindi NULL 46000 House B-1343, Sattellite town Rawalpindi -PK 04 NULL Rawalpindi NULL 46000 House CB-299F, Street 1, Lane 4 Peshawar Road Rawalpindi -PK 04 NULL Rawalpindi NULL 46300 House No 1518 Umer Block phase 8 BehriaTown -PK 04 NULL sialkot NULL 51310 The National Model School, Ismaiealabad, Pacca Garah Sialkot -PK 08 NULL Islamabad NULL CIomsats Institute of Information Technology Islamabad -PK 08 NULL Islamabad NULL 38700 COMSATS tarlai boys hostel Islamabad. COMSATS tarlai boys hostel Islamabad (Room 30) -PK 08 NULL Islamabad NULL 44000 -PK 08 NULL Islamabad NULL 44000 House # 256, Street # 9, Shahzad Town, Islamabad. -PK 08 NULL Islamabad NULL 44000 Islamabad , Comsats University Islamabd ,Pakistan -PK 08 NULL Islamabad NULL 44000 World Bank Building Sector G 5 -PK 08 NULL lahore NULL 54000 3c zafar ali road gulburg 5 3c zafar ali road gulburg 5 -PK 08 NULL lahore NULL 54000 49-a bilal park, chaburgy 49-a bilal park, chaburgy -PK NULL NULL Lahore NULL 54000 -PK NULL NULL Lahore NULL 54000 85 E block Model Town -SN 01 NULL NULL ouakam cité comico en face 217 -SN 01 NULL Dakar NULL -SN 01 NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 -SN 01 NULL Dakar NULL liberte 6/ dakar -SN 01 NULL Dakar NULL ngor -SN 01 NULL Dakar NULL 4027 ZAC Mbao Cité Fadia -SN NULL NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 -TZ NULL Dar es Salaam NULL NULL -TZ NULL Dar es salaam NULL NULL 76021 Dar es salaam 1507 Morogoro -TZ NULL Dar es salaam NULL NULL dar es salaam nassoro.ahmedy@yahoo.com -TZ NULL DAR ES SALAAM NULL NULL dar es salaam UDSM -TZ NULL Dar es salaam NULL NULL NA -TZ NULL DAR ES SALAAM NULL NULL P O BOX 23409 -TZ NULL dar es salaam NULL NULL p. o. box 104994 -TZ NULL Dar es Salaam NULL NULL P.o. BOX 71415 Dar es Salaam -TZ NULL Dar es Salaam NULL NULL P.O.BOx 66675 DSM -TZ NULL Dar es salaam NULL NULL Tz Tz -TZ NULL dsm NULL NULL -TZ 02 NULL Bagamoyo NULL NULL PO.Box 393 -TZ 02 NULL Dar es salaam NULL NULL 22548 -TZ 03 NULL Dar-es-salaam NULL NULL Dodoma Municipal Kimara, Dar-es-salaa, -TZ 23 NULL Dar es Salaam NULL NULL -TZ 23 NULL dar es salaam NULL NULL 35074 -TZ 23 NULL dar es salaam NULL NULL 67389 -TZ 23 NULL Dar es Salaam NULL NULL COSTECH, Dar es Salaam, Tanzania -TZ 23 NULL Dar es salaam NULL NULL na -TZ 23 NULL dar es salaam NULL NULL p o box 60164 -TZ 23 NULL dar es salaam NULL NULL P. O. Box 77588 -TZ 23 NULL dar es salaam NULL NULL P.O BOX 78144 -TZ 23 NULL Dar es Salaam NULL NULL P.O.BOX 78373 -TZ 23 NULL Dar es salaam NULL NULL UDSM Dar es Salaam -TZ 23 NULL Dar es salaam NULL NULL udsm udsm -TZ 23 NULL Temeke NULL NULL P.O. Box 50127 -TZ NULL NULL Dar es Salaam NULL NULL -TZ NULL NULL Dar es Salaam NULL NULL Kigoma -TZ NULL NULL Dar es Salaam NULL NULL Mwanza -UG NULL Kampala NULL NULL -UG NULL Kampala NULL NULL Kampala Uganda East Africa -US NULL London NULL SE1 8RT Capital Tower 91 Waterloo Road -US CA NULL Los Angeles NULL -US CA NULL Pleasanton NULL 94588 3412 Pickens Lane -US CA NULL Sacramento NULL -US CA NULL San Francisco NULL -US CA NULL seattle NULL 98113 1234 1st st -US CO NULL Denver NULL 80235 6666 West Quincy Ave -US CT NULL Greenwich NULL 06830 140 Milbank -US CT NULL Hartford NULL 06106 Center for Urban and Global Studies at Trinity College, 70 Vernon Street -US DC NULL Washington NULL -US DC NULL Washington NULL 20007 World Bank Headquarters 1818 H Street NW -US DC NULL Washington NULL 20010 -US DC NULL Washington NULL 20036 -US DC NULL Washington NULL 20405 1889 F St NW -US DC NULL Washington NULL 20433 -US DC NULL Washington NULL 20433 1818 H Street NW -US DC NULL Washington NULL 20433 1818H St -US DC NULL Washington NULL 20433 1818 H Street NW -US DC NULL Washington DC NULL 20005 1424, K Street, NW Suite 600 -US DC NULL Washington DC NULL 20010 1818 H Street, NW -US DC NULL Washington, DC NULL 20003 1818 H Street NW -US DE NULL Virgin Islands|Charlotte Amalie,Cruz Bay,Christiansted NULL Morocco|Tafraout,Rabat,Tangier,Tetouan,Casablanca,Marrakesh,Fez,Oujda,Meknes,Agadir United Arab Emirates|Garhoud,Dubai,Bur Dubai,Ras al Khaymah,Abu Dhabi,Ajman,Al Fujayrah,Sharjah -US FL NULL Falmouth NULL Falmouth Falmouth -US FL NULL Lilongwe NULL Lilongwe Lilongwe -US GA NULL Atlanta NULL -US GU NULL Herndon NULL 15642 Ht USA -US GU NULL Miami NULL Miami Miami -US MD NULL Gaithersburg NULL 20877 554 N Frederick Avenue Suite 216 -US MD NULL Potomac NULL 20854 14 Sandalfoot Court -US MD NULL Silver Spring NULL 20901 9202 Whitney St. -US MI NULL Traverse City NULL 49685 PO Box 792 -US ND NULL Pirassununga NULL Pirassununga Pirassununga -US NJ NULL Princeton NULL -US NY NULL Brooklyn NULL 11206-1980 25 Montrose Ave. Apt 304 -US NY NULL Brooklyn NULL 11225 975 washington ave 2d -US NY NULL Brooklyn NULL 11217 150 4TH AVE APT 9E -US NY NULL New York NULL -US NY NULL New York NULL 10013 148 Lafayette St. PH -US NY NULL New York NULL 10017 UNICEF 3 UN Plaza -US NY NULL New York NULL 10019 25 Columbus Circle Suite 52E -US NY NULL New York NULL 10024 65 West 85th Street 3A -US NY NULL New York NULL 10027 606 W. 116th Street #22 -US NY NULL New York NULL 10037 -US NY NULL Rochester NULL -US NY NULL Scarsdale NULL 10583-1423 54 Walworth Avenue -US OR NULL Portland NULL -US PA NULL Philadelphia NULL -US PA NULL Philadelphia NULL -US PR NULL Colonel Hill NULL Colonel Hill Colonel Hill -US SD NULL Banjul NULL Banjul Banjul -US SD NULL London NULL London London -US TX NULL Aledo NULL 76008 1588 Hunterglenn Dr -US TX NULL Keller NULL 76248 810 Placid View Ct. -US WA NULL Seattle NULL -ZA NULL Cape Town NULL -ZA NULL Cape Town NULL 7945 Alexander Road Muizenberg -ZA NULL Pretoria NULL -ZA 11 NULL Cape Town NULL -ZA 11 NULL Cape Town NULL 7435 PostNet Suite #57, Private Bag X18 Milnerton -ZA 11 NULL Cape town NULL 7508 24 Solyet Court, Lansdowne Road Claremont -ZA 11 NULL Cape Town NULL 7701 -ZA 11 NULL Cape Town NULL 7785 10 Nyamakazi Road Luzuko Park Phillipi East -ZA 11 NULL Cape Town NULL 7915 66 Albert Rd -ZA 11 NULL Cape Town NULL 8001 210 Long Street -ZM NULL Lusaka NULL -ZM 09 NULL LUSAKA NULL 10101 P.O. BOX FW 174 +AT NULL Feldkirch NULL 6800 Pater Grimm Weg 20 NULL +AU NULL Melbourne NULL NULL +AU NULL Sydney NULL NULL +AU 4 NULL NORMANBY NULL 4059 30 Normanby Terrace NULL +BD NULL Dhaka NULL 1205 23, Subal Das Road, Chowdhury Bazar, Lalbagh NULL +BD NULL Dhaka NULL 1207 R-1,H-19,Kallaynpur,Mirpur,Dhaka NULL +BD NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar NULL +BD NULL Dhaka NULL 1209 House# 66B, Flat# B2 Zigatola NULL +BD NULL Dhaka NULL 1219 390 West Rampura Dhaka NULL +BD NULL Dhaka NULL 1230 Uttara NULL +BD 81 NULL Dhaka NULL 1000 Institute of Water and Flood Management NULL +BD 81 NULL Dhaka NULL 1203 84/a maniknagar NULL +BD 81 NULL Dhaka NULL 1205 Dhaka Bangladesh NULL +BD 81 NULL Dhaka NULL 1207 BetterStories Limited 17 West Panthopath NULL +BD 81 NULL Dhaka NULL 1216 Mirpur, Dhaka NULL +BD 81 NULL Dhaka NULL 1230 830, Prembagan, Dhakshin Khan NULL +BD 82 NULL khulna NULL 9203 NULL +BD NULL NULL Dhaka NULL 1000 Institute of Water and Flood Management NULL +BD NULL NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar NULL +BE NULL Brussels NULL NULL +BE NULL Watermael-Boitsfort NULL 1170 Avenue des Staphylins NULL +BH NULL Manama NULL 973 Manama Bahrain Manama Bahrain NULL +BR NULL Porto Alegre NULL NULL +BR NULL Recife NULL NULL +BR RJ NULL Rio de Janeiro NULL NULL +BW NULL Francistown NULL NULL NULL +BW NULL NULL Francistown NULL NULL NULL +CA NULL Montreal NULL NULL +CA NULL Toronto NULL NULL +CA BC NULL Vancouver NULL NULL +CA ON NULL Kitchener NULL NULL +CA ON NULL wterloo NULL n2l3g1 200 University Avenue West NULL +CH NULL Geneva NULL 1202 15, chemin Louis-Dunant NULL +CH 25 NULL Zurich NULL 8098 UBS Optimus Foundation Augustinerhof 1 NULL +DE NULL Berlin NULL NULL +DE 5 NULL Frankfurt am Main NULL 60386 Johanna-Tesch-Platz 7 NULL +DK NULL Aarhus NULL NULL +ES NULL Bilbao NULL NULL +ET 44 NULL ADDIS ABABA NULL 11945 ADDIS ABABA,P.O.BOX 11945 NULL +FI NULL Espoo NULL 2130 Mahlarinne 3B NULL +FI NULL Helsinki NULL 580 Hermannin rantatie 2 A Hermannin rantatie 2 A NULL +FI NULL Tampere NULL 33101 Tampere University of Technology NULL +FI 13 NULL Espoo NULL 2150 Aalto Venture Garage Betonimiehenkuja 3 NULL +GB NULL Exeter NULL NULL +GB NULL London NULL NULL +GB NULL London NULL N4 2DP 2 Myddleton Ave NULL +GB NULL London NULL N7 0AH 104 St George’s Avenue NULL +GB NULL London NULL SE16 3UL 25 Blue Anchor Lane NULL +GB NULL London NULL SW18 5SP Flat 1 150 Merton road NULL +GB NULL London NULL W1T 4BQ 13 Fitzroy Street NULL +GB NULL Oxford NULL NULL +GB NULL Southampton NULL NULL +GB C3 NULL NULL cb244qg 32 market street swavesey NULL +GB E7 NULL London NULL SE3 7TP NULL +GB F3 NULL Wood Green NULL N22 5RU 6 Cedar House NULL +GB H1 NULL London NULL SE11 5JD 47-49 Durham Street NULL +GB H6 NULL London NULL SE8 4DD 8 Harton St Deptford NULL +GB K2 NULL Oxford NULL OX2 6QY 3 The Villas, Rutherway NULL +GH 5 NULL NSAWAM NULL NULL P.O.BOX 455 NULL +GH NULL NULL Accra NULL NULL NULL +ID NULL Bandung NULL 40134 Jalan Sadang Hegar 1 No. 12 RT04 RW13 Sadang Serang NULL +ID NULL Bekasi NULL 17411 Jl.Binadharma 1 No.62. Jatiwaringin NULL +ID NULL Jakarta NULL NULL +ID NULL Jakarta NULL 12440 Jl. H. Niin 7 Lebak Bulus, Cilandak NULL +ID NULL Jakarta NULL 13330 Otista NULL +ID NULL Jakarta selatan NULL 12000 jl. rawa jati timur 6 no. 10 NULL +ID NULL Jakarta Timur NULL Jl.Mulia No.15B Kel.Bidara Cina, Kec.Jatinegara, Jakarta Timur NULL +ID NULL Pematang Siantar NULL 51511 Jl. Durian I 30 NULL +ID 4 NULL Bogor NULL 16165 NULL +ID 4 NULL jakarta NULL otista NULL +ID 4 NULL Jakarta NULL 12520 Jl. Pertanian Raya III No.42 Jakarta Selatan Pasar Minggu NULL +ID 4 NULL Jakarta NULL 13330 Jakarta NULL +ID 4 NULL Jakarta NULL 13330 Jl Sensus IIC Bidaracina Jaktim NULL +ID 4 NULL Jakarta NULL 13330 Jl. Bonasut 2 no.22 NULL +ID 4 NULL Jakarta NULL 13330 Otista 64c NULL +ID 4 NULL jakarta NULL 13330 Otista jaktim NULL +ID 4 NULL Jakarta Timur NULL 13330 Kebon Sayur I no. 1 RT 10/15 NULL +ID 4 NULL Jakarta Timur NULL 13460 Jl. Pondok Kopi Blok G4/5 RT. 005/08 Jakarta Timur NULL +ID 4 NULL Jakarta Timur NULL 13810 Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur NULL +ID 7 NULL Brebes NULL 54321 Jl Kersem Blok D14 Perum Taman Indo Kaligangsa Wetan Brebes NULL +ID 7 NULL Semarang NULL 50143 Puspowarno Tengah 2/2 NULL +ID 8 NULL Lumajang NULL 67373 Desa Tumpeng Kecamatan Candipuro Lumajang NULL +ID 30 NULL Bandung NULL 55241 Jl Pelesiran No 55A/56 NULL +ID 30 NULL Bekasi NULL 17510 bekasi West Java Indonesia NULL +ID 30 NULL Depok NULL 16245 Jalan juragan sinda 2 no 10 NULL +ID 30 NULL Depok NULL 16424 Jalan Margonda RayaJalan Kober Gang Mawar NULL +ID 30 NULL Depok NULL 16424 Jl. Haji Yahya Nuih no.24, Pondok Cina NULL +ID 30 NULL Depok NULL 16425 Kukusan Kelurahan NULL +ID 30 NULL Depok NULL 16518 Jl. Salak No.1/C.88 Durenseribu Bojongsari NULL +ID 30 NULL Depok NULL 16952 Jl. Merak No.34 -36 Rt.004/014 Jl. Merak No. 34 -36 Rt. 004/014 NULL +ID 36 NULL biak numfor NULL 98111 jl. s. mamberamo no 6782 biak numfor NULL +IL NULL Tel Aviv NULL NULL +IN NULL Bangalore NULL NULL +IN NULL India NULL NULL +IN NULL new delhi NULL 110003 55 lodi estate NULL +IN 7 NULL NEW DELHI NULL 110018 15/11 A 1ST FLOOR TILAK NAGAR NULL +IN 7 NULL New Delhu NULL 110075 B 54 Hilansh Apartments Plot No 1, Sector 10, Dwarka NULL +IN 10 NULL Gurgaon NULL D- 201 Ivy Apartments Sushant Lok 1 Gurgaon Haryana NULL +IN 13 NULL Trivandrum NULL 695010 TC 9/1615, SRMH Road, Sasthamangalam, Trivandrum NULL +IN 16 NULL Mumbai NULL 400020 Bharat Mahal, Flat#55 Marine Drive NULL +IN 16 NULL Mumbai NULL 400028 303,Shree Parvati Co-Op Housing Society, D.L.Vaidya Road,Dadar NULL +IN 16 NULL Pune NULL NULL +IN 16 NULL Pune NULL Infosys Campus Hinjewadi Phase 2 NULL +IN 16 NULL Pune NULL 400705 #22 Iris Garden Gokhale Road NULL +IN 16 NULL PUNE NULL 411043 NULL +IN 16 NULL Pune NULL 411051 NULL +IN 16 NULL Pune NULL 411057 Infosys Ltd. Rajiv gandhi infostech park Hinjewadi phase 2 NULL +IN 16 NULL Pune NULL 412108 Pune Maharatshtra NULL +IN 16 NULL Pune NULL 433011 502 utkarsh vihar golande state pune NULL +IN 19 NULL Bangalore NULL 560080 Indian Institute for Human Settlements IIHS Bangalore City Campus, Sadashivanagar, NULL +IN 19 NULL Bangalore NULL 560100 electronic city NULL +IN 19 NULL Bhalki NULL 585411 bhalki,bidar ,karnataka karnataka NULL +IN 24 NULL Jaipur NULL 302011 Institute of Health Management Research 1, Prabhu Dayal Marg NULL +IR 26 NULL Tehran NULL 1118844454 Baharestan sq. mostafa khomeini str., javahery Ave., no. 11, NULL +IT NULL Trento NULL NULL +JM 8 NULL Kingston NULL Kgn 7 MOna Campus UWI NULL +KE NULL Nairobi NULL NULL +KE 5 NULL Nairobi NULL 30300 212,kapsabet NULL +KH NULL NULL Phnom Penh NULL NULL +LR NULL Monrovia NULL 0 NULL +NG 11 NULL Abuja NULL 930001 17 Bechar street Wuse zone 2 NULL +PE 15 NULL Lima NULL 18 Lima Lima NULL +PE 15 NULL Lima NULL Lima 18 123 Miraflores NULL +PE NULL NULL Lima NULL 3 Calle Granada 104 NULL +PE NULL NULL Lima NULL 18 Lima Lima NULL +PH NULL Manila NULL Globe Telepark 111 Valero Street NULL +PH NULL Quezon Coty NULL 1109 86 Harvard Street, Cubao, Quezon City, Philippines 84 Harvard Street, Cubao, Quezon City,hilippines NULL +PH 20 NULL Silang NULL 4118 370 Bayungan Kaong Silang Cavite NULL +PH 57 NULL Kidapawan NULL 9400 Kidapawan City Kidapawan City NULL +PH 66 NULL zamboanga NULL 7000 29-tripplet rd san jose 29-tripplet rd san jose NULL +PH D9 NULL Pasig City NULL World Bank Office Manila, 20/F Taipan Place F. Ortigas Jr. Road, Ortigas Center NULL +PK NULL Lahore NULL 54000 17-R Model Town Lahore NULL +PK NULL Lahore NULL 54000 53- chamber lane road Lahore NULL +PK NULL Lahore NULL 54000 85 E block Model Town NULL +PK NULL Lahore NULL 54000 House no 227, street no 5, Imamia Colony Shahadra Lahore NULL +PK NULL LAHORE NULL 54000 room no.6 khalid bim waleed hall, near New Anarkali, LAHORE room no.6 khalid bim waleed hall, near New Anarkali, LAHORE NULL +PK NULL Lahore NULL pk097 LUMS, Lahore, NULL +PK NULL Sheikhupura NULL 3935 D.H.Q.Hospital Sheikhupura House number 08. Room no 109 Khalid bin waleed haal, punjab University lahore old campus. NULL +PK 2 NULL Quetta NULL 87000 Postal Address 87000, Kuchlak, Quetta, Balochistan. H#24 Peer Abul Khair road Quetta, Balochistan. NULL +PK 2 NULL Quetta NULL 87300 block no-1 falt no. 7 New Crime Branch Abbas Ali Road Cantt NULL +PK 2 NULL Quetta NULL 87300 Flat no. 3 Shafeen Centre Jinnah Town ,Near I.T university , Quetta NULL +PK 2 NULL Quetta NULL 87300 H-no. C-220 Zarghoonabad Phase-2 , Nawa Killi ,Quetta NULL +PK 4 NULL burewala NULL 60101 Fatima Fayyaz Hazrat Sakina hall girls hostel number 9 Punjab university Lahore Pakistan Sardar Wajid Azim Azeem abad Burewala dist Vehari Pakistan NULL +PK 4 NULL Faisalabad NULL 38000 P 101/1, Green Town, Millat Road, Faisalabad NULL +PK 4 NULL Islamabad NULL 44000 P.O Tarlai kalan chappar Islamabad NULL +PK 4 NULL lahore NULL NULL +PK 4 NULL Lahore NULL 54000 NULL +PK 4 NULL lahore NULL 54000 Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. NULL +PK 4 NULL Lahore NULL 54000 1149-1-D2 Green Town Lahore NULL +PK 4 NULL Lahore NULL 54000 124, street# 2, karim block Allama Iqbal Town lahore. 124, street# 2, karim block Allama Iqbal Town lahore. NULL +PK 4 NULL Lahore NULL 54000 150 A Qila Lachman Singh Ravi Road lahore NULL +PK 4 NULL Lahore NULL 54000 166/1L DHA Lahore NULL +PK 4 NULL Lahore NULL 54000 172 A2 Township Lahore NULL +PK 4 NULL Lahore NULL 54000 183,S/Block, Model Town, Lhr NULL +PK 4 NULL lahore NULL 54000 19- A block ,Eden Lane Villas Raiwind Road ,Lahore NULL +PK 4 NULL lahore NULL 54000 3-c kaliyar road opposite kids lyceum, rustam park near mor samnabad NULL +PK 4 NULL Lahore NULL 54000 31 Saeed Block, Canal Bank Scheme NULL +PK 4 NULL Lahore NULL 54000 31c DHA Lahore NULL +PK 4 NULL Lahore NULL 54000 387 E1 wapda town, Lahore NULL +PK 4 NULL Lahore NULL 54000 45-D dha eme sector multan road,lahore NULL +PK 4 NULL Lahore NULL 54000 5 Zafar Ali Road NULL +PK 4 NULL Lahore NULL 54000 54-R PGECHS NULL +PK 4 NULL lahore NULL 54000 566 E-1 johar town lahore 566 E-1 johar town lahore NULL +PK 4 NULL Lahore NULL 54000 82/1 Z Block, Phase 3 DHA NULL +PK 4 NULL Lahore NULL 54000 A-1 VRI Zarrar shaheed road lahore cantt A-1 VRI Zarrar shaheed road lahore cantt NULL +PK 4 NULL lahore NULL 54000 e5/39D street 6 zaman colony cavalry ground ext NULL +PK 4 NULL Lahore NULL 54000 Ho # 61, Block G3, Johar Town Lahore NULL +PK 4 NULL LAhore NULL 54000 House #19-A street #5 Usman nagr Ghaziabad Lahore NULL +PK 4 NULL lahore NULL 54000 House no 692 street no 67 sadar bazar NULL +PK 4 NULL Lahore NULL 54000 Khosa Law Chamber 1 Turner Road NULL +PK 4 NULL Lahore NULL 54000 Lahore,Pakistan Lahore,Pakistan NULL +PK 4 NULL Lahore NULL 54000 room no 69, khalid bin waleed hall, anarkali NULL +PK 4 NULL Lahore NULL 54000 Suite # 8, Al-Hafeez Suites, Gulberg II NULL +PK 4 NULL Lahore NULL 54085 199 Shadman 2 NULL +PK 4 NULL Lahore NULL 54300 Mughalpura Lahore Pakistan NULL +PK 4 NULL Lahore NULL 54660 SD 69 falcon complex gulberg III lahore NULL +PK 4 NULL lahore NULL 54800 764-G4 johar town ,lahore NULL +PK 4 NULL Rawalpindi NULL 44000 House 522, F-Block Sattellite Town, Rawalpindi NULL +PK 4 NULL Rawalpindi NULL 46000 1950/c, Indusroad 2, Tariqabad, Rawalpindi Cantt NULL +PK 4 NULL Rawalpindi NULL 46000 House 54-E Lane 9 Sector 4, AECHS Chaklala Rawalpindi NULL +PK 4 NULL Rawalpindi NULL 46000 House B-1343, Sattellite town Rawalpindi NULL +PK 4 NULL Rawalpindi NULL 46000 House CB-299F, Street 1, Lane 4 Peshawar Road Rawalpindi NULL +PK 4 NULL Rawalpindi NULL 46300 House No 1518 Umer Block phase 8 BehriaTown NULL +PK 4 NULL sialkot NULL 51310 The National Model School, Ismaiealabad, Pacca Garah Sialkot NULL +PK 8 NULL Islamabad NULL CIomsats Institute of Information Technology Islamabad NULL +PK 8 NULL Islamabad NULL 38700 COMSATS tarlai boys hostel Islamabad. COMSATS tarlai boys hostel Islamabad (Room 30) NULL +PK 8 NULL Islamabad NULL 44000 NULL +PK 8 NULL Islamabad NULL 44000 House # 256, Street # 9, Shahzad Town, Islamabad. NULL +PK 8 NULL Islamabad NULL 44000 Islamabad , Comsats University Islamabd ,Pakistan NULL +PK 8 NULL Islamabad NULL 44000 World Bank Building Sector G 5 NULL +PK 8 NULL lahore NULL 54000 3c zafar ali road gulburg 5 3c zafar ali road gulburg 5 NULL +PK 8 NULL lahore NULL 54000 49-a bilal park, chaburgy 49-a bilal park, chaburgy NULL +PK NULL NULL Lahore NULL 54000 NULL +PK NULL NULL Lahore NULL 54000 85 E block Model Town NULL +SN 1 NULL NULL ouakam cité comico en face 217 NULL +SN 1 NULL Dakar NULL NULL +SN 1 NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 NULL +SN 1 NULL Dakar NULL liberte 6/ dakar NULL +SN 1 NULL Dakar NULL ngor NULL +SN 1 NULL Dakar NULL 4027 ZAC Mbao Cité Fadia NULL +SN NULL NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 NULL +TZ NULL Dar es Salaam NULL NULL NULL +TZ NULL Dar es salaam NULL NULL 76021 Dar es salaam 1507 Morogoro NULL +TZ NULL Dar es salaam NULL NULL dar es salaam nassoro.ahmedy@yahoo.com NULL +TZ NULL DAR ES SALAAM NULL NULL dar es salaam UDSM NULL +TZ NULL Dar es salaam NULL NULL NA NULL +TZ NULL DAR ES SALAAM NULL NULL P O BOX 23409 NULL +TZ NULL dar es salaam NULL NULL p. o. box 104994 NULL +TZ NULL Dar es Salaam NULL NULL P.o. BOX 71415 Dar es Salaam NULL +TZ NULL Dar es Salaam NULL NULL P.O.BOx 66675 DSM NULL +TZ NULL Dar es salaam NULL NULL Tz Tz NULL +TZ NULL dsm NULL NULL NULL +TZ 2 NULL Bagamoyo NULL NULL PO.Box 393 NULL +TZ 2 NULL Dar es salaam NULL NULL 22548 NULL +TZ 3 NULL Dar-es-salaam NULL NULL Dodoma Municipal Kimara, Dar-es-salaa, NULL +TZ 23 NULL Dar es Salaam NULL NULL NULL +TZ 23 NULL dar es salaam NULL NULL 35074 NULL +TZ 23 NULL dar es salaam NULL NULL 67389 NULL +TZ 23 NULL Dar es Salaam NULL NULL COSTECH, Dar es Salaam, Tanzania NULL +TZ 23 NULL Dar es salaam NULL NULL na NULL +TZ 23 NULL dar es salaam NULL NULL p o box 60164 NULL +TZ 23 NULL dar es salaam NULL NULL P. O. Box 77588 NULL +TZ 23 NULL dar es salaam NULL NULL P.O BOX 78144 NULL +TZ 23 NULL Dar es Salaam NULL NULL P.O.BOX 78373 NULL +TZ 23 NULL Dar es salaam NULL NULL UDSM Dar es Salaam NULL +TZ 23 NULL Dar es salaam NULL NULL udsm udsm NULL +TZ 23 NULL Temeke NULL NULL P.O. Box 50127 NULL +TZ NULL NULL Dar es Salaam NULL NULL NULL +TZ NULL NULL Dar es Salaam NULL NULL Kigoma NULL +TZ NULL NULL Dar es Salaam NULL NULL Mwanza NULL +UG NULL Kampala NULL NULL NULL +UG NULL Kampala NULL NULL Kampala Uganda East Africa NULL +US NULL London NULL SE1 8RT Capital Tower 91 Waterloo Road NULL +US CA NULL Los Angeles NULL NULL +US CA NULL Pleasanton NULL 94588 3412 Pickens Lane NULL +US CA NULL Sacramento NULL NULL +US CA NULL San Francisco NULL NULL +US CA NULL seattle NULL 98113 1234 1st st NULL +US CO NULL Denver NULL 80235 6666 West Quincy Ave NULL +US CT NULL Greenwich NULL 6830 140 Milbank NULL +US CT NULL Hartford NULL 6106 Center for Urban and Global Studies at Trinity College, 70 Vernon Street NULL +US DC NULL Washington NULL NULL +US DC NULL Washington NULL 20007 World Bank Headquarters 1818 H Street NW NULL +US DC NULL Washington NULL 20010 NULL +US DC NULL Washington NULL 20036 NULL +US DC NULL Washington NULL 20405 1889 F St NW NULL +US DC NULL Washington NULL 20433 NULL +US DC NULL Washington NULL 20433 1818 H Street NW NULL +US DC NULL Washington NULL 20433 1818H St NULL +US DC NULL Washington NULL 20433 1818 H Street NW NULL +US DC NULL Washington DC NULL 20005 1424, K Street, NW Suite 600 NULL +US DC NULL Washington DC NULL 20010 1818 H Street, NW NULL +US DC NULL Washington, DC NULL 20003 1818 H Street NW NULL +US DE NULL Virgin Islands|Charlotte Amalie,Cruz Bay,Christiansted NULL Morocco|Tafraout,Rabat,Tangier,Tetouan,Casablanca,Marrakesh,Fez,Oujda,Meknes,Agadir United Arab Emirates|Garhoud,Dubai,Bur Dubai,Ras al Khaymah,Abu Dhabi,Ajman,Al Fujayrah,Sharjah NULL +US FL NULL Falmouth NULL Falmouth Falmouth NULL +US FL NULL Lilongwe NULL Lilongwe Lilongwe NULL +US GA NULL Atlanta NULL NULL +US GU NULL Herndon NULL 15642 Ht USA NULL +US GU NULL Miami NULL Miami Miami NULL +US MD NULL Gaithersburg NULL 20877 554 N Frederick Avenue Suite 216 NULL +US MD NULL Potomac NULL 20854 14 Sandalfoot Court NULL +US MD NULL Silver Spring NULL 20901 9202 Whitney St. NULL +US MI NULL Traverse City NULL 49685 PO Box 792 NULL +US ND NULL Pirassununga NULL Pirassununga Pirassununga NULL +US NJ NULL Princeton NULL NULL +US NY NULL Brooklyn NULL 11206-1980 25 Montrose Ave. Apt 304 NULL +US NY NULL Brooklyn NULL 11225 975 washington ave 2d NULL +US NY NULL Brooklyn NULL 11217 150 4TH AVE APT 9E NULL +US NY NULL New York NULL NULL +US NY NULL New York NULL 10013 148 Lafayette St. PH NULL +US NY NULL New York NULL 10017 UNICEF 3 UN Plaza NULL +US NY NULL New York NULL 10019 25 Columbus Circle Suite 52E NULL +US NY NULL New York NULL 10024 65 West 85th Street 3A NULL +US NY NULL New York NULL 10027 606 W. 116th Street #22 NULL +US NY NULL New York NULL 10037 NULL +US NY NULL Rochester NULL NULL +US NY NULL Scarsdale NULL 10583-1423 54 Walworth Avenue NULL +US OR NULL Portland NULL NULL +US PA NULL Philadelphia NULL NULL +US PA NULL Philadelphia NULL NULL +US PR NULL Colonel Hill NULL Colonel Hill Colonel Hill NULL +US SD NULL Banjul NULL Banjul Banjul NULL +US SD NULL London NULL London London NULL +US TX NULL Aledo NULL 76008 1588 Hunterglenn Dr NULL +US TX NULL Keller NULL 76248 810 Placid View Ct. NULL +US WA NULL Seattle NULL NULL +ZA NULL Cape Town NULL NULL +ZA NULL Cape Town NULL 7945 Alexander Road Muizenberg NULL +ZA NULL Pretoria NULL NULL +ZA 11 NULL Cape Town NULL NULL +ZA 11 NULL Cape Town NULL 7435 PostNet Suite #57, Private Bag X18 Milnerton NULL +ZA 11 NULL Cape town NULL 7508 24 Solyet Court, Lansdowne Road Claremont NULL +ZA 11 NULL Cape Town NULL 7701 NULL +ZA 11 NULL Cape Town NULL 7785 10 Nyamakazi Road Luzuko Park Phillipi East NULL +ZA 11 NULL Cape Town NULL 7915 66 Albert Rd NULL +ZA 11 NULL Cape Town NULL 8001 210 Long Street NULL +ZM NULL Lusaka NULL NULL +ZM 9 NULL LUSAKA NULL 10101 P.O. BOX FW 174 NULL diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc index 793e2f1e..19e7958b 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.address_formats.inc @@ -41,11 +41,11 @@ function addressfield_get_address_format($country_code) { // 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', + 'CR', 'CY', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE', 'GN', 'GT', 'GW', 'HR', 'HT', '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', + 'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'VA', 'VC', 'VG', 'XK', 'ZM', ); foreach ($countries_with_optional_postal_code as $code) { $address_formats[$code] = array( @@ -56,9 +56,9 @@ function addressfield_get_address_format($country_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', + 'AT', 'AX', 'BE', 'BL', 'CH', 'CZ', 'DE', 'DK', 'FI', 'FK', 'FR', 'GF', 'GG', 'GL', 'GP', 'GR', 'GS', 'HU', 'IM', 'IO', 'JE', 'LI', 'LU', 'MF', 'MQ', 'NC', - 'NL', 'NO', 'PL', 'PM', 'PN', 'PT', 'RE', 'SE', 'SH', 'SJ', 'TC', 'WF', + 'NL', 'NO', 'PL', 'PM', 'PN', 'PT', 'RE', 'SE', 'SH', 'SJ', 'SK', 'TC', 'WF', 'YT', ); foreach ($countries_with_required_postal_code as $code) { @@ -114,7 +114,7 @@ function addressfield_get_address_format($country_code) { 'used_fields' => array('locality', 'administrative_area', 'postal_code'), ); $address_formats['CL'] = array( - 'used_fields' => array('locality', 'administrative_area', 'postal_code'), + 'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'), 'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')), 'render_administrative_area_value' => TRUE, ); @@ -124,7 +124,7 @@ function addressfield_get_address_format($country_code) { 'dependent_locality_label' => t('District'), ); $address_formats['CO'] = array( - 'used_fields' => array('locality', 'administrative_area'), + 'used_fields' => array('locality', 'administrative_area', 'postal_code'), 'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')), ); $address_formats['CV'] = array( @@ -235,6 +235,7 @@ function addressfield_get_address_format($country_code) { 'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'), 'required_fields' => array('locality', 'administrative_area', 'postal_code'), 'dependent_locality_label' => t('District'), + 'render_administrative_area_value' => TRUE, ); $address_formats['KY'] = array( 'used_fields' => array('administrative_area', 'postal_code'), diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc index 88343de9..aa6ebad6 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.administrative_areas.inc @@ -11,6 +11,29 @@ * NULL if not found. */ function addressfield_get_administrative_areas($country_code) { + // Maintain a static cache to avoid passing the administrative areas through + // t() more than once per request. + $administrative_areas = &drupal_static(__FUNCTION__, array()); + if (empty($administrative_areas)) { + // Get the default administrative areas. + $administrative_areas = _addressfield_get_administrative_areas_defaults(); + + // 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; +} + +/** + * Provides the default administrative areas. + */ +function _addressfield_get_administrative_areas_defaults() { + // To avoid needless pollution of the strings list we only pass to t() + // those administrative areas that are in English (or a latin transcription), + // and belong to a country that either has multiple official languages (CA) + // or uses a non-latin script (AE, CN, JP, KR, UA, RU, etc). + // No translation is expected in other cases. $administrative_areas = array(); $administrative_areas['AE'] = array( 'AZ' => t('Abu Dhabi'), @@ -22,69 +45,69 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'B' => 'Buenos Aires', + 'K' => 'Catamarca', + 'H' => 'Chaco', + 'U' => 'Chubut', + 'C' => 'Ciudad de Buenos Aires', + 'X' => 'Córdoba', + 'W' => 'Corrientes', + 'E' => 'Entre Ríos', + 'P' => 'Formosa', + 'Y' => 'Jujuy', + 'L' => 'La Pampa', + 'F' => 'La Rioja', + 'M' => 'Mendoza', + 'N' => 'Misiones', + 'Q' => 'Neuquén', + 'R' => 'Río Negro', + 'A' => 'Salta', + 'J' => 'San Juan', + 'D' => 'San Luis', + 'Z' => 'Santa Cruz', + 'S' => 'Santa Fe', + 'G' => 'Santiago del Estero', + 'V' => 'Tierra del Fuego', + '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'), + 'ACT' => 'Australian Capital Territory', + 'NSW' => 'New South Wales', + 'NT' => 'Northern Territory', + 'QLD' => 'Queensland', + 'SA' => 'South Australia', + 'TAS' => 'Tasmania', + 'VIC' => 'Victoria', + 'WA' => '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'), + 'AC' => 'Acre', + 'AL' => 'Alagoas', + 'AM' => 'Amazonas', + 'AP' => 'Amapá', + 'BA' => 'Bahia', + 'CE' => 'Ceará', + 'DF' => 'Distrito Federal', + 'ES' => 'Espírito Santo', + 'GO' => 'Goiás', + 'MA' => 'Maranhão', + 'MG' => 'Minas Gerais', + 'MS' => 'Mato Grosso do Sul', + 'MT' => 'Mato Grosso', + 'PA' => 'Pará', + 'PB' => 'Paraíba', + 'PE' => 'Pernambuco', + 'PI' => 'Piauí', + 'PR' => 'Paraná', + 'RJ' => 'Rio de Janeiro', + 'RN' => 'Rio Grande do Norte', + 'RO' => 'Rondônia', + 'RR' => 'Roraima', + 'RS' => 'Rio Grande do Sul', + 'SC' => 'Santa Catarina', + 'SE' => 'Sergipe', + 'SP' => 'São Paulo', + 'TO' => 'Tocantins', ); $administrative_areas['CA'] = array( 'AB' => t('Alberta'), @@ -102,21 +125,21 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'AI' => 'Aysén del General Carlos Ibáñez del Campo', + 'AN' => 'Antofagasta', + 'AR' => 'Araucanía', + 'AP' => 'Arica y Parinacota', + 'AT' => 'Atacama', + 'BI' => 'Biobío', + 'CO' => 'Coquimbo', + 'LI' => 'Libertador General Bernardo O\'Higgins', + 'LL' => 'Los Lagos', + 'LR' => 'Los Ríos', + 'MA' => 'Magallanes y de la Antártica Chilena', + 'ML' => 'Maule', + 'RM' => 'Metropolitana de Santiago', + 'TA' => 'Tarapacá', + 'VS' => 'Valparaíso', ); $administrative_areas['CN'] = array( '34' => t('Anhui Sheng'), @@ -155,55 +178,55 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'AMA' => 'Amazonas', + 'ANT' => 'Antioquia', + 'ARA' => 'Arauca', + 'ATL' => 'Atlántico', + 'BOL' => 'Bolívar', + 'BOY' => 'Boyacá', + 'CAL' => 'Caldas', + 'CAQ' => 'Caquetá', + 'CAS' => 'Casanare', + 'CAU' => 'Cauca', + 'CES' => 'Cesar', + 'COR' => 'Córdoba', + 'CUN' => 'Cundinamarca', + 'CHO' => 'Chocó', + 'GUA' => 'Guainía', + 'GUV' => 'Guaviare', + 'HUI' => 'Huila', + 'LAG' => 'La Guajira', + 'MAG' => 'Magdalena', + 'MET' => 'Meta', + 'NAR' => 'Nariño', + 'NSA' => 'Norte de Santander', + 'PUT' => 'Putumayo', + 'QUI' => 'Quindío', + 'RIS' => 'Risaralda', + 'SAP' => 'San Andrés, Providencia y Santa Catalina', + 'SAN' => 'Santander', + 'SUC' => 'Sucre', + 'TOL' => 'Tolima', + 'VAC' => 'Valle del Cauca', + 'VAU' => 'Vaupés', + 'VID' => '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'), + '37' => 'Harjumaa', + '39' => 'Hiiumaa', + '44' => 'Ida-Virumaa', + '49' => 'Jõgevamaa', + '51' => 'Järvamaa', + '57' => 'Läänemaa', + '59' => 'Lääne-Virumaa', + '65' => 'Põlvamaa', + '67' => 'Pärnumaa', + '70' => 'Raplamaa', + '74' => 'Saaremaa', + '78' => 'Tartumaa', + '82' => 'Valgamaa', + '84' => 'Viljandimaa', + '86' => 'Võrumaa', ); $administrative_areas['EG'] = array( 'ALX' => t('Alexandria'), @@ -235,58 +258,58 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'C' => "A Coruña", + 'VI' => 'Alava', + 'AB' => 'Albacete', + 'A' => 'Alicante', + 'AL' => "Almería", + 'O' => 'Asturias', + 'AV' => "Ávila", + 'BA' => 'Badajoz', + 'PM' => 'Baleares', + 'B' => 'Barcelona', + 'BU' => 'Burgos', + 'CC' => "Cáceres", + 'CA' => "Cádiz", + 'S' => 'Cantabria', + 'CS' => "Castellón", + 'CE' => 'Ceuta', + 'CR' => 'Ciudad Real', + 'CO' => "Córdoba", + 'CU' => 'Cuenca', + 'GI' => 'Girona', + 'GR' => 'Granada', + 'GU' => 'Guadalajara', + 'SS' => "Guipúzcoa", + 'H' => 'Huelva', + 'HU' => 'Huesca', + 'J' => "Jaén", + 'LO' => 'La Rioja', + 'GC' => 'Las Palmas', + 'LE' => "León", + 'L' => "Lleida", + 'LU' => 'Lugo', + 'M' => 'Madrid', + 'MA' => "Málaga", + 'ML' => 'Melilla', + 'MU' => 'Murcia', + 'NA' => 'Navarra', + 'OR' => 'Ourense', + 'P' => 'Palencia', + 'PO' => 'Pontevedra', + 'SA' => 'Salamanca', + 'TF' => 'Santa Cruz de Tenerife', + 'SG' => 'Segovia', + 'SE' => 'Sevilla', + 'SO' => 'Soria', + 'T' => 'Tarragona', + 'TE' => 'Teruel', + 'TO' => 'Toledo', + 'V' => 'Valencia', + 'VA' => 'Valladolid', + 'BI' => 'Vizcaya', + 'ZA' => 'Zamora', + 'Z' => 'Zaragoza', ); $administrative_areas['HK'] = array( // HK subdivisions have no ISO codes assigned. @@ -330,57 +353,57 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'CW' => 'Co Carlow', + 'CN' => 'Co Cavan', + 'CE' => 'Co Clare', + 'CO' => 'Co Cork', + 'DL' => 'Co Donegal', + 'D' => 'Co Dublin', + 'D1' => 'Dublin 1', + 'D2' => 'Dublin 2', + 'D3' => 'Dublin 3', + 'D4' => 'Dublin 4', + 'D5' => 'Dublin 5', + 'D6' => 'Dublin 6', + 'D6W' => 'Dublin 6w', + 'D7' => 'Dublin 7', + 'D8' => 'Dublin 8', + 'D9' => 'Dublin 9', + 'D10' => 'Dublin 10', + 'D11' => 'Dublin 11', + 'D12' => 'Dublin 12', + 'D13' => 'Dublin 13', + 'D14' => 'Dublin 14', + 'D15' => 'Dublin 15', + 'D16' => 'Dublin 16', + 'D17' => 'Dublin 17', + 'D18' => 'Dublin 18', + 'D19' => 'Dublin 19', + 'D20' => 'Dublin 20', + 'D21' => 'Dublin 21', + 'D22' => 'Dublin 22', + 'D23' => 'Dublin 23', + 'D24' => 'Dublin 24', + 'G' => 'Co Galway', + 'KY' => 'Co Kerry', + 'KE' => 'Co Kildare', + 'KK' => 'Co Kilkenny', + 'LS' => 'Co Laois', + 'LM' => 'Co Leitrim', + 'LK' => 'Co Limerick', + 'LD' => 'Co Longford', + 'LH' => 'Co Louth', + 'MO' => 'Co Mayo', + 'MH' => 'Co Meath', + 'MN' => 'Co Monaghan', + 'OY' => 'Co Offaly', + 'RN' => 'Co Roscommon', + 'SO' => 'Co Sligo', + 'TA' => 'Co Tipperary', + 'WD' => 'Co Waterford', + 'WH' => 'Co Westmeath', + 'WX' => 'Co Wexford', + 'WW' => 'Co Wicklow', ); $administrative_areas['IN'] = array( 'AP' => t('Andhra Pradesh'), @@ -388,8 +411,6 @@ function addressfield_get_administrative_areas($country_code) { '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'), @@ -424,116 +445,116 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'AG' => 'Agrigento', + 'AL' => 'Alessandria', + 'AN' => 'Ancona', + 'AO' => 'Aosta', + 'AP' => 'Ascoli Piceno', + 'AQ' => "L'Aquila", + 'AR' => 'Arezzo', + 'AT' => 'Asti', + 'AV' => 'Avellino', + 'BA' => 'Bari', + 'BG' => 'Bergamo', + 'BI' => 'Biella', + 'BL' => 'Belluno', + 'BN' => 'Benevento', + 'BO' => 'Bologna', + 'BR' => 'Brindisi', + 'BS' => 'Brescia', + 'BT' => 'Barletta-Andria-Trani', + 'BZ' => 'Bolzano/Bozen', + 'CA' => 'Cagliari', + 'CB' => 'Campobasso', + 'CE' => 'Caserta', + 'CH' => 'Chieti', + 'CI' => 'Carbonia-Iglesias', + 'CL' => 'Caltanissetta', + 'CN' => 'Cuneo', + 'CO' => 'Como', + 'CR' => 'Cremona', + 'CS' => 'Cosenza', + 'CT' => 'Catania', + 'CZ' => 'Catanzaro', + 'EN' => 'Enna', + 'FC' => 'Forlì-Cesena', + 'FE' => 'Ferrara', + 'FG' => 'Foggia', + 'FI' => 'Firenze', + 'FM' => 'Fermo', + 'FR' => 'Frosinone', + 'GE' => 'Genova', + 'GO' => 'Gorizia', + 'GR' => 'Grosseto', + 'IM' => 'Imperia', + 'IS' => 'Isernia', + 'KR' => 'Crotone', + 'LC' => 'Lecco', + 'LE' => 'Lecce', + 'LI' => 'Livorno', + 'LO' => 'Lodi', + 'LT' => 'Latina', + 'LU' => 'Lucca', + 'MB' => 'Monza e Brianza', + 'MC' => 'Macerata', + 'ME' => 'Messina', + 'MI' => 'Milano', + 'MN' => 'Mantova', + 'MO' => 'Modena', + 'MS' => 'Massa-Carrara', + 'MT' => 'Matera', + 'NA' => 'Napoli', + 'NO' => 'Novara', + 'NU' => 'Nuoro', + 'OG' => 'Ogliastra', + 'OR' => 'Oristano', + 'OT' => 'Olbia-Tempio', + 'PA' => 'Palermo', + 'PC' => 'Piacenza', + 'PD' => 'Padova', + 'PE' => 'Pescara', + 'PG' => 'Perugia', + 'PI' => 'Pisa', + 'PN' => 'Pordenone', + 'PO' => 'Prato', + 'PR' => 'Parma', + 'PT' => 'Pistoia', + 'PU' => 'Pesaro e Urbino', + 'PV' => 'Pavia', + 'PZ' => 'Potenza', + 'RA' => 'Ravenna', + 'RC' => 'Reggio Calabria', + 'RE' => 'Reggio Emilia', + 'RG' => 'Ragusa', + 'RI' => 'Rieti', + 'RM' => 'Roma', + 'RN' => 'Rimini', + 'RO' => 'Rovigo', + 'SA' => 'Salerno', + 'SI' => 'Siena', + 'SO' => 'Sondrio', + 'SP' => 'La Spezia', + 'SR' => 'Siracusa', + 'SS' => 'Sassari', + 'SV' => 'Savona', + 'TA' => 'Taranto', + 'TE' => 'Teramo', + 'TN' => 'Trento', + 'TO' => 'Torino', + 'TP' => 'Trapani', + 'TR' => 'Terni', + 'TS' => 'Trieste', + 'TV' => 'Treviso', + 'UD' => 'Udine', + 'VA' => 'Varese', + 'VB' => 'Verbano-Cusio-Ossola', + 'VC' => 'Vercelli', + 'VE' => 'Venezia', + 'VI' => 'Vicenza', + 'VR' => 'Verona', + 'VS' => 'Medio Campidano', + 'VT' => 'Viterbo', + 'VV' => 'Vibo Valentia', ); $administrative_areas['JM'] = array( '13' => 'Clarendon', @@ -638,38 +659,38 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'AGU' => 'Aguascalientes', + 'BCN' => 'Baja California', + 'BCS' => 'Baja California Sur', + 'CAM' => 'Campeche', + 'COA' => 'Coahuila', + 'COL' => 'Colima', + 'CHP' => 'Chiapas', + 'CHH' => 'Chihuahua', + 'DIF' => 'Distrito Federal', + 'DUG' => 'Durango', + 'MEX' => 'Estado de México', + 'GUA' => 'Guanajuato', + 'GRO' => 'Guerrero', + 'HID' => 'Hidalgo', + 'JAL' => 'Jalisco', + 'MIC' => 'Michoacán', + 'MOR' => 'Morelos', + 'NAY' => 'Nayarit', + 'NLE' => 'Nuevo León', + 'OAX' => 'Oaxaca', + 'PUE' => 'Puebla', + 'QUE' => 'Queretaro', + 'ROO' => 'Quintana Roo', + 'SLP' => 'San Luis Potosí', + 'SIN' => 'Sinaloa', + 'SON' => 'Sonora', + 'TAB' => 'Tabasco', + 'TAM' => 'Tamaulipas', + 'TLA' => 'Tlaxcala', + 'VER' => 'Veracruz', + 'YUC' => 'Yucatán', + 'ZAC' => 'Zacatecas', ); $administrative_areas['MY'] = array( '01' => t('Johor'), @@ -690,31 +711,31 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'AMA' => 'Amazonas', + 'ANC' => 'Ancash', + 'APU' => 'Apurimac', + 'ARE' => 'Arequipa', + 'AYA' => 'Ayacucho', + 'CAJ' => 'Cajamarca', + 'CAL' => 'Callao', + 'CUS' => 'Cusco', + 'HUV' => 'Huancavelica', + 'HUC' => 'Huanuco', + 'ICA' => 'Ica', + 'JUN' => 'Junin', + 'LAL' => 'La Libertad', + 'LAM' => 'Lambayeque', + 'LIM' => 'Lima', + 'LOR' => 'Loreto', + 'MDD' => 'Madre de Dios', + 'MOQ' => 'Moquegua', + 'PAS' => 'Pasco', + 'PIU' => 'Piura', + 'PUN' => 'Puno', + 'SAM' => 'San Martin', + 'TAC' => 'Tacna', + 'TUM' => 'Tumbes', + 'UCA' => 'Ucayali', ); $administrative_areas['RU'] = array( 'MOW' => t('Moskva'), @@ -918,7 +939,6 @@ function addressfield_get_administrative_areas($country_code) { '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'), @@ -1003,35 +1023,32 @@ function addressfield_get_administrative_areas($country_code) { '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'), + 'Z' => 'Amazonas', + 'B' => 'Anzoátegui', + 'C' => 'Apure', + 'D' => 'Aragua', + 'E' => 'Barinas', + 'F' => 'Bolívar', + 'G' => 'Carabobo', + 'H' => 'Cojedes', + 'Y' => 'Delta Amacuro', + 'W' => 'Dependencias Federales', + 'A' => 'Distrito Federal', + 'I' => 'Falcón', + 'J' => 'Guárico', + 'K' => 'Lara', + 'L' => 'Mérida', + 'M' => 'Miranda', + 'N' => 'Monagas', + 'O' => 'Nueva Esparta', + 'P' => 'Portuguesa', + 'R' => 'Sucre', + 'S' => 'Táchira', + 'T' => 'Trujillo', + 'X' => 'Vargas', + 'U' => 'Yaracuy', + 'V' => '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; + return $administrative_areas; } 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 e14c8885..2eb9c41a 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.devel_generate.inc @@ -43,7 +43,6 @@ function _addressfield_sample_addresses() { $fields = array(); if ($handle = @fopen("$filepath/addresses.txt",'r')) { 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, $sub_premise) = explode("\t", $buffer); $fields[] = array( diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.feeds.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.feeds.inc index 2b8537ad..062b221f 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.feeds.inc +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.feeds.inc @@ -6,10 +6,10 @@ */ /** - * Implements hook_feeds_node_processor_targets_alter(). + * Implements hook_feeds_processor_targets_alter(). */ -function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) { - foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) { +function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bundle) { + foreach (field_info_instances($entity_type, $bundle) as $name => $instance) { $info = field_info_field($name); if ($info['type'] == 'addressfield') { foreach ($info['columns'] as $sub_field => $schema_info) { @@ -34,7 +34,7 @@ function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bu * An entity object, for instance a node object. * @param $target * A string identifying the target on the node. - * @param $value + * @param $values * The value to populate the target with. */ function addressfield_set_target($source, $entity, $target, $values) { diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.info b/sites/all/modules/contrib/fields/addressfield/addressfield.info index 991621bb..89e95157 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.info +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.info @@ -6,12 +6,13 @@ package = Fields dependencies[] = ctools files[] = addressfield.migrate.inc +files[] = views/addressfield_views_handler_field_administrative_area.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 2015-04-23 -version = "7.x-1.1" +; Information added by Drupal.org packaging script on 2015-10-07 +version = "7.x-1.2" core = "7.x" project = "addressfield" -datestamp = "1429819382" +datestamp = "1444254070" diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc b/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc index 6e74d63f..cc98911c 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.migrate.inc @@ -152,7 +152,7 @@ class MigrateAddressFieldHandler extends MigrateFieldHandler { if ($value) { if (isset($field_info['columns'][$column_key])) { - // Store the data in a seperate column. + // Store the data in a separate column. $result[$column_key] = $value; } else { diff --git a/sites/all/modules/contrib/fields/addressfield/addressfield.module b/sites/all/modules/contrib/fields/addressfield/addressfield.module index db7e0236..25b277dc 100644 --- a/sites/all/modules/contrib/fields/addressfield/addressfield.module +++ b/sites/all/modules/contrib/fields/addressfield/addressfield.module @@ -534,7 +534,9 @@ function addressfield_field_widget_form(&$form, &$form_state, $field, $instance, // $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($form_state['input'])) { + $input_address = drupal_array_get_nested_value($form_state['input'], $parents); + } if (!empty($input_address)) { $address = $input_address; } @@ -728,8 +730,6 @@ function addressfield_field_formatter_settings_summary($field, $instance, $view_ $display = $instance['display'][$view_mode]; $settings = $display['settings']; - $summary = ''; - if ($settings['use_widget_handlers']) { return t('Use widget configuration'); } diff --git a/sites/all/modules/contrib/fields/addressfield/example/addressfield_example.info b/sites/all/modules/contrib/fields/addressfield/example/addressfield_example.info index c7120e3b..b0f19829 100644 --- a/sites/all/modules/contrib/fields/addressfield/example/addressfield_example.info +++ b/sites/all/modules/contrib/fields/addressfield/example/addressfield_example.info @@ -7,9 +7,9 @@ hidden = TRUE dependencies[] = ctools dependencies[] = addressfield -; Information added by Drupal.org packaging script on 2015-04-23 -version = "7.x-1.1" +; Information added by Drupal.org packaging script on 2015-10-07 +version = "7.x-1.2" core = "7.x" project = "addressfield" -datestamp = "1429819382" +datestamp = "1444254070" diff --git a/sites/all/modules/contrib/fields/addressfield/example/plugins/format/address-ch-example.inc b/sites/all/modules/contrib/fields/addressfield/example/plugins/format/address-ch-example.inc index db3a98e2..4f92daa5 100644 --- a/sites/all/modules/contrib/fields/addressfield/example/plugins/format/address-ch-example.inc +++ b/sites/all/modules/contrib/fields/addressfield/example/plugins/format/address-ch-example.inc @@ -3552,8 +3552,6 @@ function addressfield_form_ch_postal_code_validation($element, &$form_state, &$f if (!empty($element['#value']) && (isset($data[$element['#value']]))) { // Get the base #parents for this address form. $base_parents = array_slice($element['#parents'], 0, -1); - $base_array_parents = array_slice($element['#array_parents'], 0, -2); - $city = $data[$element['#value']]; // Set the new values in the form. diff --git a/sites/all/modules/contrib/fields/addressfield/plugins/format/address-optional.inc b/sites/all/modules/contrib/fields/addressfield/plugins/format/address-optional.inc index 201e40ea..bb4408be 100644 --- a/sites/all/modules/contrib/fields/addressfield/plugins/format/address-optional.inc +++ b/sites/all/modules/contrib/fields/addressfield/plugins/format/address-optional.inc @@ -7,7 +7,7 @@ */ $plugin = array( - 'title' => t('Make all fields optional (Not recommended)'), + 'title' => t('Make all fields optional (No validation - unsuitable for postal purposes)'), 'format callback' => 'addressfield_format_address_optional', 'type' => 'address', 'weight' => 100, diff --git a/sites/all/modules/contrib/fields/addressfield/plugins/format/address.inc b/sites/all/modules/contrib/fields/addressfield/plugins/format/address.inc index 0523ffe1..e9b801f1 100644 --- a/sites/all/modules/contrib/fields/addressfield/plugins/format/address.inc +++ b/sites/all/modules/contrib/fields/addressfield/plugins/format/address.inc @@ -83,7 +83,7 @@ function addressfield_format_address_generate(&$format, $address, $context = arr '#tag' => 'div', '#attributes' => array( 'class' => array('dependent-locality'), - 'autocomplete' => '"address-level3', + 'autocomplete' => 'address-level3', ), // Most formats place this field in its own row. '#suffix' => $clearfix, @@ -97,7 +97,7 @@ function addressfield_format_address_generate(&$format, $address, $context = arr '#prefix' => ' ', '#attributes' => array( 'class' => array('locality'), - 'autocomplete' => '"address-level2', + 'autocomplete' => 'address-level2', ), ); $format['locality_block']['administrative_area'] = array( diff --git a/sites/all/modules/contrib/fields/addressfield/plugins/format/organisation.inc b/sites/all/modules/contrib/fields/addressfield/plugins/format/organisation.inc index 5cef00e3..3cec0f7f 100644 --- a/sites/all/modules/contrib/fields/addressfield/plugins/format/organisation.inc +++ b/sites/all/modules/contrib/fields/addressfield/plugins/format/organisation.inc @@ -20,7 +20,7 @@ $plugin = array( function addressfield_format_organisation_generate(&$format, $address) { $format['organisation_block'] = array( '#type' => 'addressfield_container', - '#attributes' => array('class' => array('addressfield-container-inline', 'name-block')), + '#attributes' => array('class' => array('addressfield-container-inline', 'organisation-block')), '#weight' => -50, // The addressfield is considered empty without a country, hide all fields // until one is selected. diff --git a/sites/all/modules/contrib/fields/addressfield/views/addressfield.views.inc b/sites/all/modules/contrib/fields/addressfield/views/addressfield.views.inc index 9be1637e..f059da34 100644 --- a/sites/all/modules/contrib/fields/addressfield/views/addressfield.views.inc +++ b/sites/all/modules/contrib/fields/addressfield/views/addressfield.views.inc @@ -26,7 +26,7 @@ function addressfield_field_views_data($field) { // Only expose these components as Views field handlers. $implemented = array( 'country' => 'addressfield_views_handler_field_country', - 'administrative_area' => 'views_handler_field', + 'administrative_area' => 'addressfield_views_handler_field_administrative_area', 'sub_administrative_area' => 'views_handler_field', 'dependent_locality' => 'views_handler_field', 'locality' => 'views_handler_field', diff --git a/sites/all/modules/contrib/fields/addressfield/views/addressfield_views_handler_field_administrative_area.inc b/sites/all/modules/contrib/fields/addressfield/views/addressfield_views_handler_field_administrative_area.inc new file mode 100644 index 00000000..daeae662 --- /dev/null +++ b/sites/all/modules/contrib/fields/addressfield/views/addressfield_views_handler_field_administrative_area.inc @@ -0,0 +1,48 @@ +country_alias = $this->query->add_field($this->table_alias, $this->definition['field_name'] . '_country'); + } + + function option_definition() { + $options = parent::option_definition(); + $options['display_name'] = array('default' => TRUE); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + $form['display_name'] = array( + '#type' => 'checkbox', + '#title' => t('Display the name of administrative area instead of the code.'), + '#default_value' => $this->options['display_name'], + ); + } + + function get_value($values, $field = NULL) { + $value = parent::get_value($values, $field); + + // If we have a value for the field, look for the administrative area name in the + // Address Field options list array if specified. + if (!empty($value) && !empty($this->options['display_name'])) { + module_load_include('inc', 'addressfield', 'addressfield.administrative_areas'); + $country = $values->{$this->country_alias}; + $areas = addressfield_get_administrative_areas($country); + + if (!empty($areas[$value])) { + $value = $areas[$value]; + } + } + + return $value; + } +} diff --git a/sites/all/modules/contrib/fields/date/.gitignore b/sites/all/modules/contrib/fields/date/.gitignore new file mode 100644 index 00000000..a0238825 --- /dev/null +++ b/sites/all/modules/contrib/fields/date/.gitignore @@ -0,0 +1,4 @@ +*.patch +*.diff +.idea/ +.idea/* diff --git a/sites/all/modules/contrib/fields/date/date.devel_generate.inc b/sites/all/modules/contrib/fields/date/date.devel_generate.inc index 47de0847..6c61e23c 100644 --- a/sites/all/modules/contrib/fields/date/date.devel_generate.inc +++ b/sites/all/modules/contrib/fields/date/date.devel_generate.inc @@ -15,8 +15,14 @@ function date_devel_generate($entity, $field, $instance, $bundle) { $entity_field = array(); if (isset($instance['widget']['settings']['year_range'])) { $split = explode(':', $instance['widget']['settings']['year_range']); - $back = str_replace('-', '', $split[0]); - $forward = str_replace('+', '', $split[1]); + // Determine how much to go back and forward depending on whether a relative + // number of years (with - or + sign) or an absolute year is given. + $back = strpos($split[0], '-') === 0 + ? str_replace('-', '', $split[0]) + : date_format(date_now(), 'Y') - $split[0]; + $forward = strpos($split[1], '+') === 0 + ? str_replace('+', '', $split[1]) + : $split[1] - date_format(date_now(), 'Y'); } else { $back = 2; @@ -61,9 +67,11 @@ function date_devel_generate($entity, $field, $instance, $bundle) { case 'date': $format = DATE_FORMAT_ISO; break; + case 'datestamp': $format = DATE_FORMAT_UNIX; break; + case 'datetime': $format = DATE_FORMAT_DATETIME; break; diff --git a/sites/all/modules/contrib/fields/date/date.field.inc b/sites/all/modules/contrib/fields/date/date.field.inc index 46ea317b..fa311224 100644 --- a/sites/all/modules/contrib/fields/date/date.field.inc +++ b/sites/all/modules/contrib/fields/date/date.field.inc @@ -19,6 +19,7 @@ function date_field_formatter_info() { 'multiple_from' => '', 'multiple_to' => '', 'fromto' => 'both', + 'show_remaining_days' => FALSE, ), ), 'format_interval' => array( @@ -48,6 +49,7 @@ function date_field_formatter_settings_form($field, $instance, $view_mode, $form case 'format_interval': $form = date_interval_formatter_settings_form($field, $instance, $view_mode, $form, $form_state); break; + default: $form = date_default_formatter_settings_form($field, $instance, $view_mode, $form, $form_state); break; @@ -72,6 +74,7 @@ function date_field_formatter_settings_summary($field, $instance, $view_mode) { case 'format_interval': $summary = date_interval_formatter_settings_summary($field, $instance, $view_mode); break; + default: $summary = date_default_formatter_settings_summary($field, $instance, $view_mode); break; @@ -169,11 +172,16 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la $element[$delta] = array('#markup' => $item['value']); } else { - $element[$delta] = array('#markup' => t('!start-date to !end-date', array('!start-date' => $item['value'], '!end-date' => $item['value2']))); + $element[$delta] = array( + '#markup' => t('!start-date to !end-date', array( + '!start-date' => $item['value'], + '!end-date' => $item['value2'] + ))); } } } break; + case 'format_interval': foreach ($items as $delta => $item) { if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) { @@ -188,6 +196,7 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la } } break; + default: foreach ($items as $delta => $item) { if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) { @@ -198,6 +207,7 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la $variables['item'] = $item; $variables['dates'] = date_formatter_process($formatter, $entity_type, $entity, $field, $instance, $langcode, $item, $display); $variables['attributes'] = !empty($rdf_mapping) ? rdf_rdfa_attributes($rdf_mapping, $item['value']) : array(); + $variables['show_remaining_days'] = $display['settings']['show_remaining_days']; $output = theme('date_display_combination', $variables); if (!empty($output)) { $element[$delta] = array('#markup' => $output); @@ -231,10 +241,11 @@ function date_field_is_empty($item, $field) { * Implements hook_field_info(). */ function date_field_info() { + $granularity = array('year', 'month', 'day', 'hour', 'minute'); $settings = array( 'settings' => array( 'todate' => '', - 'granularity' => drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute')), + 'granularity' => drupal_map_assoc($granularity), 'tz_handling' => 'site', 'timezone_db' => 'UTC', ), @@ -250,26 +261,26 @@ function date_field_info() { ); return array( 'datetime' => array( - 'label' => 'Date', + 'label' => t('Date'), 'description' => t('Store a date in the database as a datetime field, recommended for complete dates and times that may need timezone conversion.'), 'default_widget' => 'date_select', 'default_formatter' => 'date_default', 'default_token_formatter' => 'date_plain', - ) + $settings, + ) + $settings, 'date' => array( - 'label' => 'Date (ISO format)', + 'label' => t('Date (ISO format)'), 'description' => t('Store a date in the database as an ISO date, recommended for historical or partial dates.'), 'default_widget' => 'date_select', 'default_formatter' => 'date_default', 'default_token_formatter' => 'date_plain', - ) + $settings, + ) + $settings, 'datestamp' => array( - 'label' => 'Date (Unix timestamp)', + 'label' => t('Date (Unix timestamp)'), 'description' => t('Store a date in the database as a timestamp, deprecated format to support legacy data.'), 'default_widget' => 'date_select', 'default_formatter' => 'date_default', 'default_token_formatter' => 'date_plain', - ) + $settings, + ) + $settings, ); } @@ -294,18 +305,18 @@ function date_field_widget_info() { $info = array( 'date_select' => array( - 'label' => t('Select list'), + 'label' => t('Select list'), 'field types' => array('date', 'datestamp', 'datetime'), ) + $settings, 'date_text' => array( - 'label' => t('Text field'), + 'label' => t('Text field'), 'field types' => array('date', 'datestamp', 'datetime'), - ) + $settings, + ) + $settings, ); if (module_exists('date_popup')) { $info['date_popup'] = array( - 'label' => t('Pop-up calendar'), + 'label' => t('Pop-up calendar'), 'field types' => array('date', 'datestamp', 'datetime'), ) + $settings; } diff --git a/sites/all/modules/contrib/fields/date/date.info b/sites/all/modules/contrib/fields/date/date.info index a1731de0..c6fdde55 100644 --- a/sites/all/modules/contrib/fields/date/date.info +++ b/sites/all/modules/contrib/fields/date/date.info @@ -11,10 +11,12 @@ files[] = tests/date_field.test files[] = tests/date_migrate.test files[] = tests/date_validation.test files[] = tests/date_timezone.test +files[] = tests/date_views_pager.test +files[] = tests/date_views_popup.test -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date.install b/sites/all/modules/contrib/fields/date/date.install index 23fb07eb..9a9b6d35 100644 --- a/sites/all/modules/contrib/fields/date/date.install +++ b/sites/all/modules/contrib/fields/date/date.install @@ -19,6 +19,7 @@ function date_field_schema($field) { 'views' => TRUE, ); break; + case 'datetime': $db_columns['value'] = array( 'type' => 'datetime', @@ -31,6 +32,7 @@ function date_field_schema($field) { 'views' => TRUE, ); break; + default: $db_columns['value'] = array( 'type' => 'varchar', @@ -66,7 +68,12 @@ function date_field_schema($field) { 'views' => FALSE, ); if (!empty($field['settings']['todate'])) { - $db_columns['offset2'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE, 'views' => FALSE); + $db_columns['offset2'] = array( + 'type' => 'int', + 'not null' => FALSE, + 'sortable' => TRUE, + 'views' => FALSE + ); } } if (isset($field['settings']['repeat']) && $field['settings']['repeat'] == 1) { @@ -88,8 +95,9 @@ function date_update_last_removed() { } /** - * Get rid of the individual formatters for each format type, - * these are now settings in the default formatter. + * Get rid of the individual formatters for each format type. + * + * These are now settings in the default formatter. */ function date_update_7000() { $instances = field_info_instances(); @@ -115,8 +123,9 @@ function date_update_7000() { } /** - * Get rid of the separate widgets for repeating dates. The code now handles - * repeating dates correctly using the regular widgets. + * Get rid of the separate widgets for repeating dates. + * + * The code now handles repeating dates correctly using the regular widgets. */ function date_update_7001() { $query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC)); @@ -127,7 +136,11 @@ function date_update_7001() { foreach ($results as $record) { $instance = unserialize($record['data']); - if (in_array($instance['widget']['type'], array('date_popup_repeat', 'date_text_repeat', 'date_select_repeat'))) { + if (in_array($instance['widget']['type'], array( + 'date_popup_repeat', + 'date_text_repeat', + 'date_select_repeat' + ))) { $instance['widget']['type'] = str_replace('_repeat', '', $instance['widget']['type']); db_update('field_config_instance') ->fields(array( @@ -191,4 +204,3 @@ function date_update_7004() { field_cache_clear(); drupal_set_message(t('Date text widgets have been updated to use an increment of 1.')); } - diff --git a/sites/all/modules/contrib/fields/date/date.js b/sites/all/modules/contrib/fields/date/date.js index 2e60175f..b58d3be6 100644 --- a/sites/all/modules/contrib/fields/date/date.js +++ b/sites/all/modules/contrib/fields/date/date.js @@ -27,7 +27,7 @@ Drupal.date.EndDateHandler = function (widget) { this.$widget = $(widget); this.$start = this.$widget.find('.form-type-date-select[class$=value]'); this.$end = this.$widget.find('.form-type-date-select[class$=value2]'); - if (this.$end.length == 0) { + if (this.$end.length === 0) { return; } this.initializeSelects(); @@ -68,7 +68,7 @@ Drupal.date.EndDateHandler.prototype.endDateIsBlank = function () { var id; for (id in this.selects) { if (this.selects.hasOwnProperty(id)) { - if (this.selects[id].end.val() != '') { + if (this.selects[id].end.val() !== '') { return false; } } diff --git a/sites/all/modules/contrib/fields/date/date.migrate.inc b/sites/all/modules/contrib/fields/date/date.migrate.inc index 095c789e..ad2a5681 100644 --- a/sites/all/modules/contrib/fields/date/date.migrate.inc +++ b/sites/all/modules/contrib/fields/date/date.migrate.inc @@ -40,7 +40,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { * @return array * An array of the defined variables in this scope. */ - static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) { + public static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) { return get_defined_vars(); } @@ -129,6 +129,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { // timestamp for 'now'. if (empty($from)) { $return[$language][$delta]['value'] = NULL; + $return[$language][$delta]['timezone'] = NULL; if (!empty($field_info['settings']['todate'])) { $return[$language][$delta]['value2'] = NULL; } @@ -151,6 +152,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { case 'datestamp': // Already done. break; + case 'datetime': // YYYY-MM-DD HH:MM:SS. $from = format_date($from, 'custom', 'Y-m-d H:i:s', $timezone); @@ -158,6 +160,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { $to = format_date($to, 'custom', 'Y-m-d H:i:s', $timezone); } break; + case 'date': // ISO date: YYYY-MM-DDTHH:MM:SS. $from = format_date($from, 'custom', 'Y-m-d\TH:i:s', $timezone); @@ -165,6 +168,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { $to = format_date($to, 'custom', 'Y-m-d\TH:i:s', $timezone); } break; + default: break; } @@ -173,12 +177,17 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { // created. if (function_exists('date_repeat_build_dates') && !empty($field_info['settings']['repeat']) && $rrule) { include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc'; - $item = array('value' => $from, 'value2' => $to, 'timezone' => $timezone); + $item = array( + 'value' => $from, + 'value2' => $to, + 'timezone' => $timezone, + ); // Can be de-uglified when http://drupal.org/node/1159404 is committed. $return[$language] = date_repeat_build_dates(NULL, date_ical_parse_rrule($field_info, $rrule), $field_info, $item); } else { $return[$language][$delta]['value'] = $from; + $return[$language][$delta]['timezone'] = $timezone; if (!empty($to)) { $return[$language][$delta]['value2'] = $to; } @@ -190,6 +199,9 @@ class DateMigrateFieldHandler extends MigrateFieldHandler { return $return; } + /** + * {@inheritdoc} + */ public function fields($migration = NULL) { return array( 'timezone' => t('Timezone'), diff --git a/sites/all/modules/contrib/fields/date/date.module b/sites/all/modules/contrib/fields/date/date.module index 91c0b65a..6f849dfa 100644 --- a/sites/all/modules/contrib/fields/date/date.module +++ b/sites/all/modules/contrib/fields/date/date.module @@ -1,8 +1,10 @@ field_name; break; + default: $bundle = field_extract_bundle($entity_type, $entity); break; @@ -40,13 +43,20 @@ function date_default_format($type) { * Wrapper function around each of the widget types for creating a date object. */ function date_input_date($field, $instance, $element, $input) { + // Trim extra spacing off user input of text fields. + if (isset($input['date'])) { + $input['date'] = trim($input['date']); + } + switch ($instance['widget']['type']) { case 'date_text': $function = 'date_text_input_date'; break; + case 'date_popup': $function = 'date_popup_input_date'; break; + default: $function = 'date_select_input_date'; } @@ -66,6 +76,7 @@ function date_theme() { ); $themes = array( 'date_combo' => $base + array('render element' => 'element'), + 'date_form_element' => $base + array('render element' => 'element'), 'date_text_parts' => $base + array('render element' => 'element'), 'date' => $base + array('render element' => 'element'), 'date_display_single' => $base + array( @@ -97,7 +108,13 @@ function date_theme() { 'add_rdf' => NULL, 'microdata' => NULL, 'add_microdata' => NULL, - )), + ), + ), + 'date_display_remaining' => $base + array( + 'variables' => array( + 'remaining_days' => NULL, + ), + ), 'date_display_combination' => $base + array( 'variables' => array( 'entity_type' => NULL, @@ -130,7 +147,7 @@ function date_theme() { 'attributes' => array(), 'rdf_mapping' => NULL, 'add_rdf' => NULL, - ), + ), ), ); @@ -209,8 +226,10 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst $settings = $display['settings']; $field_name = $field['field_name']; $format = date_formatter_format($formatter, $settings, $granularity, $langcode); - $timezone = isset($item['timezone']) ? $item['timezone'] : ''; - $timezone = date_get_timezone($field['settings']['tz_handling'], $timezone); + if (!isset($field['settings']['tz_handling']) || $field['settings']['tz_handling'] !== 'utc') { + $timezone = isset($item['timezone']) ? $item['timezone'] : ''; + $timezone = date_get_timezone($field['settings']['tz_handling'], $timezone); + } $timezone_db = date_get_timezone_db($field['settings']['tz_handling']); $db_format = date_type_format($field['type']); $process = date_process_values($field); @@ -246,10 +265,10 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst $dates[$processed]['formatted_iso'] = date_format_date($date, 'custom', 'c'); if (is_object($date)) { if ($format == 'format_interval') { - $dates[$processed]['interval'] = date_format_interval($date); + $dates[$processed]['interval'] = date_format_interval($date); } elseif ($format == 'format_calendar_day') { - $dates[$processed]['calendar_day'] = date_format_calendar_day($date); + $dates[$processed]['calendar_day'] = date_format_calendar_day($date); } elseif ($format == 'U' || $format == 'r' || $format == 'c') { $dates[$processed]['formatted'] = date_format_date($date, 'custom', $format); @@ -258,10 +277,11 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst $dates[$processed]['formatted_timezone'] = ''; } elseif (!empty($format)) { - $dates[$processed]['formatted'] = date_format_date($date, 'custom', $format); - $dates[$processed]['formatted_date'] = date_format_date($date, 'custom', date_limit_format($format, array('year', 'month', 'day'))); - $dates[$processed]['formatted_time'] = date_format_date($date, 'custom', date_limit_format($format, array('hour', 'minute', 'second'))); - $dates[$processed]['formatted_timezone'] = date_format_date($date, 'custom', date_limit_format($format, array('timezone'))); + $formats = _get_custom_date_format($date, $format); + $dates[$processed]['formatted'] = $formats['formatted']; + $dates[$processed]['formatted_date'] = $formats['date']; + $dates[$processed]['formatted_time'] = $formats['time']; + $dates[$processed]['formatted_timezone'] = $formats['zone']; } } } @@ -288,6 +308,30 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst return $dates; } +/** + * Get a custom date format. + */ +function _get_custom_date_format($date, $format) { + $custom = array(); + $custom['granularities'] = array( + 'date' => array('year', 'month', 'day'), + 'time' => array('hour', 'minute', 'second'), + 'zone' => array('timezone'), + ); + $custom['limits'] = array( + 'date' => date_limit_format($format, $custom['granularities']['date']), + 'time' => date_limit_format($format, $custom['granularities']['time']), + 'zone' => date_limit_format($format, $custom['granularities']['zone']), + ); + + return array( + 'formatted' => date_format_date($date, 'custom', $format), + 'date' => date_format_date($date, 'custom', $custom['limits']['date']), + 'time' => date_format_date($date, 'custom', $custom['limits']['time']), + 'zone' => date_format_date($date, 'custom', $custom['limits']['zone']), + ); +} + /** * Retrieves the granularity for a field. * @@ -301,14 +345,14 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst */ function date_granularity($field) { if (!is_array($field) || !is_array($field['settings']['granularity'])) { - $field['settings']['granularity'] = drupal_map_assoc(array('year', 'month', 'day')); + $granularity = drupal_map_assoc(array('year', 'month', 'day')); + $field['settings']['granularity'] = $granularity; } return array_values(array_filter($field['settings']['granularity'])); } /** - * Helper function to create an array of the date values in a - * field that need to be processed. + * Helper function to create an array of the date values in a field that need to be processed. */ function date_process_values($field) { return $field['settings']['todate'] ? array('value', 'value2') : array('value'); @@ -394,10 +438,10 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l switch ($formatter) { case 'format_interval': return 'format_interval'; - break; + case 'date_plain': return 'date_plain'; - break; + default: $format = date_format_type_format($format_type, $langcode); break; @@ -410,6 +454,7 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l /** * Helper function to get the right format for a format type. + * * Checks for locale-based format first. */ function date_format_type_format($format_type, $langcode = NULL) { @@ -432,27 +477,30 @@ function date_format_type_format($format_type, $langcode = NULL) { case 'short': $default = 'm/d/Y - H:i'; break; + case 'long': $default = 'l, F j, Y - H:i'; break; + // If it's not one of the core date types and isn't stored in the // database, we'll fall back on using the same default format as the // 'medium' type. case 'medium': default: // @todo: If a non-core module provides a date type and does not - // variable_set() a default for it, the default assumed here may - // not be correct (since the default format used by 'medium' may - // not even be one of the allowed formats for the date type in - // question). To fix this properly, we should really call - // system_get_date_formats($format_type) and take the first - // format from that list as the default. However, this function - // is called often (on many different page requests), so calling - // system_get_date_formats() from here would be a performance hit - // since that function writes several records to the database - // during each page request that calls it. + // variable_set() a default for it, the default assumed here may + // not be correct (since the default format used by 'medium' may + // not even be one of the allowed formats for the date type in + // question). To fix this properly, we should really call + // system_get_date_formats($format_type) and take the first + // format from that list as the default. However, this function + // is called often (on many different page requests), so calling + // system_get_date_formats() from here would be a performance hit + // since that function writes several records to the database + // during each page request that calls it. $default = 'D, m/d/Y - H:i'; break; + } $format = variable_get('date_format_' . $format_type, $default); } @@ -506,7 +554,7 @@ function date_prepare_entity($formatter, $entity_type, $entity, $field, $instanc elseif ((!empty($max_count) && is_numeric($max_count) && $count >= $max_count) || (!empty($value['value']) && $value['value'] < $start) || (!empty($value['value2']) && $value['value2'] > $end)) { - unset($entity->{$field_name}[$langcode][$delta]); + unset($entity->{$field_name}[$langcode][$delta]); } else { $count++; @@ -647,7 +695,7 @@ function date_entity_metadata_field_setter(&$entity, $name, $value, $langcode, $ } /** - * Auto creation callback for fields which contain two date values in one + * Auto creation callback for fields which contain two date values in one. */ function date_entity_metadata_struct_create($name, $property_info) { return array( @@ -658,10 +706,10 @@ function date_entity_metadata_struct_create($name, $property_info) { /** * Callback for setting an individual field value if a to-date may be there too. + * * Based on entity_property_verbatim_set(). * - * The passed in unix timestamp (UTC) is converted to the right value and - * format dependent on the field. + * The passed in unix timestamp (UTC) is converted to the right value and format dependent on the field. * * $name is either 'value' or 'value2'. */ @@ -683,9 +731,9 @@ function date_entity_metadata_struct_setter(&$item, $name, $value, $langcode, $t } /** - * Duplicate functionality of what is now date_all_day_field() in - * the Date All Day module. Copy left here to avoid breaking other - * modules that use this function. + * Duplicate functionality of what is now date_all_day_field() in the Date All Day module. + * + * Copy left here to avoid breaking other modules that use this function. * * DEPRECATED!, will be removed at some time in the future. */ @@ -759,7 +807,7 @@ function date_field_widget_properties_alter(&$widget, $context) { $entity = $context['entity']; $info = entity_get_info($entity_type); $id = $info['entity keys']['id']; - $widget['is_new']= FALSE; + $widget['is_new'] = FALSE; if (empty($entity->$id)) { $widget['is_new'] = TRUE; } diff --git a/sites/all/modules/contrib/fields/date/date.theme b/sites/all/modules/contrib/fields/date/date.theme index a1f7d939..5cec8b42 100644 --- a/sites/all/modules/contrib/fields/date/date.theme +++ b/sites/all/modules/contrib/fields/date/date.theme @@ -77,6 +77,7 @@ function theme_date_display_combination($variables) { $microdata = $variables['microdata']; $add_microdata = $variables['add_microdata']; $precision = date_granularity_precision($field['settings']['granularity']); + $show_remaining_days = $variables['show_remaining_days']; $output = ''; @@ -121,10 +122,12 @@ function theme_date_display_combination($variables) { $date1 = $dates['value']['formatted']; $date2 = $date1; break; + case 'value2': $date2 = $dates['value2']['formatted']; $date1 = $date2; break; + default: $date1 = $dates['value']['formatted']; $date2 = $dates['value2']['formatted']; @@ -151,6 +154,20 @@ function theme_date_display_combination($variables) { $has_time_string = FALSE; } + // Check remaining days. + $show_remaining_days = ''; + if (!empty($variables['show_remaining_days'])) { + $remaining_days = floor((strtotime($variables['dates']['value']['formatted_iso']) + - strtotime('now')) / (24 * 3600)); + + // Show remaining days only for future events. + if ($remaining_days >= 0) { + $show_remaining_days = theme('date_display_remaining', array( + 'remaining_days' => $remaining_days, + )); + } + } + // No date values, display nothing. if (empty($date1) && empty($date2)) { $output .= ''; @@ -167,6 +184,7 @@ function theme_date_display_combination($variables) { 'microdata' => $microdata, 'add_microdata' => $add_microdata, 'dates' => $dates, + 'show_remaining_days' => $show_remaining_days, )); } // Same day, different times, don't repeat the date but show both Start and @@ -186,6 +204,7 @@ function theme_date_display_combination($variables) { 'microdata' => $microdata, 'add_microdata' => $add_microdata, 'dates' => $dates, + 'show_remaining_days' => $show_remaining_days, )); $replaced = str_replace($time1, $time, $date1); $output .= theme('date_display_single', array( @@ -209,6 +228,7 @@ function theme_date_display_combination($variables) { 'microdata' => $microdata, 'add_microdata' => $add_microdata, 'dates' => $dates, + 'show_remaining_days' => $show_remaining_days, )); } @@ -236,12 +256,12 @@ function template_preprocess_date_display_single(&$variables) { // Because the Entity API integration for Date has a variable data // structure depending on whether there is an end value, the attributes // could be attached to the field or to the value property. - if(!empty($variables['microdata']['#attributes']['itemprop'])) { + if (!empty($variables['microdata']['#attributes']['itemprop'])) { $variables['microdata']['value']['#attributes'] = $variables['microdata']['#attributes']; } // Add the machine readable time using the content attribute. - if(!empty($variables['microdata']['value']['#attributes'])) { + if (!empty($variables['microdata']['value']['#attributes'])) { $variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso']; } else { @@ -257,6 +277,7 @@ function theme_date_display_single($variables) { $date = $variables['date']; $timezone = $variables['timezone']; $attributes = $variables['attributes']; + $show_remaining_days = isset($variables['show_remaining_days']) ? $variables['show_remaining_days'] : ''; // Wrap the result with the attributes. $output = '' . $date . $timezone . ''; @@ -265,7 +286,8 @@ function theme_date_display_single($variables) { $output .= ''; } - return $output; + // Add remaining message and return. + return $output . $show_remaining_days; } /** @@ -314,6 +336,7 @@ function theme_date_display_range($variables) { $timezone = $variables['timezone']; $attributes_start = $variables['attributes_start']; $attributes_end = $variables['attributes_end']; + $show_remaining_days = $variables['show_remaining_days']; $start_date = '' . $date1 . ''; $end_date = '' . $date2 . $timezone . ''; @@ -326,10 +349,13 @@ function theme_date_display_range($variables) { } // Wrap the result with the attributes. - return t('!start-date to !end-date', array( + $output = '
' . t('!start-date to !end-date', array( '!start-date' => $start_date, '!end-date' => $end_date, - )); + )) . '
'; + + // Add remaining message and return. + return $output . $show_remaining_days; } /** @@ -375,7 +401,7 @@ function theme_date_combo($variables) { '#title' => field_filter_xss(t($element['#title'])) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''), '#value' => '', '#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '', - '#attributes' => array(), + '#attributes' => array('class' => array('date-combo')), '#children' => $element['#children'], ); // Add marker to required date fields. @@ -396,7 +422,11 @@ function theme_date_text_parts($variables) { $rows[] = drupal_render($element[$key]); } else { - $rows[] = array($part, drupal_render($element[$key][0]), drupal_render($element[$key][1])); + $rows[] = array( + $part, + drupal_render($element[$key][0]), + drupal_render($element[$key][1]), + ); } } if ($element['year']['#type'] == 'hidden') { @@ -408,4 +438,49 @@ function theme_date_text_parts($variables) { } } +/** + * Render a date combo as a form element. + */ +function theme_date_form_element($variables) { + $element = &$variables['element']; + + // Detect whether element is multiline. + $count = preg_match_all('`<(?:div|span)\b[^>]* class="[^"]*\b(?:date-no-float|date-clear)\b`', $element['#children'], $matches, PREG_OFFSET_CAPTURE); + $multiline = FALSE; + if ($count > 1) { + $multiline = TRUE; + } + elseif ($count) { + $before = substr($element['#children'], 0, $matches[0][0][1]); + if (preg_match('`<(?:div|span)\b[^>]* class="[^"]*\bdate-float\b`', $before)) { + $multiline = TRUE; + } + } + + // Detect if there is more than one subfield. + $count = count(explode(''. $element['#children'] .''; + + return theme('form_element', $variables); +} + +/** + * Returns HTML for remaining message. + */ +function theme_date_display_remaining($variables) { + $remaining_days = $variables['remaining_days']; + $output = ''; + $show_remaining_text = t('The upcoming date less then 1 day.'); + if ($remaining_days) { + $show_remaining_text = format_plural($remaining_days, 'To event remaining 1 day', 'To event remaining @count days'); + } + + return '
' . $show_remaining_text . '
'; +} + /** @} End of addtogroup themeable */ diff --git a/sites/all/modules/contrib/fields/date/date_admin.inc b/sites/all/modules/contrib/fields/date/date_admin.inc index 0e32fc5a..13da42ef 100644 --- a/sites/all/modules/contrib/fields/date/date_admin.inc +++ b/sites/all/modules/contrib/fields/date/date_admin.inc @@ -74,6 +74,12 @@ function date_default_formatter_settings_form($field, $instance, $view_mode, $fo '#description' => t('Identify specific start and/or end dates in the format YYYY-MM-DDTHH:MM:SS, or leave blank for all available dates.'), ); + $form['show_remaining_days'] = array( + '#title' => t('Show remaining days'), + '#type' => 'checkbox', + '#default_value' => $settings['show_remaining_days'], + '#weight' => 0, + ); return $form; } @@ -127,9 +133,11 @@ function date_default_formatter_settings_summary($field, $instance, $view_mode) case 'date_plain': $format = t('Plain'); break; + case 'format_interval': $format = t('Interval'); break; + default: if (!empty($format_types[$settings['format_type']])) { $format = $format_types[$settings['format_type']]; @@ -148,7 +156,9 @@ function date_default_formatter_settings_summary($field, $instance, $view_mode) 'value' => t('Display Start date only'), 'value2' => t('Display End date only'), ); - $summary[] = $options[$settings['fromto']]; + if (isset($options[$settings['fromto']])) { + $summary[] = $options[$settings['fromto']]; + } } if (array_key_exists('multiple_number', $settings) && !empty($field['cardinality'])) { @@ -159,6 +169,10 @@ function date_default_formatter_settings_summary($field, $instance, $view_mode) )); } + if (array_key_exists('show_remaining_days', $settings)) { + $summary[] = t('Show remaining days: @value', array('@value' => ($settings['show_remaining_days'] ? 'yes' : 'no'))); + } + return $summary; } @@ -191,7 +205,11 @@ function _date_field_instance_settings_form($field, $instance) { '#type' => 'select', '#title' => t('Default date'), '#default_value' => $settings['default_value'], - '#options' => array('blank' => t('No default value'), 'now' => t('Now'), 'strtotime' => t('Relative')), + '#options' => array( + 'blank' => t('No default value'), + 'now' => t('Now'), + 'strtotime' => t('Relative'), + ), '#weight' => 1, '#fieldset' => 'default_values', ); @@ -204,8 +222,11 @@ function _date_field_instance_settings_form($field, $instance) { '#default_value' => $settings['default_value_code'], '#states' => array( 'visible' => array( - ':input[name="instance[settings][default_value]"]' => array('value' => 'strtotime')), + ':input[name="instance[settings][default_value]"]' => array( + 'value' => 'strtotime', + ), ), + ), '#weight' => 1.1, '#fieldset' => 'default_values', ); @@ -213,7 +234,12 @@ function _date_field_instance_settings_form($field, $instance) { '#type' => !empty($field['settings']['todate']) ? 'select' : 'hidden', '#title' => t('Default end date'), '#default_value' => $settings['default_value2'], - '#options' => array('same' => t('Same as Default date'), 'blank' => t('No default value'), 'now' => t('Now'), 'strtotime' => t('Relative')), + '#options' => array( + 'same' => t('Same as Default date'), + 'blank' => t('No default value'), + 'now' => t('Now'), + 'strtotime' => t('Relative'), + ), '#weight' => 2, '#fieldset' => 'default_values', ); @@ -224,8 +250,11 @@ function _date_field_instance_settings_form($field, $instance) { '#default_value' => $settings['default_value_code2'], '#states' => array( 'visible' => array( - ':input[name="instance[settings][default_value2]"]' => array('value' => 'strtotime')), + ':input[name="instance[settings][default_value2]"]' => array( + 'value' => 'strtotime', + ), ), + ), '#weight' => 2.1, '#fieldset' => 'default_values', ); @@ -284,6 +313,7 @@ function _date_field_widget_settings_form($field, $instance) { $formats = drupal_map_assoc($formats); } $now = date_example_date(); + $options['site-wide'] = t('Short date format: @date', array('@date' => date_format_date($now, 'short'))); foreach ($formats as $f) { $options[$f] = date_format_date($now, 'custom', $f); } @@ -369,11 +399,18 @@ function _date_field_widget_settings_form($field, $instance) { '#weight' => 9, ); if (in_array($widget['type'], array('date_select'))) { - $options = array('above' => t('Above'), 'within' => t('Within'), 'none' => t('None')); + $options = array( + 'above' => t('Above'), + 'within' => t('Within'), + 'none' => t('None'), + ); $description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'Within' inserts the label as the first option in the select list and in blank textfields. 'None' doesn't visually label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text."); } else { - $options = array('above' => t('Above'), 'none' => t('None')); + $options = array( + 'above' => t('Above'), + 'none' => t('None'), + ); $description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'None' doesn't visually label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text."); } $form['advanced']['label_position'] = array( @@ -403,6 +440,13 @@ function _date_field_widget_settings_form($field, $instance) { } } + $form['advanced']['no_fieldset'] = array( + '#type' => 'checkbox', + '#title' => t('Render as a regular field'), + '#default_value' => !empty($settings['no_fieldset']), + '#description' => t('Whether to render this field as a regular field instead of a fieldset. The date field elements are wrapped in a fieldset by default, and may not display well without it.'), + ); + $context = array( 'field' => $field, 'instance' => $instance, @@ -470,7 +514,9 @@ function _date_field_settings_form($field, $instance, $has_data) { '#title' => t('Date attributes to collect'), '#default_value' => $granularity, '#options' => $options, - '#attributes' => array('class' => array('container-inline')), + '#attributes' => array( + 'class' => array('container-inline'), + ), '#description' => $description, 'year' => $checkbox_year, ); @@ -528,7 +574,9 @@ function _date_field_settings_form($field, $instance, $has_data) { '#weight' => 11, '#states' => array( 'visible' => array( - 'input[name="field[settings][cache_enabled]"]' => array('checked' => TRUE), + 'input[name="field[settings][cache_enabled]"]' => array( + 'checked' => TRUE, + ), ), ), ); @@ -600,7 +648,7 @@ function date_timezone_handling_options() { 'site' => t("Site's time zone"), 'date' => t("Date's time zone"), 'user' => t("User's time zone"), - 'utc' => 'UTC', + 'utc' => 'UTC', 'none' => t('No time zone conversion'), ); } diff --git a/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.info b/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.info index 8eeb7325..df773e41 100644 --- a/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.info +++ b/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.info @@ -5,9 +5,9 @@ dependencies[] = date package = Date/Time core = 7.x -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.module b/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.module index 93fc61ba..e79bc944 100644 --- a/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.module +++ b/sites/all/modules/contrib/fields/date/date_all_day/date_all_day.module @@ -31,11 +31,11 @@ function date_all_day_theme() { 'format' => NULL, 'entity_type' => NULL, 'entity' => NULL, - 'view' => NULL - ) + 'view' => NULL, + ), ), 'date_all_day_label' => array( - 'variables' => array() + 'variables' => array(), ), ); @@ -91,14 +91,29 @@ function date_all_day_date_formatter_dates_alter(&$dates, $context) { /** * Adjust start/end date format to account for 'all day' . * - * @param array $field, the field definition for this date field. - * @param string $which, which value to return, 'date1' or 'date2' . - * @param object $date1, a date/time object for the 'start' date. - * @param object $date2, a date/time object for the 'end' date. - * @param string $format - * @param object $entity, the node this date comes from (may be incomplete, always contains nid). - * @param object $view, the view this node comes from, if applicable. - * @return formatted date. + * @params array $field + * The field definition for this date field. + * + * @params string $which + * Which value to return, 'date1' or 'date2'. + * + * @params object $date1 + * A date/time object for the 'start' date. + * + * @params object $date2 + * A date/time object for the 'end' date. + * + * @params string $format + * A date/time format + * + * @params object $entity + * The node this date comes from (may be incomplete, always contains nid). + * + * @params object $view + * The view this node comes from, if applicable. + * + * @return string + * Formatted date. */ function theme_date_all_day($vars) { $field = $vars['field']; @@ -135,23 +150,32 @@ function theme_date_all_day($vars) { } return trim(date_format_date($$which, 'custom', $format) . $suffix); - } /** * Theme the way an 'all day' label will look. */ function theme_date_all_day_label() { - return '(' . t('All day', array(), array('context' => 'datetime')) .')'; + return '(' . t('All day', array(), array('context' => 'datetime')) . ')'; } /** * Determine if a Start/End date combination qualify as 'All day'. * - * @param array $field, the field definition for this date field. - * @param object $date1, a date/time object for the 'Start' date. - * @param object $date2, a date/time object for the 'End' date. - * @return TRUE or FALSE. + * @param array $field + * The field definition for this date field. + * + * @param array $instance + * The field instance for this date field. + * + * @param object $date1 + * A date/time object for the 'Start' date. + * + * @param object $date2 + * A date/time object for the 'End' date. + * + * @return bool + * TRUE or FALSE. */ function date_all_day_field($field, $instance, $date1, $date2 = NULL) { if (empty($date1) || !is_object($date1)) { @@ -167,7 +191,6 @@ function date_all_day_field($field, $instance, $date1, $date2 = NULL) { $granularity = date_granularity_precision($field['settings']['granularity']); $increment = isset($instance['widget']['settings']['increment']) ? $instance['widget']['settings']['increment'] : 1; return date_is_all_day(date_format($date1, DATE_FORMAT_DATETIME), date_format($date2, DATE_FORMAT_DATETIME), $granularity, $increment); - } /** @@ -222,7 +245,8 @@ function date_all_day_date_combo_process_alter(&$element, &$form_state, $context function date_all_day_date_text_process_alter(&$element, &$form_state, $context) { $all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : ''; if ($all_day_id != '') { - // All Day handling on text dates works only if the user leaves the time out of the input value. + // All Day handling on text dates works only + // if the user leaves the time out of the input value. // There is no element to hide or show. } } @@ -234,10 +258,11 @@ function date_all_day_date_text_process_alter(&$element, &$form_state, $context) */ function date_all_day_date_select_process_alter(&$element, &$form_state, $context) { - // Hide or show this element in reaction to the all_day status for this element. + // Hide or show this element in reaction + // to the all_day status for this element. $all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : ''; if ($all_day_id != '') { - foreach(array('hour', 'minute', 'second', 'ampm') as $field) { + foreach (array('hour', 'minute', 'second', 'ampm') as $field) { if (array_key_exists($field, $element)) { $element[$field]['#states'] = array( 'visible' => array( @@ -255,7 +280,8 @@ function date_all_day_date_select_process_alter(&$element, &$form_state, $contex */ function date_all_day_date_popup_process_alter(&$element, &$form_state, $context) { - // Hide or show this element in reaction to the all_day status for this element. + // Hide or show this element in reaction to + // the all_day status for this element. $all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : ''; if ($all_day_id != '' && array_key_exists('time', $element)) { $element['time']['#states'] = array( @@ -272,7 +298,8 @@ function date_all_day_date_popup_process_alter(&$element, &$form_state, $context * of the date_select validation gets fired. */ function date_all_day_date_text_pre_validate_alter(&$element, &$form_state, &$input) { - // Let Date module massage the format for all day values so they will pass validation. + // Let Date module massage the format for all day + // values so they will pass validation. // The All day flag, if used, actually exists on the parent element. date_all_day_value($element, $form_state); } @@ -284,7 +311,8 @@ function date_all_day_date_text_pre_validate_alter(&$element, &$form_state, &$in * of the date_select validation gets fired. */ function date_all_day_date_select_pre_validate_alter(&$element, &$form_state, &$input) { - // Let Date module massage the format for all day values so they will pass validation. + // Let Date module massage the format for all + // day values so they will pass validation. // The All day flag, if used, actually exists on the parent element. date_all_day_value($element, $form_state); } @@ -296,13 +324,16 @@ function date_all_day_date_select_pre_validate_alter(&$element, &$form_state, &$ * of the date_popup validation gets fired. */ function date_all_day_date_popup_pre_validate_alter(&$element, &$form_state, &$input) { - // Let Date module massage the format for all day values so they will pass validation. + // Let Date module massage the format for all + // day values so they will pass validation. // The All day flag, if used, actually exists on the parent element. date_all_day_value($element, $form_state); } /** - * A helper function to check if the all day flag is set on the parent of an + * A helper function date_all_day_value(). + * + * To check if the all day flag is set on the parent of an * element, and adjust the date_format accordingly so the missing time will * not cause validation errors. */ @@ -332,7 +363,8 @@ function date_all_day_date_combo_pre_validate_alter(&$element, &$form_state, $co $field = $context['field']; // If we have an all day flag on this date and the time is empty, - // change the format to match the input value so we don't get validation errors. + // change the format to match the input value + // so we don't get validation errors. $element['#date_is_all_day'] = TRUE; $element['value']['#date_format'] = date_part_format('date', $element['value']['#date_format']); if (!empty($field['settings']['todate'])) { @@ -344,29 +376,29 @@ function date_all_day_date_combo_pre_validate_alter(&$element, &$form_state, $co /** * Implements hook_date_combo_validate_date_start_alter(). * - * This hook lets us alter the local date objects created by the date_combo validation - * before they are converted back to the database timezone and stored. + * This hook lets us alter the local date objects + * created by the date_combo validation before they are + * converted back to the database timezone and stored. */ function date_all_day_date_combo_validate_date_start_alter(&$date, &$form_state, $context) { - - // If this is an 'All day' value, set the time to midnight. - if (!empty($context['element']['#date_is_all_day'])) { - $date->setTime(0, 0, 0); - } + // If this is an 'All day' value, set the time to midnight. + if (!empty($context['element']['#date_is_all_day'])) { + $date->setTime(0, 0, 0); + } } /** * Implements hook_date_combo_validate_date_end_alter(). * - * This hook lets us alter the local date objects created by the date_combo validation - * before they are converted back to the database timezone and stored. + * This hook lets us alter the local date objects + * created by the date_combo validation before + * they are converted back to the database timezone and stored. */ function date_all_day_date_combo_validate_date_end_alter(&$date, &$form_state, $context) { - - // If this is an 'All day' value, set the time to midnight. - if (!empty($context['element']['#date_is_all_day'])) { - $date->setTime(0, 0, 0); - } + // If this is an 'All day' value, set the time to midnight. + if (!empty($context['element']['#date_is_all_day'])) { + $date->setTime(0, 0, 0); + } } /** diff --git a/sites/all/modules/contrib/fields/date/date_api/date.css b/sites/all/modules/contrib/fields/date/date_api/date.css index 9b72ecdb..e47a2ae2 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date.css +++ b/sites/all/modules/contrib/fields/date/date_api/date.css @@ -15,9 +15,11 @@ .container-inline-date > .form-item { display: inline-block; margin-right: 0.5em; /* LTR */ - margin-bottom: 10px; vertical-align: top; } +fieldset.date-combo .container-inline-date > .form-item { + margin-bottom: 10px; +} .container-inline-date .form-item .form-item { float: left; /* LTR */ } @@ -52,9 +54,11 @@ /* The exposed Views form doesn't need some of these styles */ .container-inline-date .date-padding { - padding: 10px; float: left; } +fieldset.date-combo .container-inline-date .date-padding { + padding: 10px; +} .views-exposed-form .container-inline-date .date-padding { padding: 0; } @@ -116,7 +120,7 @@ span.date-display-end { } /* Add space between the date and time portions of the date_select widget. */ -.form-type-date-select .form-type-select[class$=hour] { +.form-type-date-select .form-type-select[class*=hour] { margin-left: .75em; /* LTR */ } @@ -173,6 +177,10 @@ div.date-calendar-day span.year { padding: 2px; } +.date-form-element-content-multiline { + padding: 10px; + border: 1px solid #CCC; +} /* Admin styling */ .form-item.form-item-instance-widget-settings-input-format-custom, .form-item.form-item-field-settings-enddate-required { diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api.admin.inc b/sites/all/modules/contrib/fields/date/date_api/date_api.admin.inc index 966b1a42..3c706aeb 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api.admin.inc +++ b/sites/all/modules/contrib/fields/date/date_api/date_api.admin.inc @@ -10,112 +10,112 @@ */ function _date_timezone_replacement($old) { $replace = array( - 'Brazil/Acre' => 'America/Rio_Branco', - 'Brazil/DeNoronha' => 'America/Noronha', - 'Brazil/East' => 'America/Recife', - 'Brazil/West' => 'America/Manaus', - 'Canada/Atlantic' => 'America/Halifax', - 'Canada/Central' => 'America/Winnipeg', - 'Canada/East-Saskatchewan' => 'America/Regina', - 'Canada/Eastern' => 'America/Toronto', - 'Canada/Mountain' => 'America/Edmonton', - 'Canada/Newfoundland' => 'America/St_Johns', - 'Canada/Pacific' => 'America/Vancouver', - 'Canada/Saskatchewan' => 'America/Regina', - 'Canada/Yukon' => 'America/Whitehorse', - 'CET' => 'Europe/Berlin', - 'Chile/Continental' => 'America/Santiago', - 'Chile/EasterIsland' => 'Pacific/Easter', - 'CST6CDT' => 'America/Chicago', - 'Cuba' => 'America/Havana', - 'EET' => 'Europe/Bucharest', - 'Egypt' => 'Africa/Cairo', - 'Eire' => 'Europe/Belfast', - 'EST' => 'America/New_York', - 'EST5EDT' => 'America/New_York', - 'GB' => 'Europe/London', - 'GB-Eire' => 'Europe/Belfast', - 'Etc/GMT' => 'UTC', - 'Etc/GMT+0' => 'UTC', - 'Etc/GMT+1' => 'UTC', - 'Etc/GMT+10' => 'UTC', - 'Etc/GMT+11' => 'UTC', - 'Etc/GMT+12' => 'UTC', - 'Etc/GMT+2' => 'UTC', - 'Etc/GMT+3' => 'UTC', - 'Etc/GMT+4' => 'UTC', - 'Etc/GMT+5' => 'UTC', - 'Etc/GMT+6' => 'UTC', - 'Etc/GMT+7' => 'UTC', - 'Etc/GMT+8' => 'UTC', - 'Etc/GMT+9' => 'UTC', - 'Etc/GMT-0' => 'UTC', - 'Etc/GMT-1' => 'UTC', - 'Etc/GMT-10' => 'UTC', - 'Etc/GMT-11' => 'UTC', - 'Etc/GMT-12' => 'UTC', - 'Etc/GMT-13' => 'UTC', - 'Etc/GMT-14' => 'UTC', - 'Etc/GMT-2' => 'UTC', - 'Etc/GMT-3' => 'UTC', - 'Etc/GMT-4' => 'UTC', - 'Etc/GMT-5' => 'UTC', - 'Etc/GMT-6' => 'UTC', - 'Etc/GMT-7' => 'UTC', - 'Etc/GMT-8' => 'UTC', - 'Etc/GMT-9' => 'UTC', - 'Etc/GMT0' => 'UTC', - 'Etc/Greenwich' => 'UTC', - 'Etc/UCT' => 'UTC', - 'Etc/Universal' => 'UTC', - 'Etc/UTC' => 'UTC', - 'Etc/Zulu' => 'UTC', - 'Factory' => 'UTC', - 'GMT' => 'UTC', - 'GMT+0' => 'UTC', - 'GMT-0' => 'UTC', - 'GMT0' => 'UTC', - 'Hongkong' => 'Asia/Hong_Kong', - 'HST' => 'Pacific/Honolulu', - 'Iceland' => 'Atlantic/Reykjavik', - 'Iran' => 'Asia/Tehran', - 'Israel' => 'Asia/Tel_Aviv', - 'Jamaica' => 'America/Jamaica', - 'Japan' => 'Asia/Tokyo', - 'Kwajalein' => 'Pacific/Kwajalein', - 'Libya' => 'Africa/Tunis', - 'MET' => 'Europe/Budapest', - 'Mexico/BajaNorte' => 'America/Tijuana', - 'Mexico/BajaSur' => 'America/Mazatlan', - 'Mexico/General' => 'America/Mexico_City', - 'MST' => 'America/Boise', - 'MST7MDT' => 'America/Boise', - 'Navajo' => 'America/Phoenix', - 'NZ' => 'Pacific/Auckland', - 'NZ-CHAT' => 'Pacific/Chatham', - 'Poland' => 'Europe/Warsaw', - 'Portugal' => 'Europe/Lisbon', - 'PRC' => 'Asia/Chongqing', - 'PST8PDT' => 'America/Los_Angeles', - 'ROC' => 'Asia/Taipei', - 'ROK' => 'Asia/Seoul', - 'Singapore' => 'Asia/Singapore', - 'Turkey' => 'Europe/Istanbul', - 'US/Alaska' => 'America/Anchorage', - 'US/Aleutian' => 'America/Adak', - 'US/Arizona' => 'America/Phoenix', - 'US/Central' => 'America/Chicago', - 'US/East-Indiana' => 'America/Indianapolis', - 'US/Eastern' => 'America/New_York', - 'US/Hawaii' => 'Pacific/Honolulu', - 'US/Indiana-Starke' => 'America/Indiana/Knox', - 'US/Michigan' => 'America/Detroit', - 'US/Mountain' => 'America/Boise', - 'US/Pacific' => 'America/Los_Angeles', - 'US/Pacific-New' => 'America/Los_Angeles', - 'US/Samoa' => 'Pacific/Samoa', - 'W-SU' => 'Europe/Moscow', - 'WET' => 'Europe/Paris', + 'Brazil/Acre' => 'America/Rio_Branco', + 'Brazil/DeNoronha' => 'America/Noronha', + 'Brazil/East' => 'America/Recife', + 'Brazil/West' => 'America/Manaus', + 'Canada/Atlantic' => 'America/Halifax', + 'Canada/Central' => 'America/Winnipeg', + 'Canada/East-Saskatchewan' => 'America/Regina', + 'Canada/Eastern' => 'America/Toronto', + 'Canada/Mountain' => 'America/Edmonton', + 'Canada/Newfoundland' => 'America/St_Johns', + 'Canada/Pacific' => 'America/Vancouver', + 'Canada/Saskatchewan' => 'America/Regina', + 'Canada/Yukon' => 'America/Whitehorse', + 'CET' => 'Europe/Berlin', + 'Chile/Continental' => 'America/Santiago', + 'Chile/EasterIsland' => 'Pacific/Easter', + 'CST6CDT' => 'America/Chicago', + 'Cuba' => 'America/Havana', + 'EET' => 'Europe/Bucharest', + 'Egypt' => 'Africa/Cairo', + 'Eire' => 'Europe/Belfast', + 'EST' => 'America/New_York', + 'EST5EDT' => 'America/New_York', + 'GB' => 'Europe/London', + 'GB-Eire' => 'Europe/Belfast', + 'Etc/GMT' => 'UTC', + 'Etc/GMT+0' => 'UTC', + 'Etc/GMT+1' => 'UTC', + 'Etc/GMT+10' => 'UTC', + 'Etc/GMT+11' => 'UTC', + 'Etc/GMT+12' => 'UTC', + 'Etc/GMT+2' => 'UTC', + 'Etc/GMT+3' => 'UTC', + 'Etc/GMT+4' => 'UTC', + 'Etc/GMT+5' => 'UTC', + 'Etc/GMT+6' => 'UTC', + 'Etc/GMT+7' => 'UTC', + 'Etc/GMT+8' => 'UTC', + 'Etc/GMT+9' => 'UTC', + 'Etc/GMT-0' => 'UTC', + 'Etc/GMT-1' => 'UTC', + 'Etc/GMT-10' => 'UTC', + 'Etc/GMT-11' => 'UTC', + 'Etc/GMT-12' => 'UTC', + 'Etc/GMT-13' => 'UTC', + 'Etc/GMT-14' => 'UTC', + 'Etc/GMT-2' => 'UTC', + 'Etc/GMT-3' => 'UTC', + 'Etc/GMT-4' => 'UTC', + 'Etc/GMT-5' => 'UTC', + 'Etc/GMT-6' => 'UTC', + 'Etc/GMT-7' => 'UTC', + 'Etc/GMT-8' => 'UTC', + 'Etc/GMT-9' => 'UTC', + 'Etc/GMT0' => 'UTC', + 'Etc/Greenwich' => 'UTC', + 'Etc/UCT' => 'UTC', + 'Etc/Universal' => 'UTC', + 'Etc/UTC' => 'UTC', + 'Etc/Zulu' => 'UTC', + 'Factory' => 'UTC', + 'GMT' => 'UTC', + 'GMT+0' => 'UTC', + 'GMT-0' => 'UTC', + 'GMT0' => 'UTC', + 'Hongkong' => 'Asia/Hong_Kong', + 'HST' => 'Pacific/Honolulu', + 'Iceland' => 'Atlantic/Reykjavik', + 'Iran' => 'Asia/Tehran', + 'Israel' => 'Asia/Tel_Aviv', + 'Jamaica' => 'America/Jamaica', + 'Japan' => 'Asia/Tokyo', + 'Kwajalein' => 'Pacific/Kwajalein', + 'Libya' => 'Africa/Tunis', + 'MET' => 'Europe/Budapest', + 'Mexico/BajaNorte' => 'America/Tijuana', + 'Mexico/BajaSur' => 'America/Mazatlan', + 'Mexico/General' => 'America/Mexico_City', + 'MST' => 'America/Boise', + 'MST7MDT' => 'America/Boise', + 'Navajo' => 'America/Phoenix', + 'NZ' => 'Pacific/Auckland', + 'NZ-CHAT' => 'Pacific/Chatham', + 'Poland' => 'Europe/Warsaw', + 'Portugal' => 'Europe/Lisbon', + 'PRC' => 'Asia/Chongqing', + 'PST8PDT' => 'America/Los_Angeles', + 'ROC' => 'Asia/Taipei', + 'ROK' => 'Asia/Seoul', + 'Singapore' => 'Asia/Singapore', + 'Turkey' => 'Europe/Istanbul', + 'US/Alaska' => 'America/Anchorage', + 'US/Aleutian' => 'America/Adak', + 'US/Arizona' => 'America/Phoenix', + 'US/Central' => 'America/Chicago', + 'US/East-Indiana' => 'America/Indianapolis', + 'US/Eastern' => 'America/New_York', + 'US/Hawaii' => 'Pacific/Honolulu', + 'US/Indiana-Starke' => 'America/Indiana/Knox', + 'US/Michigan' => 'America/Detroit', + 'US/Mountain' => 'America/Boise', + 'US/Pacific' => 'America/Los_Angeles', + 'US/Pacific-New' => 'America/Los_Angeles', + 'US/Samoa' => 'Pacific/Samoa', + 'W-SU' => 'Europe/Moscow', + 'WET' => 'Europe/Paris', ); if (array_key_exists($old, $replace)) { return $replace[$old]; diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api.info b/sites/all/modules/contrib/fields/date/date_api/date_api.info index 3ca86e65..40fbb056 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api.info +++ b/sites/all/modules/contrib/fields/date/date_api/date_api.info @@ -9,9 +9,9 @@ stylesheets[all][] = date.css files[] = date_api.module files[] = date_api_sql.inc -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api.install b/sites/all/modules/contrib/fields/date/date_api/date_api.install index ce5b746d..d5a68bbd 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api.install +++ b/sites/all/modules/contrib/fields/date/date_api/date_api.install @@ -96,7 +96,7 @@ function date_api_uninstall() { 'date_php_min_year', 'date_db_tz_support', 'date_api_use_iso8601', - ); + ); foreach ($variables as $variable) { variable_del($variable); } @@ -118,8 +118,9 @@ function date_api_update_last_removed() { } /** - * Move old date format data to new date format tables, and delete the old - * tables. Insert only values that don't already exist in the new tables, in + * Move old date format to new date format tables,and delete the old tables. + * + * Insert only values that don't already exist in the new tables, in * case new version of those custom values have already been created. */ function date_api_update_7000() { diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api.module b/sites/all/modules/contrib/fields/date/date_api/date_api.module index b1be6e5f..2a973ccf 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api.module +++ b/sites/all/modules/contrib/fields/date/date_api/date_api.module @@ -59,16 +59,16 @@ function date_help($path, $arg) { } if (module_exists('date_tools')) { - $output .= '

Date Tools

' . t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and with a date field. ', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard'))); + $output .= '

Date Tools

' . t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and with a date field.', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard'))); } else { - $output .= '

Date Tools

' . t('Dates and calendars can be complicated to set up. If you enable the Date Tools module, it provides a Date Wizard that makes it easy to create a simple date content type with a date field. '); + $output .= '

Date Tools

' . t('Dates and calendars can be complicated to set up. If you enable the Date Tools module, it provides a Date Wizard that makes it easy to create a simple date content type with a date field.'); } $output .= '

More Information

' . t('Complete documentation for the Date and Date API modules is available at http://drupal.org/node/92460.', array('@link' => 'http://drupal.org/node/262062')) . '

'; return $output; - break; + } } @@ -101,7 +101,7 @@ function date_api_status() { $value = variable_get('date_format_medium'); if (isset($value)) { $now = date_now(); - $success_messages[] = $t('The medium date format type has been set to to @value. You may find it helpful to add new format types like Date, Time, Month, or Year, with appropriate formats, at Date and time settings.', array('@value' => $now->format($value), '@regional_date_time' => url('admin/config/regional/date-time'))); + $success_messages[] = $t('The medium date format type has been set to @value. You may find it helpful to add new format types like Date, Time, Month, or Year, with appropriate formats, at Date and time settings.', array('@value' => $now->format($value), '@regional_date_time' => url('admin/config/regional/date-time'))); } else { $error_messages[] = $t('The Date API requires that you set up the system date formats to function correctly.', array('@regional_date_time' => url('admin/config/regional/date-time'))); @@ -143,7 +143,15 @@ function date_api_menu() { class DateObject extends DateTime { public $granularity = array(); public $errors = array(); - protected static $allgranularity = array('year', 'month', 'day', 'hour', 'minute', 'second', 'timezone'); + protected static $allgranularity = array( + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timezone' + ); private $serializedTime; private $serializedTimezone; @@ -402,7 +410,7 @@ class DateObject extends DateTime { * A single date part. */ public function removeGranularity($g) { - if ($key = array_search($g, $this->granularity)) { + if (($key = array_search($g, $this->granularity)) !== FALSE) { unset($this->granularity[$key]); } } @@ -458,23 +466,35 @@ class DateObject extends DateTime { $true = $this->hasGranularity() && (!$granularity || $flexible || $this->hasGranularity($granularity)); if (!$true && $granularity) { foreach ((array) $granularity as $part) { - if (!$this->hasGranularity($part) && in_array($part, array('second', 'minute', 'hour', 'day', 'month', 'year'))) { + if (!$this->hasGranularity($part) && in_array($part, array( + 'second', + 'minute', + 'hour', + 'day', + 'month', + 'year') + )) { switch ($part) { case 'second': $this->errors[$part] = t('The second is missing.'); break; + case 'minute': $this->errors[$part] = t('The minute is missing.'); break; + case 'hour': $this->errors[$part] = t('The hour is missing.'); break; + case 'day': $this->errors[$part] = t('The day is missing.'); break; + case 'month': $this->errors[$part] = t('The month is missing.'); break; + case 'year': $this->errors[$part] = t('The year is missing.'); break; @@ -537,7 +557,14 @@ class DateObject extends DateTime { $temp = date_parse($time); // Special case for 'now'. if ($time == 'now') { - $this->granularity = array('year', 'month', 'day', 'hour', 'minute', 'second'); + $this->granularity = array( + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + ); } else { // This PHP date_parse() method currently doesn't have resolution down to @@ -600,7 +627,14 @@ class DateObject extends DateTime { return FALSE; } $this->granularity = array(); - $final_date = array('hour' => 0, 'minute' => 0, 'second' => 0, 'month' => 1, 'day' => 1, 'year' => 0); + $final_date = array( + 'hour' => 0, + 'minute' => 0, + 'second' => 0, + 'month' => 1, + 'day' => 1, + 'year' => 0, + ); foreach ($letters as $i => $letter) { $value = $values[$i]; switch ($letter) { @@ -609,21 +643,25 @@ class DateObject extends DateTime { $final_date['day'] = intval($value); $this->addGranularity('day'); break; + case 'n': case 'm': $final_date['month'] = intval($value); $this->addGranularity('month'); break; + case 'F': $array_month_long = array_flip(date_month_names()); $final_date['month'] = array_key_exists($value, $array_month_long) ? $array_month_long[$value] : -1; $this->addGranularity('month'); break; + case 'M': $array_month = array_flip(date_month_names_abbr()); $final_date['month'] = array_key_exists($value, $array_month) ? $array_month[$value] : -1; $this->addGranularity('month'); break; + case 'Y': $final_date['year'] = $value; $this->addGranularity('year'); @@ -631,16 +669,19 @@ class DateObject extends DateTime { $this->errors['year'] = t('The year is invalid. Please check that entry includes four digits.'); } break; + case 'y': $year = $value; // If no century, we add the current one ("06" => "2006"). $final_date['year'] = str_pad($year, 4, substr(date("Y"), 0, 2), STR_PAD_LEFT); $this->addGranularity('year'); break; + case 'a': case 'A': $ampm = strtolower($value); break; + case 'g': case 'h': case 'G': @@ -648,14 +689,17 @@ class DateObject extends DateTime { $final_date['hour'] = intval($value); $this->addGranularity('hour'); break; + case 'i': $final_date['minute'] = intval($value); $this->addGranularity('minute'); break; + case 's': $final_date['second'] = intval($value); $this->addGranularity('second'); break; + case 'U': parent::__construct($value, $tz ? $tz : new DateTimeZone("UTC")); $this->addGranularity('year'); @@ -665,7 +709,7 @@ class DateObject extends DateTime { $this->addGranularity('minute'); $this->addGranularity('second'); return $this; - break; + } } if (isset($ampm) && $ampm == 'pm' && $final_date['hour'] < 12) { @@ -758,10 +802,24 @@ class DateObject extends DateTime { // date or we will get date slippage, i.e. a value of 2011-00-00 will get // interpreted as November of 2010 by PHP. if ($full) { - $arr += array('year' => 0, 'month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0); + $arr += array( + 'year' => 0, + 'month' => 1, + 'day' => 1, + 'hour' => 0, + 'minute' => 0, + 'second' => 0, + ); } else { - $arr += array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''); + $arr += array( + 'year' => '', + 'month' => '', + 'day' => '', + 'hour' => '', + 'minute' => '', + 'second' => '', + ); } $datetime = ''; if ($arr['year'] !== '') { @@ -839,28 +897,27 @@ class DateObject extends DateTime { case 'year': $fallback = $now->format('Y'); return !is_int($value) || empty($value) || $value < variable_get('date_min_year', 1) || $value > variable_get('date_max_year', 4000) ? $fallback : $value; - break; + case 'month': $fallback = $default == 'first' ? 1 : $now->format('n'); return !is_int($value) || empty($value) || $value <= 0 || $value > 12 ? $fallback : $value; - break; + case 'day': $fallback = $default == 'first' ? 1 : $now->format('j'); $max_day = isset($year) && isset($month) ? date_days_in_month($year, $month) : 31; return !is_int($value) || empty($value) || $value <= 0 || $value > $max_day ? $fallback : $value; - break; + case 'hour': $fallback = $default == 'first' ? 0 : $now->format('G'); return !is_int($value) || $value < 0 || $value > 23 ? $fallback : $value; - break; + case 'minute': $fallback = $default == 'first' ? 0 : $now->format('i'); return !is_int($value) || $value < 0 || $value > 59 ? $fallback : $value; - break; + case 'second': $fallback = $default == 'first' ? 0 : $now->format('s'); return !is_int($value) || $value < 0 || $value > 59 ? $fallback : $value; - break; } } @@ -898,18 +955,23 @@ class DateObject extends DateTime { case 'year': $errors['year'] = t('The year is invalid.'); break; + case 'month': $errors['month'] = t('The month is invalid.'); break; + case 'day': $errors['day'] = t('The day is invalid.'); break; + case 'hour': $errors['hour'] = t('The hour is invalid.'); break; + case 'minute': $errors['minute'] = t('The minute is invalid.'); break; + case 'second': $errors['second'] = t('The second is invalid.'); break; @@ -929,7 +991,7 @@ class DateObject extends DateTime { * The stop date. * @param string $measure * (optional) A granularity date part. Defaults to 'seconds'. - * @param boolean $absolute + * @param bool $absolute * (optional) Indicate whether the absolute value of the difference should * be returned or if the sign should be retained. Defaults to TRUE. */ @@ -955,10 +1017,13 @@ class DateObject extends DateTime { // The easy cases first. case 'seconds': return $diff; + case 'minutes': return $diff / 60; + case 'hours': return $diff / 3600; + case 'years': return $year_diff; @@ -1013,7 +1078,7 @@ class DateObject extends DateTime { $sign = ($year_diff < 0) ? -1 : 1; for ($i = 1; $i <= abs($year_diff); $i++) { - date_modify($date1, (($sign > 0) ? '+': '-').'1 year'); + date_modify($date1, (($sign > 0) ? '+' : '-') . '1 year'); $week_diff += (date_iso_weeks_in_year($date1) * $sign); } return $week_diff; @@ -1060,10 +1125,13 @@ function date_type_format($type) { switch ($type) { case DATE_ISO: return DATE_FORMAT_ISO; + case DATE_UNIX: return DATE_FORMAT_UNIX; + case DATE_DATETIME: return DATE_FORMAT_DATETIME; + case DATE_ICAL: return DATE_FORMAT_ICAL; } @@ -1119,7 +1187,7 @@ function date_month_names($required = FALSE) { } /** - * Constructs a translated array of month name abbreviations + * Constructs a translated array of month name abbreviations. * * @param bool $required * (optional) If FALSE, the returned array will include a blank value. @@ -1211,9 +1279,11 @@ function date_week_days_abbr($required = FALSE, $refresh = TRUE, $length = 3) { case 1: $context = 'day_abbr1'; break; + case 2: $context = 'day_abbr2'; break; + default: $context = ''; break; @@ -1248,10 +1318,10 @@ function date_week_days_ordered($weekdays) { /** * Constructs an array of years. * - * @param int $min - * The minimum year in the array. - * @param int $max - * The maximum year in the array. + * @param int $start + * The start year in the array. + * @param int $end + * The end year in the array. * @param bool $required * (optional) If FALSE, the returned array will include a blank value. * Defaults to FALSE. @@ -1259,16 +1329,16 @@ function date_week_days_ordered($weekdays) { * @return array * An array of years in the selected range. */ -function date_years($min = 0, $max = 0, $required = FALSE) { +function date_years($start = 0, $end = 0, $required = FALSE) { // Ensure $min and $max are valid values. - if (empty($min)) { - $min = intval(date('Y', REQUEST_TIME) - 3); + if (empty($start)) { + $start = intval(date('Y', REQUEST_TIME) - 3); } - if (empty($max)) { - $max = intval(date('Y', REQUEST_TIME) + 3); + if (empty($end)) { + $end = intval(date('Y', REQUEST_TIME) + 3); } $none = array(0 => ''); - return !$required ? $none + drupal_map_assoc(range($min, $max)) : drupal_map_assoc(range($min, $max)); + return !$required ? $none + drupal_map_assoc(range($start, $end)) : drupal_map_assoc(range($start, $end)); } /** @@ -1474,7 +1544,14 @@ function date_granularity_names() { * An array of date parts. */ function date_granularity_sorted($granularity) { - return array_intersect(array('year', 'month', 'day', 'hour', 'minute', 'second'), $granularity); + return array_intersect(array( + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + ), $granularity); } /** @@ -1492,14 +1569,19 @@ function date_granularity_array_from_precision($precision) { switch ($precision) { case 'year': return array_slice($granularity_array, -6, 1); + case 'month': return array_slice($granularity_array, -6, 2); + case 'day': return array_slice($granularity_array, -6, 3); + case 'hour': return array_slice($granularity_array, -6, 4); + case 'minute': return array_slice($granularity_array, -6, 5); + default: return $granularity_array; } @@ -1533,14 +1615,19 @@ function date_granularity_format($granularity) { switch ($granularity) { case 'year': return substr($format, 0, 1); + case 'month': return substr($format, 0, 3); + case 'day': return substr($format, 0, 5); + case 'hour'; return substr($format, 0, 7); + case 'minute': return substr($format, 0, 9); + default: return $format; } @@ -1657,40 +1744,51 @@ function date_format_date($date, $type = 'medium', $format = '', $langcode = NUL case 'l': $datestring .= t($date->format('l'), array(), array('context' => '', 'langcode' => $langcode)); break; + case 'D': $datestring .= t($date->format('D'), array(), array('context' => '', 'langcode' => $langcode)); break; + case 'F': $datestring .= t($date->format('F'), array(), array('context' => 'Long month name', 'langcode' => $langcode)); break; + case 'M': $datestring .= t($date->format('M'), array(), array('langcode' => $langcode)); break; + case 'A': case 'a': $datestring .= t($date->format($c), array(), array('context' => 'ampm', 'langcode' => $langcode)); break; + // The timezone name translations can use t(). case 'e': case 'T': $datestring .= t($date->format($c)); break; + // Remaining date parts need no translation. case 'O': $datestring .= sprintf('%s%02d%02d', (date_offset_get($date) < 0 ? '-' : '+'), abs(date_offset_get($date) / 3600), abs(date_offset_get($date) % 3600) / 60); break; + case 'P': $datestring .= sprintf('%s%02d:%02d', (date_offset_get($date) < 0 ? '-' : '+'), abs(date_offset_get($date) / 3600), abs(date_offset_get($date) % 3600) / 60); break; + case 'Z': $datestring .= date_offset_get($date); break; + case '\\': $datestring .= $format[++$i]; break; + case 'r': - $datestring .= date_format_date($date, 'custom', 'D, d M Y H:i:s O', $langcode); + $datestring .= date_format_date($date, 'custom', 'D, d M Y H:i:s O', 'en'); break; + default: if (strpos('BdcgGhHiIjLmnNosStTuUwWYyz', $c) !== FALSE) { $datestring .= $date->format($c); @@ -1739,8 +1837,8 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) { * (optional) Optionally force time to a specific timezone, defaults to user * timezone, if set, otherwise site timezone. Defaults to NULL. * - * @param boolean $reset [optional] - * Static cache reset + * @param bool $reset + * (optional) Static cache reset. * * @return object * The current time as a date object. @@ -1831,7 +1929,7 @@ function date_days_in_month($year, $month) { * @param mixed $date * (optional) The current date object, or a date string. Defaults to NULL. * - * @return integer + * @return int * The number of days in the year. */ function date_days_in_year($date = NULL) { @@ -1860,7 +1958,7 @@ function date_days_in_year($date = NULL) { * @param mixed $date * (optional) The current date object, or a date string. Defaults to NULL. * - * @return integer + * @return int * The number of ISO weeks in a year. */ function date_iso_weeks_in_year($date = NULL) { @@ -1952,7 +2050,7 @@ function date_week_range($week, $year) { // Move forwards to the last day of the week. $max_date = clone($min_date); - date_modify($max_date, '+7 days'); + date_modify($max_date, '+6 days'); if (date_format($min_date, 'Y') != $year) { $min_date = new DateObject($year . '-01-01 00:00:00'); @@ -1986,7 +2084,7 @@ function date_iso_week_range($week, $year) { // Move forwards to the last day of the week. $max_date = clone($min_date); - date_modify($max_date, '+7 days'); + date_modify($max_date, '+6 days'); return array($min_date, $max_date); } @@ -2094,7 +2192,8 @@ function date_has_time($granularity) { if (!is_array($granularity)) { $granularity = array(); } - return (bool) count(array_intersect($granularity, array('hour', 'minute', 'second'))); + $options = array('hour', 'minute', 'second'); + return (bool) count(array_intersect($granularity, $options)); } /** @@ -2110,7 +2209,8 @@ function date_has_date($granularity) { if (!is_array($granularity)) { $granularity = array(); } - return (bool) count(array_intersect($granularity, array('year', 'month', 'day'))); + $options = array('year', 'month', 'day'); + return (bool) count(array_intersect($granularity, $options)); } /** @@ -2128,8 +2228,10 @@ function date_part_format($part, $format) { switch ($part) { case 'date': return date_limit_format($format, array('year', 'month', 'day')); + case 'time': return date_limit_format($format, array('hour', 'minute', 'second')); + default: return date_limit_format($format, array($part)); } @@ -2157,7 +2259,7 @@ function date_limit_format($format, $granularity) { $drupal_static_fast['formats'] = &drupal_static(__FUNCTION__); } $formats = &$drupal_static_fast['formats']; - $format_granularity_cid = $format .'|'. implode(',', $granularity); + $format_granularity_cid = $format . '|' . implode(',', $granularity); if (isset($formats[$format_granularity_cid])) { return $formats[$format_granularity_cid]; } @@ -2191,21 +2293,27 @@ function date_limit_format($format, $granularity) { case 'year': $regex[] = '([\-/\.,:]?\s?(? "$path/theme", ); return array( - 'date_nav_title' => $base + array('variables' => array('granularity' => NULL, 'view' => NULL, 'link' => NULL, 'format' => NULL)), + 'date_nav_title' => $base + array( + 'variables' => array( + 'granularity' => NULL, 'view' => NULL, 'link' => NULL, 'format' => NULL + ), + ), 'date_timezone' => $base + array('render element' => 'element'), 'date_select' => $base + array('render element' => 'element'), 'date_text' => $base + array('render element' => 'element'), @@ -2355,7 +2481,11 @@ function date_api_theme($existing, $type, $theme, $path) { 'date_part_label_time' => $base + array('variables' => array('date_part' => NULL, 'element' => NULL)), 'date_views_filter_form' => $base + array('template' => 'date-views-filter-form', 'render element' => 'form'), 'date_calendar_day' => $base + array('variables' => array('date' => NULL)), - 'date_time_ago' => $base + array('variables' => array('start_date' => NULL, 'end_date' => NULL, 'interval' => NULL)), + 'date_time_ago' => $base + array( + 'variables' => array( + 'start_date' => NULL, 'end_date' => NULL, 'interval' => NULL + ), + ), ); } @@ -2375,9 +2505,11 @@ function date_get_timezone($handling, $timezone = '') { case 'date': $timezone = !empty($timezone) ? $timezone : date_default_timezone(); break; + case 'utc': $timezone = 'UTC'; break; + default: $timezone = date_default_timezone(); } @@ -2404,6 +2536,7 @@ function date_get_timezone_db($handling, $timezone = NULL) { // These handling modes all convert to UTC before storing in the DB. $timezone = 'UTC'; break; + case ('date'): if ($timezone == NULL) { // This shouldn't happen, since it's meaning is undefined. But we need @@ -2411,6 +2544,7 @@ function date_get_timezone_db($handling, $timezone = NULL) { $timezone = date_default_timezone(); } break; + case ('none'): default: $timezone = date_default_timezone(); @@ -2465,12 +2599,12 @@ function date_order() { * TRUE if the date range is valid, FALSE otherwise. */ function date_range_valid($string) { - $matches = preg_match('@^(\-[0-9]+|[0-9]{4}):([\+|\-][0-9]+|[0-9]{4})$@', $string); + $matches = preg_match('@^([\+\-][0-9]+|[0-9]{4}):([\+\-][0-9]+|[0-9]{4})$@', $string); return $matches < 1 ? FALSE : TRUE; } /** - * Splits a string like -3:+3 or 2001:2010 into an array of min and max years. + * Splits a string like -3:+3 or 2001:2010 into an array of start and end years. * * Center the range around the current year, if any, but expand it far * enough so it will pick up the year value in the field in case @@ -2482,45 +2616,44 @@ function date_range_valid($string) { * (optional) A date object. Defaults to NULL. * * @return array - * A numerically indexed array, containing a minimum and maximum year. + * A numerically indexed array, containing a start and end year. */ function date_range_years($string, $date = NULL) { $this_year = date_format(date_now(), 'Y'); - list($min_year, $max_year) = explode(':', $string); + list($start_year, $end_year) = explode(':', $string); // Valid patterns would be -5:+5, 0:+1, 2008:2010. - $plus_pattern = '@[\+|\-][0-9]{1,4}@'; + $plus_pattern = '@[\+\-][0-9]{1,4}@'; $year_pattern = '@^[0-9]{4}@'; - if (!preg_match($year_pattern, $min_year, $matches)) { - if (preg_match($plus_pattern, $min_year, $matches)) { - $min_year = $this_year + $matches[0]; + if (!preg_match($year_pattern, $start_year, $matches)) { + if (preg_match($plus_pattern, $start_year, $matches)) { + $start_year = $this_year + $matches[0]; } else { - $min_year = $this_year; + $start_year = $this_year; } } - if (!preg_match($year_pattern, $max_year, $matches)) { - if (preg_match($plus_pattern, $max_year, $matches)) { - $max_year = $this_year + $matches[0]; + if (!preg_match($year_pattern, $end_year, $matches)) { + if (preg_match($plus_pattern, $end_year, $matches)) { + $end_year = $this_year + $matches[0]; } else { - $max_year = $this_year; + $end_year = $this_year; } } - // We expect the $min year to be less than the $max year. - // Some custom values for -99:+99 might not obey that. - if ($min_year > $max_year) { - $temp = $max_year; - $max_year = $min_year; - $min_year = $temp; - } // If there is a current value, stretch the range to include it. $value_year = is_object($date) ? $date->format('Y') : ''; if (!empty($value_year)) { - $min_year = min($value_year, $min_year); - $max_year = max($value_year, $max_year); + if ($start_year <= $end_year) { + $start_year = min($value_year, $start_year); + $end_year = max($value_year, $end_year); + } + else { + $start_year = max($value_year, $start_year); + $end_year = min($value_year, $end_year); + } } - return array($min_year, $max_year); + return array($start_year, $end_year); } /** @@ -2680,6 +2813,7 @@ function date_is_all_day($string1, $string2, $granularity = 'second', $increment || ($hour2 == 23 && in_array($min2, array($max_minutes, 59)) && in_array($sec2, array($max_seconds, 59))) || ($hour1 == 0 && $hour2 == 0 && $min1 == 0 && $min2 == 0 && $sec1 == 0 && $sec2 == 0); break; + case 'minute': $min_match = $time1 == '00:00:00' || ($hour1 == 0 && $min1 == 0); @@ -2687,6 +2821,7 @@ function date_is_all_day($string1, $string2, $granularity = 'second', $increment || ($hour2 == 23 && in_array($min2, array($max_minutes, 59))) || ($hour1 == 0 && $hour2 == 0 && $min1 == 0 && $min2 == 0); break; + case 'hour': $min_match = $time1 == '00:00:00' || ($hour1 == 0); @@ -2694,6 +2829,7 @@ function date_is_all_day($string1, $string2, $granularity = 'second', $increment || ($hour2 == 23) || ($hour1 == 0 && $hour2 == 0); break; + default: $min_match = TRUE; $max_match = FALSE; @@ -2754,15 +2890,21 @@ function date_is_date($date) { } /** - * This function will replace ISO values that have the pattern 9999-00-00T00:00:00 - * with a pattern like 9999-01-01T00:00:00, to match the behavior of non-ISO - * dates and ensure that date objects created from this value contain a valid month - * and day. Without this fix, the ISO date '2020-00-00T00:00:00' would be created as + * Replace specific ISO values using patterns. + * + * Function will replace ISO values that have the pattern 9999-00-00T00:00:00 + * with a pattern like 9999-01-01T00:00:00, to match the behavior of non-ISO dates + * and ensure that date objects created from this value contain a valid month + * and day. + * Without this fix, the ISO date '2020-00-00T00:00:00' would be created as * November 30, 2019 (the previous day in the previous month). * * @param string $iso_string * An ISO string that needs to be made into a complete, valid date. * + * @return mixed|string + * replaced value, or incoming value. + * * @TODO Expand on this to work with all sorts of partial ISO dates. */ function date_make_iso_valid($iso_string) { diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api_elements.inc b/sites/all/modules/contrib/fields/date/date_api/date_api_elements.inc index 57e41615..fc91205c 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api_elements.inc +++ b/sites/all/modules/contrib/fields/date/date_api/date_api_elements.inc @@ -116,15 +116,19 @@ function date_default_date($element) { case 16: $format = 'Y-m-d H:i'; break; + case 13: $format = 'Y-m-d H'; break; + case 10: $format = 'Y-m-d'; break; + case 7: $format = 'Y-m'; break; + case 4: $format = 'Y'; break; @@ -170,7 +174,7 @@ function date_year_range_element_process($element, &$form_state, $form) { $element['#attached']['js'][] = drupal_get_path('module', 'date_api') . '/date_year_range.js'; $context = array( - 'form' => $form, + 'form' => $form, ); drupal_alter('date_year_range_process', $element, $form_state, $context); @@ -256,7 +260,7 @@ function date_timezone_element_process($element, &$form_state, $form) { } $context = array( - 'form' => $form, + 'form' => $form, ); drupal_alter('date_timezone_process', $element, $form_state, $context); @@ -264,7 +268,7 @@ function date_timezone_element_process($element, &$form_state, $form) { } /** - * Validation for timezone input + * Validation for timezone input. * * Move the timezone value from the nested field back to the original field. */ @@ -307,7 +311,6 @@ function date_text_element_value_callback($element, $input = FALSE, &$form_state * * The exact parts displayed in the field are those in #date_granularity. * The display of each part comes from #date_format. - * */ function date_text_element_process($element, &$form_state, $form) { if (date_hidden_element($element)) { @@ -323,9 +326,18 @@ function date_text_element_process($element, &$form_state, $form) { $now = date_example_date(); $element['date']['#title'] = t('Date'); $element['date']['#title_display'] = 'invisible'; - $element['date']['#description'] = ' ' . t('Format: @date', array('@date' => date_format_date(date_example_date(), 'custom', $element['#date_format']))); + $element['date']['#description'] = ' ' . t('Format: @date', array( + '@date' => date_format_date(date_example_date(), 'custom', $element['#date_format'] + ))); $element['date']['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE; + // Make changes if instance is set to be rendered as a regular field. + if (!empty($element['#instance']['widget']['settings']['no_fieldset']) && $element['#field']['cardinality'] == 1) { + $element['date']['#title'] = check_plain($element['#instance']['label']); + $element['date']['#title_display'] = $element['#title_display']; + $element['date']['#required'] = $element['#required']; + } + // Keep the system from creating an error message for the sub-element. // We'll set our own message on the parent element. // $element['date']['#required'] = $element['#required']; @@ -341,7 +353,7 @@ function date_text_element_process($element, &$form_state, $form) { } $context = array( - 'form' => $form, + 'form' => $form, ); drupal_alter('date_text_process', $element, $form_state, $context); @@ -349,12 +361,11 @@ function date_text_element_process($element, &$form_state, $form) { } /** - * Validation for text input. + * Validation for text input. * * When used as a Views widget, the validation step always gets triggered, * even with no form submission. Before form submission $element['#value'] * contains a string, after submission it contains an array. - * */ function date_text_validate($element, &$form_state) { if (date_hidden_element($element)) { @@ -367,6 +378,11 @@ function date_text_validate($element, &$form_state) { $input_exists = NULL; $input = drupal_array_get_nested_value($form_state['values'], $element['#parents'], $input_exists); + // Trim extra spacing off user input of text fields. + if (isset($input['date'])) { + $input['date'] = trim($input['date']); + } + drupal_alter('date_text_pre_validate', $element, $form_state, $input); $label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : ''); @@ -421,7 +437,14 @@ function date_text_input_date($element, $input) { * Element value callback for date_select element. */ function date_select_element_value_callback($element, $input = FALSE, &$form_state = array()) { - $return = array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''); + $return = array( + 'year' => '', + 'month' => '', + 'day' => '', + 'hour' => '', + 'minute' => '', + 'second' => '', + ); $date = NULL; if ($input !== FALSE) { $return = $input; @@ -431,7 +454,14 @@ function date_select_element_value_callback($element, $input = FALSE, &$form_sta $date = date_default_date($element); } $granularity = date_format_order($element['#date_format']); - $formats = array('year' => 'Y', 'month' => 'n', 'day' => 'j', 'hour' => 'H', 'minute' => 'i', 'second' => 's'); + $formats = array( + 'year' => 'Y', + 'month' => 'n', + 'day' => 'j', + 'hour' => 'H', + 'minute' => 'i', + 'second' => 's', + ); foreach ($granularity as $field) { if ($field != 'timezone') { $return[$field] = date_is_date($date) ? $date->format($formats[$field]) : ''; @@ -449,7 +479,6 @@ function date_select_element_value_callback($element, $input = FALSE, &$form_sta * * The exact parts displayed in the field are those in #date_granularity. * The display of each part comes from ['#date_settings']['format']. - * */ function date_select_element_process($element, &$form_state, $form) { if (date_hidden_element($element)) { @@ -473,7 +502,14 @@ function date_select_element_process($element, &$form_state, $form) { // Store a hidden value for all date parts not in the current display. $granularity = date_format_order($element['#date_format']); - $formats = array('year' => 'Y', 'month' => 'n', 'day' => 'j', 'hour' => 'H', 'minute' => 'i', 'second' => 's'); + $formats = array( + 'year' => 'Y', + 'month' => 'n', + 'day' => 'j', + 'hour' => 'H', + 'minute' => 'i', + 'second' => 's', + ); foreach (date_nongranularity($granularity) as $field) { if ($field != 'timezone') { $element[$field] = array( @@ -490,7 +526,7 @@ function date_select_element_process($element, &$form_state, $form) { } $context = array( - 'form' => $form, + 'form' => $form, ); drupal_alter('date_select_process', $element, $form_state, $context); @@ -521,7 +557,7 @@ function date_parts_element($element, $date, $format) { $sub_element = array('#granularity' => $granularity); $order = array_flip($granularity); - $hours_format = strpos(strtolower($element['#date_format']), 'a') ? 'g': 'G'; + $hours_format = strpos(strtolower($element['#date_format']), 'a') ? 'g' : 'G'; $month_function = strpos($element['#date_format'], 'F') !== FALSE ? 'date_month_names' : 'date_month_names_abbr'; $count = 0; $increment = min(intval($element['#date_increment']), 1); @@ -539,26 +575,29 @@ function date_parts_element($element, $date, $format) { switch ($field) { case 'year': $range = date_range_years($element['#date_year_range'], $date); - $min_year = $range[0]; - $max_year = $range[1]; + $start_year = $range[0]; + $end_year = $range[1]; $sub_element[$field]['#default_value'] = is_object($date) ? $date->format('Y') : ''; if ($part_type == 'select') { - $sub_element[$field]['#options'] = drupal_map_assoc(date_years($min_year, $max_year, $part_required)); + $sub_element[$field]['#options'] = drupal_map_assoc(date_years($start_year, $end_year, $part_required)); } break; + case 'month': $sub_element[$field]['#default_value'] = is_object($date) ? $date->format('n') : ''; if ($part_type == 'select') { $sub_element[$field]['#options'] = $month_function($part_required); } break; + case 'day': $sub_element[$field]['#default_value'] = is_object($date) ? $date->format('j') : ''; if ($part_type == 'select') { $sub_element[$field]['#options'] = drupal_map_assoc(date_days($part_required)); } break; + case 'hour': $sub_element[$field]['#default_value'] = is_object($date) ? $date->format($hours_format) : ''; if ($part_type == 'select') { @@ -566,6 +605,7 @@ function date_parts_element($element, $date, $format) { } $sub_element[$field]['#prefix'] = theme('date_part_hour_prefix', $element); break; + case 'minute': $sub_element[$field]['#default_value'] = is_object($date) ? $date->format('i') : ''; if ($part_type == 'select') { @@ -573,6 +613,7 @@ function date_parts_element($element, $date, $format) { } $sub_element[$field]['#prefix'] = theme('date_part_minsec_prefix', $element); break; + case 'second': $sub_element[$field]['#default_value'] = is_object($date) ? $date->format('s') : ''; if ($part_type == 'select') { diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api_ical.inc b/sites/all/modules/contrib/fields/date/date_api/date_api_ical.inc index 2ca484e7..4911298c 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api_ical.inc +++ b/sites/all/modules/contrib/fields/date/date_api/date_api_ical.inc @@ -181,6 +181,7 @@ function date_ical_parse($icaldatafolded = array()) { $parent[array_pop($parents)][] = array_pop($subgroups); } break; + // Add the timezones in with their index their TZID. case 'VTIMEZONE': $subgroup = end($subgroups); @@ -196,6 +197,7 @@ function date_ical_parse($icaldatafolded = array()) { array_pop($subgroups); array_pop($parents); break; + // Do some fun stuff with durations and all_day events and then append // to parent. case 'VEVENT': @@ -222,9 +224,9 @@ function date_ical_parse($icaldatafolded = array()) { // assumes the end date is inclusive. if (!empty($subgroup['DTEND']) && (!empty($subgroup['DTEND']['all_day']))) { // Make the end date one day earlier. - $date = new DateObject ($subgroup['DTEND']['datetime'] . ' 00:00:00', $subgroup['DTEND']['tz']); + $date = new DateObject($subgroup['DTEND']['datetime'] . ' 00:00:00', $subgroup['DTEND']['tz']); date_modify($date, '-1 day'); - $subgroup['DTEND']['datetime'] = date_format($date, 'Y-m-d'); + $subgroup['DTEND']['datetime'] = date_format($date, 'Y-m-d'); } // If a start datetime is defined AND there is no definition for // the end datetime THEN make the end datetime equal the start @@ -239,7 +241,7 @@ function date_ical_parse($icaldatafolded = array()) { if (!empty($subgroup['DTSTART']['all_day'])) { $subgroup['all_day'] = TRUE; } - // Add this element to the parent as an array under the + // Add this element to the parent as an array under the. prev($subgroups); $parent = &$subgroups[key($subgroups)]; @@ -264,12 +266,13 @@ function date_ical_parse($icaldatafolded = array()) { $field = !empty($matches[2]) ? $matches[2] : ''; $data = !empty($matches[3]) ? $matches[3] : ''; $parse_result = ''; + switch ($name) { // Keep blank lines out of the results. case '': break; - // Lots of properties have date values that must be parsed out. + // Lots of properties have date values that must be parsed out. case 'CREATED': case 'LAST-MODIFIED': case 'DTSTART': @@ -317,9 +320,9 @@ function date_ical_parse($icaldatafolded = array()) { $parse_result = date_ical_parse_location($field, $data); break; - // For all other properties, just store the property and the value. - // This can be expanded on in the future if other properties should - // be given special treatment. + // For all other properties, just store the property and the value. + // This can be expanded on in the future if other properties should + // be given special treatment. default: $parse_result = $data; break; @@ -360,7 +363,7 @@ function date_ical_parse($icaldatafolded = array()) { * has no timezone; the ical specs say no timezone * conversion should be done if no timezone info is * supplied - * @todo + * @todo * Another option for dates is the format PROPERTY;VALUE=PERIOD:XXXX. The * period may include a duration, or a date and a duration, or two dates, so * would have to be split into parts and run through date_ical_parse_date() @@ -401,6 +404,7 @@ function date_ical_parse_date($field, $data) { // Date. $datetime = date_pad($regs[1]) . '-' . date_pad($regs[2]) . '-' . date_pad($regs[3]); break; + case 'DATE-TIME': preg_match(DATE_REGEX_ICAL_DATETIME, $data, $regs); // Date. @@ -519,12 +523,12 @@ function date_ical_parse_duration(&$subgroup, $field = 'DURATION') { $data = $items['DATA']; preg_match('/^P(\d{1,4}[Y])?(\d{1,2}[M])?(\d{1,2}[W])?(\d{1,2}[D])?([T]{0,1})?(\d{1,2}[H])?(\d{1,2}[M])?(\d{1,2}[S])?/', $data, $duration); $items['year'] = isset($duration[1]) ? str_replace('Y', '', $duration[1]) : ''; - $items['month'] = isset($duration[2]) ?str_replace('M', '', $duration[2]) : ''; - $items['week'] = isset($duration[3]) ?str_replace('W', '', $duration[3]) : ''; - $items['day'] = isset($duration[4]) ?str_replace('D', '', $duration[4]) : ''; - $items['hour'] = isset($duration[6]) ?str_replace('H', '', $duration[6]) : ''; - $items['minute'] = isset($duration[7]) ?str_replace('M', '', $duration[7]) : ''; - $items['second'] = isset($duration[8]) ?str_replace('S', '', $duration[8]) : ''; + $items['month'] = isset($duration[2]) ? str_replace('M', '', $duration[2]) : ''; + $items['week'] = isset($duration[3]) ? str_replace('W', '', $duration[3]) : ''; + $items['day'] = isset($duration[4]) ? str_replace('D', '', $duration[4]) : ''; + $items['hour'] = isset($duration[6]) ? str_replace('H', '', $duration[6]) : ''; + $items['minute'] = isset($duration[7]) ? str_replace('M', '', $duration[7]) : ''; + $items['second'] = isset($duration[8]) ? str_replace('S', '', $duration[8]) : ''; $start_date = array_key_exists('DTSTART', $subgroup) ? $subgroup['DTSTART']['datetime'] : date_format(date_now(), DATE_FORMAT_ISO); $timezone = array_key_exists('DTSTART', $subgroup) ? $subgroup['DTSTART']['tz'] : variable_get('date_default_timezone'); if (empty($timezone)) { @@ -542,7 +546,7 @@ function date_ical_parse_duration(&$subgroup, $field = 'DURATION') { 'datetime' => date_format($date2, DATE_FORMAT_DATETIME), 'all_day' => isset($subgroup['DTSTART']['all_day']) ? $subgroup['DTSTART']['all_day'] : 0, 'tz' => $timezone, - ); + ); $duration = date_format($date2, 'U') - date_format($date, 'U'); $subgroup['DURATION'] = array('DATA' => $data, 'DURATION' => $duration); } @@ -631,7 +635,6 @@ function date_ical_date($ical_date, $to_tz = FALSE) { * * @return string * Escaped text - * */ function date_ical_escape_text($text) { $text = drupal_html_to_text($text); @@ -693,14 +696,14 @@ function date_ical_escape_text($text) { * ) */ function date_api_ical_build_rrule($form_values) { - $RRULE = ''; + $rrule = ''; if (empty($form_values) || !is_array($form_values)) { - return $RRULE; + return $rrule; } // Grab the RRULE data and put them into iCal RRULE format. - $RRULE .= 'RRULE:FREQ=' . (!array_key_exists('FREQ', $form_values) ? 'DAILY' : $form_values['FREQ']); - $RRULE .= ';INTERVAL=' . (!array_key_exists('INTERVAL', $form_values) ? 1 : $form_values['INTERVAL']); + $rrule .= 'RRULE:FREQ=' . (!array_key_exists('FREQ', $form_values) ? 'DAILY' : $form_values['FREQ']); + $rrule .= ';INTERVAL=' . (!array_key_exists('INTERVAL', $form_values) ? 1 : $form_values['INTERVAL']); // Unset the empty 'All' values. if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) { @@ -713,14 +716,14 @@ function date_api_ical_build_rrule($form_values) { unset($form_values['BYMONTHDAY']['']); } - if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY']) && $BYDAY = implode(",", $form_values['BYDAY'])) { - $RRULE .= ';BYDAY=' . $BYDAY; + if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY']) && $byday = implode(",", $form_values['BYDAY'])) { + $rrule .= ';BYDAY=' . $byday; } - if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH']) && $BYMONTH = implode(",", $form_values['BYMONTH'])) { - $RRULE .= ';BYMONTH=' . $BYMONTH; + if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH']) && $bymonth = implode(",", $form_values['BYMONTH'])) { + $rrule .= ';BYMONTH=' . $bymonth; } - if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY']) && $BYMONTHDAY = implode(",", $form_values['BYMONTHDAY'])) { - $RRULE .= ';BYMONTHDAY=' . $BYMONTHDAY; + if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY']) && $bymonthday = implode(",", $form_values['BYMONTHDAY'])) { + $rrule .= ';BYMONTHDAY=' . $bymonthday; } // The UNTIL date is supposed to always be expressed in UTC. // The input date values may already have been converted to a date object on a @@ -731,8 +734,17 @@ function date_api_ical_build_rrule($form_values) { if (!is_object($form_values['UNTIL']['datetime'])) { // If this is a date without time, give it time. if (strlen($form_values['UNTIL']['datetime']) < 11) { + $granularity_options = drupal_map_assoc(array( + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + )); + $form_values['UNTIL']['datetime'] .= ' 23:59:59'; - $form_values['UNTIL']['granularity'] = serialize(drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute', 'second'))); + $form_values['UNTIL']['granularity'] = serialize($granularity_options); $form_values['UNTIL']['all_day'] = FALSE; } $until = date_ical_date($form_values['UNTIL'], 'UTC'); @@ -740,21 +752,21 @@ function date_api_ical_build_rrule($form_values) { else { $until = $form_values['UNTIL']['datetime']; } - $RRULE .= ';UNTIL=' . date_format($until, DATE_FORMAT_ICAL) . 'Z'; + $rrule .= ';UNTIL=' . date_format($until, DATE_FORMAT_ICAL) . 'Z'; } // Our form doesn't allow a value for COUNT, but it may be needed by // modules using the API, so add it to the rule. if (array_key_exists('COUNT', $form_values)) { - $RRULE .= ';COUNT=' . $form_values['COUNT']; + $rrule .= ';COUNT=' . $form_values['COUNT']; } // iCal rules presume the week starts on Monday unless otherwise specified, // so we'll specify it. if (array_key_exists('WKST', $form_values)) { - $RRULE .= ';WKST=' . $form_values['WKST']; + $rrule .= ';WKST=' . $form_values['WKST']; } else { - $RRULE .= ';WKST=' . date_repeat_dow2day(variable_get('date_first_day', 0)); + $rrule .= ';WKST=' . date_repeat_dow2day(variable_get('date_first_day', 0)); } // Exceptions dates go last, on their own line. @@ -765,7 +777,7 @@ function date_api_ical_build_rrule($form_values) { foreach ($form_values['EXDATE'] as $value) { if (!empty($value['datetime'])) { $date = !is_object($value['datetime']) ? date_ical_date($value, 'UTC') : $value['datetime']; - $ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z': ''; + $ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z' : ''; if (!empty($ex_date)) { $ex_dates[] = $ex_date; } @@ -773,11 +785,11 @@ function date_api_ical_build_rrule($form_values) { } if (!empty($ex_dates)) { sort($ex_dates); - $RRULE .= chr(13) . chr(10) . 'EXDATE:' . implode(',', $ex_dates); + $rrule .= chr(13) . chr(10) . 'EXDATE:' . implode(',', $ex_dates); } } elseif (!empty($form_values['EXDATE'])) { - $RRULE .= chr(13) . chr(10) . 'EXDATE:' . $form_values['EXDATE']; + $rrule .= chr(13) . chr(10) . 'EXDATE:' . $form_values['EXDATE']; } // Exceptions dates go last, on their own line. @@ -785,19 +797,19 @@ function date_api_ical_build_rrule($form_values) { $ex_dates = array(); foreach ($form_values['RDATE'] as $value) { $date = !is_object($value['datetime']) ? date_ical_date($value, 'UTC') : $value['datetime']; - $ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z': ''; + $ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z' : ''; if (!empty($ex_date)) { $ex_dates[] = $ex_date; } } if (!empty($ex_dates)) { sort($ex_dates); - $RRULE .= chr(13) . chr(10) . 'RDATE:' . implode(',', $ex_dates); + $rrule .= chr(13) . chr(10) . 'RDATE:' . implode(',', $ex_dates); } } elseif (!empty($form_values['RDATE'])) { - $RRULE .= chr(13) . chr(10) . 'RDATE:' . $form_values['RDATE']; + $rrule .= chr(13) . chr(10) . 'RDATE:' . $form_values['RDATE']; } - return $RRULE; + return $rrule; } diff --git a/sites/all/modules/contrib/fields/date/date_api/date_api_sql.inc b/sites/all/modules/contrib/fields/date/date_api/date_api_sql.inc index e02f0507..a95ca4ef 100644 --- a/sites/all/modules/contrib/fields/date/date_api/date_api_sql.inc +++ b/sites/all/modules/contrib/fields/date/date_api/date_api_sql.inc @@ -23,13 +23,14 @@ function date_sql_concat($array) { switch (Database::getConnection()->databaseType()) { case 'mysql': return "CONCAT(" . implode(",", $array) . ")"; + case 'pgsql': return implode(" || ", $array); } } /** - * Helper function to do cross-database NULL replacements + * Helper function to do cross-database NULL replacements. * * @param array $array * An array of values to test for NULL values. @@ -61,6 +62,7 @@ function date_sql_pad($str, $size = 2, $pad = '0', $side = 'l') { switch ($side) { case 'r': return "RPAD($str, $size, '$pad')"; + default: return "LPAD($str, $size, '$pad')"; } @@ -69,6 +71,7 @@ function date_sql_pad($str, $size = 2, $pad = '0', $side = 'l') { /** * A class to manipulate date SQL. */ +// @codingStandardsIgnoreStart class date_sql_handler { var $db_type = NULL; var $date_type = DATE_DATETIME; @@ -86,7 +89,7 @@ class date_sql_handler { /** * The object constuctor. */ - function __construct($date_type = DATE_DATETIME, $local_timezone = NULL, $offset = '+00:00') { + public function __construct($date_type = DATE_DATETIME, $local_timezone = NULL, $offset = '+00:00') { $this->db_type = Database::getConnection()->databaseType(); $this->date_type = $date_type; $this->db_timezone = 'UTC'; @@ -97,7 +100,7 @@ class date_sql_handler { /** * See if the db has timezone name support. */ - function db_tz_support($reset = FALSE) { + public function db_tz_support($reset = FALSE) { $has_support = variable_get('date_db_tz_support', -1); if ($has_support == -1 || $reset) { $has_support = FALSE; @@ -108,6 +111,7 @@ class date_sql_handler { $has_support = TRUE; } break; + case 'pgsql': $test = db_query("SELECT '2008-02-15 12:00:00 UTC' AT TIME ZONE 'US/Central'")->fetchField(); if ($test == '2008-02-15 06:00:00') { @@ -136,7 +140,7 @@ class date_sql_handler { * set a fixed offset, not a timezone, so any value other than * '+00:00' should be used with caution. */ - function set_db_timezone($offset = '+00:00') { + public function set_db_timezone($offset = '+00:00') { static $already_set = FALSE; $type = Database::getConnection()->databaseType(); if (!$already_set) { @@ -144,9 +148,11 @@ class date_sql_handler { case 'mysql': db_query("SET @@session.time_zone = '$offset'"); break; + case 'pgsql': db_query("SET TIME ZONE INTERVAL '$offset' HOUR TO MINUTE"); break; + case 'sqlsrv': // Issue #1201342, This is the wrong way to set the timezone, this // still needs to be fixed. In the meantime, commenting this out makes @@ -161,7 +167,7 @@ class date_sql_handler { /** * Return timezone offset for the date being processed. */ - function get_offset($comp_date = NULL) { + public function get_offset($comp_date = NULL) { if (!empty($this->db_timezone) && !empty($this->local_timezone)) { if ($this->db_timezone != $this->local_timezone) { if (empty($comp_date)) { @@ -199,47 +205,57 @@ class date_sql_handler { case DATE_UNIX: $field = "FROM_UNIXTIME($field)"; break; + case DATE_ISO: $field = "STR_TO_DATE($field, '%Y-%m-%dT%T')"; break; + case DATE_DATETIME: break; } break; + case 'pgsql': switch ($this->date_type) { case DATE_UNIX: $field = "$field::ABSTIME"; break; + case DATE_ISO: $field = "TO_DATE($field, 'FMYYYY-FMMM-FMDDTFMHH24:FMMI:FMSS')"; break; + case DATE_DATETIME: break; } break; + case 'sqlite': switch ($this->date_type) { case DATE_UNIX: $field = "datetime($field, 'unixepoch')"; break; + case DATE_ISO: case DATE_DATETIME: $field = "datetime($field)"; break; } break; + case 'sqlsrv': switch ($this->date_type) { case DATE_UNIX: $field = "DATEADD(s, $field, '19700101 00:00:00:000')"; break; + case DATE_ISO: case DATE_DATETIME: $field = "CAST($field as smalldatetime)"; break; } break; + break; } // Adjust the resulting value to the right timezone/offset. @@ -254,10 +270,13 @@ class date_sql_handler { switch ($this->db_type) { case 'mysql': return "ADDTIME($field, SEC_TO_TIME($offset))"; + case 'pgsql': - return "($field + INTERVAL '$offset SECONDS')";; + return "($field + INTERVAL '$offset SECONDS')"; + case 'sqlite': return "datetime($field, '$offset seconds')"; + case 'sqlsrv': return "DATEADD(second, $offset, $field)"; } @@ -285,6 +304,7 @@ class date_sql_handler { switch ($direction) { case 'ADD': return "DATE_ADD($field, INTERVAL $count $granularity)"; + case 'SUB': return "DATE_SUB($field, INTERVAL $count $granularity)"; } @@ -294,6 +314,7 @@ class date_sql_handler { switch ($direction) { case 'ADD': return "($field + INTERVAL '$count $granularity')"; + case 'SUB': return "($field - INTERVAL '$count $granularity')"; } @@ -302,6 +323,7 @@ class date_sql_handler { switch ($direction) { case 'ADD': return "datetime($field, '+$count $granularity')"; + case 'SUB': return "datetime($field, '-$count $granularity')"; } @@ -352,6 +374,7 @@ class date_sql_handler { switch ($this->db_type) { case 'mysql': return "CONVERT_TZ($field, $db_zone, $localzone)"; + case 'pgsql': // WITH TIME ZONE assumes the date is using the system // timezone, which should have been set to UTC. @@ -395,6 +418,7 @@ class date_sql_handler { ); $format = strtr($format, $replace); return "DATE_FORMAT($field, '$format')"; + case 'pgsql': $replace = array( 'Y' => 'YYYY', @@ -421,6 +445,7 @@ class date_sql_handler { ); $format = strtr($format, $replace); return "TO_CHAR($field, '$format')"; + case 'sqlite': $replace = array( // 4 digit year number. @@ -460,6 +485,7 @@ class date_sql_handler { ); $format = strtr($format, $replace); return "strftime('$format', $field)"; + case 'sqlsrv': $replace = array( // 4 digit year number. @@ -528,18 +554,25 @@ class date_sql_handler { switch (strtoupper($extract_type)) { case 'DATE': return $field; + case 'YEAR': return "EXTRACT(YEAR FROM($field))"; + case 'MONTH': return "EXTRACT(MONTH FROM($field))"; + case 'DAY': return "EXTRACT(DAY FROM($field))"; + case 'HOUR': return "EXTRACT(HOUR FROM($field))"; + case 'MINUTE': return "EXTRACT(MINUTE FROM($field))"; + case 'SECOND': return "EXTRACT(SECOND FROM($field))"; + // ISO week number for date. case 'WEEK': switch ($this->db_type) { @@ -547,6 +580,7 @@ class date_sql_handler { // WEEK using arg 3 in MySQl should return the same value as // Postgres EXTRACT. return "WEEK($field, 3)"; + case 'pgsql': return "EXTRACT(WEEK FROM($field))"; } @@ -556,6 +590,7 @@ class date_sql_handler { // MySQL returns 1 for Sunday through 7 for Saturday, PHP date // functions and Postgres use 0 for Sunday and 6 for Saturday. return "INTEGER(DAYOFWEEK($field) - 1)"; + case 'pgsql': return "EXTRACT(DOW FROM($field))"; } @@ -563,6 +598,7 @@ class date_sql_handler { switch ($this->db_type) { case 'mysql': return "DAYOFYEAR($field)"; + case 'pgsql': return "EXTRACT(DOY FROM($field))"; } @@ -775,8 +811,7 @@ class date_sql_handler { } /** - * Create a complete datetime value out of an - * incomplete array of selected values. + * Create a complete date/time value out of an incomplete array of values. * * For example, array('year' => 2008, 'month' => 05) will fill * in the day, hour, minute and second with the earliest possible @@ -795,9 +830,11 @@ class date_sql_handler { case 'empty_min': case 'min': return date_format($dates[0], 'Y-m-d H:i:s'); + case 'empty_max': case 'max': return date_format($dates[1], 'Y-m-d H:i:s'); + default: return; } @@ -840,7 +877,7 @@ class date_sql_handler { } /** - * A function to test the validity of various date parts + * A function to test the validity of various date parts. */ function part_is_valid($value, $type) { if (!preg_match('/^[0-9]*$/', $value)) { @@ -856,16 +893,19 @@ class date_sql_handler { return FALSE; } break; + case 'month': if ($value < 0 || $value > 12) { return FALSE; } break; + case 'day': if ($value < 0 || $value > 31) { return FALSE; } break; + case 'week': if ($value < 0 || $value > 53) { return FALSE; @@ -890,26 +930,36 @@ class date_sql_handler { $formats['display'] = 'Y'; $formats['sql'] = 'Y'; break; + case 'month': $formats['display'] = date_limit_format($short, array('year', 'month')); $formats['sql'] = 'Y-m'; break; + case 'day': - $formats['display'] = date_limit_format($short, array('year', 'month', 'day')); + $args = array('year', 'month', 'day'); + $formats['display'] = date_limit_format($short, $args); $formats['sql'] = 'Y-m-d'; break; + case 'hour': - $formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour')); + $args = array('year', 'month', 'day', 'hour'); + $formats['display'] = date_limit_format($short, $args); $formats['sql'] = 'Y-m-d\TH'; break; + case 'minute': - $formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour', 'minute')); + $args = array('year', 'month', 'day', 'hour', 'minute'); + $formats['display'] = date_limit_format($short, $args); $formats['sql'] = 'Y-m-d\TH:i'; break; + case 'second': - $formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour', 'minute', 'second')); + $args = array('year', 'month', 'day', 'hour', 'minute', 'second'); + $formats['display'] = date_limit_format($short, $args); $formats['sql'] = 'Y-m-d\TH:i:s'; break; + case 'week': $formats['display'] = 'F j Y (W)'; $formats['sql'] = 'Y-\WW'; @@ -927,7 +977,7 @@ class date_sql_handler { '#type' => 'radios', '#default_value' => $granularity, '#options' => $this->date_parts(), - ); + ); return $form; } @@ -1030,7 +1080,6 @@ class date_sql_handler { $direction = $results[1]; $count = $results[2]; $item = $results[3]; - $replace = array( 'now' => '@', '+' => 'P', @@ -1051,14 +1100,27 @@ class date_sql_handler { 'second' => 'S', ' ' => '', ' ' => '', - ); - $prefix = in_array($item, array('hours', 'hour', 'minutes', 'minute', 'seconds', 'second')) ? 'T' : ''; - return $prefix . strtr($direction, $replace) . $count . strtr($item, $replace); + ); + $args = array('hours', 'hour', 'minutes', 'minute', 'seconds', 'second'); + if (in_array($item, $args)) { + $prefix = 'T'; + } + else { + $prefix = ''; + } + $return = $prefix; + $return .= strtr($direction, $replace); + $return .= $count; + $return .= strtr($item, $replace); + + return $return; } /** - * Use the parsed values from the ISO argument to determine the - * granularity of this period. + * Granularity arguments handler. + * + * Use the parsed values from the ISO argument + * to determine the granularity of this period. */ function arg_granularity($arg) { $granularity = ''; @@ -1137,8 +1199,9 @@ class date_sql_handler { } return array($min_date, $max_date); } - // Intercept invalid info and fall back to the current date. + // Intercept invalid info and fall back to the current date. $now = date_now(); return array($now, $now); } } +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_api/theme/theme.inc b/sites/all/modules/contrib/fields/date/date_api/theme/theme.inc index 032e3e93..a6aef230 100644 --- a/sites/all/modules/contrib/fields/date/date_api/theme/theme.inc +++ b/sites/all/modules/contrib/fields/date/date_api/theme/theme.inc @@ -206,24 +206,31 @@ function theme_date_time_ago($variables) { $now = date_format(date_now(), DATE_FORMAT_UNIX); $start = date_format($start_date, DATE_FORMAT_UNIX); - // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence) + // Will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence). $time_diff = $now - $start; // Uses the same options used by Views format_interval. switch ($display) { case 'raw time ago': return format_interval($time_diff, $interval); + case 'time ago': return t('%time ago', array('%time' => format_interval($time_diff, $interval))); + case 'raw time hence': return format_interval(-$time_diff, $interval); + case 'time hence': return t('%time hence', array('%time' => format_interval(-$time_diff, $interval))); + case 'raw time span': return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), $interval); + case 'inverse time span': return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), $interval); + case 'time span': return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), $interval))); + } } diff --git a/sites/all/modules/contrib/fields/date/date_context/date_context.info b/sites/all/modules/contrib/fields/date/date_context/date_context.info index 1d8a551d..c521dd26 100644 --- a/sites/all/modules/contrib/fields/date/date_context/date_context.info +++ b/sites/all/modules/contrib/fields/date/date_context/date_context.info @@ -8,9 +8,9 @@ dependencies[] = context files[] = date_context.module files[] = plugins/date_context_date_condition.inc -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_context/date_context.module b/sites/all/modules/contrib/fields/date/date_context/date_context.module index 44e975ac..9b568e15 100644 --- a/sites/all/modules/contrib/fields/date/date_context/date_context.module +++ b/sites/all/modules/contrib/fields/date/date_context/date_context.module @@ -1,5 +1,8 @@ execute() @@ -8,8 +11,6 @@ * Cache the date processing, perhaps cache the formatted, timezone-adjusted * date strings for each entity (would have to be cached differently for each * timezone, based on the tz_handling method for the date). - * - * Add an option to set/not set the context on forms vs views. */ /** @@ -22,7 +23,7 @@ function date_context_context_node_condition_alter($node, $op) { } /** - * Implements hook_context_plugins() + * Implements hook_context_plugins(). */ function date_context_context_plugins() { $plugins = array(); @@ -38,7 +39,7 @@ function date_context_context_plugins() { } /** - * Implements hook_context_registry() + * Implements hook_context_registry(). */ function date_context_context_registry() { return array( @@ -51,4 +52,3 @@ function date_context_context_registry() { ), ); } - diff --git a/sites/all/modules/contrib/fields/date/date_context/plugins/date_context_date_condition.inc b/sites/all/modules/contrib/fields/date/date_context/plugins/date_context_date_condition.inc index 573b0354..97c18b47 100644 --- a/sites/all/modules/contrib/fields/date/date_context/plugins/date_context_date_condition.inc +++ b/sites/all/modules/contrib/fields/date/date_context/plugins/date_context_date_condition.inc @@ -1,10 +1,20 @@ $field) { @@ -15,10 +25,13 @@ class date_context_date_condition extends context_condition_node { return $values; } - function options_form($context) { + /** + * {@inheritdoc} + */ + public function options_form($context) { $defaults = $this->fetch_from_context($context, 'options'); $options = array( - '<' => t('Is less than'), + '<' => t('Is less than'), '<=' => t('Is less than or equal to'), '>=' => t('Is greater than or equal to'), '>' => t('Is greater than'), @@ -27,6 +40,8 @@ class date_context_date_condition extends context_condition_node { 'empty' => t('Is empty'), 'not empty' => t('Is not Empty'), ); + $dependency_options = array('<', '<=', '>', '>=', '=', '!='); + $form['operation'] = array( '#title' => t('Operation'), '#type' => 'select', @@ -41,12 +56,15 @@ class date_context_date_condition extends context_condition_node { '#description' => t("The value the field should contain to meet the condition. This can either be an absolute date in ISO format (YYYY-MM-DDTHH:MM:SS) or a relative string like '12AM today'. Examples: 2011-12-31T00:00:00, now, now +1 day, 12AM today, Monday next week. More examples of relative date formats in the PHP documentation.", array('@relative_format' => 'http://www.php.net/manual/en/datetime.formats.relative.php')), '#default_value' => isset($defaults['value']) ? $defaults['value'] : '', '#process' => array('ctools_dependent_process'), - '#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => array('<', '<=', '>', '>=', '=', '!=')), + '#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => $dependency_options), ); return $form; } - function execute($entity, $op) { + /** + * {@inheritdoc} + */ + public function execute($entity, $op) { if (in_array($op, array('view', 'form'))) { foreach ($this->get_contexts() as $context) { $options = $this->fetch_from_context($context, 'options'); @@ -91,32 +109,37 @@ class date_context_date_condition extends context_condition_node { str_replace('now', 'today', $options['value']); $date = date_create($options['value'], date_default_timezone_object()); $compdate = $date->format(DATE_FORMAT_DATETIME); - switch($options['operation']) { + switch ($options['operation']) { case '=': if ($date2 >= $compdate && $date1 <= $compdate) { $this->condition_met($context, $field_name); } break; + case '>': if ($date1 > $compdate) { $this->condition_met($context, $field_name); } break; + case '>=': if ($date1 >= $compdate) { $this->condition_met($context, $field_name); } break; + case '<': if ($date2 < $compdate) { $this->condition_met($context, $field_name); } break; + case '<=': if ($date2 <= $compdate) { $this->condition_met($context, $field_name); } break; + case '!=': if ($date1 < $compdate || $date2 > $compdate) { $this->condition_met($context, $field_name); @@ -130,3 +153,4 @@ class date_context_date_condition extends context_condition_node { } } } +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_elements.inc b/sites/all/modules/contrib/fields/date/date_elements.inc index 6908d967..83697153 100644 --- a/sites/all/modules/contrib/fields/date/date_elements.inc +++ b/sites/all/modules/contrib/fields/date/date_elements.inc @@ -40,7 +40,6 @@ * * - In the field's submission processing, the new date values, which are in * the local timezone, are converted back to their UTC values and stored. - * */ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) { @@ -87,7 +86,7 @@ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langco } module_load_include('inc', 'date_api', 'date_api_elements'); - $timezone = date_get_timezone($field['settings']['tz_handling'], isset($items[0]['timezone']) ? $items[0]['timezone'] : date_default_timezone()); + $timezone = date_get_timezone($field['settings']['tz_handling'], isset($items[$delta]['timezone']) ? $items[$delta]['timezone'] : date_default_timezone()); // TODO see if there's a way to keep the timezone element from ever being // nested as array('timezone' => 'timezone' => value)). After struggling @@ -122,7 +121,13 @@ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langco '#weight' => $instance['widget']['weight'] + 1, '#attributes' => array('class' => array('date-no-float')), '#date_label_position' => $instance['widget']['settings']['label_position'], - ); + ); + } + + // Make changes if instance is set to be rendered as a regular field. + if (!empty($instance['widget']['settings']['no_fieldset'])) { + $element['#title'] = check_plain($instance['label']); + $element['#theme_wrappers'] = ($field['cardinality'] == 1) ? array('date_form_element') : array(); } return $element; @@ -148,6 +153,7 @@ function date_local_date($item, $timezone, $field, $instance, $part = 'value') { // @TODO Figure out how to replace date_fuzzy_datetime() function. // Special case for ISO dates to create a valid date object for formatting. // Is this still needed? + // @codingStandardsIgnoreStart /* if ($field['type'] == DATE_ISO) { $value = date_fuzzy_datetime($value); @@ -157,6 +163,7 @@ function date_local_date($item, $timezone, $field, $instance, $part = 'value') { $value = date_convert($value, $field['type'], DATE_DATETIME, $db_timezone); } */ + // @codingStandardsIgnoreEnd $date = new DateObject($value, date_get_timezone_db($field['settings']['tz_handling'])); $date->limitGranularity($field['settings']['granularity']); @@ -193,8 +200,7 @@ function date_default_value($field, $instance, $langcode) { } /** - * Helper function for the date default value callback to set - * either 'value' or 'value2' to its default value. + * Helper function for the date default value callback to set either 'value' or 'value2' to its default value. */ function date_default_value_part($item, $field, $instance, $langcode, $part = 'value') { $timezone = date_get_timezone($field['settings']['tz_handling']); @@ -241,7 +247,6 @@ function date_default_value_part($item, $field, $instance, $langcode, $part = 'v * Process an individual date element. */ function date_combo_element_process($element, &$form_state, $form) { - if (date_hidden_element($element)) { // A hidden value for a new entity that had its end date set to blank // will not get processed later to populate the end date, so set it here. @@ -296,6 +301,7 @@ function date_combo_element_process($element, &$form_state, $form) { // Blank out the end date for optional end dates that match the start date, // except when this is a new node that has default values that should be honored. if (!$date_is_default && $field['settings']['todate'] != 'required' + && is_array($element['#default_value']) && !empty($element['#default_value'][$to_field]) && $element['#default_value'][$to_field] == $element['#default_value'][$from_field]) { unset($element['#default_value'][$to_field]); @@ -329,9 +335,9 @@ function date_combo_element_process($element, &$form_state, $form) { '#date_increment' => $instance['widget']['settings']['increment'], '#date_year_range' => $instance['widget']['settings']['year_range'], '#date_label_position' => $instance['widget']['settings']['label_position'], - ); + ); - $description = !empty($element['#description']) ? t($element['#description']) : ''; + $description = !empty($element['#description']) ? t($element['#description']) : ''; unset($element['#description']); // Give this element the right type, using a Date API @@ -347,11 +353,13 @@ function date_combo_element_process($element, &$form_state, $form) { $element['#attached']['js'][] = drupal_get_path('module', 'date') . '/date.js'; $element[$from_field]['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE; break; + case 'date_popup': $element[$from_field]['#type'] = 'date_popup'; $element[$from_field]['#theme_wrappers'] = array('date_popup'); $element[$from_field]['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE; break; + default: $element[$from_field]['#type'] = 'date_text'; $element[$from_field]['#theme_wrappers'] = array('date_text'); @@ -380,8 +388,11 @@ function date_combo_element_process($element, &$form_state, $form) { if ($field['settings']['todate'] == 'optional') { $element[$to_field]['#states'] = array( 'visible' => array( - 'input[name="' . $show_id . '"]' => array('checked' => TRUE), - )); + 'input[name="' . $show_id . '"]' => array( + 'checked' => TRUE, + ), + ), + ); } } else { @@ -404,16 +415,27 @@ function date_combo_element_process($element, &$form_state, $form) { $element[$from_field]['#date_title'] = t('@field_name', array('@field_name' => $instance['label'])); } + // Make changes if instance is set to be rendered as a regular field. + if (!empty($instance['widget']['settings']['no_fieldset'])) { + unset($element[$from_field]['#description']); + if (!empty($field['settings']['todate']) && isset($element['#description'])) { + $element['#description'] .= ' ' . t("Empty 'End date' values will use the 'Start date' values.") . ''; + } + } + $context = array( - 'field' => $field, - 'instance' => $instance, - 'form' => $form, + 'field' => $field, + 'instance' => $instance, + 'form' => $form, ); drupal_alter('date_combo_process', $element, $form_state, $context); return $element; } +/** + * Empty a date element. + */ function date_element_empty($element, &$form_state) { $item = array(); $item['value'] = NULL; @@ -428,6 +450,7 @@ function date_element_empty($element, &$form_state) { /** * Validate and update a combo element. + * * Don't try this if there were errors before reaching this point. */ function date_combo_validate($element, &$form_state) { @@ -444,6 +467,10 @@ function date_combo_validate($element, &$form_state) { $delta = $element['#delta']; $langcode = $element['#language']; + // Related issue: https://drupal.org/node/2279831. + if (!is_array($element['#field_parents'])) { + $element['#field_parents'] = array(); + } $form_values = drupal_array_get_nested_value($form_state['values'], $element['#field_parents']); $form_input = drupal_array_get_nested_value($form_state['input'], $element['#field_parents']); diff --git a/sites/all/modules/contrib/fields/date/date_migrate/date_migrate.info b/sites/all/modules/contrib/fields/date/date_migrate/date_migrate.info index 69012711..b3a6bba6 100644 --- a/sites/all/modules/contrib/fields/date/date_migrate/date_migrate.info +++ b/sites/all/modules/contrib/fields/date/date_migrate/date_migrate.info @@ -4,9 +4,9 @@ core = 7.x package = Date/Time hidden = TRUE -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.info b/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.info index 7223b763..6d79df40 100644 --- a/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.info +++ b/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.info @@ -20,9 +20,9 @@ package = "Features" project = "date_migrate_example" version = "7.x-2.0" -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.migrate.inc b/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.migrate.inc index e11dea66..216e1c54 100644 --- a/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.migrate.inc +++ b/sites/all/modules/contrib/fields/date/date_migrate/date_migrate_example/date_migrate_example.migrate.inc @@ -47,8 +47,8 @@ class DateExampleMigration extends XMLMigration { $xml_folder = drupal_get_path('module', 'date_migrate_example'); $items_url = $xml_folder . '/date_migrate_example.xml'; $item_xpath = '/source_data/item'; - $item_ID_xpath = 'id'; - $items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath); + $item_id_xpath = 'id'; + $items_class = new MigrateItemsXML($items_url, $item_xpath, $item_id_xpath); $this->source = new MigrateSourceMultiItems($items_class, $fields); $this->destination = new MigrateDestinationNode('date_migrate_example'); @@ -78,7 +78,7 @@ class DateExampleMigration extends XMLMigration { $this->addFieldMapping('field_datestamp_range:to', 'datestamp_range_to'); // You can specify a timezone to be applied to all values going into the - // field (Tokyo is UTC+9, no DST) + // field (Tokyo is UTC+9, no DST). $this->addFieldMapping('field_datetime', 'datetime') ->xpath('datetime'); $this->addFieldMapping('field_datetime:timezone') @@ -107,25 +107,25 @@ class DateExampleMigration extends XMLMigration { // The date range field can have multiple values. $current_row->date_range_from = array(); foreach ($current_row->xml->date_range as $range) { - $current_row->date_range_from[] = (string)$range->from[0]; - $current_row->date_range_to[] = (string)$range->to[0]; + $current_row->date_range_from[] = (string) $range->from[0]; + $current_row->date_range_to[] = (string) $range->to[0]; } - $current_row->datestamp_range_from = - (string) $current_row->xml->datestamp_range->from[0]; - $current_row->datestamp_range_to = - (string) $current_row->xml->datestamp_range->to[0]; + $current_row->datestamp_range_from + = (string) $current_row->xml->datestamp_range->from[0]; + $current_row->datestamp_range_to + = (string) $current_row->xml->datestamp_range->to[0]; - $current_row->datetime_range_from = - (string) $current_row->xml->datetime_range->from[0]; - $current_row->datetime_range_to = - (string) $current_row->xml->datetime_range->to[0]; - $current_row->datetime_range_timezone = - (string) $current_row->xml->datetime_range->timezone[0]; + $current_row->datetime_range_from + = (string) $current_row->xml->datetime_range->from[0]; + $current_row->datetime_range_to + = (string) $current_row->xml->datetime_range->to[0]; + $current_row->datetime_range_timezone + = (string) $current_row->xml->datetime_range->timezone[0]; - $current_row->date_repeat = - (string) $current_row->xml->date_repeat->date[0]; - $current_row->date_repeat_rrule = - (string) $current_row->xml->date_repeat->rule[0]; + $current_row->date_repeat + = (string) $current_row->xml->date_repeat->date[0]; + $current_row->date_repeat_rrule + = (string) $current_row->xml->date_repeat->rule[0]; } } diff --git a/sites/all/modules/contrib/fields/date/date_popup/date_popup.info b/sites/all/modules/contrib/fields/date/date_popup/date_popup.info index 271e1c68..500c7ffb 100644 --- a/sites/all/modules/contrib/fields/date/date_popup/date_popup.info +++ b/sites/all/modules/contrib/fields/date/date_popup/date_popup.info @@ -7,9 +7,9 @@ configure = admin/config/date/date_popup stylesheets[all][] = themes/datepicker.1.7.css -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_popup/date_popup.install b/sites/all/modules/contrib/fields/date/date_popup/date_popup.install index 790a514a..e13a4f5a 100644 --- a/sites/all/modules/contrib/fields/date/date_popup/date_popup.install +++ b/sites/all/modules/contrib/fields/date/date_popup/date_popup.install @@ -5,6 +5,7 @@ * Install, update and uninstall functions for the Date Popup module. */ +// @codingStandardsIgnoreStart /** * Implements hook_install(). */ @@ -17,6 +18,7 @@ function date_popup_install() { function date_popup_uninstall() { } +// @codingStandardsIgnoreEnd /** * Implements hook_enable(). diff --git a/sites/all/modules/contrib/fields/date/date_popup/date_popup.js b/sites/all/modules/contrib/fields/date/date_popup/date_popup.js index 1847f84f..bbf25e2d 100644 --- a/sites/all/modules/contrib/fields/date/date_popup/date_popup.js +++ b/sites/all/modules/contrib/fields/date/date_popup/date_popup.js @@ -1,62 +1,65 @@ /** * Attaches the calendar behavior to all required fields */ -(function ($) { -Drupal.behaviors.date_popup = { - attach: function (context) { - for (var id in Drupal.settings.datePopup) { - $('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) { - if (!$(this).hasClass('date-popup-init')) { - var datePopup = e.data; - // Explicitely filter the methods we accept. - switch (datePopup.func) { - case 'datepicker': - $(this) - .datepicker(datePopup.settings) - .addClass('date-popup-init') - $(this).click(function(){ - $(this).focus(); - }); - break; +(function($) { + function makeFocusHandler(e) { + if (!$(this).hasClass('date-popup-init')) { + var datePopup = e.data; + // Explicitely filter the methods we accept. + switch (datePopup.func) { + case 'datepicker': + $(this) + .datepicker(datePopup.settings) + .addClass('date-popup-init'); + $(this).click(function(){ + $(this).focus(); + }); + break; - case 'timeEntry': - $(this) - .timeEntry(datePopup.settings) - .addClass('date-popup-init') - $(this).click(function(){ - $(this).focus(); - }); - break; - case 'timepicker': - // Translate the PHP date format into the style the timepicker uses. - datePopup.settings.timeFormat = datePopup.settings.timeFormat - // 12-hour, leading zero, - .replace('h', 'hh') - // 12-hour, no leading zero. - .replace('g', 'h') - // 24-hour, leading zero. - .replace('H', 'HH') - // 24-hour, no leading zero. - .replace('G', 'H') - // AM/PM. - .replace('A', 'p') - // Minutes with leading zero. - .replace('i', 'mm') - // Seconds with leading zero. - .replace('s', 'ss'); + case 'timeEntry': + $(this) + .timeEntry(datePopup.settings) + .addClass('date-popup-init'); + $(this).click(function(){ + $(this).focus(); + }); + break; - datePopup.settings.startTime = new Date(datePopup.settings.startTime); - $(this) - .timepicker(datePopup.settings) - .addClass('date-popup-init'); - $(this).click(function(){ - $(this).focus(); - }); - break; - } + case 'timepicker': + // Translate the PHP date format into the style the timepicker uses. + datePopup.settings.timeFormat = datePopup.settings.timeFormat + // 12-hour, leading zero, + .replace('h', 'hh') + // 12-hour, no leading zero. + .replace('g', 'h') + // 24-hour, leading zero. + .replace('H', 'HH') + // 24-hour, no leading zero. + .replace('G', 'H') + // AM/PM. + .replace('A', 'p') + // Minutes with leading zero. + .replace('i', 'mm') + // Seconds with leading zero. + .replace('s', 'ss'); + + datePopup.settings.startTime = new Date(datePopup.settings.startTime); + $(this) + .timepicker(datePopup.settings) + .addClass('date-popup-init'); + $(this).click(function(){ + $(this).focus(); + }); + break; } - }); + } } - } -}; + + Drupal.behaviors.date_popup = { + attach: function (context) { + for (var id in Drupal.settings.datePopup) { + $('#'+ id).bind('focus', Drupal.settings.datePopup[id], makeFocusHandler); + } + } + }; })(jQuery); diff --git a/sites/all/modules/contrib/fields/date/date_popup/date_popup.module b/sites/all/modules/contrib/fields/date/date_popup/date_popup.module index a2d0ebb1..e91cc8a7 100644 --- a/sites/all/modules/contrib/fields/date/date_popup/date_popup.module +++ b/sites/all/modules/contrib/fields/date/date_popup/date_popup.module @@ -16,7 +16,6 @@ * If no time elements are included in the format string, only the date * textfield will be created. If no date elements are included in the format * string, only the time textfield, will be created. - * */ /** @@ -44,7 +43,7 @@ function date_popup_add() { /** * Get the location of the Willington Vega timepicker library. * - * @return + * @return string * The location of the library, or FALSE if the library isn't installed. */ function date_popup_get_wvega_path() { @@ -94,9 +93,11 @@ function date_popup_library() { } /** - * Create a unique CSS id name and output a single inline JS block for - * each startup function to call and settings array to pass it. This - * used to create a unique CSS class for each unique combination of + * Create a unique CSS id name and output a single inline JS block. + * + * For each startup function to call and settings array to pass it. + * + * This used to create a unique CSS class for each unique combination of * function and settings, but using classes requires a DOM traversal * and is much slower than an id lookup. The new approach returns to * requiring a duplicate copy of the settings/code for every element @@ -104,17 +105,20 @@ function date_popup_library() { * putting the ids for each unique function/settings combo into * Drupal.settings and searching for each listed id. * - * @param $pfx + * @param string $id * The CSS class prefix to search the DOM for. * TODO : unused ? - * @param $func - * The jQuery function to invoke on each DOM element containing the - * returned CSS class. - * @param $settings + * + * @param string $func + * The jQuery function to invoke on each DOM element + * containing the returned CSS class. + * + * @param array $settings * The settings array to pass to the jQuery function. + * * @returns - * The CSS id to assign to the element that should have - * $func($settings) invoked on it. + * The CSS id to assign to the element that should have $func($settings) + * invoked on it. */ function date_popup_js_settings_id($id, $func, $settings) { static $js_added = FALSE; @@ -123,14 +127,15 @@ function date_popup_js_settings_id($id, $func, $settings) { // Make sure popup date selector grid is in correct year. if (!empty($settings['yearRange'])) { $parts = explode(':', $settings['yearRange']); - // Set the default date to 0 or the lowest bound if the date ranges do not include the current year - // Necessary for the datepicker to render and select dates correctly - $defaultDate = ($parts[0] > 0 || 0 > $parts[1]) ? $parts[0] : 0; - $settings += array('defaultDate' => (string) $defaultDate . 'y'); + // Set the default date to 0 or the lowest bound if + // the date ranges do not include the current year. + // Necessary for the datepicker to render and select dates correctly. + $default_date = ($parts[0] > 0 || 0 > $parts[1]) ? $parts[0] : 0; + $settings += array('defaultDate' => (string) $default_date . 'y'); } if (!$js_added) { - drupal_add_js(drupal_get_path('module', 'date_popup') .'/date_popup.js'); + drupal_add_js(drupal_get_path('module', 'date_popup') . '/date_popup.js'); $js_added = TRUE; } @@ -140,29 +145,35 @@ function date_popup_js_settings_id($id, $func, $settings) { $id_count[$id] = 0; } -// It looks like we need the additional id_count for this to -// work correctly when there are multiple values. -// $return_id = "$id-$func-popup"; - $return_id = "$id-$func-popup-". $id_count[$id]++; + // It looks like we need the additional id_count for this to + // work correctly when there are multiple values. + // $return_id = "$id-$func-popup"; + $return_id = "$id-$func-popup-" . $id_count[$id]++; $js_settings['datePopup'][$return_id] = array( 'func' => $func, - 'settings' => $settings + 'settings' => $settings, ); drupal_add_js($js_settings, 'setting'); return $return_id; } +/** + * Date popup theme handler. + */ function date_popup_theme() { return array( - 'date_popup' => array('render element' => 'element'), - ); + 'date_popup' => array( + 'render element' => 'element', + ), + ); } /** * Implements hook_element_info(). * * Set the #type to date_popup and fill the element #default_value with - * a date adjusted to the proper local timezone in datetime format (YYYY-MM-DD HH:MM:SS). + * a date adjusted to the proper local timezone in datetime format + * (YYYY-MM-DD HH:MM:SS). * * The element will create two textfields, one for the date and one for the * time. The date textfield will include a jQuery popup calendar date picker, @@ -218,20 +229,32 @@ function date_popup_element_info() { return $type; } +/** + * Date popup date granularity. + */ function date_popup_date_granularity($element) { $granularity = date_format_order($element['#date_format']); return array_intersect($granularity, array('month', 'day', 'year')); } +/** + * Date popup time granularity. + */ function date_popup_time_granularity($element) { $granularity = date_format_order($element['#date_format']); return array_intersect($granularity, array('hour', 'minute', 'second')); } +/** + * Date popup date format. + */ function date_popup_date_format($element) { return (date_limit_format($element['#date_format'], date_popup_date_granularity($element))); } +/** + * Date popup time format. + */ function date_popup_time_format($element) { return date_popup_format_to_popup_time(date_limit_format($element['#date_format'], date_popup_time_granularity($element)), $element['#timepicker']); } @@ -239,6 +262,7 @@ function date_popup_time_format($element) { /** * Element value callback for date_popup element. */ +// @codingStandardsIgnoreStart function date_popup_element_value_callback($element, $input = FALSE, &$form_state) { $granularity = date_format_order($element['#date_format']); $has_time = date_has_time($granularity); @@ -266,9 +290,11 @@ function date_popup_element_value_callback($element, $input = FALSE, &$form_stat return $return; } +// @codingStandardsIgnoreEnd /** * Javascript popup element processing. + * * Add popup attributes to $element. */ function date_popup_element_process($element, &$form_state, $form) { @@ -284,7 +310,9 @@ function date_popup_element_process($element, &$form_state, $form) { if (!empty($element['#ajax'])) { $element['#ajax'] += array( - 'trigger_as' => array('name' =>$element['#name']), + 'trigger_as' => array( + 'name' => $element['#name'], + ), 'event' => 'change', ); } @@ -292,6 +320,18 @@ function date_popup_element_process($element, &$form_state, $form) { $element['date'] = date_popup_process_date_part($element); $element['time'] = date_popup_process_time_part($element); + // Make changes if instance is set to be rendered as a regular field. + if (!empty($element['#instance']['widget']['settings']['no_fieldset']) && $element['#field']['cardinality'] == 1) { + if (!empty($element['date']) && empty($element['time'])) { + $element['date']['#title'] = check_plain($element['#instance']['label']); + $element['date']['#required'] = $element['#required']; + } + elseif (empty($element['date']) && !empty($element['time'])) { + $element['time']['#title'] = check_plain($element['#instance']['label']); + $element['time']['#required'] = $element['#required']; + } + } + if (isset($element['#element_validate'])) { array_push($element['#element_validate'], 'date_popup_validate'); } @@ -300,7 +340,7 @@ function date_popup_element_process($element, &$form_state, $form) { } $context = array( - 'form' => $form, + 'form' => $form, ); drupal_alter('date_popup_process', $element, $form_state, $context); @@ -313,13 +353,22 @@ function date_popup_element_process($element, &$form_state, $form) { function date_popup_process_date_part(&$element) { $granularity = date_format_order($element['#date_format']); $date_granularity = date_popup_date_granularity($element); - if (empty($date_granularity)) return array(); + if (empty($date_granularity)) { + return array(); + } // The datepicker can't handle zero or negative values like 0:+1 // even though the Date API can handle them, so rework the value // we pass to the datepicker to use defaults it can accept (such as +0:+1) // date_range_string() adds the necessary +/- signs to the range string. $this_year = date_format(date_now(), 'Y'); + // When used as a Views exposed filter widget, $element['#value'] contains an array instead an string. + // Fill the 'date' string in this case. + $mock = NULL; + $callback_values = date_popup_element_value_callback($element, FALSE, $mock); + if (!isset($element['#value']['date']) && isset($callback_values['date'])) { + $element['#value']['date'] = $callback_values['date']; + } $date = ''; if (!empty($element['#value']['date'])) { $date = new DateObject($element['#value']['date'], $element['#date_timezone'], date_popup_date_format($element)); @@ -336,8 +385,9 @@ function date_popup_process_date_part(&$element) { 'closeAtTop' => FALSE, 'speed' => 'immediate', 'firstDay' => intval(variable_get('date_first_day', 0)), - //'buttonImage' => base_path() . drupal_get_path('module', 'date_api') ."/images/calendar.png", - //'buttonImageOnly' => TRUE, + // 'buttonImage' => base_path() + // . drupal_get_path('module', 'date_api') ."/images/calendar.png", + // 'buttonImageOnly' => TRUE, 'dateFormat' => date_popup_format_to_popup(date_popup_date_format($element), 'datepicker'), 'yearRange' => $year_range, // Custom setting, will be expanded in Drupal.behaviors.date_popup() @@ -347,26 +397,33 @@ function date_popup_process_date_part(&$element) { // Create a unique id for each set of custom settings. $id = date_popup_js_settings_id($element['#id'], 'datepicker', $settings); - // Manually build this element and set the value - this will prevent corrupting - // the parent value + // Manually build this element and set the value - + // this will prevent corrupting the parent value. $parents = array_merge($element['#parents'], array('date')); $sub_element = array( '#type' => 'textfield', '#title' => theme('date_part_label_date', array('part_type' => 'date', 'element' => $element)), '#title_display' => $element['#date_label_position'] == 'above' ? 'before' : 'invisible', - '#default_value' => $element['#value']['date'], + '#default_value' => date_format_date($date, 'custom', date_popup_date_format($element)), '#id' => $id, '#input' => FALSE, '#size' => !empty($element['#size']) ? $element['#size'] : 20, '#maxlength' => !empty($element['#maxlength']) ? $element['#maxlength'] : 30, '#attributes' => $element['#attributes'], '#parents' => $parents, - '#name' => array_shift($parents) . '['. implode('][', $parents) .']', + '#name' => array_shift($parents) . '[' . implode('][', $parents) . ']', '#ajax' => !empty($element['#ajax']) ? $element['#ajax'] : FALSE, ); $sub_element['#value'] = $sub_element['#default_value']; - // TODO, figure out exactly when we want this description. In many places it is not desired. - $sub_element['#description'] = ' '. t('E.g., @date', array('@date' => date_format_date(date_example_date(), 'custom', date_popup_date_format($element)))); + // TODO, figure out exactly when we want this description. + // In many places it is not desired. + $sub_element['#description'] = ' ' . t('E.g., @date', array( + '@date' => date_format_date( + date_example_date(), + 'custom', + date_popup_date_format($element) + ), + )); return $sub_element; } @@ -377,7 +434,17 @@ function date_popup_process_date_part(&$element) { function date_popup_process_time_part(&$element) { $granularity = date_format_order($element['#date_format']); $has_time = date_has_time($granularity); - if (empty($has_time)) return array(); + if (empty($has_time)) { + return array(); + } + + // When used as a Views exposed filter widget, $element['#value'] contains an array instead an string. + // Fill the 'time' string in this case. + $mock = NULL; + $callback_values = date_popup_element_value_callback($element, FALSE, $mock); + if (!isset($element['#value']['time']) && isset($callback_values['time'])) { + $element['#value']['time'] = $callback_values['time']; + } switch ($element['#timepicker']) { case 'default': @@ -385,10 +452,14 @@ function date_popup_process_time_part(&$element) { $settings = array( 'show24Hours' => strpos($element['#date_format'], 'H') !== FALSE ? TRUE : FALSE, 'showSeconds' => (in_array('second', $granularity) ? TRUE : FALSE), - 'timeSteps' => array(1, intval($element['#date_increment']), (in_array('second', $granularity) ? $element['#date_increment'] : 0)), + 'timeSteps' => array( + 1, + intval($element['#date_increment']), + (in_array('second', $granularity) ? $element['#date_increment'] : 0), + ), 'spinnerImage' => '', 'fromTo' => isset($fromto), - ); + ); if (strpos($element['#date_format'], 'a') !== FALSE) { // Then we are using lowercase am/pm. $settings['ampmNames'] = array('am', 'pm'); @@ -397,9 +468,11 @@ function date_popup_process_time_part(&$element) { $settings['ampmPrefix'] = ' '; } break; + case 'wvega': $func = 'timepicker'; - $time_granularity = array_intersect($granularity, array('hour', 'minute', 'second')); + $grans = array('hour', 'minute', 'second'); + $time_granularity = array_intersect($granularity, $grans); $format = date_popup_format_to_popup_time(date_limit_format($element['#date_format'], $time_granularity), 'wvega'); // The first value in the dropdown list should be the same as the element // default_value, but it needs to be in JS format (i.e. milliseconds since @@ -414,6 +487,7 @@ function date_popup_process_time_part(&$element) { 'scrollbar' => TRUE, ); break; + default: $func = ''; $settings = array(); @@ -423,8 +497,8 @@ function date_popup_process_time_part(&$element) { // Create a unique id for each set of custom settings. $id = date_popup_js_settings_id($element['#id'], $func, $settings); - // Manually build this element and set the value - this will prevent corrupting - // the parent value + // Manually build this element and set the value - + // this will prevent corrupting the parent value. $parents = array_merge($element['#parents'], array('time')); $sub_element = array( '#type' => 'textfield', @@ -436,16 +510,22 @@ function date_popup_process_time_part(&$element) { '#maxlength' => 10, '#attributes' => $element['#attributes'], '#parents' => $parents, - '#name' => array_shift($parents) . '['. implode('][', $parents) .']', + '#name' => array_shift($parents) . '[' . implode('][', $parents) . ']', '#ajax' => !empty($element['#ajax']) ? $element['#ajax'] : FALSE, ); $sub_element['#value'] = $sub_element['#default_value']; - // TODO, figure out exactly when we want this description. In many places it is not desired. + // TODO, figure out exactly when we want this description. + // In many places it is not desired. $example_date = date_now(); date_increment_round($example_date, $element['#date_increment']); - $sub_element['#description'] = t('E.g., @date', array('@date' => date_format_date($example_date, 'custom', date_popup_time_format($element)))); + $sub_element['#description'] = t('E.g., @date', array( + '@date' => date_format_date( + $example_date, + 'custom', + date_popup_time_format($element) + ))); return ($sub_element); } @@ -456,7 +536,6 @@ function date_popup_process_time_part(&$element) { * When used as a Views widget, the validation step always gets triggered, * even with no form submission. Before form submission $element['#value'] * contains a string, after submission it contains an array. - * */ function date_popup_validate($element, &$form_state) { @@ -473,6 +552,11 @@ function date_popup_validate($element, &$form_state) { $input_exists = NULL; $input = drupal_array_get_nested_value($form_state['values'], $element['#parents'], $input_exists); + // If the date is a string, it is not considered valid and can cause problems + // later on, so just exit out now. + if (is_string($input)) { + return; + } drupal_alter('date_popup_pre_validate', $element, $form_state, $input); @@ -481,9 +565,15 @@ function date_popup_validate($element, &$form_state) { $time_granularity = date_popup_time_granularity($element); $has_time = date_has_time($granularity); - $label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : ''); - $label = t($label); - + // @codingStandardsIgnoreStart + $label = ''; + if (!empty($element['#date_title'])) { + $label = t($element['#date_title']); + } + elseif (!empty($element['#title'])) { + $label = t($element['#title']); + } + // @codingStandardsIgnoreEnd $date = date_popup_input_date($element, $input); // If the date has errors, display them. @@ -517,7 +607,7 @@ function date_popup_validate($element, &$form_state) { /** * Helper function for extracting a date value out of user input. * - * @param autocomplete + * @param bool $auto_complete * Should we add a time value to complete the date if there is no time? * Useful anytime the time value is optional. */ @@ -532,8 +622,8 @@ function date_popup_input_date($element, $input, $auto_complete = FALSE) { $format = date_popup_date_format($element); $format .= $has_time ? ' ' . date_popup_time_format($element) : ''; - $datetime = $input['date']; - $datetime .= $has_time ? ' ' . $input['time'] : ''; + $datetime = trim($input['date']); + $datetime .= $has_time ? ' ' . trim($input['time']) : ''; $date = new DateObject($datetime, $element['#date_timezone'], $format); if (is_object($date)) { $date->limitGranularity($granularity); @@ -552,7 +642,7 @@ function date_popup_time_formats($with_seconds = FALSE) { return array( 'H:i:s', 'h:i:sA', - ); + ); } /** @@ -561,8 +651,17 @@ function date_popup_time_formats($with_seconds = FALSE) { * TODO Remove any formats not supported by the widget, if any. */ function date_popup_formats() { - $formats = str_replace('i', 'i:s', array_keys(system_get_date_formats('short'))); + // Load short date formats. + $formats = system_get_date_formats('short'); + + // Load custom date formats. + if ($formats_custom = system_get_date_formats('custom')) { + $formats = array_merge($formats, $formats_custom); + } + + $formats = str_replace('i', 'i:s', array_keys($formats)); $formats = drupal_map_assoc($formats); + return $formats; } @@ -570,7 +669,8 @@ function date_popup_formats() { * Recreate a date format string so it has the values popup expects. * * @param string $format - * a normal date format string, like Y-m-d + * A normal date format string, like Y-m-d + * * @return string * A format string in popup format, like YMD-, for the * earlier 'calendar' version, or m/d/Y for the later 'datepicker' @@ -588,15 +688,34 @@ function date_popup_format_to_popup($format) { * Recreate a time format string so it has the values popup expects. * * @param string $format - * a normal time format string, like h:i (a) + * A normal time format string, like h:i (a) + * * @return string - * a format string that the popup can accept like h:i a + * A format string that the popup can accept like h:i a */ function date_popup_format_to_popup_time($format, $timepicker = NULL) { if (empty($format)) { $format = 'H:i'; } - $format = str_replace(array('/', '-', ' .', ',', 'F', 'M', 'l', 'z', 'w', 'W', 'd', 'j', 'm', 'n', 'y', 'Y'), '', $format); + $symbols = array( + '/', + '-', + ' .', + ',', + 'F', + 'M', + 'l', + 'z', + 'w', + 'W', + 'd', + 'j', + 'm', + 'n', + 'y', + 'Y', + ); + $format = str_replace($symbols, '', $format); $format = strtr($format, date_popup_timepicker_format_replacements($timepicker)); return $format; } @@ -605,9 +724,10 @@ function date_popup_format_to_popup_time($format, $timepicker = NULL) { * Reconstruct popup format string into normal format string. * * @param string $format - * a string in popup format, like YMD- + * A string in popup format, like YMD- + * * @return string - * a normal date format string, like Y-m-d + * A normal date format string, like Y-m-d */ function date_popup_popup_to_format($format) { $replace = array_flip(date_popup_datepicker_format_replacements()); @@ -621,22 +741,21 @@ function date_popup_popup_to_format($format) { * This function returns a map of format replacements required to change any * input format into one that the given timepicker can support. * - * @param $timepicker + * @param string $timepicker * The time entry plugin being used: either 'wvega' or 'default'. - * @return + * + * @return array * A map of replacements. */ function date_popup_timepicker_format_replacements($timepicker = 'default') { switch ($timepicker) { case 'wvega': - return array( - 'a' => 'A', // The wvega timepicker only supports uppercase AM/PM. - ); + // The wvega timepicker only supports uppercase AM/PM. + return array('a' => 'A'); + default: - return array( - 'G' => 'H', // The default timeEntry plugin requires leading zeros. - 'g' => 'h', - ); + // The default timeEntry plugin requires leading zeros. + return array('G' => 'H', 'g' => 'h'); } } @@ -645,16 +764,16 @@ function date_popup_timepicker_format_replacements($timepicker = 'default') { */ function date_popup_datepicker_format_replacements() { return array( - 'd' => 'dd', - 'j' => 'd', - 'l' => 'DD', - 'D' => 'D', - 'm' => 'mm', - 'n' => 'm', - 'F' => 'MM', - 'M' => 'M', - 'Y' => 'yy', - 'y' => 'y', + 'd' => 'dd', + 'j' => 'd', + 'l' => 'DD', + 'D' => 'D', + 'm' => 'mm', + 'n' => 'm', + 'F' => 'MM', + 'M' => 'M', + 'Y' => 'yy', + 'y' => 'y', ); } @@ -667,16 +786,18 @@ function theme_date_popup($vars) { $element = $vars['element']; $attributes = !empty($element['#wrapper_attributes']) ? $element['#wrapper_attributes'] : array('class' => array()); $attributes['class'][] = 'container-inline-date'; - // If there is no description, the floating date elements need some extra padding below them. + // If there is no description, the floating date + // elements need some extra padding below them. $wrapper_attributes = array('class' => array('date-padding')); if (empty($element['date']['#description'])) { $wrapper_attributes['class'][] = 'clearfix'; } - // Add an wrapper to mimic the way a single value field works, for ease in using #states. + // Add an wrapper to mimic the way a single value field works, + // for ease in using #states. if (isset($element['#children'])) { - $element['#children'] = '
' . $element['#children'] . '
'; + $element['#children'] = '
' . $element['#children'] . '
'; } - return '
' . theme('form_element', $element) . '
'; + return '
' . theme('form_element', $element) . '
'; } /** @@ -707,8 +828,8 @@ function date_popup_settings() { '#type' => 'select', '#options' => array( 'default' => t('Use default jQuery timepicker'), - 'wvega' => t('Use dropdown timepicker'), - 'none' => t('Manual time entry, no jQuery timepicker') + 'wvega' => t('Use dropdown timepicker'), + 'none' => t('Manual time entry, no jQuery timepicker'), ), '#title' => t('Timepicker'), '#default_value' => variable_get('date_popup_timepicker', $preferred_timepicker), @@ -734,7 +855,7 @@ function date_popup_settings() { } EOM; - $form['#suffix'] = t('

The Date Popup calendar includes some css for IE6 that breaks css validation. Since IE 6 is now superceded by IE 7, 8, and 9, the special css for IE 6 has been removed from the regular css used by the Date Popup. If you find you need that css after all, you can add it back in your theme. Look at the way the Garland theme adds special IE-only css in in its page.tpl.php file. The css you need is:

') .'
' . $css .'
'; + $form['#suffix'] = t('

The Date Popup calendar includes some css for IE6 that breaks css validation. Since IE 6 is now superceded by IE 7, 8, and 9, the special css for IE 6 has been removed from the regular css used by the Date Popup. If you find you need that css after all, you can add it back in your theme. Look at the way the Garland theme adds special IE-only css in in its page.tpl.php file. The css you need is:

') . '
' . $css . '
'; return system_settings_form($form); } diff --git a/sites/all/modules/contrib/fields/date/date_popup/jquery.timeentry.pack.js b/sites/all/modules/contrib/fields/date/date_popup/jquery.timeentry.pack.js index e26c64bf..658e7e49 100644 --- a/sites/all/modules/contrib/fields/date/date_popup/jquery.timeentry.pack.js +++ b/sites/all/modules/contrib/fields/date/date_popup/jquery.timeentry.pack.js @@ -1,7 +1,8 @@ /* http://keith-wood.name/timeEntry.html - Time entry for jQuery v1.4.8. + Time entry for jQuery v1.5.2. Written by Keith Wood (kbwood{at}iinet.com.au) June 2007. - Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and - MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. + Licensed under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. Please attribute the author if you use it. */ -eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(r($){r 1n(){p.Y=[];p.26=[];p.26[\'\']={1c:B,1d:\':\',1o:\'\',Z:[\'3J\',\'3K\'],2C:[\'3L\',\'3M 2D\',\'3N 2D\',\'3O\',\'3P\']};p.1B={2E:\'\',1C:B,27:[1,1,1],2F:0,2G:L,2H:v,2I:v,2J:v,2K:\'3Q.3R\',1p:[20,20,8],2L:\'\',1D:[40,40,16],2M:B,28:[3S,3T],2N:v,2O:v};$.1q(p.1B,p.26[\'\'])}7 m=\'o\';$.1q(1n.2P,{1e:\'3U\',3V:r(a){1E(p.1B,a||{});u p},2Q:r(b,c){7 d=$(b);q(d.2R(p.1e)){u}7 e={};e.1r=$.1q({},c);e.E=0;e.13=0;e.14=0;e.x=0;e.w=$(b);$.y(b,m,e);7 f=p.t(e,\'2K\');7 g=p.t(e,\'3W\');7 h=p.t(e,\'1p\');7 i=p.t(e,\'2E\');7 j=(!f?v:$(\'<15 1F="3X" 2S="3Y: 3Z-41; \'+\'29: 2T(\\\'\'+f+\'\\\') 0 0 2U-2V; \'+\'2a: \'+h[0]+\'O; 2W: \'+h[1]+\'O;\'+($.K.2X&&$.K.42<\'1.9\'?\' 2Y-U: \'+h[0]+\'O; 2Y-43: \'+(h[1]-18)+\'O;\':\'\')+\'">\'));d.44(\'<15 1F="45">\').2Z(i?\'<15 1F="47">\'+i+\'\':\'\').2Z(j||\'\');d.49(p.1e).17(\'2b.o\',p.2c).17(\'4a.o\',p.30).17(\'4b.o\',p.31).17(\'4c.o\',p.32).17(\'4d.o\',p.33);q($.K.2X){d.17(\'w.o\',r(a){$.o.1f(e)})}q($.K.2d){d.17(\'4e.o\',r(a){1G(r(){$.o.1f(e)},1)})}q(p.t(e,\'2G\')&&$.1H.2e){d.2e(p.34)}q(j){j.3a(p.2f).2g(p.1I).4f(p.3b).2h(p.1I).3c(p.2i)}},4g:r(a){p.2j(a,B)},4h:r(a){p.2j(a,L)},2j:r(b,c){7 d=$.y(b,m);q(!d){u}b.3d=c;q(b.2k&&b.2k.1J.1g()==\'15\'){$.o.1K(d,b.2k,(c?5:-1))}$.o.Y=$.3e($.o.Y,r(a){u(a==b?v:a)});q(c){$.o.Y.4i(b)}},1s:r(a){u $.3f(a,p.Y)>-1},4j:r(a,b,c){7 d=$.y(a,m);q(d){q(1h b==\'1L\'){7 e=b;b={};b[e]=c}7 f=p.1i(d);1E(d.1r,b||{});q(f){p.19(d,F J(0,0,0,f[0],f[1],f[2]))}}$.y(a,m,d)},4k:r(b){$w=$(b);q(!$w.2R(p.1e)){u}$w.4l(p.1e).4m(\'.o\');q($.1H.2e){$w.4n()}p.Y=$.3e(p.Y,r(a){u(a==b?v:a)});$w.4o().4p($w);$.4q(b,m)},4r:r(a,b){7 c=$.y(a,m);q(c){p.19(c,b?(1h b==\'4s\'?F J(b.2l()):b):v)}},3g:r(a){7 b=$.y(a,m);7 c=(b?p.1i(b):v);u(!c?v:F J(0,0,0,c[0],c[1],c[2]))},4t:r(a){7 b=$.y(a,m);7 c=(b?p.1i(b):v);u(!c?0:(c[0]*4u+c[1]*2m+c[2])*3h)},2c:r(a){7 b=(a.1J&&a.1J.1g()==\'w\'?a:p);q($.o.P==b||$.o.1s(b)){$.o.1M=B;u}7 c=$.y(b,m);$.o.1M=L;$.o.P=b;$.o.1j=v;7 d=$.o.t(c,\'2N\');1E(c.1r,(d?d.1N(b,[b]):{}));$.y(b,m,c);$.o.1f(c);1G(r(){$.o.1a(c)},10)},30:r(a){$.o.1j=$.o.P;$.o.P=v},31:r(b){7 c=b.1k;7 d=$.y(c,m);q(!$.o.1M){7 e=$.o.t(d,\'1d\').G+2;d.x=0;q(c.3i!=v){1O(7 f=0;f<=I.1l(1,d.V,d.D);f++){7 g=(f!=d.D?(f*e)+2:(d.D*e)+$.o.t(d,\'1o\').G+$.o.t(d,\'Z\')[0].G);d.x=f;q(c.3i=48){u L}7 b=$.y(a.1k,m);2r(a.2q){A 9:u(a.4B?$.o.W(b,-1,L):$.o.W(b,+1,L));A 35:q(a.3m){$.o.1R(b,\'\')}N{b.x=I.1l(1,b.V,b.D);$.o.R(b,0)}C;A 36:q(a.3m){$.o.19(b)}N{b.x=0;$.o.R(b,0)}C;A 37:$.o.W(b,-1,B);C;A 38:$.o.R(b,+1);C;A 39:$.o.W(b,+1,B);C;A 40:$.o.R(b,-1);C;A 46:$.o.1R(b,\'\');C}u B},33:r(a){7 b=4C.4D(a.3n==4E?a.2q:a.3n);q(b<\' \'){u L}7 c=$.y(a.1k,m);$.o.3o(c,b);u B},34:r(a,b){q($.o.1s(a.1k)){u}b=($.K.3p?-b/I.1S(b):($.K.2s?b/I.1S(b):b));7 c=$.y(a.1k,m);c.w.2b();q(!c.w.T()){$.o.1f(c)}$.o.R(c,b);a.4F()},3b:r(b){7 c=$.o.1b(b);7 d=$.y($.o.1m(c),m);7 e=$.o.t(d,\'2L\');q(e){d.1T=L;7 f=$(c).1Q();7 g=v;$(c).3q().2t(r(){7 a=$(p);q(a.1v(\'1w\')==\'4G\'||a.1v(\'1w\')==\'3r\'){g=a.1Q()}u!g});7 h=$.o.t(d,\'1p\');7 i=$.o.t(d,\'1D\');$(\'<3s 1F="4H" 2S="1w: 3r; U: \'+(f.U-(i[0]-h[0])/2-(g?g.U:0))+\'O; 1x: \'+(f.1x-(i[1]-h[1])/2-(g?g.1x:0))+\'O; 2a: \'+i[0]+\'O; 2W: \'+i[1]+\'O; 29: 4I 2T(\'+e+\') 2U-2V 2u 2u; z-4J: 10;">\').3a($.o.2f).2g($.o.1I).2h($.o.3t).3c($.o.2i).4K(c)}},1m:r(a){u $(a).4L(\'.\'+$.o.1e)[0]},2i:r(a){7 b=$.o.1b(a);7 c=$.y($.o.1m(b),m);b.4M=$.o.t(c,\'2C\')[$.o.2v(c,a)]},2f:r(a){7 b=$.o.1b(a);7 c=$.o.1m(b);q($.o.1s(c)){u}q(c==$.o.1j){$.o.P=c;$.o.1j=v}7 d=$.y(c,m);$.o.2c(c);7 e=$.o.2v(d,a);$.o.1K(d,b,e);$.o.2w(d,e);$.o.X=v;$.o.1U=L;7 f=$.o.t(d,\'28\');q(e>=3&&f[0]){$.o.X=1G(r(){$.o.2x(d,e)},f[0]);$(b).3u(\'2h\',$.o.2y).3u(\'2g\',$.o.2y)}},2w:r(a,b){q(!a.w.T()){$.o.1f(a)}2r(b){A 0:p.19(a);C;A 1:p.W(a,-1,B);C;A 2:p.W(a,+1,B);C;A 3:p.R(a,+1);C;A 4:p.R(a,-1);C}},2x:r(a,b){q(!$.o.X){u}$.o.P=$.o.1j;p.2w(a,b);p.X=1G(r(){$.o.2x(a,b)},p.t(a,\'28\')[1])},2y:r(a){4N($.o.X);$.o.X=v},3t:r(a){$.o.X=v;7 b=$.o.1b(a);7 c=$.o.1m(b);7 d=$.y(c,m);$(b).4O();d.1T=B},1I:r(a){$.o.X=v;7 b=$.o.1b(a);7 c=$.o.1m(b);7 d=$.y(c,m);q(!$.o.1s(c)){$.o.1K(d,b,-1)}q($.o.1U){$.o.P=$.o.1j}q($.o.P&&$.o.1U){$.o.1a(d)}$.o.1U=B},1b:r(a){u a.1k||a.3j},2v:r(a,b){7 c=p.1b(b);7 d=($.K.3p||$.K.2s?$.o.3v(c):$(c).1Q());7 e=($.K.2s?$.o.3w(c):[1t.2n.1u||1t.3x.1u,1t.2n.1V||1t.3x.1V]);7 f=p.t(a,\'2M\');7 g=(f?3y:b.3k+e[0]-d.U-($.K.2d?2:0));7 h=b.4P+e[1]-d.1x-($.K.2d?2:0);7 i=p.t(a,(a.1T?\'1D\':\'1p\'));7 j=(f?3y:i[0]-1-g);7 k=i[1]-1-h;q(i[2]>0&&I.1S(g-j)<=i[2]&&I.1S(h-k)<=i[2]){u 0}7 l=I.3z(g,h,j,k);u(l==g?1:(l==j?2:(l==h?3:4)))},1K:r(a,b,c){$(b).1v(\'29-1w\',\'-\'+((c+1)*p.t(a,(a.1T?\'1D\':\'1p\'))[0])+\'O 2u\')},3v:r(a){7 b=1W=0;q(a.3A){b=a.2o;1W=a.3B;2z(a=a.3A){7 c=b;b+=a.2o;q(b<0){b=c}1W+=a.3B}}u{U:b,1x:1W}},3w:r(a){7 b=B;$(a).3q().2t(r(){b|=$(p).1v(\'1w\')==\'4Q\'});q(b){u[0,0]}7 c=a.1u;7 d=a.1V;2z(a=a.4R){c+=a.1u||0;d+=a.1V||0}u[c,d]},t:r(a,b){u(a.1r[b]!=v?a.1r[b]:$.o.1B[b])},1f:r(a){7 b=p.1i(a);7 c=p.t(a,\'1C\');q(b){a.E=b[0];a.13=b[1];a.14=b[2]}N{7 d=p.1y(a);a.E=d[0];a.13=d[1];a.14=(c?d[2]:0)}a.V=(c?2:-1);a.D=(p.t(a,\'1c\')?-1:(c?3:2));a.1X=\'\';a.x=I.1l(0,I.3z(I.1l(1,a.V,a.D),p.t(a,\'2F\')));q(a.w.T()!=\'\'){p.2A(a)}},1i:r(a,b){b=b||a.w.T();7 c=p.t(a,\'1d\');7 d=b.4S(c);q(c==\'\'&&b!=\'\'){d[0]=b.1z(0,2);d[1]=b.1z(2,4);d[2]=b.1z(4,6)}7 e=p.t(a,\'Z\');7 f=p.t(a,\'1c\');q(d.G>=2){7 g=!f&&(b.3C(e[0])>-1);7 h=!f&&(b.3C(e[1])>-1);7 i=Q(d[0],10);i=(2B(i)?0:i);i=((g||h)&&i==12?0:i)+(h?12:0);7 j=Q(d[1],10);j=(2B(j)?0:j);7 k=(d.G>=3?Q(d[2],10):0);k=(2B(k)||!p.t(a,\'1C\')?0:k);u p.1y(a,[i,j,k])}u v},1y:r(a,b){7 c=(b!=v);q(!c){7 d=p.1A(a,p.t(a,\'2H\'))||F J();b=[d.1Y(),d.1Z(),d.21()]}7 e=B;7 f=p.t(a,\'27\');1O(7 i=0;i1){b[i]=I.4T(b[i]/f[i])*f[i];e=L}}u b},2A:r(a){7 b=p.t(a,\'1c\');7 c=p.t(a,\'1d\');7 d=(p.22(b?a.E:((a.E+11)%12)+1)+c+p.22(a.13)+(p.t(a,\'1C\')?c+p.22(a.14):\'\')+(b?\'\':p.t(a,\'1o\')+p.t(a,\'Z\')[(a.E<12?0:1)]));p.1R(a,d);p.1a(a)},1a:r(a){7 b=a.w[0];q(a.w.4U(\':4V\')||$.o.P!=b){u}7 c=p.t(a,\'1d\');7 d=c.G+2;7 e=(a.x!=a.D?(a.x*d):(a.D*d)-c.G+p.t(a,\'1o\').G);7 f=e+(a.x!=a.D?2:p.t(a,\'Z\')[0].G);q(b.3D){b.3D(e,f)}N q(b.1P){7 g=b.1P();g.4W(\'2p\',e);g.3l(\'2p\',f-a.w.T().G);g.4X()}q(!b.3d){b.2b()}},22:r(a){u(a<10?\'0\':\'\')+a},1R:r(a,b){q(b!=a.w.T()){a.w.T(b).4Y(\'4Z\')}},W:r(a,b,c){7 d=(a.w.T()==\'\'||a.x==(b==-1?0:I.1l(1,a.V,a.D)));q(!d){a.x+=b}p.1a(a);a.1X=\'\';$.y(a.w[0],m,a);u(d&&c)},R:r(a,b){q(a.w.T()==\'\'){b=0}7 c=p.t(a,\'27\');p.19(a,F J(0,0,0,a.E+(a.x==0?b*c[0]:0)+(a.x==a.D?b*12:0),a.13+(a.x==1?b*c[1]:0),a.14+(a.x==a.V?b*c[2]:0)))},19:r(a,b){b=p.1A(a,b);7 c=p.1y(a,b?[b.1Y(),b.1Z(),b.21()]:v);b=F J(0,0,0,c[0],c[1],c[2]);7 b=p.25(b);7 d=p.25(p.1A(a,p.t(a,\'2I\')));7 e=p.25(p.1A(a,p.t(a,\'2J\')));b=(d&&be?e:b));7 f=p.t(a,\'2O\');q(f){b=f.1N(a.w[0],[p.3g(a.w[0]),b,d,e])}a.E=b.1Y();a.13=b.1Z();a.14=b.21();p.2A(a);$.y(a.w[0],m,a)},25:r(a){q(!a){u v}a.50(51);a.52(0);a.53(0);u a},1A:r(i,j){7 k=r(a){7 b=F J();b.54(b.2l()+a*3h);u b};7 l=r(a){7 b=$.o.1i(i,a);7 c=F J();7 d=(b?b[0]:c.1Y());7 e=(b?b[1]:c.1Z());7 f=(b?b[2]:c.21());q(!b){7 g=/([+-]?[0-9]+)\\s*(s|S|m|M|h|H)?/g;7 h=g.3E(a);2z(h){2r(h[2]||\'s\'){A\'s\':A\'S\':f+=Q(h[1],10);C;A\'m\':A\'M\':e+=Q(h[1],10);C;A\'h\':A\'H\':d+=Q(h[1],10);C}h=g.3E(a)}}c=F J(0,0,10,d,e,f,0);q(/^!/.55(a)){q(c.3F()>10){c=F J(0,0,10,23,59,59)}N q(c.3F()<10){c=F J(0,0,10,0,0,0)}}u c};u(j?(1h j==\'1L\'?l(j):(1h j==\'56\'?k(j):j)):v)},3o:r(a,b){q(b==p.t(a,\'1d\')){p.W(a,+1,B)}N q(b>=\'0\'&&b<=\'9\'){7 c=Q(b,10);7 d=Q(a.1X+b,10);7 e=p.t(a,\'1c\');7 f=(a.x!=0?a.E:(e?(d<24?d:c):(d>=1&&d<=12?d:(c>0?c:a.E))%12+(a.E>=12?12:0)));7 g=(a.x!=1?a.13:(d<2m?d:c));7 h=(a.x!=a.V?a.14:(d<2m?d:c));7 i=p.1y(a,[f,g,h]);p.19(a,F J(0,0,0,i[0],i[1],i[2]));a.1X=b}N q(!p.t(a,\'1c\')){b=b.1g();7 j=p.t(a,\'Z\');q((b==j[0].1z(0,1).1g()&&a.E>=12)||(b==j[1].1z(0,1).1g()&&a.E<12)){7 k=a.x;a.x=a.D;p.R(a,+1);a.x=k;p.1a(a)}}}});r 1E(a,b){$.1q(a,b);1O(7 c 57 b){q(b[c]==v){a[c]=v}}u a}7 n=[\'58\',\'2l\',\'5a\'];$.1H.o=r(c){7 d=5b.2P.5c.5d(5e,1);q(1h c==\'1L\'&&$.3f(c,n)>-1){u $.o[\'3G\'+c+\'1n\'].1N($.o,[p[0]].3H(d))}u p.2t(r(){7 a=p.1J.1g();q(a==\'w\'){q(1h c==\'1L\'){$.o[\'3G\'+c+\'1n\'].1N($.o,[p].3H(d))}N{7 b=($.1H.3I?$(p).3I():{});$.o.2Q(p,$.1q(b,c))}}})};$.o=F 1n()})(5f);',62,326,'|||||||var|||||||||||||||||timeEntry|this|if|function||_get|return|null|input|_field|data||case|false|break|_ampmField|_selectedHour|new|length||Math|Date|browser|true||else|px|_lastInput|parseInt|_adjustField||val|left|_secondField|_changeField|_timer|_disabledInputs|ampmNames||||_selectedMinute|_selectedSecond|span||bind||_setTime|_showField|_getSpinnerTarget|show24Hours|separator|markerClassName|_parseTime|toLowerCase|typeof|_extractTime|_blurredInput|target|max|_getInput|TimeEntry|ampmPrefix|spinnerSize|extend|options|_isDisabledTimeEntry|document|scrollLeft|css|position|top|_constrainTime|substring|_determineTime|_defaults|showSeconds|spinnerBigSize|extendRemove|class|setTimeout|fn|_endSpinner|nodeName|_changeSpinner|string|_focussed|apply|for|createTextRange|offset|_setValue|abs|_expanded|_handlingSpinner|scrollTop|curTop|_lastChr|getHours|getMinutes||getSeconds|_formatNumber|||_normaliseTime|regional|timeSteps|spinnerRepeat|background|width|focus|_doFocus|msie|mousewheel|_handleSpinner|mouseup|mouseout|_describeSpinner|_enableDisable|nextSibling|getTime|60|documentElement|offsetLeft|character|keyCode|switch|safari|each|0px|_getSpinnerRegion|_actionSpinner|_repeatSpinner|_releaseSpinner|while|_showTime|isNaN|spinnerTexts|field|appendText|initialField|useMouseWheel|defaultTime|minTime|maxTime|spinnerImage|spinnerBigImage|spinnerIncDecOnly|beforeShow|beforeSetTime|prototype|_connectTimeEntry|hasClass|style|url|no|repeat|height|mozilla|padding|after|_doBlur|_doClick|_doKeyDown|_doKeyPress|_doMouseWheel||||||mousedown|_expandSpinner|mousemove|disabled|map|inArray|_getTimeTimeEntry|1000|selectionStart|srcElement|clientX|moveEnd|ctrlKey|charCode|_handleKeyPress|opera|parents|absolute|div|_endExpand|one|_findPos|_findScroll|body|99|min|offsetParent|offsetTop|indexOf|setSelectionRange|exec|getDate|_|concat|metadata|AM|PM|Now|Previous|Next|Increment|Decrement|spinnerDefault|png|500|250|hasTimeEntry|setDefaults|spinnerText|timeEntry_control|display|inline||block|version|bottom|wrap|timeEntry_wrap||timeEntry_append||addClass|blur|click|keydown|keypress|paste|mouseover|_enableTimeEntry|_disableTimeEntry|push|_changeTimeEntry|_destroyTimeEntry|removeClass|unbind|unmousewheel|parent|replaceWith|removeData|_setTimeTimeEntry|object|_getOffsetTimeEntry|3600|thin|medium|thick|border|collapse|boundingWidth|shiftKey|String|fromCharCode|undefined|preventDefault|relative|timeEntry_expand|transparent|index|insertAfter|siblings|title|clearTimeout|remove|clientY|fixed|parentNode|split|round|is|hidden|moveStart|select|trigger|change|setFullYear|1900|setMonth|setDate|setTime|test|number|in|getOffset||isDisabled|Array|slice|call|arguments|jQuery'.split('|'),0,{})) \ No newline at end of file +/* jshint ignore:start */ +(function($){function TimeEntry(){this._disabledInputs=[];this.regional=[];this.regional['']={show24Hours:false,separator:':',ampmPrefix:'',ampmNames:['AM','PM'],spinnerTexts:['Now','Previous field','Next field','Increment','Decrement']};this._defaults={appendText:'',showSeconds:false,timeSteps:[1,1,1],initialField:0,noSeparatorEntry:false,useMouseWheel:true,defaultTime:null,minTime:null,maxTime:null,spinnerImage:'spinnerDefault.png',spinnerSize:[20,20,8],spinnerBigImage:'',spinnerBigSize:[40,40,16],spinnerIncDecOnly:false,spinnerRepeat:[500,250],beforeShow:null,beforeSetTime:null};$.extend(this._defaults,this.regional[''])}$.extend(TimeEntry.prototype,{markerClassName:'hasTimeEntry',propertyName:'timeEntry',_appendClass:'timeEntry_append',_controlClass:'timeEntry_control',_expandClass:'timeEntry_expand',setDefaults:function(a){$.extend(this._defaults,a||{});return this},_attachPlugin:function(b,c){var d=$(b);if(d.hasClass(this.markerClassName)){return}var e={options:$.extend({},this._defaults,c),input:d,_field:0,_selectedHour:0,_selectedMinute:0,_selectedSecond:0};d.data(this.propertyName,e).addClass(this.markerClassName).bind('focus.'+this.propertyName,this._doFocus).bind('blur.'+this.propertyName,this._doBlur).bind('click.'+this.propertyName,this._doClick).bind('keydown.'+this.propertyName,this._doKeyDown).bind('keypress.'+this.propertyName,this._doKeyPress).bind('paste.'+this.propertyName,function(a){setTimeout(function(){n._parseTime(e)},1)});this._optionPlugin(b,c)},_optionPlugin:function(a,b,c){a=$(a);var d=a.data(this.propertyName);if(!b||(typeof b=='string'&&c==null)){var e=b;b=(d||{}).options;return(b&&e?b[e]:b)}if(!a.hasClass(this.markerClassName)){return}b=b||{};if(typeof b=='string'){var e=b;b={};b[e]=c}var f=this._extractTime(d);$.extend(d.options,b);d._field=0;if(f){this._setTime(d,new Date(0,0,0,f[0],f[1],f[2]))}a.next('span.'+this._appendClass).remove();a.parent().find('span.'+this._controlClass).remove();if($.fn.mousewheel){a.unmousewheel()}var g=(!d.options.spinnerImage?null:$(''));a.after(d.options.appendText?''+d.options.appendText+'':'').after(g||'');if(d.options.useMouseWheel&&$.fn.mousewheel){a.mousewheel(this._doMouseWheel)}if(g){g.mousedown(this._handleSpinner).mouseup(this._endSpinner).mouseover(this._expandSpinner).mouseout(this._endSpinner).mousemove(this._describeSpinner)}},_enablePlugin:function(a){this._enableDisable(a,false)},_disablePlugin:function(a){this._enableDisable(a,true)},_enableDisable:function(b,c){var d=$.data(b,this.propertyName);if(!d){return}b.disabled=c;if(b.nextSibling&&b.nextSibling.nodeName.toLowerCase()=='span'){n._changeSpinner(d,b.nextSibling,(c?5:-1))}n._disabledInputs=$.map(n._disabledInputs,function(a){return(a==b?null:a)});if(c){n._disabledInputs.push(b)}},_isDisabledPlugin:function(a){return $.inArray(a,this._disabledInputs)>-1},_destroyPlugin:function(b){b=$(b);if(!b.hasClass(this.markerClassName)){return}b.removeClass(this.markerClassName).removeData(this.propertyName).unbind('.'+this.propertyName);if($.fn.mousewheel){b.unmousewheel()}this._disabledInputs=$.map(this._disabledInputs,function(a){return(a==b[0]?null:a)});b.siblings('.'+this._appendClass+',.'+this._controlClass).remove()},_setTimePlugin:function(a,b){var c=$.data(a,this.propertyName);if(c){if(b===null||b===''){c.input.val('')}else{this._setTime(c,b?(typeof b=='object'?new Date(b.getTime()):b):null)}}},_getTimePlugin:function(a){var b=$.data(a,this.propertyName);var c=(b?this._extractTime(b):null);return(!c?null:new Date(0,0,0,c[0],c[1],c[2]))},_getOffsetPlugin:function(a){var b=$.data(a,this.propertyName);var c=(b?this._extractTime(b):null);return(!c?0:(c[0]*3600+c[1]*60+c[2])*1000)},_doFocus:function(a){var b=(a.nodeName&&a.nodeName.toLowerCase()=='input'?a:this);if(n._lastInput==b||n._isDisabledPlugin(b)){n._focussed=false;return}var c=$.data(b,n.propertyName);n._focussed=true;n._lastInput=b;n._blurredInput=null;$.extend(c.options,($.isFunction(c.options.beforeShow)?c.options.beforeShow.apply(b,[b]):{}));n._parseTime(c);setTimeout(function(){n._showField(c)},10)},_doBlur:function(a){n._blurredInput=n._lastInput;n._lastInput=null},_doClick:function(b){var c=b.target;var d=$.data(c,n.propertyName);var e=d._field;if(!n._focussed){var f=d.options.separator.length+2;d._field=0;if(c.selectionStart!=null){for(var g=0;g<=Math.max(1,d._secondField,d._ampmField);g++){var h=(g!=d._ampmField?(g*f)+2:(d._ampmField*f)+d.options.ampmPrefix.length+d.options.ampmNames[0].length);d._field=g;if(c.selectionStart=48){return true}var b=$.data(a.target,n.propertyName);switch(a.keyCode){case 9:return(a.shiftKey?n._changeField(b,-1,true):n._changeField(b,+1,true));case 35:if(a.ctrlKey){n._setValue(b,'')}else{b._field=Math.max(1,b._secondField,b._ampmField);n._adjustField(b,0)}break;case 36:if(a.ctrlKey){n._setTime(b)}else{b._field=0;n._adjustField(b,0)}break;case 37:n._changeField(b,-1,false);break;case 38:n._adjustField(b,+1);break;case 39:n._changeField(b,+1,false);break;case 40:n._adjustField(b,-1);break;case 46:n._setValue(b,'');break;default:return true}return false},_doKeyPress:function(a){var b=String.fromCharCode(a.charCode==undefined?a.keyCode:a.charCode);if(b<' '){return true}var c=$.data(a.target,n.propertyName);n._handleKeyPress(c,b);return false},_doMouseWheel:function(a,b){if(n._isDisabledPlugin(a.target)){return}var c=$.data(a.target,n.propertyName);c.input.focus();if(!c.input.val()){n._parseTime(c)}n._adjustField(c,b);a.preventDefault()},_expandSpinner:function(b){var c=n._getSpinnerTarget(b);var d=$.data(n._getInput(c),n.propertyName);if(n._isDisabledPlugin(d.input[0])){return}if(d.options.spinnerBigImage){d._expanded=true;var e=$(c).offset();var f=null;$(c).parents().each(function(){var a=$(this);if(a.css('position')=='relative'||a.css('position')=='absolute'){f=a.offset()}return!f});$('
').mousedown(n._handleSpinner).mouseup(n._endSpinner).mouseout(n._endExpand).mousemove(n._describeSpinner).insertAfter(c)}},_getInput:function(a){return $(a).siblings('.'+n.markerClassName)[0]},_describeSpinner:function(a){var b=n._getSpinnerTarget(a);var c=$.data(n._getInput(b),n.propertyName);b.title=c.options.spinnerTexts[n._getSpinnerRegion(c,a)]},_handleSpinner:function(a){var b=n._getSpinnerTarget(a);var c=n._getInput(b);if(n._isDisabledPlugin(c)){return}if(c==n._blurredInput){n._lastInput=c;n._blurredInput=null}var d=$.data(c,n.propertyName);n._doFocus(c);var e=n._getSpinnerRegion(d,a);n._changeSpinner(d,b,e);n._actionSpinner(d,e);n._timer=null;n._handlingSpinner=true;if(e>=3&&d.options.spinnerRepeat[0]){n._timer=setTimeout(function(){n._repeatSpinner(d,e)},d.options.spinnerRepeat[0]);$(b).one('mouseout',n._releaseSpinner).one('mouseup',n._releaseSpinner)}},_actionSpinner:function(a,b){if(!a.input.val()){n._parseTime(a)}switch(b){case 0:this._setTime(a);break;case 1:this._changeField(a,-1,false);break;case 2:this._changeField(a,+1,false);break;case 3:this._adjustField(a,+1);break;case 4:this._adjustField(a,-1);break}},_repeatSpinner:function(a,b){if(!n._timer){return}n._lastInput=n._blurredInput;this._actionSpinner(a,b);this._timer=setTimeout(function(){n._repeatSpinner(a,b)},a.options.spinnerRepeat[1])},_releaseSpinner:function(a){clearTimeout(n._timer);n._timer=null},_endExpand:function(a){n._timer=null;var b=n._getSpinnerTarget(a);var c=n._getInput(b);var d=$.data(c,n.propertyName);$(b).remove();d._expanded=false},_endSpinner:function(a){n._timer=null;var b=n._getSpinnerTarget(a);var c=n._getInput(b);var d=$.data(c,n.propertyName);if(!n._isDisabledPlugin(c)){n._changeSpinner(d,b,-1)}if(n._handlingSpinner){n._lastInput=n._blurredInput}if(n._lastInput&&n._handlingSpinner){n._showField(d)}n._handlingSpinner=false},_getSpinnerTarget:function(a){return a.target||a.srcElement},_getSpinnerRegion:function(a,b){var c=this._getSpinnerTarget(b);var d=$(c).offset();var e=[document.documentElement.scrollLeft||document.body.scrollLeft,document.documentElement.scrollTop||document.body.scrollTop];var f=(a.options.spinnerIncDecOnly?99:b.clientX+e[0]-d.left);var g=b.clientY+e[1]-d.top;var h=a.options[a._expanded?'spinnerBigSize':'spinnerSize'];var i=(a.options.spinnerIncDecOnly?99:h[0]-1-f);var j=h[1]-1-g;if(h[2]>0&&Math.abs(f-i)<=h[2]&&Math.abs(g-j)<=h[2]){return 0}var k=Math.min(f,g,i,j);return(k==f?1:(k==i?2:(k==g?3:4)))},_changeSpinner:function(a,b,c){$(b).css('background-position','-'+((c+1)*a.options[a._expanded?'spinnerBigSize':'spinnerSize'][0])+'px 0px')},_parseTime:function(a){var b=this._extractTime(a);if(b){a._selectedHour=b[0];a._selectedMinute=b[1];a._selectedSecond=b[2]}else{var c=this._constrainTime(a);a._selectedHour=c[0];a._selectedMinute=c[1];a._selectedSecond=(a.options.showSeconds?c[2]:0)}a._secondField=(a.options.showSeconds?2:-1);a._ampmField=(a.options.show24Hours?-1:(a.options.showSeconds?3:2));a._lastChr='';a._field=Math.max(0,Math.min(Math.max(1,a._secondField,a._ampmField),a.options.initialField));if(a.input.val()!=''){this._showTime(a)}},_extractTime:function(a,b){b=b||a.input.val();var c=b.split(a.options.separator);if(a.options.separator==''&&b!=''){c[0]=b.substring(0,2);c[1]=b.substring(2,4);c[2]=b.substring(4,6)}if(c.length>=2){var d=!a.options.show24Hours&&(b.indexOf(a.options.ampmNames[0])>-1);var e=!a.options.show24Hours&&(b.indexOf(a.options.ampmNames[1])>-1);var f=parseInt(c[0],10);f=(isNaN(f)?0:f);f=((d||e)&&f==12?0:f)+(e?12:0);var g=parseInt(c[1],10);g=(isNaN(g)?0:g);var h=(c.length>=3?parseInt(c[2],10):0);h=(isNaN(h)||!a.options.showSeconds?0:h);return this._constrainTime(a,[f,g,h])}return null},_constrainTime:function(a,b){var c=(b!=null);if(!c){var d=this._determineTime(a.options.defaultTime,a)||new Date();b=[d.getHours(),d.getMinutes(),d.getSeconds()]}var e=false;for(var i=0;i1){b[i]=Math.round(b[i]/a.options.timeSteps[i])*a.options.timeSteps[i];e=true}}return b},_showTime:function(a){var b=(this._formatNumber(a.options.show24Hours?a._selectedHour:((a._selectedHour+11)%12)+1)+a.options.separator+this._formatNumber(a._selectedMinute)+(a.options.showSeconds?a.options.separator+this._formatNumber(a._selectedSecond):'')+(a.options.show24Hours?'':a.options.ampmPrefix+a.options.ampmNames[(a._selectedHour<12?0:1)]));this._setValue(a,b);this._showField(a)},_showField:function(a){var b=a.input[0];if(a.input.is(':hidden')||n._lastInput!=b){return}var c=a.options.separator.length+2;var d=(a._field!=a._ampmField?(a._field*c):(a._ampmField*c)-a.options.separator.length+a.options.ampmPrefix.length);var e=d+(a._field!=a._ampmField?2:a.options.ampmNames[0].length);if(b.setSelectionRange){b.setSelectionRange(d,e)}else if(b.createTextRange){var f=b.createTextRange();f.moveStart('character',d);f.moveEnd('character',e-a.input.val().length);f.select()}if(!b.disabled){b.focus()}},_formatNumber:function(a){return(a<10?'0':'')+a},_setValue:function(a,b){if(b!=a.input.val()){a.input.val(b).trigger('change')}},_changeField:function(a,b,c){var d=(a.input.val()==''||a._field==(b==-1?0:Math.max(1,a._secondField,a._ampmField)));if(!d){a._field+=b}this._showField(a);a._lastChr='';return(d&&c)},_adjustField:function(a,b){if(a.input.val()==''){b=0}this._setTime(a,new Date(0,0,0,a._selectedHour+(a._field==0?b*a.options.timeSteps[0]:0)+(a._field==a._ampmField?b*12:0),a._selectedMinute+(a._field==1?b*a.options.timeSteps[1]:0),a._selectedSecond+(a._field==a._secondField?b*a.options.timeSteps[2]:0)))},_setTime:function(a,b){b=this._determineTime(b,a);var c=this._constrainTime(a,b?[b.getHours(),b.getMinutes(),b.getSeconds()]:null);b=new Date(0,0,0,c[0],c[1],c[2]);var b=this._normaliseTime(b);var d=this._normaliseTime(this._determineTime(a.options.minTime,a));var e=this._normaliseTime(this._determineTime(a.options.maxTime,a));if(d&&e&&d>e){if(be){b=(Math.abs(b-d)e?e:b))}if($.isFunction(a.options.beforeSetTime)){b=a.options.beforeSetTime.apply(a.input[0],[this._getTimePlugin(a.input[0]),b,d,e])}a._selectedHour=b.getHours();a._selectedMinute=b.getMinutes();a._selectedSecond=b.getSeconds();this._showTime(a)},_determineTime:function(i,j){var k=function(a){var b=new Date();b.setTime(b.getTime()+a*1000);return b};var l=function(a){var b=n._extractTime(j,a);var c=new Date();var d=(b?b[0]:c.getHours());var e=(b?b[1]:c.getMinutes());var f=(b?b[2]:c.getSeconds());if(!b){var g=/([+-]?[0-9]+)\s*(s|S|m|M|h|H)?/g;var h=g.exec(a);while(h){switch(h[2]||'s'){case's':case'S':f+=parseInt(h[1],10);break;case'm':case'M':e+=parseInt(h[1],10);break;case'h':case'H':d+=parseInt(h[1],10);break}h=g.exec(a)}}c=new Date(0,0,10,d,e,f,0);if(/^!/.test(a)){if(c.getDate()>10){c=new Date(0,0,10,23,59,59)}else if(c.getDate()<10){c=new Date(0,0,10,0,0,0)}}return c};return(i?(typeof i=='string'?l(i):(typeof i=='number'?k(i):i)):null)},_normaliseTime:function(a){if(!a){return null}a.setFullYear(1900);a.setMonth(0);a.setDate(0);return a},_handleKeyPress:function(a,b){if(b==a.options.separator){this._changeField(a,+1,false)}else if(b>='0'&&b<='9'){var c=parseInt(b,10);var d=parseInt(a._lastChr+b,10);var e=(a._field!=0?a._selectedHour:(a.options.show24Hours?(d<24?d:c):(d>=1&&d<=12?d:(c>0?c:a._selectedHour))%12+(a._selectedHour>=12?12:0)));var f=(a._field!=1?a._selectedMinute:(d<60?d:c));var g=(a._field!=a._secondField?a._selectedSecond:(d<60?d:c));var h=this._constrainTime(a,[e,f,g]);this._setTime(a,new Date(0,0,0,h[0],h[1],h[2]));if(a.options.noSeparatorEntry&&a._lastChr){this._changeField(a,+1,false)}else{a._lastChr=b}}else if(!a.options.show24Hours){b=b.toLowerCase();if((b==a.options.ampmNames[0].substring(0,1).toLowerCase()&&a._selectedHour>=12)||(b==a.options.ampmNames[1].substring(0,1).toLowerCase()&&a._selectedHour<12)){var i=a._field;a._field=a._ampmField;this._adjustField(a,+1);a._field=i;this._showField(a)}}}});var m=['getOffset','getTime','isDisabled'];function isNotChained(a,b){if(a=='option'&&(b.length==0||(b.length==1&&typeof b[0]=='string'))){return true}return $.inArray(a,m)>-1}$.fn.timeEntry=function(b){var c=Array.prototype.slice.call(arguments,1);if(isNotChained(b,c)){return n['_'+b+'Plugin'].apply(n,[this[0]].concat(c))}return this.each(function(){if(typeof b=='string'){if(!n['_'+b+'Plugin']){throw'Unknown command: '+b;}n['_'+b+'Plugin'].apply(n,[this].concat(c))}else{var a=($.fn.metadata?$(this).metadata():{});n._attachPlugin(this,$.extend({},a,b||{}))}})};var n=$.timeEntry=new TimeEntry()})(jQuery); +/* jshint ignore:end */ \ No newline at end of file diff --git a/sites/all/modules/contrib/fields/date/date_repeat.inc b/sites/all/modules/contrib/fields/date/date_repeat.inc index 2df03dc8..046d8aee 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat.inc +++ b/sites/all/modules/contrib/fields/date/date_repeat.inc @@ -2,5 +2,6 @@ /** * @file * Empty file to avoid fatal error if it doesn't exist. + * * Formerly the Date Repeat field code. - */ \ No newline at end of file + */ diff --git a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.info b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.info index 695a2fd9..b6afcd47 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.info +++ b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.info @@ -7,9 +7,9 @@ php = 5.2 files[] = tests/date_repeat.test files[] = tests/date_repeat_form.test -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.install b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.install index 65c3adbb..52039630 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.install +++ b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.install @@ -12,21 +12,3 @@ function date_repeat_install() { // Make sure this module loads after date_api. db_query("UPDATE {system} SET weight = 1 WHERE name = 'date_repeat'"); } - -/** - * Implements hook_uninstall(). - */ -function date_repeat_uninstall() { -} - -/** - * Implements hook_enable(). - */ -function date_repeat_enable() { -} - -/** - * Implements hook_disable(). - */ -function date_repeat_disable() { -} diff --git a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.module b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.module index d742dc88..61d971ba 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.module +++ b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat.module @@ -1,7 +1,6 @@ array('render element' => 'element'), @@ -55,6 +57,9 @@ function date_repeat_freq_options() { ); } +/** + * Helper function for interval options. + */ function date_repeat_interval_options() { $options = range(0, 366); unset($options[0]); @@ -92,9 +97,11 @@ function date_repeat_dow_day_options_abbr($translated = TRUE, $length = 3) { case 1: $context = 'day_abbr1'; break; + case 2: $context = 'day_abbr2'; break; + default: $context = ''; break; @@ -105,16 +112,28 @@ function date_repeat_dow_day_options_abbr($translated = TRUE, $length = 3) { return $return; } +/** + * Helper function for weekdays translated. + */ function date_repeat_dow_day_untranslated() { static $date_repeat_weekdays; if (empty($date_repeat_weekdays)) { - $date_repeat_weekdays = array('SU' => 'Sunday', 'MO' => 'Monday', 'TU' => 'Tuesday', - 'WE' => 'Wednesday', 'TH' => 'Thursday', 'FR' => 'Friday', - 'SA' => 'Saturday'); + $date_repeat_weekdays = array( + 'SU' => 'Sunday', + 'MO' => 'Monday', + 'TU' => 'Tuesday', + 'WE' => 'Wednesday', + 'TH' => 'Thursday', + 'FR' => 'Friday', + 'SA' => 'Saturday' + ); } return $date_repeat_weekdays; } +/** + * Helper function for weekdays order. + */ function date_repeat_dow_day_options_ordered($weekdays) { $day_keys = array_keys($weekdays); $day_values = array_values($weekdays); @@ -164,8 +183,7 @@ function date_repeat_dow2day($dow) { } /** - * Shift the array of iCal day names into the right order - * for a specific week start day. + * Shift the array of iCal day names into the right order for a specific week start day. */ function date_repeat_days_ordered($week_start_day) { $days = array_flip(array_keys(date_repeat_dow_day_options(FALSE))); @@ -212,18 +230,21 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') { '!except' => '', '!additional' => '', '!week_starts_on' => '', - ); + ); $interval = date_repeat_interval_options(); switch ($rrule['FREQ']) { case 'WEEKLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every week', 'every @count weeks') . ' '; break; + case 'MONTHLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every month', 'every @count months') . ' '; break; + case 'YEARLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every year', 'every @count years') . ' '; break; + default: $description['!interval'] = format_plural($rrule['INTERVAL'], 'every day', 'every @count days') . ' '; break; @@ -240,26 +261,41 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') { if (!empty($count)) { // See if there is a 'pretty' option for this count, i.e. +1 => First. $order = array_key_exists($count, $counts) ? strtolower($counts[$count]) : $count; - $results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week', array('!repeats_every_interval ' => '', '!date_order' => $order, '!day_of_week' => $days[$day]))); + $results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week', + array( + '!repeats_every_interval ' => '', + '!date_order' => $order, + '!day_of_week' => $days[$day] + ))); } else { - $results[] = trim(t('!repeats_every_interval every !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day]))); + $results[] = trim(t('!repeats_every_interval every !day_of_week', + array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day]))); } } $description['!byday'] = implode(' ' . t('and') . ' ', $results); } if (!empty($rrule['BYMONTH'])) { - if (sizeof($rrule['BYMONTH']) < 12) { + if (count($rrule['BYMONTH']) < 12) { $results = array(); $months = date_month_names(); foreach ($rrule['BYMONTH'] as $month) { $results[] = $months[$month]; } if (!empty($rrule['BYMONTHDAY'])) { - $description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names', array('!repeats_every_interval ' => '', '!month_days' => implode(', ', $rrule['BYMONTHDAY']), '!month_names' => implode(', ', $results)))); + $description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names', + array( + '!repeats_every_interval ' => '', + '!month_days' => implode(', ', $rrule['BYMONTHDAY']), + '!month_names' => implode(', ', $results) + ))); } else { - $description['!bymonth'] = trim(t('!repeats_every_interval on !month_names', array('!repeats_every_interval ' => '', '!month_names' => implode(', ', $results)))); + $description['!bymonth'] = trim(t('!repeats_every_interval on !month_names', + array( + '!repeats_every_interval ' => '', + '!month_names' => implode(', ', $results) + ))); } } } @@ -267,12 +303,17 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') { $rrule['INTERVAL'] = 1; } if (!empty($rrule['COUNT'])) { - $description['!count'] = trim(t('!repeats_every_interval !count times', array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT']))); + $description['!count'] = trim(t('!repeats_every_interval !count times', + array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT']))); } if (!empty($rrule['UNTIL'])) { $until = date_ical_date($rrule['UNTIL'], 'UTC'); date_timezone_set($until, date_default_timezone_object()); - $description['!until'] = trim(t('!repeats_every_interval until !until_date', array('!repeats_every_interval ' => '', '!until_date' => date_format_date($until, 'custom', $format)))); + $description['!until'] = trim(t('!repeats_every_interval until !until_date', + array( + '!repeats_every_interval ' => '', + '!until_date' => date_format_date($until, 'custom', $format) + ))); } if ($exceptions) { $values = array(); @@ -281,11 +322,16 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') { date_timezone_set($except, date_default_timezone_object()); $values[] = date_format_date($except, 'custom', $format); } - $description['!except'] = trim(t('!repeats_every_interval except !except_dates', array('!repeats_every_interval ' => '', '!except_dates' => implode(', ', $values)))); + $description['!except'] = trim(t('!repeats_every_interval except !except_dates', + array( + '!repeats_every_interval ' => '', + '!except_dates' => implode(', ', $values) + ))); } if (!empty($rrule['WKST'])) { $day_names = date_repeat_dow_day_options(); - $description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])]))); + $description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week', + array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])]))); } if ($additions) { $values = array(); @@ -294,9 +340,15 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') { date_timezone_set($add, date_default_timezone_object()); $values[] = date_format_date($add, 'custom', $format); } - $description['!additional'] = trim(t('Also includes !additional_dates.', array('!additional_dates' => implode(', ', $values)))); + $description['!additional'] = trim(t('Also includes !additional_dates.', + array('!additional_dates' => implode(', ', $values)))); } - return t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description); + $output = t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description); + // Removes double whitespaces from Repeat tile. + $output = preg_replace('/\s+/', ' ', $output); + // Removes whitespace before full stop ".", at the end of the title. + $output = str_replace(' .', '.', $output); + return $output; } /** @@ -310,17 +362,17 @@ function date_repeat_split_rrule($rrule) { $additions = array(); foreach ($parts as $part) { if (strstr($part, 'RRULE')) { - $RRULE = str_replace('RRULE:', '', $part); - $rrule = (array) date_ical_parse_rrule('RRULE:', $RRULE); + $cleanded_part = str_replace('RRULE:', '', $part); + $rrule = (array) date_ical_parse_rrule('RRULE:', $cleanded_part); } elseif (strstr($part, 'EXDATE')) { - $EXDATE = str_replace('EXDATE:', '', $part); - $exceptions = (array) date_ical_parse_exceptions('EXDATE:', $EXDATE); + $exdate = str_replace('EXDATE:', '', $part); + $exceptions = (array) date_ical_parse_exceptions('EXDATE:', $exdate); unset($exceptions['DATA']); } elseif (strstr($part, 'RDATE')) { - $RDATE = str_replace('RDATE:', '', $part); - $additions = (array) date_ical_parse_exceptions('RDATE:', $RDATE); + $rdate = str_replace('RDATE:', '', $part); + $additions = (array) date_ical_parse_exceptions('RDATE:', $rdate); unset($additions['DATA']); } } @@ -372,7 +424,7 @@ function date_repeat_form_element_radios_process($element) { '#title_display' => 'invisible', '#return_value' => $key, '#default_value' => isset($element['#default_value']) ? - $element['#default_value'] : NULL, + $element['#default_value'] : NULL, '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)), diff --git a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_calc.inc b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_calc.inc index 4ff3c4a5..d840df62 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_calc.inc +++ b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_calc.inc @@ -53,9 +53,11 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi // Create a date object for the start and end dates. $start_date = new DateObject($start, $timezone); - // Versions of PHP greater than PHP 5.3.5 require that we set an explicit time when - // using date_modify() or the time may not match the original value. Adding this - // modifier gives us the same results in both older and newer versions of PHP. + // Versions of PHP greater than PHP 5.3.5 require + // that we set an explicit time when using date_modify() + // or the time may not match the original value. + // Adding this modifier gives us the same results in both older + // and newer versions of PHP. $modify_time = ' ' . $start_date->format('g:ia'); // If the rule has an UNTIL, see if that is earlier than the end date. @@ -91,27 +93,32 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi } // Make sure DAILY frequency isn't used in places it won't work; - if (!empty($rrule['BYMONTHDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) { + if (!empty($rrule['BYMONTHDAY']) && + !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) { $rrule['FREQ'] = 'MONTHLY'; } - elseif (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) { + elseif (!empty($rrule['BYDAY']) + && !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) { $rrule['FREQ'] = 'WEEKLY'; - } + } // Find the time period to jump forward between dates. switch ($rrule['FREQ']) { - case 'DAILY': - $jump = $interval . ' days'; - break; - case 'WEEKLY': - $jump = $interval . ' weeks'; - break; - case 'MONTHLY': - $jump = $interval . ' months'; - break; - case 'YEARLY': - $jump = $interval . ' years'; - break; + case 'DAILY': + $jump = $interval . ' days'; + break; + + case 'WEEKLY': + $jump = $interval . ' weeks'; + break; + + case 'MONTHLY': + $jump = $interval . ' months'; + break; + + case 'YEARLY': + $jump = $interval . ' years'; + break; } $rrule = date_repeat_adjust_rrule($rrule, $start_date); @@ -135,7 +142,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi $direction_days[$day] = array( 'direction' => !empty($regs[1]) ? $regs[1] : '+', 'direction_count' => $regs[2], - ); + ); } } while (!$finished) { @@ -198,8 +205,9 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi else { - // More complex searches for day names and criteria like '-1SU' or '2TU,2TH', - // require that we interate through the whole time period checking each BYDAY. + // More complex searches for day names and criteria + // like '-1SU' or '2TU,2TH', require that we interate through + // the whole time period checking each BYDAY. // Create helper array to pull day names out of iCal day strings. $day_names = date_repeat_dow_day_options(FALSE); @@ -303,7 +311,8 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi // period, then jumping ahead to the next week, month, or year, // an INTERVAL at a time. - if (!empty($week_days) && in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) { + if (!empty($week_days) && + in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) { $finished = FALSE; $current_day = clone($start_date); $format = $rrule['FREQ'] == 'YEARLY' ? 'Y' : 'n'; @@ -322,8 +331,9 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi $moved = FALSE; foreach ($week_days as $delta => $day) { // Find the next occurence of each day in this week, only add it - // if we are still in the current month or year. The date_repeat_add_dates - // function is insufficient to test whether to include this date + // if we are still in the current month or year. + // The date_repeat_add_dates function is insufficient + // to test whether to include this date // if we are using a rule like 'every other month', so we must // explicitly test it here. @@ -370,10 +380,12 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi date_modify($current_day, '+1 ' . $week_start_day . $modify_time); date_modify($current_day, '-1 week' . $modify_time); break; + case 'MONTHLY': date_modify($current_day, '-' . (date_format($current_day, 'j') - 1) . ' days' . $modify_time); date_modify($current_day, '-1 month' . $modify_time); break; + case 'YEARLY': date_modify($current_day, '-' . date_format($current_day, 'z') . ' days' . $modify_time); date_modify($current_day, '-1 year' . $modify_time); @@ -387,7 +399,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi } } - // add additional dates + // Add additional dates. foreach ($additions as $addition) { $date = new dateObject($addition . ' ' . $start_date->format('H:i:s'), $timezone); $days[] = date_format($date, DATE_FORMAT_DATETIME); @@ -426,8 +438,8 @@ function date_repeat_adjust_rrule($rrule, $start_date) { // position rules make no sense in other periods and just add complexity. elseif (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) { - foreach ($rrule['BYDAY'] as $delta => $BYDAY) { - $rrule['BYDAY'][$delta] = substr($BYDAY, -2); + foreach ($rrule['BYDAY'] as $delta => $by_day) { + $rrule['BYDAY'][$delta] = substr($by_day, -2); } } @@ -442,7 +454,7 @@ function date_repeat_adjust_rrule($rrule, $start_date) { * and that it meets other criteria in the RRULE. */ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $exceptions, $rrule) { - if (isset($rrule['COUNT']) && sizeof($days) >= $rrule['COUNT']) { + if (isset($rrule['COUNT']) && count($days) >= $rrule['COUNT']) { return FALSE; } $formatted = date_format($current_day, DATE_FORMAT_DATETIME); @@ -456,13 +468,14 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex return FALSE; } if (!empty($rrule['BYDAY'])) { - $BYDAYS = $rrule['BYDAY']; - foreach ($BYDAYS as $delta => $BYDAY) { - $BYDAYS[$delta] = substr($BYDAY, -2); + $by_days = $rrule['BYDAY']; + foreach ($by_days as $delta => $by_day) { + $by_days[$delta] = substr($by_day, -2); } - if (!in_array(date_repeat_dow2day(date_format($current_day, 'w')), $BYDAYS)) { + if (!in_array(date_repeat_dow2day(date_format($current_day, 'w')), $by_days)) { return FALSE; - }} + } + } if (!empty($rrule['BYYEAR']) && !in_array(date_format($current_day, 'Y'), $rrule['BYYEAR'])) { return FALSE; } @@ -472,17 +485,17 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex if (!empty($rrule['BYMONTHDAY'])) { // Test month days, but only if there are no negative numbers. $test = TRUE; - $BYMONTHDAYS = array(); + $by_month_days = array(); foreach ($rrule['BYMONTHDAY'] as $day) { if ($day > 0) { - $BYMONTHDAYS[] = $day; + $by_month_days[] = $day; } else { $test = FALSE; break; } } - if ($test && !empty($BYMONTHDAYS) && !in_array(date_format($current_day, 'j'), $BYMONTHDAYS)) { + if ($test && !empty($by_month_days) && !in_array(date_format($current_day, 'j'), $by_month_days)) { return FALSE; } } @@ -499,7 +512,7 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex * Stop when $current_day is greater than $end_date or $count is reached. */ function date_repeat_is_finished($current_day, $days, $count, $end_date) { - if (($count && sizeof($days) >= $count) + if (($count && count($days) >= $count) || (!empty($end_date) && date_format($current_day, 'U') > date_format($end_date, 'U'))) { return TRUE; } @@ -517,7 +530,7 @@ function date_repeat_is_finished($current_day, $days, $count, $end_date) { * If $day is empty, will set to the number of days from the * beginning or end of the month. */ -function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) { +function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time = '') { if (is_object($date_in)) { $current_month = date_format($date_in, 'n'); @@ -567,7 +580,7 @@ function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', * If $day is empty, will set to the number of days from the * beginning or end of the year. */ -function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) { +function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time = '') { if (is_object($date_in)) { $current_year = date_format($date_in, 'Y'); @@ -620,4 +633,4 @@ function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction } } return $date_in; -} \ No newline at end of file +} diff --git a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_form.inc b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_form.inc index db7a79bc..33525956 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_form.inc +++ b/sites/all/modules/contrib/fields/date/date_repeat/date_repeat_form.inc @@ -30,13 +30,16 @@ * BYSETPOS * Seldom used anywhere, so no reason to complicated the code. */ + /** * Generate the repeat setting form. */ function _date_repeat_rrule_process($element, &$form_state, $form) { - // If the RRULE field is not visible to the user, needs no processing or validation. - // The Date field module is not adding this element to forms if the field is hidden, + // If the RRULE field is not visible to the user, + // needs no processing or validation. + // The Date field module is not adding this element to forms + // if the field is hidden, // this test is just in case some other module attempts to do so. if (date_hidden_element($element)) { @@ -67,16 +70,16 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { $timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(); $merged_values = date_repeat_merge($rrule, $element); - $UNTIL = ''; + $until = ''; if (!empty($merged_values['UNTIL']['datetime'])) { $until_date = new DateObject($merged_values['UNTIL']['datetime'], $merged_values['UNTIL']['tz']); date_timezone_set($until_date, timezone_open($timezone)); - $UNTIL = date_format($until_date, DATE_FORMAT_DATETIME); + $until = date_format($until_date, DATE_FORMAT_DATETIME); } - $COUNT = ''; + $count = ''; if (!empty($merged_values['COUNT'])) { - $COUNT = $merged_values['COUNT']; + $count = $merged_values['COUNT']; } $element['FREQ'] = array( @@ -137,7 +140,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ); list($prefix, $suffix) = explode('@interval', t('Every @interval days', array(), array('context' => 'Date repeat'))); - $DAILY_INTERVAL = array( + $daily_interval = array( '#type' => 'textfield', '#title' => t('Repeats', array(), array('context' => 'Date repeat')), '#title_display' => 'invisible', @@ -210,32 +213,34 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { '#suffix' => '', ); - $DAILY_radios_default = 'INTERVAL'; + $daily_radios_default = 'INTERVAL'; if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'DAILY' && !empty($rrule['BYDAY'])) { switch (count($rrule['BYDAY'])) { case 2: - $DAILY_radios_default = 'every_tu_th'; + $daily_radios_default = 'every_tu_th'; break; + case 3: - $DAILY_radios_default = 'every_mo_we_fr'; + $daily_radios_default = 'every_mo_we_fr'; break; + case 5: - $DAILY_radios_default = 'every_weekday'; + $daily_radios_default = 'every_weekday'; break; } } - $DAILY_every_weekday = array( + $daily_every_weekday = array( '#type' => 'item', '#markup' => '
' . t('Every weekday', array(), array('context' => 'Date repeat')) . '
', ); - $DAILY_mo_we_fr = array( + $daily_mo_we_fr = array( '#type' => 'item', '#markup' => '
' . t('Every Mon, Wed, Fri', array(), array('context' => 'Date repeat')) . '
', ); - $DAILY_tu_th = array( + $daily_tu_th = array( '#type' => 'item', '#markup' => '
' . t('Every Tue, Thu', array(), array('context' => 'Date repeat')) . '
', ); @@ -251,17 +256,17 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'DAILY'), ), ), - '#default_value' => $DAILY_radios_default, + '#default_value' => $daily_radios_default, '#options' => array( 'INTERVAL' => t('interval'), 'every_weekday' => t('every weekday'), 'every_mo_we_fr' => t('monday wednesday friday'), 'every_tu_th' => t('tuesday thursday'), ), - 'INTERVAL_child' => $DAILY_INTERVAL, - 'every_weekday_child' => $DAILY_every_weekday, - 'mo_we_fr_child' => $DAILY_mo_we_fr, - 'tu_th_child' => $DAILY_tu_th, + 'INTERVAL_child' => $daily_interval, + 'every_weekday_child' => $daily_every_weekday, + 'mo_we_fr_child' => $daily_mo_we_fr, + 'tu_th_child' => $daily_tu_th, '#div_classes' => array( 'container-inline interval', 'container-inline weekday', @@ -270,18 +275,18 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ), ); - $MONTHLY_day_month_default = 'BYMONTHDAY_BYMONTH'; + $monthly_day_month_default = 'BYMONTHDAY_BYMONTH'; if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'MONTHLY' && !empty($rrule['BYDAY'])) { - $MONTHLY_day_month_default = 'BYDAY_BYMONTH'; + $monthly_day_month_default = 'BYDAY_BYMONTH'; } - $MONTHLY_on_day_BYMONTHDAY_of_BYMONTH = array( + $monthly_on_day_bymonthday_of_bymonth = array( '#type' => 'container', '#tree' => TRUE, ); list($bymonthday_title, $bymonthday_suffix) = explode('@bymonthday', t('On day @bymonthday of', array(), array('context' => 'Date repeat'))); - $MONTHLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTHDAY'] = array( + $monthly_on_day_bymonthday_of_bymonth['BYMONTHDAY'] = array( '#type' => 'select', '#title' => $bymonthday_title, '#default_value' => !empty($rrule['BYMONTHDAY']) && $rrule['FREQ'] === 'MONTHLY' ? $rrule['BYMONTHDAY'] : '', @@ -292,11 +297,11 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { '#field_suffix' => $bymonthday_suffix, ); - $MONTHLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTH'] = array( + $monthly_on_day_bymonthday_of_bymonth['BYMONTH'] = array( '#type' => 'checkboxes', '#title' => t('Bymonth', array(), array('context' => 'Date repeat')), '#title_display' => 'invisible', - '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $MONTHLY_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), + '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $monthly_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), '#options' => date_month_names_abbr(TRUE), '#attributes' => array('class' => array('container-inline')), '#multiple' => TRUE, @@ -304,45 +309,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { '#suffix' => '', ); - $MONTHLY_on_the_BYDAY_of_BYMONTH = array( + $monthly_on_the_byday_of_bymonth = array( '#type' => 'container', '#tree' => TRUE, ); - $MONTHLY_BYDAY_COUNT = ''; - $MONTHLY_BYDAY_DAY = ''; + $monthly_byday_count = ''; + $monthly_byday_day = ''; if (isset($rrule['BYDAY']) && !empty($rrule['BYDAY']) && $rrule['FREQ'] === 'MONTHLY') { - $MONTHLY_BYDAY_COUNT = substr($rrule['BYDAY'][0], 0, -2); - $MONTHLY_BYDAY_DAY = substr($rrule['BYDAY'][0], -2);; + $monthly_byday_count = substr($rrule['BYDAY'][0], 0, -2); + $monthly_byday_day = substr($rrule['BYDAY'][0], -2);; } list($byday_count_title, $byday_day_title) = explode('@byday', t('On the @byday of', array(), array('context' => 'Date repeat'))); - $MONTHLY_on_the_BYDAY_of_BYMONTH['BYDAY_COUNT'] = array( + $monthly_on_the_byday_of_bymonth['BYDAY_COUNT'] = array( '#type' => 'select', '#title' => $byday_count_title, - '#default_value' => !empty($MONTHLY_BYDAY_COUNT) ? $MONTHLY_BYDAY_COUNT : '', + '#default_value' => !empty($monthly_byday_count) ? $monthly_byday_count : '', '#options' => date_order_translated(), '#multiple' => FALSE, '#prefix' => '
', '#suffix' => '
', ); - $MONTHLY_on_the_BYDAY_of_BYMONTH['BYDAY_DAY'] = array( + $monthly_on_the_byday_of_bymonth['BYDAY_DAY'] = array( '#type' => 'select', '#title' => $byday_day_title, '#title_display' => 'after', - '#default_value' => !empty($MONTHLY_BYDAY_DAY) ? $MONTHLY_BYDAY_DAY : '', + '#default_value' => !empty($monthly_byday_day) ? $monthly_byday_day : '', '#options' => date_repeat_dow_day_options(TRUE), '#multiple' => FALSE, '#prefix' => '
', '#suffix' => '
', ); - $MONTHLY_on_the_BYDAY_of_BYMONTH['BYMONTH'] = array( + $monthly_on_the_byday_of_bymonth['BYMONTH'] = array( '#type' => 'checkboxes', '#title' => t('Bymonth', array(), array('context' => 'Date repeat')), '#title_display' => 'invisible', - '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $MONTHLY_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), + '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $monthly_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), '#options' => date_month_names_abbr(TRUE), '#attributes' => array('class' => array('container-inline')), '#multiple' => TRUE, @@ -361,31 +366,31 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ), ), '#attributes' => array('class' => array('date-repeat-radios clearfix')), - '#default_value' => $MONTHLY_day_month_default, + '#default_value' => $monthly_day_month_default, '#options' => array( 'BYMONTHDAY_BYMONTH' => t('On day ... of ...'), 'BYDAY_BYMONTH' => t('On the ... of ...'), ), - 'BYMONTHDAY_BYMONTH_child' => $MONTHLY_on_day_BYMONTHDAY_of_BYMONTH, - 'BYDAY_BYMONTH_child' => $MONTHLY_on_the_BYDAY_of_BYMONTH, + 'BYMONTHDAY_BYMONTH_child' => $monthly_on_day_bymonthday_of_bymonth, + 'BYDAY_BYMONTH_child' => $monthly_on_the_byday_of_bymonth, '#div_classes' => array( 'date-repeat-radios-item date-clear clearfix bymonthday-bymonth', 'date-repeat-radios-item date-clear clearfix byday-bymonth', ), ); - $YEARLY_day_month_default = 'BYMONTHDAY_BYMONTH'; + $yearly_day_month_default = 'BYMONTHDAY_BYMONTH'; if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'YEARLY' && !empty($rrule['BYDAY'])) { - $YEARLY_day_month_default = 'BYDAY_BYMONTH'; + $yearly_day_month_default = 'BYDAY_BYMONTH'; } - $YEARLY_on_day_BYMONTHDAY_of_BYMONTH = array( + $yearly_on_day_bymonthday_of_bymonth = array( '#type' => 'container', '#tree' => TRUE, ); list($bymonthday_title, $bymonthday_suffix) = explode('@bymonthday', t('On day @bymonthday of', array(), array('context' => 'Date repeat'))); - $YEARLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTHDAY'] = array( + $yearly_on_day_bymonthday_of_bymonth['BYMONTHDAY'] = array( '#type' => 'select', '#title' => $bymonthday_title, '#default_value' => !empty($rrule['BYMONTHDAY']) && $rrule['FREQ'] === 'YEARLY' ? $rrule['BYMONTHDAY'] : '', @@ -396,11 +401,11 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { '#field_suffix' => $bymonthday_suffix, ); - $YEARLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTH'] = array( + $yearly_on_day_bymonthday_of_bymonth['BYMONTH'] = array( '#type' => 'checkboxes', '#title' => t('Bymonth', array(), array('context' => 'Date repeat')), '#title_display' => 'invisible', - '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $YEARLY_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), + '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $yearly_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), '#options' => date_month_names_abbr(TRUE), '#attributes' => array('class' => array('container-inline')), '#multiple' => TRUE, @@ -408,45 +413,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { '#suffix' => '', ); - $YEARLY_on_the_BYDAY_of_BYMONTH = array( + $yearly_on_the_byday_of_bymonth = array( '#type' => 'container', '#tree' => TRUE, ); - $YEARLY_BYDAY_COUNT = ''; - $YEARLY_BYDAY_DAY = ''; + $yearly_byday_count = ''; + $yearly_byday_day = ''; if (isset($rrule['BYDAY']) && !empty($rrule['BYDAY']) && $rrule['FREQ'] === 'YEARLY') { - $YEARLY_BYDAY_COUNT = substr($rrule['BYDAY'][0], 0, -2); - $YEARLY_BYDAY_DAY = substr($rrule['BYDAY'][0], -2);; + $yearly_byday_count = substr($rrule['BYDAY'][0], 0, -2); + $yearly_byday_day = substr($rrule['BYDAY'][0], -2);; } list($byday_count_title, $byday_day_title) = explode('@byday', t('On the @byday of', array(), array('context' => 'Date repeat'))); - $YEARLY_on_the_BYDAY_of_BYMONTH['BYDAY_COUNT'] = array( + $yearly_on_the_byday_of_bymonth['BYDAY_COUNT'] = array( '#type' => 'select', '#title' => $byday_count_title, - '#default_value' => !empty($YEARLY_BYDAY_COUNT) ? $YEARLY_BYDAY_COUNT : '', + '#default_value' => !empty($yearly_byday_count) ? $yearly_byday_count : '', '#options' => date_order_translated(), '#multiple' => FALSE, '#prefix' => '
', '#suffix' => '
', ); - $YEARLY_on_the_BYDAY_of_BYMONTH['BYDAY_DAY'] = array( + $yearly_on_the_byday_of_bymonth['BYDAY_DAY'] = array( '#type' => 'select', '#title' => $byday_day_title, '#title_display' => 'after', - '#default_value' => !empty($YEARLY_BYDAY_DAY) ? $YEARLY_BYDAY_DAY : '', + '#default_value' => !empty($yearly_byday_day) ? $yearly_byday_day : '', '#options' => date_repeat_dow_day_options(TRUE), '#multiple' => FALSE, '#prefix' => '
', '#suffix' => '
', ); - $YEARLY_on_the_BYDAY_of_BYMONTH['BYMONTH'] = array( + $yearly_on_the_byday_of_bymonth['BYMONTH'] = array( '#type' => 'checkboxes', '#title' => t('Bymonth', array(), array('context' => 'Date repeat')), '#title_display' => 'invisible', - '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $YEARLY_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), + '#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $yearly_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(), '#options' => date_month_names_abbr(TRUE), '#attributes' => array('class' => array('container-inline')), '#multiple' => TRUE, @@ -465,13 +470,13 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ), ), '#attributes' => array('class' => array('date-repeat-radios clearfix')), - '#default_value' => $YEARLY_day_month_default, + '#default_value' => $yearly_day_month_default, '#options' => array( 'BYMONTHDAY_BYMONTH' => t('On day ... of ...'), 'BYDAY_BYMONTH' => t('On the ... of ...'), ), - 'BYMONTHDAY_BYMONTH_child' => $YEARLY_on_day_BYMONTHDAY_of_BYMONTH, - 'BYDAY_BYMONTH_child' => $YEARLY_on_the_BYDAY_of_BYMONTH, + 'BYMONTHDAY_BYMONTH_child' => $yearly_on_day_bymonthday_of_bymonth, + 'BYDAY_BYMONTH_child' => $yearly_on_the_byday_of_bymonth, '#div_classes' => array( 'date-repeat-radios-item date-clear clearfix bymonthday-bymonth', 'date-repeat-radios-item date-clear clearfix byday-bymonth', @@ -482,7 +487,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { $count_form_element = array( '#type' => 'textfield', '#title' => t('Count', array(), array('context' => 'Date repeat')), - '#default_value' => $COUNT, + '#default_value' => $count, '#element_validate' => array('element_validate_integer_positive'), '#attributes' => array('placeholder' => array('#')), '#prefix' => $prefix, @@ -499,21 +504,26 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { '#type' => $element['#date_repeat_widget'], '#title' => t('Until', array(), array('context' => 'Date repeat')), '#title_display' => 'invisible', - '#default_value' => $UNTIL, - '#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d', + '#default_value' => $until, + '#date_format' => !empty($element['#date_format']) ? + date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d', '#date_timezone' => $timezone, '#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(), '#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3', - '#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within', + '#date_label_position' => !empty($element['#date_label_position']) ? + $element['#date_label_position'] : 'within', '#date_flexible' => 0, ), 'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']), 'all_day' => array('#type' => 'hidden', '#value' => 1), - 'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))), + 'granularity' => array( + '#type' => 'hidden', + '#value' => serialize(array('year', 'month', 'day')), + ), ); $range_of_repeat_default = 'COUNT'; - if (!empty($UNTIL)) { + if (!empty($until)) { $range_of_repeat_default = 'UNTIL'; } $element['range_of_repeat'] = array( @@ -528,7 +538,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'NONE'), ), ), - '#default_value' => $range_of_repeat_default, + '#default_value' => $range_of_repeat_default, '#options' => array( 'COUNT' => t('Count'), 'UNTIL' => t('Until'), @@ -544,7 +554,8 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { $parents = $element['#array_parents']; $instance = implode('-', $parents); - // Make sure this will work right either in the normal form or in an ajax callback from the 'Add more' button. + // Make sure this will work right either in the normal + // form or in an ajax callback from the 'Add more' button. if (empty($form_state['num_exceptions'][$instance])) { $form_state['num_exceptions'][$instance] = count($exceptions); } @@ -576,33 +587,48 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ), ), ); - for ($i = 0; $i < max($form_state['num_exceptions'][$instance], 1) ; $i++) { - $EXCEPT = ''; + for ($i = 0; $i < max($form_state['num_exceptions'][$instance], 1); $i++) { + $except = ''; if (!empty($exceptions[$i]['datetime'])) { $ex_date = new DateObject($exceptions[$i]['datetime'], $exceptions[$i]['tz']); date_timezone_set($ex_date, timezone_open($timezone)); - $EXCEPT = date_format($ex_date, DATE_FORMAT_DATETIME); + $except = date_format($ex_date, DATE_FORMAT_DATETIME); + } + $date_format = 'Y-m-d'; + if (!empty($element['#date_format'])) { + $grans = array('year', 'month', 'day'); + $date_format = date_limit_format($element['#date_format'], $grans); } $element['exceptions']['EXDATE'][$i] = array( '#tree' => TRUE, 'datetime' => array( '#name' => 'exceptions|' . $instance, '#type' => $element['#date_repeat_widget'], - '#default_value' => $EXCEPT, - '#date_timezone' => !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(), - '#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d', + '#default_value' => $except, + '#date_timezone' => !empty($element['#date_timezone']) ? + $element['#date_timezone'] : date_default_timezone(), + '#date_format' => $date_format, '#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(), '#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3', '#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within', '#date_flexible' => 0, - ), - 'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']), - 'all_day' => array('#type' => 'hidden', '#value' => 1), - 'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))), - ); + ), + 'tz' => array( + '#type' => 'hidden', + '#value' => $element['#date_timezone'], + ), + 'all_day' => array( + '#type' => 'hidden', + '#value' => 1, + ), + 'granularity' => array( + '#type' => 'hidden', + '#value' => serialize(array('year', 'month', 'day')), + ), + ); } - // collect additions in the same way as exceptions - implements RDATE. + // Collect additions in the same way as exceptions - implements RDATE. if (empty($form_state['num_additions'][$instance])) { $form_state['num_additions'][$instance] = count($additions); } @@ -634,30 +660,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { ), ), ); - for ($i = 0; $i < max($form_state['num_additions'][$instance], 1) ; $i++) { - $RDATE = ''; + for ($i = 0; $i < max($form_state['num_additions'][$instance], 1); $i++) { + $r_date = ''; if (!empty($additions[$i]['datetime'])) { $rdate = new DateObject($additions[$i]['datetime'], $additions[$i]['tz']); date_timezone_set($rdate, timezone_open($timezone)); - $RDATE = date_format($rdate, DATE_FORMAT_DATETIME); + $r_date = date_format($rdate, DATE_FORMAT_DATETIME); + } + $date_format = 'Y-m-d'; + if (!empty($element['#date_format'])) { + $grans = array('year', 'month', 'day'); + $date_format = date_limit_format($element['#date_format'], $grans); } $element['additions']['RDATE'][$i] = array( '#tree' => TRUE, 'datetime' => array( '#type' => $element['#date_repeat_widget'], '#name' => 'additions|' . $instance, - '#default_value' => $RDATE, - '#date_timezone' => !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(), - '#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d', + '#default_value' => $r_date, + '#date_timezone' => !empty($element['#date_timezone']) ? + $element['#date_timezone'] : date_default_timezone(), + '#date_format' => $date_format, '#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(), '#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3', '#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within', '#date_flexible' => 0, - ), - 'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']), - 'all_day' => array('#type' => 'hidden', '#value' => 1), - 'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))), - ); + ), + 'tz' => array( + '#type' => 'hidden', + '#value' => $element['#date_timezone'], + ), + 'all_day' => array( + '#type' => 'hidden', + '#value' => 1, + ), + 'granularity' => array( + '#type' => 'hidden', + '#value' => serialize(array('year', 'month', 'day')), + ), + ); } $element['exceptions']['exceptions_add'] = array( @@ -687,6 +728,9 @@ function _date_repeat_rrule_process($element, &$form_state, $form) { return $element; } +/** + * Add callback to date repeat. + */ function date_repeat_add_exception_callback($form, &$form_state) { $parents = $form_state['triggering_element']['#array_parents']; $button_key = array_pop($parents); @@ -694,6 +738,9 @@ function date_repeat_add_exception_callback($form, &$form_state) { return $element; } +/** + * Add addition callback to date repeat. + */ function date_repeat_add_addition_callback($form, &$form_state) { $parents = $form_state['triggering_element']['#array_parents']; $button_key = array_pop($parents); @@ -701,6 +748,9 @@ function date_repeat_add_addition_callback($form, &$form_state) { return $element; } +/** + * Add exception to date repeat. + */ function date_repeat_add_exception($form, &$form_state) { $parents = $form_state['triggering_element']['#array_parents']; $instance = implode('-', array_slice($parents, 0, count($parents) - 2)); @@ -708,6 +758,9 @@ function date_repeat_add_exception($form, &$form_state) { $form_state['rebuild'] = TRUE; } +/** + * Add addition to date repeat. + */ function date_repeat_add_addition($form, &$form_state) { $parents = $form_state['triggering_element']['#array_parents']; $instance = implode('-', array_slice($parents, 0, count($parents) - 2)); @@ -723,8 +776,14 @@ function date_repeat_merge($form_values, $element) { return $form_values; } if (array_key_exists('exceptions', $form_values) || array_key_exists('additions', $form_values)) { - if (!array_key_exists('exceptions', $form_values)) $form_values['exceptions'] = array(); - if (!array_key_exists('additions', $form_values)) $form_values['additions'] = array(); + if (!array_key_exists('exceptions', $form_values)) { + $form_values['exceptions'] = array(); + } + + if (!array_key_exists('additions', $form_values)) { + $form_values['additions'] = array(); + } + $form_values = array_merge($form_values, (array) $form_values['exceptions'], (array) $form_values['additions']); unset($form_values['exceptions']); unset($form_values['additions']); @@ -738,18 +797,22 @@ function date_repeat_merge($form_values, $element) { case 'INTERVAL': $form_values['INTERVAL'] = $form_values['daily']['INTERVAL_child']; break; + case 'every_weekday': $form_values['BYDAY'] = array('MO', 'TU', 'WE', 'TH', 'FR'); break; + case 'every_mo_we_fr': $form_values['BYDAY'] = array('MO', 'WE', 'FR'); break; + case 'every_tu_th': $form_values['BYDAY'] = array('TU', 'TH'); break; } } break; + case 'WEEKLY': if (array_key_exists('weekly', $form_values)) { $form_values = array_merge($form_values, (array) $form_values['weekly']); @@ -758,12 +821,14 @@ function date_repeat_merge($form_values, $element) { } } break; + case 'MONTHLY': if (array_key_exists('monthly', $form_values)) { switch ($form_values['monthly']['day_month']) { case 'BYMONTHDAY_BYMONTH': $form_values['monthly'] = array_merge($form_values['monthly'], (array) $form_values['monthly']['BYMONTHDAY_BYMONTH_child']); break; + case 'BYDAY_BYMONTH': $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY'] = $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY_COUNT'] . $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY_DAY']; $form_values['monthly'] = array_merge($form_values['monthly'], (array) $form_values['monthly']['BYDAY_BYMONTH_child']); @@ -783,12 +848,14 @@ function date_repeat_merge($form_values, $element) { } } break; + case 'YEARLY': if (array_key_exists('yearly', $form_values)) { switch ($form_values['yearly']['day_month']) { case 'BYMONTHDAY_BYMONTH': $form_values['yearly'] = array_merge($form_values['yearly'], (array) $form_values['yearly']['BYMONTHDAY_BYMONTH_child']); break; + case 'BYDAY_BYMONTH': $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY'] = $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY_COUNT'] . $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY_DAY']; $form_values['yearly'] = array_merge($form_values['yearly'], (array) $form_values['yearly']['BYDAY_BYMONTH_child']); @@ -808,6 +875,7 @@ function date_repeat_merge($form_values, $element) { } } break; + default: break; } @@ -823,6 +891,7 @@ function date_repeat_merge($form_values, $element) { case 'COUNT': $form_values['COUNT'] = $form_values['count_child']; break; + case 'UNTIL': $form_values['UNTIL'] = $form_values['until_child']; break; @@ -832,14 +901,23 @@ function date_repeat_merge($form_values, $element) { unset($form_values['count_child']); unset($form_values['until_child']); - if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) unset($form_values['BYDAY']['']); - if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH'])) unset($form_values['BYMONTH']['']); - if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY'])) unset($form_values['BYMONTHDAY']['']); + if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) { + unset($form_values['BYDAY']['']); + } + + if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH'])) { + unset($form_values['BYMONTH']['']); + } + + if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY'])) { + unset($form_values['BYMONTHDAY']['']); + } if (array_key_exists('UNTIL', $form_values) && is_array($form_values['UNTIL']['datetime'])) { $function = $element['#date_repeat_widget'] . '_input_date'; $until_element = $element; - $until_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d'; + $until_element['#date_format'] = !empty($element['#date_format']) ? + date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d'; $date = $function($until_element, $form_values['UNTIL']['datetime']); $form_values['UNTIL']['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : ''; } @@ -849,9 +927,14 @@ function date_repeat_merge($form_values, $element) { if (array_key_exists('EXDATE', $form_values) && is_array($form_values['EXDATE'])) { $function = $element['#date_repeat_widget'] . '_input_date'; $exdate_element = $element; + $date_format = 'Y-m-d'; + if (!empty($element['#date_format'])) { + $grans = array('year', 'month', 'day'); + $date_format = date_limit_format($element['#date_format'], $grans); + } foreach ($form_values['EXDATE'] as $delta => $value) { if (is_array($value['datetime'])) { - $exdate_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d'; + $exdate_element['#date_format'] = $date_format; $date = $function($exdate_element, $form_values['EXDATE'][$delta]['datetime']); $form_values['EXDATE'][$delta]['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : ''; } @@ -864,9 +947,14 @@ function date_repeat_merge($form_values, $element) { if (array_key_exists('RDATE', $form_values) && is_array($form_values['RDATE'])) { $function = $element['#date_repeat_widget'] . '_input_date'; $rdate_element = $element; + $date_format = 'Y-m-d'; + if (!empty($element['#date_format'])) { + $grans = array('year', 'month', 'day'); + $date_format = date_limit_format($element['#date_format'], $grans); + } foreach ($form_values['RDATE'] as $delta => $value) { if (is_array($value['datetime'])) { - $rdate_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d'; + $rdate_element['#date_format'] = $date_format; $date = $function($rdate_element, $form_values['RDATE'][$delta]['datetime']); $form_values['RDATE'][$delta]['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : ''; } @@ -910,7 +998,7 @@ function date_repeat_rrule_validate($element, &$form_state) { } /** - * Theme the exception list as a table so the buttons line up + * Theme the exception list as a table so the buttons line up. */ function theme_date_repeat_current_exceptions($vars) { $rows = $vars['rows']; @@ -920,11 +1008,14 @@ function theme_date_repeat_current_exceptions($vars) { $rows_info[] = array(drupal_render($value['action']), drupal_render($value['display'])); } } - return theme('table', array('header' => array(t('Delete'), t('Current exceptions')), 'rows' => $rows_info)); + return theme('table', array( + 'header' => array(t('Delete'), t('Current exceptions')), + 'rows' => $rows_info) + ); } - /** - * Theme the exception list as a table so the buttons line up +/** + * Theme the exception list as a table so the buttons line up. */ function theme_date_repeat_current_additions($rows = array()) { $rows_info = array(); @@ -933,7 +1024,10 @@ function theme_date_repeat_current_additions($rows = array()) { $rows_info[] = array(drupal_render($value['action']), drupal_render($value['display'])); } } - return theme('table', array('header' => array(t('Delete'), t('Current additions')), 'rows' => $rows_info)); + return theme('table', array( + 'header' => array(t('Delete'), t('Current additions')), + 'rows' => $rows_info) + ); } /** @@ -943,7 +1037,13 @@ function theme_date_repeat_rrule($vars) { $element = $vars['element']; $id = drupal_html_id('repeat-settings-fieldset'); $parents = $element['#parents']; - $selector = "{$parents[0]}[{$parents[1]}][{$parents[2]}][show_repeat_settings]"; + + $selector = $parents[0]; + for ($i = 1; $i < count($parents) - 1; $i++) { + $selector .= '[' . $parents[$i] . ']'; + } + $selector .= '[show_repeat_settings]'; + $fieldset = array( '#type' => 'item', '#title' => t('Repeat settings'), @@ -960,6 +1060,9 @@ function theme_date_repeat_rrule($vars) { return drupal_render($fieldset); } +/** + * Filter non zero values. + */ function date_repeat_filter_non_zero_value($value) { return $value !== 0; } diff --git a/sites/all/modules/contrib/fields/date/date_repeat_field/date_repeat_field.devel_generate.inc b/sites/all/modules/contrib/fields/date/date_repeat_field/date_repeat_field.devel_generate.inc index 3880e8b4..51c3708b 100644 --- a/sites/all/modules/contrib/fields/date/date_repeat_field/date_repeat_field.devel_generate.inc +++ b/sites/all/modules/contrib/fields/date/date_repeat_field/date_repeat_field.devel_generate.inc @@ -1,5 +1,5 @@ 'Repeats', - 'page callback' => 'date_repeat_field_page', - 'page arguments' => array($entity_type, $count), - 'access callback' => 'date_repeat_field_show', - 'access arguments' => array($entity_type, $count), - 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + 'title' => 'Repeats', + 'page callback' => 'date_repeat_field_page', + 'page arguments' => array($entity_type, $count), + 'access callback' => 'date_repeat_field_show', + 'access arguments' => array($entity_type, $count), + 'type' => MENU_LOCAL_TASK, + 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, ); } } @@ -91,13 +91,13 @@ function date_repeat_field_menu() { else { $path = $entity_type . '/%' . $entity_type; $items[$path . '/repeats'] = array( - 'title' => 'Repeats', - 'page callback' => 'date_repeat_field_page', - 'page arguments' => array($entity_type, 1), - 'access callback' => 'date_repeat_field_show', - 'access arguments' => array($entity_type, 1), - 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + 'title' => 'Repeats', + 'page callback' => 'date_repeat_field_page', + 'page arguments' => array($entity_type, 1), + 'access callback' => 'date_repeat_field_show', + 'access arguments' => array($entity_type, 1), + 'type' => MENU_LOCAL_TASK, + 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, ); } } @@ -108,10 +108,12 @@ function date_repeat_field_menu() { * Implements hook_permission(). */ function date_repeat_field_permission() { - return array('view date repeats' => array( - 'title' => t('View Repeating Dates'), - 'description' => t('Allow user to see a page with all the times a date repeats.'), - )); + return array( + 'view date repeats' => array( + 'title' => t('View Repeating Dates'), + 'description' => t('Allow user to see a page with all the times a date repeats.'), + ), + ); } /** @@ -195,6 +197,9 @@ function date_repeat_field_bundles() { return $values; } +/** + * Check field is repeat. + */ function date_is_repeat_field($field, $instance = NULL) { if (is_string($field)) { $field = field_info_field($field); @@ -215,7 +220,7 @@ function date_is_repeat_field($field, $instance = NULL) { } } -/* +/** * Implements hook_date_field_insert_alter(). */ function date_repeat_field_date_field_insert_alter(&$items, $context) { @@ -239,7 +244,7 @@ function date_repeat_field_date_field_insert_alter(&$items, $context) { } } -/* +/** * Implements hook_date_field_update_alter(). */ function date_repeat_field_date_field_update_alter(&$items, $context) { @@ -279,6 +284,13 @@ function date_repeat_field_field_widget_form_alter(&$element, &$form_state, $con '#suffix' => '', '#default_value' => isset($items[$delta]['rrule']) && !empty($items[$delta]['rrule']) ? 1 : 0, ); + + // Make changes if instance is set to be rendered as a regular field. + if (!empty($instance['widget']['settings']['no_fieldset'])) { + $element['#title'] = check_plain($instance['label']); + $element['#description'] = field_filter_xss($instance['description']); + $element['#theme_wrappers'] = array('date_form_element'); + } } } } @@ -340,13 +352,14 @@ function date_repeat_field_widget_validate($element, &$form_state) { // The RRULE has already been created by this point, so go back // to the posted values to see if this was filled out. $error_field_base = implode('][', $element['#parents']); - $error_field_until = $error_field_base . '][rrule][until_child][datetime]['; + $error_field_until = $error_field_base . '][rrule][until_child][datetime]['; if (!empty($item['rrule']) && $rrule_values['range_of_repeat'] === 'UNTIL' && empty($rrule_values['UNTIL']['datetime'])) { switch ($instance['widget']['type']) { case 'date_text': case 'date_popup': form_set_error($error_field_until . 'date', t("Missing value in 'Range of repeat'. (UNTIL).", array(), array('context' => 'Date repeat'))); break; + case 'date_select': form_set_error($error_field_until . 'year', t("Missing value in 'Range of repeat': Year (UNTIL)", array(), array('context' => 'Date repeat'))); form_set_error($error_field_until . 'month', t("Missing value in 'Range of repeat': Month (UNTIL)", array(), array('context' => 'Date repeat'))); @@ -382,8 +395,9 @@ function date_repeat_field_widget_validate($element, &$form_state) { // We only collect a date for UNTIL, but we need it to be inclusive, // so force it to a full datetime element at the last possible second of the day. if (!empty($rrule_values['UNTIL'])) { + $gran = array('year', 'month', 'day', 'hour', 'minute', 'second'); $rrule_values['UNTIL']['datetime'] .= ' 23:59:59'; - $rrule_values['UNTIL']['granularity'] = serialize(drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute', 'second'))); + $rrule_values['UNTIL']['granularity'] = serialize(drupal_map_assoc($gran)); $rrule_values['UNTIL']['all_day'] = 0; } $value = date_repeat_build_dates($rrule, $rrule_values, $field, $item); @@ -418,9 +432,10 @@ function date_repeat_after_build(&$element, &$form_state) { * Pass in either the RRULE or the $form_values array for the RRULE, * whichever is missing will be created when needed. */ +// @codingStandardsIgnoreStart function date_repeat_build_dates($rrule = NULL, $rrule_values = NULL, $field, $item) { - - include_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc'); +// @codingStandardsIgnoreEnd + include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc'; $field_name = $field['field_name']; if (empty($rrule)) { @@ -497,8 +512,9 @@ function date_repeat_build_dates($rrule = NULL, $rrule_values = NULL, $field, $i 'offset2' => date_offset_get($date_end), 'timezone' => $timezone, 'rrule' => $rrule, - ); + ); } + return $value; } @@ -681,9 +697,8 @@ function date_repeat_field_date_field_widget_settings_form_alter(&$form, $contex '#title' => t('Repeat display', array(), array('context' => 'Date repeat')), '#description' => t("Should the repeat options form start out expanded or collapsed? Set to 'Collapsed' to make those options less obtrusive.", array(), array('context' => 'Date repeat')), '#fieldset' => 'date_format', - ); + ); } - } /** diff --git a/sites/all/modules/contrib/fields/date/date_tools/date_tools.change_type.inc b/sites/all/modules/contrib/fields/date/date_tools/date_tools.change_type.inc index cad2cafd..041c5dea 100644 --- a/sites/all/modules/contrib/fields/date/date_tools/date_tools.change_type.inc +++ b/sites/all/modules/contrib/fields/date/date_tools/date_tools.change_type.inc @@ -28,10 +28,14 @@ function date_tools_change_type_form() { // Get the available date fields. foreach ($fields as $field_name => $field) { if ($field['type'] == 'date' || $field['type'] == 'datestamp' || $field['type'] == 'datetime') { - $date_options[$labels[$field['type']]][$field_name] = t('Field @label (@field_name)', array('@label' => $field['widget']['label'], '@field_name' => $field_name, '@type' => $labels[$field['type']])); + $date_options[$labels[$field['type']]][$field_name] = t('Field @label (@field_name)', array( + '@label' => $field['widget']['label'], + '@field_name' => $field_name, + '@type' => $labels[$field['type']] + )); } } - if (sizeof($date_options) < 1) { + if (count($date_options) < 1) { drupal_set_message(t('There are no date fields in this database.')); return $form; } @@ -142,26 +146,31 @@ function date_tools_change_type_form_submit($form, &$form_state) { case 'datestamp': $new_columns[] = $date_handler->sql_format('U', $db_field) . ' AS ' . $info['column']; break; + case 'datetime': $new_columns[] = $date_handler->sql_format('Y-m-d H:i:s', $db_field) . ' AS ' . $info['column']; break; } break; + case 'datestamp': switch ($new_type) { case 'date': $new_columns[] = $date_handler->sql_format('Y-m-d/TH:i:s', $db_field) . ' AS ' . $info['column']; break; + case 'datetime': $new_columns[] = $date_handler->sql_format('Y-m-d H:i:s', $db_field) . ' AS ' . $info['column']; break; } break; + case 'datetime': switch ($new_type) { case 'date': $new_columns[] = $date_handler->sql_format('Y-m-d/TH:i:s', $db_field) . ' AS ' . $info['column']; break; + case 'datestamp': $new_columns[] = $date_handler->sql_format('U', $db_field) . ' AS ' . $info['column']; break; @@ -178,5 +187,9 @@ function date_tools_change_type_form_submit($form, &$form_state) { db_query($sql); db_query("DROP TABLE {" . $temp_table . "}"); - drupal_set_message(t('The field @field_name has been changed from @old_type to @new_type.', array('@field_name' => $field['widget']['label'], '@old_type' => $labels[$old_type], '@new_type' => $labels[$new_type]))); + drupal_set_message(t('The field @field_name has been changed from @old_type to @new_type.', array( + '@field_name' => $field['widget']['label'], + '@old_type' => $labels[$old_type], + '@new_type' => $labels[$new_type] + ))); } diff --git a/sites/all/modules/contrib/fields/date/date_tools/date_tools.info b/sites/all/modules/contrib/fields/date/date_tools/date_tools.info index dbcff7d9..3ec02859 100644 --- a/sites/all/modules/contrib/fields/date/date_tools/date_tools.info +++ b/sites/all/modules/contrib/fields/date/date_tools/date_tools.info @@ -6,9 +6,9 @@ core = 7.x configure = admin/config/date/tools files[] = tests/date_tools.test -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_tools/date_tools.module b/sites/all/modules/contrib/fields/date/date_tools/date_tools.module index a7ac5f1e..997808df 100644 --- a/sites/all/modules/contrib/fields/date/date_tools/date_tools.module +++ b/sites/all/modules/contrib/fields/date/date_tools/date_tools.module @@ -31,7 +31,7 @@ function date_tools_help($section, $arg) { */ function date_tools_permission() { return array( - 'administer date tools' => array( + 'administer date tools' => array( 'title' => t('Administer date tools'), ), ); @@ -68,6 +68,7 @@ function date_tools_menu() { 'file' => 'date_tools.wizard.inc', ); + // @codingStandardsIgnoreStart /** $items['admin/config/date/tools/change'] = array( 'title' => 'Change type', @@ -79,18 +80,18 @@ function date_tools_menu() { 'file' => 'date_tools.change_type.inc', ); */ + // @codingStandardsIgnoreEnd return $items; } /** - * Main Date Tools page + * Main Date Tools page. */ function date_tools_page() { $content = ''; - $content .= t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and related calendar. ', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard'))); - + $content .= t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and related calendar.', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard'))); return $content; } diff --git a/sites/all/modules/contrib/fields/date/date_tools/date_tools.wizard.inc b/sites/all/modules/contrib/fields/date/date_tools/date_tools.wizard.inc index 14bc2759..94a130a4 100644 --- a/sites/all/modules/contrib/fields/date/date_tools/date_tools.wizard.inc +++ b/sites/all/modules/contrib/fields/date/date_tools/date_tools.wizard.inc @@ -6,6 +6,8 @@ */ /** + * Implements hook_form(). + * * @todo. */ function date_tools_wizard_form() { @@ -59,7 +61,10 @@ function date_tools_wizard_form() { $form['field']['repeat'] = array( '#type' => 'select', '#default_value' => 0, - '#options' => array(0 => t('No'), 1 => t('Yes')), + '#options' => array( + 0 => t('No'), + 1 => t('Yes'), + ), '#title' => t('Show repeating date options'), '#access' => module_exists('date_repeat_field'), ); @@ -72,7 +77,11 @@ function date_tools_wizard_form() { $form['field']['advanced']['todate'] = array( '#type' => 'select', '#default_value' => 'optional', - '#options' => array('' => t('Never'), 'optional' => t('Optional'), 'required' => t('Required')), + '#options' => array( + '' => t('Never'), + 'optional' => t('Optional'), + 'required' => t('Required'), + ), '#title' => t('End Date'), '#description' => t("Display a matching second date field as a 'End date'."), ); @@ -106,7 +115,10 @@ function date_tools_wizard_form() { $form['calendar'] = array( '#type' => 'select', '#default_value' => module_exists('calendar'), - '#options' => array(0 => t('No'), 1 => t('Yes')), + '#options' => array( + 0 => t('No'), + 1 => t('Yes'), + ), '#title' => t('Create a calendar for this date field'), '#access' => module_exists('calendar'), ); @@ -119,13 +131,26 @@ function date_tools_wizard_form() { } /** + * Form validate. + * * @todo. */ function date_tools_wizard_form_validate(&$form, &$form_state) { $bundle = $form_state['values']['bundle']; $field_name = 'field_' . $form_state['values']['field_name']; - $existing_type = db_query("SELECT type FROM {node_type} WHERE type=:bundle", array(':bundle' => $bundle))->fetchField(); - $existing_instance = db_query("SELECT field_name FROM {field_config_instance} WHERE field_name=:field_name AND bundle=:bundle AND entity_type=:entity_type", array(':field_name' => $field_name, ':bundle' => $bundle, ':entity_type' => 'node'))->fetchField(); + + $args = array( + ':field_name' => $field_name, + ':bundle' => $bundle, + ':entity_type' => 'node', + ); + + $query = "SELECT type FROM {node_type} WHERE type=:bundle"; + $existing_type = db_query($query, array(':bundle' => $args[':bundle']))->fetchField(); + + $query = "SELECT field_name FROM {field_config_instance} WHERE field_name=:field_name AND bundle=:bundle AND entity_type=:entity_type"; + $existing_instance = db_query($query, $args)->fetchField(); + if ($existing_type) { drupal_set_message(t('This content type name already exists, adding new field to existing content type.')); } @@ -147,6 +172,8 @@ function date_tools_wizard_form_validate(&$form, &$form_state) { } /** + * Form submit. + * * @todo. */ function date_tools_wizard_form_submit(&$form, &$form_state) { @@ -161,6 +188,8 @@ function date_tools_wizard_form_submit(&$form, &$form_state) { } /** + * Wizard build. + * * @todo. */ function date_tools_wizard_build($form_values) { @@ -201,7 +230,7 @@ function date_tools_wizard_build($form_values) { 'timezone_db' => date_get_timezone_db($tz_handling), 'repeat' => $repeat, 'todate' => !empty($todate) ? $todate : 'optional', - ), + ), ); $instance = array( 'entity_type' => 'node', @@ -275,6 +304,8 @@ function date_tools_wizard_build($form_values) { } /** + * Includes handler. + * * @todo. */ function date_tools_wizard_include() { @@ -285,6 +316,8 @@ function date_tools_wizard_include() { } /** + * Implements hook_field_types(). + * * @todo. */ function date_tools_wizard_field_types() { @@ -296,6 +329,7 @@ function date_tools_wizard_field_types() { } /** + * Implements hook_widget_types(). * @todo. */ function date_tools_wizard_widget_types() { @@ -309,6 +343,8 @@ function date_tools_wizard_widget_types() { } /** + * Tz handler. + * * @todo. */ function date_tools_wizard_tz_handling() { @@ -317,6 +353,8 @@ function date_tools_wizard_tz_handling() { } /** + * Create date tools wizard content type. + * * @todo. */ function date_tools_wizard_create_content_type($name, $bundle, $description, $type_settings = array()) { @@ -332,8 +370,7 @@ function date_tools_wizard_create_content_type($name, $bundle, $description, $ty 'body_label' => 'Body', 'min_word_count' => '0', 'help' => '', - 'node_options' => - array( + 'node_options' => array( 'status' => 1, 'promote' => 1, 'sticky' => 0, @@ -374,8 +411,10 @@ function date_tools_wizard_create_content_type($name, $bundle, $description, $ty 'weight' => -4, 'module' => 'text', ), - 'settings' => array('display_summary' => TRUE), - 'display' => array( + 'settings' => array( + 'display_summary' => TRUE, + ), + 'display' => array( 'default' => array( 'label' => 'hidden', 'type' => 'text_default', diff --git a/sites/all/modules/contrib/fields/date/date_views/date_views.info b/sites/all/modules/contrib/fields/date/date_views/date_views.info index 0f2d7ec3..663efd35 100644 --- a/sites/all/modules/contrib/fields/date/date_views/date_views.info +++ b/sites/all/modules/contrib/fields/date/date_views/date_views.info @@ -12,9 +12,9 @@ files[] = includes/date_views_filter_handler_simple.inc files[] = includes/date_views.views.inc files[] = includes/date_views_plugin_pager.inc -; Information added by Drupal.org packaging script on 2014-07-29 -version = "7.x-2.8" +; Information added by Drupal.org packaging script on 2015-09-08 +version = "7.x-2.9" core = "7.x" project = "date" -datestamp = "1406653438" +datestamp = "1441727353" diff --git a/sites/all/modules/contrib/fields/date/date_views/date_views.install b/sites/all/modules/contrib/fields/date/date_views/date_views.install index c9697b2d..e1d2e3ef 100644 --- a/sites/all/modules/contrib/fields/date/date_views/date_views.install +++ b/sites/all/modules/contrib/fields/date/date_views/date_views.install @@ -28,3 +28,27 @@ function date_views_uninstall() { variable_del('date_views_week_format_with_year'); variable_del('date_views_week_format_without_year'); } + +/** + * Set default date views variables. + */ +function date_views_update_7200() { + if (!variable_get('date_views_month_format_with_year', FALSE)) { + variable_set('date_views_month_format_with_year', 'F Y'); + } + if (!variable_get('date_views_month_format_without_year', FALSE)) { + variable_set('date_views_month_format_without_year', 'F'); + } + if (!variable_get('date_views_day_format_with_year', FALSE)) { + variable_set('date_views_day_format_with_year', 'l, F j, Y'); + } + if (!variable_get('date_views_day_format_without_year', FALSE)) { + variable_set('date_views_day_format_without_year', 'l, F j'); + } + if (!variable_get('date_views_week_format_with_year', FALSE)) { + variable_set('date_views_week_format_with_year', 'F j, Y'); + } + if (!variable_get('date_views_week_format_without_year', FALSE)) { + variable_set('date_views_week_format_without_year', 'F j'); + } +} diff --git a/sites/all/modules/contrib/fields/date/date_views/date_views.module b/sites/all/modules/contrib/fields/date/date_views/date_views.module index 04bad091..c050e56e 100644 --- a/sites/all/modules/contrib/fields/date/date_views/date_views.module +++ b/sites/all/modules/contrib/fields/date/date_views/date_views.module @@ -1,5 +1,9 @@ 'Configure settings for date views.', 'page callback' => 'drupal_get_form', 'page arguments' => array('date_views_settings'), - 'access arguments' => array('administer site configuration '), + 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, ); @@ -86,13 +90,30 @@ function date_views_theme() { 'file' => 'theme.inc', 'path' => "$path/theme", ); - return array( - 'date_nav_title' => $base + array('variables' => array('granularity' => NULL, 'view' => NULL, 'link' => NULL, 'format' => NULL)), - 'date_views_filter_form' => $base + array('template' => 'date-views-filter-form', 'render element' => 'form'), - 'date_calendar_day' => $base + array('variables' => array('date' => NULL)), + return array( + 'date_nav_title' => $base + array( + 'variables' => array( + 'granularity' => NULL, + 'view' => NULL, + 'link' => NULL, + 'format' => NULL, + ), + ), + 'date_views_filter_form' => $base + array( + 'template' => 'date-views-filter-form', + 'render element' => 'form', + ), + 'date_calendar_day' => $base + array( + 'variables' => array( + 'date' => NULL, + ), + ), 'date_views_pager' => $base + array( - 'variables' => array('plugin' => NULL, 'input' => NULL), + 'variables' => array( + 'plugin' => NULL, + 'input' => NULL, + ), // Register a pattern so that it can work like all views templates. 'pattern' => 'date_views_pager__', 'template' => 'date-views-pager', @@ -100,6 +121,9 @@ function date_views_theme() { ); } +/** + * Implements hook_views_api(). + */ function date_views_views_api() { return array( 'api' => 3, @@ -119,7 +143,7 @@ function date_views_views_fetch_fields($base, $type) { } /** - * Identify all potential date/timestamp fields and cache the data. + * Identify all potential date/timestamp fields and cache the data. */ function date_views_fields($base = 'node', $reset = FALSE) { static $fields = array(); @@ -141,8 +165,8 @@ function date_views_fields($base = 'node', $reset = FALSE) { /** * Implements hook_date_views_entities(). - * Map extra Views tables to the entity that holds its date fields, - * needed for Views tables other than the primary tables identified in entity_info(). + * + * Map extra Views tables to the entity that holds its date fields, needed for Views tables other than the primary tables identified in entity_info(). */ function date_views_date_views_extra_tables() { return array( @@ -151,14 +175,13 @@ function date_views_date_views_extra_tables() { } /** - * Helper function to map entity types to the Views base table they use, - * to make it easier to infer the entity type from a base table. + * Helper function to map entity types to the Views base table they use, to make it easier to infer the entity type from a base table. * - * Views has a new handler called views_handler_field_entity() that loads - * entities, and you can use something like the following to get the - * entity type from a view, but not all our base tables contain the - * entity information we need, (i.e. revisions) so it won't work here - * and we resort to creating information from entity_get_info(). + * Views has a new handler called views_handler_field_entity() that loads entities. + * + * And you can use something like the following to get the entity type from a view, but not all our base tables contain the entity information we need, (i.e. revisions). + * + * So it won't work here and we resort to creating information from entity_get_info(). * * // A method to get the entity type for a base table. * $table_data = views_fetch_data($base_table); @@ -193,11 +216,7 @@ function date_views_base_tables() { /** * Implements hook_date_views_fields(). * - * All modules that create custom fields that use the - * 'views_handler_field_date' handler can provide - * additional information here about the type of - * date they create so the date can be used by - * the Date API views date argument and date filter. + * All modules that create custom fields that use the 'views_handler_field_date' handler can provide additional information here about the type of date they create so the date can be used by the Date API views date argument and date filter. */ function date_views_date_views_fields($field) { $values = array( @@ -263,12 +282,15 @@ function date_pager_url($view, $date_type = NULL, $date_arg = NULL, $force_view_ case 'year': $args[$pos] = date_pad($view->date_info->year, 4); break; + case 'week': $args[$pos] = date_pad($view->date_info->year, 4) . '-W' . date_pad($view->date_info->week); break; + case 'day': $args[$pos] = date_pad($view->date_info->year, 4) . '-' . date_pad($view->date_info->month) . '-' . date_pad($view->date_info->day); break; + default: $args[$pos] = date_pad($view->date_info->year, 4) . '-' . date_pad($view->date_info->month); break; @@ -298,9 +320,14 @@ function date_pager_url($view, $date_type = NULL, $date_arg = NULL, $force_view_ // if they use exposed filters. return url($view->get_url($args), array( 'query' => date_views_querystring($view), - 'absolute' => $absolute)); + 'absolute' => $absolute, + ) + ); } +/** + * Identifier of a date block. + */ function date_block_identifier($view) { if (!empty($view->block_identifier)) { return $view->block_identifier; @@ -311,12 +338,9 @@ function date_block_identifier($view) { /** * Implements hook_field_views_data_alter(). * - * Create a Views field for each date column we care about - * to supplement the generic 'entity_id' and 'revision_id' - * fields that are automatically created. + * Create a Views field for each date column we care about to supplement the generic 'entity_id' and 'revision_id' fields that are automatically created. * - * Also use friendlier labels to distinguish the start date - * and end date in listings (for fields that use both). + * Also use friendlier labels to distinguish the start date and end date in listings (for fields that use both). */ function date_views_field_views_data_alter(&$result, $field, $module) { if ($module == 'date') { @@ -336,8 +360,8 @@ function date_views_field_views_data_alter(&$result, $field, $module) { $result[$table][$column]['field']['is date'] = TRUE; // Not sure yet if we still need a custom field handler in D7 now that custom formatters are available. // Might still need it to handle grouping of multiple value dates. - //$result[$table][$column]['field']['handler'] = 'date_handler_field_date'; - //$result[$table][$column]['field']['add fields to query'] = TRUE; + // $result[$table][$column]['field']['handler'] = 'date_handler_field_date'; + // $result[$table][$column]['field']['add fields to query'] = TRUE; } // For filters, arguments, and sorts, determine if this column is for @@ -395,12 +419,25 @@ function date_views_field_views_data_alter(&$result, $field, $module) { // translatable string. This is a hack to get it to appear right // before 'end date' in the listing (i.e., in a non-alphabetical, // but more user friendly, order). - $result[$table][$column]['title'] = t('@label - start date (!name)', array('@label' => $label, '!name' => $field['field_name'])); - $result[$table][$column]['title short'] = t('@label - start date', array('@label' => $label)); + $result[$table][$column]['title'] = t('@label - start date (!name)', array( + '@label' => $label, + '!name' => $field['field_name'], + )); + $result[$table][$column]['title short'] = t('@label - start date', array( + '@label' => $label, + )); break; + case 'value2': - $result[$table][$column]['title'] = t('@label - end date (!name:!column)', array('@label' => $label, '!name' => $field['field_name'], '!column' => $this_column)); - $result[$table][$column]['title short'] = t('@label - end date:!column', array('@label' => $label, '!column' => $this_column)); + $result[$table][$column]['title'] = t('@label - end date (!name:!column)', array( + '@label' => $label, + '!name' => $field['field_name'], + '!column' => $this_column, + )); + $result[$table][$column]['title short'] = t('@label - end date:!column', array( + '@label' => $label, + '!column' => $this_column, + )); break; } } @@ -421,18 +458,15 @@ function date_views_form_views_ui_edit_form_alter(&$form, &$form_state, $form_id } /** - * The instanceof function makes this work for any handler that was derived - * from 'views_handler_filter_date' or 'views_handler_argument_date', - * which includes core date fields like the node updated field. + * The instanceof function makes this work for any handler that was derived from 'views_handler_filter_date' or 'views_handler_argument_date', which includes core date fields like the node updated field. * - * The test for $handler->min_date tells us that this is an argument that - * not only is derived from the views date handler but also has been processed - * by the Date Views filter or argument code. -*/ + * The test for $handler->min_date tells us that this is an argument that not only is derived from the views date handler but also has been processed by the Date Views filter or argument code. + */ function date_views_handler_is_date($handler, $type = 'argument') { switch ($type) { case 'filter': return $handler instanceof views_handler_filter_date && !empty($handler->min_date); + case 'argument': return $handler instanceof views_handler_argument_date && !empty($handler->min_date); } @@ -441,8 +475,8 @@ function date_views_handler_is_date($handler, $type = 'argument') { /** * Validation hook for exposed filters that use the select widget. - * This is to ensure the the user completes all parts of the date - * not just some parts. Only needed for the select widget. + * + * This is to ensure the the user completes all parts of the date not just some parts. Only needed for the select widget. */ function date_views_select_validate(&$form, &$form_state) { // If there are no values just return. @@ -453,7 +487,7 @@ function date_views_select_validate(&$form, &$form_state) { $filled = array(); $value = drupal_array_get_nested_value($form_state['input'], $form['#parents']); foreach ($granularity as $part) { - if (!empty($value['value'][$part])) { + if (isset($value['value']) && is_numeric($value['value'][$part])) { $filled[] = $part; } } @@ -464,18 +498,23 @@ function date_views_select_validate(&$form, &$form_state) { case 'year': form_error($form['value'][$part], t('Please choose a year.'), $form_state); break; + case 'month': form_error($form['value'][$part], t('Please choose a month.'), $form_state); break; + case 'day': form_error($form['value'][$part], t('Please choose a day.'), $form_state); break; + case 'hour': form_error($form['value'][$part], t('Please choose an hour.'), $form_state); break; + case 'minute': form_error($form['value'][$part], t('Please choose a minute.'), $form_state); break; + case 'second': form_error($form['value'][$part], t('Please choose a second.'), $form_state); break; @@ -487,8 +526,7 @@ function date_views_select_validate(&$form, &$form_state) { /** * Implements hook_date_formatter_view_alter(). * - * If we are displaying a date from a view, see if we have information about - * which multiple value to display. If so, set the date_id in the entity. + * If we are displaying a date from a view, see if we have information about which multiple value to display. If so, set the date_id in the entity. */ function date_views_date_formatter_pre_view_alter(&$entity, &$variables) { // Some views have no row index. @@ -501,4 +539,4 @@ function date_views_date_formatter_pre_view_alter(&$entity, &$variables) { $entity->date_id = 'date.' . $date_item->$date_id . '.' . $field['field_name'] . '.' . $date_item->$date_delta . '.0'; } } -} \ No newline at end of file +} diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_plugin_display_attachment.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_plugin_display_attachment.inc index 94371f76..779f4d1f 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_plugin_display_attachment.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_plugin_display_attachment.inc @@ -1,6 +1,7 @@ 'date_views', // This just tells our themes are elsewhere. + // This just tells our themes are elsewhere. + 'module' => 'date_views', 'display' => array( // Display plugin for date navigation. 'date_nav' => array( @@ -83,7 +85,7 @@ function date_views_views_plugins() { } /** - * Implements hook_views_data() + * Implements hook_views_data(). */ function date_views_views_data() { $data = array(); @@ -95,12 +97,12 @@ function date_views_views_data() { $data[$base_table]['date_argument'] = array( 'group' => t('Date'), 'title' => t('Date (!base_table)', array('!base_table' => $base_table)), - 'help' => t('Filter any Views !base_table date field by a date argument, using any common ISO date/period format (i.e. YYYY, YYYY-MM, YYYY-MM-DD, YYYY-W99, YYYY-MM-DD--P3M, P90D, etc). ', array('!base_table' => $base_table)), + 'help' => t('Filter any Views !base_table date field by a date argument, using any common ISO date/period format (i.e. YYYY, YYYY-MM, YYYY-MM-DD, YYYY-W99, YYYY-MM-DD--P3M, P90D, etc).', array('!base_table' => $base_table)), 'argument' => array( 'handler' => 'date_views_argument_handler', 'empty field name' => t('Undated'), 'is date' => TRUE, - //'skip base' => $base_table, + // 'skip base' => $base_table, ), ); // The flexible date filter. @@ -112,7 +114,7 @@ function date_views_views_data() { 'handler' => 'date_views_filter_handler', 'empty field name' => t('Undated'), 'is date' => TRUE, - //'skip base' => $base_table, + // 'skip base' => $base_table, ), ); } @@ -140,8 +142,9 @@ function date_views_views_data_alter(&$data) { } /** - * Central function for setting up the right timezone values - * in the SQL date handler. + * Central function for setting up the right timezone values. + * + * In the SQL date handler. * * The date handler will use this information to decide if the * database value needs a timezone conversion. @@ -152,30 +155,45 @@ function date_views_views_data_alter(&$data) { */ function date_views_set_timezone(&$date_handler, &$view, $field) { switch ($field['tz_handling']) { - case 'date' : + case 'date': $date_handler->db_timezone = 'UTC'; $date_handler->local_timezone_field = $field['timezone_field']; $date_handler->offset_field = $field['offset_field']; break; + case 'none': $date_handler->db_timezone = date_default_timezone(); $date_handler->local_timezone = date_default_timezone(); break; + case 'utc': $date_handler->db_timezone = 'UTC'; $date_handler->local_timezone = 'UTC'; break; - default : + + default: $date_handler->db_timezone = 'UTC'; $date_handler->local_timezone = date_default_timezone(); break; } } +/** + * Helper function to generate a query string. + * + * @param object $view + * A View object. + * + * @param array $extra_params + * An extra parameters. + * + * @return null/string + * Return a query or NULL. + */ function date_views_querystring($view, $extra_params = array()) { $query_params = array_merge($_GET, $extra_params); // Allow NULL params to be removed from the query string. - foreach ($extra_params AS $key => $value) { + foreach ($extra_params as $key => $value) { if (!isset($value)) { unset($query_params[$key]); } diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler.inc index 61aeafc1..20eedff0 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler.inc @@ -3,12 +3,14 @@ * @file * Date API views argument handler. * This argument combines multiple date arguments into a single argument - * where all fields are controlled by the same date and can be combined with either AND or OR. + * where all fields are controlled by the same date and can be combined + * with either AND or OR. */ /** * Date API argument handler. */ +// @codingStandardsIgnoreStart class date_views_argument_handler extends date_views_argument_handler_simple { /** @@ -198,3 +200,4 @@ class date_views_argument_handler extends date_views_argument_handler_simple { } } +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler_simple.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler_simple.inc index 35f88e00..2839b959 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler_simple.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_argument_handler_simple.inc @@ -7,11 +7,13 @@ /** * Date API argument handler. */ +// @codingStandardsIgnoreStart class date_views_argument_handler_simple extends views_handler_argument_date { /** - * Get granularity and use it to create the formula and a format - * for the results. + * Get granularity. + * + * Use it to create the formula and a format for the results. */ function init(&$view, &$options) { parent::init($view, $options); @@ -29,12 +31,14 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $this->date_handler->local_timezone = date_get_timezone($field['settings']['tz_handling']); } $this->date_handler->granularity = $this->options['granularity']; - // This value needs to be initialized so it exists even if the query doesn't run. + // This value needs to be initialized so + // it exists even if the query doesn't run. $this->date_handler->placeholders = array(); $this->format = $this->date_handler->views_formats($this->date_handler->granularity, 'display'); $this->sql_format = $this->date_handler->views_formats($this->date_handler->granularity, 'sql'); - // $this->arg_format is the format the parent date handler will use to create a default argument. + // $this->arg_format is the format the parent date + // handler will use to create a default argument. $this->arg_format = $this->format(); // Identify the base table for this field. @@ -43,6 +47,9 @@ class date_views_argument_handler_simple extends views_handler_argument_date { } + /** + * {@inheritdoc} + */ function format() { if (!empty($this->options['granularity'])) { return $this->date_handler->views_formats($this->options['granularity']); @@ -53,8 +60,9 @@ class date_views_argument_handler_simple extends views_handler_argument_date { } /** - * Set the empty argument value to the current date, - * formatted appropriately for this argument. + * Set the empty argument value to the current date. + * + * Formatted appropriately for this argument. */ function get_default_argument($raw = FALSE) { $is_default = FALSE; @@ -85,6 +93,7 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $options = parent::option_definition(); $options['year_range'] = array('default' => '-3:+3'); $options['granularity'] = array('default' => 'month'); + $options['granularity_reset'] = array('default' => FALSE); $options['default_argument_type']['default'] = 'date'; $options['add_delta'] = array('default' => ''); $options['use_fromto'] = array('default' => ''); @@ -116,7 +125,9 @@ class date_views_argument_handler_simple extends views_handler_argument_date { '#attributes' => array('class' => array('dependent-options')), '#states' => array( 'visible' => array( - ':input[name="options[default_action]"]' => array('value' => 'summary') + ':input[name="options[default_action]"]' => array( + 'value' => 'summary', + ), ), ), ); @@ -129,23 +140,37 @@ class date_views_argument_handler_simple extends views_handler_argument_date { '#attributes' => array('class' => array('dependent-options')), '#states' => array( 'visible' => array( - ':input[name="options[title_format]"]' => array('value' => 'custom') + ':input[name="options[title_format]"]' => array( + 'value' => 'custom', + ), ), ), ); + // Get default granularity options $options = $this->date_handler->date_parts(); - unset($options['second'], $options['minute']); - $options += array('week' => t('Week', array(), array('context' => 'datetime'))); + // Add the 'week' option. + $options += array( + 'week' => t('Week', array(), array( + 'context' => 'datetime', + )), + ); + $form['granularity'] = array( '#title' => t('Granularity'), '#type' => 'radios', '#options' => $options, '#default_value' => $this->options['granularity'], - '#multiple' => TRUE, '#description' => t("Select the type of date value to be used in defaults, summaries, and navigation. For example, a granularity of 'month' will set the default date to the current month, summarize by month in summary views, and link to the next and previous month when using date navigation."), ); + $form['granularity_reset'] = array( + '#title' => t('Use granularity from argument value'), + '#type' => 'checkbox', + '#default_value' => $this->options['granularity_reset'], + '#description' => t("If the granularity of argument value is different from selected, use it from argument value."), + ); + $form['year_range'] = array( '#title' => t('Date year range'), '#type' => 'textfield', @@ -172,16 +197,18 @@ class date_views_argument_handler_simple extends views_handler_argument_date { '#default_value' => $this->options['add_delta'], '#options' => array('' => t('No'), 'yes' => t('Yes')), '#description' => t('Add an identifier to the view to show which multiple value date fields meet the filter criteria. Note: This option may introduce duplicate values into the view. Required when using multiple value fields in a Calendar or any time you want the node view of multiple value dates to display only the values that match the view filters.'), - // Only let mere mortals tweak this setting for multi-value fields + // Only let mere mortals tweak this setting for multi-value fields. '#access' => $access, ); - } + /** + * {@inheritdoc} + */ function options_validate(&$form, &$form_state) { // It is very important to call the parent function here: parent::options_validate($form, $form_state); - if (!preg_match('/^(?:\-[0-9]{1,4}|[0-9]{4}):(?:[\+|\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) { + if (!preg_match('/^(?:\-[0-9]{1,4}|[0-9]{4}):(?:[\+\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) { form_error($form['year_range'], t('Date year range must be in the format -9:+9, 2005:2010, -9:2010, or 2005:+9')); } } @@ -209,14 +236,15 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $format = !empty($this->options['title_format_custom']) && !empty($this->options['title_format_custom']) ? $this->options['title_format_custom'] : $this->date_handler->views_formats($this->options['granularity'], 'display'); $range = $this->date_handler->arg_range($this->argument); return date_format_date($range[0], 'custom', $format); - } + } /** - * Provide the argument to use to link from the summary to the next level; - * this will be called once per row of a summary, and used as part of + * Provide the argument to use to link from the summary to the next level. + * + * This will be called once per row of a summary, and used as part of * $view->get_url(). * - * @param $data + * @param object $data * The query results for the row. */ function summary_argument($data) { @@ -234,10 +262,11 @@ class date_views_argument_handler_simple extends views_handler_argument_date { */ function summary_query() { - // @TODO The summary values are computed by the database. Unless the database has - // built-in timezone handling it will use a fixed offset, which will not be - // right for all dates. The only way I can see to make this work right is to - // store the offset for each date in the database so it can be added to the base + // @TODO The summary values are computed by the database. + // Unless the database has built-in timezone handling it will use + // a fixed offset, which will not be right for all dates. + // The only way I can see to make this work right is to store the offset + // for each date in the database so it can be added to the base // date value before the database formats the result. Because this is a huge // architectural change, it won't go in until we start a new branch. $this->formula = $this->date_handler->sql_format($this->sql_format, $this->date_handler->sql_field("***table***.$this->real_field")); @@ -245,7 +274,8 @@ class date_views_argument_handler_simple extends views_handler_argument_date { // Now that our table is secure, get our formula. $formula = $this->get_formula(); - // Add the field, give it an alias that does NOT match the actual field name or grouping won't work right. + // Add the field, give it an alias that does NOT match the actual + // field name or grouping won't work right. $this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $this->field . '_summary'); $this->query->set_count_field(NULL, $formula, $this->field); @@ -254,20 +284,22 @@ class date_views_argument_handler_simple extends views_handler_argument_date { /** * Inject a test for valid date range before the regular query. + * * Override the parent query to be able to control the $group. */ function query($group_by = FALSE) { - // @TODO Not doing anything with $group_by yet, need to figure out what has to be done. + // @TODO Not doing anything with $group_by yet, + // need to figure out what has to be done. if ($this->date_forbid()) { return; } // See if we need to reset granularity based on an argument value. - // Make sure we don't try to reset to some bogus value if someone has typed in an unexpected argument. - $granularity = $this->date_handler->arg_granularity($this->argument); - if (!empty($granularity)) { + // Make sure we don't try to reset to some bogus value if someone has + // typed in an unexpected argument. + if ($this->options['granularity_reset'] && $granularity = $this->date_handler->arg_granularity($this->argument)) { $this->date_handler->granularity = $granularity; $this->format = $this->date_handler->views_formats($this->date_handler->granularity, 'display'); $this->sql_format = $this->date_handler->views_formats($this->date_handler->granularity, 'sql'); @@ -276,7 +308,8 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $this->ensure_my_table(); $group = !empty($this->options['date_group']) ? $this->options['date_group'] : 0; - // If requested, add the delta field to the view so we can later find the value that matched our query. + // If requested, add the delta field to the view so + // we can later find the value that matched our query. if (!empty($this->options['add_delta']) && (substr($this->real_field, -6) == '_value' || substr($this->real_field, -7) == '_value2')) { $this->query->add_field($this->table_alias, 'delta'); $real_field_name = str_replace(array('_value', '_value2'), '', $this->real_field); @@ -291,7 +324,8 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $view_max_placeholder = $this->placeholder(); $this->date_handler->placeholders = array($view_min_placeholder => $view_min, $view_max_placeholder => $view_max); - // Are we comparing this field only or the Start/End date range to the view criteria? + // Are we comparing this field only or the Start/End date range + // to the view criteria? if (!empty($this->options['use_fromto'])) { // The simple case, match the field to the view range. @@ -302,10 +336,14 @@ class date_views_argument_handler_simple extends views_handler_argument_date { } else { - // Look for the intersection of the range of the date field with the range of the view. - // Get the Start/End values for this field. Retrieve using the original table name. - // Swap the current table name (adjusted for relationships) into the query. - // @TODO We may be able to use Views substitutions here, investigate that later. + // Look for the intersection of the range + // of the date field with the range of the view. + // Get the Start/End values for this field. + // Retrieve using the original table name. + // Swap the current table name (adjusted for relationships) + // into the query. + // @TODO We may be able to use Views substitutions here, + // investigate that later. $fields = date_views_fields($this->base_table); $fields = $fields['name']; $fromto = $fields[$this->original_table . '.' . $this->real_field]['fromto']; @@ -321,7 +359,10 @@ class date_views_argument_handler_simple extends views_handler_argument_date { } /** - * Add a callback to determine if we have moved outside the valid date range for this argument. + * Add a callback. + * + * To determine if we have moved outside + * the valid date range for this argument. */ function date_forbid() { if (empty($this->argument)) { @@ -343,3 +384,4 @@ class date_views_argument_handler_simple extends views_handler_argument_date { } } +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_fields.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_fields.inc index a002b088..d497ef60 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_fields.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_fields.inc @@ -5,13 +5,11 @@ */ /** - * Identify all potential date/timestamp fields. + * Identify all potential date/timestamp fields. * - * @return - * array with fieldname, type, and table. - * @see - * date_views_date_views_fields() which implements - * the hook_date_views_fields() for the core date fields. + * @return array + * An array with fieldname, type, and table. + * @see date_views_date_views_fields() */ function _date_views_fields($base = 'node') { @@ -60,7 +58,7 @@ function _date_views_fields($base = 'node') { $handler = views_get_handler($table_name, $field_name, 'filter'); $handler_name = $handler->definition['handler']; - // We don't care about anything but date handlers + // We don't care about anything but date handlers. if (empty($handler->definition['is date'])) { continue; } @@ -72,14 +70,17 @@ function _date_views_fields($base = 'node') { $field = field_info_field($handler->definition['field_name']); $is_field = TRUE; switch ($field['type']) { - case 'date': + case 'date': $sql_type = DATE_ISO; break; + case 'datestamp': break; + case 'datetime': $sql_type = DATE_DATETIME; break; + default: // If this is not a date field, nothing more to do. continue; @@ -88,7 +89,8 @@ function _date_views_fields($base = 'node') { $revision = in_array($base, array('node_revision')) ? FIELD_LOAD_REVISION : FIELD_LOAD_CURRENT; $db_info = date_api_database_info($field, $revision); $name = $table_name . "." . $field_name; - $granularity = !empty($field['granularity']) ? $field['granularity'] : array('year', 'month', 'day', 'hour', 'minute', 'second'); + $grans = array('year', 'month', 'day', 'hour', 'minute', 'second'); + $granularity = !empty($field['granularity']) ? $field['granularity'] : $grans; $fromto = array( $table_name . '.' . $db_info['columns'][$table_name]['value'], diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler.inc index 0cfc7fcc..f761dfa0 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler.inc @@ -3,9 +3,11 @@ * @file * A flexible, configurable date filter. * This filter combines multiple date filters into a single filter - * where all fields are controlled by the same date and can be combined with either AND or OR. + * where all fields are controlled by the same date and can be combined + * with either AND or OR. */ +// @codingStandardsIgnoreStart class date_views_filter_handler extends date_views_filter_handler_simple { function init(&$view, &$options) { parent::init($view, $options); @@ -64,6 +66,9 @@ class date_views_filter_handler extends date_views_filter_handler_simple { if ($field['table_name'] != $this->table || !empty($this->relationship)) { $this->related_table_alias = $this->query->ensure_table($field['table_name'], $this->relationship); } + else { + $this->related_table_alias = null; + } $table_alias = !empty($this->related_table_alias) ? $this->related_table_alias : $field['table_name']; $field_name = $table_alias . '.' . $field['field_name']; @@ -179,3 +184,4 @@ class date_views_filter_handler extends date_views_filter_handler_simple { } } } +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler_simple.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler_simple.inc index d41f30b6..4fa4c409 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler_simple.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_filter_handler_simple.inc @@ -1,9 +1,11 @@ $operator_values); } if (!isset($form_state['input'][$identifier][$prefix])) { - $form_state['input'][$identifier][$prefix] = $this->value[$prefix]; + // Ensure these exist. + foreach ($granularity as $key) { + $form_state['input'][$identifier][$prefix][$key] = NULL; + } } } else { @@ -530,3 +535,4 @@ class date_views_filter_handler_simple extends views_handler_filter_date { } } +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_plugin_pager.inc b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_plugin_pager.inc index f9594a72..5caca4e5 100644 --- a/sites/all/modules/contrib/fields/date/date_views/includes/date_views_plugin_pager.inc +++ b/sites/all/modules/contrib/fields/date/date_views/includes/date_views_plugin_pager.inc @@ -2,50 +2,74 @@ /** * @file * Date pager. - * Works with a Date argument, the argument filters the view and the pager provides back/next navigation. + * Works with a Date argument, the argument filters + * the view and the pager provides back/next navigation. * * USER NOTES: * * To use this, add a pager to a view, and choose the option to 'Page by date'. * There are several settings: - * - The pager id: Set an id to be used as the identifier in the url for pager values, defaults to 'date'. - * - Pager position: Choose whether to display the date pager above, below, or both above and below the content. - * - Link format: Choose whether the pager links will be in the simple 'calendar/2011-12' format or the - * more complex 'calendar/?date=2011-12' pager format. The second one is more likely to work correctly - * if the pager is used in blocks and panels. + * - The pager id: Set an id to be used as the identifier + * in the url for pager values, defaults to 'date'. + * - Pager position: Choose whether to display the date + * pager above, below, or both above and below the content. + * - Link format: Choose whether the pager links will be in t + * he simple 'calendar/2011-12' format or the + * more complex 'calendar/?date=2011-12' pager format. + * The second one is more likely to work correctly + * if the pager is used in blocks and panels. * - * The pager works in combination with a Date argument and it will use the date fields and granularity - * set in that argument to create its back/next links. If the view has no Date argument, the pager can - * do nothing. The argument can either be a 'Date' argument that lets you select one or more date fields - * in the argument, or the simple 'Content' argument for an individual date field. It must be an + * The pager works in combination with a Date argument + * and it will use the date fields and granularity + * set in that argument to create its back/next links. + * If the view has no Date argument, the pager can + * do nothing. The argument can either be a 'Date' argument + * that lets you select one or more date fields + * in the argument, or the simple 'Content' argument for an + * individual date field. It must be an * argument that uses the date argument handler. * * DEVELOPER NOTES * - * The pager could technically create a query of its own rather than depending on the date argument to - * set the query, but it has only a limited set of tools to work with because it is a plugin, not a handler: - * it has no knowledge about relationships, it cannot use the ensure_my_table() function, - * plugins are not even invoked in pre_query(), so can't do anything there. + * The pager could technically create a query of its own rather + * than depending on the date argument to + * set the query, but it has only a limited set of tools to work + * with because it is a plugin, not a handler: + * it has no knowledge about relationships, it cannot use the + * ensure_my_table() function, plugins are not even invoked in pre_query(), + * so can't do anything there. * - * My conclusion was that the date pager simply is not powerful enough to create its own queries for - * date fields, which require very complex queries. Instead, we can combine this with a date argument and - * let the argument create the query and let the pager just provide the back/next links. If there is no + * My conclusion was that the date pager simply + * is not powerful enough to create its own queries for + * date fields, which require very complex queries. + * Instead, we can combine this with a date argument and + * let the argument create the query and let the pager + * just provide the back/next links. If there is no * date argument, the pager will do nothing. * - * There are still other problems. The pager is not even initialized until after all the handlers - * have created their queries, so it has no chance to alter values ahead of that. And the argument - * has no knowledge of the pager, so it can't check for pager values before the query is created. + * There are still other problems. The pager is not even + * initialized until after all the handlers + * have created their queries, so it has no chance + * to alter values ahead of that. And the argument + * has no knowledge of the pager, so it can't check + * for pager values before the query is created. * - * The solution used here is to let the argument create the original query. The pager query - * runs after that, so the pager checks to see if there is a pager value that needs to be used in the query. - * The date argument has identified the placeholders it used in the query. So if a change is needed, - * we can swap the pager value into the query created by the date argument and adjust the - * $view->date_info values set by the argument accordingly so the theme will pick up the new information. + * The solution used here is to let the argument create + * the original query. The pager query + * runs after that, so the pager checks to see + * if there is a pager value that needs to be used in the query. + * The date argument has identified the placeholders + * it used in the query. So if a change is needed, + * we can swap the pager value into the query created + * by the date argument and adjust the + * $view->date_info values set by the argument accordingly + * so the theme will pick up the new information. */ /** * Example plugin to handle paging by month. */ +// @codingStandardsIgnoreStart class date_views_plugin_pager extends views_plugin_pager { /** @@ -79,6 +103,7 @@ class date_views_plugin_pager extends views_plugin_pager { $options['link_format'] = array('default' => 'pager'); $options['date_argument'] = array('default' => 'Unknown'); $options['granularity'] = array('default' => 'Unknown'); + $options['skip_empty_pages'] = array('default' => FALSE); return $options; } @@ -110,6 +135,12 @@ class date_views_plugin_pager extends views_plugin_pager { '#default_value' => $this->options['link_format'], '#required' => TRUE, ); + $form['skip_empty_pages'] = array( + '#title' => t('Skip empty pages'), + '#type' => 'checkbox', + '#description' => t('When selected, the pager will not display pages with no result for the given date. This causes a slight performance degradation because two additional queries need to be executed.'), + '#default_value' => $this->options['skip_empty_pages'], + ); $form['date_argument']['#type'] = 'hidden'; $form['date_argument']['#value'] = $this->options['date_argument']; $form['granularity']['#type'] = 'hidden'; @@ -150,13 +181,7 @@ class date_views_plugin_pager extends views_plugin_pager { // Reset values set by argument if pager requires it. if (!empty($value)) { - $argument->argument = $value; - $argument->date_range = $argument->date_handler->arg_range($value); - $argument->min_date = $argument->date_range[0]; - $argument->max_date = $argument->date_range[1]; - // $argument->is_default works correctly for normal arguments, but does not - // work correctly if we are swapping in a new value from the pager. - $argument->is_default = FALSE; + $this->set_argument_value($argument, $value); } // The pager value might move us into a forbidden range, so test it. @@ -164,13 +189,102 @@ class date_views_plugin_pager extends views_plugin_pager { $this->view->build_info['fail'] = TRUE; return; } - - if (empty($this->view->date_info)) $this->view->date_info = new stdClass(); + // Write date_info to store information to be used + // in the theming functions. + if (empty($this->view->date_info)) { + $this->view->date_info = new stdClass(); + } $this->view->date_info->granularity = $argument->date_handler->granularity; $format = $this->view->date_info->granularity == 'week' ? DATE_FORMAT_DATETIME : $argument->sql_format; $this->view->date_info->placeholders = isset($argument->placeholders) ? $argument->placeholders : $argument->date_handler->placeholders; $this->view->date_info->date_arg = $argument->argument; $this->view->date_info->date_arg_pos = $i; + $this->view->date_info->limit = $argument->limit; + $this->view->date_info->url = $this->view->get_url(); + $this->view->date_info->pager_id = $this->options['date_id']; + $this->view->date_info->date_pager_position = $this->options['pager_position']; + $this->view->date_info->date_pager_format = $this->options['link_format']; + $this->view->date_info->skip_empty_pages = $this->options['skip_empty_pages'] == 1; + // Execute two additional queries to find + // the previous and next page with values. + if ($this->view->date_info->skip_empty_pages) { + $q = clone $argument->query; + $field = $argument->table_alias . '.' . $argument->real_field; + $fieldsql = $date_handler->sql_field($field); + $fieldsql = $date_handler->sql_format($format, $fieldsql); + $q->clear_fields(); + $q->orderby = array(); + $q->set_distinct(TRUE, TRUE); + // Date limits of this argument. + $datelimits = $argument->date_handler->arg_range($argument->limit[0] . '--' . $argument->limit[1]); + // Find the first two dates between the minimum date + // and the upper bound of the current value. + $q->add_orderby(NULL, $fieldsql, 'DESC', 'date'); + $this->set_argument_placeholders($this->view->date_info->placeholders, $datelimits[0], $argument->max_date, $q, $format); + + $compiledquery = $q->query(); + $compiledquery->range(0, 2); + $results = $compiledquery->execute()->fetchCol(0); + + $prevdate = array_shift($results); + $prevdatealt = array_shift($results); + // Find the first two dates between the lower bound + // of the current value and the maximum date. + $q->add_orderby(NULL, $fieldsql, 'ASC', 'date'); + $this->set_argument_placeholders($this->view->date_info->placeholders, $argument->min_date, $datelimits[1], $q, $format); + + $compiledquery = $q->query(); + $compiledquery->range(0, 2); + $results = $compiledquery->execute()->fetchCol(0); + + $nextdate = array_shift($results); + $nextdatealt = array_shift($results); + + // Set the default value of the query to $prevfirst or $nextfirst + // when there is no value and $prevsecond or $nextsecond is set. + if (empty($value)) { + // @Todo find out which of $prevdate or $nextdate is closest to the + // default argument date value and choose that one. + if ($prevdate && $prevdatealt) { + $this->set_argument_value($argument, $prevdate); + $value = $prevdate; + $prevdate = $prevdatealt; + // If the first next date is the same as the first previous date, + // move to the following next date. + if ($value == $nextdate) { + $nextdate = $nextdatealt; + $nextdatealt = NULL; + } + } + elseif ($nextdate && $nextdatealt) { + $this->set_argument_value($argument, $nextdate); + $value = $nextdate; + $nextdate = $nextdatealt; + // If the first previous date is the same as the first next date, + // move to the following previous date. + if ($value == $prevdate) { + $prevdate = $prevdatealt; + $prevdatealt = NULL; + } + } + } + else { + // $prevdate and $nextdate are the same as $value, so move to + // the next values. + $prevdate = $prevdatealt; + $nextdate = $nextdatealt; + } + + $this->view->date_info->prev_date = $prevdate ? new DateObject($prevdate, NULL, $format) : NULL; + $this->view->date_info->next_date = $nextdate ? new DateObject($nextdate, NULL, $format) : NULL; + } + else { + $this->view->date_info->prev_date = clone($argument->min_date); + date_modify($this->view->date_info->prev_date, '-1 ' . $argument->date_handler->granularity); + $this->view->date_info->next_date = clone($argument->max_date); + date_modify($this->view->date_info->next_date, '+1 ' . $argument->date_handler->granularity); + } + // Write the date_info properties that depend on the current value. $this->view->date_info->year = date_format($argument->min_date, 'Y'); $this->view->date_info->month = date_format($argument->min_date, 'n');; $this->view->date_info->day = date_format($argument->min_date, 'j'); @@ -178,11 +292,6 @@ class date_views_plugin_pager extends views_plugin_pager { $this->view->date_info->date_range = $argument->date_range; $this->view->date_info->min_date = $argument->min_date; $this->view->date_info->max_date = $argument->max_date; - $this->view->date_info->limit = $argument->limit; - $this->view->date_info->url = $this->view->get_url(); - $this->view->date_info->pager_id = $this->options['date_id']; - $this->view->date_info->date_pager_position = $this->options['pager_position']; - $this->view->date_info->date_pager_format = $this->options['link_format']; } $i++; } @@ -191,20 +300,33 @@ class date_views_plugin_pager extends views_plugin_pager { // If there is pager input and the argument has set the placeholders, // swap the pager value in for the placeholder set by the argument. if (!empty($value) && !empty($this->view->date_info->placeholders)) { - $placeholders = $this->view->date_info->placeholders; - $count = count($placeholders); - foreach ($this->view->query->where as $group => $data) { - foreach ($data['conditions'] as $delta => $condition) { - if (array_key_exists('value', $condition) && is_array($condition['value'])) { - foreach ($condition['value'] as $placeholder => $placeholder_value) { - if (array_key_exists($placeholder, $placeholders)) { - // If we didn't get a match, this is a > $min < $max query that uses the view - // min and max dates as placeholders. - $date = ($count == 2) ? $this->view->date_info->min_date : $this->view->date_info->max_date; - $next_placeholder = array_shift($placeholders); - $this->view->query->where[$group]['conditions'][$delta]['value'][$placeholder] = $date->format($format); - $count--; - } + $this->set_argument_placeholders($this->view->date_info->placeholders, $this->view->date_info->min_date, $this->view->date_info->max_date, $this->view->query, $format); + } + } + + function set_argument_value($argument, $value) { + $argument->argument = $value; + $argument->date_range = $argument->date_handler->arg_range($value); + $argument->min_date = $argument->date_range[0]; + $argument->max_date = $argument->date_range[1]; + // $argument->is_default works correctly for normal arguments, but does not + // work correctly if we are swapping in a new value from the pager. + $argument->is_default = FALSE; + } + + function set_argument_placeholders($placeholders, $mindate, $maxdate, $query, $format) { + $count = count($placeholders); + foreach ($query->where as $group => $data) { + foreach ($data['conditions'] as $delta => $condition) { + if (array_key_exists('value', $condition) && is_array($condition['value'])) { + foreach ($condition['value'] as $placeholder => $placeholder_value) { + if (array_key_exists($placeholder, $placeholders)) { + // If we didn't get a match, this is a > $min < $max query that uses the view + // min and max dates as placeholders. + $date = ($count == 2) ? $mindate : $maxdate; + $next_placeholder = array_shift($placeholders); + $query->where[$group]['conditions'][$delta]['value'][$placeholder] = $date->format($format); + $count--; } } } @@ -230,4 +352,5 @@ class date_views_plugin_pager extends views_plugin_pager { $pager_theme = views_theme_functions('date_views_pager', $this->view, $this->display); return theme($pager_theme, array('plugin' => $this, 'input' => $input)); } -} \ No newline at end of file +} +// @codingStandardsIgnoreEnd diff --git a/sites/all/modules/contrib/fields/date/date_views/theme/date-views-pager.tpl.php b/sites/all/modules/contrib/fields/date/date_views/theme/date-views-pager.tpl.php index b12c2e1c..ac8cfb4e 100644 --- a/sites/all/modules/contrib/fields/date/date_views/theme/date-views-pager.tpl.php +++ b/sites/all/modules/contrib/fields/date/date_views/theme/date-views-pager.tpl.php @@ -27,8 +27,10 @@ * be used in the l() function, including rel=nofollow. */ ?> - -
+ + + +

@@ -36,7 +38,11 @@
  • - 'date_nav'))), $prev_url, $prev_options); ?> + 'date_nav')); + print l(t($text), $prev_url, $prev_options); + ?>
  • @@ -46,4 +52,4 @@
-
\ No newline at end of file +
diff --git a/sites/all/modules/contrib/fields/date/date_views/theme/theme.inc b/sites/all/modules/contrib/fields/date/date_views/theme/theme.inc index 8c42a527..9e7debc7 100644 --- a/sites/all/modules/contrib/fields/date/date_views/theme/theme.inc +++ b/sites/all/modules/contrib/fields/date/date_views/theme/theme.inc @@ -4,6 +4,7 @@ * @file * Theme files for Date Pager. */ + /** * Jump in and move the pager. */ @@ -15,9 +16,11 @@ function date_views_preprocess_views_view(&$vars) { $vars['header'] .= $vars['pager']; $vars['pager'] = ''; break; + case 'both': $vars['header'] .= $vars['pager']; break; + default: // Already on the bottom. } @@ -66,28 +69,37 @@ function template_preprocess_date_views_pager(&$vars) { } if (empty($date_info->hide_nav)) { - $prev_date = clone($min_date); - date_modify($prev_date, '-1 ' . $granularity); - $next_date = clone($min_date); - date_modify($next_date, '+1 ' . $granularity); - $format = array('year' => 'Y', 'month' => 'Y-m', 'day' => 'Y-m-d'); - switch ($granularity) { - case 'week': - $next_week = date_week(date_format($next_date, 'Y-m-d')); - $prev_week = date_week(date_format($prev_date, 'Y-m-d')); - $next_arg = date_format($next_date, 'o-\W') . date_pad($next_week); - $prev_arg = date_format($prev_date, 'o-\W') . date_pad($prev_week); - break; - default: - $next_arg = date_format($next_date, $format[$granularity]); - $prev_arg = date_format($prev_date, $format[$granularity]); + $prev_date = $date_info->prev_date; + $next_date = $date_info->next_date; + + $format = array('year' => 'Y', 'month' => 'Y-m', 'day' => 'Y-m-d', 'hour' => 'Y-m-d\TH'); + if (!empty($prev_date)) { + switch ($granularity) { + case 'week': + $prev_week = date_week(date_format($prev_date, 'Y-m-d')); + $prev_arg = date_format($prev_date, 'Y-\W') . date_pad($prev_week); + break; + default: + $prev_arg = date_format($prev_date, $format[$granularity]); + } + $prev_path = str_replace($date_info->date_arg, $prev_arg, $date_info->url); + $prev_args[$pos] = $prev_arg; + $vars['prev_url'] = date_pager_url($view, NULL, $prev_arg); } - $next_path = str_replace($date_info->date_arg, $next_arg, $date_info->url); - $prev_path = str_replace($date_info->date_arg, $prev_arg, $date_info->url); - $next_args[$pos] = $next_arg; - $prev_args[$pos] = $prev_arg; - $vars['next_url'] = date_pager_url($view, NULL, $next_arg); - $vars['prev_url'] = date_pager_url($view, NULL, $prev_arg); + if (!empty($next_date)) { + switch ($granularity) { + case 'week': + $next_week = date_week(date_format($next_date, 'Y-m-d')); + $next_arg = date_format($next_date, 'Y-\W') . date_pad($next_week); + break; + default: + $next_arg = date_format($next_date, $format[$granularity]); + } + $next_path = str_replace($date_info->date_arg, $next_arg, $date_info->url); + $next_args[$pos] = $next_arg; + $vars['next_url'] = date_pager_url($view, NULL, $next_arg); + } + $vars['next_options'] = $vars['prev_options'] = array(); } else { @@ -117,14 +129,17 @@ function template_preprocess_date_views_pager(&$vars) { $prev_title = t('Navigate to previous year'); $next_title = t('Navigate to next year'); break; + case 'month': $prev_title = t('Navigate to previous month'); $next_title = t('Navigate to next month'); break; + case 'week': $prev_title = t('Navigate to previous week'); $next_title = t('Navigate to next week'); break; + case 'day': $prev_title = t('Navigate to previous day'); $next_title = t('Navigate to next day'); @@ -157,34 +172,44 @@ function template_preprocess_date_views_pager(&$vars) { } /** - * Theme the calendar title + * Theme the calendar title. */ function theme_date_nav_title($params) { + $title = ''; $granularity = $params['granularity']; $view = $params['view']; $date_info = $view->date_info; $link = !empty($params['link']) ? $params['link'] : FALSE; $format = !empty($params['format']) ? $params['format'] : NULL; - $format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y'); - $format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j'); + $format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y'); + $format_without_year = variable_get('date_views_' . $granularity . '_format_without_year', 'l, F j'); switch ($granularity) { case 'year': $title = $date_info->year; $date_arg = $date_info->year; break; + case 'month': $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year); $title = date_format_date($date_info->min_date, 'custom', $format); $date_arg = $date_info->year . '-' . date_pad($date_info->month); break; + case 'day': $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year); $title = date_format_date($date_info->min_date, 'custom', $format); - $date_arg = $date_info->year . '-' . date_pad($date_info->month) . '-' . date_pad($date_info->day); + $date_arg = $date_info->year; + $date_arg .= '-'; + $date_arg .= date_pad($date_info->month); + $date_arg .= '-'; + $date_arg .= date_pad($date_info->day); break; + case 'week': $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year); - $title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format))); + $title = t('Week of @date', array( + '@date' => date_format_date($date_info->min_date, 'custom', $format), + )); $date_arg = $date_info->year . '-W' . date_pad($date_info->week); break; } diff --git a/sites/all/modules/contrib/fields/date/tests/date_api.test b/sites/all/modules/contrib/fields/date/tests/date_api.test index f50020c1..0924ebaa 100644 --- a/sites/all/modules/contrib/fields/date/tests/date_api.test +++ b/sites/all/modules/contrib/fields/date/tests/date_api.test @@ -132,11 +132,11 @@ class DateAPITestCase extends DrupalWebTestCase { // Test week range with calendar weeks. variable_set('date_first_day', 0); variable_set('date_api_use_iso8601', FALSE); - $expected = '2008-01-27 to 2008-02-03'; + $expected = '2008-01-27 to 2008-02-02'; $result = date_week_range(5, 2008); $value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE); $this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2008): should be $expected, found $value."); - $expected = '2009-01-25 to 2009-02-01'; + $expected = '2009-01-25 to 2009-01-31'; $result = date_week_range(5, 2009); $value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE); $this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2009): should be $expected, found $value."); @@ -144,11 +144,11 @@ class DateAPITestCase extends DrupalWebTestCase { // And now with ISO weeks. variable_set('date_first_day', 1); variable_set('date_api_use_iso8601', TRUE); - $expected = '2008-01-28 to 2008-02-04'; + $expected = '2008-01-28 to 2008-02-03'; $result = date_week_range(5, 2008); $value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE); $this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2008): should be $expected, found $value."); - $expected = '2009-01-26 to 2009-02-02'; + $expected = '2009-01-26 to 2009-02-01'; $result = date_week_range(5, 2009); $value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE); $this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2009): should be $expected, found $value."); @@ -396,6 +396,28 @@ class DateAPITestCase extends DrupalWebTestCase { $date = new dateObject($input, $timezone, $format); $this->assertNotEqual(count($date->errors), 0, '23 abc 2012 should be an invalid date'); + // Test Granularity. + $input = '2005-06-01 10:30:45'; + $timezone = NULL; + $format = 'Y-m-d H:i:s'; + + $date = new dateObject($input, $timezone, $format); + $date->removeGranularity('hour'); + $date->removeGranularity('second'); + $date->removeGranularity('minute'); + + $value = $date->format($format); + $expected = '2005-06-01'; + $this->assertEqual($expected, $value, "The date with removed granularity should be $expected, found $value."); + + $date->addGranularity('hour'); + $date->addGranularity('second'); + $date->addGranularity('minute'); + + $value = $date->format($format); + $expected = '2005-06-01 10:30:45'; + + $this->assertEqual($expected, $value, "The date with added granularity should be $expected, found $value."); } /** diff --git a/sites/all/modules/contrib/fields/date/tests/date_field.test b/sites/all/modules/contrib/fields/date/tests/date_field.test index b2a45a0d..2dd3f051 100644 --- a/sites/all/modules/contrib/fields/date/tests/date_field.test +++ b/sites/all/modules/contrib/fields/date/tests/date_field.test @@ -52,7 +52,7 @@ abstract class DateFieldBasic extends DrupalWebTestCase { $repeat = !empty($repeat) ? $repeat : 0; $todate = !empty($todate) ? $todate : 'optional'; $widget_type = !empty($widget_type) ? $widget_type : 'date_select'; - $tz_handling = !empty($tz_handing) ? $tz_handling : 'site'; + $tz_handling = !empty($tz_handling) ? $tz_handling : 'site'; $granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute'); $year_range = !empty($year_range) ? $year_range : '2010:+1'; $input_format = !empty($input_format) ? $input_format : date_default_format($widget_type); @@ -151,6 +151,123 @@ abstract class DateFieldBasic extends DrupalWebTestCase { } + /** + * Creates a date field from an array of settings values. + * + * All values have defaults, only need to specify values that need to be + * different. + */ + protected function createMultiDateField($values = array()) { + extract($values); + + $field_name = !empty($field_name) ? $field_name : 'field_test'; + $entity_type = !empty($entity_type) ? $entity_type : 'node'; + $bundle = !empty($bundle) ? $bundle : 'story'; + $label = !empty($label) ? $label : 'Test'; + $field_type = !empty($field_type) ? $field_type : 'datetime'; + $repeat = !empty($repeat) ? $repeat : 0; + $todate = !empty($todate) ? $todate : 'optional'; + $widget_type = !empty($widget_type) ? $widget_type : 'date_select'; + $this->verbose(!empty($tz_handling)); + $tz_handling = !empty($tz_handling) ? $tz_handling : 'site'; + $granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute'); + $year_range = !empty($year_range) ? $year_range : '2010:+1'; + $input_format = !empty($input_format) ? $input_format : date_default_format($widget_type); + $input_format_custom = !empty($input_format_custom) ? $input_format_custom : ''; + $text_parts = !empty($text_parts) ? $text_parts : array(); + $increment = !empty($increment) ? $increment : 15; + $default_value = !empty($default_value) ? $default_value : 'now'; + $default_value2 = !empty($default_value2) ? $default_value2 : 'blank'; + $default_format = !empty($default_format) ? $default_format : 'long'; + $cache_enabled = !empty($cache_enabled); + $cache_count = !empty($cache_count) ? $cache_count : 4; + $cardinality = !empty($cardinality) ? $cardinality : 1; + + $field = array( + 'field_name' => $field_name, + 'type' => $field_type, + 'cardinality' => $cardinality, + 'settings' => array( + 'granularity' => $granularity, + 'tz_handling' => $tz_handling, + 'timezone_db' => date_get_timezone_db($tz_handling), + 'repeat' => $repeat, + 'todate' => $todate, + 'cache_enabled' => $cache_enabled, + 'cache_count' => $cache_count, + ), + ); + $instance = array( + 'entity_type' => $entity_type, + 'field_name' => $field_name, + 'label' => $label, + 'bundle' => $bundle, + // Move the date right below the title. + 'weight' => -4, + 'widget' => array( + 'type' => $widget_type, + // Increment for minutes and seconds, can be 1, 5, 10, 15, or 30. + 'settings' => array( + 'increment' => $increment, + // The number of years to go back and forward in drop-down year + // selectors. + 'year_range' => $year_range, + 'input_format' => $input_format, + 'input_format_custom' => $input_format_custom, + 'text_parts' => $text_parts, + 'label_position' => 'above', + 'repeat_collapsed' => 0, + ), + 'weight' => -4, + ), + 'settings' => array( + 'default_value' => $default_value, + 'default_value2' => $default_value2, + ), + ); + + $instance['display'] = array( + 'default' => array( + 'label' => 'above', + 'type' => 'date_default', + 'settings' => array( + 'format_type' => $default_format, + 'show_repeat_rule' => 'show', + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_to' => '', + 'fromto' => 'both', + ), + 'module' => 'date', + 'weight' => 0 , + ), + 'teaser' => array( + 'label' => 'above', + 'type' => 'date_default', + 'weight' => 0, + 'settings' => array( + 'format_type' => $default_format, + 'show_repeat_rule' => 'show', + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_to' => '', + 'fromto' => 'both', + ), + 'module' => 'date', + ), + ); + + $field = field_create_field($field); + $instance = field_create_instance($instance); + + field_info_cache_clear(TRUE); + field_cache_clear(TRUE); + + // Look at how the field got configured. + $this->drupalGet("admin/structure/types/manage/$bundle/fields/$field_name"); + $this->drupalGet("admin/structure/types/manage/$bundle/display"); + } + /** * @todo. */ diff --git a/sites/all/modules/contrib/fields/date/tests/date_timezone.test b/sites/all/modules/contrib/fields/date/tests/date_timezone.test index ddbdcef9..54d882fd 100644 --- a/sites/all/modules/contrib/fields/date/tests/date_timezone.test +++ b/sites/all/modules/contrib/fields/date/tests/date_timezone.test @@ -50,6 +50,111 @@ class DateTimezoneTestCase extends DateFieldBasic { } } + /** + * Validates timezone handling with a multi-value date field. + */ + public function testMultiUserTimezone() { + // Create date fields with combinations of various types and granularity + // using the "Date's Timezone" strategy. + $field_type = 'datetime'; + $tz_handling = 'date'; + $max_granularity = 'minute'; + + // Create date field + $field_name = "field_test"; + $label = 'Test'; + $options = array( + 'label' => $label, + 'widget_type' => 'date_text', + 'field_name' => $field_name, + 'field_type' => $field_type, + 'input_format' => 'custom', + 'input_format_custom' => 'm/d/Y - H:i:s T', + 'cardinality' => 3, + 'tz_handling' => $tz_handling, + ); + $this->createMultiDateField($options); + + // Submit a date field form with multiple values + $this->dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling); + + + $this->deleteDateField($label); + } + + /** + * Tests the submission of a date field's widget form when using unlimited + * cardinality + */ + public function dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling) { + variable_set('date_format_long', 'D, m/d/Y - H:i:s T'); + + $edit = array(); + $should_be = array(); + $edit['title'] = $this->randomName(8); + $timezones = array('America/Chicago', 'America/Los_Angeles', 'America/New_York'); + + switch ($max_granularity) { + case 'hour': + $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago'; + $should_be[0] = 'Thu, 10/07/2010 - 10 CDT'; + + $edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles'; + $should_be[1] = 'Thu, 10/07/2010 - 10 PDT'; + + $edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York'; + $should_be[2] = 'Thu, 10/07/2010 - 10 EDT'; + + break; + case 'minute': + $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago'; + $should_be[0] = 'Thu, 10/07/2010 - 10:30 CDT'; + + $edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles'; + $should_be[1] = 'Thu, 10/07/2010 - 10:30 PDT'; + + $edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York'; + $should_be[2] = 'Thu, 10/07/2010 - 10:30 EDT'; + + break; + case 'second': + $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago'; + $should_be[0] = 'Thu, 10/07/2010 - 10:30:30 CDT'; + + $edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles'; + $should_be[1] = 'Thu, 10/07/2010 - 10:30:30 PDT'; + + $edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30'; + $edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York'; + $should_be[2] = 'Thu, 10/07/2010 - 10:30:30 EDT'; + break; + } + + $this->drupalPost('node/add/story', $edit, t('Save')); + $this->assertText($edit['title'], "Node has been created"); + + foreach ($should_be as $assertion) { + $this->assertText($assertion, "Found the correct date for a $field_type field using $max_granularity granularity with $tz_handling timezone handling."); + } + + // Goto the edit page and save the node again. + $node = $this->drupalGetNodeByTitle($edit['title']); + $this->drupalGet('node/' . $node->nid . '/edit'); + + // Re-assert the proper date timezones. + foreach ($timezones as $key => $timezone) { + $this->assertOptionSelected('edit-field-test-und-' . $key . '-timezone-timezone', $timezone, "Found the correct timezone $timezone for a $field_type field using $max_granularity granularity with $tz_handling timezone handling."); + } + } + /** * @todo. */ diff --git a/sites/all/modules/contrib/fields/date/tests/date_views_pager.test b/sites/all/modules/contrib/fields/date/tests/date_views_pager.test new file mode 100644 index 00000000..4f5dd97d --- /dev/null +++ b/sites/all/modules/contrib/fields/date/tests/date_views_pager.test @@ -0,0 +1,129 @@ + 'Date views pager skipping test', + 'description' => "Views date pager, option to skip empty pages test", + 'group' => 'Date', + ); + } + + /** + * Test setup actions. + */ + public function setUp() { + // Load the 'date_views', 'views', 'views_ui', 'ctools' modules. + parent::setUp('date_views', 'views', 'views_ui', 'ctools'); + // Set required permissions. + $permissions = array('administer views', 'administer site configuration'); + // Create admin user and login. + $admin_user = $this->drupalCreateUser($permissions); + $this->drupalLogin($admin_user); + + // Create a new view for test. + $view = new view(); + $view->name = 'test_date_pager'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_date_pager'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'test_date_pager'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'date_views_pager'; + $handler->display->display_options['pager']['options']['skip_empty_pages'] = 1; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Contextual filter: Date: Date (node) */ + $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument'; + $handler->display->display_options['arguments']['date_argument']['table'] = 'node'; + $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument'; + $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default'; + $handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date'; + $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['date_argument']['granularity'] = 'hour'; + $handler->display->display_options['arguments']['date_argument']['date_fields'] = array( + 'node.created' => 'node.created', + ); + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['path'] = 'test_date_pager'; + + $view->save(); + } + + /** + * Test pager skipping. + */ + public function testPagerSkipping() { + // Go to view admin page. + $this->drupalGet('admin/structure/views/view/display/test_date_pager/edit'); + // Go to pager options. + $this->drupalGet('admin/structure/views/nojs/display/test_date_pager/default/pager_options'); + // Check if "Skip empty pages" text - exist. + $this->assertText('Skip empty pages'); + // Check if field and it's value is correct. + $this->assertFieldByName('pager_options[skip_empty_pages]', '1'); + // Go back to view admin page. + $this->drupalGet('admin/structure/views/view/display/test_date_pager/edit'); + // Check if pager on empty page are gone. + $this->assertNoText('« Prev', 'Previous pager does not exist'); + $this->assertNoText('Next »', 'Next pager does not exist'); + } + + /** + * Test the view page has no PHP warnings. + */ + public function testPagerWarning() { + $this->drupalCreateNode(array('type' => 'blog')); + // Set pager to skip empty pages. + $edit = array( + 'pager_options[skip_empty_pages]' => FALSE, + ); + $this->drupalPost('admin/structure/views/nojs/display/test_date_pager/default/pager_options', $edit, t('Apply')); + // Save the view. + $this->drupalPost('admin/structure/views/view/test_date_pager/edit', array(), t('Save')); + + // Visit view page. This will throw error, if any PHP warnings or errors. + $this->drupalGet('test_date_pager'); + } + +} diff --git a/sites/all/modules/contrib/fields/date/tests/date_views_popup.test b/sites/all/modules/contrib/fields/date/tests/date_views_popup.test new file mode 100644 index 00000000..e3d4306d --- /dev/null +++ b/sites/all/modules/contrib/fields/date/tests/date_views_popup.test @@ -0,0 +1,106 @@ + 'Date Views - Popup Test', + 'description' => 'Tests date popup in Views', + 'group' => 'Date', + ); + } + + /** + * Test setup actions. + */ + public function setUp() { + parent::setUp(); + // Load the 'date_popup', 'date_views', 'views', 'views_ui', 'ctools' modules. + $modules = array('date_popup', 'date_views', 'views', 'views_ui', 'ctools'); + $success = module_enable($modules, TRUE); + $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); + + // Reset/rebuild all data structures after enabling the modules. + $this->resetAll(); + + // Create a date field. + $field_name = "field_test_date_popup"; + $label = 'Test'; + $options = array( + 'label' => 'Test', + 'widget_type' => 'date_popup', + 'field_name' => $field_name, + 'field_type' => 'datetime', + 'input_format' => 'm/d/Y - H:i', + ); + $this->createDateField($options); + + // Set required permissions. + $permissions = array('administer views', 'administer site configuration'); + // Create admin user and login. + $admin_user = $this->drupalCreateUser($permissions); + $this->drupalLogin($admin_user); + + // Create the view. + $view = new view(); + $view->name = 'test_date_popup'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Test date_popup'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'test_date_popup_page'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Filter criterion: Content: test_date_popup (field_test_date_popup) */ + $handler->display->display_options['filters']['field_test_date_popup_value']['id'] = 'field_test_date_popup_value'; + $handler->display->display_options['filters']['field_test_date_popup_value']['table'] = 'field_data_field_test_date_popup'; + $handler->display->display_options['filters']['field_test_date_popup_value']['field'] = 'field_test_date_popup_value'; + $handler->display->display_options['filters']['field_test_date_popup_value']['exposed'] = TRUE; + $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator_id'] = 'field_test_date_popup_value_op'; + $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['label'] = 'test_date_popup (field_test_date_popup)'; + $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator'] = 'field_test_date_popup_value_op'; + $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['identifier'] = 'field_test_date_popup_value'; + $handler->display->display_options['filters']['field_test_date_popup_value']['form_type'] = 'date_popup'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['path'] = 'test-date-popup'; + + $view->save(); + } + + /** + * Test date popup. + */ + public function testDatePopup() { + // Go to view page. + $this->drupalGet('test-date-popup'); + } +} diff --git a/sites/all/modules/contrib/form/honeypot/honeypot.admin.inc b/sites/all/modules/contrib/form/honeypot/honeypot.admin.inc index 37bcba75..f76edd4a 100644 --- a/sites/all/modules/contrib/form/honeypot/honeypot.admin.inc +++ b/sites/all/modules/contrib/form/honeypot/honeypot.admin.inc @@ -32,7 +32,7 @@ function honeypot_admin_form($form, &$form_state) { $form['configuration']['honeypot_element_name'] = array( '#type' => 'textfield', '#title' => t('Honeypot element name'), - '#description' => t("The name of the Honeypot form field. It's usually most effective to use a generic name like email, homepage, or name, but this should be changed if it interferes with fields that are already in your forms. Must not contain spaces or special characters."), + '#description' => t("The name of the Honeypot form field. It's usually most effective to use a generic name like email, homepage, or link, but this should be changed if it interferes with fields that are already in your forms. Must not contain spaces or special characters."), '#default_value' => variable_get('honeypot_element_name', 'url'), '#required' => TRUE, '#size' => 30, @@ -170,11 +170,25 @@ function honeypot_admin_form_validate($form, &$form_state) { if (!preg_match("/^[-_a-zA-Z0-9]+$/", $form_state['values']['honeypot_element_name'])) { form_set_error('honeypot_element_name', t("The element name cannot contain spaces or other special characters.")); } + + // Make sure Honeypot element name isn't one of the reserved names. + $reserved_element_names = array( + 'name', + 'pass', + 'website', + ); + if (in_array($form_state['values']['honeypot_element_name'], $reserved_element_names)) { + form_set_error('honeypot_element_name', t("The element name cannot match one of the common Drupal form field names (e.g. @names).", array('@names' => implode(', ', $reserved_element_names)))); + } } /** - * Clear the honeypot form cache on submit. + * Honeypot admin form submit callback. */ function honeypot_admin_form_submit($form, &$form_state) { + // Create CSS file for honeypot. + honeypot_create_css($form_state['values']['honeypot_element_name']); + + // Clear the Honeypot form cache on submit. cache_clear_all('honeypot_protected_forms', 'cache'); } diff --git a/sites/all/modules/contrib/form/honeypot/honeypot.info b/sites/all/modules/contrib/form/honeypot/honeypot.info index 4bbd3742..92ba90d3 100644 --- a/sites/all/modules/contrib/form/honeypot/honeypot.info +++ b/sites/all/modules/contrib/form/honeypot/honeypot.info @@ -6,9 +6,9 @@ package = "Spam control" files[] = honeypot.test -; Information added by Drupal.org packaging script on 2014-05-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2015-09-04 +version = "7.x-1.21" core = "7.x" project = "honeypot" -datestamp = "1401478128" +datestamp = "1441334340" diff --git a/sites/all/modules/contrib/form/honeypot/honeypot.install b/sites/all/modules/contrib/form/honeypot/honeypot.install index e4eacf16..7dd0f942 100644 --- a/sites/all/modules/contrib/form/honeypot/honeypot.install +++ b/sites/all/modules/contrib/form/honeypot/honeypot.install @@ -37,10 +37,15 @@ function honeypot_schema() { * Implements hook_install(). */ function honeypot_install() { - $t = get_t(); - drupal_set_message($t("Honeypot installed successfully. Please !link to protect your forms from spam bots.", array( - '!link' => l($t('configure Honeypot'), 'admin/config/content/honeypot'), - ))); + // Create CSS file. + honeypot_create_css(variable_get('honeypot_element_name', 'url')); + + if (!drupal_is_cli()) { + $t = get_t(); + drupal_set_message($t("Honeypot installed successfully. Please !link to protect your forms from spam bots.", array( + '!link' => l($t('configure Honeypot'), 'admin/config/content/honeypot'), + ))); + } } /** @@ -56,6 +61,9 @@ function honeypot_uninstall() { cache_clear_all($table, 'cache'); } } + + // Delete 'honeypot' directory from public file directory. + file_unmanaged_delete_recursive('public://honeypot'); } /** @@ -129,3 +137,12 @@ function honeypot_update_7003() { db_create_table('honeypot_user', $table); } } + +/** + * Create Honeypot CSS file. + */ +function honeypot_update_7004() { + drupal_load('module', 'honeypot'); + module_load_include('inc', 'honeypot', 'honeypot.admin'); + honeypot_create_css(variable_get('honeypot_element_name', 'url')); +} diff --git a/sites/all/modules/contrib/form/honeypot/honeypot.module b/sites/all/modules/contrib/form/honeypot/honeypot.module index 22d3de1c..3fb54ad0 100644 --- a/sites/all/modules/contrib/form/honeypot/honeypot.module +++ b/sites/all/modules/contrib/form/honeypot/honeypot.module @@ -45,6 +45,12 @@ function honeypot_cron() { db_delete('honeypot_user') ->condition('timestamp', time() - variable_get('honeypot_expire', 300), '<') ->execute(); + + // Regenerate the honeypot css file if it does not exist. + $honeypot_css = honeypot_get_css_file_path(); + if (!file_exists($honeypot_css)) { + honeypot_create_css(variable_get('honeypot_element_name', 'url')); + } } /** @@ -142,6 +148,7 @@ function honeypot_get_protected_forms() { $forms = $cache->data; } else { + $forms = array(); // Look up all the honeypot forms in the variables table. $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'honeypot_form_%'")->fetchCol(); // Add each form that's enabled to the $forms array. @@ -185,6 +192,15 @@ function honeypot_add_form_protection(&$form, &$form_state, $options = array()) // Get the element name (default is generic 'url'). $honeypot_element = variable_get('honeypot_element_name', 'url'); + // Add 'autocomplete="off"' if configured. + $attributes = array(); + if (variable_get('honeypot_autocomplete_attribute', 1)) { + $attributes = array('autocomplete' => 'off'); + } + + // Get the path to the honeypot css file. + $honeypot_css = honeypot_get_css_file_path(); + // Build the honeypot element. $honeypot_class = $honeypot_element . '-textfield'; $form[$honeypot_element] = array( @@ -192,14 +208,14 @@ function honeypot_add_form_protection(&$form, &$form_state, $options = array()) '#title' => t('Leave this field blank'), '#size' => 20, '#weight' => 100, - '#attributes' => array('autocomplete' => 'off'), + '#attributes' => $attributes, '#element_validate' => array('_honeypot_honeypot_validate'), '#prefix' => '
', '#suffix' => '
', - // Hide honeypot. + // Hide honeypot using CSS. '#attached' => array( 'css' => array( - '.' . $honeypot_class . ' { display: none !important; }' => array('type' => 'inline'), + 'data' => $honeypot_css, ), ), ); @@ -211,13 +227,13 @@ function honeypot_add_form_protection(&$form, &$form_state, $options = array()) $form['honeypot_time'] = array( '#type' => 'hidden', '#title' => t('Timestamp'), - '#default_value' => time(), + '#default_value' => honeypot_get_signed_timestamp(time()), '#element_validate' => array('_honeypot_time_restriction_validate'), ); // Disable page caching to make sure timestamp isn't cached. if (user_is_anonymous()) { - $GLOBALS['conf']['cache'] = 0; + drupal_page_is_cacheable(FALSE); } } @@ -251,18 +267,18 @@ function _honeypot_time_restriction_validate($element, &$form_state) { } // Get the time value. - $honeypot_time = $form_state['values']['honeypot_time']; + $honeypot_time = honeypot_get_time_from_signed_timestamp($form_state['values']['honeypot_time']); // Get the honeypot_time_limit. $time_limit = honeypot_get_time_limit($form_state['values']); // Make sure current time - (time_limit + form time value) is greater than 0. // If not, throw an error. - if (time() < ($honeypot_time + $time_limit)) { + if (!$honeypot_time || time() < ($honeypot_time + $time_limit)) { _honeypot_log($form_state['values']['form_id'], 'honeypot_time'); // Get the time limit again, since it increases after first failure. $time_limit = honeypot_get_time_limit($form_state['values']); - $form_state['values']['honeypot_time'] = time(); + $form_state['values']['honeypot_time'] = honeypot_get_signed_timestamp(time()); form_set_error('', t('There was a problem with your form submission. Please wait @limit seconds and try again.', array('@limit' => $time_limit))); } } @@ -300,16 +316,20 @@ function honeypot_get_time_limit($form_values = array()) { // Only calculate time limit if honeypot_time_limit has a value > 0. if ($honeypot_time_limit) { + $expire_time = variable_get('honeypot_expire', 300); // Get value from {honeypot_user} table for authenticated users. if ($user->uid) { - $number = db_query("SELECT COUNT(*) FROM {honeypot_user} WHERE uid = :uid", array(':uid' => $user->uid))->fetchField(); + $number = db_query("SELECT COUNT(*) FROM {honeypot_user} WHERE uid = :uid AND timestamp > :time", array( + ':uid' => $user->uid, + ':time' => time() - $expire_time, + ))->fetchField(); } // Get value from {flood} table for anonymous users. else { $number = db_query("SELECT COUNT(*) FROM {flood} WHERE event = :event AND identifier = :hostname AND timestamp > :time", array( ':event' => 'honeypot', ':hostname' => ip_address(), - ':time' => time() - variable_get('honeypot_expire', 300), + ':time' => time() - $expire_time, ))->fetchField(); } // Don't add more than 30 days' worth of extra time. @@ -372,3 +392,76 @@ function honeypot_log_failure($form_id, $type) { rules_invoke_event('honeypot_reject', $form_id, $type); } } + +/** + * Retrieve the location of the Honeypot CSS file. + * + * @return string + * The path to the honeypot.css file. + */ +function honeypot_get_css_file_path() { + return variable_get('file_public_path', conf_path() . '/files') . '/honeypot/honeypot.css'; +} + +/** + * Create CSS file to hide the Honeypot field. + * + * @param string $element_name + * The honeypot element class name (e.g. 'url'). + */ +function honeypot_create_css($element_name) { + $path = 'public://honeypot'; + + if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) { + drupal_set_message(t('Unable to create Honeypot CSS directory, %path. Check the permissions on your files directory.', array('%path' => file_uri_target($path))), 'error'); + } + else { + $filename = $path . '/honeypot.css'; + $data = '.' . $element_name . '-textfield { display: none !important; }'; + file_unmanaged_save_data($data, $filename, FILE_EXISTS_REPLACE); + } +} + +/** + * Sign the timestamp $time. + * + * @param mixed $time + * The timestamp to sign. + * + * @return string + * A signed timestamp in the form timestamp|HMAC. + */ +function honeypot_get_signed_timestamp($time) { + return $time . '|' . drupal_hmac_base64($time, drupal_get_private_key()); +} + +/** + * Validate a signed timestamp. + * + * @param string $signed_timestamp + * A timestamp concateneted with the signature + * + * @return int + * The timestamp if the signature is correct, 0 otherwise. + */ +function honeypot_get_time_from_signed_timestamp($signed_timestamp) { + $honeypot_time = 0; + + // Fail fast if timestamp was forged or saved with an older Honeypot version. + if (strpos($signed_timestamp, '|') === FALSE) { + return $honeypot_time; + } + + list($timestamp, $received_hmac) = explode('|', $signed_timestamp); + + if ($timestamp && $received_hmac) { + $calculated_hmac = drupal_hmac_base64($timestamp, drupal_get_private_key()); + // Prevent leaking timing information, compare second order hmacs. + $random_key = drupal_random_bytes(32); + if (drupal_hmac_base64($calculated_hmac, $random_key) === drupal_hmac_base64($received_hmac, $random_key)) { + $honeypot_time = $timestamp; + } + } + + return $honeypot_time; +} diff --git a/sites/all/modules/contrib/form/honeypot/honeypot.test b/sites/all/modules/contrib/form/honeypot/honeypot.test index feccd0f5..23fae24e 100644 --- a/sites/all/modules/contrib/form/honeypot/honeypot.test +++ b/sites/all/modules/contrib/form/honeypot/honeypot.test @@ -171,6 +171,65 @@ class HoneypotFormTestCase extends DrupalWebTestCase { } } +/** + * Test Honeypot's CSS generation routines. + */ +class HoneypotCssTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Honeypot CSS tests', + 'description' => 'Ensure that Honeypot rebuilds its CSS file correctly.', + 'group' => 'Form API', + ); + } + + public function setUp() { + // Enable modules required for this test. + parent::setUp(array('honeypot')); + + // Set up required Honeypot variables. + variable_set('honeypot_element_name', 'url'); + } + + /** + * Test CSS file regeneration. + */ + public function testHoneypotCssRegeneration() { + $honeypot_css = honeypot_get_css_file_path(); + + // Delete the Honeypot CSS file (if it exists). + file_unmanaged_delete($honeypot_css); + + // Make sure the Honeypot CSS file doesn't exist. + $this->assertFalse(file_exists($honeypot_css)); + + // Create the CSS file. + honeypot_create_css(variable_get('honeypot_element_name', 'url')); + + // Make sure the Honeypot CSS file exists. + $this->assertTrue(file_exists($honeypot_css)); + } + + /** + * Test cron-based CSS file regeneration + */ + public function testHoneypotCssRegenerationOnCron() { + $honeypot_css = honeypot_get_css_file_path(); + + // Delete the Honeypot CSS file (if it exists). + file_unmanaged_delete($honeypot_css); + + // Make sure the Honeypot CSS file doesn't exist. + $this->assertFalse(file_exists($honeypot_css)); + + // Run cron. + honeypot_cron(); + + // Make sure the Honeypot CSS file exists. + $this->assertTrue(file_exists($honeypot_css)); + } +} + /** * Test the functionality of the Honeypot module's integration with Trigger. */