export_ui.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // @todo The API specifications say that a 'cache clear' callback is required,
  16. // but there is none provided?
  17. // @see cache.inc
  18. // 'cache clear' => ???
  19. );
  20. function ctools_cache_export_ui_cache_get($plugin_name, $key) {
  21. ctools_include('export-ui');
  22. $plugin = ctools_get_export_ui($plugin_name);
  23. $handler = ctools_export_ui_get_handler($plugin);
  24. if ($handler) {
  25. $item = $handler->edit_cache_get($key);
  26. if (!$item) {
  27. $item = ctools_export_crud_load($handler->plugin['schema'], $key);
  28. }
  29. return $item;
  30. }
  31. }
  32. function ctools_cache_export_ui_cache_set($plugin_name, $key, $item) {
  33. ctools_include('export-ui');
  34. $plugin = ctools_get_export_ui($plugin_name);
  35. $handler = ctools_export_ui_get_handler($plugin);
  36. if ($handler) {
  37. return $handler->edit_cache_set_key($item, $key);
  38. }
  39. }