function printKeyValue($key, $value) { $output = ""; // TODO maybe using $output instead of $value is a better thing for all this string building... switch ($key) { case "url": $output .= "<tr><td><i>" . $key . "</i></td><td><a href='" . $value . "'>" . $value . "</a></td></tr>"; break; case "name": // this should be ignored break; default: $output .= "<tr><td><i>" . $key . "</i></td><td>" . parseTeX($value) . "</td></tr>"; } return $output; }
function parseCitations($code) { global $regex; $count = preg_match_all("/\\\\cite\\{([\\.\\w,\\-+\\_]*)\\}/", $code, $matches); for ($i = 0; $i < $count; $i++) { $keys = explode(",", $matches[1][$i]); $matchings = explode(",", $matches[0][$i]); foreach ($keys as $index => $key) { $item = getBibliographyItem($key); $code = str_replace($matchings[$index], '[<a title="' . parseTeX($item['author']) . ', ' . parseTeX($item['title']) . '" href="' . href('bibliography/' . $key) . '">' . $key . "</a>]", $code); } } $count = preg_match_all("/\\\\cite\\[(" . $regex . ")\\]\\{([\\w-]*)\\}/", $code, $matches); for ($i = 0; $i < $count; $i++) { $item = getBibliographyItem($matches[2][$i]); $code = str_replace($matches[0][$i], '[<a title="' . parseTeX($item['author']) . ', ' . parseTeX($item['title']) . '" href="' . href('bibliography/' . $matches[2][$i]) . '">' . $matches[2][$i] . "</a>, " . $matches[1][$i] . "]", $code); } return $code; }