You are here

function mediafront_get_preset in MediaFront 7.2

Same name and namespace in other branches
  1. 6.2 includes/mediafront.preset.inc \mediafront_get_preset()
  2. 6 includes/mediafront.preset.inc \mediafront_get_preset()
  3. 7 includes/mediafront.preset.inc \mediafront_get_preset()

Get's the preset.

3 calls to mediafront_get_preset()
mediafront_features_export_render in includes/mediafront.features.inc
Implementation of hook_features_export_render().
mediafront_get_preset_params in ./mediafront.module
Provided the preset and an additional array of params, this returns the player params.
mediafront_preset_load in includes/mediafront.preset.inc
Used for the menu item to load a preset.

File

includes/mediafront.preset.inc, line 623

Code

function mediafront_get_preset($preset_name, $reset = FALSE) {

  // Get the preset from cache.
  $cache = cache_get('mediafront_preset_' . $preset_name);
  if (!$reset && $cache) {
    if (!empty($cache->data['settings']['id'])) {
      unset($cache->data['settings']['id']);
    }
    return $cache->data;
  }
  else {

    // Get the preset from the database.
    $preset = db_select('mediafront_preset', 'p')
      ->fields('p')
      ->condition('p.name', $preset_name)
      ->execute()
      ->fetchAssoc();
    if ($preset) {
      $preset['settings'] = $preset['settings'] ? unserialize($preset['settings']) : array();
      $preset['connect'] = $preset['connect'] ? unserialize($preset['connect']) : array();
    }
    else {

      // Get all of the default presets.
      $default_presets = mediafront_preset_get_default_presets();

      // Check to see if this preset exists.
      if (isset($default_presets[$preset_name])) {

        // Make this our preset
        $preset = $default_presets[$preset_name];
      }
    }

    // Make sure to unset the id.
    if (!empty($preset['settings']['id'])) {
      unset($preset['settings']['id']);
    }

    // Now cache it.
    cache_set('mediafront_preset_' . $preset_name, $preset);

    // Return the preset.
    return $preset;
  }
}