00001 <?php
00007 class STransSDRMetadata extends STransXML
00008 {
00009
00013 const NEWTAB = 1;
00014
00015
00016
00021 public function translate ($si)
00022 {
00023 if (parent::translate($si) == false) return false;
00024 $xml = SXMLHelper::parse($si->getSource());
00025 if ($xml === false) return false;
00026
00027 $md_shodor = $xml;
00028
00029 if (('Main' == $si->getName()) && ($xml !== false))
00030 {
00031 $this->page->setSlot('PageName', $md_shodor->Title);
00032 }
00033
00034
00035
00036 $collect = "";
00037
00038 $collect .=<<<ENDCOLLECT
00039 <table cellpadding="5" cellspacing="2" border="0" width="100%" style="margin-top: 2px;">
00040 ENDCOLLECT;
00041 $collect .= $this->wrapInTableRow("Title", $md_shodor->Title);
00042 $collect .= $this->wrapInTableRow("Url", $this->wrapInLink($md_shodor->Url, self::NEWTAB));
00043 $collect .= $this->wrapInTableRow("Creator", $this->conglomerateTagValues($md_shodor, "Creator"));
00044 $collect .= $this->wrapInTableRow("Contributor", $this->conglomerateTagValues($md_shodor, "Contributor"));
00045 $collect .= $this->wrapInTableRow("Publisher", $this->conglomerateTagValues($md_shodor, "Publisher"));
00046 $collect .= $this->wrapInTableRow("Description", $md_shodor->Description, true);
00047
00048
00049 $collect .= $this->wrapInTableRow("Format", $this->conglomerateTagValues($md_shodor, "Format"));
00050 $collect .= $this->wrapInTableRow("Language", $this->conglomerateTagValues($md_shodor, "Language"));
00051 $collect .= $this->wrapInTableRow("Subject", $this->conglomerateTagValues($md_shodor, "Subject"));
00052 $collect .= $this->wrapInTableRow("Keywords", $this->conglomerateTagValues($md_shodor, "Keyword"));
00053 $collect .= $this->wrapInTableRow("Audience", $this->conglomerateTagValues($md_shodor, "Audience"));
00054 $collect .= $this->wrapInTableRow("Education Level", $this->conglomerateTagValues($md_shodor, "Education_Level"));
00055 $collect .= $this->wrapInTableRow("Resource Type", $this->conglomerateTagValues($md_shodor, "Resource_Type"));
00056
00057 $collect .= "</table>";
00058
00059 $this->sendToTarget($si, $collect);
00060 parent::translate($si);
00061 }
00062
00071 protected function wrapInTableRow($key, $value, $hilight = false){
00072 $hilight = ($hilight) ? " highlight" : "";
00073 return <<<END_RETURN
00074 <tr class="lightBody$hilight">
00075 <td class="key" valign="top"><b>$key:</b></td>
00076 <td class="value">$value</td>
00077 </tr>
00078 END_RETURN;
00079 }
00080
00088 protected function conglomerateTagValues($xml, $tag) {
00089 $a = array();
00090 foreach($xml->$tag as $key => $value) {
00091 array_push($a, $value);
00092 }
00093 if (count($a) == 0) return "<i>none listed</i>";
00094 return implode(", ", $a);
00095 }
00096
00104 protected function wrapInLink($link, $tab) {
00105 if($tab == self::NEWTAB) {
00106 return "<a href=\"$link\"target='_blank'>$link</a>";
00107 }
00108 else {
00109 return "<a href=\"$link\">$link</a>";
00110 }
00111 }
00112
00113 }
00114
00115 ?>