Project

General

Profile

Revision 01f36513

Added by Assos Assos about 6 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/i18n/i18n_sync/i18n_sync.module
91 91

  
92 92
    $form['i18n_sync']['i18n_sync_node_type'] = array(
93 93
      '#tree' => TRUE,
94
      '#weight' => 1,
94 95
    );
95 96

  
96 97
    // Each set provides title and options. We build a big checkboxes control for it to be
......
121 122
        );
122 123
      }
123 124
    }
125

  
126
    // Add option to restrict syncing only when editing the translation source.
127
    $form['i18n_sync']['i18n_sync_source_description'] = array(
128
      '#prefix' => '<div>', '#suffix' => '</div>',
129
      '#markup' => t('Restrict synchronization to the translation source.'),
130
      '#weight' => 2,
131
    );
132
    $form['i18n_sync']['i18n_sync_source'] = array(
133
      '#type' => 'checkbox',
134
      '#title' => t('Synchronize translations only when saving the translation source'),
135
      '#default_value' => variable_get('i18n_sync_source_' . $type, FALSE),
136
      '#disabled' => $disabled,
137
      '#weight' => 3,
138
      '#description' => t('If not checked each node will trigger the synchronization, whether it\'s the source or not.'),
139
    );
124 140
  }
125 141
}
126 142

  
......
167 183
 */
168 184
function i18n_sync_node_update($node) {
169 185
  // Let's go with field synchronization.
170
  if (i18n_sync_node_check($node) && !empty($node->tnid) && ($fields = i18n_sync_node_fields($node->type)) && ($translations = i18n_sync_node_get_translations($node, TRUE))) {
171
    module_load_include('node.inc', 'i18n_sync');
172
    i18n_sync_node_translation($node, $translations, $fields, 'update');
186
  if (i18n_sync_node_check($node) && !empty($node->tnid) && (!variable_get('i18n_sync_source_' . $node->type, TRUE) || $node->tnid == $node->nid) && ($fields = i18n_sync_node_fields($node->type)) && ($translations = i18n_sync_node_get_translations($node, TRUE))) {
187
    $do_sync = TRUE;
188
    if (module_exists('entity_translation')) {
189
      if (entity_translation_enabled_bundle('node', $node->type)) {
190
        $do_sync = FALSE;
191
      }
192
    }
193
    if ($do_sync) {
194
      module_load_include('node.inc', 'i18n_sync');
195
      i18n_sync_node_translation($node, $translations, $fields, 'update');
196
    }
173 197
  }
174 198
}
175 199

  

Also available in: Unified diff