Skip to content
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
8 changes: 7 additions & 1 deletion api/v1/reviews/PKPReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ public function getHistory(Request $illuminateRequest): JsonResponse
}

$publicationAbstract = $publication->getData('abstract');
$publicationKeywords = $publication->getData('keywords');
$publicationKeywords = collect($publication->getData('keywords'))
->map(
fn(array $items): array => collect($items)
->pluck("name")
->all()
)
->all();

$declineEmail = null;
if ($reviewAssignment->getDeclined()) {
Expand Down
4 changes: 1 addition & 3 deletions classes/components/forms/publication/PKPMetadataForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ protected function getVocabEntryData(string $symbolic): array
return Repo::controlledVocab()->getBySymbolic(
$symbolic,
Application::ASSOC_TYPE_PUBLICATION,
$this->publication->getId(),
[],
Repo::controlledVocab()::AS_ENTRY_DATA
$this->publication->getId()
);
}
}
2 changes: 0 additions & 2 deletions classes/controlledVocab/ControlledVocab.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ControlledVocab extends Model
public const CONTROLLED_VOCAB_SUBMISSION_AGENCY = 'submissionAgency';
public const CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE = 'submissionDiscipline';
public const CONTROLLED_VOCAB_SUBMISSION_KEYWORD = 'submissionKeyword';
public const CONTROLLED_VOCAB_SUBMISSION_LANGUAGE = 'submissionLanguage';
public const CONTROLLED_VOCAB_SUBMISSION_SUBJECT = 'submissionSubject';

/**
Expand Down Expand Up @@ -91,7 +90,6 @@ public static function getDefinedVocabSymbolic(): array
static::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
static::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
static::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
static::CONTROLLED_VOCAB_SUBMISSION_LANGUAGE,
static::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
];
}
Expand Down
43 changes: 7 additions & 36 deletions classes/controlledVocab/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

class Repository
{

const AS_ENTRY_DATA = true;

/**
Expand Down Expand Up @@ -51,9 +52,8 @@ public function getBySymbolic(
int $assocType,
?int $assocId,
?array $locales = [],
bool $asEntryData = !Repository::AS_ENTRY_DATA
): array
{
bool $asEntryData = Repository::AS_ENTRY_DATA
): array {
$result = [];

ControlledVocabEntry::query()
Expand All @@ -65,10 +65,12 @@ public function getBySymbolic(
->get()
->each(function ($entry) use (&$result, $asEntryData) {
foreach ($entry->name as $locale => $value) {
$result[$locale][] = $asEntryData ? $entry->getEntryData($locale) : $value;
$result[$locale][] = $asEntryData
? $entry->getEntryData($locale)
: $value;
}
});

return $result;
}

Expand Down Expand Up @@ -141,35 +143,4 @@ public function resequence(int $controlledVocabId): void
});
}

/**
* Hydrate controlled vocab entries as entry data for a publication which will
* include other meta information(e.g. source & identifier) in vocabs
*/
public function hydrateVocabsAsEntryData(PKPPublication $publication): PKPPublication
{
$mappings = [
'keywords' => ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
'subjects' => ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
'disciplines' => ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
'supportingAgencies' => ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
];

foreach ($mappings as $dataKey => $symbolic) {
if (empty($publication->getData($dataKey))) {
continue;
}
$publication->setData(
$dataKey,
$this->getBySymbolic(
$symbolic,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId(),
[],
static::AS_ENTRY_DATA
)
);
}

return $publication;
}
}
1 change: 0 additions & 1 deletion classes/publication/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ public function edit(Publication $publication, array $params): Publication
}
}

$publication = Repo::controlledVocab()->hydrateVocabsAsEntryData($publication);
$newPublication = Repo::publication()->newDataObject(array_merge($publication->_data, $params));
$newPublication->stampModified();

