aboutsummaryrefslogtreecommitdiff
path: root/video.install
blob: b640bc982a11781beafda9405d4217f6f7a6a81f (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?php
/**
 * Implementation of hook_schema().
 */
function video_schema() {
  $schema['video'] = array(
    'description' => t('TODO'),
    'fields' => array(
      'vid' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'vtype' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'vidfile' => array(
        'description' => t('TODO'),
        'type' => 'text',
        'not null' => TRUE,
        'default' => '',
      ),
      'videox' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'videoy' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'size' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'download_counter' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'play_counter' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'video_bitrate' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'audio_bitrate' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'audio_sampling_rate' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'audio_channels' => array(
        'description' => t('TODO'),
        'type' => 'unknown',
        'not null' => FALSE,
      ),
      'playtime_seconds' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'download_folder' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'disable_multidownload' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'use_play_folder' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'custom_field_1' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'custom_field_2' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'custom_field_3' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'custom_field_4' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'custom_field_5' => array(
        'description' => t('TODO'),
        'type' => 'text',
        'not null' => FALSE,
      ),
      'custom_field_6' => array(
        'description' => t('TODO'),
        'type' => 'text',
        'not null' => FALSE,
      ),
      'serialized_data' => array(
        'description' => t('TODO'),
        'type' => 'text',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array('vid'),
  );

  return $schema;
}

// ex: set syntax=php tabstop=2 expandtab shiftwidth=2 softtabstop=2:

function video_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {video} (
        vid int(10) unsigned NOT NULL default '0',
        nid int(10) unsigned NOT NULL default '0',
        vtype varchar(32) NOT NULL default '',
        vidfile text NOT NULL default '',
        videox smallint(4) unsigned NOT NULL default '0',
        videoy smallint(4) unsigned NOT NULL default '0',
        size bigint(13) unsigned default NULL,
        download_counter int(10) unsigned NOT NULL default '0',
        play_counter int(10) unsigned NOT NULL default '0',
        video_bitrate int(10) unsigned default NULL,
        audio_bitrate int(10) unsigned default NULL,
        audio_sampling_rate int(10) unsigned default NULL,
        audio_channels enum('','5.1','stereo','mono') default NULL,
        playtime_seconds int(10) unsigned default NULL,
        download_folder varchar(255) NULL default NULL,
        disable_multidownload tinyint(1) unsigned NOT NULL default '0',
        use_play_folder tinyint(1) unsigned NOT NULL default '0',
        custom_field_1 varchar(255) NULL default NULL,
        custom_field_2 varchar(255) NULL default NULL,
        custom_field_3 varchar(255) NULL default NULL,
        custom_field_4 varchar(255) NULL default NULL,
        custom_field_5 text NULL default NULL,
        custom_field_6 text NULL default NULL,
        serialized_data text NULL default NULL,
        PRIMARY KEY  (vid)
      ) TYPE=MyISAM COMMENT='size is in bytes' /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {video} (
        vid integer NOT NULL default '0',
        nid integer NOT NULL default '0',
        vtype varchar(32) NOT NULL default '',
        vidfile text NOT NULL default '',
        videox smallint NOT NULL default '0',
        videoy smallint NOT NULL default '0',
        size bigint default NULL,
        download_counter integer NOT NULL default '0',
        play_counter integer NOT NULL default '0',
        video_bitrate integer default NULL,
        audio_bitrate integer default NULL,
        audio_sampling_rate integer default NULL,
        audio_channels varchar(10) default NULL,
        playtime_seconds integer default NULL,
        download_folder varchar(255) NULL default NULL,
        disable_multidownload smallint NOT NULL default '0',
        use_play_folder smallint NOT NULL default '0',
        custom_field_1 varchar(255) NULL default NULL,
        custom_field_2 varchar(255) NULL default NULL,
        custom_field_3 varchar(255) NULL default NULL,
        custom_field_4 varchar(255) NULL default NULL,
        custom_field_5 text NULL default NULL,
        custom_field_6 text NULL default NULL,
        serialized_data text NULL default NULL,
        PRIMARY KEY  (vid)
      );");

  }
  
  // default values for some variables use for resolution stuff
  variable_set('video_resolution_1_name', '4:3 - Television');
  variable_set('video_resolution_1_value', '400x300');
  variable_set('video_resolution_2_name', '16:9 - Widescreen');
  variable_set('video_resolution_2_value', '400x226');
}

/**
 * Add audio details
 *
 * @return array
 */
/**
 * Rename counter, add custom fields, for video.module version 1.9
 *
 * @return array
 */
/**
 * Add unsigned to all int fields
 *
 * @return array
 */
/**
 * Start of Drupal 4.7 support in video.module issue #40005, version 1.25
 * updated revisions, db schema, forms api, form validation, permissions, added .swf and image support
 *
 * @return array
 */
/**
 * Add the vtype field for video module subtypes
 *
 * @return array
 */
function _video_update_6_get_vtype($node) {
  $file_type = '';
  $vidfile = $node->vidfile;
  //If the filename doesn't contain a ".", "/", or "\" and is exactly 11 characters then consider it a youtube video ID.
  if (!strpos($vidfile, '.') and !strpos($vidfile, '/') and !strpos($vidfile, '\\') and strlen($vidfile) == 11) {
    $file_type = 'youtube';
  }
  else if (strpos($vidfile, 'google:') === 0) {
    $file_type = 'google';
  }
  else if(db_result(db_query("SELECT count(fid) FROM {files} WHERE nid=%d", $node->nid)) > 0) {
    $file_type = 'upload';
  }
  else if ($vidfile != '' ) { // enable absolute urls and relative paths
    $file_type = 'url';
  }
  else {
    drupal_set_message(t('Could not determine video type of node %nid', array('%nid' => $node->nid)), 'error');
  }
  return $file_type;
}

/**
 * Set vtype for all the videos
*/
/**
 * Set default values of resolutions
*/
/**
 * Video_upload changes from relying on files table to locate
 * video file to saving it in serialized_data as video_fid
*/
/**
 * Update the vidfile for youtube videos so they will work again
 */
/**
 * Update vidfile for google videos -- they play, but they are not editable
 * in the current form because validation fails upon submit
 */