function gathercontent_gathercontent_process_content_pane in GatherContent 7.3
Parameters
EntityMetadataWrapper $node: Object of node.
int $gathercontent_id: ID of item in GatherContent.
string $local_field_name: Name of local Drupal field.
object $field: Object of GatherContent field.
string $content_type: Name of Content type, we are mapping to.
bool $is_translatable: Indicator if node is translatable.
string $language: Language of translation if applicable.
1 call to gathercontent_gathercontent_process_content_pane()
- _gathercontent_fetcher in ./
gathercontent.module - Helper function for fetching data from GatherContent.
File
- ./
gathercontent.module, line 726
Code
function gathercontent_gathercontent_process_content_pane(EntityMetadataWrapper &$node, $local_field_name, $field, $content_type, $is_translatable, $language, $files, &$_title_is_mapped = FALSE) {
$field_info = field_info_field($local_field_name);
$field_instances = field_info_instances('node', $content_type);
$field_settings = $field_instances[$local_field_name]['settings'];
$is_textfield = isset($field_settings['text_processing']) ? !$field_settings['text_processing'] : FALSE;
$is_translatable = $is_translatable && $field_info['translatable'];
switch ($field->type) {
case 'files':
gathercontent_gathercontent_process_files_field($node, $local_field_name, $field->name, $is_translatable, $language, $files);
break;
case 'choice_radio':
gathercontent_gathercontent_process_choice_radio_field($node, $local_field_name, $field->name, $is_translatable, $language, $field->options);
break;
case 'choice_checkbox':
gathercontent_gathercontent_process_choice_checkbox_field($node, $local_field_name, $field->name, $is_translatable, $language, $field->options);
break;
case 'section':
gathercontent_gathercontent_process_section_field($node, $local_field_name, $field->name, $is_translatable, $language, $field);
break;
default:
if ($local_field_name === 'title') {
$node->title
->set($field->value);
$_title_is_mapped = TRUE;
}
else {
if ($is_translatable) {
if (module_exists('title') && title_field_replacement_enabled('node', $content_type, 'title') && title_field_replacement_info('node', 'title')['field']['field_name'] === $local_field_name) {
// If we are setting title for default language,
// we set it just into title attribute and
// it's synced automatically.
// @see http://andrejgaluf.com/blog/2015-11-27/drupal-7-setting-title-module-field-programmatically
if ($language === $node->language
->value()) {
$node->title
->set($field->value);
}
else {
$node
->language($language)->{$local_field_name}
->set($field->value);
}
$_title_is_mapped = TRUE;
}
else {
if ($is_textfield) {
$node
->language($language)->{$local_field_name}
->set($field->value);
}
else {
$node
->language($language)->{$local_field_name}
->set(array(
'value' => $field->value,
'format' => $field->plain_text ? 'plain_text' : 'filtered_gathercontent_html',
));
}
}
}
else {
if (module_exists('title') && title_field_replacement_enabled('node', $content_type, 'title') && title_field_replacement_info('node', 'title')['field']['field_name'] === $local_field_name) {
// If we are setting title for default language,
// we set it just into title attribute and
// it's synced automatically.
// @see http://andrejgaluf.com/blog/2015-11-27/drupal-7-setting-title-module-field-programmatically
if ($language === $node->language
->value()) {
$node->title
->set($field->value);
}
else {
$node
->language($language)->{$local_field_name}
->set($field->value);
}
$_title_is_mapped = TRUE;
}
else {
if ($is_textfield) {
$node->{$local_field_name}
->set($field->value);
}
else {
$node->{$local_field_name}
->set(array(
'value' => $field->value,
'format' => $field->plain_text ? 'plain_text' : 'filtered_gathercontent_html',
));
}
}
}
}
break;
}
}