| 1 |
<?php |
<?php |
| 2 |
// $Id: audio.install,v 1.13 2007/02/15 16:37:47 drewish Exp $ |
// $Id: audio.install,v 1.14 2007/07/27 18:47:30 drewish Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Install the initial schema. |
* Install the initial schema. |
| 291 |
break; |
break; |
| 292 |
} |
} |
| 293 |
return $ret; |
return $ret; |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
/** |
| 297 |
|
* Use the token module for title and teasers. |
| 298 |
|
*/ |
| 299 |
|
function audio_update_5201() { |
| 300 |
|
$ret = array(); |
| 301 |
|
|
| 302 |
|
// Build an array of conversions. First the hard coded values... |
| 303 |
|
$tokens = array( |
| 304 |
|
'!filelength' => '[audio-file-length]', |
| 305 |
|
'!fileformat' => '[audio-file-format]', |
| 306 |
|
'!player' => '[audio-player]', |
| 307 |
|
'!filename' => '[audio-filename]', |
| 308 |
|
); |
| 309 |
|
// ...then the tags. |
| 310 |
|
foreach (audio_get_tags_allowed() as $tag) { |
| 311 |
|
$tokens['!'. $tag] = '[audio-tag-'. strtr($tag, '_', '-') .']'; |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
// Gather a list of all the different title formats and then replace them |
| 315 |
|
// with the new token based equivalents. |
| 316 |
|
$result = db_query('SELECT DISTINCT title_format FROM {audio}'); |
| 317 |
|
while ($o = db_fetch_object($result)) { |
| 318 |
|
$new_value = strtr($o->title_format, $tokens); |
| 319 |
|
db_query("UPDATE {audio} SET title_format = '%s' WHERE title_format = '%s'", $new_value, $o->title_format); |
| 320 |
|
} |
| 321 |
|
|
| 322 |
|
// Update the default title and teaser formats. |
| 323 |
|
foreach (array('audio_default_title_format', 'audio_teaser_format') as $variable) { |
| 324 |
|
if ($old_value = variable_get($variable, FALSE)) { |
| 325 |
|
$new_value = strtr($old_value, $tokens); |
| 326 |
|
variable_set($variable, $new_value); |
| 327 |
|
} |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
// Let them know if they don't have token installed. |
| 331 |
|
if (!module_exists('token')) { |
| 332 |
|
drupal_set_message(t('The audio module requires that the <a href="http://drupal.org/project/token">token module</a> be installed. You should install it as soon as possible.')); |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
return $ret; |
| 336 |
} |
} |