- From: Dan Brickley <danbri@w3.org>
- Date: Sun, 8 Aug 2004 17:59:41 -0400
- To: www-archive@w3.org
<?php
// Exports a Wordpress category database in SKOS format (as RDF/N3)
// author: Dan Brickley <danbri@w3.org>
require('wp-config.php');
get_currentuserinfo();
global $post_ID, $tablecategories, $tablepost2cat, $mode, $wpdb;
header('Content-type: text/plain');
echo "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n";
echo "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n";
echo "@prefix skos: <http://www.w3.org/2004/02/skos/core> .\n";
echo "\n\n";
$q="SELECT * FROM $tablecategories ORDER BY category_parent DESC,
cat_name ASC";
$categories = $wpdb->get_results($q);
$result = array();
foreach($categories as $category) {
$array_category = get_object_vars($category);
$me = 0 + $category->cat_ID;
$parent = 0 + $category->category_parent;
if (isset($result[$me])) $array_category['children'] = $result[$me];
echo '_:c',$category->cat_ID, ' a skos:Concept; skos:id
"',$category->cat_ID,'" ;';
echo ' skos:prefLabel "',$category->cat_name, "\" ";
if ($category->category_description) {
echo ' skos:definition "',$category->category_description, "\" ";
}
$p = $category->category_parent;
if ($p != '0') {
echo 'skos:broader _:c', $p, " .\n";
}
else { echo " .\n";
}
}
?>
Received on Sunday, 8 August 2004 21:59:41 UTC