/** * @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(); $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; }
/** * @return string */ public function showEditKeywords() { $keywords = $this->publication->getKeywords(); $string = ''; foreach ($keywords as $keyword) { $string .= '<li> <form action="#" method="post" accept-charset="utf-8"> ' . $this->html($keyword->getName()) . ' <input type="hidden" name="keyword_id" value="' . $this->html($keyword->getId()) . '"/> <input type="hidden" name="action" value="removeKeyword"/> <input type="submit" value="x"/> </form> </li>'; } $string .= '<li><form action="#" method="post" accept-charset="utf-8"> <input name="name" type="text" placeholder="Keyword"/> <input type="hidden" name="action" value="addKeyword"/> <input type="submit" value="Add"/> </form></li>'; return $string; }
/** * @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; }
/** * @param Publication $publication * * @return DOMElement */ private function createRecordHeader(Publication $publication) { $xml = new DOMDocument('1.0', 'UTF-8'); $header = $xml->createElement('header'); $header->appendChild($xml->createElement('identifier', 'oai:' . $this->repositoryIdentifier . ':' . $publication->getId())); $header->appendChild($xml->createElement('datestamp', $publication->getDateAdded('Y-m-d'))); $keywords = $publication->getKeywords(); foreach ($keywords as $keyword) { $setSpec = str_replace(' ', '_', $keyword->getName()); $setSpec = strtolower($setSpec); $header->appendChild($xml->createElement('setSpec', $setSpec)); } return $header; }