function views_rdf_foaf_xml_render in Views Datasource 5
1 call to views_rdf_foaf_xml_render()
File
- ./
views_rdf.module, line 156 - Provides Views plugin for rendering node content as RDF.
Code
function views_rdf_foaf_xml_render($vid, $nodes, $type) {
$view = views_load_view($vid);
$fields = _views_get_fields();
$xml .= '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
$xml .= '<!-- generator="Drupal Views_Datasource.Module" -->' . "\n";
$xml .= '<rdf:RDF xmlns="http://xmlns.com/foaf/0.1"' . "\n";
$xml .= ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n";
$xml .= ' xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"' . "\n";
$xml .= ' xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n";
$xml .= ' xmlns:foaf="http://xmlns.com/foaf/0.1/">' . "\n";
foreach ($nodes as $node) {
$xml .= "<foaf:Person>\n";
foreach ($view->field as $field) {
if ($fields[$field['id']]['visible'] !== false) {
$label = $field['label'] ? $field['label'] : $fields[$field['fullname']]['name'];
/*strip illegal XML characters*/
$label = views_rdf_strip_illegal_chars($label);
$value = views_rdf_strip_illegal_chars(views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view));
//echo("$label:$value");
}
else {
continue;
}
if (is_null($value) || $value === '') {
continue;
}
if (stripos($label, 'firstname') !== false) {
$xml .= " <foaf:firstName>{$value}</foaf:firstName>\n";
continue;
}
if (stripos($label, 'surname') !== false) {
$xml .= " <foaf:surName>{$value}</foaf:surName>\n";
continue;
}
if (stripos($label, 'name') !== false && !(stripos($label, 'surname') !== false || stripos($label, 'firstname') !== false)) {
if (stripos($xml, "<foaf:name>") == false) {
$xml .= " <foaf:name>{$value}</foaf:name>\n";
}
continue;
}
if (stripos($label, 'title') !== false) {
$xml .= " <foaf:title>{$value}</foaf:title>\n";
continue;
}
if (stripos($label, 'nick') !== false) {
$xml .= " <foaf:nick>{$value}</foaf:nick>\n";
continue;
}
if (stripos($label, 'mbox_sha1sum') !== false) {
$xml .= " <foaf:mbox_sha1sum>{$value}</foaf:mbox_sha1sum>\n";
continue;
}
if (stripos($label, 'mbox') !== false && !(stripos($label, 'mbox_sha1sum') !== false)) {
$xml .= " <foaf:mbox>{$value}</foaf:mbox>\n";
continue;
}
if (stripos($label, 'openid') !== false) {
$xml .= " <foaf:openid>{$value}</foaf:openid>\n";
continue;
}
if (strpos($label, 'workplaceHomepage') !== false) {
$xml .= ' <foaf:workplaceHomepage rdf:resource="' . $value . '"/>' . "\n";
continue;
}
if (strpos($label, 'homepage') !== false) {
$xml .= ' <foaf:homepage rdf:resource="' . $value . '"/>' . "\n";
continue;
}
if (stripos($label, 'weblog') !== false) {
$xml .= ' <foaf:weblog rdf:resource="' . $value . '"/>' . "\n";
continue;
}
if (strpos($label, 'img') !== false) {
$xml .= ' <foaf:img rdf:resource="' . $value . '"/>' . "\n";
$xml .= ' <foaf:depiction rdf:resource="' . $value . '"/>' . "\n";
continue;
}
if (stripos($label, 'member') !== false) {
$xml .= " <foaf:member>{$value}</foaf:member>\n";
continue;
}
if (stripos($label, 'phone') !== false) {
$xml .= " <foaf:phone>{$value}</foaf:phone>\n";
continue;
}
if (stripos($label, 'jabberID') !== false) {
$xml .= " <foaf:jabberID>{$value}</foaf:jabberID>\n";
continue;
}
if (stripos($label, 'msnChatID') !== false) {
$xml .= " <foaf:msnChatID>{$value}</foaf:msnChatID>\n";
continue;
}
if (stripos($label, 'aimChatID') !== false) {
$xml .= " <foaf:aimChatID>{$value}</foaf:aimChatID>\n";
continue;
}
if (stripos($label, 'yahooChatID') !== false) {
$xml .= " <foaf:yahooChatID>{$value}</foaf:yahooChatID>\n";
continue;
}
}
$xml .= "</foaf:Person>\n";
}
$xml .= "</rdf:RDF>\n";
drupal_set_header('Content-Type: text/xml');
//var_dump($view);
print $xml;
module_invoke_all('exit');
exit;
}