export_ui.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * A caching mechanism for use with subsystems that use the export ui.
  5. */
  6. $plugin = array(
  7. // cache plugins are the rare plugin types that have no real UI but
  8. // we're providing a title just in case.
  9. 'title' => t('Export UI wizard cache'),
  10. 'cache get' => 'ctools_cache_export_ui_cache_get',
  11. 'cache set' => 'ctools_cache_export_ui_cache_set',
  12. // Some operations use a 'finalize' but that really just means set
  13. // for us, since we're not using temporary storage for subsystems.
  14. 'cache finalize' => 'ctools_cache_export_ui_cache_set',
  15. );
  16. function ctools_cache_export_ui_cache_get($plugin_name, $key) {
  17. ctools_include('export-ui');
  18. $plugin = ctools_get_export_ui($plugin_name);
  19. $handler = ctools_export_ui_get_handler($plugin);
  20. if ($handler) {
  21. $item = $handler->edit_cache_get($key);
  22. if (!$item) {
  23. $item = ctools_export_crud_load($handler->plugin['schema'], $key);
  24. }
  25. return $item;
  26. }
  27. }
  28. function ctools_cache_export_ui_cache_set($plugin_name, $key, $item) {
  29. ctools_include('export-ui');
  30. $plugin = ctools_get_export_ui($plugin_name);
  31. $handler = ctools_export_ui_get_handler($plugin);
  32. if ($handler) {
  33. return $handler->edit_cache_set_key($item, $key);
  34. }
  35. }