You are here

spaces_controller_boxes.inc in Boxes 7

Same filename and directory in other branches
  1. 6 plugins/spaces_controller_boxes.inc

File

plugins/spaces_controller_boxes.inc
View source
<?php

/**
 * Spaces controller for boxes module.
 */
class spaces_controller_boxes extends spaces_controller {

  // Override of load_original_values
  protected function load_original_values($id = NULL) {
    if (empty($this->loaded_all['original'])) {

      // TODO can we always rely on having export.inc loaded?
      if (!isset($id)) {
        $boxes = array();
        foreach (ctools_export_load_object('box') as $box) {
          $boxes[$box->delta] = $box;
        }
        $this->values['original'] = $boxes;
        $this->loaded_all['original'] = TRUE;
      }
      elseif (!isset($this->loaded['original'][$id])) {
        if ($box = ctools_export_load_object('box', 'names', array(
          $id,
        ))) {
          $this->values['original'][$id] = reset($box);
          $this->loaded['original'][$id] = TRUE;
        }
      }
    }
  }

  /**
   * Override of the set() method.
   *
   * Remove flags used by to detect state and transflorm to stdClass so that the
   * box configuration can be loaded regardless of whether the plugin is
   * available.
   */
  function set($id, $value) {
    unset($value->new);
    unset($value->export_type);
    $box = new stdClass();
    foreach ($value as $k => $v) {
      $box->{$k} = $v;
    }
    parent::set($id, $box);
  }

}

Classes

Namesort descending Description
spaces_controller_boxes Spaces controller for boxes module.