| 1 |
<?php
|
| 2 |
// $Id: flashnode.install,v 1.11 2008/08/10 23:05:32 stuartgreenfield Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function flashnode_install() {
|
| 8 |
drupal_install_schema('flashnode');
|
| 9 |
}
|
| 10 |
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of hook_uninstall
|
| 14 |
*/
|
| 15 |
function flashnode_uninstall() {
|
| 16 |
drupal_uninstall_schema('flashnode');
|
| 17 |
}
|
| 18 |
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Schema definition for Flash node
|
| 22 |
*/
|
| 23 |
function flashnode_schema() {
|
| 24 |
$schema['flashnode'] = array(
|
| 25 |
'description' => t('Stores details associated with each Flash file, such as height, width and display mode.'),
|
| 26 |
'fields' => array(
|
| 27 |
'vid' => array(
|
| 28 |
'description' => t('Primary key: {node}.vid for revision tracking of Flash nodes.'),
|
| 29 |
'type' => 'int',
|
| 30 |
'unsigned' => TRUE,
|
| 31 |
'not null' => TRUE,
|
| 32 |
),
|
| 33 |
'fid' => array(
|
| 34 |
'description' => t('{file}.fid associated with each Flash node revision.'),
|
| 35 |
'type' => 'int',
|
| 36 |
'unsigned' => TRUE,
|
| 37 |
'not null' => TRUE,
|
| 38 |
),
|
| 39 |
'nid' => array(
|
| 40 |
'description' => t('{node}.nid with which the Flash file is associated.'),
|
| 41 |
'type' => 'int',
|
| 42 |
'unsigned' => TRUE,
|
| 43 |
'not null' => TRUE,
|
| 44 |
),
|
| 45 |
'height' => array(
|
| 46 |
'description' => t('Display height, in pixels, of the Flash file.'),
|
| 47 |
'type' => 'int',
|
| 48 |
'unsigned' => TRUE,
|
| 49 |
'not null' => TRUE,
|
| 50 |
),
|
| 51 |
'width' => array(
|
| 52 |
'description' => t('Display width, in pixels, of the Flash file.'),
|
| 53 |
'type' => 'int',
|
| 54 |
'unsigned' => TRUE,
|
| 55 |
'not null' => TRUE,
|
| 56 |
),
|
| 57 |
'display' => array(
|
| 58 |
'description' => t('Display mode for the Flash file in this node: 0 = teaser and body, 1 = teaser only, 2 = body only.'),
|
| 59 |
'type' => 'int',
|
| 60 |
'unsigned' => TRUE,
|
| 61 |
'size' => 'tiny',
|
| 62 |
'not null' => TRUE,
|
| 63 |
),
|
| 64 |
'substitution' => array(
|
| 65 |
'description' => t('Substitution text to display if using a JavaScript replacement method.'),
|
| 66 |
'type' => 'text',
|
| 67 |
'size' => 'big',
|
| 68 |
'not null' => TRUE,
|
| 69 |
),
|
| 70 |
'flashvars' => array(
|
| 71 |
'description' => t('Flashvars to pass to the Flash file.'),
|
| 72 |
'type' => 'text',
|
| 73 |
'size' => 'big',
|
| 74 |
'not null' => TRUE,
|
| 75 |
),
|
| 76 |
'base' => array(
|
| 77 |
'description' => t('Base parameter to pass to the Flash file.'),
|
| 78 |
'type' => 'varchar',
|
| 79 |
'length' => '255',
|
| 80 |
'not null' => TRUE,
|
| 81 |
),
|
| 82 |
'params' => array(
|
| 83 |
'description' => t('Parameters to pass to the Flash player.'),
|
| 84 |
'type' => 'varchar',
|
| 85 |
'length' => '255',
|
| 86 |
'not null' => TRUE,
|
| 87 |
),
|
| 88 |
),
|
| 89 |
'primary key' => array('vid'),
|
| 90 |
);
|
| 91 |
|
| 92 |
return $schema;
|
| 93 |
}
|
| 94 |
|
| 95 |
|
| 96 |
/**
|
| 97 |
* If this is an upgrade install (i.e. from Drupal 5) then update flashnode filepath
|
| 98 |
* entries in {files} to be consistent with Drupal 6 storage convention
|
| 99 |
* Also update schema to ensure it matches new specification
|
| 100 |
*/
|
| 101 |
function flashnode_update_6000() {
|
| 102 |
|
| 103 |
// Initialise array for results
|
| 104 |
$ret = array();
|
| 105 |
|
| 106 |
// Retrieve the file_directory_path and append a slash
|
| 107 |
$base = file_directory_path().'/';
|
| 108 |
|
| 109 |
// SQL string varies depending whether MySQL or Postgres
|
| 110 |
switch ($GLOBALS['db_type']) {
|
| 111 |
case 'mysql':
|
| 112 |
case 'mysqli':
|
| 113 |
$sql = "UPDATE {files} SET filepath = CONCAT('".$base."', filepath) WHERE filename = '_flashnode'";
|
| 114 |
break;
|
| 115 |
|
| 116 |
case 'pgsql':
|
| 117 |
$sql = "UPDATE {files} SET filepath = '".$base."' || filepath WHERE filename = '_flashnode'";
|
| 118 |
}
|
| 119 |
|
| 120 |
// Run the update
|
| 121 |
$ret[] = update_sql($sql);
|
| 122 |
|
| 123 |
// Drop the existing primary key (nid)
|
| 124 |
db_drop_primary_key($ret, 'flashnode');
|
| 125 |
|
| 126 |
// Amend vid to match new schema
|
| 127 |
db_change_field($ret, 'flashnode', 'vid', 'vid', array(
|
| 128 |
'type' => 'int',
|
| 129 |
'unsigned' => TRUE,
|
| 130 |
'not null' => TRUE,
|
| 131 |
), array('primary key' => array('vid')));
|
| 132 |
|
| 133 |
// Amend fid to match new schema
|
| 134 |
db_change_field($ret, 'flashnode', 'fid', 'fid', array(
|
| 135 |
'type' => 'int',
|
| 136 |
'unsigned' => TRUE,
|
| 137 |
'not null' => TRUE,
|
| 138 |
), array());
|
| 139 |
|
| 140 |
// Amend base to match new schema
|
| 141 |
db_change_field($ret, 'flashnode', 'base', 'base', array(
|
| 142 |
'type' => 'varchar',
|
| 143 |
'length' => '255',
|
| 144 |
'not null' => TRUE,
|
| 145 |
),array());
|
| 146 |
|
| 147 |
// Amend nid to match new schema
|
| 148 |
db_change_field($ret, 'flashnode', 'nid', 'nid', array(
|
| 149 |
'type' => 'int',
|
| 150 |
'unsigned' => TRUE,
|
| 151 |
'not null' => TRUE,
|
| 152 |
),array());
|
| 153 |
|
| 154 |
// Amend height to match new schema
|
| 155 |
db_change_field($ret, 'flashnode', 'height', 'height', array(
|
| 156 |
'type' => 'int',
|
| 157 |
'unsigned' => TRUE,
|
| 158 |
'not null' => TRUE,
|
| 159 |
),array());
|
| 160 |
|
| 161 |
// Amend height to match new schema
|
| 162 |
db_change_field($ret, 'flashnode', 'width', 'width', array(
|
| 163 |
'type' => 'int',
|
| 164 |
'unsigned' => TRUE,
|
| 165 |
'not null' => TRUE,
|
| 166 |
),array());
|
| 167 |
|
| 168 |
// Amend display to match new schema
|
| 169 |
db_change_field($ret, 'flashnode', 'display', 'display', array(
|
| 170 |
'type' => 'int',
|
| 171 |
'unsigned' => TRUE,
|
| 172 |
'size' => 'tiny',
|
| 173 |
'not null' => TRUE,
|
| 174 |
),array());
|
| 175 |
|
| 176 |
// Amend substitution to match new schema
|
| 177 |
db_change_field($ret, 'flashnode', 'substitution', 'substitution', array(
|
| 178 |
'type' => 'text',
|
| 179 |
'size' => 'big',
|
| 180 |
'not null' => TRUE,
|
| 181 |
),array());
|
| 182 |
|
| 183 |
// Amend flashvars to match new schema
|
| 184 |
db_change_field($ret, 'flashnode', 'flashvars', 'flashvars', array(
|
| 185 |
'type' => 'text',
|
| 186 |
'size' => 'big',
|
| 187 |
'not null' => TRUE,
|
| 188 |
),array());
|
| 189 |
|
| 190 |
// Return results
|
| 191 |
return $ret;
|
| 192 |
}
|
| 193 |
|
| 194 |
/**
|
| 195 |
* Add 'params' column in order to support parameters associated with flash nodes
|
| 196 |
*/
|
| 197 |
function flashnode_update_6001() {
|
| 198 |
|
| 199 |
// Initialise array for results
|
| 200 |
$ret = array();
|
| 201 |
|
| 202 |
// Add the parameters field
|
| 203 |
db_add_field($ret, 'flashnode', 'params', array(
|
| 204 |
'description' => t('Parameters to pass to the Flash player.'),
|
| 205 |
'type' => 'varchar',
|
| 206 |
'length' => '255',
|
| 207 |
'not null' => TRUE,)
|
| 208 |
);
|
| 209 |
|
| 210 |
// Return results
|
| 211 |
return $ret;
|
| 212 |
|
| 213 |
}
|