You are here

function lingotek_translatable_node_field_details in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.2 lingotek.util.inc \lingotek_translatable_node_field_details()
  2. 7.4 lingotek.util.inc \lingotek_translatable_node_field_details()

Goes though ALL the fields in the system and gets the details about the ones that are marked 'translatable'.

2 calls to lingotek_translatable_node_field_details()
lingotek_get_type_field_mapping in ./lingotek.dashboard.inc
Returns an array that maps a content_type to one (and just 1) of its translated fields. We can then use that array to track how many nodes have been translated.
lingotek_translatable_node_types in ./lingotek.util.inc
Content node types linked to 'translatable' fields.

File

./lingotek.util.inc, line 546
Utility functions.

Code

function lingotek_translatable_node_field_details() {
  $fields = field_info_fields();
  $translatable_fields = array();
  foreach ($fields as $field_id => $field) {
    foreach ($field['bundles'] as $type => $instance) {

      /*
       echo '<br>FieldID: ' . $field_id;
       echo '<br>Field: ' . $field;
       echo '<br>Type: ' . $type;
       echo '<br>Instance: ' . $instance;
      */
      if (field_is_translatable($type, $field)) {

        //echo '<br>Translatable: YES!' ;
        $field_db_table = array_keys($field['storage']['details']['sql']['FIELD_LOAD_CURRENT']);
        $field_db_table = array_shift($field_db_table);
        $translatable_fields[] = array(
          'entity_type' => $type,
          'machine_name' => $field['field_name'],
          'db_table' => $field_db_table,
          'bundles' => $field['bundles'][$type],
        );
      }

      //echo '<br>';
    }
  }

  /* Return data format
      array (
      0 =>
      array (
      'entity_type' => 'node',
      'machine_name' => 'body',
      'db_table' => 'field_data_body',
      'bundles' =>
      array (
      0 => 'page',
      1 => 'article',
      ),
      ),
      1 =>
      array (
      'entity_type' => 'node',
      'machine_name' => 'title_field',
      'db_table' => 'field_data_title_field',
      'bundles' =>
      array (
      0 => 'article',
      1 => 'page',
      ),
      ),
      )
     */
  return $translatable_fields;
}