You are here

function taxonomy_display_fetch_taxonomy_display in Taxonomy display 7

Helper function; retrieve taxonomy display settings.

Parameters

string $machine_name: The machine name of the vocabulary's taxonomy display data to fetch.

Return value

object Return ctools export object with taxonomy display settings.

4 calls to taxonomy_display_fetch_taxonomy_display()
taxonomy_display_admin_form in ./taxonomy_display.admin.inc
Helper callback; perform form alterations for taxonomy display admin form.
taxonomy_display_save_taxonomy_display in ./taxonomy_display.module
Helper function; save a taxonomy display record in the database.
taxonomy_display_taxonomy_term_page in ./taxonomy_display.module
Page callback; displays all nodes associated with a term.
taxonomy_display_taxonomy_vocabulary_update in ./taxonomy_display.module
Implements hook_taxonomy_vocabulary_update().
1 string reference to 'taxonomy_display_fetch_taxonomy_display'
taxonomy_display_schema in ./taxonomy_display.install
Implements hook_schema().

File

./taxonomy_display.module, line 60
Hooks for the taxonomy display module.

Code

function taxonomy_display_fetch_taxonomy_display($machine_name) {

  // Attempt to fetch cached settings for the machine name.
  $cache = cache_get('taxonomy_display:settings:' . $machine_name);
  if ($cache) {
    return $cache->data;
  }
  $plugin_types = _taxonomy_display_plugin_types();
  ctools_include('export');
  $result = ctools_export_load_object('taxonomy_display', 'names', array(
    $machine_name,
  ));

  // Set defaults if a result was not found.
  if (!isset($result[$machine_name])) {
    $defaults = new stdClass();
    $defaults->machine_name = $machine_name;
    $defaults->add_feed = TRUE;
    $defaults->no_record = TRUE;
    foreach ($plugin_types as $k => $v) {
      $defaults->{$k . '_display_plugin'} = 'TaxonomyDisplay' . ucfirst($k) . 'DisplayHandlerCore';
      $defaults->{$k . '_display_options'} = NULL;
    }
    return $defaults;
  }
  $result = $result[$machine_name];

  // Prepare plugins' data for use.
  foreach ($plugin_types as $k => $v) {
    if (!class_exists($result->{$k . '_display_plugin'})) {

      // Note that if providing translations for this module you must provide a
      // translation for this watchdog warning for each $value.
      watchdog('taxonomy_display', 'The taxonomy ' . $v['short'] . ' plugin assigned to the %name vocabulary is missing, Drupal default settings were used instead.', array(
        '%name' => $machine_name,
      ), WATCHDOG_WARNING);
      $result->{$k . '_display_plugin'} = 'TaxonomyDisplay' . ucfirst($k) . 'DisplayHandlerCore';
      $result->{$k . '_display_options'} = NULL;
      $result->{$k . '_plugin_missing'} = TRUE;
    }
  }

  // Store $result for next time.
  cache_set('taxonomy_display:settings:' . $machine_name, $result);
  return $result;
}