public static function ajax_html() { $data = json_decode($_POST['jsonData'], true); $fnames = array("Title", "Author", "Publisher", "Date", "Related {$data['idtype']}#s"); $fvals = array_values($data); $header = ""; $row = ""; $relatedIDs = explode(',', preg_replace("/[^0-9]+/", ',', $fvals[5])); $n = count($relatedIDs); $urls = \oclc\WorldCatCatalogSearch::getLinks($data['idtype'], $relatedIDs); for ($i = 0; $i < $n; ++$i) { $id = $relatedIDs[$i]; if ($urls[$id] !== FALSE) { $relatedIDs[$i] = "<a href=\"{$urls[$id]}\" target=\"_blank\">{$id}</a>"; } } $fvals[5] = implode(" <br/>", $relatedIDs); for ($i = 1; $i < 6; $i++) { $header .= "<th>{$fnames[$i - 1]}</th>"; $row .= "<td>{$fvals[$i]}</td>"; } return "<div id='modal-data'><table><thead>{$header}</thead><tbody><tr>{$row}</tr></tbody></table></div>"; }