text_field_load

Versions
7
text_field_load($obj_type, $objects, $field, $instances, $langcode, &$items)

Implement hook_field_load().

Where possible, generate the sanitized version of each field early so that it is cached in the field cache. This avoids looking up from the filter cache separately.

See also

text_field_sanitize()

Code

modules/field/modules/text/text.module, line 190

<?php
function text_field_load($obj_type, $objects, $field, $instances, $langcode, &$items) {
  foreach ($objects as $id => $object) {
    foreach ($items[$id] as $delta => $item) {
      if (!empty($instances[$id]['settings']['text_processing'])) {
        // Only process items with a cacheable format, the rest will be
        // handled by text_field_sanitize().
        $format_id = $item['format'];
        if (filter_format_allowcache($format_id)) {
          $items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format_id, $langcode) : '';
          if ($field['type'] == 'text_with_summary') {
            $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format_id, $langcode) : '';
          }
        }
      }
      else {
        $items[$id][$delta]['safe'] = check_plain($item['value']);
        if ($field['type'] == 'text_with_summary') {
          $items[$id][$delta]['safe_summary'] = check_plain($item['summary']);
        }
      }
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.