function taxonomy_server_term_page in Taxonomy import/export via XML 7
An override of taxonomy_term_page. Checks if we can give the client another version of this data.
Checks content-negotiation, then passes back to the normal page renderer unless an alternative was requested.
Parameters
$term object:
1 string reference to 'taxonomy_server_term_page'
- taxonomy_server_menu in taxonomy_server/
taxonomy_server.module - Implementation of hook_menu: Define menu links.
File
- taxonomy_server/
taxonomy_server.module, line 195 - 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_term_page($term = NULL, $format_id = NULL) {
// Only do content-negotiation if the format was not explicitly requested
if ($format_id == NULL) {
// Check if this request was from a content-negotiation compatible client.
// Redirect them to the alternate version if so.
$preferred = taxonomy_server_get_preferred_content($_SERVER["HTTP_ACCEPT"]);
watchdog('taxonomy_server', "\n Received a request for <b>{$_SERVER['REQUEST_URI']}</b> .\n Seeing if I can give it better content via content-negotiation.\n Client asked for ({$_SERVER['HTTP_ACCEPT']})\n <br> It seems that the client would prefer '{$preferred}'\n ");
// TODO https & port support
$rdf_uri = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "/rdf";
if ($preferred == 'rdf') {
watchdog('taxonomy_server', "Received a <b>content-negotiated</b> request for {$_SERVER['REQUEST_URI']} as {$preferred}. Boinging the request to that version of this page ({$rdf_uri}).");
header("HTTP/1.1 303");
header("Vary: Accept");
header("Location: " . $rdf_uri);
exit;
}
}
// Maybe this page was a catcher because there was a format ID appended to the arguments
if (!empty($format_id)) {
// this vocab was requested in a specific export format.
// Use the appropriate export function.
return taxonomy_xml_export_term($term, $format_id);
}
// Else, return the normal HTML version!
// @todo May need to start thinking about depth
#dpm("Thought about, but decided against sending another format");
#dpm($_SERVER['HTTP_ACCEPT']);
// add a link tag so user-agents can see I have this semantic version avaialable
drupal_add_html_head_link(array(
'rel' => 'alternate',
'type' => 'application/rdf+xml',
'title' => $term->name,
'href' => $rdf_uri,
));
# <link rel="alternate" type="application/rss+xml" title="semanticweb.org RSS Feed" href="http://semanticweb.org/index.php?title=Special:RecentChanges&feed=rss" />
// Need to load the taxonomy library inc
module_load_include('inc', 'taxonomy', 'taxonomy.pages');
return taxonomy_term_page($term);
}