Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Filter for "reviewed", and abbreviated journal title #68

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Classes/Domain/Model/Dto/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ class Filter
*/
protected int $externFilter = 0;

/**
* @var int 0=off, 1=intern, 2=extern
*/
protected int $reviewFilter = 0;

/**
* @var array
*/
Expand Down Expand Up @@ -125,6 +130,7 @@ public function __construct(array $settings)
$this->setTags(GeneralUtility::trimExplode(PHP_EOL, $settings['tags'], true));
$this->setAuthor($settings['author'] ?? '');
$this->setExternFilter((int)$settings['extern']);
$this->setReviewFilter((int)$settings['review']);
$this->setRecursive((int)$settings['recursive']);
$this->setRecords(GeneralUtility::intExplode(',', $settings['records'], true));
$this->setExport(GeneralUtility::intExplode(',', $settings['export'], true));
Expand Down Expand Up @@ -467,6 +473,48 @@ public function setExternFilter(int $externFilter): self
return $this;
}

/**
* @return int
*/
public function getReviewFilter(): int
{
return $this->reviewFilter;
}

/**
* @return bool
*/
public function isReviewed(): bool
{
return $this->isReview() || $this->isNotReview();
}

/**
* @return bool
*/
public function isReview(): bool
{
return $this->getReviewFilter() === 1;
}

/**
* @return bool
*/
public function isNotReview(): bool
{
return $this->getReviewFilter() === 2;
}

/**
* @param int $reviewFilter
* @return Filter
*/
public function setReviewFilter(int $reviewFilter): self
{
$this->reviewFilter = $reviewFilter;
return $this;
}

/**
* @return array
*/
Expand Down
24 changes: 24 additions & 0 deletions Classes/Domain/Model/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class Publication extends AbstractEntity
*/
protected string $journal = '';

/**
* @var string
*/
protected string $journalAbbr = '';

/**
* @var string
*/
Expand Down Expand Up @@ -291,6 +296,7 @@ class Publication extends AbstractEntity
'institute' => 'institute',
'booktitle' => 'booktitle',
'journal' => 'journal',
'journalAbbr' => 'journal_abbr',
'edition' => 'edition',
'volume' => 'volume',
'publisher' => 'publisher',
Expand Down Expand Up @@ -729,6 +735,14 @@ public function getJournal(): string
return $this->journal;
}

/**
* @return string
*/
public function getJournalAbbr(): string
{
return $this->journalAbbr;
}

/**
* @return string
*/
Expand Down Expand Up @@ -757,6 +771,16 @@ public function setJournal(string $journal): self
return $this;
}

/**
* @param string $journalAbbr
* @return Publication
*/
public function setJournalAbbr(string $journalAbbr): self
{
$this->journalAbbr = $journalAbbr;
return $this;
}

