function paging_update_7000 in Paging 7
Update: remove legacy Drupal 6 variables, add new D7 variables.
File
- ./
paging.install, line 33 - Install hooks for the Paging module.
Code
function paging_update_7000(&$sandbox) {
// List of paging variables that moved from type-specfic to general.
$general_vars = array(
'paging_read_more_enabled' => FALSE,
'paging_names_enabled' => FALSE,
'paging_name_title' => FALSE,
'paging_read_more_enabled' => TRUE,
'paging_separator' => '<!--pagebreak-->',
);
// New paging variables - per type.
$type_vars = array(
'paging_field' => 'body',
'paging_automatic_words_orphan' => '100',
'paging_automatic_chars_orphan' => '400',
);
foreach (node_type_get_names() as $machine => $human) {
// Remove legacy variables, unused in D7.
variable_del('paging_ajax_enabled_' . $machine);
variable_del('paging_pager_widget_' . $machine);
variable_del('paging_pager_widget_custom_' . $machine);
variable_del('paging_pager_widget_position_' . $machine);
variable_del('paging_separator_widget_' . $machine);
// Move specific content-type settings to global.
// If ANY of the previous settings were set, save them to the new.
foreach ($general_vars as $name => $default) {
$value = variable_get($name . '_' . $machine, $default);
// Yes, this will overwrite if there was more than one :/
variable_set($name, $value);
}
// Set new type-specific variables.
foreach ($type_vars as $name => $default) {
variable_set($name . '_' . $machine, $default);
}
}
return t('Legacy variables have been removed, new variables added.');
}