You are here

function scald_config_rebuild in Scald: Media Management made easy 6

Rebuild the Scald Configuration Object & other key configuration variables.

NOTE: The Scald Configuration Object only includes information relevant to the internal operation of Scald. If a label is available for "public" viewing (e.g. the title of an Action), it is included, but if it is only for the benefit of Admins or Devs (e.g. the title of a Transcoder) it is *not* included in the Scald Configuration Object.

Parameters

$sections: A string specifying the section of the Scald Configuration Object to rebuild OR an array with more one such string. Permitted strings are: 'types', 'actions', 'contexts', 'transcoders', and 'relationships'. If unspecified, all sections are rebuilt.

Return value

TRUE/FALSE based on success of object building.

6 calls to scald_config_rebuild()
scald_admin_contexts_form_submit in ./scald.admin.inc
Submit handler for Scald Contexts admin settings form.
scald_admin_provider_reregister in ./scald.admin.inc
Forces a Scald Provider to re-register with Scald Core, potentially previously-unknown Provisions.
scald_admin_types_form_submit in ./scald.admin.inc
Submist function for admin settings for Scald Types.
scald_image_update_6001 in scald_image/scald_image.install
Implements hook_update_N(). Converts our imagecache based transcoders to use the presetname instead of the presetid as a key. This is more robust to change such as putting presets in code.
scald_init in ./scald.module
Implementation of hook_init().

... See full list

File

./scald.module, line 460

Code

function scald_config_rebuild($sections = NULL) {

  // Argument validation
  $available_sections = array(
    'types',
    'contexts',
    'actions',
    'transcoders',
    'relationships',
  );
  if (empty($sections)) {
    $sections = $available_sections;
  }
  else {
    if (!is_array($sections)) {
      $sections = array(
        $sections,
      );
    }
  }

  // Build the Scald Configuration Object
  $scald_config = variable_get('scald_config', 0);
  if (!$scald_config) {
    $scald_config = new stdClass();
  }
  foreach ($sections as $section) {
    switch ($section) {
      case 'types':
        $scald_config->types = _scald_types();

        // Early save to fascilitate the build functions for Contexts and
        //  Transcoders.
        variable_set('scald_config', $scald_config);
        break;
      case 'contexts':
        $scald_config->contexts = _scald_contexts();
        break;
      case 'actions':
        $scald_config->actions = _scald_actions();
        break;
      case 'transcoders':
        $scald_config->transcoders = _scald_transcoders();
        break;
      case 'relationships':
        $scald_config->relationships = _scald_relationships();
        break;
    }
  }
  variable_set('scald_config', $scald_config);

  // Build the Scald Atom Defaults Object
  $scald_atom_defaults = variable_get('scald_atom_defaults', 0);
  if (empty($scald_atom_defaults)) {
    $scald_atom_defaults = new stdClass();
  }
  foreach ($scald_config->types as $type => $details) {

    // NOTE: Using isset rather than empty because NULL is a valid default
    if (!isset($scald_atom_defaults->file_source[$type])) {
      $scald_atom_defaults->file_source[$type] = NULL;
    }

    // NOTE: A thumbnail of some sort *must* be provided, however; No NULLs here
    if (empty($scald_atom_defaults->thumbnail_source[$type])) {
      $scald_atom_defaults->thumbnail_source[$type] = drupal_get_path('module', 'scald') . '/assets/thumbnail_default.png';
    }
    if (!isset($scald_atom_defaults->description[$type]) || is_null($scald_atom_defaults->description[$type])) {
      $scald_atom_defaults->description[$type] = 'A ' . $type . ' Scald Atom.';
    }
    if (empty($scald_atom_defaults->actions[$type])) {
      $scald_atom_defaults->actions[$type] = 0;
    }
  }
  variable_set('scald_atom_defaults', $scald_atom_defaults);
  return TRUE;
}