Skip to content
Snippets Groups Projects
Commit e6944c09 authored by Beatrycze Volk's avatar Beatrycze Volk Committed by Norman Steger
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 2383 additions and 0 deletions
<?php
namespace Slub\Bison\Controller;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
use GuzzleHttp\Client;
use Elastic\Elasticsearch\ClientBuilder;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Slub\Bison\Utility\IndexDatabaseList;
use Slub\Bison\Utility\LocalFilter;
use Slub\Bison\Utility\LocalPriceList;
use Slub\Bison\Utility\MirrorJournalList;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* Abstract base controller for the extension
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
*/
abstract class AbstractController extends ActionController implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* @var Client
* @access protected
*/
protected $client;
/**
* @var array
* @access protected
*/
protected $extConfig;
/**
* This holds the request parameters
*
* @var array
* @access protected
*/
protected $requestData;
/**
* This holds some common data for the fluid view
*
* @var array
* @access protected
*/
protected $viewData;
/**
* @var IndexDatabaseList
* @access protected
*/
protected $indexDatabaseList;
/**
* @var LocalPriceList
* @access protected
*/
protected $localPriceList;
/**
* @var MirrorJournalList
* @access protected
*/
protected $mirrorJournalList;
/**
* @var LocalFilter
* @access protected
*/
protected $localFilter;
/**
* This is the constructor to initialize controllers.
*
* @access public
*
* @return void
*/
public function __construct()
{
// Get extension configuration.
$this->extConfig = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('bison');
$this->client = new Client(
[
// Base URI is used with relative requests
'base_uri' => 'https://service.tib.eu/bison/api/public/v1/',
// You can set any number of default request options.
'timeout' => 10.0,
'headers' =>
[
'User-Agent' => $this->extConfig['userAgent'],
],
]
);
$this->requestData = GeneralUtility::_GPmerged('tx_bison');
$this->viewData = [
'pageUid' => $GLOBALS['TSFE']->id,
'uniqueId' => uniqid(),
'requestData' => $this->requestData
];
$this->indexDatabaseList = new IndexDatabaseList();
$this->localPriceList = new LocalPriceList();
$this->mirrorJournalList = new MirrorJournalList();
$this->localFilter = new LocalFilter();
}
/**
* Gets contact data stored in extension configuration.
*
* @access protected
*
* @return array
*/
protected function getContactPerson()
{
return [
'name' => $this->extConfig['contactName'],
'email' => $this->extConfig['contactEmail'],
'url' => $this->extConfig['contactUrl']
];
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Controller;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
use Slub\Bison\Domain\Repository\JournalRepository;
use Slub\Bison\Model\Journal;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Extbase\Annotation\IgnoreValidation;
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
/**
* The journal controller for the Bison extension.
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property JournalRepository $journalRepository
* @property Journal $journal This holds the journal for displaying to the frontend
*/
class JournalController extends AbstractController
{
/**
* @var JournalRepository
* @access private
*/
private $journalRepository;
/**
* @var Journal
* @access private
*/
private $journal;
/**
* @param JournalRepository $journalRepository
*
* @return void
*/
public function injectJournalRepository(JournalRepository $journalRepository)
{
$this->journalRepository = $journalRepository;
}
/**
* The journal function returning one journal based on idx.
*
* @access public
*
* @return void
*/
public function mainAction()
{
$this->getJournal();
$this->view->assign('journal', $this->journal);
$this->view->assign('contact', $this->getContactPerson());
$this->view->assign('viewData', $this->viewData);
}
/**
* Gets journal from API.
*
* @access private
*
* @return void
*/
private function getJournal()
{
try {
$response = $this->client->request(
'GET',
'journal/'.$this->requestData['id']
);
if ($response->getStatusCode() === 200) {
$content = $response->getBody()->getContents();
$journalJson = json_decode($content);
$this->journal = new Journal($journalJson);
$this->mirrorJournalList->assignMirrorJournal($this->journal);
$this->localPriceList->assignLocalPrice($this->journal);
}
} catch (Exception $e) {
$this->logger->error('Request error: '.$e->getMessage());
}
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Controller;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
use Slub\Bison\Domain\Repository\JournalRepository;
use Slub\Bison\Model\Journal;
use Slub\Bison\Model\Language;
use Slub\Bison\Model\Subject;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Extbase\Annotation\IgnoreValidation;
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
/**
* The recommender controller for the Bison extension
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property JournalRepository $journalRepository
* @property array<Journal> $results This holds the journals for displaying to the frontend
*/
class RecommenderController extends AbstractController
{
/**
* @var JournalRepository
* @access private
*/
private $journalRepository;
/**
* @var array<Journal>
* @access private
*/
private $results;
/**
* @param JournalRepository $journalRepository
*
* @return void
*/
public function injectJournalRepository(JournalRepository $journalRepository)
{
$this->journalRepository = $journalRepository;
}
/**
* The recommender function returning journals based on title etc.
*
* @return void
*/
public function mainAction()
{
$this->results = [];
if (!empty($this->requestData['title']) || !empty($this->requestData['abstract']) || !empty($this->requestData['references'])) {
try {
$response = $this->client->request(
'POST',
'search',
[
'json' => [
'title' => $this->requestData['title'],
'abstract' => $this->requestData['abstract'],
'references' => $this->requestData['references'],
]
]
);
if ($response->getStatusCode() === 200) {
$content = $response->getBody()->getContents();
$result = json_decode($content);
foreach ($result->journals as $journal) {
$this->results[] = new Journal($journal);
}
$this->indexDatabaseList->assignIndexDatabases($this->results);
$this->localPriceList->assignLocalPrices($this->results);
$this->mirrorJournalList->assignMirrorJournals($this->results);
$this->mirrorJournalList->markMirrorJournals($this->results);
$this->localFilter->filter($this->results);
$this->view->assign('maxApc', $this->getMaxApc());
$this->view->assign('maxPublicationTime', $this->getMaxPublicationTime());
$this->view->assign('keywords', $this->getKeywords());
$this->view->assign('languages', $this->getLanguages());
$this->view->assign('subjects', $this->getSubjects());
$this->view->assign('suggestLanguage', $this->getSuggestLanguage($result));
$this->view->assign('suggestSubject', $this->getSuggestSubject($result));
$this->view->assign('displayMismatchedResults', filter_var($this->extConfig['displayMismatchedResults'], FILTER_VALIDATE_BOOLEAN));
$this->view->assign('displayMirrorJournals', filter_var($this->extConfig['displayMirrorJournals'], FILTER_VALIDATE_BOOLEAN));
$this->view->assign('isFilterTooStrict', $this->isFilterTooStrict());
$this->view->assign('countResults', $this->countResultsAfterFilter());
$this->view->assign('results', $this->results);
}
} catch (Exception $e) {
$this->logger->error('Request error: '.$e->getMessage());
$this->view->assign('error', $e->getMessage());
}
}
$this->view->assign('contact', $this->getContactPerson());
$this->view->assign('viewData', $this->viewData);
}
/**
* Checks if local filters are too strict. It is a case when after
* filtering we have no results, but without filters there are results.
*
* @return bool
*/
private function isFilterTooStrict()
{
return $this->countResultsAfterFilter() == 0 && count($this->results) > 0;
}
/**
* Counts all results which match to filter conditions.
*
* @return int
*/
private function countResultsAfterFilter()
{
$count = 0;
foreach ($this->results as $result) {
if ($result->getFilter() !== false) {
$count++;
}
}
return $count;
}
/**
* Gets the language suggested for results.
*
* @param array $result JSON array with results
*
* @return Language|null
*/
private function getSuggestLanguage($result)
{
if ($result->language !== NULL) {
return new Language($result->language);
}
}
/**
* Gets the subject suggested for results.
*
* @param array $result JSON array with results
*
* @return Subject|null
*/
private function getSuggestSubject($result)
{
if ($result->subject->code !== NULL) {
return Subject::fromSubject($result->subject);
}
}
/**
* Gets the max APC for client side filter. APC can be stored
* in filter field (when overwritten by local data)
* or in APC max field.
*
* @return int
*/
private function getMaxApc()
{
$apc = 0;
foreach ($this->results as $result) {
if (!empty($result->getLocalPrice()) && !empty($result->getLocalPrice()->getPrice())) {
$euro = $result->getLocalPrice()->getPrice()->getEuro();
if ($euro !== NULL && $apc < $euro) {
$apc = $euro;
}
} else {
$euro = $result->getApcMax()->getEuro();
if ($euro !== NULL && $apc < $euro) {
$apc = $euro;
}
}
}
return (ceil($apc / 100) * 100);
}
/**
* Gets the max publication time for client side filter.
*
* @return int
*/
private function getMaxPublicationTime()
{
$weeks = 0;
foreach ($this->results as $result) {
if ($weeks < $result->getPublicationTimeWeeks()) {
$weeks = $result->getPublicationTimeWeeks();
}
}
return $weeks;
}
/**
* Gets the keywords for client side filter.
*
* @return array
*/
private function getKeywords()
{
$keywords = [];
foreach ($this->results as $result) {
$resultKeywords = $result->getKeywords();
foreach ($resultKeywords as $keyword) {
if (!in_array($keyword, $keywords)) {
$keywords[] = $keyword;
}
}
}
sort($keywords);
return $keywords;
}
/**
* Gets the languages for client side filter.
*
* @return array
*/
private function getLanguages()
{
$languages = [];
foreach ($this->results as $result) {
$resultLanguages = $result->getLanguages();
foreach ($resultLanguages as $language) {
if (!in_array($language, $languages)) {
$languages[] = $language;
}
}
}
usort($languages, function ($first, $second) {
return strcmp($first->getName(), $second->getName());
});
return $languages;
}
/**
* Gets the subjects for client side filter.
*
* @return array
*/
private function getSubjects()
{
$subjects = [];
foreach ($this->results as $result) {
foreach ($result->getSubjects() as $subject) {
$code = $subject->getCode();
if (!isset($subjects[$code])) {
$subjects[$code] = $subject;
}
$code = $subject->getParent()->getCode();
if (!isset($subjects[$code])) {
$subjects[$code] = $subject->getParent();
}
}
}
uasort($subjects, function ($first, $second) {
return strcmp($first->getCode(), $second->getCode());
});
return array_values($subjects);
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* ApcMax
*/
class ApcMax extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* euro
*
* @var float
*/
protected $euro = null;
/**
* price
*
* @var integer
*/
protected $price = null;
/**
* currency
*
* @var string
*/
protected $currency = null;
/**
* Returns the euro
*
* @return float
*/
public function getEuro()
{
return $this->euro;
}
/**
* Sets the euro
*
* @param float $euro
* @return void
*/
public function setEuro(float $euro)
{
$this->euro = $euro;
}
/**
* Returns the price
*
* @return int
*/
public function getPrice()
{
return $this->price;
}
/**
* Sets the price
*
* @param int $price
* @return void
*/
public function setPrice(int $price)
{
$this->price = $price;
}
/**
* Returns the currency
*
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* Sets the currency
*
* @param string $currency
* @return void
*/
public function setCurrency(string $currency)
{
$this->currency = $currency;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Article
*/
class Article extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* title
*
* @var string
*/
protected $title = null;
/**
* doi
*
* @var string
*/
protected $doi = null;
/**
* Returns the title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Sets the title
*
* @param string $title
* @return void
*/
public function setTitle(string $title)
{
$this->title = $title;
}
/**
* Returns the doi
*
* @return string
*/
public function getDoi()
{
return $this->doi;
}
/**
* Sets the doi
*
* @param string $doi
* @return void
*/
public function setDoi(string $doi)
{
$this->doi = $doi;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* DatasetState
*/
class DatasetState extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* dataset
*
* @var string
*/
protected $dataset = null;
/**
* date
*
* @var \DateTime
*/
protected $date = null;
/**
* Returns the dataset
*
* @return string
*/
public function getDataset()
{
return $this->dataset;
}
/**
* Sets the dataset
*
* @param string $dataset
* @return void
*/
public function setDataset(string $dataset)
{
$this->dataset = $dataset;
}
/**
* Returns the date
*
* @return \DateTime
*/
public function getDate()
{
return $this->date;
}
/**
* Sets the date
*
* @param \DateTime $date
* @return void
*/
public function setDate(\DateTime $date)
{
$this->date = $date;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* EditorialProcessReview
*/
class EditorialProcessReview extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* process
*
* @var string
*/
protected $process = null;
/**
* Returns the process
*
* @return string
*/
public function getProcess()
{
return $this->process;
}
/**
* Sets the process
*
* @param string $process
* @return void
*/
public function setProcess(string $process)
{
$this->process = $process;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* IsReplacedBy
*/
class IsReplacedBy extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* replacement
*
* @var string
*/
protected $replacement = null;
/**
* Returns the replacement
*
* @return string
*/
public function getReplacement()
{
return $this->replacement;
}
/**
* Sets the replacement
*
* @param string $replacement
* @return void
*/
public function setReplacement(string $replacement)
{
$this->replacement = $replacement;
}
}
This diff is collapsed.
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Keyword
*/
class Keyword extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* keyword
*
* @var string
*/
protected $keyword = null;
/**
* Returns the keyword
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Sets the keyword
*
* @param string $keyword
* @return void
*/
public function setKeyword(string $keyword)
{
$this->keyword = $keyword;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Language
*/
class Language extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* lang
*
* @var string
*/
protected $lang = null;
/**
* Returns the lang
*
* @return string
*/
public function getLang()
{
return $this->lang;
}
/**
* Sets the lang
*
* @param string $lang
* @return void
*/
public function setLang(string $lang)
{
$this->lang = $lang;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* License
*/
class License extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* nonCommercial
*
* @var boolean
*/
protected $nonCommercial = null;
/**
* noDerivative
*
* @var boolean
*/
protected $noDerivative = null;
/**
* attribution
*
* @var boolean
*/
protected $attribution = null;
/**
* Returns the nonCommercial
*
* @return bool
*/
public function getNonCommercial()
{
return $this->nonCommercial;
}
/**
* Sets the nonCommercial
*
* @param bool $nonCommercial
* @return void
*/
public function setNonCommercial(bool $nonCommercial)
{
$this->nonCommercial = $nonCommercial;
}
/**
* Returns the boolean state of nonCommercial
*
* @return bool
*/
public function isNonCommercial()
{
return $this->nonCommercial;
}
/**
* Returns the noDerivative
*
* @return bool
*/
public function getNoDerivative()
{
return $this->noDerivative;
}
/**
* Sets the noDerivative
*
* @param bool $noDerivative
* @return void
*/
public function setNoDerivative(bool $noDerivative)
{
$this->noDerivative = $noDerivative;
}
/**
* Returns the boolean state of noDerivative
*
* @return bool
*/
public function isNoDerivative()
{
return $this->noDerivative;
}
/**
* Returns the attribution
*
* @return bool
*/
public function getAttribution()
{
return $this->attribution;
}
/**
* Sets the attribution
*
* @param bool $attribution
* @return void
*/
public function setAttribution(bool $attribution)
{
$this->attribution = $attribution;
}
/**
* Returns the boolean state of attribution
*
* @return bool
*/
public function isAttribution()
{
return $this->attribution;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Subject
*/
class Subject extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* term
*
* @var string
*/
protected $term = null;
/**
* Returns the term
*
* @return string
*/
public function getTerm()
{
return $this->term;
}
/**
* Sets the term
*
* @param string $term
* @return void
*/
public function setTerm(string $term)
{
$this->term = $term;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Domain\Repository;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* The repository for Journals
*/
class JournalRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Access Data DTO
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property string $url This holds the url of the journal's webpage
* @property string $authorInstructionsUrl This holds the url of the author instructions
* @property string $aimsAndScopeUrl This holds the url of the journal aims and scope
* @property string $editorialBoardUrl This holds the url of the editorial board
*/
class AccessData
{
/**
* url of the journal's webpage
*
* @var string
*/
protected $url;
/**
* author instructions url
*
* @var string
*/
protected $authorInstructionsUrl;
/**
* aims and scope url
*
* @var string
*/
protected $aimsAndScopeUrl;
/**
* editorial board url
*
* @var string
*/
protected $editorialBoardUrl;
/**
* Empty constructor
*
* @return void
*/
public function __construct()
{
}
/**
* Constructor from journal JSON
*
* @access public
*
* @static
*
* @param array $journal JSON journal
*
* @return AccessData instance of this class
*/
public static function fromJournal($journal)
{
$instance = new self();
$instance->url = $journal->ref_journal;
$instance->authorInstructionsUrl = $journal->ref_author_instructions;
$instance->aimsAndScopeUrl = $journal->aims_scope;
$instance->editorialBoardUrl = $journal->editorial_board_url;
return $instance;
}
/**
* Constructor from URL
*
* @access public
*
* @static
*
* @param string $url URL of the webpage of the journal
*
* @return AccessData instance of this class
*/
public static function fromUrl($url)
{
$instance = new self();
$instance->url = $url;
return $instance;
}
/**
* Returns the url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Returns the author instructions url
*
* @return string
*/
public function getAuthorInstructionsUrl()
{
return $this->authorInstructionsUrl;
}
/**
* Returns the aims and scope url
*
* @return string
*/
public function getAimsAndScopeUrl()
{
return $this->aimsAndScopeUrl;
}
/**
* Returns the editorial board url
*
* @return string
*/
public function getEditorialBoardUrl()
{
return $this->editorialBoardUrl;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Article DTO
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property string $title This holds the article's title
* @property string $doi This holds the article's DOI
* @property string $type This holds the possible types of article: 'title', 'abstract' and 'doi'
*/
class Article
{
/**
* title
*
* @var string
*/
protected $tile;
/**
* DOI
*
* @var string
*/
protected $doi;
/**
* Constructor for article
*
* @access public
*
* @param array $article JSON article
*/
public function __construct($article)
{
$this->title = $article->title;
$this->doi = $article->doi;
}
/**
* Returns the title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Returns the doi
*
* @return string
*/
public function getDoi()
{
return $this->doi;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* EditorialReviewProcess DTO
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property string $process This holds the name of editorial review process
*/
class EditorialReviewProcess
{
/**
* process
*
* @var string
*/
protected $process;
/**
* Constructor for editorial review process
*
* @access public
*
* @param string $process the name of the process
*/
public function __construct($process)
{
$this->process = $process;
}
/**
* Returns the process
*
* @return string
*/
public function getProcess()
{
return $this->process;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* IndexDatabase DTO - this holds the information about the databases
* in which the journal is indexed. This information comes from the CSV file.
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property string $pIssn This holds the P-ISSN of the journal
* @property string $eIssn This holds the E-ISSN of the journal
* @property bool $pubMed This holds the information if the journal is indexed in PubMed database
* @property bool $openAlex This holds the information if the journal is indexed in Open Alex database
* @property bool $webOfScience This holds the information if the journal is indexed in Web of Science database
* @property bool $scopus This holds the information if the journal is indexed in Scopus database
*/
class IndexDatabase
{
/**
* P-ISSN of the journal
*
* @var string
*/
protected $pIssn;
/**
* E-ISSN of the journal
*
* @var string
*/
protected $eIssn;
/**
* PubMed
*
* @var boolean
*/
protected $pubMed;
/**
* OpenAlex
*
* @var boolean
*/
protected $openAlex;
/**
* Web of Science
*
* @var boolean
*/
protected $webOfScience;
/**
* Scopus
*
* @var boolean
*/
protected $scopus;
/**
* Constructor for index database
*
* @access public
*
* @param string $pIssn the P-ISSN of the journal
* @param string $eIssn the E-ISSN of the journal
* @param string $pubMed format 'Y' or 'N' - if 'Y', the journal is indexed in database
* @param string $openAlex format 'Y' or 'N' - if 'Y', the journal is indexed in database
* @param string $webOfScience format 'Y' or 'N' - if 'Y', the journal is indexed in database
* @param string $scopus format 'Y' or 'N' - if 'Y', the journal is indexed in database
*/
public function __construct($pIssn, $eIssn, $pubMed, $openAlex, $webOfScience, $scopus)
{
$this->pIssn = $pIssn;
$this->eIssn = $eIssn;
$this->pubMed = $this->setValue($pubMed);
$this->openAlex = $this->setValue($openAlex);
$this->webOfScience = $this->setValue($webOfScience);
$this->scopus = $this->setValue($scopus);
}
/**
* Returns the P-ISSN of the journal
*
* @return string
*/
public function getPIssn()
{
return $this->pIssn;
}
/**
* Returns the E-ISSN of the journal
*
* @return string
*/
public function getEIssn()
{
return $this->eIssn;
}
/**
* Returns the information if journal is stored in PubMed database
*
* @return bool
*/
public function getPubMed()
{
return $this->pubMed;
}
/**
* Returns the information if journal is stored in OpenAlex database
*
* @return bool
*/
public function getOpenAlex()
{
return $this->openAlex;
}
/**
* Returns the information if journal is stored in Web of Science database
*
* @return bool
*/
public function getWebOfScience()
{
return $this->webOfScience;
}
/**
* Returns the information if journal is stored in Scopus database
*
* @return bool
*/
public function getScopus()
{
return $this->scopus;
}
/**
* Set boolean value for database.
*
* @param string $value format 'Y' or 'N' - if 'Y', the journal is indexed in database
*
* @return bool
*/
private function setValue($value)
{
return $value === 'Y';
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Journal DTO
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property string $idx This holds the xid of the journal
* @property string $id This holds the id of the journal
* @property Score $id This holds the score which informs how much the searched article matches to this journal
* @property Price $apcMax This holds the P-ISSN of the journal
* @property string $pIssn This holds the P-ISSN of the journal
* @property string $eIssn This holds the E-ISSN of the journal
* @property string $title This holds the title of the journal
* @property string $alternativeTitle This holds the alternative title of the journal
* @property bool $planSCompliance This holds the information if the journal is plan S compliant
* @property bool $retainsCopyrightAuthor This holds the information if the author retains copyright
* @property bool $doiPidScheme This holds the information if the article receives DOI
* @property bool $hasApc This holds the information if the journal has APC
* @property bool $hasOtherCharges This holds the information if the journal has other charges
* @property Publisher $publisher This holds the information about the publisher
* @property integer $publicationTimeWeeks This holds the information about the amount of weeks needed for publication
*/
class Journal
{
/**
* idx of the journal
*
* @var string
*/
protected $idx;
/**
* id of the journal
*
* @var string
*/
protected $id;
/**
* score
*
* @var Score
*/
protected $score;
/**
* maximal article processing charge (APC)
*
* @var Price
*/
protected $apcMax;
/**
* E-ISSN of the journal
*
* @var string
*/
protected $eIssn;
/**
* P-ISSN of the journal
*
* @var string
*/
protected $pIssn;
/**
* title
*
* @var string
*/
protected $title;
/**
* alternative title
*
* @var string
*/
protected $alternativeTitle;
/**
* plan S compliance
*
* @var boolean
*/
protected $planSCompliance;
/**
* information if the author retains copyright
*
* @var boolean
*/
protected $retainsCopyrightAuthor;
/**
* information if the article receives DOI
*
* @var boolean
*/
protected $doiPidScheme;
/**
* has APC
*
* @var boolean
*/
protected $hasApc;
/**
* has other charges
*
* @var boolean
*/
protected $hasOtherCharges;
/**
* publisher
*
* @var Publisher
*/
protected $publisher;
/**
* publication time weeks
*
* @var integer
*/
protected $publicationTimeWeeks;
/**
* access data
*
* @var AccessData
*/
protected $accessData = [];
/**
* keywords
*
* @var array<Keyword>
*/
protected $keywords = [];
/**
* licenses
*
* @var array<License>
*/
protected $licenses = [];
/**
* subjects
*
* @var array<Subject>
*/
protected $subjects = [];
/**
* editorial review processes
*
* @var array<EditorialReviewProcess>
*/
protected $editorialReviewProcesses = [];
/**
* replacements
*
* @var array<Replacement>
*/
protected $replacements;
/**
* created date
*
* @var \DateTime
*/
protected $createdDate;
/**
* discontinued date
*
* @var \DateTime
*/
protected $discontinuedDate;
/**
* last updated
*
* @var \DateTime
*/
protected $lastUpdated;
/**
* has preservation
*
* @var boolean
*/
protected $hasPreservation;
/**
* true if matches filter, false if doesn't match filter
*
* @var boolean
*/
protected $filter;
/**
* local price
*
* @var LocalPrice
*/
protected $localPrice;
/**
* mirror journal
*
* @var MirrorJournal
*/
protected $mirrorJournal;
/**
* mark as mirror journal
*
* @var boolean
*/
protected $isMirrorJournal;
/**
* index database
*
* @var IndexDatabase
*/
protected $indexDatabase;
/**
* Construct for journal instance
*
* @access public
*
* @param array $journal The journal JSON
*
* @return void
*/
public function __construct($journal)
{
$this->idx = $journal->idx;
$this->id = $journal->id;
$this->score = new Score($journal->score);
$this->apcMax = Price::fromAPC($journal->apc_max);
$this->eIssn = $journal->eissn;
$this->pIssn = $journal->pissn;
$this->title = $journal->title;
$this->alternativeTitle = $journal->alternative_title;
$this->planSCompliance = $journal->plan_s_compliance;
$this->retainsCopyrightAuthor = $journal->copyright_author_retains;
$this->doiPidScheme = $journal->doi_pid_scheme;
$this->hasApc = $journal->has_apc;
$this->hasOtherCharges = $journal->has_other_charges;
$this->publisher = new Publisher($journal->publisher_name, $journal->publisher_country);
$this->publicationTimeWeeks = $journal->publication_time_weeks;
$this->accessData = AccessData::fromJournal($journal);
foreach ($journal->keywords as $keyword) {
$this->keywords[] = new Keyword($keyword);
}
foreach ($journal->languages as $language) {
$this->languages[] = new Language($language);
}
foreach ($journal->licenses as $license) {
$this->licenses[] = new License($license);
}
foreach ($journal->subjects as $subject) {
$this->subjects[] = Subject::fromSubject($subject);
}
foreach ($journal->editorial_review_process as $process) {
$this->editorialReviewProcesses[] = new EditorialReviewProcess($process);
}
$this->createdDate = $journal->created_date;
$this->filter = false;
$this->isMirrorJournal = false;
}
/**
* Returns the idx
*
* @return string
*/
public function getIdx()
{
return $this->idx;
}
/**
* Returns the id
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Returns the score
*
* @return Score
*/
public function getScore()
{
return $this->score;
}
/**
* Returns the max APC
*
* @return Price
*/
public function getApcMax()
{
return $this->apcMax;
}
/**
* Returns the E-ISSN
*
* @return string
*/
public function getEIssn()
{
return $this->eIssn;
}
/**
* Returns the P-ISSN
*
* @return string
*/
public function getPIssn()
{
return $this->pIssn;
}
/**
* Returns the ISSNs
*
* @return string
*/
public function getIssns()
{
if (!empty($this->eIssn) && !empty($this->pIssn)) {
return $this->eIssn.', '.$this->pIssn;
} else if (!empty($this->eIssn)) {
return $this->eIssn;
} else {
return $this->pIssn;
}
}
/**
* Returns the title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Returns the alternative title
*
* @return string
*/
public function getAlternativeTitle()
{
return $this->alternativeTitle;
}
/**
* Returns the information if plan S compliant
*
* @return boolean
*/
public function getPlanSCompliance()
{
return $this->planSCompliance;
}
/**
* Returns the information if author retains copyright
*
* @return boolean
*/
public function getRetainsCopyrightAuthor()
{
return $this->retainsCopyrightAuthor;
}
/**
* Returns the information if article receives DOI
*
* @return boolean
*/
public function getDoiPidScheme()
{
return $this->doiPidScheme;
}
/**
* Returns the information if there is APC
*
* @return bool
*/
public function getHasApc()
{
return $this->hasApc;
}
/**
* Returns the information if there are other charges
*
* @return bool
*/
public function getHasOtherCharges()
{
return $this->hasOtherCharges;
}
/**
* Returns the publisher
*
* @return Publisher
*/
public function getPublisher()
{
return $this->publisher;
}
/**
* Returns the access data
*
* @return AccessData
*/
public function getAccessData()
{
return $this->accessData;
}
/**
* Returns the publication time in weeks
*
* @return int
*/
public function getPublicationTimeWeeks()
{
return $this->publicationTimeWeeks;
}
/**
* Returns the keywords
*
* @return array<Keyword>
*/
public function getKeywords()
{
return $this->keywords;
}
/**
* Returns the languages
*
* @return array<Language>
*/
public function getLanguages()
{
return $this->languages;
}
/**
* Returns the licenses
*
* @return array<License>
*/
public function getLicenses()
{
return $this->licenses;
}
/**
* Returns the subjects
*
* @return array<Subject>
*/
public function getSubjects()
{
return $this->subjects;
}
/**
* Returns the editorial review processes
*
* @return array<EditorialReviewProcess>
*/
public function getEditorialReviewProcesses()
{
return $this->editorialReviewProcesses;
}
/**
* Date of creation
*
* @return \DateTime
*/
public function getCreatedDate()
{
return $this->createdDate;
}
/**
* Returns the information if the journal matches filter results
*
* @return boolean
*/
public function getFilter()
{
return $this->filter;
}
/**
* Sets the information if the journal matches filter results
*
* @param boolean $filter data or false if there is no filter match
*
* @return void
*/
public function setFilter($filter)
{
$this->filter = $filter;
}
/**
* Returns the local price
*
* @return LocalPrice
*/
public function getLocalPrice()
{
return $this->localPrice;
}
/**
* Sets the the local price
*
* @param LocalPrice $localPrice
*
* @return void
*/
public function setLocalPrice($localPrice)
{
$this->localPrice = $localPrice;
}
/**
* Returns the mirror journal
*
* @return MirrorJournal
*/
public function getMirrorJournal()
{
return $this->mirrorJournal;
}
/**
* Sets the the mirror journal
*
* @param MirrorJournal $mirrorJournal
*
* @return void
*/
public function setMirrorJournal($mirrorJournal)
{
$this->mirrorJournal = $mirrorJournal;
}
/**
* Returns the information if is mirror journal
*
* @return bool
*/
public function getIsMirrorJournal()
{
return $this->isMirrorJournal;
}
/**
* Sets the the information if is mirror journal
*
* @param boolean $isMirrorJournal
*
* @return void
*/
public function setIsMirrorJournal($isMirrorJournal)
{
$this->isMirrorJournal = $isMirrorJournal;
}
/**
* Returns the information about the index databases
*
* @return IndexDatabase
*/
public function getIndexDatabase()
{
return $this->indexDatabase;
}
/**
* Sets the the information the index databases
*
* @param IndexDatabase $indexDatabase
*
* @return void
*/
public function setIndexDatabase($indexDatabase)
{
$this->indexDatabase = $indexDatabase;
}
}
<?php
declare(strict_types=1);
namespace Slub\Bison\Model;
/**
* This file is part of the "Bison" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 Beatrycze Volk <beatrycze.volk@slub-dresden.de>, SLUB
*/
/**
* Keyword DTO
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage bison
* @access public
* @property string $keyword This holds the keyword
* @property string $label This holds the keyword without white spaces
*/
class Keyword
{
/**
* keyword
*
* @var string
*/
protected $keyword;
/**
* label
*
* @var string
*/
protected $label;
/**
* Constructs keyword instance
*
* @access public
*
* @param array $keyword The keyword
*
* @return void
*/
public function __construct($keyword)
{
$this->keyword = $keyword;
$this->label = str_replace(' ', '', $keyword);
}
/**
* Returns the keyword
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Returns the label
*
* @return string
*/
public function getLabel()
{
return $this->label;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment