-
Notifications
You must be signed in to change notification settings - Fork 5
/
transcripts_ui.admin.inc
executable file
·65 lines (61 loc) · 2.86 KB
/
transcripts_ui.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
function transcripts_ui_admin()
{
$form = array();
$form['transcripts_ui_tier_settings'] = array(
'#title' => t('Transcript tiers'),
'#type' => 'fieldset',
'#collapsed' => FALSE,
);
$default_tiers = array(
'ts_content_epo' => 'Esperanto',
'ts_content_qya' => 'Quenya',
'ts_content_sjn' => 'Sindarin',
);
$form['transcripts_ui_tier_settings']['transcripts_ui_tiers'] = array(
'#title' => t('All tiers'),
'#type' => 'textarea',
'#rows' => 10,
'#default_value' => list_allowed_values_string(variable_get('transcripts_ui_tiers', $default_tiers)),
'#description' => t('Enter a list of all language tiers, one per line, each in the form TIER_ID|TIER_NAME.'),
'#required' => TRUE,
);
$default_hidden = array(
'ts_content_tlh' => 'Klingon',
);
$description = t('Enter a list of tiers that are hidden by default, one per line, each in the form TIER_ID|TIER_NAME. '
. 'In order for these tiers to not be positioned at the bottom of the list of languages, make sure that they are also '
. 'included in the list of all tiers above.');
$form['transcripts_ui_tier_settings']['transcripts_ui_hidden_tiers'] = array(
'#title' => t('Hidden tiers'),
'#type' => 'textarea',
'#rows' => 10,
'#default_value' => list_allowed_values_string(variable_get('transcripts_ui_hidden_tiers', $default_hidden)),
'#description' => $description,
'#required' => FALSE,
);
$default_speaker_names = array(
'@script' => 'Script',
'phonetic' => 'Phonetic',
);
$form['transcripts_ui_tier_settings']['transcripts_ui_speaker_names'] = array(
'#title' => t('Speaker names'),
'#type' => 'textarea',
'#rows' => 10,
'#default_value' => list_allowed_values_string(variable_get('transcripts_ui_speaker_names', $default_speaker_names)),
'#description' => t('Enter a list of speaker name display formats, one per line, each in the form SPEAKER_NAME_DISPLAY_ID|SPEAKER_NAME_DISPLAY_FORMAT.'),
'#required' => TRUE,
);
$form = system_settings_form($form);
array_unshift($form['#submit'], 'transcripts_ui_admin_submit');
return $form;
}
function transcripts_ui_admin_submit($form, &$form_state)
{
$tiers = list_extract_allowed_values($form_state['values']['transcripts_ui_tiers'], 'list_text', FALSE);
$hidden_tiers = list_extract_allowed_values($form_state['values']['transcripts_ui_hidden_tiers'], 'list_text', FALSE);
$speaker_names = list_extract_allowed_values($form_state['values']['transcripts_ui_speaker_names'], 'list_text', FALSE);
$form_state['values']['transcripts_ui_tiers'] = $tiers;
$form_state['values']['transcripts_ui_hidden_tiers'] = $hidden_tiers;
$form_state['values']['transcripts_ui_speaker_names'] = $speaker_names;
}