You are here

function microdata_get_vocabularies in Microdata 7

Helper function.

Return value

array An array of vocabulary info, keyed by vocabulary and then itemtype.

1 call to microdata_get_vocabularies()
microdata_get_types in ./microdata.pages.inc
Helper function.

File

./microdata.pages.inc, line 102
Page callbacks for microdata module.

Code

function microdata_get_vocabularies() {
  $vocabulary_info = microdata_get_vocabulary_info();
  $enabled_vocabs = microdata_get_enabled_vocabularies();

  // If there are enabled vocabularies, compile their definitions into one
  // array.
  if (!empty($vocabulary_info) && count($enabled_vocabs)) {
    foreach ($enabled_vocabs as $vocab_name) {
      if (($cache = cache_get($vocab_name, 'cache_microdata_vocabulary')) && $cache->data) {
        $schema = $cache->data;
      }
      else {
        module_load_include('inc', 'microdata', 'microdata.admin');
        if ($data = microdata_update_vocabulary_schema($vocabulary_info[$vocab_name]['import_url'])) {
          $schema = json_decode($data);
          cache_set($vocab_name, $schema, 'cache_microdata_vocabulary');
        }
      }

      // @todo Remove the array conversion once Vocabulary Parser is in place.
      $schema->types = (array) $schema->types;
      $vocabulary_info[$vocab_name]['types'] = $schema->types;
    }
  }
  return $vocabulary_info;
}