This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmediamosa_ck.admin.inc
181 lines (157 loc) · 6.39 KB
/
mediamosa_ck.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
* @file
* Any admin or user related code and hooks.
*/
/**
* The main configuration form for MediaMosa Construction Kit.
*
* Uses the hook_mediamosa_ck_configuration_collect() to collect settings.
*
* @return array
* An array representing the form definition.
*/
function mediamosa_ck_configuration_form() {
// Build the settings form and enrich it with our settings collect hook.
$form = system_settings_form(module_invoke_all('mediamosa_ck_configuration_collect'));
// Create group.
$form['mediamosa_ck_settings'] = array(
'#type' => 'vertical_tabs',
);
// Collect the titles.
$titles = array();
foreach ($form as $name => $item) {
if (empty($item['#type']) || $item['#type'] != 'fieldset') {
continue;
}
// Make sure the fieldset is collapsed.
$form[$name]['#collapsed'] = TRUE;
// Get the title for sorting.
$titles[$item['#title']] = $name;
// Add group type to fieldset.
$form[$name]['#group'] = 'mediamosa_ck_settings';
}
// Now sort on key.
ksort($titles, SORT_STRING);
// Now add weights.
$weight = -count($titles);
foreach ($titles as $name) {
$form[$name]['#weight'] = $weight++;
}
$form['mediamosa_ck_settings']['owner'] = array(
'#type' => 'fieldset',
'#title' => 'Ownership',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Setting to identify the owner in the MediaMosa'),
'#weight' => 10,
);
$form['mediamosa_ck_settings']['owner']['mediamosa_ck_asset_owner'] = array(
'#type' => 'radios',
'#title' => t('owner field'),
'#default_value' => variable_get('mediamosa_ck_asset_owner', 'mail'),
'#options' => array('name' => t('Drupal username'), 'mail' => t('Drupal user mail')),
'#description' => t('Either the user name or the user email address is used to store as owner of the asset.'),
);
// Add Transcodes settings here. This resides here instead of in the
// mediamosa_ck_transcode module, as this is an very important setting, and
// almost always used. The transcode module containes further transcoding
// functions, for advanced use.
$form['mediamosa_ck_settings']['transcode_profile'] = array(
'#type' => 'fieldset',
'#title' => 'Transcode profiles',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Setting page on how to use and restrict MediaMosa transcode profiles.'),
'#weight' => 11,
);
// Build up the options.
$options = array(
0 => t('Select default profile'),
);
$profiles = MediaMosaCkConnectorWrapper::get_transcode_profiles();
if ($profiles && isset($profiles->items->item)) {
foreach ($profiles->items->item as $profile) {
$options[(int) $profile->profile_id] = (string) $profile->profile;
}
}
$form['mediamosa_ck_settings']['transcode_profile']['mediamosa_ck_transcode_profile_default'] = array(
'#title' => t('Select your default transcode profile'),
'#description' => t('The default transcode profile is used by the player, to determine the most preferred mediafile to view.'),
'#type' => 'select',
'#options' => $options,
'#size' => 1,
'#default_value' => MediaMosaCkConnectorWrapper::get_default_transcode_profile(),
);
// Remove none for the allowed list.
unset($options[0]);
$form['mediamosa_ck_settings']['transcode_profile']['mediamosa_ck_transcode_profiles_allowed'] = array(
'#title' => t('Select your allowed transcode profiles'),
'#description' => t('By default, all transcodes are allowed.'),
'#size' => 20,
'#type' => 'select',
'#options' => $options,
'#multiple' => TRUE,
'#default_value' => array_keys(MediaMosaCkConnectorWrapper::get_allowed_transcode_profiles()),
);
// Start automatically transcodes?
$form['mediamosa_ck_settings']['mediamosa_ck_transcodes'] = array(
'#type' => 'fieldset',
'#description' => t('Select the transcode after any upload to MediaMosa in the application. This setting is used for basic upload and bulk upload.'),
'#title' => t('Automatic transcodes'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 12,
);
$default_transcode_profile = variable_get('mediamosa_ck_transcode_profile_default');
if (!isset($default_transcode_profile)) {
$default_transcode_profile = MediaMosaCkConnectorWrapper::get_default_transcode_profile();
}
$available_transcode_profiles = variable_get('mediamosa_ck_transcode_profiles_allowed');
$mediamosa_ck_transcodes = variable_get('mediamosa_ck_transcodes_autostart');
if (!isset($mediamosa_ck_transcodes)) {
$mediamosa_ck_transcodes = array($default_transcode_profile);
}
$form['mediamosa_ck_settings']['mediamosa_ck_transcodes']['mediamosa_ck_transcodes_autostart'] = array(
'#type' => 'checkboxes',
'#title' => t('Automatically start transcodes:'),
'#options' => $available_transcode_profiles,
'#default_value' => $mediamosa_ck_transcodes,
'#description' => 'The list is taken from the defined allowed profiles (see above)',
);
// Media view settings.
$form['mediamosa_ck_settings']['media_view'] = array(
'#type' => 'fieldset',
'#title' => 'View options',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Setting page for view options.'),
);
$form['mediamosa_ck_settings']['media_view']['mediamosa_ck_view_https'] = array(
'#title' => t('Force Mediamosa backend play/view requests to use https:// instead of http://.'),
'#description' => t('A view request to the backend will get a view object with links to media. Depending on the backend, this is served with http or https links. This option rewrites received http:// links with https://.'),
'#type' => 'checkbox',
'#default_value' => variable_get('mediamosa_ck_view_https', FALSE),
);
return $form;
}
/**
* Implements hook_form_validate().
*
* Form validation handler for main configuration form for MediaMosa
* Construction Kit.
*/
function mediamosa_ck_configuration_form_validate($form, &$form_state) {
// Call our (optional) validation hooks.
module_invoke_all('mediamosa_ck_configuration_collect_validate', $form, $form_state);
}
/**
* Implements hook_form_submit().
*
* Form submission handler for the main configuration form for MediaMosa
* Construction Kit.
*/
function mediamosa_ck_configuration_form_submit($form, &$form_state) {
// Call our (optional) submit hooks.
module_invoke_all('mediamosa_ck_configuration_collect_submit', $form, $form_state);
}