function globallink_get_pending_fields in GlobalLink Connect for Drupal 7.5
Same name and namespace in other branches
- 7.7 globallink.inc \globallink_get_pending_fields()
- 7.6 globallink.inc \globallink_get_pending_fields()
Gets pending fields by content type.
Parameters
string $content_type: The desired content type.
Return value
array Array of pending fields.
3 calls to globallink_get_pending_fields()
- globallink_field in ./
globallink_field_configuration.inc - Renders form for globallink_field.
- globallink_insert_all_fields in ./
globallink.module - Adds all fields of content type to field config.
- globallink_insert_gl_field_config in ./
globallink_field_configuration.inc - Inserts GlobalLink field configuration.
File
- ./
globallink.inc, line 762 - Miscellaneous GlobalLink functions for node translations (non-entity).
Code
function globallink_get_pending_fields($content_type, $entity_type = NULL) {
$_type = $content_type;
if ($entity_type == 'fieldable_panels_pane') {
$_type = 'fpp:' . $content_type;
}
else {
if ($entity_type == 'taxonomy_term') {
$_type = 'tax:' . $content_type;
}
}
$config_fields = globallink_get_config_fields($_type);
if ($entity_type == NULL || $entity_type == 'node') {
$field_info_arr = field_info_instances('node', $content_type);
$field_info_arr[] = array(
'field_name' => 'title',
'label' => 'Title',
);
}
else {
$field_info_arr = field_info_instances($entity_type, $content_type);
}
if (module_exists('metatag') && $entity_type != 'fieldable_panels_pane') {
$field_info_arr[] = array(
'field_name' => 'metatags',
'label' => 'Meta tags',
);
}
$field_arr = array();
foreach ($field_info_arr as $field_info) {
$field_name = $field_info['field_name'];
if ($field_name != 'metatag' && $field_name != 'title') {
$field = field_info_field($field_name);
if ($field['type'] != 'list_boolean' && $field['type'] != 'file' && $field['type'] != 'taxonomy_term_reference' && $field['type'] != 'entityreference') {
if (!isset($config_fields[$field_name])) {
$field_arr[$field_name] = $field_info['label'];
}
}
}
else {
if (!isset($config_fields[$field_name])) {
$field_arr[$field_name] = $field_info['label'];
}
}
}
asort($field_arr);
if (!entity_translation_node_supported_type($content_type)) {
return $field_arr;
}
else {
/*Added these changes for synching up the content type field configurations, with globallink field config. */
$ret_fields = array();
foreach ($field_arr as $key => $value) {
if ($key != 'metatags') {
$ret_fields[] = $key;
}
}
if (empty($ret_fields)) {
return $field_arr;
}
else {
$query = db_select('field_config', 'tf')
->fields('tf', array(
'field_name',
))
->condition('field_name', $ret_fields, 'IN')
->condition(db_or()
->condition(db_and()
->condition('translatable', '1', '='))
->condition(db_and()
->condition('type', 'image', '=')));
$results = $query
->execute();
$result = array();
foreach ($results as $row) {
foreach ($field_arr as $key => $value) {
if ($key == $row->field_name) {
$result[$row->field_name] = $row->field_name;
}
}
}
foreach ($field_arr as $key => $value) {
if ($key == 'metatags') {
$result[$key] = $value;
}
}
return $result;
}
}
}