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;
}
 public function __construct($database, $name)
 {
     $this->db = $database;
     $this->item = getBibliographyItem($name);
 }