You are here

function readmorecontrol_field_requires_processing in Read More Control 7

A helper function to help determine if a field should be tested.

Checks the instance settings and field view access rights.

1 call to readmorecontrol_field_requires_processing()
readmorecontrol_entity_view in ./readmorecontrol.module
Extract, update or construct the read more link.

File

./readmorecontrol.module, line 295
Defines options to control how the Read more link is displayed on teasers.

Code

function readmorecontrol_field_requires_processing($entity_type, $entity, $field, $instance) {
  if (field_access('view', $field, $entity_type, $entity)) {

    // Test the default action to determine if we should use this field.
    switch ($entity->readmorebehaviour) {
      case 'when_required':

        // Check the field settings to see if this field is to be ignored.
        if ($behaviour = readmorecontrol_instance_settings($instance)) {
          return $behaviour == 'process';
        }
        return TRUE;
      case 'when_required_text':
        if (in_array($field['type'], array(
          'text_with_summary',
          'text_long',
        ))) {
          if ($behaviour = readmorecontrol_instance_settings($instance)) {
            return $behaviour == 'process';
          }
          return TRUE;
        }
        break;
      case 'when_required_body':
        if ($field['field_name'] == 'body') {
          if ($behaviour = readmorecontrol_instance_settings($instance)) {
            return $behaviour == 'process';
          }
          return TRUE;
        }
        break;
    }
  }
  return FALSE;
}