You are here

function _scald_contexts in Scald: Media Management made easy 6

Get available Scald Contexts

NOTE: Having $scald_config->types properly populated is a prerequisite for this function.

This function determines and returns a structured array specifying all the currently provided Scald Contexts. The Scald Contexts array is cached in the Drupal variables table and only rebuilt upon request from this function. The Scald Contexts array has the following format: array( 'context-slug' => array( 'provider' => 'provider-name', 'render_language' => 'language-slug', // e.g. 'XHTML' 'type_format' => array( 'type-slug' => array( 'file_format' => 'format-slug' 'transcoder' => 'transcoder-slug' ), ... ), ), ... );

Return value

The Scald Contexts array

1 call to _scald_contexts()
scald_config_rebuild in ./scald.module
Rebuild the Scald Configuration Object & other key configuration variables.

File

./scald.module, line 612

Code

function _scald_contexts() {
  $scald_contexts = array();

  // Grab all the contexts from the db
  $contexts_results = db_query('
    SELECT
      context,
      provider,
      render_language,
      parseable
    FROM
     {scald_contexts}
  ');
  while ($context_raw = db_fetch_array($contexts_results)) {
    $scald_contexts[$context_raw['context']] = array(
      'provider' => $context_raw['provider'],
      'render_language' => $context_raw['render_language'],
      'parseable' => $context_raw['parseable'],
      'type_format' => array(),
    );
  }

  // Pull the context => type/format mappings from the db
  $format_results = db_query('
    SELECT
      context,
      type,
      file_format,
      transcoder
    FROM
      {scald_context_type_transcoder}
  ');
  while ($format_raw = db_fetch_array($format_results)) {
    $scald_contexts[$format_raw['context']]['type_format'][$format_raw['type']] = array(
      'file_format' => $format_raw['file_format'],
      'transcoder' => $format_raw['transcoder'],
    );
  }
  return $scald_contexts;
}