spaces_controller_boxes.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Spaces controller for boxes module.
  4. */
  5. class spaces_controller_boxes extends spaces_controller {
  6. // Override of load_original_values
  7. protected function load_original_values($id = NULL) {
  8. if (empty($this->loaded_all['original'])) {
  9. // TODO can we always rely on having export.inc loaded?
  10. if (!isset($id)) {
  11. $boxes = array();
  12. foreach (ctools_export_load_object('box') as $box) {
  13. $boxes[$box->delta] = $box;
  14. }
  15. $this->values['original'] = $boxes;
  16. $this->loaded_all['original'] = TRUE;
  17. }
  18. else if (!isset($this->loaded['original'][$id])) {
  19. if ($box = array_pop(ctools_export_load_object('box', 'names', array($id)))) {
  20. $this->values['original'][$id] = $box;
  21. $this->loaded['original'][$id] = TRUE;
  22. }
  23. }
  24. }
  25. }
  26. /**
  27. * Override of the set() method.
  28. *
  29. * Remove flags used by to detect state and transflorm to stdClass so that the
  30. * box configuration can be loaded regardless of whether the plugin is
  31. * available.
  32. */
  33. function set($id, $value) {
  34. unset($value->new);
  35. unset($value->export_type);
  36. $box = new stdClass();
  37. foreach ($value as $k => $v) {
  38. $box->$k = $v;
  39. }
  40. parent::set($id, $box);
  41. }
  42. }