/**
* @return string
*/
Expand Down
15 changes: 15 additions & 0 deletions Classes/Domain/Repository/PublicationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected function filterQuery(QueryInterface $query, Filter $filter)
$and = $this->filterQueryByStatus($query, $filter, $and);
$and = $this->filterQueryByAuthor($query, $filter, $and);
$and = $this->filterQueryByExternFilter($query, $filter, $and);
$and = $this->filterQueryByReviewFilter($query, $filter, $and);
$and = $this->filterQueryByRecords($query, $filter, $and);
}
if ($filter->isFilterFrontendSet()) {
Expand Down Expand Up @@ -181,6 +182,20 @@ protected function filterQueryByExternFilter(QueryInterface $query, Filter $filt
return $and;
}

/**
* @param QueryInterface $query
* @param Filter $filter
* @param array $and
* @return array
*/
protected function filterQueryByReviewFilter(QueryInterface $query, Filter $filter, array $and): array
{
if ($filter->isReviewed()) {
$and[] = $query->equals('reviewed', ($filter->isReview() ? 0 : 1));
}
return $and;
}

/**
* @param QueryInterface $query
* @param Filter $filter
Expand Down
27 changes: 27 additions & 0 deletions Configuration/FlexForms/FlexFormPi1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,33 @@
</config>
</TCEforms>
</settings.extern>
<settings.review>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:publications/Resources/Private/Language/locallang_db.xlf:flexform.pi1.filter.review</label>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:publications/Resources/Private/Language/locallang_db.xlf:flexform.pi1.filter.review.0</numIndex>
<numIndex index="1">0</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:publications/Resources/Private/Language/locallang_db.xlf:flexform.pi1.filter.review.1</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:publications/Resources/Private/Language/locallang_db.xlf:flexform.pi1.filter.review.2</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
</items>
<size>1</size>
<minitems>0</minitems>
<maxitems>1</maxitems>
</config>
</TCEforms>
</settings.review>
<settings.records>
<TCEforms>
<exclude>1</exclude>
Expand Down
11 changes: 10 additions & 1 deletion Configuration/TCA/tx_publications_domain_model_publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
],
'palette_publishing' => [
'showitem' =>
'booktitle,journal,--linebreak--,edition,volume,--linebreak--,publisher,address,' .
'booktitle,--linebreak--,journal,journal_abbr,--linebreak--,edition,volume,--linebreak--,publisher,address,' .
'--linebreak--,chapter,series,--linebreak--,howpublished,editor,--linebreak--,pages,' .
'affiliation,--linebreak--,extern,'
],
Expand Down Expand Up @@ -377,6 +377,15 @@
'default' => ''
]
],
'journal_abbr' => [
'exclude' => true,
'label' => $llTable . '.journal_abbr',
'config' => [
'type' => 'input',
'eval' => 'trim',
'default' => ''
]
],
'year' => [
'exclude' => true,
'label' => $llTable . '.year',
Expand Down
5 changes: 5 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2019-08-01T12:00:00Z" product-name="publications">
<header/>
Expand Down Expand Up @@ -159,6 +160,10 @@
<source>Journal</source>
<target state="translated">Journal</target>
</trans-unit>
<trans-unit id="tx_publications_domain_model_publication.journal_abbr">
<source>Journal (Abbreviated)</source>
<target state="translated">Journal (Abgk.)</target>
</trans-unit>
<trans-unit id="tx_publications_domain_model_publication.year">
<source>Year</source>
<target state="translated">Jahr</target>
Expand Down
15 changes: 15 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<trans-unit id="tx_publications_domain_model_publication.journal">
<source>Journal</source>
</trans-unit>
<trans-unit id="tx_publications_domain_model_publication.journal_abbr">
<source>Journal (Abbreviated)</source>
</trans-unit>
<trans-unit id="tx_publications_domain_model_publication.year">
<source>Year</source>
</trans-unit>
Expand Down Expand Up @@ -406,6 +409,18 @@
<trans-unit id="flexform.pi1.filter.extern.2">
<source>Extern only</source>
</trans-unit>
<trans-unit id="flexform.pi1.filter.review">
<source>Reviewed</source>
</trans-unit>
<trans-unit id="flexform.pi1.filter.review.0">
<source>Show all</source>
</trans-unit>
<trans-unit id="flexform.pi1.filter.review.1">
<source>Non-Reviewed only</source>
</trans-unit>
<trans-unit id="flexform.pi1.filter.review.2">
<source>Reviewed only</source>
</trans-unit>
<trans-unit id="flexform.pi1.filter.records">
<source>Show publications from this pages only</source>
</trans-unit>
Expand Down
1 change: 1 addition & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE TABLE tx_publications_domain_model_publication (
title text NOT NULL,
abstract text,
journal varchar(255) DEFAULT '' NOT NULL,
journal_abbr varchar(255) DEFAULT '' NOT NULL,
year varchar(255) DEFAULT '' NOT NULL,
month varchar(255) DEFAULT '' NOT NULL,
day varchar(255) DEFAULT '' NOT NULL,
Expand Down