public static function TextimageStyles::save in Textimage 7.3
Save Textimage style data.
Parameters
array $style: image style to save
2 calls to TextimageStyles::save()
- TextimageStyles::delete in classes/
TextimageStyles.inc - Delete Textimage style data.
- textimage_image_style_save in ./
textimage.module - Implements hook_image_style_save().
File
- classes/
TextimageStyles.inc, line 128 - Textimage - Styles handling class.
Class
- TextimageStyles
- Styles management class.
Code
public static function save($style, $on_delete = FALSE) {
// A change to the name of the style.
if (isset($style['old_name']) && $style['old_name'] != $style['name']) {
// Change style name in fields.
$instances = field_read_instances();
// Loop through all fields searching for textimage fields.
foreach ($instances as $instance) {
$instance_changed = FALSE;
foreach ($instance['display'] as $view_mode => $display) {
// Check if the formatter involves an image style.
if ($display['type'] == 'textimage' && $display['settings']['image_style'] == $style['old_name']) {
// Update display information for any instance using the image
// style that was just deleted.
$instance['display'][$view_mode]['settings']['image_style'] = $style['name'];
$instance_changed = TRUE;
}
}
if ($instance_changed) {
field_update_instance($instance);
}
}
// Void store.
if (!$on_delete) {
db_update('textimage_store')
->fields(array(
'style_name' => $style['name'],
'is_void' => 1,
))
->condition('style_name', $style['old_name'], '=')
->execute();
}
return;
}
// Void store.
db_update('textimage_store')
->fields(array(
'is_void' => 1,
))
->condition('style_name', $style['name'], '=')
->execute();
}