You are here

function node_convert_format_field_value in Node Convert 7

Returns a string containing the value of the $field from the $node object.

Parameters

$node: A $node object

$field: The field who's value to get.

bool $no_labels Returns values only.:

Return value

string A string containing the value of the $field from the $node object.

2 calls to node_convert_format_field_value()
node_convert_conversion_form in ./node_convert.forms.inc
Node conversion form.
node_convert_field_convert in ./node_convert.util.inc
Transfers information from source_field to dest_field.

File

./node_convert.util.inc, line 299
API and Utility Functions.

Code

function node_convert_format_field_value($node, $field, $no_labels = FALSE) {

  /* @var $field_values Array */
  $field_values = field_get_items('node', $node, $field['field_name']);
  $options = array();
  if ($field['type'] == 'text') {
    $options = array(
      'singular_label' => 'Text',
      'plural_label' => 'Texts',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'text_with_summary') {
    $options = array(
      'singular_label' => 'Text w/Summary',
      'plural_label' => 'Texts w/Summary',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'image') {
    $options = array(
      'singular_label' => 'File ID',
      'plural_label' => 'File IDs',
      'columns' => array(
        'fid',
        'Title' => 'title',
        'URI' => 'uri',
      ),
    );
  }
  elseif ($field['type'] == 'link_field') {
    $options = array(
      'singular_label' => 'Link',
      'plural_label' => 'Links',
      'columns' => array(
        'url',
        'title',
      ),
    );
  }
  elseif ($field['type'] == "email") {
    $options = array(
      'singular_label' => 'Email',
      'plural_label' => 'Emails',
      'columns' => array(
        'email',
      ),
    );
  }
  elseif ($field['type'] == 'file') {
    $options = array(
      'singular_label' => 'File ID',
      'plural_label' => 'File IDs',
      'columns' => array(
        'fid',
        'URI' => 'uri',
      ),
    );
  }
  elseif ($field['type'] == 'taxonomy_term_reference') {
    $options = array(
      'singular_label' => 'Term ID',
      'plural_label' => 'Term IDs',
      'columns' => array(
        'tid',
      ),
    );
  }
  elseif ($field['type'] == 'node_reference') {
    $options = array(
      'singular_label' => 'Node ID',
      'plural_label' => 'Node IDs',
      'columns' => array(
        'nid',
      ),
    );
  }
  elseif ($field['type'] == 'user_reference') {
    $options = array(
      'singular_label' => 'User ID',
      'plural_label' => 'User IDs',
      'columns' => array(
        'uid',
      ),
    );
  }
  elseif ($field['type'] == 'entityreference') {
    $options = array(
      'singular_label' => 'Entity ID',
      'plural_label' => 'Entity IDs',
      'columns' => array(
        'target_id',
      ),
      'prefix_label' => 'Entity Type: ' . $field['settings']['target_type'],
    );
  }
  elseif ($field['type'] == 'date') {
    $options = array(
      'singular_label' => 'Date',
      'plural_label' => 'Dates',
      'columns' => array(
        'value',
        'timezone',
      ),
    );
  }
  elseif ($field['type'] == 'datestamp') {
    $options = array(
      'singular_label' => 'Date-stamp',
      'plural_label' => 'Date-stamps',
      'columns' => array(
        'value',
        'timezone',
      ),
    );
  }
  elseif ($field['type'] == 'datetime') {
    $options = array(
      'singular_label' => 'Date-time',
      'plural_label' => 'Date-time',
      'columns' => array(
        'value',
        'timezone',
      ),
    );
  }
  elseif ($field['type'] == 'number_decimal') {
    $options = array(
      'singular_label' => 'Decimal',
      'plural_label' => 'Decimals',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'number_float') {
    $options = array(
      'singular_label' => 'Float',
      'plural_label' => 'Floats',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'number_integer') {
    $options = array(
      'singular_label' => 'Integer',
      'plural_label' => 'Integers',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'list_boolean') {
    $options = array(
      'singular_label' => 'List Boolean',
      'plural_label' => 'List Booleans',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'list_float') {
    $options = array(
      'singular_label' => 'List Float',
      'plural_label' => 'List Floats',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'list_integer') {
    $options = array(
      'singular_label' => 'List Integer',
      'plural_label' => 'List Integers',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif ($field['type'] == 'list_text') {
    $options = array(
      'singular_label' => 'List Text',
      'plural_label' => 'List Texts',
      'columns' => array(
        'value',
      ),
    );
  }
  elseif (isset($field_values[0]['value'])) {
    $options['columns'] = array(
      'value',
    );

    //$value = t("Unknown field format, can't display field value.");
  }
  else {
    $unknown_format = TRUE;
  }

  // It's a known format, show the value.
  if (!isset($unknown_format)) {
    $options += array(
      'no_labels' => $no_labels,
    );
    $value = node_convert_format_field_value_helper($field_values, $options);
  }
  else {

    // Format is not known, and we should show the error message.
    if (!$no_labels) {
      $value = t("Unknown field format, can't display field value.");
    }
    else {
      $value = '';
    }
  }
  return $value;
}