You are here

function taxonomy_server_get_preferred_content in Taxonomy import/export via XML 7

Get the best content type requested, depending on what the server asked for.

stolen from neologism.module

3 calls to taxonomy_server_get_preferred_content()
taxonomy_server_get_preferred_uri in taxonomy_server/taxonomy_server.module
Get the best uri requested, based on content negotiation and guesswork.
taxonomy_server_term_page in taxonomy_server/taxonomy_server.module
An override of taxonomy_term_page. Checks if we can give the client another version of this data.
taxonomy_server_vocabulary_page in taxonomy_server/taxonomy_server.module
Display a page showing one or all available vocabularies

File

taxonomy_server/taxonomy_server.module, line 417
Extends taxonomy_xml to publish downloadable or queriable taxonomy vocabularies and terms. Extends the Drupal URLs to make vocabulary information available under /taxonomy/vocabulary and /taxonomy/vocabulary/{vid}.

Code

function taxonomy_server_get_preferred_content($accept) {
  if (isset($accept)) {
    module_load_include('inc.php', 'taxonomy_server', 'content_negotiation/content_negotiation');
    if (!class_exists('content_negotiation')) {
      watchdog('taxonomy_server', "Failed to load the content negotiation library expected to be at %path. This means I won't be serving alternative formats transparently", array(
        '%path' => TAXONOMY_SERVER_CONTENT_NEGOTATION_DIR . "/content_negotiation.inc.php",
      ));
      return 'html';
    }
    $best = content_negotiation::mime_best_negotiation();
    if ($best == "application/rdf+xml") {
      return 'rdf';
    }
    else {
      if ($best == "text/rdf+n3") {
        return 'n3';
      }
      else {
        if ($best == "application/xml") {
          return 'xml';
        }
        else {
          return 'html';
        }
      }
    }
  }
  else {
    return 'rdf';
  }
}