Révision 4444412d
Ajouté par Julien Enselme il y a environ 10 ans
drupal7/modules/node/node.tokens.inc | ||
---|---|---|
136 | 136 |
case 'body': |
137 | 137 |
case 'summary': |
138 | 138 |
if ($items = field_get_items('node', $node, 'body', $language_code)) { |
139 |
$column = ($name == 'body') ? 'value' : 'summary'; |
|
140 | 139 |
$instance = field_info_instance('node', 'body', $node->type); |
141 | 140 |
$field_langcode = field_language('node', $node, 'body', $language_code); |
142 |
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column]; |
|
141 |
// If the summary was requested and is not empty, use it. |
|
142 |
if ($name == 'summary' && !empty($items[0]['summary'])) { |
|
143 |
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'summary') : $items[0]['summary']; |
|
144 |
} |
|
145 |
// Attempt to provide a suitable version of the 'body' field. |
|
146 |
else { |
|
147 |
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value']; |
|
148 |
// A summary was requested. |
|
149 |
if ($name == 'summary') { |
|
150 |
if (isset($instance['display']['teaser']['settings']['trim_length'])) { |
|
151 |
$trim_length = $instance['display']['teaser']['settings']['trim_length']; |
|
152 |
} |
|
153 |
else { |
|
154 |
// Use default value. |
|
155 |
$trim_length = NULL; |
|
156 |
} |
|
157 |
// Generate an optionally trimmed summary of the body field. |
|
158 |
$output = text_summary($output, $instance['settings']['text_processing'] ? $items[0]['format'] : NULL, $trim_length); |
|
159 |
} |
|
160 |
} |
|
161 |
$replacements[$original] = $output; |
|
143 | 162 |
} |
144 | 163 |
break; |
145 | 164 |
|
Formats disponibles : Unified diff
Update drupal 7.27 -> 7.28