/usr/share/drupal6/modules/filefield/filefield_meta/filefield_meta.install is in drupal6-mod-filefield 3.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?php
/**
* @file
* FileField Meta: Add Video Support to File Field.
*/
/**
* Implementation of hook_install().
*/
function filefield_meta_install() {
drupal_install_schema('filefield_meta');
}
function filefield_meta_uninstall() {
drupal_uninstall_schema('filefield_meta');
}
/**
* Implementation of hook_schema().
*/
function filefield_meta_schema() {
$schema = array();
// The primary field/index.
$schema['filefield_meta'] = array(
'description' => 'The table for meta data about filefield files.',
'fields' => array(
'fid' => array(
'description' => 'The file id.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'width' => array(
'description' => 'Width of a video or image file in pixels.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'height' => array(
'description' => 'Height of a video or image file in pixels.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'duration' => array(
'description' => 'The duration of audio or video files, in seconds.',
'type' => 'float',
'size' => 'normal',
'not null' => FALSE,
),
'audio_format' => array(
'description' => 'The audio format.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
),
'audio_sample_rate' => array(
'description' => 'The sample rate of the audio.',
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'default' => 0,
),
'audio_channel_mode' => array(
'description' => 'The number of channels in the audio, by name (stereo or mono).',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
),
'audio_bitrate' => array(
'description' => 'The audio bitrate.',
'type' => 'float',
'size' => 'medium',
'not null' => TRUE,
'default' => 0,
),
'audio_bitrate_mode' => array(
'description' => 'The kind of audio bitrate, such as VBR. Usually empty.',
'type' => 'varchar',
'length' => 4,
'not null' => TRUE,
'default' => '',
),
'tags' => array(
'description' => 'ID3 tags such as artist, album, and genre.',
'type' => 'text',
'serialize' => TRUE,
),
),
'primary key' => array('fid'),
);
return $schema;
}
function filefield_meta_update_1() {
$ret = array();
db_add_field($ret, 'filefield_meta', 'audio_format', array(
'description' => 'The audio format.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
));
db_add_field($ret, 'filefield_meta', 'audio_sample_rate', array(
'description' => 'The sample rate of the audio.',
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
'default' => 0,
));
db_add_field($ret, 'filefield_meta', 'audio_channel_mode', array(
'description' => 'The number of channels in the audio, by name.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
));
db_add_field($ret, 'filefield_meta', 'audio_bitrate', array(
'description' => 'The audio bitrate.',
'type' => 'float',
'size' => 'medium',
'not null' => TRUE,
'default' => 0,
));
db_add_field($ret, 'filefield_meta', 'audio_bitrate_mode', array(
'description' => 'The kind of audio bitrate.',
'type' => 'varchar',
'length' => 4,
'not null' => TRUE,
'default' => '',
));
return $ret;
}
/**
* Add the tags column.
*/
function filefield_meta_update_6100(&$context) {
$ret = array();
// Set up our update and add the tags column.
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['total'] = db_result(db_query("SELECT COUNT(*) FROM {files} f INNER JOIN {filefield_meta} fm ON f.fid = fm.fid WHERE fm.audio_format <> ''"));
$context['sandbox']['current_fid'] = 0;
if (!db_column_exists('filefield_meta', 'tags')) {
db_add_field($ret, 'filefield_meta', 'tags', array('type' => 'text'));
}
// We are done if there are none to update.
if ($context['sandbox']['total'] == 0) {
return $ret;
}
}
// Select and process 200 files at a time.
$limit = 200;
$result = db_query_range("SELECT f.* FROM {files} f INNER JOIN {filefield_meta} fm ON f.fid = fm.fid WHERE f.fid > %d AND fm.audio_format <> '' ORDER BY f.fid ASC", $context['sandbox']['current_fid'], 0, $limit);
// Loop through each file and read in its ID3 tags if applicable.
while ($file = db_fetch_object($result)) {
filefield_meta_file_update($file);
$context['sandbox']['current_fid'] = $file->fid;
$context['sandbox']['progress']++;
}
// Update our progress indicator.
$ret['#finished'] = $context['sandbox']['progress'] / $context['sandbox']['total'];
return $ret;
}
|