/[drupal]/contributions/modules/movino/optional/movino_admin.module
ViewVC logotype

Contents of /contributions/modules/movino/optional/movino_admin.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download) (as text)
Sun May 4 23:53:50 2008 UTC (18 months, 3 weeks ago) by tomsun
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, HEAD
Changes since 1.7: +76 -17 lines
File MIME type: text/x-php
Added new preview default image options, changed default sizes, added logo, bugfix: width and height mixed when player enabled on teaser.
1 <?php // $Id: movino_admin.module,v 1.7 2008/05/04 16:18:07 tomsun Exp $
2 /*
3 Movino Web Frontend - Admin interface
4 Copyright 2006, 2007 Tom Sundströšm
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20
21 /**
22 * Implementation of hook_help().
23 */
24 function movino_admin_help($section) {
25 switch ($section) {
26 case 'admin/help#help':
27 // TODO: expand
28 $output = '<p>'. t('The admin interface for Movino API. Needed initially, can safely be turned off once you are done configuring.') . '</p>';
29 return $output;
30 }
31 }
32
33
34 /**
35 * Implementation of hook_menu().
36 */
37 function movino_admin_menu($may_cache) {
38 global $user;
39 $items = array();
40
41 if (!$may_cache) {
42
43 $items[] = array(
44 'title' => t('Movino settings'),
45 'path' => 'admin/settings/movino',
46 'description' => t('Provides live video streaming capabilities.'),
47 'callback' => 'drupal_get_form',
48 'callback arguments' => array('movino_admin_general'),
49 'access' => user_access('administer Movino'),
50 );
51 $items[] = array(
52 'path' => 'admin/settings/movino/general',
53 'title' => t('General'),
54 'type' => MENU_DEFAULT_LOCAL_TASK,
55 'weight' => -10,
56 );
57 $items[] = array(
58 'path' => 'admin/settings/movino/servers',
59 'title' => t('Servers'),
60 'callback' => 'drupal_get_form',
61 'callback arguments' => array('movino_admin_servers'),
62 'access' => user_access('administer Movino'),
63 'type' => MENU_LOCAL_TASK,
64 'weight' => -5,
65 );
66 $items[] = array(
67 'path' => 'admin/settings/movino/servers/edit',
68 'title' => t('Edit Movino server'),
69 'type' => MENU_CALLBACK,
70 'callback' => 'drupal_get_form',
71 'callback arguments' => array('movino_admin_server_settings'),
72 'access' => user_access('administer Movino'),
73 'weight' => -10,
74 );
75 $items[] = array(
76 'path' => 'admin/settings/movino/servers/delete',
77 'title' => t('Delete Movino server'),
78 'type' => MENU_CALLBACK,
79 'callback' => 'movino_admin_server_delete_dialog',
80 'access' => user_access('administer Movino'),
81 );
82 $items[] = array(
83 'path' => 'admin/settings/movino/players',
84 'title' => t('Players'),
85 'callback' => 'drupal_get_form',
86 'callback arguments' => array('movino_admin_players'),
87 'access' => user_access('administer Movino'),
88 'type' => MENU_LOCAL_TASK,
89 );
90 $items[] = array(
91 'path' => 'admin/settings/movino/display',
92 'title' => t('Display settings'),
93 'callback' => 'drupal_get_form',
94 'callback arguments' => array('movino_admin_display'),
95 'access' => user_access('administer Movino'),
96 'type' => MENU_LOCAL_TASK,
97 'weight' => 1,
98 );
99 }
100 return $items;
101 }
102
103
104 /**
105 * Movino admin settings - general tab
106 */
107 function movino_admin_general() {
108
109 $row = array();
110 $row[] = array(t('Number of active videos in cache'), movino_get_video_count(), '');
111 $row[] = array(t('Number of dead videos'), movino_get_video_count(TRUE), t('<em>In cache but no longer available on server, thus marked as not active.<br />Live videos with archiving turned off will end up in this state when the stream ends.</em>'));
112
113 $form['movino_general'] = array(
114 '#type' => 'fieldset',
115 '#title' => t('Status'),
116 '#collapsible' => FALSE,
117 '#collapsed' => FALSE,
118 '#description' => theme('table', array('', '', ''), $row),
119 );
120
121 return system_settings_form($form);
122 }
123
124
125 /**
126 * Movino admin settings - server tab
127 */
128 function movino_admin_servers() {
129
130 $feedurls_description = <<<END
131 For performance reasons, feeds are divided into live and archive feeds.
132 <ul>
133 <li>Live feeds are loaded more frequently and should preferably be as light-weight as possible.</li>
134 <li>Archive feeds are only loaded when viewing an archive related page. Future versions of Movino might be able to cache archive feeds in the web interface database, in order to boost performace.</li>
135 </ul>
136 END;
137
138 $example_feed = <<<END
139 <feed>
140 <item>
141 <id>6</id>
142 <title>The newest live video</title>
143 <author>Author name</author>
144 <url>http://my.videoserver.com:1236</url>
145 <size>320x240</size>
146 <created>4123512352</created>
147 <length>540</length>
148 <encoding>ogg/vorbis/theora</encoding>
149 </item>
150 <item>
151 <id>5</id>
152 <url>http://my.videoserver.com:1235</url>
153 <size>320x240</size>
154 <created>2121512823</created>
155 <encoding>ogg/vorbis/theora</encoding>
156 </item>
157 </feed>
158 END;
159
160 $example_description = <<<END
161 <ul>
162 <li>The required attributes are <b>id</b>, <b>url</b>, <b>size</b>, <b>encoding</b> and <b>created</b>.</li>
163 <li>Each video should have an id that is unique within the feed. A feed id is added by the system to avoid collisions between feeds.</li>
164 <li>The length should be specified in seconds.</li>
165 <li>The created value is a Unix-style timestamp (seconds).</li>
166 <li>For live videos, length is the current number of seconds since the beginning of the broadcast.</li>
167 </ul>
168 END;
169
170 $servers = movino_get_servers();
171 $server_count = empty($servers) ? 0 : count($servers);
172
173 // Generate server list.
174 $server_list = '';
175 if (!empty($servers)) {
176 $rows = array();
177 foreach ($servers as $id => $server) {
178 if (empty($server['secret_key'])) {
179 $server['secret_key'] = movino_server_generate_secret_key($id);
180 }
181 $rows[] = array($server['name'], $server['description'], $server['id'], $server['secret_key'], $server['admin_links']);
182 }
183 $server_list .= theme('table', array(t('Server name'), t('Description'), t('Server id'), t('Secret key'), t('Tools')), $rows);
184 }
185
186 $form['movino_servers'] = array(
187 '#type' => 'fieldset',
188 '#title' => t('Movino Video Servers'),
189 '#collapsible' => FALSE,
190 '#collapsed' => FALSE,
191 '#description' => t('You have %count %server configured.', array(
192 '%count' => empty($server_count) ? 'no' : $server_count,
193 '%server' => format_plural($server_count, t('video server'), t('video servers'))
194 )) . '<br />' . l(t('Add a new server'), 'admin/settings/movino/servers/edit/new')
195 . (empty($server_list) ? '' : '<br /><br />' . $server_list),
196 );
197
198
199 $time_intervals = array(
200 0 => t('On every page load (not recommended)'),
201 3 => t('3 seconds'),
202 5 => t('5 seconds'),
203 10 => t('10 seconds'),
204 30 => t('30 seconds'),
205 60 => t('1 minute'),
206 120 => t('2 minutes'),
207 180 => t('3 minutes'),
208 240 => t('4 minutes'),
209 300 => t('5 minutes'),
210 600 => t('10 minutes'),
211 900 => t('15 minutes'),
212 1800 => t('30 minutes'),
213 3600 => t('1 hour'),
214 7200 => t('2 hours'),
215 10800 => t('3 hours'),
216 21600 => t('6 hours'),
217 43200 => t('12 hour'),
218 86400 => t('24 hours'),
219 );
220
221 $form['movino_feeds'] = array(
222 '#type' => 'fieldset',
223 '#title' => t('Feed settings'),
224 '#collapsible' => FALSE,
225 '#collapsed' => FALSE,
226 '#description' => 'Control how video server feeds are parsed. You can set minimum age for feeds to prevent excessive updating.',
227 );
228 $form['movino_feeds']['movino_feed_age_live'] = array(
229 '#type' => 'select',
230 '#title' => t('Update interval, live feeds'),
231 '#options' => $time_intervals,
232 '#default_value' => variable_get('movino_feed_age_live', 10),
233 );
234 $form['movino_feeds']['movino_feed_age_archive'] = array(
235 '#type' => 'select',
236 '#title' => t('Update interval, archive feeds'),
237 '#options' => $time_intervals,
238 '#default_value' => variable_get('movino_feed_age_archive', 300),
239 );
240
241 $form['movino_feeds']['movino_use_cron'] = array(
242 '#type' => 'radios',
243 '#title' => t('Use Cron to trigger update'),
244 '#options' => array(
245 0 => t('No'),
246 1 => t('Yes')
247 ),
248 '#default_value' => variable_get('movino_use_cron', 0),
249 '#description' => t('When using Cron to update feeds, you need to have a "cron job" scheduled to call Drupal\'s cron.php (see <a href="http://drupal.org/cron">http://drupal.org/cron</a> for details). The above "update interval" setting is effective only when set larger than or equal to the interval your cron job runs at. I.e. if your cron job runs once an hour, the feeds will update once an hour (or less often, but never more often).<br /><br />When not using Cron, the video feeds are checked before the rendering of any page.'),
250 );
251 $form['movino_feeds']['movino_use_dedicated_cron'] = array(
252 '#type' => 'radios',
253 '#title' => t('Enable dedicated Movino cron callback'),
254 '#options' => array(
255 0 => t('No'),
256 1 => t('Yes')
257 ),
258 '#default_value' => variable_get('movino_use_dedicated_cron', 0),
259 '#description' => t('Enables the <em>http://www.yoursite.com/movino/update</em> callback, which is useful if you want to set up a cron job that refreshes Movino feeds without doing other Drupal cron tasks.'),
260 );
261
262 $form['movino_feeds']['movino_unpublish'] = array(
263 '#type' => 'radios',
264 '#title' => t('Unpublish videos'),
265 '#options' => array(
266 0 => t('Never'),
267 1 => t('Always when missing from feeds'),
268 ),
269 '#default_value' => variable_get('movino_unpublish', 1),
270 '#description' => t('If you experience problems with feed parsing, use this option to keep the site content intact.'),
271 );
272
273 return system_settings_form($form);
274 }
275
276
277 /**
278 * Movino admin settings - players tab
279 */
280 function movino_admin_players() {
281
282 $players = movino_player_list();
283 $player_count = (empty($players) ? 0 : count($players));
284
285 $player_list = '';
286 if (!empty($players)) {
287 $rows = array();
288 foreach ($players as $player) {
289 $rows[] = array($player['#name'], $player['#description'], implode('<br />', $player['#supports']), (empty($player['#settings']) ? '' : l(t('Settings'), $player['#settings'])));
290 }
291 $player_list .= theme('table', array(t('Player name'), t('Description'), t('Supported formats'), t('Tools')), $rows);
292 }
293
294 $form['movino_players'] = array(
295 '#type' => 'fieldset',
296 '#title' => t('Movino Players'),
297 '#collapsible' => FALSE,
298 '#collapsed' => FALSE,
299 '#description' => t('You have %count %player configured.', array(
300 '%count' => empty($player_count) ? 'no' : $player_count,
301 '%player' => format_plural($player_count, t('player'), t('players'))
302 )) . (empty($player_list) ? '' : '<br /><br />' . $player_list),
303 );
304
305 return $form;
306 }
307
308
309 /**
310 * Form for adding or editing a server.
311 */
312 function movino_admin_server_settings() {
313
314 $settings_default = _movino_server_settings_defaults();
315 $id = arg(5);
316
317 if ($id != 'new') {
318 $server = movino_server_get($id);
319 }
320
321 if (!empty($id) && $id != 'new' && $server === FALSE) {
322 drupal_set_message('Invalid server id!', 'error');
323 drupal_access_denied();
324 }
325
326 if ($id == 'new') {
327 $settings = $settings_default;
328 }
329 else {
330 $settings = array_merge($settings_default, $server);
331 }
332
333 // Preserve the original id in case the user changes it.
334 $form['id_old'] = array(
335 '#type' => 'hidden',
336 '#value' => $id
337 );
338
339 $form['server'] = array(
340 '#type' => 'fieldset',
341 '#title' => t('Edit server'),
342 '#collapsible' => FALSE,
343 '#collapsed' => FALSE,
344 );
345 $form['server']['id'] = array(
346 '#type' => 'textfield',
347 '#title' => t('Server id'),
348 '#required' => TRUE,
349 '#size' => 40,
350 '#default_value' => $settings['id'],
351 '#description' => 'The internal id of the videoserver. Lowercase alphanumerical characters and \'-\' allowed.',
352 );
353 $form['server']['name'] = array(
354 '#type' => 'textfield',
355 '#title' => t('Server name'),
356 '#required' => TRUE,
357 '#size' => 40,
358 '#default_value' => $settings['name'],
359 '#description' => 'The name of the videoserver.',
360 );
361 $form['server']['description'] = array(
362 '#type' => 'textarea',
363 '#title' => t('Description'),
364 '#rows' => 3,
365 '#cols' => 40,
366 '#default_value' => $settings['description'],
367 '#description' => 'Description of the video server.',
368 );
369 $form['server']['host'] = array(
370 '#type' => 'textfield',
371 '#title' => t('Host name'),
372 '#required' => TRUE,
373 '#size' => 40,
374 '#default_value' => $settings['host'],
375 '#description' => 'Hostname or IP-adress of the video server (exclude http://).',
376 );
377
378 $form['server']['advanced'] = array(
379 '#type' => 'fieldset',
380 '#title' => t('Advanced server settings'),
381 '#description' => t('If you modify the default settings of the server, you might have to change these settings accordingly.'),
382 '#collapsible' => TRUE,
383 '#collapsed' => TRUE,
384 );
385
386 $form['server']['advanced']['live'] = array(
387 '#type' => 'fieldset',
388 '#title' => t('Live feed'),
389 '#collapsible' => FALSE,
390 '#collapsed' => FALSE,
391 );
392 $form['server']['advanced']['live']['feed_live'] = array(
393 '#type' => 'radios',
394 '#title' => t('Live videos enabled'),
395 '#required' => TRUE,
396 '#size' => 5,
397 '#options' => array(0 => t('No'), 1 => t('Yes')),
398 '#default_value' => $settings['feed_live'],
399 );
400 $form['server']['advanced']['live']['feed_live_port'] = array(
401 '#type' => 'textfield',
402 '#title' => t('Port'),
403 '#size' => 5,
404 '#default_value' => $settings['feed_live_port'],
405 '#description' => t('Default: @port', array('@port' => $settings_default['feed_live_port'])),
406 );
407 $form['server']['advanced']['live']['feed_live_path'] = array(
408 '#type' => 'textfield',
409 '#title' => t('Path'),
410 '#size' => 40,
411 '#default_value' => $settings['feed_live_path'],
412 '#description' => t('Default: @path', array('@path' => $settings_default['feed_live_path'])),
413 );
414
415 $form['server']['advanced']['archive'] = array(
416 '#type' => 'fieldset',
417 '#title' => t('Archive feed'),
418 '#collapsible' => FALSE,
419 '#collapsed' => FALSE,
420 );
421 $form['server']['advanced']['archive']['feed_archive'] = array(
422 '#type' => 'radios',
423 '#title' => t('Archived videos enabled'),
424 '#required' => TRUE,
425 '#size' => 5,
426 '#options' => array(0 => t('No'), 1 => t('Yes')),
427 '#default_value' => $settings['feed_archive'],
428 );
429 $form['server']['advanced']['archive']['feed_archive_port'] = array(
430 '#type' => 'textfield',
431 '#title' => t('Port'),
432 '#size' => 5,
433 '#default_value' => $settings['feed_archive_port'],
434 '#description' => t('Default: @port', array('@port' => $settings_default['feed_archive_port'])),
435 );
436 $form['server']['advanced']['archive']['feed_archive_path'] = array(
437 '#type' => 'textfield',
438 '#title' => t('Path'),
439 '#size' => 40,
440 '#default_value' => $settings['feed_archive_path'],
441 '#description' => t('Default: @path', array('@path' => $settings_default['feed_archive_path'])),
442 );
443
444 $form['server']['advanced']['upload'] = array(
445 '#type' => 'fieldset',
446 '#title' => t('Upload content'),
447 '#collapsible' => FALSE,
448 '#collapsed' => FALSE,
449 );
450 $form['server']['advanced']['upload']['source_port'] = array(
451 '#type' => 'textfield',
452 '#title' => t('Port'),
453 '#size' => 5,
454 '#default_value' => $settings['source_port'],
455 '#description' => t('Default: @port', array('@port' => $settings_default['source_port'])),
456 );
457
458 $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
459 if (!empty($_POST) && form_get_errors()) {
460 drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
461 }
462 $form['#base'] = 'movino_admin_server_settings';
463 $form['#redirect'] = 'admin/settings/movino/servers';
464 return $form;
465 }
466
467
468 /**
469 * Confirmation dialog for deleting a video server.
470 */
471 function movino_admin_server_delete_dialog() {
472 $op = $_REQUEST['op'];
473
474 $id = arg(5);
475 if (!movino_server_get($id)) {
476 drupal_set_message(t('Invalid Movino server id.'), 'error');
477 drupal_goto('admin/settings/movino/servers');
478 }
479
480 switch ($op) {
481 case 'delete':
482 movino_server_delete($id);
483 drupal_set_message(t('Movino server deleted.'));
484 drupal_goto('admin/settings/movino/servers');
485 break;
486
487 default:
488 $output .= "<p>Are you sure you want to delete this Movino video server?</p>\n";
489 $output .= '<div class="container-inline">';
490 $output .= l(t('Yes'), $_REQUEST['q'], array(), 'op=delete');
491 $output .= '&nbsp;&nbsp;&nbsp;' . l(t('No'), 'admin/settings/movino/servers');
492 $output .= "</div>\n";
493
494 return $output;
495 }
496 }
497
498
499 /**
500 * Validation of the form for adding or editing a server.
501 */
502 function movino_admin_server_settings_validate($form_id, $form_values) {
503 // Decide which server id to use.
504 $id = _movino_server_id($form_values['id']);
505 if (empty($id)) {
506 $id = _movino_server_id($form_values['name']);
507 }
508
509 if ($id == 'new') {
510 form_set_error('id', t("'new' is a reserved server id."));
511 }
512
513 if ($form_values['id_old'] == 'new' && movino_server_get($id)) {
514 form_set_error('id', t('Server id already exists. Server not created!'));
515 }
516
517 if ($form_values['id_old'] != 'new') {
518 if (!movino_server_get($form_values['id_old'])) {
519 form_set_error('id', t('Server does not exist!'));
520 }
521 if ($id != $form_values['id_old'] && movino_server_get($id)) {
522 form_set_error('id', t('The server id you tried to change to is taken!'));
523 }
524 }
525 }
526
527
528 /**
529 * Save a submitted server.
530 */
531 function movino_admin_server_settings_submit($form_id, $form_values) {
532
533 // Exclude unnecessary elements.
534 unset($form_values['submit'], $form_values['reset'], $form_values['form_id'], $form_values['op'], $form_values['form_token']);
535
536 // Decide which server id to use.
537 $id = _movino_server_id($id);
538 if (empty($id)) {
539 $id = _movino_server_id($form_values['name']);
540 }
541
542 if ($form_values['id_old'] == 'new') {
543 movino_server_insert($form_values);
544 } else {
545 movino_server_update($form_values);
546 }
547
548 }
549
550
551 /**
552 * Movino admin settings - display tab
553 */
554 function movino_admin_display() {
555
556 $form['movino_display_metadata'] = array(
557 '#type' => 'fieldset',
558 '#title' => t('Fields'),
559 '#collapsible' => TRUE,
560 '#collapsed' => FALSE,
561 '#description' => t('The metadata to be displayed. Note that the visibility of <i>@title</i>, <i>@author</i>, and <i>@created</i> is controlled by your theme settings when viewing videos as Drupal nodes.',
562 array('@title' => t('Title'), '@author' => t('Author'), '@created' => t('Created time'))),
563 );
564 $form['movino_display_metadata']['movino_metadata_teaser'] = array(
565 '#type' => 'checkboxes',
566 '#title' => t('Teaser fields'),
567 '#options' => movino_metadata(TRUE),
568 '#default_value' => movino_metadata_enabled(TRUE),
569 );
570 $form['movino_display_metadata']['movino_metadata_labels_enabled_teaser'] = array(
571 '#type' => 'checkboxes',
572 '#title' => t('Teaser labels'),
573 '#options' => movino_metadata(TRUE),
574 '#default_value' => movino_metadata_labels_enabled(TRUE),
575 '#suffix' => '<br />',
576 );
577 $form['movino_display_metadata']['movino_metadata_page'] = array(
578 '#type' => 'checkboxes',
579 '#title' => t('Page fields'),
580 '#options' => movino_metadata(),
581 '#default_value' => movino_metadata_enabled(),
582 );
583 $form['movino_display_metadata']['movino_metadata_labels_enabled_page'] = array(
584 '#type' => 'checkboxes',
585 '#title' => t('Page labels'),
586 '#options' => movino_metadata(),
587 '#default_value' => movino_metadata_labels_enabled(),
588 );
589
590
591 $form['movino_display_previews'] = array(
592 '#type' => 'fieldset',
593 '#title' => t('Preview images and icons'),
594 '#collapsible' => TRUE,
595 '#collapsed' => FALSE,
596 );
597 $form['movino_display_previews']['movino_display_preview_width'] = array(
598 '#type' => 'textfield',
599 '#title' => t('Icon width'),
600 '#size' => 3,
601 '#default_value' => variable_get('movino_display_preview_width', 320),
602 '#description' => 'Number of pixels. Default: 320',
603 );
604 $form['movino_display_previews']['movino_display_preview_height'] = array(
605 '#type' => 'textfield',
606 '#title' => t('Icon height'),
607 '#size' => 3,
608 '#default_value' => variable_get('movino_display_preview_height', 240),
609 '#description' => 'Number of pixels. Default: 240',
610 );
611 $form['movino_display_previews']['movino_display_archive_previews'] = array(
612 '#type' => 'radios',
613 '#title' => t('Use previews'),
614 '#default_value' => variable_get('movino_display_archive_previews', 1),
615 '#options' => array(t('No'), t('Yes')),
616 '#description' => t('A random snapshot from the video stream replaces the icon if the video server supports this feature.'),
617 );
618 $form['movino_display_previews']['movino_display_preview_default_image'] = array(
619 '#type' => 'select',
620 '#title' => t('Image to use use when no video snapshot is available'),
621 '#options' => _movino_admin_get_default_icons(),
622 '#default_value' => variable_get('movino-logo.png', ''),
623 '#description' => t('Optionally add more options to @path', array('@path' => drupal_get_path('module', 'movino_player_flv') . '/preview')),
624 );
625
626
627 $form['movino_display_player'] = array(
628 '#type' => 'fieldset',
629 '#title' => t('Embedded player'),
630 '#collapsible' => TRUE,
631 '#collapsed' => FALSE,
632 );
633 $form['movino_display_player']['movino_display_player_override_size_teaser'] = array(
634 '#type' => 'checkbox',
635 '#title' => t('Override player size on teasers'),
636 '#default_value' => variable_get('movino_display_player_override_size_teaser', 1),
637 '#description' => 'Check to scale all Movino videos to the same size in the browser.',
638 );
639 $form['movino_display_player']['movino_display_player_width_teaser'] = array(
640 '#type' => 'textfield',
641 '#title' => t('Width'),
642 '#size' => 3,
643 '#default_value' => variable_get('movino_display_player_width_teaser', 320),
644 '#description' => 'Number of pixels. Default: 320',
645 );
646 $form['movino_display_player']['movino_display_player_height_teaser'] = array(
647 '#type' => 'textfield',
648 '#title' => t('Height'),
649 '#size' => 3,
650 '#default_value' => variable_get('movino_display_player_height_teaser', 240),
651 '#description' => 'Number of pixels. Default: 240',
652 );
653
654 $form['movino_display_player']['movino_display_player_override_size_page'] = array(
655 '#type' => 'checkbox',
656 '#title' => t('Override player size on pages'),
657 '#default_value' => variable_get('movino_display_player_override_size_page', 1),
658 '#description' => 'Check to scale all Movino videos to the same size in the browser.',
659 );
660 $form['movino_display_player']['movino_display_player_width_page'] = array(
661 '#type' => 'textfield',
662 '#title' => t('Width'),
663 '#size' => 3,
664 '#default_value' => variable_get('movino_display_player_width_page', 320),
665 '#description' => 'Number of pixels. Default: 320',
666 );
667 $form['movino_display_player']['movino_display_player_height_page'] = array(
668 '#type' => 'textfield',
669 '#title' => t('Height'),
670 '#size' => 3,
671 '#default_value' => variable_get('movino_display_player_height_page', 240),
672 '#description' => 'Number of pixels. Default: 240',
673 );
674
675 $form['movino_display_movino'] = array(
676 '#type' => 'fieldset',
677 '#title' => t('Powered by Movino'),
678 '#collapsible' => TRUE,
679 '#collapsed' => FALSE,
680 '#description' => 'If you want to, feel free to link back to movino.org. A few preconfigured way of doing that:',
681 );
682 $form['movino_display_movino']['movino_display_movino_overlay_logo'] = array(
683 '#type' => 'checkbox',
684 '#title' => t('Add logo overlay'),
685 '#default_value' => variable_get('movino_display_movino_overlay_logo', 1),
686 '#description' => 'When possible, works with JW FLV Media Player.',
687 );
688 $form['movino_display_movino']['movino_display_movino_metadata_button'] = array(
689 '#type' => 'checkbox',
690 '#title' => t('Add a button in metadata'),
691 '#default_value' => variable_get('movino_display_movino_metadata_button', 1),
692 );
693
694
695 return system_settings_form($form);
696 }
697
698 function _movino_admin_get_default_icons($path = NULL, $prefix = '') {
699
700 if ($path == NULL) {
701 $path = drupal_get_path('module', 'movino') . '/preview';
702 }
703 $result = array();
704 $subdirs = array();
705
706 $fh = opendir($path);
707 while ($file = readdir($fh)) {
708 if ($file != "." && $file != "..") {
709 if(is_dir($path."/".$file)) {
710 // Found subdirectory.
711 $subdirs[] = $file;
712 } elseif (in_array(strtolower(substr($file, strlen($file) - 4)), array('.swf', '.png', '.gif'))) {
713 // Found image file
714 $result[$prefix . $file] = $prefix . $file;
715 }
716 }
717 }
718 closedir($fh);
719
720 if (!empty($subdirs)) {
721 foreach($subdirs as $dir) {
722 $subresult = _movino_admin_get_default_icons($path . '/' . $dir, $dir . '/');
723 if (!empty($subresult)) {
724 $result = array_merge($result, $subresult);
725 }
726 }
727 }
728
729 return $result;
730 }

  ViewVC Help
Powered by ViewVC 1.1.2