예제 #1
0
 /**
  * @param Request $request
  *
  * @return string
  * @throws NotFoundException
  * @throws \Exception
  */
 public function run(Request $request)
 {
     $repo = new TypeRepository($this->db);
     $type = $repo->where('id', '=', $request->get('id'))->findSingle();
     if (!$type) {
         throw new NotFoundException('type not found');
     }
     $repo = new PublicationRepository($this->db);
     $publications = $repo->where('type_id', '=', $request->get('id'))->order('date_published', 'DESC')->find();
     $view = new TypeView($type, $publications);
     return $view->display();
 }
예제 #2
0
 /**
  * @param Request $request
  *
  * @return string
  * @throws NotFoundException
  * @throws \Exception
  */
 public function run(Request $request)
 {
     $repo = new StudyFieldRepository($this->db);
     $study_field = $repo->where('id', '=', $request->get('id'))->findSingle();
     if (!$study_field) {
         throw new NotFoundException('study field not found');
     }
     $repo = new PublicationRepository($this->db);
     $publications = $repo->where('study_field_id', '=', $request->get('id'))->order('date_published', 'DESC')->find();
     $view = new StudyFieldView($study_field, $publications);
     return $view->display();
 }
예제 #3
0
파일: PRISMTags.php 프로젝트: arkuuu/publin
 /**
  * @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;
 }
예제 #4
0
 /**
  * @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;
 }
예제 #5
0
파일: RIS.php 프로젝트: arkuuu/publin
 /**
  * @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;
 }
예제 #6
0
 /**
  * @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;
 }
예제 #7
0
파일: CSLJson.php 프로젝트: arkuuu/publin
 /**
  * @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;
 }
예제 #8
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return string
  * @throws Exception
  * @throws NotFoundException
  */
 private function login(Request $request)
 {
     $errors = array();
     if ($request->post('username') && $request->post('password')) {
         $username = Validator::sanitizeText($request->post('username'));
         $password = Validator::sanitizeText($request->post('password'));
         if ($this->auth->login($username, $password)) {
             $destination = !empty($_SESSION['referrer']) ? $_SESSION['referrer'] : Request::createUrl(array(), true);
             $this->redirect($destination);
         } else {
             $errors[] = 'Invalid user name or password';
         }
     }
     $view = new View('login', $errors);
     return $view->display();
 }
예제 #9
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>';
 }
예제 #10
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;
 }
예제 #11
0
파일: DBLPXML.php 프로젝트: arkuuu/publin
 /**
  * @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;
 }
예제 #12
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool|int
  * @throws PermissionRequiredException
  * @throws exceptions\LoginRequiredException
  */
 private function edit(Request $request)
 {
     if (!$this->auth->checkPermission(Auth::EDIT_KEYWORD)) {
         throw new PermissionRequiredException(Auth::EDIT_KEYWORD);
     }
     $id = Validator::sanitizeNumber($request->get('id'));
     if (!$id) {
         throw new UnexpectedValueException();
     }
     $validator = $this->model->getValidator();
     if ($validator->validate($request->post())) {
         $input = $validator->getSanitizedResult();
         $this->model->update($id, $input);
         return true;
     } else {
         $this->errors = array_merge($this->errors, $validator->getErrors());
         return false;
     }
 }
예제 #13
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool|int
  */
 private function changePassword(Request $request)
 {
     $password = Validator::sanitizeText($request->post('password'));
     if (!$password || !$this->auth->validateLogin($this->user->getName(), $password)) {
         $this->errors[] = 'Invalid current password';
         return false;
     }
     $password_new = Validator::sanitizeText($request->post('password_new'));
     $password_confirm = Validator::sanitizeText($request->post('password_confirm'));
     if (!$password_new || !$password_confirm) {
         $this->errors[] = 'New password required but invalid';
         return false;
     }
     if ($password_new !== $password_confirm) {
         $this->errors[] = 'Entered passwords are not the same';
         return false;
     }
     return $this->auth->setPassword($this->user->getName(), $password_new);
 }
예제 #14
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool
  * @throws \Exception
  */
 private function submit(Request $request)
 {
     $input = $this->model->formatPost($request->post());
     $_SESSION['input'] = $input;
     try {
         $result = $this->store_publication($input);
     } catch (DBDuplicateEntryException $e) {
         //$this->db->cancelTransaction();
         // TODO make single error messages for each case
         $this->errors[] = 'A publication with this name already exists or you tried to add the same author or keyword to this publication twice';
         return false;
     }
     if (empty($this->errors) && $result) {
         if ($this->next()) {
             return true;
         }
         $this->clearForm();
         $this->redirect(Request::createUrl(array('p' => 'browse', 'by' => 'recent')));
         return true;
     } else {
         return false;
     }
 }
예제 #15
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool
  */
 private function deleteUser(Request $request)
 {
     $user_id = Validator::sanitizeNumber($request->post('user_id'));
     if (!$user_id) {
         throw new UnexpectedValueException();
     }
     $model = new UserModel($this->db);
     return $model->delete($user_id);
 }
예제 #16
0
 /**
  * @return string|null
  */
 public function getPublinUrl()
 {
     return Request::createUrl(array('p' => 'publication', 'id' => $this->id));
 }
