function custom_breadcrumbs_paths_install in Custom Breadcrumbs 7.2
Same name and namespace in other branches
- 6.2 custom_breadcrumbs_paths/custom_breadcrumbs_paths.install \custom_breadcrumbs_paths_install()
Implements hook_install().
File
- custom_breadcrumbs_paths/
custom_breadcrumbs_paths.install, line 11 - Install file for the custom_breadcrumbs module.
Code
function custom_breadcrumbs_paths_install() {
$t = get_t();
// Search for Paths breadcrumbs in existing {custom_breadcrumb} and copy to
// new table.
drupal_set_message($t('Looking for Specify Path breadcrumbs to copy from {custom_breadcrumb}...'));
$result = db_query("SELECT * FROM {custom_breadcrumb} WHERE node_type = :node_type", array(
':node_type' => 'Specify Path',
));
$found = 0;
foreach ($result as $breadcrumb) {
$start = strpos($breadcrumb->paths, "\n");
$specific_path = drupal_substr($breadcrumb->paths, 0, $start);
$title = drupal_substr($breadcrumb->titles, strpos($breadcrumb->titles, "\n") + 1);
$newpath = drupal_substr($breadcrumb->paths, strpos($breadcrumb->paths, "\n") + 1);
db_insert('custom_breadcrumbs_paths')
->fields(array(
'titles' => $title,
'paths' => $newpath,
'visibility_php' => $breadcrumb->visibility_php,
'specific_path' => $specific_path,
'set_active_menu' => $breadcrumb->set_active_menu,
'language' => $breadcrumb->language,
))
->execute();
drupal_set_message($t('Copied path @specific_path to {custom_breadcrumbs_paths}.', array(
'@specific_path' => $specific_path,
)));
++$found;
}
if ($found > 0) {
drupal_set_message(format_plural($found, 'Copied 1 breadcrumb.', 'Copied @count breadcrumbs.'));
drupal_set_message($t('You can now delete the old Specify Path breadcrumb from <a href="@link">admin/structure/custom_breadcrumbs</a>. They will be listed with title Specify Path and page type node.', array(
'@link' => url('admin/structure/custom_breadcrumbs'),
)));
}
else {
drupal_set_message($t('No Specify Path breadcrumbs were found in {custom_breadcrumb}'));
}
}