From f0b3fa4b1bb0b8c91424c3ad36dfef592ccbc954 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 8 Aug 2010 13:02:37 +0000 Subject: - Patch #504564 by tic2000, andypost, catch: the 'Length of trimmed content' form input in the 'node type' edit form was way too harsh (affects the display of all 'trimmed / summary_or_trimmed' formatters on all text fields in all view modes), and irrelevant for text fields on non-node entities, which are currently all blocked to 'trim to 600 chars'. * Added field formatter settings for 'text_trimmed' and 'text_summary_or_trimmed' formatters * Removed 'teaser_length' settings for node types * Added upgrade path for 'teaser_length' variable in node_update_7011() * Fixed a test --- modules/node/node.install | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'modules/node/node.install') diff --git a/modules/node/node.install b/modules/node/node.install index b5e10d6b0..cc3d8ee97 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -496,11 +496,29 @@ function node_update_7006(&$sandbox) { ->fields('node_type') ->execute(); + $default_trim_length = variable_get('teaser_length', 600); // Add body field instances for existing node types. foreach ($result as $node_type) { if ($node_type->has_body) { - node_add_body_field($node_type, $node_type->body_label); + $instance = node_add_body_field($node_type, $node_type->body_label); + // Update newly created instance to convert teaser_length variable + // into formatter settings. + $trim_length = variable_get('teaser_length_' . $node_type->type, $default_trim_length); + $instance_changed = FALSE; + foreach ($instance['display'] as $view_mode => $view_mode_info) { + if ($view_mode_info['type'] == 'text_trimmed' || $view_mode_info['type'] == 'text_summary_or_trimmed') { + if (!isset($view_mode_info['settings']['trim_length'])) { + $instance['display'][$view_mode]['settings']['trim_length'] = $trim_length; + $instance_changed = TRUE; + } + } + } + if ($instance_changed) { + field_update_instance($instance); + } + variable_del('teaser_length_' . $node_type->type); } + // Leave 'teaser_length' variable for aggregator module upgrade. $sandbox['node_types_info'][$node_type->type] = array( 'has_body' => $node_type->has_body, -- cgit v1.2.3