You are here

function spaces_preset_load in Spaces 6.3

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \spaces_preset_load()
  2. 6 spaces_admin.inc \spaces_preset_load()
  3. 6.2 spaces_admin.inc \spaces_preset_load()
  4. 7.3 spaces.module \spaces_preset_load()
  5. 7 spaces.module \spaces_preset_load()

Preset loader.

Parameters

$name: Optional name for the preset to load.

$name: Optional spaces_type of the the presets to load.

Return value

Returns a fully-loaded preset.

13 calls to spaces_preset_load()
SpacesContextControllerTestCase::test in tests/spaces.test
Test override inheritance of variable controller.
spaces_controller::load_preset_values in plugins/spaces_controller.inc
Protected method that ensures a preset-level override for the provided object has been loaded. Since presets values are stored in aggregate, the $id argument here is largely for consistency.
spaces_controller_variable::load_preset_values in plugins/spaces_controller_variable.inc
Override of load_preset_values(). We cannot rely on variable_get() -- we must first check our space override values.
spaces_form_alter in ./spaces.overrides.inc
Implementation of hook_form_alter().
spaces_overrides_form in ./spaces.admin.inc
Form for managing space override values.

... See full list

File

./spaces.module, line 227

Code

function spaces_preset_load($name = NULL, $space_type = NULL, $reset = FALSE) {
  ctools_include('export');
  static $presets;
  if (!isset($presets) || $reset) {
    if (!$reset && ($cache = cache_get('spaces_presets', 'cache'))) {
      $presets = $cache->data;
    }
    else {
      if ($reset) {
        ctools_export_load_object_reset('spaces_presets');
      }
      $presets = ctools_export_load_object('spaces_presets', 'all');
      cache_set('spaces_presets', $presets);
    }
  }
  if (!isset($name) && !isset($space_type)) {
    return $presets;
  }
  if (isset($name)) {
    return isset($presets[$name]) ? $presets[$name] : FALSE;
  }
  if (isset($space_type)) {
    $return = array();
    foreach ($presets as $key => $preset) {
      if ($preset->space_type === $space_type) {
        $return[$key] = $preset;
      }
    }
    return $return;
  }
}