function get_document($uuid) { $json = $this->fetch_details($uuid); $res = json_decode($json, true); $paper = new Paper($uuid); if (isset($res["authors"])) { $paper->authors = $res["authors"]; } if (isset($res["title"])) { $paper->title = htmlentities($res["title"]); } if (isset($res["year"])) { $paper->year = htmlentities($res["year"]); } if (isset($res["publication_outlet"])) { $paper->journal = htmlentities($res["publication_outlet"]); } if (isset($res['mendeley_url']) && is_mendeley_url($res['mendeley_url'])) { $paper->mendeley_url = $res['mendeley_url']; } if (isset($res['identifiers'])) { if (isset($res['identifiers']['pmid']) && is_pmid($res['identifiers']['pmid'])) { $paper->pmid = $res['identifiers']['pmid']; } } return $paper; }
function to_db($p) { $query = sprintf("INSERT INTO %s (uuid, title, authors, journal, year, pmid, mendeley_url) " . "VALUES ('%s', '%s', '%s', '%s', %d, %d, '%s'); ", TBL_PAPERS, sqlite_escape_string($p->uuid), sqlite_escape_string($p->title), json_encode($p->authors), sqlite_escape_string($p->journal), sqlite_escape_string($p->year), sqlite_escape_string($p->pmid), is_mendeley_url($p->mendeley_url) ? $p->mendeley_url : ""); if (!$this->db->queryExec($query, $error)) { echo $query . "<br>"; die($error); } else { #echo "<br>".$query; } }
function format_html() { echo '<table class="paper">'; echo '<tr><td class="authors">' . $this->format_authors(true), '</td></tr>'; echo '<tr><td class="title">' . (isset($this->title) ? '' . $this->title . '' : 'Unknown title') . '</td></tr>'; echo '<tr><td class="journal">'; echo isset($this->journal) ? $this->journal : ""; echo isset($this->year) ? ' (' . $this->year . ')' : ""; echo '</td></tr>'; echo '<tr><td><div class="paper_actions">'; if (isset($this->mendeley_url) && is_mendeley_url($this->mendeley_url)) { echo '<a class="button" href="', $this->mendeley_url, '"><span>View in Mendeley</span></a> '; } if (isset($this->pmid) && is_pmid($this->pmid)) { echo '<a class="button" href="http://www.ncbi.nlm.nih.gov/pubmed/', $this->pmid, '"><span>View in PubMed</span></a> '; } echo '<a class="button" href="related.php?uuid=', $this->uuid, '"><span>Related</span></a> '; echo '<a class="button" href="details.php?uuid=', $this->uuid, '"><span>Add to database</span></a>'; echo '</div></td></tr>'; echo '</table>'; }