00001 <?php
00002
00003 #doc
00004 # classname: TransSDRMetadataXML
00005 # scope: PUBLIC
00006 #
00007 #/doc
00008
00009 class TransSDRMetadataXML extends STransObject
00010 {
00011
00012 const NEWTAB = 1;
00013
00014
00015
00016 public function translate ($si)
00017 {
00018
00019
00020 $results = $si->getSource();
00021 $metadata = $results->getMetadata();
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 # Translate the Page Content
00034 $collect = "";
00035
00036 $collect .=<<<ENDCOLLECT
00037 <table cellpadding="5" cellspacing="2" border="0" width="100%" style="margin-top: 2px;">
00038 ENDCOLLECT;
00039
00040
00041
00042
00043
00044
00045 $collect .= $this->wrapInTableRow("Title", $this->implodeValues($metadata->getValue('Title')));
00046 $url = $metadata->getValue('Url');
00047 $collect .= $this->wrapInTableRow("Url", $this->wrapInLink($url[0], TransSDRMetadataXML::NEWTAB));
00048 $collect .= $this->wrapInTableRow("Creator", $this->implodeValues($metadata->getValue('Creator')));
00049 $collect .= $this->wrapInTableRow("Contributor", $this->implodeValues($metadata->getValue('Contributor')));
00050 $collect .= $this->wrapInTableRow("Publisher", $this->implodeValues($metadata->getValue('Publisher')));
00051 $collect .= $this->wrapInTableRow("Description", $this->implodeValues($metadata->getValue('Description')));
00052
00053 $collect .= $this->wrapInTableRow("Format", $this->implodeValues($metadata->getValue('Format')));
00054 $collect .= $this->wrapInTableRow("Language", $this->implodeValues($metadata->getValue('Language')));
00055 $collect .= $this->wrapInTableRow("Subject", $this->implodeValues($metadata->getValue('Subject')));
00056 $collect .= $this->wrapInTableRow("Keywords", $this->implodeValues($metadata->getValue('Keyword')));
00057 $collect .= $this->wrapInTableRow("Audience", $this->implodeValues($metadata->getValue('Audience')));
00058 $collect .= $this->wrapInTableRow("Education Level", $this->implodeValues($metadata->getValue('Education_Level')));
00059 $collect .= $this->wrapInTableRow("Resource Type", $this->implodeValues($metadata->getValue('Resource_Type')));
00060
00061 $collect .= "</table>";
00062
00063 $this->sendToTarget($si, $collect);
00064 parent::translate($si);
00065 }
00066
00067 protected function wrapInTableRow($key, $value, $hilight = false){
00068 $hilight = ($hilight) ? " highlight" : "";
00069 return <<<END_RETURN
00070 <tr class="lightBody$hilight">
00071 <td class="key" valign="top"><b>$key:</b></td>
00072 <td class="value">$value</td>
00073 </tr>
00074 END_RETURN;
00075 }
00076
00077 protected function implodeValues($values) {
00078 if (count($values) == 0) return "<i>none listed</i>";
00079 return implode(", ", $values);
00080 }
00081
00082 protected function wrapInLink($link, $tab) {
00083 if($tab == TransSDRMetadataXML::NEWTAB) {
00084 return "<a href=\"$link\"target='_blank'>$link</a>";
00085 }
00086 else {
00087 return "<a href=\"$link\">$link</a>";
00088 }
00089 }
00090
00091 }
00092
00093 ?>