Expand Down
1 change: 0 additions & 1 deletion classes/publication/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function summarizeMany(Enumerable $collection, bool $anonymize = false):
*/
protected function mapByProperties(array $props, Publication $publication, bool $anonymize): array
{
$publication = Repo::controlledVocab()->hydrateVocabsAsEntryData($publication);
$this->anonymize = $anonymize;

$output = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,19 @@ public function handleChildElement($n, $publication)

for ($nc = $n->firstChild; $nc !== null; $nc = $nc->nextSibling) {
if ($nc instanceof \DOMElement) {
$controlledVocabulary[] = $nc->textContent;
$item = ['name' => $nc->getElementsByTagName('name')->item(0)->textContent];

$identifierNode = $nc->getElementsByTagName('identifier')->item(0);
if ($identifierNode) {
$item['identifier'] = $identifierNode->textContent;
}

$sourceNode = $nc->getElementsByTagName('source')->item(0);
if ($sourceNode) {
$item['source'] = $sourceNode->textContent;
}

$controlledVocabulary[] = $item;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ public function addMetadata($doc, $entityNode, $entity)

// add controlled vocabularies
// get the supported locale keys
# f11557
# TODO native XML
$controlledVocabulariesMapping = $this->_getControlledVocabulariesMappings();
foreach ($controlledVocabulariesMapping as $controlledVocabulariesNodeName => $mappings) {
$symbolic = $mappings[0];
Expand All @@ -239,12 +241,22 @@ public function addControlledVocabulary($doc, $entityNode, $controlledVocabulari
{
$deployment = $this->getDeployment();
$locales = array_keys($controlledVocabulary);

foreach ($locales as $locale) {
if (!empty($controlledVocabulary[$locale])) {
$controlledVocabulariesNode = $doc->createElementNS($deployment->getNamespace(), $controlledVocabulariesNodeName);
$controlledVocabulariesNode->setAttribute('locale', $locale);
foreach ($controlledVocabulary[$locale] as $controlledVocabularyItem) {
$controlledVocabulariesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), $controlledVocabularyNodeName, htmlspecialchars($controlledVocabularyItem, ENT_COMPAT, 'UTF-8')));

foreach ($controlledVocabulary[$locale] as $item) {
$node = $doc->createElementNS($deployment->getNamespace(), $controlledVocabularyNodeName);
$node->appendChild($doc->createElementNS($deployment->getNamespace(), 'name', htmlspecialchars($item['name'], ENT_COMPAT, 'UTF-8')));
if (!empty($item['identifier'])) {
$node->appendChild($doc->createElementNS($deployment->getNamespace(), 'identifier', htmlspecialchars($item['identifier'], ENT_COMPAT, 'UTF-8')));
}
if (!empty($item['source'])) {
$node->appendChild($doc->createElementNS($deployment->getNamespace(), 'source', htmlspecialchars($item['source'], ENT_COMPAT, 'UTF-8')));
}
$controlledVocabulariesNode->appendChild($node);
}

$entityNode->appendChild($controlledVocabulariesNode);
Expand Down
23 changes: 15 additions & 8 deletions plugins/importexport/native/pkp-native.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -356,20 +356,27 @@
<element name="pkppublication" type="pkp:pkppublication" />

<!-- Controlled vocabularies -->
<complexType name="ControlledVocabEntryType">
<sequence>
<element name="name" type="string"/>
<element name="identifier" type="string" minOccurs="0"/>
<element name="source" type="string" minOccurs="0"/>
</sequence>
</complexType>
<element name="keywords">
<complexType>
<sequence>
<element name="keyword" type="string" minOccurs="1" maxOccurs="unbounded" />
<element name="keyword" type="pkp:ControlledVocabEntryType" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="locale" type="string" />
<attribute name="locale" type="string"/>
</complexType>
</element>
<element name="agencies">
<complexType>
<sequence>
<element name="agency" type="string" minOccurs="1" maxOccurs="unbounded" />
<element name="keyword" type="pkp:ControlledVocabEntryType" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="locale" type="string" />
<attribute name="locale" type="string"/>
</complexType>
</element>
<element name="languages">
Expand All @@ -383,17 +390,17 @@
<element name="disciplines">
<complexType>
<sequence>
<element name="discipline" type="string" minOccurs="1" maxOccurs="unbounded" />
<element name="keyword" type="pkp:ControlledVocabEntryType" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="locale" type="string" />
<attribute name="locale" type="string"/>
</complexType>
</element>
<element name="subjects">
<complexType>
<sequence>
<element name="subject" type="string" minOccurs="1" maxOccurs="unbounded" />
<element name="keyword" type="pkp:ControlledVocabEntryType" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="locale" type="string" />
<attribute name="locale" type="string"/>
</complexType>
</element>
<element name="citations">
Expand Down