Révision e4c061ad
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc | ||
---|---|---|
118 | 118 |
$field_settings = array( |
119 | 119 |
'label' => $label, |
120 | 120 |
'type' => $conf['formatter'], |
121 |
// Pass all entity field panes settings to field display settings. |
|
122 |
'pane_settings' => $conf, |
|
121 | 123 |
); |
122 | 124 |
|
123 | 125 |
// Get the field output, and the title. |
... | ... | |
127 | 129 |
|
128 | 130 |
$all_values = field_get_items($entity_type, $entity, $field_name, $language); |
129 | 131 |
if (!is_array($all_values)) { |
130 |
$all_values = array(); |
|
132 |
// Do not render if the field is empty. |
|
133 |
return; |
|
131 | 134 |
} |
132 | 135 |
|
133 | 136 |
// Reverse values. |
134 | 137 |
if (isset($conf['delta_reversed']) && $conf['delta_reversed']) { |
135 |
$all_values = array_reverse($all_values); |
|
138 |
$all_values = array_reverse($all_values, TRUE);
|
|
136 | 139 |
} |
137 | 140 |
|
138 | 141 |
if (isset($conf['delta_limit'])) { |
139 |
$delta_limit = $conf['delta_limit']; |
|
140 | 142 |
$offset = intval($conf['delta_offset']); |
141 |
$total = count($all_values); |
|
142 |
|
|
143 |
if ($delta_limit == 0) { |
|
144 |
$delta_limit = $total - $offset; |
|
145 |
} |
|
146 |
|
|
147 |
$new_values = array(); |
|
148 |
for ($i = 0; $i < $delta_limit; $i++) { |
|
149 |
$new_delta = $offset + $i; |
|
150 |
|
|
151 |
if (isset($all_values[$new_delta])) { |
|
152 |
$new_values[] = $all_values[$new_delta]; |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
$all_values = $new_values; |
|
143 |
$limit = !empty($conf['delta_limit']) ? $conf['delta_limit'] : NULL; |
|
144 |
$all_values = array_slice($all_values, $offset, $limit, TRUE); |
|
157 | 145 |
} |
158 | 146 |
|
159 | 147 |
$clone = clone $entity; |
... | ... | |
263 | 251 |
} |
264 | 252 |
|
265 | 253 |
/** |
266 |
* Returns the administrative title for a type. |
|
267 |
*/ |
|
254 |
* Returns the administrative title for a type.
|
|
255 |
*/
|
|
268 | 256 |
function ctools_entity_field_content_type_admin_title($subtype, $conf, $context) { |
269 | 257 |
list($bundle, $field_name) = explode(':', $subtype); |
270 | 258 |
ctools_include('fields'); |
271 |
return t('"@s" @field', array('@s' => $context->identifier, '@field' => ctools_field_label($field_name))); |
|
259 |
if (is_object($context) && isset($context->identifier)) { |
|
260 |
$identifier = $context->identifier; |
|
261 |
} |
|
262 |
else { |
|
263 |
$type = 'ctools_entity_field_content_type_admin_title'; |
|
264 |
$message = t('Context is missing for field: @name', array('@name' => $subtype)); |
|
265 |
$variables = array($subtype, $conf, $context); |
|
266 |
watchdog($type, $message, $variables, $severity = WATCHDOG_NOTICE); |
|
267 |
$identifier = t('Unknown'); |
|
268 |
} |
|
269 |
|
|
270 |
return t('"@s" @field', array('@s' => $identifier, '@field' => ctools_field_label($field_name))); |
|
272 | 271 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules