| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * @file 5 * Class file used to store video in the filesyetm as CDN or local. 6 * 7 */ 8 9 class video_filesystem { 10 11 private $filesystem; 12 13 public function __construct($filesystem = null) { 14 //get our configured transcoder. 15 if (!isset($filesystem)) 16 $filesystem = variable_get('vid_filesystem', 'drupal'); 17 if (!module_load_include('inc', 'video', '/filesystem/' . $filesystem)) { 18 $modules = module_list(); 19 foreach ($modules as $module) { 20 $mobule_files = array(); 21 $module_path = drupal_get_path('module', $module) . '/filesystem'; 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 == $filesystem) 26 require_once $file->filename; 27 } 28 } 29 } 30 } 31 if (class_exists($filesystem)) { 32 $this->filesystem = new $filesystem; 33 } else { 34 drupal_set_message(t('The file system is not configured properly.'), 'error'); 35 } 36 } 37 38 public function load_file(&$video) { 39 return $this->filesystem->load_file($video); 40 } 41 42 public function admin_settings() { 43 $fs = variable_get('vid_filesystem', 'drupal'); 44 $downloads = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC); 45 46 if ($downloads == FILE_DOWNLOADS_PRIVATE && empty($_POST['vid_filesystem'])) { 47 drupal_set_message(t('Storing videos in the Drupal file system is not supported when using <a href="@filesystem">private downloads</a>.', array('@filesystem' => url('admin/settings/file-system'))), $fs == 'drupal' ? 'error' : 'warn'); 48 } 49 50 $form = array(); 51 $options = $this->_filesystem(); 52 $form['vid_filesystem'] = array( 53 '#type' => 'radios', 54 '#title' => t('Video file system'), 55 '#default_value' => variable_get('vid_filesystem', 'drupal'), 56 '#options' => $options['radios'], 57 '#description' => t('!list', array('!list' => theme('item_list', $options['help']))), 58 '#prefix' => '<div id="filesystem-radios">', 59 '#suffix' => '</div>', 60 ); 61 $form = $form + $options['admin_settings']; 62 return $form; 63 } 64 65 private function _filesystem() { 66 $files = array(); 67 // Lets find our transcoder classes and build our radio options 68 // We do this by scanning our transcoders folder 69 $form = array('radios' => array(), 'help' => array(), 'admin_settings' => array()); 70 $path = drupal_get_path('module', 'video') . '/filesystem'; 71 $files = file_scan_directory($path, '^.*\.inc$'); 72 // check inside sub modules 73 $modules = module_list(); 74 foreach ($modules as $module) { 75 $mobule_files = array(); 76 $module_path = drupal_get_path('module', $module) . '/filesystem'; 77 $mobule_files = file_scan_directory($module_path, '^.*\.inc$'); 78 $files = array_merge($files, $mobule_files); 79 } 80 81 foreach ($files as $file) { 82 if (!module_load_include('inc', 'video', '/filesystem/' . $file->name)) 83 require_once $file->filename; 84 $focus = new $file->name; 85 $form['radios'][$focus->get_value()] = $focus->get_name(); 86 $form['help'][] = $focus->get_help(); 87 // creating div for each option 88 $form['video_' . $focus->get_value() . '_start'] = array( 89 'video_' . $focus->get_value() . '_start' => array( 90 '#type' => 'markup', 91 '#value' => '<div id="' . $focus->get_value() . '">', 92 ), 93 ); 94 $form['video_' . $focus->get_value() . '_end'] = array( 95 'video_' . $focus->get_value() . '_end' => array( 96 '#type' => 'markup', 97 '#value' => '</div>', 98 ), 99 ); 100 101 $form['admin_settings'] = $form['admin_settings'] + $form['video_' . $focus->get_value() . '_start'] + $focus->admin_settings() + $form['video_' . $focus->get_value() . '_end']; 102 } 103 return $form; 104 } 105 106 public function admin_settings_validate(&$form, &$form_state) { 107 return $this->filesystem->admin_settings_validate($form, $form_state); 108 } 109 110 } 111 112 interface filesystem_interface { 113 public function load_file($video); 114 115 public function get_value(); 116 117 public function get_name(); 118 119 public function get_help(); 120 121 public function admin_settings(); 122 123 public function admin_settings_validate($form, &$form_state); 124 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |