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