diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-02-12 19:37:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-02-12 19:37:04 +0000 |
commit | b5c18e8a17024d4af8b2ea508d5ded2570893f07 (patch) | |
tree | 305a4b33d3a3130d7589d70dc5166caa25f488b2 | |
parent | 14b84fa2997b5e27046a70ac307a4241d724e466 (diff) | |
download | brdo-b5c18e8a17024d4af8b2ea508d5ded2570893f07.tar.gz brdo-b5c18e8a17024d4af8b2ea508d5ded2570893f07.tar.bz2 |
- Patch 5592 by Goba: introduced a new function, drupal_map_assoc().
-rw-r--r-- | includes/common.inc | 27 | ||||
-rw-r--r-- | modules/comment.module | 2 | ||||
-rw-r--r-- | modules/comment/comment.module | 2 | ||||
-rw-r--r-- | modules/node.module | 2 | ||||
-rw-r--r-- | modules/node/node.module | 2 | ||||
-rw-r--r-- | modules/watchdog.module | 3 | ||||
-rw-r--r-- | modules/watchdog/watchdog.module | 3 |
7 files changed, 35 insertions, 6 deletions
diff --git a/includes/common.inc b/includes/common.inc index 82c665179..8815458be 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1158,6 +1158,33 @@ function drupal_page_footer() { } /** + * Walks through the provided array and constructs an associative + * array out of it. The keys of the resulting array will be the + * values of the passed array. The values will either be the same + * (if no function was specified), or the results of the function + * given the value. + * + * @param $array An array + * @param $function A name of a function to apply to all values + */ +function drupal_map_assoc($array, $function = NULL) { + if (!isset($function)) { + $result = array(); + foreach ($array as $value) { + $result[$value] = $value; + } + return $result; + } + elseif (function_exists($function)) { + $result = array(); + foreach($array as $value) { + $result[$value] = $function($value); + } + return $result; + } +} + +/** * Wrapper around xml_parser_create() which extracts the encoding from the XML * data first and sets the output encoding to UTF-8. This function should be * used instead of xml_parser_create(), because PHP's XML parser doesn't check diff --git a/modules/comment.module b/modules/comment.module index ae6e0a1e3..a206023a3 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -1687,7 +1687,7 @@ function _comment_get_orders() { } function _comment_per_page() { - return array(10 => 10, 30 => 30, 50 => 50, 70 => 70, 90 => 90); + return drupal_map_assoc(array(10, 30, 50, 70, 90)); } ?> diff --git a/modules/comment/comment.module b/modules/comment/comment.module index ae6e0a1e3..a206023a3 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1687,7 +1687,7 @@ function _comment_get_orders() { } function _comment_per_page() { - return array(10 => 10, 30 => 30, 50 => 50, 70 => 70, 90 => 90); + return drupal_map_assoc(array(10, 30, 50, 70, 90)); } ?> diff --git a/modules/node.module b/modules/node.module index 9d513fe95..7a0632ccf 100644 --- a/modules/node.module +++ b/modules/node.module @@ -573,7 +573,7 @@ function node_search($keys) { } function node_settings() { - $output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t('The default maximum number of posts to display per page on overview pages such as the main page.')); + $output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default maximum number of posts to display per page on overview pages such as the main page.')); $output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 600), array(0 => t('Unlimited'), 200 => t('200 characters'), 400 => t('400 characters'), 600 => t('600 characters'), 800 => t('800 characters'), 1000 => t('1000 characters'), 1200 => t('1200 characters'), 1400 => t('1400 characters'), 1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 characters')), t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'.")); $output .= form_radios(t('Preview post'), 'node_preview', variable_get('node_preview', 0), array(t('Optional'), t('Required')), t('Must users preview posts before submitting?')); diff --git a/modules/node/node.module b/modules/node/node.module index 9d513fe95..7a0632ccf 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -573,7 +573,7 @@ function node_search($keys) { } function node_settings() { - $output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t('The default maximum number of posts to display per page on overview pages such as the main page.')); + $output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default maximum number of posts to display per page on overview pages such as the main page.')); $output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 600), array(0 => t('Unlimited'), 200 => t('200 characters'), 400 => t('400 characters'), 600 => t('600 characters'), 800 => t('800 characters'), 1000 => t('1000 characters'), 1200 => t('1200 characters'), 1400 => t('1400 characters'), 1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 characters')), t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'.")); $output .= form_radios(t('Preview post'), 'node_preview', variable_get('node_preview', 0), array(t('Optional'), t('Required')), t('Must users preview posts before submitting?')); diff --git a/modules/watchdog.module b/modules/watchdog.module index b0db2d3fd..20a47077e 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -65,7 +65,8 @@ function watchdog_link($type) { } function watchdog_settings() { - $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); + $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), "format_interval"); + $period[1000000000] = t('Never'); $output .= form_select(t("Discard entries older than"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); return $output; } diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index b0db2d3fd..20a47077e 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -65,7 +65,8 @@ function watchdog_link($type) { } function watchdog_settings() { - $period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); + $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), "format_interval"); + $period[1000000000] = t('Never'); $output .= form_select(t("Discard entries older than"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); return $output; } |