[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/video/includes/ -> metadata.inc (source)

   1  <?php
   2  
   3  /*
   4   * @file
   5   * Class file used to store metadata on the video.
   6   * 
   7   */
   8  
   9  class video_metadata {
  10  
  11    private $metadata;
  12  
  13    public function __construct($metadata = null) {
  14      //get our configured transcoder.
  15      if (!isset($metadata))
  16        $metadata = variable_get('vid_metadata', 'flvtool2');
  17      if (!module_load_include('inc', 'video', '/metadata/' . $metadata)) {
  18        $modules = module_list();
  19        foreach ($modules as $module) {
  20          $mobule_files = array();
  21          $module_path = drupal_get_path('module', $module) . '/metadata';
  22          $mobule_files = file_scan_directory($module_path, '^.*\.inc$');
  23          if (is_array($mobule_files)) {
  24            foreach ($mobule_files as $file) {
  25              if ($file->name == $metadata)
  26                require_once $file->filename;
  27            }
  28          }
  29  //
  30        }
  31      }
  32      if (class_exists($metadata)) {
  33        $this->metadata = new $metadata;
  34      } else {
  35        drupal_set_message(t('The metadata is not configured properly.'), 'error');
  36      }
  37    }
  38  
  39    public function process($video) {
  40      $command_output = $this->metadata->process($video);
  41      return $command_output;
  42    }
  43  
  44    public function admin_settings() {
  45      $form = array();
  46      $form['video_metadata'] = array(
  47        '#type' => 'checkbox',
  48        '#title' => t('Enable Metadata'),
  49        '#default_value' => variable_get('video_metadata', FALSE),
  50        '#description' => t('Metadata is particularly useful in video, where information about its contents (such as transcripts of conversations and text descriptions of its scenes) are not directly understandable by a computer, but where efficient search is desirable.'),
  51      );
  52      $options = $this->_metadata();
  53      $form['vid_metadata'] = array(
  54        '#type' => 'radios',
  55        '#title' => t('Video Metadata'),
  56        '#default_value' => variable_get('vid_metadata', 'flvtool2'),
  57        '#options' => $options['radios'],
  58        '#description' => t('!list', array('!list' => theme('item_list', $options['help']))),
  59        '#prefix' => '<div id="metadata-radios">',
  60        '#suffix' => '</div>',
  61      );
  62      $form = $form + $options['admin_settings'];
  63      $form['video_metadata_dimensions'] = array(
  64        '#type' => 'textarea',
  65        '#title' => t('Selectable Dimensions when uploading videos'),
  66        '#description' => t('Enter one dimension per line as Video Resolutions.  Each resolution must be in the form of WxH where W=Width and H=Height in pixels.  Example dimensions are 1280x720.'),
  67        '#default_value' => variable_get("video_metadata_dimensions", video_default_dimensions()),
  68      );
  69  
  70      return $form;
  71    }
  72  
  73    private function _metadata() {
  74      $files = array();
  75      // Lets find our transcoder classes and build our radio options
  76      // We do this by scanning our transcoders folder
  77      $form = array('radios' => array(), 'help' => array(), 'admin_settings' => array());
  78      $path = drupal_get_path('module', 'video') . '/metadata';
  79      $files = file_scan_directory($path, '^.*\.inc$');
  80      // check inside sub modules
  81      $modules = module_list();
  82      foreach ($modules as $module) {
  83        $mobule_files = array();
  84        $module_path = drupal_get_path('module', $module) . '/metadata';
  85        $mobule_files = file_scan_directory($module_path, '^.*\.inc$');
  86        $files = array_merge($files, $mobule_files);
  87      }
  88  
  89      foreach ($files as $file) {
  90        if (!module_load_include('inc', 'video', '/metadata/' . $file->name))
  91          require_once $file->filename;
  92        $focus = new $file->name;
  93        $form['radios'][$focus->get_value()] = $focus->get_name();
  94        $form['help'][] = $focus->get_help();
  95        $form['admin_settings'] = $form['admin_settings'] + $focus->admin_settings();
  96      }
  97      return $form;
  98    }
  99  
 100    public function admin_settings_validate($form, $form_state) {
 101      return $this->metadata->admin_settings_validate($form, $form_state);
 102    }
 103  
 104  }
 105  
 106  interface metadata_interface {
 107  
 108    public function get_name();
 109  
 110    public function get_help();
 111  
 112    public function process($video);
 113  
 114    public function admin_settings();
 115  
 116    public function admin_settings_validate($form, &$form_state);
 117  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7