/** * @param Publication $publication * * @return array */ private function createFields(Publication $publication) { // NOTE: dc.citation.* are non standard tags recommended by Google Scholar $fields = array(); foreach ($publication->getAuthors() as $author) { if ($author->getLastName() && $author->getFirstName()) { $fields[] = array('dc.creator', $author->getFirstName() . ' ' . $author->getLastName()); } } $fields[] = array('dc.title', $publication->getTitle()); // TODO: not dcterms.issued and YYYY-MM-DD according to https://wiki.whatwg.org/wiki/MetaExtensions? $fields[] = array('dc.issued', $publication->getDatePublished('Y/m/d')); $fields[] = array('dc.relation.ispartof', $publication->getJournal()); $fields[] = array('dc.relation.ispartof', $publication->getBooktitle()); $fields[] = array('dc.citation.volume', $publication->getVolume()); $fields[] = array('dc.citation.issue', $publication->getNumber()); $fields[] = array('dc.citation.spage', $publication->getFirstPage()); $fields[] = array('dc.citation.epage', $publication->getLastPage()); $file = $publication->getFullTextFile(); if ($file) { $fields[] = array('dc.identifier', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true)); } $fields[] = array('dc.publisher', $publication->getInstitution()); // used for institution, too $fields[] = array('dc.publisher', $publication->getPublisher()); $fields[] = array('dc.identifier', $publication->getDoi()); return $fields; }
/** * @param Publication $publication * * @return array */ private function createFields(Publication $publication) { $fields = array(); $fields[] = array('prism.title', $publication->getTitle()); // TODO: valid? Isn't it part of the dc subset of prism? $fields[] = array('prism.publicationDate', $publication->getDatePublished('Y-m-d')); $fields[] = array('prism.publicationYear', $publication->getDatePublished('Y')); $fields[] = array('prism.publicationName', $publication->getJournal()); $fields[] = array('prism.publicationName', $publication->getBooktitle()); $fields[] = array('prism.volume', $publication->getVolume()); $fields[] = array('prism.number', $publication->getNumber()); $fields[] = array('prism.edition', $publication->getEdition()); $fields[] = array('prism.startingPage', $publication->getFirstPage()); $fields[] = array('prism.endingPage', $publication->getLastPage()); $file = $publication->getFullTextFile(); if ($file) { $fields[] = array('prism.url', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true)); } //$fields[] = array('prism.issn', false); // TODO $fields[] = array('prism.isbn', $publication->getIsbn()); $fields[] = array('prism.copyright', $publication->getCopyright()); $fields[] = array('prism.organization', $publication->getInstitution()); // TODO: check if valid usage $fields[] = array('prism.doi', $publication->getDoi()); return $fields; }
/** * @param Publication $publication * * @return array * @throws Exception */ private function createFields(Publication $publication) { $fields = array(); $fields[] = array('TY', $this->encodeType($publication->getTypeName())); foreach ($publication->getAuthors() as $keyword) { if ($keyword->getLastName() && $keyword->getFirstName()) { $fields[] = array('AU', $keyword->getLastName() . ', ' . $keyword->getFirstName()); } } $fields[] = array('T1', $publication->getTitle()); // TODO: check if valid $fields[] = array('JA', $publication->getJournal()); // TODO: check if valid $fields[] = array('TI', $publication->getBooktitle()); // TODO: check if valid $fields[] = array('VL', $publication->getVolume()); $fields[] = array('IS', $publication->getNumber()); $fields[] = array('SP', $publication->getFirstPage()); $fields[] = array('EP', $publication->getLastPage()); $fields[] = array('PY', $publication->getDatePublished('Y/m/d')); $fields[] = array('PB', $publication->getPublisher()); $fields[] = array('N1', $publication->getNote()); $file = $publication->getFullTextFile(); if ($file) { $fields[] = array('L1', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true)); } $fields[] = array('UR', $publication->getDoi()); $fields[] = array('SN', $publication->getIsbn()); $fields[] = array('AB', $publication->getAbstract()); foreach ($publication->getKeywords() as $keyword) { $fields[] = array('KW', $keyword->getName()); } return $fields; }
/** * @param Publication $publication * * @return array */ private function createFields(Publication $publication) { $fields = array(); foreach ($publication->getAuthors() as $author) { if ($author->getFirstName() && $author->getLastName()) { $fields[] = array('author', $author->getFirstName() . ' ' . $author->getLastName()); } } $fields[] = array('title', $publication->getTitle()); $fields[] = array('journal', $publication->getJournal()); $fields[] = array('booktitle', $publication->getBooktitle()); $fields[] = array('volume', $publication->getVolume()); $fields[] = array('number', $publication->getNumber()); $fields[] = array('series', $publication->getSeries()); $fields[] = array('edition', $publication->getEdition()); $fields[] = array('pages', $publication->getPages('--')); $fields[] = array('month', $publication->getDatePublished('F')); $fields[] = array('year', $publication->getDatePublished('Y')); $file = $publication->getFullTextFile(); if ($file) { $fields[] = array('url', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true)); } //$fields[] = array('issn', false); // TODO $fields[] = array('isbn', $publication->getIsbn()); $fields[] = array('institution', $publication->getInstitution()); $fields[] = array('school', $publication->getSchool()); $fields[] = array('publisher', $publication->getPublisher()); $fields[] = array('ee', $publication->getDoi()); $fields[] = array('address', $publication->getAddress()); $fields[] = array('howpublished', $publication->getHowpublished()); $fields[] = array('note', $publication->getNote()); $fields[] = array('abstract', $publication->getAbstract()); $fields[] = array('biburl', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId()), true)); return $fields; }
/** * @param Publication $publication * * @return string * @throws exceptions\DBDuplicateEntryException * @throws exceptions\DBForeignKeyException */ public function store(Publication $publication) { if ($publication->getTypeId()) { $type_id = $publication->getTypeId(); } else { $repo = new TypeRepository($this->db); $type = $repo->where('name', '=', $publication->getTypeName())->findSingle(); $type_id = $type->getId(); } if ($publication->getStudyFieldId()) { $study_field_id = $publication->getStudyFieldId(); } else { $repo = new StudyFieldRepository($this->db); $type = $repo->where('name', '=', $publication->getStudyField())->findSingle(); $study_field_id = $type->getId(); } $query = 'INSERT INTO publications (type_id, study_field_id, title, date_published, booktitle, journal, volume, number, pages_from, pages_to, series, edition, note, location, publisher, institution, school, address, isbn, doi, howpublished, abstract, copyright, `foreign`) VALUES (:type_id, :study_field_id, :title, :date_published, :booktitle, :journal, :volume, :number, :pages_from, :pages_to, :series, :edition, :note, :location, :publisher, :institution, :school, :address, :isbn, :doi, :howpublished, :abstract, :copyright, :foreign);'; $this->db->prepare($query); $this->db->bindValue(':type_id', $type_id); $this->db->bindValue(':study_field_id', $study_field_id); $this->db->bindValue(':title', $publication->getTitle()); $this->db->bindValue(':date_published', $publication->getDatePublished()); $this->db->bindValue(':booktitle', $publication->getBooktitle()); $this->db->bindValue(':journal', $publication->getJournal()); $this->db->bindValue(':volume', $publication->getVolume()); $this->db->bindValue(':number', $publication->getNumber()); $this->db->bindValue(':pages_from', $publication->getFirstPage()); $this->db->bindValue(':pages_to', $publication->getLastPage()); $this->db->bindValue(':series', $publication->getSeries()); $this->db->bindValue(':edition', $publication->getEdition()); $this->db->bindValue(':note', $publication->getNote()); $this->db->bindValue(':location', $publication->getLocation()); $this->db->bindValue(':publisher', $publication->getPublisher()); $this->db->bindValue(':institution', $publication->getInstitution()); $this->db->bindValue(':school', $publication->getSchool()); $this->db->bindValue(':address', $publication->getAddress()); $this->db->bindValue(':isbn', $publication->getIsbn()); $this->db->bindValue(':doi', $publication->getDoi()); $this->db->bindValue(':howpublished', $publication->getHowpublished()); $this->db->bindValue(':abstract', $publication->getAbstract()); $this->db->bindValue(':copyright', $publication->getCopyright()); $this->db->bindValue(':foreign', $publication->getForeign()); $this->db->execute(); return $this->db->lastInsertId(); }
/** * @param Publication $publication * * @return array */ private function createFields(Publication $publication) { $fields = array(); $fields[] = array('citation_title', $publication->getTitle()); foreach ($publication->getAuthors() as $author) { if ($author->getLastName() && $author->getFirstName()) { $fields[] = array('citation_author', $author->getLastName() . ', ' . $author->getFirstName()); } } $fields[] = array('citation_publication_date', $publication->getDatePublished('Y/m/d')); $fields[] = array('citation_journal_title', $publication->getJournal()); $fields[] = array('citation_conference_title', $publication->getBooktitle()); $fields[] = array('citation_volume', $publication->getVolume()); if ($publication->getTypeName() == 'techreport') { $fields[] = array('citation_technical_report_number', $publication->getNumber()); } else { $fields[] = array('citation_issue', $publication->getNumber()); } $fields[] = array('citation_firstpage', $publication->getFirstPage()); $fields[] = array('citation_lastpage', $publication->getLastPage()); $file = $publication->getFullTextFile(); if ($file) { $fields[] = array('citation_pdf_url', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true)); } //$fields[] = array('citation_issn', false); // TODO $fields[] = array('citation_isbn', $publication->getIsbn()); $fields[] = array('citation_publisher', $publication->getPublisher()); if ($publication->getTypeName() == 'techreport') { $fields[] = array('citation_technical_report_institution', $publication->getInstitution()); } else { if (in_array($publication->getTypeName(), array('phdthesis', 'mastersthesis'))) { $fields[] = array('citation_dissertation_institution', $publication->getInstitution()); } } $fields[] = array('citation_doi', $publication->getDoi()); $keywords = ''; foreach ($publication->getKeywords() as $keyword) { if ($keyword->getName()) { $keywords .= $keyword->getName() . '; '; } } $keywords = substr($keywords, 0, -2); $fields[] = array('citation_keywords', $keywords); return $fields; }
/** * @param Publication $publication * * @return array * @throws Exception */ private function createFields(Publication $publication) { $fields = array(); $fields['type'] = $this->encodeTypes($publication->getTypeName()); $fields['id'] = 'TODO_' . $publication->getId(); // TODO $fields['title'] = $publication->getTitle(); foreach ($publication->getAuthors() as $author) { if ($author->getFirstName() && $author->getLastName()) { $fields['author'][] = array('family' => $author->getLastName(), 'given' => $author->getFirstName()); } } $fields['issued'] = array('date-parts' => array($publication->getDatePublished('Y'), $publication->getDatePublished('m'), $publication->getDatePublished('d'))); $fields['container-title'] = $publication->getJournal(); // TODO $fields['container-title'] = $publication->getBooktitle(); $fields['citation-number'] = $publication->getNumber(); $fields['volume'] = $publication->getVolume(); $fields['number'] = ''; // TODO $fields['issue'] = ''; // TODO $fields['page'] = ''; $fields['page-first'] = $publication->getFirstPage(); $fields['edition'] = $publication->getEdition(); $fields['abstract'] = $publication->getAbstract(); $fields['DOI'] = $publication->getDoi(); $fields['ISBN'] = $publication->getIsbn(); $fields['ISSN'] = ''; // TODO $file = $publication->getFullTextFile(); if ($file) { $fields['URL'] = Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true); } $fields['note'] = $publication->getNote(); $fields['publisher'] = $publication->getPublisher(); return $fields; }
/** * Shows the publication's journal name. * * @return string */ public function showJournal() { return $this->html($this->publication->getJournal()); }
/** * @param Publication $publication * @param int $max_authors * * @return string */ public function showCitation(Publication $publication, $max_authors = 6) { $citation = '<div class="citation">'; /* shows the title and links to the publication page */ $url = Request::createUrl(array('p' => 'publication', 'id' => $publication->getId())); $citation .= '<a href="' . $this->html($url) . '" class="title">' . $this->html($publication->getTitle()) . '</a><br/>'; /* creates list of authors */ $authors = $publication->getAuthors(); $num = count($authors); $authors_string = ''; if ($num > 0) { $i = 1; foreach ($authors as $author) { if ($i == 1) { /* first author */ $authors_string .= $author->getFirstName(true) . ' ' . $author->getLastName(); } else { if ($i > $max_authors) { /* break with "et al." if too many authors */ $authors_string .= ' et al.'; break; } else { if ($i == $num) { /* last author */ $authors_string .= ' and ' . $author->getFirstName(true) . ' ' . $author->getLastName(); } else { /* all other authors */ $authors_string .= ', ' . $author->getFirstName(true) . ' ' . $author->getLastName(); } } } $i++; } } /* shows list of authors */ $citation .= '<span class="authors">' . $this->html($authors_string) . '</span>'; /* appends publish date behind the authors */ $citation .= ' <span class="year">(' . $this->html($publication->getDatePublished('Y')) . ')</span>'; /* shows journal or booktitle and additional data*/ if ($publication->getJournal()) { $citation .= '<br/><span class="journal">' . $this->html($publication->getJournal()) . '</span>'; if ($publication->getVolume()) { $citation .= ', <span class="volume">' . $this->html($publication->getVolume()) . '</span>'; if ($publication->getNumber()) { $citation .= ' <span class="number">(' . $this->html($publication->getNumber()) . ')</span>'; } } if ($publication->getPages('-')) { $citation .= ', <span class="pages">' . $this->html($publication->getPages('-')) . '</span>'; } } else { if ($publication->getBooktitle()) { $citation .= '<br/>In: <span class="booktitle">' . $this->html($publication->getBooktitle()) . '</span>'; if ($publication->getPages('-')) { $citation .= ', <span class="pages">' . $this->html($publication->getPages('-')) . '</span>'; } } } $links = array(); /* shows full text link */ $file = $publication->getFullTextFile(); if ($file) { $title = $file->getExtension() == '.pdf' ? 'PDF' : 'FULLTEXT'; $url = Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId())); $links[] = '<a href="' . $this->html($url) . '" target="_blank">' . $this->html($title) . '</a>'; } /* shows DOI link */ if ($publication->getDoi()) { $links[] = '<a href="http://dx.doi.org/' . $this->html($publication->getDoi()) . '" target="_blank">DOI</a>'; } /* shows URLs */ if ($publication->getUrls()) { foreach ($publication->getUrls() as $url) { $links[] = '<a href="' . $this->html($url->getUrl()) . '" target="_blank">' . $this->html($url->getName()) . '</a>'; } } /* shows links if there are any */ if (!empty($links)) { $citation .= '<br/><span class="links">' . implode(' - ', $links) . '</span>'; } return $citation . '</div>'; }
/** * @param Publication $publication * * @return string * @throws Exception */ public function export(Publication $publication) { if (!$publication->getTypeName()) { throw new Exception('publication type missing'); } $authors = ''; foreach ($publication->getAuthors() as $author) { if ($author->getFirstName() && $author->getLastName()) { $authors .= $author->getFirstName() . ' ' . $author->getLastName() . ' and '; } } $authors = substr($authors, 0, -5); $keywords = ''; foreach ($publication->getKeywords() as $keyword) { if ($keyword->getName()) { $keywords .= $keyword->getName() . ', '; } } $keywords = substr($keywords, 0, -2); $fields = array(); $fields[] = array('author', $authors); $fields[] = array('title', $publication->getTitle()); $fields[] = array('journal', $publication->getJournal()); $fields[] = array('volume', $publication->getVolume()); $fields[] = array('number', $publication->getNumber()); $fields[] = array('booktitle', $publication->getBooktitle()); $fields[] = array('series', $publication->getSeries()); $fields[] = array('edition', $publication->getEdition()); $fields[] = array('pages', $publication->getPages('--')); $fields[] = array('note', $publication->getNote()); $fields[] = array('location', $publication->getLocation()); $fields[] = array('month', $publication->getDatePublished('F')); $fields[] = array('year', $publication->getDatePublished('Y')); $file = $publication->getFullTextFile(); $urls = $publication->getUrls(); if ($file) { $fields[] = array('url', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId(), 'file_id' => $file->getId()), true)); } else { if ($urls && isset($urls[0])) { $fields[] = array('url', $urls[0]); } } //$fields[] = array('issn', false); $fields[] = array('publisher', $publication->getPublisher()); $fields[] = array('institution', $publication->getInstitution()); $fields[] = array('school', $publication->getSchool()); $fields[] = array('address', $publication->getAddress()); $fields[] = array('howpublished', $publication->getHowpublished()); $fields[] = array('copyright', $publication->getCopyright()); $fields[] = array('doi', $publication->getDoi()); $fields[] = array('isbn', $publication->getIsbn()); $fields[] = array('abstract', $publication->getAbstract()); $fields[] = array('biburl', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId()), true)); $fields[] = array('keywords', $keywords); $result = '@' . $publication->getTypeName() . '{' . $this->generateCiteKey($publication); foreach ($fields as $field) { if ($field[1]) { $result .= ',' . "\n\t" . $field[0] . ' = {' . $this->encodeSpecialChars($field[1]) . '}'; } } $result .= "\n" . '}'; return $result; }