function _migrate_node_gallery_variables in Node Gallery 6.3
1 call to _migrate_node_gallery_variables()
- node_gallery_update_6300 in ./
node_gallery.install - MAJOR UPGRADE - please don't blindly update from 2.x to 3.x! Your data will migrate, but some of your settings and most of your theming will need to be redone.
File
- ./
node_gallery.install, line 520 - Install, update and uninstall functions for the node_gallery module.
Code
function _migrate_node_gallery_variables() {
global $conf;
/* Here's an example of an ng2 $conf['node_gallery_node_gallery_gallery']:
NA [gallery_type] => node_gallery_gallery
NA [image_type] => node_gallery_image
NA [name] => Node Gallery Default
X [gallery_directory] =>
[default_cover] =>
NA [number_uploads] => 20
[display_fields] => Array (
[title] => title
[body_field] => body_field
[revision_information] => 0
[comment_settings] => 0
[path] => 0 )
[content_display] => image
[image_comment] => image
[image_size] => Array (
[cover] => node-gallery-cover
[thumbnail] => node-gallery-thumbnail
[preview] => node-gallery-display )
[original] => Array (
[view_original] => 0
[view_original_text] => Download the Original Image )
[teaser] => Array (
[gallery_display_type] => thumbnails
[thumbnails_num] => 6
[image] => node-gallery-thumbnail )
[gallery] => Array (
[gallery_display_type] => thumbnails )
[upload_limits] => Array (
[general] => Array (
X [file_extension] => jpg jpeg gif png
X [file_resolution] => 0
X [file_max_size] => 1
NA [user_max_size] => 2
NA [user_max_number] => 0 )
X [roles] => Array ( )
)
*/
$node_types = array_keys(node_get_types());
foreach ($conf as $key => $value) {
if (strpos($key, 'node_gallery_') === 0) {
$t = substr($key, 13);
if (in_array($t, $node_types)) {
// migrate monolithic node_gallery_<content_type> variables
$var = variable_get($key, array());
if (!isset($var['gallery_type'])) {
continue;
}
$rel = new stdClass();
$rel->gallery_type = $var['gallery_type'];
$rel->image_type = $var['image_type'];
$rel->imagefield_name = 'field_node_gallery_image';
$field_instance = array();
if ($var['upload_limits']['general']['file_extension'] != 'jpg jpeg gif png') {
$field_instance['widget']['file_extensions'] = $var['upload_limits']['general']['file_extension'];
}
if ($var['upload_limits']['general']['file_resolution'] != 0) {
$field_instance['widget']['max_resolution'] = $var['upload_limits']['general']['file_resolution'];
}
$field_instance['widget']['max_filesize_per_file'] = $var['upload_limits']['general']['file_max_size'] . 'M';
$field_instance['widget']['max_filesize_per_node'] = $var['upload_limits']['general']['file_max_size'] . 'M';
if (count($var['upload_limits']['roles']) > 0) {
drupal_set_message(t("Imagefield doesn't provide per-role file limits without extra modules. If you wish to maintain those, please use the !module module.", array(
'!module' => l(t('Node Limit Number'), 'http://drupal.org/project/node_limitnumber'),
)));
}
if (isset($var['gallery_directory'])) {
if (strpos($var['gallery_directory'], '%') === FALSE) {
$field_instance['widget']['file_path'] = $var['gallery_directory'];
}
else {
if (!module_exists('filefield_paths')) {
drupal_set_message(t("Imagefield doesn't provide tokenized paths without extra modules. If you wish to maintain those, please use the !module module.", array(
'!module' => l(t('FileField Paths'), 'http://drupal.org/project/filefield_paths'),
)));
}
}
}
$rel->settings = array_merge(node_gallery_relationship_settings_defaults(), $var);
drupal_write_record('node_gallery_relationships', $rel);
variable_del($key);
}
}
}
// Move this variable to one with a proper namespace
if (variable_get('node_images_page_fragment', FALSE)) {
drupal_set_message(t('You have selected "Use Named Anchors on Image Previous and Next links" in your configuration. This setting is now set on a per-relationship basis. Please <a href="@relationship_page">configure your relationships</a> to re-apply your previous setting.', array(
'@relationship_page' => url('admin/settings/node_gallery'),
)), 'warning');
variable_del('node_images_page_fragment');
}
foreach (array(
'node_gallery_page_number',
'node_images_page_number',
) as $v) {
$value = variable_get($v, 20);
switch ($v) {
case 'node_gallery_page_number':
if ($value != 20) {
drupal_set_message(t('You have selected to display @value galleries per page. The default is 20 - you may change the value by <a href="@view_link">editing the view</a>.', array(
'@value' => $value,
'@view_link' => url('admin/build/views/edit/node_gallery_gallery_summaries'),
)), 'warning');
}
break;
case 'node_images_page_number':
if ($value != 0) {
drupal_set_message(t('You have selected to display @value images per page. The default is 0 (unlimited) - you may change the value by <a href="@view_link">editing the view</a>.', array(
'@value' => $value,
'@view_link' => url('admin/build/views/edit/node_gallery_gallery_image_views'),
)), 'warning');
}
break;
}
variable_del($v);
}
}