aboutsummaryrefslogtreecommitdiff
path: root/includes/preset.inc
blob: 1b0f6c499ddf165947f69d6323e61086889b8793 (plain)
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
<?php

//$Id$
/*
 * @file
 * Class file used to store video presets on the video.
 *
 */

class video_preset {

  private $presets;

  public function __construct($preset = null) {
    $this->presets = $preset;
    if (!isset($preset))
      $this->presets = variable_get('vid_preset', '');
//get our configured transcoder.
//    if (!isset($preset))
//      $preset = variable_get('vid_preset', 'flash_hq');
//    echo print_r($preset);
//    if (!module_load_include('inc', 'video', '/video_preset/' . $preset)) {
//      $modules = module_list();
//      foreach ($modules as $module) {
//        $mobule_files = array();
//        $module_path = drupal_get_path('module', $module) . '/video_preset';
//        $mobule_files = file_scan_directory($module_path, '^.*\.inc$');
//        if (is_array($mobule_files)) {
//          foreach ($mobule_files as $file) {
//            if ($file->name == $preset)
//              require_once $file->filename;
//          }
//        }
////
//      }
//    }
//    if (class_exists($preset)) {
//      $this->preset = new $preset;
//    } else {
//      drupal_set_message(t('The preset is not configured properly.'), 'error');
//    }
  }

  public function admin_settings() {
    $form = array();
    $options = $this->_preset();
    $form['vid_preset'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Video transcode presets'),
      '#options' => $options['radios'],
      '#default_value' => variable_get('vid_preset', array('status', 'promote')),
      '#description' => t('!list', array('!list' => theme('item_list', $options['help']))),
      '#prefix' => '<div id="preset-checkboxes">',
      '#suffix' => '</div>',
    );
//    $form = $form + $options['admin_settings'];
    return $form;
  }

  private function _preset($presets = null) {
// @TDOO : Observer will match in this case
    $files = array();
// Lets find our transcoder classes and build our radio options
// We do this by scanning our transcoders folder
    $form = array('radios' => array(), 'help' => array(), 'properties' => array());
    $path = drupal_get_path('module', 'video') . '/video_preset';
    $files = file_scan_directory($path, '/.*\.inc/');
// check inside sub modules
    $modules = module_list();
    foreach ($modules as $module) {
      $mobule_files = array();
      $module_path = drupal_get_path('module', $module) . '/video_preset';
      $mobule_files = file_scan_directory($module_path, '/.*\.inc/');
      $files = array_merge($files, $mobule_files);
    }

    foreach ($files as $file) {
      if (!module_load_include('inc', 'video', '/video_preset/' . $file->name))
        require_once $file->filename;
      $focus = new $file->name;
      $form['radios'][$focus->get_value()] = $focus->get_name();
      $form['help'][] = $focus->get_help();
//      $form['admin_settings'] = $form['admin_settings'] + $focus->admin_settings();
      if (is_array($presets) && !empty($presets[$focus->get_value()]))
        $form['properties'][$focus->get_value()] = $focus->get_properties();
//      echo $focus->get_value();
    }
    return $form;
  }

  public function properties() {
    $presets = $this->presets;
    $options = $this->_preset($presets);
    return $options['properties'];
  }

}

interface video_preset_interface {

  public function get_name();

  public function get_help();

  public function get_properties();
}