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

pkp/pkp-lib/issues/6201 Adapt to support OMP #79

Draft
wants to merge 6 commits into
base: stable-3_3_0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 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
288 changes: 238 additions & 50 deletions CitationStyleLanguagePlugin.inc.php

Large diffs are not rendered by default.

56 changes: 55 additions & 1 deletion CitationStyleLanguageSettingsForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class CitationStyleLanguageSettingsForm extends Form {
/** @var $plugin object */
public $plugin;

/** @var bool $isChapterFrontendPagePluginEnabled */
private bool $isChapterFrontendPagePluginEnabled;

/**
* Constructor
* @param $plugin object
Expand All @@ -29,6 +32,13 @@ public function __construct($plugin) {
$this->plugin = $plugin;
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
if ($this->plugin->isApplicationOmp()) {
$request = Application::get()->getRequest();
$context = $request->getContext();
$contextId = $context ? $context->getId() : 0;
$chapterPlugin = PluginRegistry::getPlugin('generic', 'chapterfrontendpageplugin');
$this->isChapterFrontendPagePluginEnabled = NULL !== $chapterPlugin && $chapterPlugin->getEnabled($contextId);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to remember, but I think you might run into timing issues here, because I think the order that plugins are registered can change. So you may run into cases where the CSL plugin is running its constructor before the chapter frontend plugin has been registered.

}
}

/**
Expand All @@ -42,6 +52,14 @@ public function initData() {
$this->setData('enabledCitationStyles', array_keys($this->plugin->getEnabledCitationStyles($contextId)));
$this->setData('enabledCitationDownloads', $this->plugin->getEnabledCitationDownloads($contextId));
$this->setData('publisherLocation', $this->plugin->getSetting($contextId, 'publisherLocation'));
$this->setData('groupAuthor', $this->plugin->getSetting($contextId, 'groupAuthor'));
$this->setData('groupTranslator', $this->plugin->getSetting($contextId, 'groupTranslator'));
if( $this->plugin->isApplicationOmp()){
$this->setData('groupEditor', $this->plugin->getSetting($contextId, 'groupEditor'));
if( $this->isChapterFrontendPagePluginEnabled ){
$this->setData('groupChapterAuthor', $this->plugin->getSetting($contextId, 'groupChapterAuthor'));
}
}
}

/**
Expand All @@ -53,7 +71,15 @@ public function readInputData() {
'enabledCitationStyles',
'enabledCitationDownloads',
'publisherLocation',
'groupAuthor',
'groupTranslator'
));
if( $this->plugin->isApplicationOmp()){
$this->readUserVars(['groupEditor']);
if( $this->isChapterFrontendPagePluginEnabled ){
$this->readUserVars(['groupChapterAuthor']);
}
}
}

/**
Expand All @@ -73,6 +99,13 @@ public function fetch($request, $template = null, $display = false) {
$allDownloads[$style['id']] = $style['title'];
}

$allUserGroups = [];
$userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
$userGroups = $userGroupDao->getByContextId($contextId);
while ($userGroup = $userGroups->next()) {
$allUserGroups[(int) $userGroup->getId()] = $userGroup->getLocalizedName();
}
NateWr marked this conversation as resolved.
Show resolved Hide resolved

$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array(
'pluginName' => $this->plugin->getName(),
Expand All @@ -81,7 +114,21 @@ public function fetch($request, $template = null, $display = false) {
'primaryCitationStyle' => $this->getData('primaryCitationStyle'),
'enabledStyles' => $this->plugin->mapCitationIds($this->plugin->getEnabledCitationStyles($contextId)),
'enabledDownloads' => $this->plugin->mapCitationIds($this->plugin->getEnabledCitationDownloads($contextId)),
'isApplicationOmp' => $this->plugin->isApplicationOmp(),
'groupAuthor' => $this->getData('groupAuthor') ? (int) $this->getData('groupAuthor') : 0,
'groupEditor' => $this->getData('groupEditor') ? (int) $this->getData('groupEditor') : 0,
'groupTranslator' => $this->getData('groupTranslator') ? (int) $this->getData('groupTranslator') : 0,
'allUserGroups' => $allUserGroups,
));
if( $this->plugin->isApplicationOmp()){
$templateMgr->assign([
'groupEditor' => $this->getData('groupEditor') ? (int) $this->getData('groupEditor') : 0,
'isChapterFrontendPagePluginEnabled' => $this->isChapterFrontendPagePluginEnabled
]);
if( $this->isChapterFrontendPagePluginEnabled ){
$templateMgr->assign(['groupChapterAuthor' => $this->getData('groupChapterAuthor') ? (int) $this->getData('groupChapterAuthor') : 0]);
}
}

return parent::fetch($request, $template, $display);
}
Expand All @@ -99,6 +146,14 @@ public function execute(...$functionArgs) {
$enabledCitationDownloads = $this->getData('enabledCitationDownloads') ? $this->getData('enabledCitationDownloads') : array();
$this->plugin->updateSetting($contextId, 'enabledCitationDownloads', $enabledCitationDownloads);
$this->plugin->updateSetting($contextId, 'publisherLocation', $this->getData('publisherLocation'));
$this->plugin->updateSetting($contextId, 'groupAuthor', $this->getData('groupAuthor'));
$this->plugin->updateSetting($contextId, 'groupTranslator', $this->getData('groupTranslator'));
if( $this->plugin->isApplicationOmp()){
$this->plugin->updateSetting($contextId, 'groupEditor', $this->getData('groupEditor'));
if( $this->isChapterFrontendPagePluginEnabled ){
$this->plugin->updateSetting($contextId, 'groupChapterAuthor', $this->getData('groupChapterAuthor'));
}
}

import('classes.notification.NotificationManager');
$notificationMgr = new NotificationManager();
Expand All @@ -108,4 +163,3 @@ public function execute(...$functionArgs) {
return parent::execute(...$functionArgs);
}
}

95 changes: 95 additions & 0 deletions css/citationStyleLanguagePlugin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.citation_display .csl-left-margin
{
display: none;
}

.citation_display [aria-hidden="true"]
{
display: none;
}

.citation_display .citation_formats
{
margin-top: 1em;
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 2px;
}

.citation_display .citation_formats_button
{
position: relative;
background: transparent;
border: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
box-shadow: none;
padding: 0 1em;
width: 100%;
min-height: 2.5em;
text-align: left;
}

.citation_display .citation_formats_button:after
{
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: "\f0d7";
position: absolute;
top: 50%;
right: 1em;
transform: translate(0, -50%);
}
.citation_display .citation_formats_button[aria-expanded="true"]:after
{
content: "\f0d8";
}

.citation_display .citation_formats_button:focus
{
outline: 0;
}

.citation_display .citation_formats_styles
{
margin: 0;
padding: 0;
list-style: none;
}

.citation_display .citation_formats_styles a
{
display: block;
padding: 0.5em 1em;
border-bottom: 1px solid #bbb;
text-decoration: none;
font-size: 0.75rem;
}

.citation_display .citation_formats_styles a:focus
{
outline: 0;
}

.citation_display .citation_formats_styles li:last-child a
{
border-bottom: none;
}

.citation_display .citation_formats_list .label
{
padding: 1em 1em 0.25em 1em;
}

.citation_display .citation_formats_styles + .label
{
border-top: 1px solid #bbb;
}

.citation_display span
{
margin-right: 0.5em;
}
43 changes: 43 additions & 0 deletions locale/de_DE/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ msgstr "Citation Style Language"
msgid "plugins.generic.citationStyleLanguage.description"
msgstr "Ermöglicht es Leser/innen, die bibliografischen Angaben für einen veröffentlichten Artikel in einem von mehreren Formaten in der Citation Style Language zu erhalten."

msgid "plugins.generic.citationStyleLanguage.description.omp"
msgstr "Ermöglicht es Leser/innen, die bibliografischen Angaben für ein veröffentlichtes Buch in einem von mehreren Formaten in der Citation Style Language zu erhalten."

msgid "plugins.generic.citationStyleLanguage.style.acm-sig-proceedings"
msgstr "ACM"

Expand Down Expand Up @@ -74,10 +77,50 @@ msgstr "Primäres Format für bibliographische Angaben"
msgid "plugins.generic.citationStyleLanguage.settings.citationFormatsPrimaryDescription"
msgstr "Wählen Sie aus, in welchem Format Sie bibliografische Angaben standardmäßig auf der Artikelseite anzeigen möchten."

msgid "plugins.generic.citationStyleLanguage.settings.citationFormatsPrimaryDescription.omp"
msgstr "Wählen Sie aus, in welchem Format Sie bibliografische Angaben standardmäßig auf der Buchseite anzeigen möchten."

msgid "plugins.generic.citationStyleLanguage.settings.publisherLocation.description"
msgstr ""
"Einige Zitierstile erfordern die Angabe des geografischen Standortes des "
"Verlags, wie zum Beispiel \"London, U.K.\"."

msgid "plugins.generic.citationStyleLanguage.settings.publisherLocation"
msgstr "Standort des Verlags"

msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroups"
msgstr "Autoren und Übersetzer"

msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroupsDescription"
msgstr "In manchen Fällen gibt es neben den Autoren noch Übersetzer. Wählen Sie bitte je eine Rolle für Autoren und Übersetzer."

msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroups.omp"
msgstr "Autoren, Herausgeber und Übersetzer"

msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroupsDescription.omp"
msgstr "In manchen Fällen gibt es neben den Autoren noch Herausgeber oder Übersetzer. Wählen Sie bitte je eine Rolle für Autoren, Herausgeber und Übersetzer."

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseAuthor"
msgstr "Autor:"

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseEditor"
msgstr "Herausgeber:"

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseTranslator"
msgstr "Übersetzer:"

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseChapterAuthor"
msgstr "Kapitelautor:"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseAuthor"
msgstr "Bitte wählen Sie eine Rolle für die Autoren"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseEditor"
msgstr "Bitte wählen Sie eine Rolle für die Herausgeber"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseTranslator"
msgstr "Bitte wählen Sie eine Rolle für die Übersetzer"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseChapterAuthor"
msgstr "Bitte wählen Sie eine Rolle für die Kapitelautoren"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't modify any locales except en_US when committing code like this. Instead, after this is merged, you'll need to provide the de_DE translations through weblate, our translation tool.

42 changes: 42 additions & 0 deletions locale/en_US/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ msgstr "Citation Style Language"
msgid "plugins.generic.citationStyleLanguage.description"
msgstr "Allow readers to get a published article's citation in one of several formats supported by the Citation Style Language."

msgid "plugins.generic.citationStyleLanguage.description.omp"
msgstr "Allow readers to get a published book's citation in one of several formats supported by the Citation Style Language."

msgid "plugins.generic.citationStyleLanguage.style.acm-sig-proceedings"
msgstr "ACM"

Expand Down Expand Up @@ -71,8 +74,47 @@ msgstr "Primary Citation Format"
msgid "plugins.generic.citationStyleLanguage.settings.citationFormatsPrimaryDescription"
msgstr "Select which citation format you would like to display by default on your article landing page."

msgid "plugins.generic.citationStyleLanguage.settings.citationFormatsPrimaryDescription.omp"
msgstr "Select which citation format you would like to display by default on your book landing page."

msgid "plugins.generic.citationStyleLanguage.settings.publisherLocation"
msgstr "Publisher Location"

msgid "plugins.generic.citationStyleLanguage.settings.publisherLocation.description"
msgstr "Some citation formats request the geographic location of the publisher, such as \"London, U.K.\"."

msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroups"
msgstr "Author and Translator"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's combine this and the OMP one into a single string that works for both:

Contributors


msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroupsDescription"
msgstr "In some cases beside authors there also exists translators. Please choose a role for authors and translators."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some citation styles, contributors must be identified differently depending on their role. Please identify the appropriate roles.


msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroups.omp"
msgstr "Author, Editor and Translator"

msgid "plugins.generic.citationStyleLanguage.settings.citationUserGroupsDescription.omp"
msgstr "In some cases beside authors there also exist editors or translators. Please choose a role for authors, editors and translators."

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseAuthor"
msgstr "Author:"

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseEditor"
msgstr "Editor:"

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseTranslator"
msgstr "Translator:"

msgid "plugins.generic.citationStyleLanguage.settings.citationChooseChapterAuthor"
msgstr "Chapter Author:"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the : from each of these strings and make each one plural:

  • Authors
  • Editors
  • Translators
  • Chapter Authors


msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseAuthor"
msgstr "Please choose a role for authors"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseEditor"
msgstr "Please choose a role for editors"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseTranslator"
msgstr "Please choose a role for translators"

msgid "plugins.generic.citationStyleLanguage.settings.citationOptionChooseChapterAuthor"
msgstr "Please choose a role for chapter authors"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible for for multiple user groups to be configured for each of these roles. I think we're going to need to adjust this to allow journals/presses to select multiple user groups for each role. Once changed, you can use the following text for each:

Select the roles that should be identified as authors.

Loading