function lingotek_admin_content_defaults_form in Lingotek Translation 7.3
Content defaults Form
1 string reference to 'lingotek_admin_content_defaults_form'
File
- ./
lingotek.admin.inc, line 837
Code
function lingotek_admin_content_defaults_form($form, &$form_state, $show_fieldset = FALSE) {
$account = LingotekAccount::instance();
$api = LingotekApi::instance();
$site = variable_get('site_name', 'Drupal Site');
$is_enterprise = $account
->isEnterprise();
$workbench_moderation_enabled = FALSE;
if (module_exists('workbench_moderation')) {
$workbench_moderation_enabled = TRUE;
}
/*
* Default Settings
*/
$form['defaults'] = array(
'#type' => $show_fieldset ? 'fieldset' : 'item',
'#title' => t('Content Defaults'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'administrative_settings',
'actions' => array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => t('Save'),
),
),
'#submit' => array(
'lingotek_admin_content_defaults_form_submit',
),
);
$form['defaults'][] = array(
'#type' => 'item',
'#description' => t('Translation management defaults used when creating new nodes. At the node level, these settings can be adjusted.'),
);
// Upload
$form['defaults']['lingotek_create_documents_by_default'] = array(
'#type' => 'checkbox',
'#title' => t('Upload Content Automatically'),
'#default_value' => variable_get('lingotek_create_documents_by_default', 0),
//'#disabled' => !$is_enterprise,
'#description' => t('When enabled, your Drupal content (including saved edits) will automatically be uploaded to Lingotek for translation.<br/>When disabled, you are required to manually upload your content by clicking the "Upload" button on the Translations tab.'),
);
if ($workbench_moderation_enabled) {
$form['defaults']['lingotek_create_documents_by_default_workbench_moderation'] = array(
'#type' => 'select',
'#title' => 'Workbench Moderation Uploads',
'#options' => lingotek_get_workbench_moderation_states(),
'#default_value' => variable_get('lingotek_create_documents_by_default_workbench_moderation', workbench_moderation_state_published()),
'#states' => array(
'invisible' => array(
':input[name="lingotek_create_documents_by_default"]' => array(
'checked' => FALSE,
),
),
),
'#description' => 'The most recent revision will be automatically uploaded when changed to this state.',
);
}
// Download
$form['defaults']['lingotek_sync'] = array(
'#type' => 'checkbox',
'#title' => t('Download Translations Automatically'),
'#default_value' => variable_get('lingotek_sync', 1) !== 0 ? 1 : 0,
//'#disabled' => !$is_enterprise,
'#description' => t('When enabled, completed translations will automatically be downloaded from Lingotek.<br/>When disabled, you are required to manually download translations by clicking the "Download" button on the Translations tab.'),
);
if ($workbench_moderation_enabled) {
$transition_select = lingotek_workbench_moderation_get_mult_transitions();
$form['defaults']['lingotek_sync_wb']['wb_options'] = array(
'#type' => 'select',
'#title' => t('Workbench Moderation Downloads'),
// '#field_prefix' => t('After translations have downloaded'),
'#field_suffix' => t('after translations have downloaded.'),
'#options' => lingotek_get_workbench_moderation_options(),
'#default_value' => variable_get('lingotek_sync_workbench_moderation', 'no_moderation'),
'#description' => t("Transitions will not occur until <i>all</i> of a node's translations have downloaded."),
'#states' => array(
'invisible' => array(
':input[name="lingotek_sync"]' => array(
'checked' => FALSE,
),
),
),
);
if (!empty($transition_select)) {
$form['defaults']['lingotek_sync_wb']['wb_select'] = array(
'#type' => 'item',
'#title' => t('Your configuration of the Workbench Moderation module has multiple transition paths.<br>Choose the state that you would like the translations to transition to below.'),
'#states' => array(
'visible' => array(
'select[name="wb_options"]' => array(
'value' => 'increment',
),
':input[name="lingotek_sync"]' => array(
'checked' => TRUE,
),
),
),
);
$header = array(
'Current State',
'Transitions to',
);
$form['defaults']['lingotek_sync_wb']['wb_select']['wb_table'] = array(
'#type' => 'container',
'#theme' => 'table',
'#header' => $header,
'#rows' => array(),
);
foreach ($transition_select as $from_state => $to_states) {
$selected = variable_get('lingotek_sync_wb_select_' . $from_state);
// get default
$select_str = '<div class="form-item form-type-select form-item-lingotek-sync-wb-select-' . $from_state . '">';
// HTML for a Drupal form select element
$select_str .= '<select id="lingotek_sync_wb_select_' . $from_state . '" name="lingotek_sync_wb_select_' . $from_state . '"';
$select_str .= ' class="form-select">';
foreach ($to_states as $state) {
$select_str .= '<option ';
$select_str .= 'value="' . $state . '"';
if ($selected && $selected == $state) {
// select default
$select_str .= ' selected="selected"';
}
$select_str .= '>' . $state . '</option>';
}
// foreach option add to string
$select_str .= '</select></div>';
$form['defaults']['lingotek_sync_wb']['wb_select']['wb_table']['#rows'][] = array(
array(
'data' => $from_state,
'width' => '20%',
),
array(
'data' => $select_str,
'width' => '80%',
),
);
// Get out of _POST
}
}
}
if ($is_enterprise) {
// Community Translation
$form['defaults']['lingotek_allow_community_translation'] = array(
'#type' => 'checkbox',
'#title' => t('Allow Community Translation'),
'#description' => t('When enabled, anonymous site visitors will be presented with a link allowing them to contribute translations for this node.'),
'#default_value' => variable_get('lingotek_allow_community_translation', 0),
);
/*
* Misc. Options
*/
// URL Alias Translation.
$form['defaults']['lingotek_url_alias_translation'] = array(
'#type' => 'select',
'#title' => t('URL Alias Translation'),
'#description' => t("Choose how you would like to translate the URL alias. The last option requires that you install both the Title and Pathauto modules, and define a path pattern, and check \"Enable Lingotek Translation\" for the Title field."),
'#options' => lingotek_get_url_alias_translations(),
'#default_value' => variable_get('lingotek_url_alias_translation', 1),
);
// Projects
$projects = class_exists('LingotekApi') ? $api
->listProjects() : array();
$id = variable_get('lingotek_project', '');
if ($id == '' || !array_key_exists($id, $projects)) {
//No project id set, project deleted, or community changed to one without that project. Try to find the Drupal project
$id = array_search($site, $projects);
if ($id === False) {
//Setup a default Drupal project
$id = lingotek_add_project($site);
$projects = class_exists('LingotekApi') ? $api
->listProjects() : array();
}
else {
//Assign to an existing Drupal project
variable_set('lingotek_project', $id);
}
}
$form['defaults']['lingotek_project'] = array(
'#type' => 'select',
'#title' => t('Default Project'),
'#options' => $projects,
'#description' => t('The default Lingotek Project with which translations will be associated.'),
'#default_value' => $id,
);
// Workflows
if ($workflows = $api
->listWorkflows()) {
$form['defaults']['lingotek_workflow'] = array(
'#type' => 'select',
'#title' => t('Default Workflow'),
'#description' => t('The default Workflow to use when translating content.'),
'#default_value' => variable_get('lingotek_workflow', ''),
'#options' => $workflows,
);
}
$vaults = $api
->listVaults();
$current_vault_id = variable_get('lingotek_vault', '');
$personal_vault_count = isset($vaults['Personal Vaults']) ? count($vaults['Personal Vaults']) : 0;
$community_vault_count = isset($vaults['Community Vaults']) ? count($vaults['Community Vaults']) : 0;
// If no vault id is set, and we don't have any personal vaults, then create one and add it to our project.
if ($current_vault_id == '' && $personal_vault_count == 0 && $community_vault_count == 0) {
$current_project_id = variable_get('lingotek_project', '');
// But only if we have a ProjectID.
if ($current_project_id != '') {
$current_vault_id = lingotek_add_vault($site);
lingotek_add_vault_to_project();
}
}
$form['defaults']['lingotek_vault'] = array(
'#type' => 'select',
'#title' => t('Default Vault'),
'#options' => $vaults,
'#description' => t('The default Translation Memory Vault where translations are saved.'),
'#default_value' => $current_vault_id,
);
}
return $form;
}