function lingotek_form_alter in Lingotek Translation 7.4
Same name and namespace in other branches
- 8 lingotek.module \lingotek_form_alter()
- 8.2 lingotek.module \lingotek_form_alter()
- 6 lingotek.module \lingotek_form_alter()
- 4.0.x lingotek.module \lingotek_form_alter()
- 3.0.x lingotek.module \lingotek_form_alter()
- 3.1.x lingotek.module \lingotek_form_alter()
- 3.2.x lingotek.module \lingotek_form_alter()
- 3.3.x lingotek.module \lingotek_form_alter()
- 3.4.x lingotek.module \lingotek_form_alter()
- 3.5.x lingotek.module \lingotek_form_alter()
- 3.6.x lingotek.module \lingotek_form_alter()
- 3.7.x lingotek.module \lingotek_form_alter()
- 3.8.x lingotek.module \lingotek_form_alter()
File
- ./
lingotek.module, line 1988
Code
function lingotek_form_alter(&$form, &$form_state, $form_id) {
if (substr($form_id, -9) == 'node_form') {
//disable the language field if the node is synced with lingotek
if (isset($form['#entity']->nid)) {
$document_id = lingotek_lingonode($form['#entity']->nid, 'document_id');
if (isset($document_id) && $document_id != 0) {
$form['language']['#disabled'] = TRUE;
}
}
if (isset($form['#entity']->tnid) && $form['#entity']->tnid != 0 && $form['#entity']->nid != $form['#entity']->tnid) {
$content_type = $form['type']['#value'];
$lingotek_fields = variable_get('lingotek_enabled_fields');
foreach ($lingotek_fields['node'][$content_type] as $field) {
$form[$field]['#disabled'] = TRUE;
}
$lingotek_locale = Lingotek::convertDrupal2Lingotek($form['#entity']->language);
$node = lingotek_node_load_default($form['#entity']->tnid);
$workbench = 'node/' . $node->nid . '/lingotekworkbench/' . $lingotek_locale;
$message = t('Some fields are not editable because the translations are managed by lingotek.
To edit this content in the source language go to the ') . l(t('source node'), 'node/' . $form['#entity']->tnid . '/edit') . '.';
$link = l(t('Lingotek workbench'), $workbench, array(
'attributes' => array(
'target' => '_blank',
),
));
$message .= '<br>' . t('To make changes to this translation you can go to the !url.', array(
'!url' => $link,
));
drupal_set_message($message);
}
}
}