features.context.inc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Implements hook_features_export().
  4. */
  5. function context_features_export($data, &$export, $module_name = '') {
  6. $pipe = ctools_component_features_export('context', $data, $export, $module_name);
  7. $contexts = context_load();
  8. foreach ($data as $identifier) {
  9. if (isset($contexts[$identifier])) {
  10. $context = $contexts[$identifier];
  11. // Conditions.
  12. // Currently only node and views conditions are supported.
  13. // @TODO: Should this be delegated to a method on the plugin?
  14. foreach (array('node', 'views') as $key) {
  15. if (!empty($context->conditions{$key}['values'])) {
  16. foreach ($context->conditions{$key}['values'] as $item) {
  17. // Special pipe for views
  18. if ($key === 'views') {
  19. $split = explode(':', $item);
  20. $view_name = array_shift($split);
  21. $pipe[$key][$view_name] = $view_name;
  22. }
  23. else {
  24. $pipe[$key][$item] = $item;
  25. }
  26. }
  27. }
  28. }
  29. // Reactions.
  30. if (!empty($context->reactions['block']['blocks'])) {
  31. foreach ($context->reactions['block']['blocks'] as $block) {
  32. $block = (array) $block;
  33. $bid = "{$block['module']}-{$block['delta']}";
  34. $pipe['block'][$bid] = $bid;
  35. }
  36. }
  37. }
  38. }
  39. return $pipe;
  40. }
  41. /**
  42. * Implements hook_features_revert().
  43. *
  44. * @param $module
  45. * name of module to revert content for
  46. */
  47. function context_features_revert($module = NULL) {
  48. $return = ctools_component_features_revert('context', $module);
  49. context_invalidate_cache();
  50. return $return;
  51. }