<?php
#
# schema_rdf.php - Helictite Schema of RDF 1.1 Classes and Properties,
#                  presented in Turtle format
#
# Revision history
# Version  Date        Author          Changes
# 1.0      2023-07-23  Glenn Baddeley  Initial version, referred to by helictite_rdf.php & abstracts_rdf.php
#
# Update sVersionDate below
#

# Change the default encoding of data sent from web server to browser from gzip to no encoding
header_remove( "Content-Encoding" );
header( "Content-Encoding: none");

# Change the default content type from text/html to text/turtle UTF-8
header_remove( "Content-Type" );
header( "Content-Type: text/turtle;charset=UTF-8");

# Include configuration constants
require 'helweb_config.php';
if( $cbDebugErrs ) { ini_set('display_errors', 1); error_reporting(E_ALL); }

# Current version of this PHP file
$sVersionDate = "1.0 of 2023-07-23";

# Generate the namespace triples 
echo "# RDF Schema for Helictite, Journal of Australasian Spelelogical Research
# Version $sVersionDate
# RDF 1.1 Turtle format - https://www.w3.org/TR/turtle
@base <https://helictite.caves.org.au/> .   # For relative IRI links in rdfs:isDefinedBy
# Helictite namespaces
@prefix : <https://helictite.caves.org.au/schema_rdf.php#> .
# RDF schema
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

";

# Generate the Helitite Terms triples

echo "# Class terms

";

#                         Class name, Defined by, Comment, Sub class of
$hj = new RdfTurtleClass( ':HelictiteJournal', 'schema_rdf.php#',
     	'The Helictite Journal top level class.',	'rdfs:Resource' );
$i  = new RdfTurtleClass( ':Issue', 'schema_rdf.php#',
	    'A published Issue of Helictite Journal.', ':HelictiteJournal' );
$c  = new RdfTurtleClass( ':Content', 'schema_rdf.php#',
	    'An item of Content in a published Issue of Helictite Journal.', ':HelictiteJournal' );
$o  = new RdfTurtleClass( ':Obituary', 'schema_rdf.php#',
	    'An Obituary published as Content in one or more Issues of Helictite Journal.', ':HelictiteJournal' );
$df = new RdfTurtleClass( ':DataFile', 'schema_rdf.php#',
	    'A Data File for an item of Content in a published Issue of Helictite Journal.', ':HelictiteJournal' );
$ni = new RdfTurtleClass( ':NewsItem', 'schema_rdf.php#',
	    'A News Item on the Internet home page of Helictite Journal.', ':HelictiteJournal' );
$a  = new RdfTurtleClass( ':Abstract', 'schema_rdf.php#',
	    'The Abstract of an item of Content in a published Issue of Helictite Journal.', ':HelictiteJournal' );
$ar = new RdfTurtleClass( ':Abstractor', 'schema_rdf.php#',
	    'Name of Astractor of an Abstract of an item of Content in a published Issue of Helictite Journal.', ':HelictiteJournal' );

echo "# Property terms

";

#              Property name, Comment, Range
$hj->AddProp( 'hasIssues', 'Journal has multiple Issue objects', ':Issue' );
$hj->AddProp( 'hasObituaries', 'Journal has multiple Obituary objects', ':Obituary' );
$hj->AddProp( 'hasDataFiles', 'Journal has multiple Data File objects', ':DataFile' );
$hj->AddProp( 'hasNewsItems', 'Journal has multiple News Items objects', ':NewsItem' );

