[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/video/plugins/video_zencoder/ -> video_zencoder.install (source)

   1  <?php
   2  
   3  
   4  /**
   5   * @file
   6   * Provides installation functions for video_s3.module.
   7   */
   8  
   9  /**
  10   * Implementation of hook_schema().
  11   */
  12  function video_zencoder_schema() {
  13    $schema['video_zencoder'] = array(
  14      'description' => t('Store video s3 cdn and convert with zencoder webservice'),
  15      'fields' => array(
  16        'vid' => array(
  17          'description' => t('Auto Increment id'),
  18          'type' => 'serial',
  19          'unsigned' => TRUE,
  20          'not null' => TRUE,
  21        ),
  22        'fid' => array(
  23          'description' => t('Original file id'),
  24          'type' => 'int',
  25          'unsigned' => TRUE,
  26          'not null' => TRUE,
  27          'default' => 0,
  28        ),
  29        'nid' => array(
  30          'description' => t('Node id'),
  31          'type' => 'int',
  32          'unsigned' => TRUE,
  33          'not null' => TRUE,
  34          'default' => 0,
  35        ),
  36        'jobid' => array(
  37          'description' => t('Job id'),
  38          'type' => 'int',
  39          'unsigned' => TRUE,
  40          'not null' => TRUE,
  41          'default' => 0,
  42        ),
  43        'status' => array(
  44          'description' => t('Status of the cdn transfer'),
  45          'type' => 'int',
  46          'unsigned' => TRUE,
  47          'not null' => TRUE,
  48          'default' => 0,
  49        ),
  50        'dimensions' => array(
  51          'type' => 'varchar',
  52          'length' => '255',
  53          'default' => '',
  54          'description' => t('The dimensions of the video.'),
  55        ),
  56        'completed' => array(
  57          'description' => t('Time of successful completion to amazon.'),
  58          'type' => 'int',
  59          'not null' => TRUE,
  60          'default' => 0,
  61        ),
  62        'data' => array(
  63          'type' => 'text',
  64          'not null' => FALSE,
  65          'size' => 'big',
  66          'description' => 'A serialized array of converted files. Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
  67        ),
  68      ),
  69      'indexes' => array(
  70        'status' => array('status'),
  71        'file' => array('fid'),
  72      ),
  73      'primary key' => array('vid'),
  74    );
  75    return $schema;
  76  }
  77  
  78  /**
  79   * Implementation of hook_install().
  80   */
  81  function video_zencoder_install() {
  82    drupal_install_schema('video_zencoder');
  83    // set the module weight to low since we need this to load later time than in S3
  84    db_query("UPDATE {system} SET weight = 50 WHERE name = 'video_zencoder'");
  85  }
  86  
  87  /**
  88   * Implementation of hook_uninstall().
  89   */
  90  function video_zencoder_uninstall() {
  91    drupal_uninstall_schema('video_zencoder');
  92    // TODO : Delete our variables.
  93  }
  94  
  95  /**
  96  * Implementation of hook_requirements().
  97  */
  98  function video_zencoder_requirements($phase) {
  99    $t = get_t();
 100    $requirements = array();
 101    
 102    if (!module_exists('libraries')) {
 103      $requirements['video_zencoder_libraries'] = array(
 104        'title' => $t('Video Zencoder requirements'),
 105        'description' => $t('The <a href="@libraries-url">Libraries API</a> module is required to use the Video Zencoder module since version 4.8.', array('@libraries-url' => 'http://drupal.org/project/libraries')),
 106        'value' => l($t('Download'), 'http://drupal.org/project/libraries'),
 107        'severity' => REQUIREMENT_ERROR,
 108      );
 109    }
 110    else {
 111      $path = libraries_get_path('zencoder');
 112      $file = $path .'/Services/Zencoder.php';
 113  
 114      if (!is_dir($path)) {
 115        $requirements['video_zencoder_librarys'] = array(
 116          'title' => $t('Video Zencoder library'),
 117          'description' => $t('The <a href="@zencoder-library-url">Zencoder API library</a> must be installed to %libpath to use Zencoder to transcode videos.', array('@zencoder-library-url' => 'https://github.com/zencoder/zencoder-php', '%libpath' => $path)),
 118          'value' => l($t('Download'), 'https://github.com/zencoder/zencoder-php'),
 119          'severity' => REQUIREMENT_ERROR,
 120        );
 121      }
 122      elseif (!is_file($file)) {
 123        $requirements['video_zencoder_librariy'] = array(
 124          'title' => $t('Video Zencoder library'),
 125          'description' => $t('The directory %libpath is found, but the <a href="@zencoder-library-url">Zencoder API library</a> does not appear to be installed correctly, as the file %libfile is not found. Check if the library archive has been extracted correctly.', array('@zencoder-library-url' => 'https://github.com/zencoder/zencoder-php', '%libpath' => $path, '%libfile' => $file)),
 126          'value' => l($t('Download'), 'https://github.com/zencoder/zencoder-php'),
 127          'severity' => REQUIREMENT_ERROR,
 128        );
 129      }
 130      else {
 131        require_once $file;
 132        
 133        // Instantiate the Zencoder API to catch errors during initialization
 134        try {
 135          $temp = new Services_Zencoder();
 136          
 137          $version = str_replace('ZencoderPHP v', '', Services_Zencoder::USER_AGENT);
 138          
 139          $requirements['video_zencoder_library'] = array(
 140            'title' => $t('Video Zencoder library'),
 141            'value' => check_plain($version),
 142            'severity' => REQUIREMENT_OK,
 143          );
 144        }
 145        catch(Exception $e) {
 146          $requirements['video_zencoder_library'] = array(
 147            'title' => $t('Video Zencoder library'),
 148            'value' => $e->getMessage(),
 149            'severity' => REQUIREMENT_ERROR,
 150          );
 151        }
 152      }
 153    }
 154  
 155    return $requirements;
 156  }
 157  
 158  // ALTER TABLE `video_zencoder` ADD `dimensions` VARCHAR( 255 ) NULL AFTER `filesize` ;
 159  /**
 160   * Update 6401
 161   * Adding new dimentaion row to the table
 162   * @return <type>
 163   */
 164  function video_zencoder_update_6401() {
 165    $ret = array();
 166    // set settings column to accept larger values
 167    switch ($GLOBALS['db_type']) {
 168      case 'mysql':
 169      case 'mysqli':
 170        $ret[] = update_sql('ALTER TABLE {video_zencoder} ADD dimensions VARCHAR( 255 ) NULL NULL AFTER filesize');
 171        break;
 172  
 173      case 'pgsql':
 174        db_add_column($ret, 'video_zencoder', 'dimensions', 'VARCHAR', array('null' => TRUE));
 175        break;
 176    }
 177  
 178    return $ret;
 179  }
 180  
 181  /**
 182   * Update 6402
 183   * Adding data field and remove unwanted fields from the table
 184   * @return <type>
 185   */
 186  function video_zencoder_update_6402() {
 187    $ret = array();
 188    // drop un wanted fields in video zencoder
 189    db_drop_field($ret, 'video_zencoder', 'filesize');
 190    db_drop_field($ret, 'video_zencoder', 'outputid');
 191    db_drop_field($ret, 'video_zencoder', 'bucket');
 192    db_drop_field($ret, 'video_zencoder', 'filename');
 193    db_drop_field($ret, 'video_zencoder', 'filepath');
 194    db_drop_field($ret, 'video_zencoder', 'filemime');
 195    switch ($GLOBALS['db_type']) {
 196      case 'mysql':
 197      case 'mysqli':
 198        db_add_column($ret, 'video_zencoder', 'data', 'longtext', array('null' => TRUE));
 199        break;
 200      case 'pgsql':
 201        db_add_column($ret, 'video_zencoder', 'data', 'text', array('null' => TRUE));
 202        break;
 203    }  return $ret;
 204  }


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