function token_custom_update_7001 in Custom Tokens 7.2
Updates Custom Tokens to use a text-format-enabled version of textarea.
File
- ./
token_custom.install, line 74 - Install, update and uninstall functions for the token_custom module.
Code
function token_custom_update_7001() {
$schema = token_custom_schema();
// Add the new format field.
db_add_field('token_custom', 'format', $schema['token_custom']['fields']['format']);
// Rename the "php_content" field to "content".
db_change_field('token_custom', 'php_content', 'content', $schema['token_custom']['fields']['content']);
// Make sure the PHP filter is available as the old content used PHP input.
module_enable(array(
'php',
));
// Wrap the content field with php tags.
$result = db_select('token_custom', 't')
->fields('t')
->execute();
while ($token = $result
->fetchAssoc()) {
$content = '<?php ' . $token['content'] . ' ?>';
db_update('token_custom')
->fields(array(
'content' => $content,
))
->condition('machine_name', $token['machine_name'])
->execute();
}
}