function metatag_update_7101 in Metatag 7
Update i18n strings for all meta tags to use the new format.
1 call to metatag_update_7101()
- metatag_update_7102 in ./
metatag.install - Re-run update 7101.
File
- ./
metatag.install, line 2279 - Install, update, and uninstall functions for the metatag module.
Code
function metatag_update_7101() {
if (!module_exists('locale') || !db_table_exists('locales_source')) {
return t('No translations to fix as the locale system is not enabled.');
}
// Loop through each entity type. Not going to bother filtering this list,
// it'll only be a difference of a few entities anyway and the queries
// should be fairly quick.
foreach (entity_get_info() as $entity_type => $entity_info) {
// Entities must have bundles.
if (empty($entity_info['bundles'])) {
$entity_info['bundles'] = array(
$entity_type => $entity_type,
);
}
foreach ($entity_info['bundles'] as $bundle_type => $bundle_info) {
// Update {locales_source}, replace 'metatag:ENTITYTYPE:BUNDLE:tag' with
// 'metatag:metatag_config:ENTITYTYPE:BUNDLE:tag'.
db_query("UPDATE {locales_source}\n SET location = REPLACE(location, 'metatag:{$entity_type}:{$bundle_type}:', 'metatag:metatag_config:{$entity_type}:{$bundle_type}:'),\n context = REPLACE(context, '{$entity_type}:{$bundle_type}:', 'metatag_config:{$entity_type}:{$bundle_type}:')\n WHERE textgroup = 'metatag'\n AND location LIKE 'metatag:{$entity_type}:{$bundle_type}:%'");
// Update {locales_source}, replace 'metatag:ENTITYTYPE:tag' with
// 'metatag:metatag_config:ENTITYTYPE:tag'.
db_query("UPDATE {locales_source}\n SET location = REPLACE(location, 'metatag:{$entity_type}:', 'metatag:metatag_config:{$entity_type}:'),\n context = REPLACE(context, '{$entity_type}:', 'metatag_config:{$entity_type}:')\n WHERE textgroup = 'metatag'\n AND location LIKE 'metatag:{$entity_type}:%'");
}
}
// Update {locales_source}, replace 'metatag:metatag:' with
// 'metatag:output:'.
db_query("UPDATE {locales_source}\n SET location = REPLACE(location, 'metatag:metatag:', 'metatag:output:'),\n context = REPLACE(context, 'metatag:', 'output:')\n WHERE textgroup = 'metatag'\n AND location LIKE 'metatag:metatag:%'");
}