diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e9dc882 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools/easyrdf"] + path = tools/easyrdf + url = git://github.com/njh/easyrdf.git diff --git a/tools/classes.php b/tools/classes.php new file mode 100644 index 0000000..b3191ba --- /dev/null +++ b/tools/classes.php @@ -0,0 +1,370 @@ +localName()); + return "$name"; + } + + protected function addPropertyList(&$list, $values, $skip) + { + foreach($values as $value) + { + $k = strval($value); + if(in_array(strval($value), $skip)) + { + continue; + } + if($value instanceof EasyRdf_Collection) + { + $this->addPropertyList($list, $value, $skip); + continue; + } + if($value instanceof EasyRdf_Resource && $value->isBNode()) + { + $union = $value->all('owl:unionOf'); + $this->addPropertyList($list, $union, $skip); + continue; + } + if ($value instanceof Phpspecgen_Term) + { + $list[$k] = $value->termLink(); + } + else if ($value instanceof EasyRdf_Resource) + { + $list[$k] = $value->htmlLink($value->shorten()); + } + else + { + $list[$k] = strval($value); + } + } + } + + public function propertyList($property, $skip = null) { + $items = array(); + if(!is_array($skip)) + { + $skip = array(); + } + $this->addPropertyList($items, $this->all($property), $skip); + ksort($items); + return $items; + } + + public function propertyRow($title, $property, $skip = null) { + $items = $this->propertyList($property, $skip); + if (count($items) > 0) { + return "
This vocabulary defines "; + $counts = array(); + if($classCount > 0) + { + $counts[] = ($classCount == 1 ? 'one class' : ($classCount . ' classes')); + } + if($propertyCount > 0) + { + $counts[] = ($propertyCount == 1 ? 'one property' : ($propertyCount . ' properties')); + } + if($schemeCount > 0) + { + $counts[] = ($schemeCount == 1 ? 'one concept scheme' : ($schemeCount . ' concept schemes')); + } + if($conceptCount > 0) + { + $counts[] = ($conceptCount == 1 ? 'one concept' : ($conceptCount . ' concepts')); + } + if($individualCount > 0) + { + $counts[] = ($individualCount == 1 ? 'one named individual' : ($individualCount . ' named individuals')); + } + $sub = array_slice($counts, 0, -1); + if(count($counts) > 1) + { + $last = ' and ' . array_pop($counts); + } + else + { + $last = ''; + } + $html .= implode(', ', $sub) . $last . '.'; + $html .= "
\n"; + + $html .= 'Term Name | Type | Definition |
---|---|---|
".$term->termLink()." | "; + $html .= "".$term->termType()." | "; + $html .= "".$term->getLiteral('rdfs:comment|rdfs:label')." | "; + $html .= "
URI: | ".$term->htmlLink()." |
---|---|
Inherited Properties: | ". + "".join(', ', $properties)." |
This vocabulary defines"; + if ($classCount == 0) { + $html .= " no classes"; + } else if ($classCount == 1) { + $html .= " one class"; + } else { + $html .= " $classCount classes"; + } + if ($properyCount == 0) { + $html .= " and no properties."; + } else if ($properyCount == 1) { + $html .= " and one property."; + } else { + $html .= " and $properyCount properties."; + } + $html .= "
\n"; + + $html .= "Term Name | Type | Definition |
---|---|---|
".$term->termLink()." | "; + $html .= "".$term->termType()." | "; + $html .= "".$term->getLiteral('rdfs:comment|rdfs:label')." | "; + $html .= "
URI: | ".$term->htmlLink()." |
---|---|
Inherited Properties: | ". + "".join(', ', $properties)." |
Error: No OWL ontologies defined at that URL.
\n"; + } else { + // FIXME: register the preferredNamespacePrefix + + print $vocab->htmlHeader(); + print $vocab->htmlSummaryOfTerms(); + print $vocab->htmlTerms('Phpspecgen_Class', 'Classes'); + print $vocab->htmlTerms('Phpspecgen_Property', 'Properties'); + + print $graph->dump(); + } + + } else { + $examples = array( + 'FOAF' => 'http://xmlns.com/foaf/spec/', + 'DOAP' => 'http://usefulinc.com/ns/doap#', + 'LODE' => 'http://linkedevents.org/ontology/', + 'Ordered List Ontology' => 'http://purl.org/ontology/olo/core#', + 'Whisky Vocabulary' => 'http://vocab.org/whisky/terms.rdf', + 'Sport Ontology' => 'http://www.bbc.co.uk/ontologies/sport/2011-02-17.rdf', + 'Music Ontology' => 'http://purl.org/ontology/mo/', + 'Programme Ontology' => 'http://www.bbc.co.uk/ontologies/programmes/2009-09-07.rdf' + ); + + print "