diff --git a/fieldable_panels_panes.module b/fieldable_panels_panes.module index 1327d28..251747f 100644 --- a/fieldable_panels_panes.module +++ b/fieldable_panels_panes.module @@ -938,12 +938,23 @@ function fieldable_panels_panes_load_from_subtype_force($subtype_name) { $object = reset($object); } } - + // UUID integration for revisions. + elseif ($type == 'vuuid' && module_exists('uuid')) { + $vids = entity_get_id_by_uuid('fieldable_panels_pane', array($id), TRUE); + if ($vids && $content = entity_load('fieldable_panels_pane', FALSE, array('vid' => reset($vids)))) { + $object = reset($content); + } + } // If the type is 'vid' then a specific FPP revision is being requested. elseif ($type == 'vid') { $fpid = db_query('SELECT fpid FROM {fieldable_panels_panes_revision} WHERE vid = :vid', array(':vid' => $id))->fetchField(); $object = fieldable_panels_panes_load($fpid, $id); } + // Load up the current revision. + elseif ($type == 'current') { + $vid = db_query('SELECT MAX(vid) FROM {fieldable_panels_panes_revision} WHERE fpid = :fpid', array(':fpid' => $id))->fetchField(); + $object = fieldable_panels_panes_load($id, $vid); + } // The remaining scenario is that it's a regular FPP id, i.e. an "fpid", so // just load the object. diff --git a/includes/PanelsPaneController.class.php b/includes/PanelsPaneController.class.php index 7a1d745..ef8e2a3 100644 --- a/includes/PanelsPaneController.class.php +++ b/includes/PanelsPaneController.class.php @@ -197,7 +197,12 @@ function saveRevision($entity, $uid = NULL) { $entity->uid = $uid; // Update the existing revision if specified. if (!empty($entity->vid)) { - drupal_write_record('fieldable_panels_panes_revision', $entity, 'vid'); + if (module_exists('uuid')) { + drupal_write_record('fieldable_panels_panes_revision', $entity, 'vuuid'); + } + else { + drupal_write_record('fieldable_panels_panes_revision', $entity, 'vid'); + } } else { // Otherwise insert a new revision. This will automatically update $entity diff --git a/plugins/content_types/fieldable_panels_pane.inc b/plugins/content_types/fieldable_panels_pane.inc index aa06879..200acd2 100644 --- a/plugins/content_types/fieldable_panels_pane.inc +++ b/plugins/content_types/fieldable_panels_pane.inc @@ -255,12 +255,40 @@ function fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form_sub fieldable_panels_panes_entity_edit_form_submit($form, $form_state); - // Sub type is not explicitly set, define it here. - if (module_exists('uuid') && isset($entity->uuid)) { - $entity_id = 'uuid:' . $entity->uuid; + // @todo: This is here to show that this should be a setting somewhere, + // however, I was having a time figuring out the appropriate place to put it + // and what to call it exactly. This is only temporary and hopefully someone + // will have some ideas. this would only apply for things like panelizer + // pages so that a pane actually corresponds to revision of the node. When + // the entity is reusable we want it to act as if it were global. We should + // also add some type of notice on the form so it's not completely + // confusing for users. + $revision_context_aware = !empty($entity->reusable); + + if (!empty($entity->is_new) || $revision_context_aware) { + if (module_exists('uuid') && isset($entity->uuid)) { + if ($revision_context_aware) { + $entity_id = 'vuuid:' . $entity->vuuid; + } + else { + $entity_id = 'uuid:' . $entity->uuid; + } + } + else { + if ($revision_context_aware) { + $entity_id = 'vid:' . $entity->vid; + } + else { + $entity_id = 'fpid:' . $entity->fpid; + } + } } else { - $entity_id = 'fpid:' . $entity->fpid; + // The current key will tell FPP to load up the current revision. This + // bypasses the entity cache on the FPP entity class and loads the revision + // that was just saved instead of the previous revision. This is only + // really relevant in panels IPE administration or similar circumstances. + $entity_id = 'current:' . $entity->fpid; } // @todo: This won't work if $form_state does not contain 'pane' which could @@ -319,11 +347,23 @@ function _fieldable_panels_panes_custom_content_type($entity) { 'icon' => 'icon_block_custom.png', ); + $revision_context_aware = !empty($entity->reusable); + if (module_exists('uuid') && isset($entity->uuid)) { - $info['name'] = 'uuid:' . $entity->uuid; + if ($revision_context_aware) { + $info['name'] = 'vuuid:' . $entity->vuuid; + } + else { + $info['name'] = 'uuid:' . $entity->uuid; + } } else { - $info['name'] = 'fpid:' . $entity->fpid; + if ($revision_context_aware) { + $info['name'] = 'vid:' . $entity->vid; + } + else { + $info['name'] = 'fpid:' . $entity->fpid; + } } $info['entity_id'] = $info['name'];