- Patch 5592 by Goba: introduced a new function, drupal_map_assoc().
parent
14b84fa299
commit
b5c18e8a17
|
@ -1157,6 +1157,33 @@ function drupal_page_footer() {
|
|||
module_invoke_all("exit");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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?'));
|
||||
|
||||
|
|
|
@ -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?'));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue