You are here

function microdata_vocabulary_settings_refresh_vocabulary_cache in Microdata 7

Submit callback; Caches microdata vocabularies.

1 call to microdata_vocabulary_settings_refresh_vocabulary_cache()
microdata_vocabulary_settings_submit in ./microdata.admin.inc
Submit callback; Caches microdata vocabularies.
1 string reference to 'microdata_vocabulary_settings_refresh_vocabulary_cache'
microdata_vocabulary_settings in ./microdata.admin.inc
Form builder; The microdata vocabulary settings form.

File

./microdata.admin.inc, line 65
Microdata administration and module settings UI.

Code

function microdata_vocabulary_settings_refresh_vocabulary_cache($form, &$form_state, $forced = TRUE) {
  $vocabulary_info = microdata_get_vocabulary_info();
  if (!empty($form_state['values']['enabled_vocabs'])) {
    foreach (array_filter($form_state['values']['enabled_vocabs']) as $vocab_name) {
      $cache = cache_get($vocab_name, 'cache_microdata_vocabulary');

      // @todo Add expires.
      if (empty($cache) || $forced) {

        // Ensure that there was some content.
        if ($data = microdata_update_vocabulary_schema($vocabulary_info[$vocab_name]['import_url'])) {
          $schema = json_decode($data);
          cache_set($vocab_name, $schema, 'cache_microdata_vocabulary');
        }
      }
    }
  }
  drupal_set_message(t('Microdata vocabulary cache refreshed.'));
}