diff --git a/fieldable_panels_panes.module b/fieldable_panels_panes.module index ead8515..6a4836a 100644 --- a/fieldable_panels_panes.module +++ b/fieldable_panels_panes.module @@ -894,12 +894,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)))) { + $content = 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(); + $content = 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/plugins/content_types/fieldable_panels_pane.inc b/plugins/content_types/fieldable_panels_pane.inc index 383b597..12723a1 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 figureing 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)) ? TRUE : FALSE; + + 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