$i->AddProp( 'volumeNumber', 'Volume number', '' );
$i->AddProp( 'issueNumber', 'Issue number', '' );
$i->AddProp( 'publicationYear', 'Publication year', '' );
$i->AddProp( 'publicationDates', 'Publication dates', '' );
$i->AddProp( 'editor', 'Editor names', '' );
$i->AddProp( 'numberOfPages', 'Number of pages', '' );
$i->AddProp( 'printPdfSizeK', 'Print resolution PDF file size in K bytes', '' );
$i->AddProp( 'printPdfUrl', 'URL of print resolution PDF file', '' );
$i->AddProp( 'screenPdfSizeK', 'Screen resolution PDF file size in K bytes', '' );
$i->AddProp( 'screenPdfUrl', 'URL of screen resolution PDF file', '' );
$i->AddProp( 'hasContents', 'Issue has multiple Content objects', ':Content' );

$c->AddProp( 'author', 'Authors', '' );
$c->AddProp( 'helRef', 'Unique Helictite Reference Id for content', '' );
$c->AddProp( 'publicationDate', 'Publication date as month name and year', '' );
$c->AddProp( 'includes', 'Included items and count, such as figures, tables, references', '' );
$c->AddProp( 'printPdfSizeK', 'Print resolution PDF file size in K bytes', '' );
$c->AddProp( 'printPdfUrl', 'URL of print resolution PDF file', '' );
$c->AddProp( 'screenPdfSizeK', 'Screen resolution PDF file size in K bytes', '' );
$c->AddProp( 'screenPdfUrl', 'URL of screen resolution PDF file', '' );
$c->AddProp( 'isInContent', 'Content is subordinate to another Contents object', ':Content' );
$c->AddProp( 'isInIssue', 'Content is in an Issue object', ':Issue' );
$c->AddProp( 'hasSubContents', 'Content has one or more subordinate Contents objects', ':Content' );
$c->AddProp( 'hasAbstract', 'Content has an Abstract object', ':Abstract' );
$c->AddProp( 'hasDataFiles', 'Content has one or more Data File objects', 'hs:DataFile' );
$c->AddProp( 'hasObituary', 'Content has an Obituary object', 'hs:Obituary' );

$o->AddProp( 'yearsLived', 'Range of years that they lived', '' );
$o->AddProp( 'yearPublished', 'Year obituary was published', '' );
$o->AddProp( 'obitAuthor', 'Authors of the obituary', '' );
$o->AddProp( 'helRefs', 'Helictite Reference Ids for obituary content', '' );
$o->AddProp( 'isInContents', 'Obituary is in one or more Content objects', ':Content' );

$df->AddProp( 'fileSize', 'Data file size expression, such as 67 Kb', '' );
$df->AddProp( 'isInContent', 'Data file is in a Content object', ':Content' );

$ni->AddProp( 'displayDate', 'Displayed date, such as 5th May 2023', '' );
$ni->AddProp( 'visibility', 'Visibility of news item, yes or no', '' );

$a->AddProp( 'hasAbstractors', 'Abstract has one or more Abstractor objects', ':Abstractor' );
$a->AddProp( 'isInContent', 'Abstract is in a Content object', ':Content' );

$ar->AddProp( 'abstractorKey', 'Unique Key for abstractor', '' );
$ar->AddProp( 'abstractorName', 'Name of abstractor', '' );

###### Classes ######

Class RdfTurtleClass {
  private $sClassName, $sDefinedBy;

  function __construct( $className, $definedBy, $comment, $subClassOf ) {
    $this->sClassName = $className;
    $this->sDefinedBy = $definedBy;
    $aCName = str_getcsv( $className, ':' );
    echo "$className a rdfs:Class;
 rdfs:isDefinedBy <$definedBy>;
 rdfs:label \"" . $aCName[1] . "\";
 rdfs:comment \"$comment\";
 rdfs:subClassOf $subClassOf .

";
  }

  public function AddProp( $propName, $comment, $range ) {
    if( strlen($range) == 0 ) $range = 'rdfs:Literal';
    echo ":$propName a rdf:Property;
 rdfs:isDefinedBy <{$this->sDefinedBy}>;
 rdfs:label \"$propName\";
 rdfs:comment \"$comment\";
 rdfs:range $range;
 rdfs:domain {$this->sClassName} .

"; 
  }

}
?>