diff --git a/includes/PanelsPaneController.class.php b/includes/PanelsPaneController.class.php index 2056a42..f94b2fb 100644 --- a/includes/PanelsPaneController.class.php +++ b/includes/PanelsPaneController.class.php @@ -120,7 +120,7 @@ class PanelsPaneController extends DrupalDefaultEntityController { // When saving a new entity revision, unset any existing $entity->vid // to ensure a new revision will actually be created and store the old // revision ID in a separate property for entity hook implementations. - if (!$entity->is_new && !empty($entity->revision) && $entity->vid) { + if (!$entity->is_new && $entity->vid) { $entity->old_vid = $entity->vid; unset($entity->vid); $entity->timestamp = REQUEST_TIME; @@ -183,7 +183,12 @@ class PanelsPaneController extends DrupalDefaultEntityController { $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 bd7eac3..24cd934 100644 --- a/plugins/content_types/fieldable_panels_pane.inc +++ b/plugins/content_types/fieldable_panels_pane.inc @@ -205,12 +205,45 @@ 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) { + // @todo: So I feel that this should be vuuid, however, when I tried + // the entity is never loaded back up, seems to work fine as + // just vid. I did briefly look, however, in the interest of + // time I stopped, hopefully someone else knows. + //$entity_id = 'vuuid:' . $entity->vuuid; + $entity_id = 'vid:' . $entity->vid; + } + 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 @@ -312,6 +345,10 @@ function _fieldable_panels_panes_load_entity($subtype_name) { $fpid = db_query('SELECT fpid FROM {fieldable_panels_panes_revision} WHERE vid = :vid', array(':vid' => $id))->fetchField(); $content = fieldable_panels_panes_load($fpid, $id); } + 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); + } else { $content = fieldable_panels_panes_load($id); } @@ -325,3 +362,4 @@ function _fieldable_panels_panes_load_entity($subtype_name) { function fieldable_panels_panes_content_type_create_access($type, $subtype) { return fieldable_panels_panes_access('create', $subtype['name']); } + diff --git a/plugins/export_ui/fieldable_panels_pane.class.php b/plugins/export_ui/fieldable_panels_pane.class.php index 3252eca..bfa8118 100644 --- a/plugins/export_ui/fieldable_panels_pane.class.php +++ b/plugins/export_ui/fieldable_panels_pane.class.php @@ -74,6 +74,7 @@ class fieldable_panels_pane extends ctools_export_ui { function edit_save_form($form_state) { parent::edit_save_form($form_state); + drupal_static_reset(); entity_info_cache_clear(); menu_rebuild();