Index: gs2-extensions/afrepo/trunk/src/src/AFRepo.GSDLEXT.class.php.in
===================================================================
--- gs2-extensions/afrepo/trunk/src/src/AFRepo.GSDLEXT.class.php.in	(revision 28349)
+++ gs2-extensions/afrepo/trunk/src/src/AFRepo.GSDLEXT.class.php.in	(revision 28351)
@@ -58,5 +58,5 @@
 
 
-	protected function remove_audio_files_prefix($full_filepath) {
+	public function remove_audio_files_prefix($full_filepath) {
 #	  echo "full filepath = " . $full_filepath . "\n";
 #	  echo "af prefix = " . $this->af_prefix . "\n";
@@ -285,4 +285,221 @@
 		return null;
 	}
+
+
+
+
+	/**
+	 * extraTriples
+	 * Return an array of any extra implementation-specific triples should be 
+	 * added to the RDF given the ID of an audiofile
+	 *
+	 * This should be an array of triples in Turtle format without the trailing 
+	 * dot. (See generateRDF)
+	 * It should return triples about all audiofiles of the same song rather 
+	 * than just the one with the ID given.
+	 */
+	protected function extraTriples($id) {
+
+		$extra_triples = array();
+
+
+		// analyze the file, get some metadata
+		$structured_metadata = $this->getStructuredMetadata($id);
+
+		if ($structured_metadata !== false) {
+
+		}
+
+		// loop through the audiofiles for this tune
+		/* foreach ($ids as $key => $fileid) { */
+
+		/* 	// some identifiers */
+		/* 	$audiofile = "repo:$fileid"; */
+		/* 	$digitalsignal = "repo:$fileid#DigitalSignal"; */
+
+		/* 	// triples about the document */
+		/* 	$triples[] = "{$audiofile}_ a foaf:Document; foaf:primaryTopic $audiofile"; */
+
+		/* 	// this is a mo:AudioFile, which is a mo:MusicalItem */
+		/* 	$triples[] = "$audiofile a mo:AudioFile"; */
+
+		/* 	// this encodes a corresponding digital signal */
+		/* 	$triples[] = "$audiofile mo:encodes $digitalsignal"; */
+
+		/* 	// our digital signal is a mo:DigitalSignal (which is a subclass of  */
+		/* 	// mo:Signal, which is a subclass of mo:MusicalExpression) */
+		/* 	$triples[] = "$digitalsignal a mo:DigitalSignal"; */
+
+		/* 	// different logic depending whether this audiofile is the preferred  */
+		/* 	// one or not */
+		/* 	if ($key == 0) { */
+		/* 		// preferred -- if we have an MBID this Signal is derived from  */
+		/* 		// the original (that at Musicbrainz) */
+		/* 		if (!is_null($mbid)) */
+		/* 			$triples[] = "$digitalsignal mo:derived_from " . mbidToSignalURI($mbid); */
+		/* 		// otherwise we don't assert that it derives from anything */
+		/* 	} else { */
+		/* 		// non-preferred -- we assert that it is derived from our  */
+		/* 		// preferred audiofile's Signal */
+		/* 		$triples[] = "$digitalsignal mo:derived_from repo:" . $ids[0] . "#DigitalSignal"; */
+		/* 	} */
+
+		/* 	// analyze the file, get some metadata */
+		/* 	$filemetadata = $this->getFileMetadata($fileid); */
+
+		/* 	// mo:AudioFile metadata */
+		/* 	if (isset($filemetadata["dataformat"])) */
+		/* 		$triples[] = "$audiofile mo:encoding \"" . $filemetadata["dataformat"] */
+		/* 				. (isset($filemetadata["bitrate"]) ? " @ " . $filemetadata["bitrate"] . "bps" : "") */
+		/* 				. (isset($filemetadata["bitrate_mode"]) ? " " . $filemetadata["bitrate_mode"] : "") */
+		/* 				. "\""; */
+
+		/* 	// mo:DigitalSignal metadata */
+		/* 	if (isset($filemetadata["playtime_seconds"])) */
+		/* 		$triples[] = "$digitalsignal mo:time [ " */
+		/* 				. "a time:Interval; " */
+		/* 				. "time:seconds \"" . $filemetadata["playtime_seconds"] . "\"^^xsd:float " */
+		/* 				. "]"; */
+		/* 	if (isset($filemetadata["channels"])) */
+		/* 		$triples[] = "$digitalsignal mo:channels \"" . $filemetadata["channels"] . "\"^^xsd:int"; */
+		/* 	if (isset($filemetadata["sample_rate"])) */
+		/* 		$triples[] = "$digitalsignal mo:sample_rate \"" . $filemetadata["sample_rate"] . "\"^^xsd:float"; */
+		/* } */
+
+		return $extra_triples;
+
+
+	}
+
+
+	/**
+	 * getgetStructuredMetadata
+	 * Return as a hashmap (keyed by algorithm the structured audio data
+	 * from the "big crunch"
+	 */
+	public function getStructuredMetadata($id) {
+
+	  $classifier = new StructuredAudioClassifier();
+
+	  if ($classifier->available() && $classifier->hasMetadata($id)) {
+	    return $classifier->loadMetadata($id);
+	  }
+
+	  return false;
+
+	}
+
+
+	public function attributionToHtmlByAlgorithm() {
+
+	  $classifier = new StructuredAudioClassifier();
+
+	  $full_dataset_path = getcwd() . "/" . "datasets";
+
+
+	  $ametadata = $classifier->getAttribution();
+
+	  $style = "<style>\n";
+	  $style .= "  tr:nth-child(even) {background: #DDD}\n";
+	  $style .= "  tr:nth-child(odd)  {background: #EEE}\n";
+	  $style .= "</style>\n";
+
+	  $html_str = "$style\n<table>";
+
+	  foreach ($ametadata as $key => $value) {
+
+	    $html_str .= "<tr>";
+
+	    $entry = $value;
+	    $title      = $entry["title"];
+	    $year       = $entry["year"];
+	    $articleUrl = $entry["articleUrl"];
+	    $authorList = $entry["authorList"];
+	    $authors    = $entry["authors"];
+  
+	    $opt_linked_title = $title;
+
+	    if ($articleUrl != false) {
+	      $opt_linked_title = "<a href=\"$articleUrl\">$title</a>";
+	    }
+
+	    $desc_entry = "<i>$opt_linked_title</i> ($year)<br />\n";
+
+	    foreach ($authorList as $author) {
+	      $author_details = $authors[$author];
+	      $organizations  = $author_details["organization"];
+	      $email          = $author_details["email"];
+
+	      $desc_entry .= $author;
+	      if ($email != false) {
+		$email = str_replace("@"," at ",$email);
+		$desc_entry .= " (<tt>$email</tt>)";
+	      }
+
+	      $desc_entry .= "<br />\n";
+	    }
+
+	    $tarfilesize = filesize("$full_dataset_path/$key.tar.gz");
+
+	    $download_key = "<a href=\"datasets/$key.tar.gz\">Download $key</a> ($tarfilesize bytes)"; 
+	    $html_str .= "  <td>$download_key</td><td>$desc_entry</td>\n";
+
+	    $html_str .= "</tr>\n";
+
+	  }
+	  $html_str .= "</table>";
+
+	  return $html_str;
+
+	}
+
+
+	public function attributionToHtmlByCollection() {
+
+##	  $classifier = new StructuredAudioClassifier();
+
+	  $full_dataset_path = getcwd() . "/" . "datasets";
+
+
+	  $cmetadata = array (
+			      "american"  => "American",
+			      "classical" => "Classical",
+			      "coversong" => "Cover Songs",
+			      "dram"      => "Dram",
+			      "ehmann"    => "Ehmann",
+			      "jamendo"   => "Jameno",
+			      "latin"     => "Latin",
+			      "magnatune" => "Magnatune",
+			      "mazurkas"  => "Mazurkas",
+			      "uscrap"    => "US Bargin Bin",
+			      "uspop"     => "US Pop"
+			      );
+
+	  $style = "<style>\n";
+	  $style .= "  tr:nth-child(even) {background: #DDD}\n";
+	  $style .= "  tr:nth-child(odd)  {background: #EEE}\n";
+	  $style .= "</style>\n";
+
+	  $html_str = "$style\n<table>";
+
+	  foreach ($cmetadata as $key => $value) {
+
+	    $html_str .= "<tr>";
+
+	    $tarfilesize = filesize("$full_dataset_path/$key.tar.gz");
+
+	    $download_key = "<a href=\"datasets/$key.tar.gz\">Download $value</a> ($tarfilesize bytes)"; 
+	    $html_str .= "  <td>$download_key</td>\n";
+
+	    $html_str .= "</tr>\n";
+
+	  }
+	  $html_str .= "</table>";
+
+	  return $html_str;
+
+	}
+
+
 }
 