예제 #17
0
    /**
     * @return string
     */
    public function showEditFiles()
    {
        $files = $this->publication->getFiles();
        $string = '';
        foreach ($files as $file) {
            $url = Request::createUrl(array('p' => 'publication', 'id' => $this->publication->getId(), 'file_id' => $file->getId()));
            $full_text = $file->isFullText() ? ' (full text)' : '';
            $hidden = $file->isHidden() ? ' (hidden)' : '';
            $restricted = $file->isRestricted() ? ' (restricted)' : '';
            $string .= '<li>
                        <form action="#" method="post" accept-charset="utf-8">
                        <a href="' . $this->html($url) . '" target="_blank">' . $this->html($file->getTitle() . $file->getExtension()) . '</a>' . $this->html($full_text . $hidden . $restricted) . '
                        <input type="hidden" name="file_id" value="' . $this->html($file->getId()) . '"/>
                        <input type="hidden" name="action" value="removeFile"/>
                        <input type="submit" value="x" onclick="return confirm(\'Do you really want to delete the file ' . $this->html($file->getTitle() . $file->getExtension()) . '?\')"/>
                        </form>
                        </li>';
        }
        $string .= '<li><form action="#" method="post" enctype="multipart/form-data">
    <label for="file">File:</label>
    <input type="file" name="file" id="file"><br/>
    <label for="title">Description:</label>
    <input type="text" name="title" id="title"><br/>
    <input type="checkbox" name="full_text" id="full_text" value="yes">
    <label for="full_text">Full Text</label>
    <input type="checkbox" name="restricted" id="restricted" value="yes"/>
    <label for="restricted">Access Restricted</label>
    <input type="checkbox" name="hidden" id="hidden" value="yes"/>
    <label for="hidden">Hidden</label><br/>
    <input type="hidden" name="action" value="addFile"/>
    <input type="submit" value="Upload File"/>
</form></li>';
        return $string;
    }
예제 #18
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool|mixed
  * @throws PermissionRequiredException
  * @throws exceptions\LoginRequiredException
  */
 private function addUrl(Request $request)
 {
     if (!$this->auth->checkPermission(Auth::EDIT_PUBLICATION)) {
         throw new PermissionRequiredException(Auth::EDIT_PUBLICATION);
     }
     $id = Validator::sanitizeNumber($request->get('id'));
     if (!$id) {
         throw new UnexpectedValueException();
     }
     $url_model = new UrlModel($this->db);
     $validator = $url_model->getValidator();
     if ($validator->validate($request->post())) {
         $data = $validator->getSanitizedResult();
         $url = new Url($data);
         try {
             return $url_model->store($url, $id);
         } catch (DBDuplicateEntryException $e) {
             $this->errors[] = 'This url is already assigned to this publication';
             return false;
         }
     } else {
         $this->errors = array_merge($this->errors, $validator->getErrors());
         return false;
     }
 }
예제 #19
0
 /**
  * @param Request $request
  *
  * @return bool
  */
 public function searchAuthors(Request $request)
 {
     $field = Validator::sanitizeText($request->get('field'));
     $search = Validator::sanitizeText($request->get('search'));
     if (!$search) {
         $this->errors[] = 'Your search input is invalid';
         return false;
     }
     $search_words = explode(' ', $search);
     $repo = new AuthorRepository($this->db);
     switch (true) {
         case $field === 'given':
             foreach ($search_words as $word) {
                 $repo->where('given', 'LIKE', '%' . $word . '%');
             }
             break;
         case $field === 'family':
             foreach ($search_words as $word) {
                 $repo->where('family', 'LIKE', '%' . $word . '%');
             }
             break;
         case $field === 'about':
             foreach ($search_words as $word) {
                 $repo->where('about', 'LIKE', '%' . $word . '%');
             }
             break;
         default:
             throw new UnexpectedValueException();
     }
     $this->result = $repo->order('family', 'ASC')->find();
     return true;
 }
예제 #20
0
파일: OAIParser.php 프로젝트: arkuuu/publin
 /**
  * @param Publication $publication
  * @param             $metadataPrefix
  *
  * @return array
  */
 private function createRecordMetadataFields(Publication $publication, $metadataPrefix)
 {
     if ($metadataPrefix == 'oai_dc') {
         $fields = array();
         $fields[] = array('dc:title', $publication->getTitle());
         foreach ($publication->getAuthors() as $author) {
             if ($author->getLastName() && $author->getFirstName()) {
                 $fields[] = array('dc:creator', $author->getLastName() . ', ' . $author->getFirstName());
             }
         }
         $fields[] = array('dc:description', $publication->getAbstract());
         $fields[] = array('dc:date', $publication->getDatePublished('Y'));
         $fields[] = array('dc:publisher', $publication->getPublisher());
         $fields[] = array('dc:type', 'Text');
         $fields[] = array('dc:rights', $publication->getCopyright());
         $fields[] = array('dc:identifier', $publication->getDoi());
         $fields[] = array('dc:identifier', Request::createUrl(array('p' => 'publication', 'id' => $publication->getId())));
         return $fields;
     } else {
         throw new UnexpectedValueException('Implementation for ' . $metadataPrefix . ' missing!');
     }
 }