コード例 #1
0
ファイル: PublicationView.php プロジェクト: arkuuu/publin
 /**
  * @return string
  */
 public function showEditUrls()
 {
     $urls = $this->publication->getUrls();
     $string = '';
     foreach ($urls as $url) {
         $string .= '<li>
                     <form action="#" method="post" accept-charset="utf-8">
                     ' . $this->html($url->getName()) . ': <a href="' . $this->html($url->getUrl()) . '" target="_blank">' . $this->html($url->getUrl()) . '</a>
                     <input type="hidden" name="url_id" value="' . $this->html($url->getId()) . '"/>
                     <input type="hidden" name="action" value="removeUrl"/>
                     <input type="submit" value="x"/>
                     </form>
                     </li>';
     }
     $string .= '<li>
                 <form action="#" method="post" accept-charset="utf-8">
                 <input type="text" name="name" placeholder="Name" />
                 <input type="text" name="url" placeholder="Url" />
                 <input type="hidden" name="action" value="addUrl"/>
                 <input type="submit" value="Add"/>
                 </form>
                 </li>';
     return $string;
 }
コード例 #2
0
ファイル: View.php プロジェクト: arkuuu/publin
 /**
  * @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>';
 }
コード例 #3
0
ファイル: Bibtex.php プロジェクト: arkuuu/publin
 /**
  * @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;
 }